VirtualBox

Changeset 44816 in vbox


Ignore:
Timestamp:
Feb 25, 2013 12:50:56 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGl: more stencil/depth saved state fixes

Location:
trunk/src/VBox
Files:
3 edited

Legend:

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

    r44802 r44816  
    2222#define SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL                      34
    2323#define SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER         35
    24 #define SHCROGL_SSM_VERSION                                         35
     24/* some ogl drivers fail to Read/DrawPixels for DEPTH and STENCIL separately
     25 * from DEPTH_STENCIL renderbuffer we used for offscreen rendering
     26 * this is why we switched to glReadDrawPixels(GL_DEPTH_STENCIL) in one run */
     27#define SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL               36
     28#define SHCROGL_SSM_VERSION                                         36
    2529
    2630/* These define the Chromium release number.
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c

    r44812 r44816  
    1010#include "cr_pixeldata.h"
    1111#include <iprt/err.h>
     12#include <stdio.h>
    1213
    1314void crStateDiffContext( CRContext *from, CRContext *to )
     
    164165        CRFBDataElement *el = &data->aElements[i];
    165166
    166         switch (el->enmFormat)
    167         {
    168             case GL_DEPTH_COMPONENT:
    169                 if (!to->buffer.depthTest)
    170                 {
    171                     diff_api.Enable(GL_DEPTH_TEST);
    172                 }
    173                 if (to->pixel.depthScale != 1.0f)
    174                 {
    175                     diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
    176                 }
    177                 if (to->pixel.depthBias != 0.0f)
    178                 {
    179                     diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
    180                 }
    181                 break;
    182             case GL_STENCIL_INDEX:
    183                 if (!to->stencil.stencilTest)
    184                 {
    185                     diff_api.Enable(GL_STENCIL_TEST);
    186                 }
    187                 if (to->pixel.mapStencil)
    188                 {
    189                     diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
    190                 }
    191                 if (to->pixel.indexOffset)
    192                 {
    193                     diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
    194                 }
    195                 if (to->pixel.indexShift)
    196                 {
    197                     diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
    198                 }
    199                 break;
    200             default:
    201                 break;
     167        if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
     168        {
     169            if (!to->buffer.depthTest)
     170            {
     171                diff_api.Enable(GL_DEPTH_TEST);
     172            }
     173            if (to->pixel.depthScale != 1.0f)
     174            {
     175                diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
     176            }
     177            if (to->pixel.depthBias != 0.0f)
     178            {
     179                diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
     180            }
     181        }
     182        if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
     183        {
     184                if (!to->stencil.stencilTest)
     185            {
     186                diff_api.Enable(GL_STENCIL_TEST);
     187            }
     188            if (to->pixel.mapStencil)
     189            {
     190                diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
     191            }
     192            if (to->pixel.indexOffset)
     193            {
     194                diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
     195            }
     196            if (to->pixel.indexShift)
     197            {
     198                diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
     199            }
    202200        }
    203201
     
    210208        crDebug("Acquired %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
    211209
    212         switch (el->enmFormat)
    213         {
    214             case GL_DEPTH_COMPONENT:
    215                 if (to->pixel.depthScale != 1.0f)
    216                 {
    217                     diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
    218                 }
    219                 if (to->pixel.depthBias != 0.0f)
    220                 {
    221                     diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
    222                 }
    223                 if (!to->buffer.depthTest)
    224                 {
    225                     diff_api.Disable(GL_DEPTH_TEST);
    226                 }
    227                 break;
    228             case GL_STENCIL_INDEX:
    229                 if (to->pixel.indexOffset)
    230                 {
    231                     diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
    232                 }
    233                 if (to->pixel.indexShift)
    234                 {
    235                     diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
    236                 }
    237                 if (to->pixel.mapStencil)
    238                 {
    239                     diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
    240                 }
    241                 if (!to->stencil.stencilTest)
    242                 {
    243                     diff_api.Disable(GL_STENCIL_TEST);
    244                 }
    245                 break;
    246             default:
    247                 break;
     210        if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
     211        {
     212            if (to->pixel.depthScale != 1.0f)
     213            {
     214                diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
     215            }
     216            if (to->pixel.depthBias != 0.0f)
     217            {
     218                diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
     219            }
     220            if (!to->buffer.depthTest)
     221            {
     222                diff_api.Disable(GL_DEPTH_TEST);
     223            }
     224        }
     225        if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
     226        {
     227            if (to->pixel.indexOffset)
     228            {
     229                diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
     230            }
     231            if (to->pixel.indexShift)
     232            {
     233                diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
     234            }
     235            if (to->pixel.mapStencil)
     236            {
     237                diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
     238            }
     239            if (!to->stencil.stencilTest)
     240            {
     241                diff_api.Disable(GL_STENCIL_TEST);
     242            }
    248243        }
    249244    }
     
    313308        {
    314309            CRFBDataElement *el = &data->aElements[i];
    315 
    316             switch (el->enmFormat)
    317             {
    318                 case GL_DEPTH_COMPONENT:
    319                     diff_api.Enable(GL_DEPTH_TEST);
    320                     if (to->pixel.depthScale != 1.0f)
    321                     {
    322                         diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
    323                     }
    324                     if (to->pixel.depthBias != 0.0f)
    325                     {
    326                         diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
    327                     }
    328                     break;
    329                 case GL_STENCIL_INDEX:
    330                     diff_api.Enable(GL_STENCIL_TEST);
    331                     if (to->pixel.mapStencil)
    332                     {
    333                         diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
    334                     }
    335                     if (to->pixel.indexOffset)
    336                     {
    337                         diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
    338                     }
    339                     if (to->pixel.indexShift)
    340                     {
    341                         diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
    342                     }
    343                     break;
    344                 default:
    345                     break;
    346             }
    347 
     310            char fname[200];
     311            sprintf(fname, "./img_apply_%p_%d_%d.tga", to, i, el->enmFormat);
     312            crDumpNamedTGA(fname, el->width, el->height, el->pvData);
     313
     314            if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
     315            {
     316                diff_api.Enable(GL_DEPTH_TEST);
     317                if (to->pixel.depthScale != 1.0f)
     318                {
     319                    diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
     320                }
     321                if (to->pixel.depthBias != 0.0f)
     322                {
     323                    diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
     324                }
     325            }
     326            if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
     327            {
     328                diff_api.Enable(GL_STENCIL_TEST);
     329                if (to->pixel.mapStencil)
     330                {
     331                    diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
     332                }
     333                if (to->pixel.indexOffset)
     334                {
     335                    diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
     336                }
     337                if (to->pixel.indexShift)
     338                {
     339                    diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
     340                }
     341            }
    348342
    349343            diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, el->idFBO);
     
    356350            crDebug("Applied %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
    357351
    358             switch (el->enmFormat)
    359             {
    360                 case GL_DEPTH_COMPONENT:
    361                     if (to->pixel.depthScale != 1.0f)
    362                     {
    363                         diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
    364                     }
    365                     if (to->pixel.depthBias != 0.0f)
    366                     {
    367                         diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
    368                     }
    369                     diff_api.Disable(GL_DEPTH_TEST);
    370                     break;
    371                 case GL_STENCIL_INDEX:
    372                     if (to->pixel.indexOffset)
    373                     {
    374                         diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
    375                     }
    376                     if (to->pixel.indexShift)
    377                     {
    378                         diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
    379                     }
    380                     if (to->pixel.mapStencil)
    381                     {
    382                         diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
    383                     }
    384                     diff_api.Disable(GL_STENCIL_TEST);
    385                     break;
    386                 default:
    387                     break;
     352            if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
     353            {
     354                if (to->pixel.depthScale != 1.0f)
     355                {
     356                    diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
     357                }
     358                if (to->pixel.depthBias != 0.0f)
     359                {
     360                    diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
     361                }
     362                diff_api.Disable(GL_DEPTH_TEST);
     363            }
     364            if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
     365            {
     366                if (to->pixel.indexOffset)
     367                {
     368                    diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
     369                }
     370                if (to->pixel.indexShift)
     371                {
     372                    diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
     373                }
     374                if (to->pixel.mapStencil)
     375                {
     376                    diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
     377                }
     378                diff_api.Disable(GL_STENCIL_TEST);
    388379            }
    389380        }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r44802 r44816  
    10121012}
    10131013
    1014 static int crVBoxServerFBImageDataInitEx(CRFBData *pData, CRContextInfo *pCtxInfo, CRMuralInfo *pMural, GLboolean fWrite, GLboolean fForceBackFrontOnly, GLuint overrideWidth, GLuint overrideHeight)
     1014static int crVBoxServerFBImageDataInitEx(CRFBData *pData, CRContextInfo *pCtxInfo, CRMuralInfo *pMural, GLboolean fWrite, uint32_t version, GLuint overrideWidth, GLuint overrideHeight)
    10151015{
    10161016    CRContext *pContext;
     
    10261026
    10271027    pContext = pCtxInfo->pContext;
     1028
     1029    /* the version should be always actual when we do reads,
     1030     * i.e. it could differ on writes when snapshot is getting loaded */
     1031    CRASSERT(fWrite || version == SHCROGL_SSM_VERSION);
    10281032
    10291033    width = overrideWidth ? overrideWidth : pMural->width;
     
    10571061    /* there is a lot of code that assumes we have double buffering, just assert here to print a warning in the log
    10581062     * so that we know that something irregular is going on */
    1059     CRASSERT(pCtxInfo->CreateInfo.visualBits && CR_DOUBLE_BIT);
    1060     if ((pCtxInfo->CreateInfo.visualBits && CR_DOUBLE_BIT) || fForceBackFrontOnly)
     1063    CRASSERT(pCtxInfo->CreateInfo.visualBits & CR_DOUBLE_BIT);
     1064    if ((pCtxInfo->CreateInfo.visualBits & CR_DOUBLE_BIT)
     1065                || version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL /* <- older version had a typo which lead to back always being used,
     1066                                                                                                                                        * no matter what the visual bits are */
     1067                )
    10611068    {
    10621069        pEl = &pData->aElements[pData->cElements];
     
    10801087    }
    10811088
    1082     if (!fForceBackFrontOnly)
    1083     {
    1084         if (pCtxInfo->CreateInfo.visualBits && CR_DEPTH_BIT)
     1089    if (version < SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER)
     1090        return VINF_SUCCESS;
     1091
     1092
     1093    if (version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL)
     1094    {
     1095/*        if (pCtxInfo->CreateInfo.visualBits & CR_DEPTH_BIT) */ /* <- older version had a typo which lead to back always being used,
     1096                                                                                                                                  * no matter what the visual bits are */
    10851097        {
    10861098            AssertCompile(sizeof (GLfloat) == 4);
     
    11121124        }
    11131125
    1114         if (pCtxInfo->CreateInfo.visualBits && CR_STENCIL_BIT)
     1126 /*       if (pCtxInfo->CreateInfo.visualBits & CR_STENCIL_BIT) */ /* <- older version had a typo which lead to back always being used,
     1127                                                                                                                                        * no matter what the visual bits are */
    11151128        {
    11161129            AssertCompile(sizeof (GLuint) == 4);
     
    11341147            ++pData->cElements;
    11351148        }
     1149        return VINF_SUCCESS;
     1150    }
     1151
     1152    if ((pCtxInfo->CreateInfo.visualBits & CR_STENCIL_BIT)
     1153                || (pCtxInfo->CreateInfo.visualBits & CR_DEPTH_BIT))
     1154    {
     1155        pEl = &pData->aElements[pData->cElements];
     1156        pEl->idFBO = pMural->fUseFBO ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     1157        pEl->enmBuffer = 0; /* we do not care */
     1158        pEl->posX = 0;
     1159        pEl->posY = 0;
     1160        pEl->width = width;
     1161        pEl->height = height;
     1162        pEl->enmFormat = GL_DEPTH_STENCIL;
     1163        pEl->enmType = GL_UNSIGNED_INT_24_8;
     1164        pEl->cbData = width * height * 4;
     1165        pEl->pvData = crCalloc(pEl->cbData);
     1166        if (!pEl->pvData)
     1167        {
     1168            crVBoxServerFBImageDataTerm(pData);
     1169            crWarning("crVBoxServerFBImageDataInit: crCalloc failed");
     1170            return VERR_NO_MEMORY;
     1171        }
     1172        ++pData->cElements;
    11361173    }
    11371174    return VINF_SUCCESS;
     
    11401177static int crVBoxServerFBImageDataInit(CRFBData *pData, CRContextInfo *pCtxInfo, CRMuralInfo *pMural, GLboolean fWrite)
    11411178{
    1142     return crVBoxServerFBImageDataInitEx(pData, pCtxInfo, pMural, fWrite, GL_FALSE, 0, 0);
     1179    return crVBoxServerFBImageDataInitEx(pData, pCtxInfo, pMural, fWrite, SHCROGL_SSM_VERSION, 0, 0);
    11431180}
    11441181
     
    16921729            return VINF_SUCCESS;
    16931730
    1694         rc = crVBoxServerFBImageDataInit(&Data.data, pContextInfo, pMural, GL_TRUE);
     1731        rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, version, 0, 0);
    16951732        if (!RT_SUCCESS(rc))
    16961733        {
     
    17191756            return VINF_SUCCESS;
    17201757
    1721         rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, GL_TRUE, storedWidth, storedHeight);
     1758        rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, version, storedWidth, storedHeight);
    17221759        if (!RT_SUCCESS(rc))
    17231760        {
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