VirtualBox

Changeset 44196 in vbox for trunk/src


Ignore:
Timestamp:
Dec 21, 2012 12:02:47 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82932
Message:

crOpenGL: glGetError fixes

Location:
trunk/src/VBox
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h

    r44108 r44196  
    226226DECLEXPORT(GLboolean) crStateEnableDiffOnMakeCurrent(GLboolean fEnable);
    227227
    228 void crStateSwichPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
    229 void crStateSwichPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
     228void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
     229void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
     230
     231void crStateSyncHWErrorState(CRContext *ctx);
    230232
    231233DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_version.h

    r43349 r44196  
    99
    1010#define SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS       28
     11/* version which might have context usage bits saved */
     12#define SHCROGL_SSM_VERSION_WITH_SAVED_CTXUSAGE_BITS   SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS
    1113#define SHCROGL_SSM_VERSION_BEFORE_FRONT_DRAW_TRACKING 29
    12 #define SHCROGL_SSM_VERSION                            30
     14/* version that might have corrupted state data */
     15#define SHCROGL_SSM_VERSION_WITH_CORUPTED_STATE        30
     16/* version with invalid glGetError state */
     17#define SHCROGL_SSM_VERSION_WITH_INVALID_ERROR_STATE   30
     18#define SHCROGL_SSM_VERSION                            31
    1319
    1420/* These define the Chromium release number.
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c

    r43980 r44196  
    346346}
    347347
    348 void crStateSwichPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
    349 {
     348void crStateSyncHWErrorState(CRContext *ctx)
     349{
     350    GLenum err;
     351    while ((err = diff_api.GetError()) != GL_NO_ERROR)
     352    {
     353        if (ctx->error != GL_NO_ERROR)
     354            ctx->error = err;
     355    }
     356}
     357
     358void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
     359{
     360    if (!fromCtx)
     361        return;
     362
     363    if (g_bVBoxEnableDiffOnMakeCurrent && toCtx && toCtx != fromCtx)
     364        crStateSyncHWErrorState(fromCtx);
     365
    350366#ifdef CR_EXT_framebuffer_object
    351     if (fromCtx)
    352         crStateFramebufferObjectDisableHW(fromCtx, idDrawFBO, idReadFBO);
    353 #endif
    354 }
    355 
    356 void crStateSwichPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
    357 {
    358     if (!fromCtx || !toCtx)
     367    crStateFramebufferObjectDisableHW(fromCtx, idDrawFBO, idReadFBO);
     368#endif
     369}
     370
     371void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
     372{
     373    if (!toCtx)
    359374        return;
    360375
     376    if (g_bVBoxEnableDiffOnMakeCurrent && fromCtx && toCtx != fromCtx)
     377    {
     378        GLenum err;
     379        while ((err = diff_api.GetError()) != GL_NO_ERROR)
     380        {
     381            crWarning("gl error (0x%x) after context switch, ignoring..", err);
     382        }
     383    }
    361384#ifdef CR_EXT_framebuffer_object
    362385    crStateFramebufferObjectReenableHW(fromCtx, toCtx, idDrawFBO, idReadFBO);
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c

    r31487 r44196  
    1919        va_list args;
    2020
    21         g->error = error;
     21        CRASSERT(error != GL_NO_ERROR);
    2222
     23        if (g->error == GL_NO_ERROR)
     24            g->error = error;
     25
     26#ifndef DEBUG_misha
    2327        if (crGetenv("CR_DEBUG"))
     28#endif
    2429        {
    2530                char *glerr;
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c

    r44125 r44196  
    10741074{
    10751075    GLuint idReadBuffer = 0, idDrawBuffer = 0;
     1076    if (!fromCtx)
     1077        fromCtx = toCtx; /* <- in case fromCtx is zero, set it to toCtx to ensure framebuffer state gets re-enabled correctly */
    10761078
    10771079    if ((fromCtx->framebufferobject.drawFB) /* <- the FBO state was reset in crStateFramebufferObjectDisableHW */
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c

    r27091 r44196  
    181181    if (!p && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
    182182    {
    183         crStateError(__LINE__, __FILE__, GL_NO_ERROR,
    184                 "Void pointer passed to PolygonStipple");
     183        crDebug("Void pointer passed to PolygonStipple");
    185184        return;
    186185    }
  • 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*/
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_blitter.cpp

    r43980 r44196  
    407407                pBlitter->pRestoreCtxInfo->SpuContext >= 0
    408408                    ? pBlitter->pRestoreCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext);
    409         crStateSwichPostprocess(pBlitter->pRestoreCtxInfo->pContext, pBlitter->pRestoreCtxInfo->pContext, idDrawFBO, idReadFBO);
     409        crStateSwitchPostprocess(pBlitter->pRestoreCtxInfo->pContext, NULL, idDrawFBO, idReadFBO);
    410410    }
    411411    else
     
    448448            idReadFBO = 0;
    449449        }
    450         crStateSwichPrepare(NULL, pRestoreCtxInfo->pContext, idDrawFBO, idReadFBO);
     450        crStateSwitchPrepare(NULL, pRestoreCtxInfo->pContext, idDrawFBO, idReadFBO);
    451451
    452452        cr_server.head_spu->dispatch_table.Flush();
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c

    r43980 r44196  
    140140    }
    141141
    142     {
    143         /* As we're using only one host context to serve all client contexts, newly created context will still
    144          * hold last error value from any previous failed opengl call. Proper solution would be to redirect any
    145          * client glGetError calls to our state tracker, but right now it's missing quite a lot of checks and doesn't
    146          * reflect host driver/gpu specific issues. Thus we just reset last opengl error at context creation.
    147          */
    148         GLint err;
    149 
    150         err = cr_server.head_spu->dispatch_table.GetError();
    151         if (err!=GL_NO_ERROR)
    152         {
    153 #ifdef DEBUG_misha
    154             crDebug("Cleared gl error %#x on context creation", err);
    155 #else
    156             crWarning("Cleared gl error %#x on context creation", err);
    157 #endif
    158         }
    159     }
    160 
    161142    crServerReturnValue( &retVal, sizeof(retVal) );
    162143
     
    330311    /* Ubuntu 11.04 hosts misbehave if context window switch is
    331312     * done with non-default framebuffer object settings.
    332      * crStateSwichPrepare & crStateSwichPostprocess are supposed to work around this problem
    333      * crStateSwichPrepare restores the FBO state to its default values before the context window switch,
    334      * while crStateSwichPostprocess restores it back to the original values */
     313     * crStateSwitchPrepare & crStateSwitchPostprocess are supposed to work around this problem
     314     * crStateSwitchPrepare restores the FBO state to its default values before the context window switch,
     315     * while crStateSwitchPostprocess restores it back to the original values */
    335316    oldCtx = crStateGetCurrent();
    336317    if (oldMural && oldMural->fUseFBO && crServerSupportRedirMuralFBO())
     
    344325        idReadFBO = 0;
    345326    }
    346     crStateSwichPrepare(cr_server.bUseMultipleContexts ? NULL : ctx, oldCtx, idDrawFBO, idReadFBO);
     327    crStateSwitchPrepare(cr_server.bUseMultipleContexts ? NULL : ctx, oldCtx, idDrawFBO, idReadFBO);
    347328
    348329    /*
     
    431412        idReadFBO = 0;
    432413    }
    433     crStateSwichPostprocess(ctx, cr_server.bUseMultipleContexts ? ctx : oldCtx, idDrawFBO, idReadFBO);
     414    crStateSwitchPostprocess(ctx, cr_server.bUseMultipleContexts ? NULL : oldCtx, idDrawFBO, idReadFBO);
    434415
    435416    if (!ctx->framebufferobject.drawFB
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r43999 r44196  
    761761
    762762#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
     763    CRASSERT(cr_server.curClient);
    763764    if (cr_server.curClient)
    764765    {
    765         unsigned long id;
    766         if (!crHashtableGetDataKey(cr_server.contextTable, pContextInfo, &id))
    767         {
    768             crWarning("No client id for server ctx %d", pContext->id);
    769         }
    770         else
    771         {
    772             crServerDispatchMakeCurrent(cr_server.curClient->currentWindow, 0, id);
    773         }
     766# ifdef DEBUG_misha
     767        {
     768            unsigned long id;
     769            if (!crHashtableGetDataKey(cr_server.contextTable, pContextInfo, &id))
     770                crWarning("No client id for server ctx %d", pContext->id);
     771            else
     772                CRASSERT(id == key);
     773        }
     774# endif
     775        crServerDispatchMakeCurrent(cr_server.curClient->currentWindow, 0, key);
    774776    }
    775777#endif
     
    778780    CRASSERT(rc == VINF_SUCCESS);
    779781}
     782
     783#if 0
     784typedef struct CR_SERVER_CHECK_BUFFERS
     785{
     786    CRBufferObject *obj;
     787    CRContext *ctx;
     788}CR_SERVER_CHECK_BUFFERS, *PCR_SERVER_CHECK_BUFFERS;
     789
     790static void crVBoxServerCheckConsistencyContextBuffersCB(unsigned long key, void *data1, void *data2)
     791{
     792    CRContextInfo* pContextInfo = (CRContextInfo*)data1;
     793    CRContext *ctx = pContextInfo->pContext;
     794    PCR_SERVER_CHECK_BUFFERS pBuffers = (PCR_SERVER_CHECK_BUFFERS)data2;
     795    CRBufferObject *obj = pBuffers->obj;
     796    CRBufferObjectState *b = &(ctx->bufferobject);
     797    int j, k;
     798
     799    if (obj == b->arrayBuffer)
     800    {
     801        Assert(!pBuffers->ctx || pBuffers->ctx == ctx);
     802        pBuffers->ctx = ctx;
     803    }
     804    if (obj == b->elementsBuffer)
     805    {
     806        Assert(!pBuffers->ctx || pBuffers->ctx == ctx);
     807        pBuffers->ctx = ctx;
     808    }
     809#ifdef CR_ARB_pixel_buffer_object
     810    if (obj == b->packBuffer)
     811    {
     812        Assert(!pBuffers->ctx || pBuffers->ctx == ctx);
     813        pBuffers->ctx = ctx;
     814    }
     815    if (obj == b->unpackBuffer)
     816    {
     817        Assert(!pBuffers->ctx || pBuffers->ctx == ctx);
     818        pBuffers->ctx = ctx;
     819    }
     820#endif
     821
     822#ifdef CR_ARB_vertex_buffer_object
     823    for (j=0; j<CRSTATECLIENT_MAX_VERTEXARRAYS; ++j)
     824    {
     825        CRClientPointer *cp = crStateGetClientPointerByIndex(j, &ctx->client.array);
     826        if (obj == cp->buffer)
     827        {
     828            Assert(!pBuffers->ctx || pBuffers->ctx == ctx);
     829            pBuffers->ctx = ctx;
     830        }
     831    }
     832
     833    for (k=0; k<ctx->client.vertexArrayStackDepth; ++k)
     834    {
     835        CRVertexArrays *pArray = &ctx->client.vertexArrayStack[k];
     836        for (j=0; j<CRSTATECLIENT_MAX_VERTEXARRAYS; ++j)
     837        {
     838            CRClientPointer *cp = crStateGetClientPointerByIndex(j, pArray);
     839            if (obj == cp->buffer)
     840            {
     841                Assert(!pBuffers->ctx || pBuffers->ctx == ctx);
     842                pBuffers->ctx = ctx;
     843            }
     844        }
     845    }
     846#endif
     847}
     848
     849static void crVBoxServerCheckConsistencyBuffersCB(unsigned long key, void *data1, void *data2)
     850{
     851    CRBufferObject *obj = (CRBufferObject *)data1;
     852    CR_SERVER_CHECK_BUFFERS Buffers = {0};
     853    Buffers.obj = obj;
     854    crHashtableWalk(cr_server.contextTable, crVBoxServerCheckConsistencyContextBuffersCB, (void*)&Buffers);
     855}
     856
     857//static void crVBoxServerCheckConsistency2CB(unsigned long key, void *data1, void *data2)
     858//{
     859//    CRContextInfo* pContextInfo1 = (CRContextInfo*)data1;
     860//    CRContextInfo* pContextInfo2 = (CRContextInfo*)data2;
     861//
     862//    CRASSERT(pContextInfo1->pContext);
     863//    CRASSERT(pContextInfo2->pContext);
     864//
     865//    if (pContextInfo1 == pContextInfo2)
     866//    {
     867//        CRASSERT(pContextInfo1->pContext == pContextInfo2->pContext);
     868//        return;
     869//    }
     870//
     871//    CRASSERT(pContextInfo1->pContext != pContextInfo2->pContext);
     872//    CRASSERT(pContextInfo1->pContext->shared);
     873//    CRASSERT(pContextInfo2->pContext->shared);
     874//    CRASSERT(pContextInfo1->pContext->shared == pContextInfo2->pContext->shared);
     875//    if (pContextInfo1->pContext->shared != pContextInfo2->pContext->shared)
     876//        return;
     877//
     878//    crHashtableWalk(pContextInfo1->pContext->shared->buffersTable, crVBoxServerCheckConsistencyBuffersCB, pContextInfo2);
     879//}
     880static void crVBoxServerCheckSharedCB(unsigned long key, void *data1, void *data2)
     881{
     882    CRContextInfo* pContextInfo = (CRContextInfo*)data1;
     883    void **ppShared = (void**)data2;
     884    if (!*ppShared)
     885        *ppShared = pContextInfo->pContext->shared;
     886    else
     887        Assert(pContextInfo->pContext->shared == *ppShared);
     888}
     889
     890static void crVBoxServerCheckConsistency()
     891{
     892    CRSharedState *pShared = NULL;
     893    crHashtableWalk(cr_server.contextTable, crVBoxServerCheckSharedCB, (void*)&pShared);
     894    Assert(pShared);
     895    if (pShared)
     896    {
     897        crHashtableWalk(pShared->buffersTable, crVBoxServerCheckConsistencyBuffersCB, NULL);
     898    }
     899}
     900#endif
    780901
    781902static uint32_t g_hackVBoxServerSaveLoadCallsLeft = 0;
     
    787908    GLboolean b;
    788909    unsigned long key;
     910    GLenum err;
    789911#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
    790912    unsigned long ctxID=-1, winID=-1;
     913#endif
     914
     915#if 0
     916    crVBoxServerCheckConsistency();
    791917#endif
    792918
     
    9041030    }
    9051031
     1032    /* all context gl error states should have now be synced with chromium erro states,
     1033     * reset the error if any */
     1034    while ((err = cr_server.head_spu->dispatch_table.GetError()) != GL_NO_ERROR)
     1035        crWarning("crServer: glGetError %d after saving snapshot", err);
     1036
    9061037    cr_server.bIsInSavingState = GL_FALSE;
    9071038
     
    9221053    uint32_t ui, uiNumElems;
    9231054    unsigned long key;
     1055    GLenum err;
    9241056
    9251057    if (!cr_server.bIsInLoadingState)
     
    12001332    cr_server.curClient = NULL;
    12011333
    1202     {
    1203         GLenum err = crServerDispatchGetError();
    1204 
    1205         if (err != GL_NO_ERROR)
    1206         {
    1207             crWarning("crServer: glGetError %d after loading snapshot", err);
    1208         }
    1209     }
     1334    while ((err = cr_server.head_spu->dispatch_table.GetError()) != GL_NO_ERROR)
     1335        crWarning("crServer: glGetError %d after loading snapshot", err);
    12101336
    12111337    cr_server.bIsInLoadingState = GL_FALSE;
     1338
     1339#if 0
     1340    crVBoxServerCheckConsistency();
     1341#endif
    12121342
    12131343    return VINF_SUCCESS;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r43980 r44196  
    948948    cr_server.head_spu->dispatch_table.ReadBuffer( mode );
    949949}
     950
     951GLenum SERVER_DISPATCH_APIENTRY crServerDispatchGetError( void )
     952{
     953    GLenum retval, err;
     954    CRContext *ctx = crStateGetCurrent();
     955    retval = ctx->error;
     956
     957    err = cr_server.head_spu->dispatch_table.GetError();
     958    if (retval == GL_NO_ERROR)
     959        retval = err;
     960    else
     961        ctx->error = GL_NO_ERROR;
     962
     963    /* our impl has a single error flag, so we just loop here to reset all error flags to no_error */
     964    while (err != GL_NO_ERROR)
     965        err = cr_server.head_spu->dispatch_table.GetError();
     966
     967    crServerReturnValue( &retval, sizeof(retval) );
     968    return retval; /* WILL PROBABLY BE IGNORED */
     969}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_special

    r43888 r44196  
    250250ReadBuffer
    251251TexPresent
     252GetError
Note: See TracChangeset for help on using the changeset viewer.

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