VirtualBox

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

crOpenGL: glGetError fixes

Location:
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 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.

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