VirtualBox

Ignore:
Timestamp:
Feb 25, 2013 6:32:06 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83932
Message:

crOpenGL: saved state stencil/depth buffer fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c

    r44802 r44812  
    164164        CRFBDataElement *el = &data->aElements[i];
    165165
     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;
     202        }
     203
    166204        diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, el->idFBO);
    167205
     
    171209        diff_api.ReadPixels(el->posX, el->posY, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
    172210        crDebug("Acquired %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
     211
     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;
     248        }
    173249    }
    174250
     
    231307        diff_api.Disable(GL_BLEND);
    232308        diff_api.Disable(GL_COLOR_LOGIC_OP);
     309        diff_api.Disable(GL_DEPTH_TEST);
     310        diff_api.Disable(GL_STENCIL_TEST);
    233311
    234312        for (i = 0; i < data->cElements; ++i)
     
    240318                case GL_DEPTH_COMPONENT:
    241319                    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                    }
    242328                    break;
    243329                case GL_STENCIL_INDEX:
    244330                    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                    }
    245343                    break;
    246344                default:
     
    248346            }
    249347
     348
    250349            diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, el->idFBO);
    251350
     
    260359            {
    261360                case GL_DEPTH_COMPONENT:
    262                     if (!to->buffer.depthTest)
    263                     {
    264                         diff_api.Disable(GL_DEPTH_TEST);
    265                     }
     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);
    266370                    break;
    267371                case GL_STENCIL_INDEX:
    268                     if (!to->stencil.stencilTest)
    269                     {
    270                         diff_api.Disable(GL_STENCIL_TEST);
    271                     }
     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);
    272385                    break;
    273386                default:
    274387                    break;
    275388            }
    276 
    277389        }
    278390
     
    313425        {
    314426            diff_api.Enable(GL_COLOR_LOGIC_OP);
     427        }
     428        if (to->buffer.depthTest)
     429        {
     430            diff_api.Enable(GL_DEPTH_TEST);
     431        }
     432        if (to->stencil.stencilTest)
     433        {
     434            diff_api.Enable(GL_STENCIL_TEST);
    315435        }
    316436
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