VirtualBox

Ignore:
Timestamp:
May 20, 2013 12:15:50 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: proper support for GL_NONE,AUX,etc. for offscreen rendering

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r45940 r46173  
    174174void crServerPresentFBO(CRMuralInfo *mural);
    175175GLboolean crServerIsRedirectedToFBO();
    176 GLuint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer);
     176GLint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer);
    177177void crServerMuralFBOSwapBuffers(CRMuralInfo *mural);
    178178
     
    190190#define CR_SERVER_FBO_BB_IDX(_mural) ((_mural)->iBbBuffer)
    191191#define CR_SERVER_FBO_FB_IDX(_mural) (((_mural)->iBbBuffer + 1) % ((_mural)->cBuffers))
     192/* returns a valid index to be used for negative _idx, i.e. for GL_NONE cases */
     193//#define CR_SERVER_FBO_ADJUST_IDX(_mural, _idx) ((_idx) >= 0 ? (_idx) : CR_SERVER_FBO_BB_IDX(_mural))
     194/* just a helper that uses CR_SERVER_FBO_ADJUST_IDX for getting mural's FBO id for buffer index*/
     195//#define CR_SERVER_FBO_FOR_IDX(_mural, _idx) ((_mural)->aidFBOs[CR_SERVER_FBO_ADJUST_IDX((_mural), (_idx))])
     196//#define CR_SERVER_FBO_TEX_FOR_IDX(_mural, _idx) ((_mural)->aidColorTexs[CR_SERVER_FBO_ADJUST_IDX((_mural), (_idx))])
     197#define CR_SERVER_FBO_FOR_IDX(_mural, _idx) ((_idx) >= 0 ? (_mural)->aidFBOs[(_idx)] : 0)
     198#define CR_SERVER_FBO_TEX_FOR_IDX(_mural, _idx) ((_idx) >= 0 ? (_mural)->aidColorTexs[(_idx)] : 0)
    192199
    193200int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer);
     
    355362    if (pCurrentMural)
    356363    {
    357         idDrawFBO = pCurrentMural->aidFBOs[pCurrentMural->iCurDrawBuffer];
    358         idReadFBO = pCurrentMural->aidFBOs[pCurrentMural->iCurReadBuffer];
     364        idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
     365        idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
    359366    }
    360367    else
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c

    r45616 r46173  
    297297    if (oldMural && (oldMural->fPresentMode & CR_SERVER_REDIR_F_FBO) && crServerSupportRedirMuralFBO())
    298298    {
    299         idDrawFBO = oldMural->aidFBOs[oldMural->iCurDrawBuffer];
    300         idReadFBO = oldMural->aidFBOs[oldMural->iCurReadBuffer];
     299        idDrawFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurDrawBuffer);
     300        idReadFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurReadBuffer);
    301301    }
    302302    else
     
    393393        }
    394394
    395         idDrawFBO = mural->aidFBOs[mural->iCurDrawBuffer];
    396         idReadFBO = mural->aidFBOs[mural->iCurReadBuffer];
     395        idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
     396        idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
    397397    }
    398398    else
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.c

    r44529 r46173  
    8282    if (0==framebuffer && crServerIsRedirectedToFBO())
    8383    {
     84        CRMuralInfo *mural = cr_server.curClient->currentMural;
    8485        if (target == GL_FRAMEBUFFER)
    8586        {
    86             GLuint idDrawFBO = cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer];
    87             GLuint idReadFBO = cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer];
     87            GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
     88            GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
    8889            if (idDrawFBO == idReadFBO)
    8990                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER, idDrawFBO);
     
    9697        else if (target == GL_READ_FRAMEBUFFER)
    9798        {
    98             GLuint idReadFBO = cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer];
     99            GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
    99100            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
    100101        }
    101102        else if (target == GL_DRAW_FRAMEBUFFER)
    102103        {
    103             GLuint idDrawFBO = cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer];
     104            GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
    104105            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
    105106        }
     
    113114        if (GL_FRAMEBUFFER_EXT == target)
    114115        {
    115             Assert(rfb == cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer]);
    116             Assert(dfb == cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer]);
     116            Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
     117            Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
    117118        }
    118119        else if (GL_READ_FRAMEBUFFER_EXT == target)
    119120        {
    120             Assert(rfb == cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer]);
     121            Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
    121122        }
    122123        else if (GL_DRAW_FRAMEBUFFER_EXT == target)
    123124        {
    124             Assert(dfb == cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer]);
     125            Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
    125126        }
    126127        else
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r45942 r46173  
    10901090        return VINF_SUCCESS;
    10911091
    1092     pData->idFBO = pMural && (pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) ? pMural->aidColorTexs[fWrite ? pMural->iCurDrawBuffer : pMural->iCurReadBuffer] : 0;
     1092    if (pMural)
     1093    {
     1094        if (fWrite)
     1095        {
     1096            if (!pContext->framebufferobject.drawFB)
     1097                pData->idOverrrideFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurDrawBuffer);
     1098        }
     1099        else
     1100        {
     1101            if (!pContext->framebufferobject.readFB)
     1102                pData->idOverrrideFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurReadBuffer);
     1103        }
     1104    }
    10931105    pData->cElements = 0;
    10941106
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r45577 r46173  
    813813    CrBltMuralSetCurrent(pBlitter, &BltInfo);
    814814
    815     idDrawFBO = mural->aidFBOs[mural->iCurDrawBuffer];
    816     idReadFBO = mural->aidFBOs[mural->iCurReadBuffer];
     815    idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
     816    idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
    817817
    818818    crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO);
     
    11401140                && cr_server.curClient->currentMural->aidFBOs[0])
    11411141        {
    1142             GLuint iBufferNeeded;
     1142            CRMuralInfo *mural = cr_server.curClient->currentMural;
     1143            GLint iBufferNeeded = -1;
    11431144            switch (mode)
    11441145            {
     
    11471148                case GL_BACK_RIGHT:
    11481149                    mode = GL_COLOR_ATTACHMENT0;
    1149                     iBufferNeeded = CR_SERVER_FBO_BB_IDX(cr_server.curClient->currentMural);
     1150                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
    11501151                    break;
    11511152                case GL_FRONT:
     
    11531154                case GL_FRONT_RIGHT:
    11541155                    mode = GL_COLOR_ATTACHMENT0;
    1155                     iBufferNeeded = CR_SERVER_FBO_FB_IDX(cr_server.curClient->currentMural);
     1156                    iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
     1157                    break;
     1158                case GL_NONE:
     1159                    crDebug("DrawBuffer: GL_NONE");
     1160                    break;
     1161                case GL_AUX0:
     1162                    crDebug("DrawBuffer: GL_AUX0");
     1163                    break;
     1164                case GL_AUX1:
     1165                    crDebug("DrawBuffer: GL_AUX1");
     1166                    break;
     1167                case GL_AUX2:
     1168                    crDebug("DrawBuffer: GL_AUX2");
     1169                    break;
     1170                case GL_AUX3:
     1171                    crDebug("DrawBuffer: GL_AUX3");
     1172                    break;
     1173                case GL_LEFT:
     1174                    crWarning("DrawBuffer: GL_LEFT not supported properly");
     1175                    mode = GL_COLOR_ATTACHMENT0;
     1176                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
     1177                    break;
     1178                case GL_RIGHT:
     1179                    crWarning("DrawBuffer: GL_RIGHT not supported properly");
     1180                    mode = GL_COLOR_ATTACHMENT0;
     1181                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
     1182                    break;
     1183                case GL_FRONT_AND_BACK:
     1184                    crWarning("DrawBuffer: GL_FRONT_AND_BACK not supported properly");
     1185                    mode = GL_COLOR_ATTACHMENT0;
     1186                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
    11561187                    break;
    11571188                default:
    1158                     crWarning("unexpected mode! 0x%x", mode);
    1159                     iBufferNeeded = CR_SERVER_FBO_BB_IDX(cr_server.curClient->currentMural);
     1189                    crWarning("DrawBuffer: unexpected mode! 0x%x", mode);
     1190                    iBufferNeeded = mural->iCurDrawBuffer;
    11601191                    break;
    11611192            }
    11621193
    1163             Assert(cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer]);
    1164             if (iBufferNeeded != cr_server.curClient->currentMural->iCurDrawBuffer)
     1194            if (iBufferNeeded != mural->iCurDrawBuffer)
    11651195            {
    1166                 cr_server.curClient->currentMural->iCurDrawBuffer = iBufferNeeded;
    1167                 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER,
    1168                         cr_server.curClient->currentMural->aidFBOs[iBufferNeeded]);
     1196                mural->iCurDrawBuffer = iBufferNeeded;
     1197                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
    11691198            }
    11701199        }
     
    11821211            && !crStateGetCurrent()->framebufferobject.readFB)
    11831212    {
    1184         GLuint iBufferNeeded;
     1213        CRMuralInfo *mural = cr_server.curClient->currentMural;
     1214        GLint iBufferNeeded = -1;
    11851215        switch (mode)
    11861216        {
     
    11891219            case GL_BACK_RIGHT:
    11901220                mode = GL_COLOR_ATTACHMENT0;
    1191                 iBufferNeeded = CR_SERVER_FBO_BB_IDX(cr_server.curClient->currentMural);
     1221                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
    11921222                break;
    11931223            case GL_FRONT:
     
    11951225            case GL_FRONT_RIGHT:
    11961226                mode = GL_COLOR_ATTACHMENT0;
    1197                 iBufferNeeded = CR_SERVER_FBO_FB_IDX(cr_server.curClient->currentMural);
     1227                iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
     1228                break;
     1229            case GL_NONE:
     1230                crDebug("ReadBuffer: GL_NONE");
     1231                break;
     1232            case GL_AUX0:
     1233                crDebug("ReadBuffer: GL_AUX0");
     1234                break;
     1235            case GL_AUX1:
     1236                crDebug("ReadBuffer: GL_AUX1");
     1237                break;
     1238            case GL_AUX2:
     1239                crDebug("ReadBuffer: GL_AUX2");
     1240                break;
     1241            case GL_AUX3:
     1242                crDebug("ReadBuffer: GL_AUX3");
     1243                break;
     1244            case GL_LEFT:
     1245                crWarning("ReadBuffer: GL_LEFT not supported properly");
     1246                mode = GL_COLOR_ATTACHMENT0;
     1247                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
     1248                break;
     1249            case GL_RIGHT:
     1250                crWarning("ReadBuffer: GL_RIGHT not supported properly");
     1251                mode = GL_COLOR_ATTACHMENT0;
     1252                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
     1253                break;
     1254            case GL_FRONT_AND_BACK:
     1255                crWarning("ReadBuffer: GL_FRONT_AND_BACK not supported properly");
     1256                mode = GL_COLOR_ATTACHMENT0;
     1257                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
    11981258                break;
    11991259            default:
    1200                 crWarning("unexpected mode! 0x%x", mode);
    1201                 iBufferNeeded = CR_SERVER_FBO_BB_IDX(cr_server.curClient->currentMural);
    1202                 break;
    1203         }
    1204 
    1205         Assert(cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer]);
    1206         if (iBufferNeeded != cr_server.curClient->currentMural->iCurReadBuffer)
    1207         {
    1208             cr_server.curClient->currentMural->iCurReadBuffer = iBufferNeeded;
    1209             cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER,
    1210                     cr_server.curClient->currentMural->aidFBOs[iBufferNeeded]);
     1260                crWarning("ReadBuffer: unexpected mode! 0x%x", mode);
     1261                iBufferNeeded = mural->iCurDrawBuffer;
     1262                break;
     1263        }
     1264
     1265        Assert(CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
     1266        if (iBufferNeeded != mural->iCurReadBuffer)
     1267        {
     1268            mural->iCurReadBuffer = iBufferNeeded;
     1269            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
    12111270        }
    12121271    }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r45942 r46173  
    404404            if (!crStateGetCurrent()->framebufferobject.drawFB)
    405405            {
    406                 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, mural->aidFBOs[mural->iCurDrawBuffer]);
     406                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
    407407            }
    408408            if (!crStateGetCurrent()->framebufferobject.readFB)
    409409            {
    410                 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->aidFBOs[mural->iCurReadBuffer]);
     410                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
    411411            }
    412412
     
    675675    if (currentMural)
    676676    {
    677         idDrawFBO = currentMural->aidFBOs[currentMural->iCurDrawBuffer];
    678         idReadFBO = currentMural->aidFBOs[currentMural->iCurReadBuffer];
     677        idDrawFBO = CR_SERVER_FBO_FOR_IDX(currentMural, currentMural->iCurDrawBuffer);
     678        idReadFBO = CR_SERVER_FBO_FOR_IDX(currentMural, currentMural->iCurReadBuffer);
    679679    }
    680680    else
     
    988988}
    989989
    990 GLuint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer)
     990GLint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer)
    991991{
    992992    if (buffer == GL_FRONT
     
    994994            || buffer == GL_FRONT_RIGHT)
    995995        return CR_SERVER_FBO_FB_IDX(mural);
    996     return CR_SERVER_FBO_BB_IDX(mural);
     996    if (buffer == GL_BACK
     997            || buffer == GL_BACK_LEFT
     998            || buffer == GL_BACK_RIGHT)
     999        return CR_SERVER_FBO_BB_IDX(mural);
     1000    if (buffer == GL_NONE)
     1001        return -1;
     1002
     1003    crWarning("crServerMuralFBOIdxFromBufferName: invalid buffer passed 0x%x", buffer);
     1004    return -2;
    9971005}
    9981006
     
    10031011    GLuint iOldCurReadBuffer = mural->iCurReadBuffer;
    10041012    mural->iBbBuffer = ((mural->iBbBuffer + 1) % (mural->cBuffers));
    1005     mural->iCurDrawBuffer = ((mural->iCurDrawBuffer + 1) % (mural->cBuffers));
    1006     mural->iCurReadBuffer = ((mural->iCurReadBuffer + 1) % (mural->cBuffers));
    1007     Assert(iOldCurDrawBuffer != mural->iCurDrawBuffer || mural->cBuffers == 1);
    1008     Assert(iOldCurReadBuffer != mural->iCurReadBuffer || mural->cBuffers == 1);
     1013    if (mural->iCurDrawBuffer >= 0)
     1014        mural->iCurDrawBuffer = ((mural->iCurDrawBuffer + 1) % (mural->cBuffers));
     1015    if (mural->iCurReadBuffer >= 0)
     1016        mural->iCurReadBuffer = ((mural->iCurReadBuffer + 1) % (mural->cBuffers));
     1017    Assert(iOldCurDrawBuffer != mural->iCurDrawBuffer || mural->cBuffers == 1 || mural->iCurDrawBuffer < 0);
     1018    Assert(iOldCurReadBuffer != mural->iCurReadBuffer || mural->cBuffers == 1 || mural->iCurReadBuffer < 0);
    10091019    if (!ctx->framebufferobject.drawFB && iOldCurDrawBuffer != mural->iCurDrawBuffer)
    10101020    {
    1011         cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, mural->aidFBOs[mural->iCurDrawBuffer]);
     1021        cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
    10121022    }
    10131023    if (!ctx->framebufferobject.readFB && iOldCurReadBuffer != mural->iCurReadBuffer)
    10141024    {
    1015         cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->aidFBOs[mural->iCurReadBuffer]);
     1025        cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
    10161026    }
    10171027    Assert(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r46061 r46173  
    128128    if (pMural)
    129129    {
    130         idDrawFBO = pMural->aidFBOs[pMural->iCurDrawBuffer];
    131         idReadFBO = pMural->aidFBOs[pMural->iCurReadBuffer];
     130        idDrawFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurDrawBuffer);
     131        idReadFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurReadBuffer);
    132132    }
    133133
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py

    r44444 r46173  
    9191    {
    9292        if (crServerIsRedirectedToFBO()
    93             && cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer]
     93            && CR_SERVER_FBO_FOR_IDX(cr_server.curClient->currentMural, cr_server.curClient->currentMural->iCurReadBuffer)
    9494            && !crStateGetCurrent()->framebufferobject.readFB)
    9595        {
    9696            *get_values = (%s) crStateGetCurrent()->buffer.readBuffer;
     97            Assert(crStateGetCurrent()->buffer.readBuffer == GL_BACK || crStateGetCurrent()->buffer.readBuffer == GL_FRONT);
    9798        }
    9899    }
     
    100101    {
    101102        if (crServerIsRedirectedToFBO()
    102             && cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer]
     103            && CR_SERVER_FBO_FOR_IDX(cr_server.curClient->currentMural, cr_server.curClient->currentMural->iCurDrawBuffer)
    103104            && !crStateGetCurrent()->framebufferobject.drawFB)
    104105        {
    105106            *get_values = (%s) crStateGetCurrent()->buffer.drawBuffer;
     107            Assert(crStateGetCurrent()->buffer.drawBuffer == GL_BACK || crStateGetCurrent()->buffer.drawBuffer == GL_FRONT);
    106108        }
    107109    }
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