VirtualBox

Changeset 44746 in vbox


Ignore:
Timestamp:
Feb 19, 2013 11:05:23 AM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: saved state fixes

Location:
trunk/src/VBox
Files:
3 edited

Legend:

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

    r44740 r44746  
    247247void CrHlpFreeTexImage(CRContext *pCurCtx, GLuint idPBO, void *pvData);
    248248void* CrHlpGetTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLuint idPBO);
     249void CrHlpPutTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, void *pvData);
    249250
    250251/* */
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r44744 r44746  
    154154     * and generally this should be zeroed up */
    155155    cr_server.currentCtxInfo = NULL;
    156     cr_server.currentWindow = NULL;
     156    cr_server.currentWindow = 0;
    157157    cr_server.currentNativeWindow = 0;
    158158    cr_server.currentMural = NULL;
     
    992992        CRASSERT(cMurals + Data.cAdditionalMurals + crHashtableNumElements(pGlobal->additionalMuralContextTable) == crHashtableNumElements(cr_server.muralTable) - 1);
    993993    }
     994
     995    crFreeHashtable(Data.usedMuralTable, NULL);
    994996}
    995997
     
    10381040        GLuint idPBO = cr_server.bUsePBOForReadback ? pMural->idPBO : 0;
    10391041
     1042        CRASSERT(!pContext->buffer.width);
     1043        CRASSERT(!pContext->buffer.height);
     1044
    10401045        if (idPBO)
    10411046        {
     
    11371142    CRASSERT(pContext && pSSM);
    11381143    CRASSERT(pMural);
     1144    CRASSERT(pMural->CreateInfo.externalID);
    11391145
    11401146    /* We could have skipped saving the key and use similar callback to load context states back,
     
    11551161
    11561162#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
    1157     if (pContextInfo->currentMural || crHashtableSearch(cr_server.muralTable, key))
     1163    if (pContextInfo->currentMural
     1164            || crHashtableSearch(cr_server.muralTable, pMural->CreateInfo.externalID) /* <- this is not a dummy mural */
     1165            )
    11581166    {
    11591167        CRASSERT(pMural->CreateInfo.externalID);
     1168        CRASSERT(!crHashtableSearch(cr_server.dummyMuralTable, pMural->CreateInfo.externalID));
    11601169        pData->rc = SSMR3PutMem(pSSM, &pMural->CreateInfo.externalID, sizeof(pMural->CreateInfo.externalID));
    11611170    }
    11621171    else
    11631172    {
     1173        /* this is a dummy mural */
    11641174        CRASSERT(!pMural->width);
    11651175        CRASSERT(!pMural->height);
    1166         CRASSERT(crHashtableSearch(cr_server.dummyMuralTable, key));
     1176        CRASSERT(crHashtableSearch(cr_server.dummyMuralTable, pMural->CreateInfo.externalID));
    11671177        pData->rc = SSMR3PutMem(pSSM, &i32Dummy, sizeof(pMural->CreateInfo.externalID));
    11681178    }
     
    15781588        storedWidth = pMural->width;
    15791589        storedHeight = pMural->height;
    1580         CRASSERT(pContext->buffer.storedWidth == storedWidth);
    1581         CRASSERT(pContext->buffer.storedHeight == storedHeight);
    15821590    }
    15831591    else
     
    16251633        {
    16261634            /* can apply the data right away */
    1627             crStateApplyFBImage(pContext);
     1635            if (!pMural->fUseFBO)
     1636            {
     1637                CRASSERT(cr_server.bForceOffscreenRendering == CR_SERVER_REDIR_NONE);
     1638                crStateApplyFBImage(pContext);
     1639            }
     1640            else
     1641            {
     1642                VBOXVR_TEXTURE Tex;
     1643                Tex.width = pMural->width;
     1644                Tex.height = pMural->height;
     1645                Tex.target = GL_TEXTURE_2D;
     1646
     1647                CRASSERT(cr_server.bForceOffscreenRendering > CR_SERVER_REDIR_NONE);
     1648
     1649                if (pBuf->pFrontImg)
     1650                {
     1651                    Tex.hwid = pMural->aidColorTexs[CR_SERVER_FBO_FB_IDX(pMural)];
     1652                    CRASSERT(Tex.hwid);
     1653                    CrHlpPutTexImage(pContext, &Tex, pBuf->pFrontImg);
     1654                }
     1655
     1656                if (pBuf->pBackImg)
     1657                {
     1658                    Tex.hwid = pMural->aidColorTexs[CR_SERVER_FBO_BB_IDX(pMural)];
     1659                    CRASSERT(Tex.hwid);
     1660                    CrHlpPutTexImage(pContext, &Tex, pBuf->pBackImg);
     1661                }
     1662
     1663                crStateFreeFBImage(pContext);
     1664            }
    16281665            CRASSERT(!pBuf->pFrontImg);
    16291666            CRASSERT(!pBuf->pBackImg);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r44740 r44746  
    286286}
    287287
    288 void* CrHlpGetTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLuint idPBO)
    289 {
    290     void *pvData = NULL;
     288void CrHlpPutTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, void *pvData)
     289{
     290    CRASSERT(pTexture->hwid);
    291291    cr_server.head_spu->dispatch_table.BindTexture(pTexture->target, pTexture->hwid);
    292292
    293     if (idPBO)
    294     {
    295         cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, idPBO);
    296     }
    297     else
    298     {
    299         if (!pCurCtx || crStateIsBufferBoundForCtx(pCurCtx, GL_PIXEL_PACK_BUFFER_ARB))
    300         {
    301             cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
    302         }
    303 
    304         pvData = crAlloc(4*pTexture->width*pTexture->height);
    305         if (!pvData)
    306         {
    307             crWarning("Out of memory in CrHlpGetTexImage");
    308             return NULL;
    309         }
     293    if (!pCurCtx || crStateIsBufferBoundForCtx(pCurCtx, GL_PIXEL_UNPACK_BUFFER_ARB))
     294    {
     295        cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
    310296    }
    311297
    312298    /*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/
    313     cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pvData);
     299    cr_server.head_spu->dispatch_table.TexSubImage2D(GL_TEXTURE_2D,  0 /* level*/,  0 /*xoffset*/,  0 /*yoffset*/,  pTexture->width, pTexture->height, GL_BGRA, GL_UNSIGNED_BYTE, pvData);
    314300
    315301    /*restore gl state*/
     
    328314    }
    329315
     316    if (pCurCtx && crStateIsBufferBoundForCtx(pCurCtx, GL_PIXEL_UNPACK_BUFFER_ARB))
     317        cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pCurCtx->bufferobject.unpackBuffer->hwid);
     318}
     319
     320void* CrHlpGetTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLuint idPBO)
     321{
     322    void *pvData = NULL;
     323    cr_server.head_spu->dispatch_table.BindTexture(pTexture->target, pTexture->hwid);
     324
     325    if (idPBO)
     326    {
     327        cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, idPBO);
     328    }
     329    else
     330    {
     331        if (!pCurCtx || crStateIsBufferBoundForCtx(pCurCtx, GL_PIXEL_PACK_BUFFER_ARB))
     332        {
     333            cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
     334        }
     335
     336        pvData = crAlloc(4*pTexture->width*pTexture->height);
     337        if (!pvData)
     338        {
     339            crWarning("Out of memory in CrHlpGetTexImage");
     340            return NULL;
     341        }
     342    }
     343
     344    /*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/
     345    cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pvData);
     346
     347    /*restore gl state*/
     348    if (pCurCtx)
     349    {
     350        CRTextureObj *pTObj;
     351        CRTextureLevel *pTImg;
     352        crStateGetTextureObjectAndImage(pCurCtx, pTexture->target, 0, &pTObj, &pTImg);
     353
     354        GLuint uid = pTObj->hwid;
     355        cr_server.head_spu->dispatch_table.BindTexture(pTexture->target, uid);
     356    }
     357    else
     358    {
     359        cr_server.head_spu->dispatch_table.BindTexture(pTexture->target, 0);
     360    }
     361
    330362    if (idPBO)
    331363    {
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