VirtualBox

Ignore:
Timestamp:
May 8, 2015 3:39:42 PM (10 years ago)
Author:
vboxsync
Message:

3D: saving state: since we use glReadPixels() in order to read image data and glDrawPixels() in order to restore, we can't use GL_DEPTH_STENCIL because according to OpenGL spec it is only supported for glReadPixels(). Therefore, let's store/restore DEPTH and STENCIL data separately.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r55213 r55758  
    13031303        return VINF_SUCCESS;
    13041304
    1305 
    1306     if (version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL)
    1307     {
    1308 /*        if (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT) */ /* <- older version had a typo which lead to back always being used,
    1309                                                                                                                                   * no matter what the visual bits are */
    1310         {
    1311             AssertCompile(sizeof (GLfloat) == 4);
    1312             pEl = &pData->aElements[pData->cElements];
    1313             pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
    1314             pEl->enmBuffer = 0; /* we do not care */
    1315             pEl->posX = 0;
    1316             pEl->posY = 0;
    1317             pEl->width = width;
    1318             pEl->height = height;
    1319             pEl->enmFormat = GL_DEPTH_COMPONENT;
    1320             pEl->enmType = GL_FLOAT;
    1321             pEl->cbData = width * height * 4;
    1322             pEl->pvData = crCalloc(pEl->cbData);
    1323             if (!pEl->pvData)
    1324             {
    1325                 crVBoxServerFBImageDataTerm(pData);
    1326                 crWarning("crVBoxServerFBImageDataInit: crCalloc failed");
    1327                 return VERR_NO_MEMORY;
    1328             }
    1329 
    1330             /* init to default depth value, just in case */
    1331             pF = (GLfloat*)pEl->pvData;
    1332             for (i = 0; i < width * height; ++i)
    1333             {
    1334                 pF[i] = 1.;
    1335             }
    1336             ++pData->cElements;
    1337         }
    1338 
    1339  /*       if (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT) */ /* <- older version had a typo which lead to back always being used,
    1340                                                                                                                                         * no matter what the visual bits are */
    1341         {
    1342             AssertCompile(sizeof (GLuint) == 4);
    1343             pEl = &pData->aElements[pData->cElements];
    1344             pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
    1345             pEl->enmBuffer = 0; /* we do not care */
    1346             pEl->posX = 0;
    1347             pEl->posY = 0;
    1348             pEl->width = width;
    1349             pEl->height = height;
    1350             pEl->enmFormat = GL_STENCIL_INDEX;
    1351             pEl->enmType = GL_UNSIGNED_INT;
    1352             pEl->cbData = width * height * 4;
    1353             pEl->pvData = crCalloc(pEl->cbData);
    1354             if (!pEl->pvData)
    1355             {
    1356                 crVBoxServerFBImageDataTerm(pData);
    1357                 crWarning("crVBoxServerFBImageDataInit: crCalloc failed");
    1358                 return VERR_NO_MEMORY;
    1359             }
    1360             ++pData->cElements;
    1361         }
    1362         return VINF_SUCCESS;
    1363     }
    1364 
    1365     /* Use GL_DEPTH_STENCIL only in case if both CR_STENCIL_BIT and CR_DEPTH_BIT specified. */
    1366     if (   (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT)
    1367         && (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT))
    1368     {
     1305    if (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT)
     1306    {
     1307        AssertCompile(sizeof (GLfloat) == 4);
    13691308        pEl = &pData->aElements[pData->cElements];
    13701309        pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     
    13741313        pEl->width = width;
    13751314        pEl->height = height;
    1376         pEl->enmFormat = GL_DEPTH_STENCIL;
    1377         pEl->enmType = GL_UNSIGNED_INT_24_8;
     1315        pEl->enmFormat = GL_DEPTH_COMPONENT;
     1316        pEl->enmType = GL_FLOAT;
    13781317        pEl->cbData = width * height * 4;
    13791318        pEl->pvData = crCalloc(pEl->cbData);
     
    13841323            return VERR_NO_MEMORY;
    13851324        }
     1325
     1326        /* init to default depth value, just in case */
     1327        pF = (GLfloat*)pEl->pvData;
     1328        for (i = 0; i < width * height; ++i)
     1329        {
     1330            pF[i] = 1.;
     1331        }
    13861332        ++pData->cElements;
    13871333    }
     1334
     1335    if (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT)
     1336    {
     1337        AssertCompile(sizeof (GLuint) == 4);
     1338        pEl = &pData->aElements[pData->cElements];
     1339        pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     1340        pEl->enmBuffer = 0; /* we do not care */
     1341        pEl->posX = 0;
     1342        pEl->posY = 0;
     1343        pEl->width = width;
     1344        pEl->height = height;
     1345        pEl->enmFormat = GL_STENCIL_INDEX;
     1346        pEl->enmType = GL_UNSIGNED_INT;
     1347        pEl->cbData = width * height * 4;
     1348        pEl->pvData = crCalloc(pEl->cbData);
     1349        if (!pEl->pvData)
     1350        {
     1351            crVBoxServerFBImageDataTerm(pData);
     1352            crWarning("crVBoxServerFBImageDataInit: crCalloc failed");
     1353            return VERR_NO_MEMORY;
     1354        }
     1355        ++pData->cElements;
     1356    }
     1357
    13881358    return VINF_SUCCESS;
    13891359}
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