VirtualBox

Ignore:
Timestamp:
Dec 21, 2012 12:02:47 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: glGetError fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c

    r44048 r44196  
    13221322    CRASSERT(VBoxTlsRefIsFunctional(pContext));
    13231323
    1324     /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */
    1325     rc = SSMR3PutMem(pSSM, pContext, VBOXTLSREFDATA_OFFSET(CRContext));
    1326     AssertRCReturn(rc, rc);
    1327 
    1328     /* now store bitid & neg_bitid */
    1329     rc = SSMR3PutMem(pSSM, pContext->bitid, sizeof (pContext->bitid) + sizeof (pContext->neg_bitid));
    1330     AssertRCReturn(rc, rc);
    1331 
    1332     /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */
    1333     ui32 = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pContext->bitid) + sizeof (pContext->neg_bitid);
    1334     ui32 &= (sizeof (void*) - 1);
    1335     if (ui32)
    1336     {
    1337         void* pTmp = NULL;
    1338         rc = SSMR3PutMem(pSSM, &pTmp, ui32);
    1339         AssertRCReturn(rc, rc);
    1340     }
    1341 
    1342     rc = SSMR3PutMem(pSSM, &pContext->shared, sizeof (CRContext) - RT_OFFSETOF(CRContext, shared));
     1324    /* make sure the gl error state is captured by our state mechanism to store the correct gl  error value */
     1325    crStateSyncHWErrorState(pContext);
     1326
     1327    rc = SSMR3PutMem(pSSM, pContext, sizeof (*pContext));
    13431328    AssertRCReturn(rc, rc);
    13441329
     
    17121697    unsigned long key;
    17131698    GLboolean bLoadShared = GL_TRUE;
    1714     union {
    1715         CRbitvalue bitid[CR_MAX_BITARRAY];
    1716         struct {
    1717             VBOXTLSREFDATA
    1718         } tlsRef;
    1719     } bitid;
     1699    GLenum err;
    17201700
    17211701    CRASSERT(pContext && pSSM);
     
    17281708    CRASSERT(VBoxTlsRefIsFunctional(pContext));
    17291709
    1730     /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */
    1731     rc = SSMR3GetMem(pSSM, pTmpContext, VBOXTLSREFDATA_OFFSET(CRContext));
    1732     AssertRCReturn(rc, rc);
    1733 
    1734     /* VBox 4.1.8 had a bug that VBOXTLSREFDATA was also stored in the snapshot,
    1735      * thus the saved state data format was changed w/o changing the saved state version.
    1736      * here we determine whether the saved state contains VBOXTLSREFDATA, and if so, treat it accordingly */
    1737     rc = SSMR3GetMem(pSSM, &bitid, sizeof (bitid));
    1738     AssertRCReturn(rc, rc);
    1739 
    1740     /* the bitid array has one bit set only. this is why if bitid.tlsRef has both cTlsRefs
    1741      * and enmTlsRefState non-zero - this is definitely NOT a bit id and is a VBOXTLSREFDATA */
    1742     if (bitid.tlsRef.enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED
    1743             && bitid.tlsRef.cTlsRefs)
    1744     {
    1745         /* VBOXTLSREFDATA is stored, skip it */
    1746         crMemcpy(&pTmpContext->bitid, ((uint8_t*)&bitid) + VBOXTLSREFDATA_SIZE(), sizeof (bitid) - VBOXTLSREFDATA_SIZE());
    1747         rc = SSMR3GetMem(pSSM, ((uint8_t*)&pTmpContext->bitid) + sizeof (pTmpContext->bitid) - VBOXTLSREFDATA_SIZE(), sizeof (pTmpContext->neg_bitid) + VBOXTLSREFDATA_SIZE());
    1748         AssertRCReturn(rc, rc);
    1749 
    1750         ui = VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid);
    1751         ui = RT_OFFSETOF(CRContext, shared) - ui;
     1710    if (u32Version <= SHCROGL_SSM_VERSION_WITH_INVALID_ERROR_STATE)
     1711    {
     1712        union {
     1713            CRbitvalue bitid[CR_MAX_BITARRAY];
     1714            struct {
     1715                VBOXTLSREFDATA
     1716            } tlsRef;
     1717        } bitid;
     1718
     1719        /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */
     1720        rc = SSMR3GetMem(pSSM, pTmpContext, VBOXTLSREFDATA_OFFSET(CRContext));
     1721        AssertRCReturn(rc, rc);
     1722
     1723        /* VBox 4.1.8 had a bug that VBOXTLSREFDATA was also stored in the snapshot,
     1724         * thus the saved state data format was changed w/o changing the saved state version.
     1725         * here we determine whether the saved state contains VBOXTLSREFDATA, and if so, treat it accordingly */
     1726        rc = SSMR3GetMem(pSSM, &bitid, sizeof (bitid));
     1727        AssertRCReturn(rc, rc);
     1728
     1729        /* the bitid array has one bit set only. this is why if bitid.tlsRef has both cTlsRefs
     1730         * and enmTlsRefState non-zero - this is definitely NOT a bit id and is a VBOXTLSREFDATA */
     1731        if (bitid.tlsRef.enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED
     1732                && bitid.tlsRef.cTlsRefs)
     1733        {
     1734            /* VBOXTLSREFDATA is stored, skip it */
     1735            crMemcpy(&pTmpContext->bitid, ((uint8_t*)&bitid) + VBOXTLSREFDATA_SIZE(), sizeof (bitid) - VBOXTLSREFDATA_SIZE());
     1736            rc = SSMR3GetMem(pSSM, ((uint8_t*)&pTmpContext->bitid) + sizeof (pTmpContext->bitid) - VBOXTLSREFDATA_SIZE(), sizeof (pTmpContext->neg_bitid) + VBOXTLSREFDATA_SIZE());
     1737            AssertRCReturn(rc, rc);
     1738
     1739            ui = VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid);
     1740            ui = RT_OFFSETOF(CRContext, shared) - ui;
     1741        }
     1742        else
     1743        {
     1744            /* VBOXTLSREFDATA is NOT stored */
     1745            crMemcpy(&pTmpContext->bitid, &bitid, sizeof (bitid));
     1746            rc = SSMR3GetMem(pSSM, &pTmpContext->neg_bitid, sizeof (pTmpContext->neg_bitid));
     1747            AssertRCReturn(rc, rc);
     1748
     1749            /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */
     1750            ui = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid);
     1751
     1752            ui &= (sizeof (void*) - 1);
     1753        }
     1754
     1755        if (ui)
     1756        {
     1757            void* pTmp = NULL;
     1758            rc = SSMR3GetMem(pSSM, &pTmp, ui);
     1759            AssertRCReturn(rc, rc);
     1760        }
     1761
     1762        if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS)
     1763        {
     1764            SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib);
     1765            rc = crStateLoadAttribState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->attrib, pSSM);
     1766            AssertRCReturn(rc, rc);
     1767            SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer);
     1768            SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, texture);
     1769            rc = crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->texture, pSSM);
     1770            AssertRCReturn(rc, rc);
     1771            SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, texture, transform);
     1772            SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, transform);
     1773        }
     1774        else
     1775        {
     1776            SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, shared);
     1777        }
     1778
     1779        pTmpContext->error = GL_NO_ERROR; /* <- the error state contained some random error data here
     1780                                                   * treat as no error */
    17521781    }
    17531782    else
    17541783    {
    1755         /* VBOXTLSREFDATA is NOT stored */
    1756         crMemcpy(&pTmpContext->bitid, &bitid, sizeof (bitid));
    1757         rc = SSMR3GetMem(pSSM, &pTmpContext->neg_bitid, sizeof (pTmpContext->neg_bitid));
    1758         AssertRCReturn(rc, rc);
    1759 
    1760         /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */
    1761         ui = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid);
    1762 
    1763         ui &= (sizeof (void*) - 1);
    1764     }
    1765 
    1766     if (ui)
    1767     {
    1768         void* pTmp = NULL;
    1769         rc = SSMR3GetMem(pSSM, &pTmp, ui);
    1770         AssertRCReturn(rc, rc);
    1771     }
     1784        rc = SSMR3GetMem(pSSM, pTmpContext, sizeof (*pTmpContext));
     1785        AssertRCReturn(rc, rc);
     1786    }
     1787
     1788    /* preserve the error to restore it at the end of context creation,
     1789     * it should not normally change, but just in case it it changed */
     1790    err = pTmpContext->error;
    17721791
    17731792    /* we will later do crMemcpy from entire pTmpContext to pContext,
    17741793     * for simplicity store the VBOXTLSREFDATA from the pContext to pTmpContext */
    17751794    VBOXTLSREFDATA_COPY(pTmpContext, pContext);
    1776 
    1777     if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS)
    1778     {
    1779         SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib);
    1780         rc = crStateLoadAttribState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->attrib, pSSM);
    1781         AssertRCReturn(rc, rc);
    1782         SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer);
    1783         SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, texture);
    1784         rc = crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->texture, pSSM);
    1785         AssertRCReturn(rc, rc);
    1786         SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, texture, transform);
    1787         SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, transform);
    1788     }
    1789     else
    1790     {
    1791         SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, shared);
    1792     }
    17931795
    17941796    /* Deal with shared state */
     
    22612263            AssertRCReturn(rc, rc);
    22622264
     2265            Assert(key == pFBO->id);
     2266
    22632267            crHashtableAdd(pContext->shared->fbTable, key, pFBO);
    22642268        }
     
    24572461    }
    24582462
     2463    if (pContext->error != err)
     2464    {
     2465        crWarning("context error state changed on context restore, was 0x%x, but became 0x%x, resetting to its original value",
     2466                err, pContext->error);
     2467        pContext->error = err;
     2468    }
    24592469
    24602470    /*Mark all as dirty to make sure we'd restore correct context state*/
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette