VirtualBox

Ignore:
Timestamp:
May 31, 2013 1:27:10 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: bugfixes, debugging, dumping draw commands to html

Location:
trunk/src/VBox/HostServices/SharedOpenGL
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk

    r45348 r46343  
    152152VBoxOGLcrserverlib_DEFS += ifdef VBOX_WITH_CRHGSMI
    153153endif
     154ifdef VBOX_WITH_CRDUMPER
     155VBoxOGLcrserverlib_DEFS        += VBOX_WITH_CRDUMPER
     156endif
     157ifdef VBOX_WITH_CRSERVER_DUMPER
     158VBoxOGLcrserverlib_DEFS        += VBOX_WITH_CRSERVER_DUMPER
     159endif
     160
    154161
    155162#
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r46173 r46343  
    351351} CR_SERVER_CTX_SWITCH;
    352352
    353 DECLINLINE(void) cr_serverCtxSwitchPrepare(CR_SERVER_CTX_SWITCH *pData, CRContext *pNewCtx)
     353DECLINLINE(void) crServerCtxSwitchPrepare(CR_SERVER_CTX_SWITCH *pData, CRContext *pNewCtx)
    354354{
    355355    CRMuralInfo *pCurrentMural = cr_server.currentMural;
     
    379379}
    380380
    381 DECLINLINE(void) cr_serverCtxSwitchPostprocess(CR_SERVER_CTX_SWITCH *pData)
     381DECLINLINE(void) crServerCtxSwitchPostprocess(CR_SERVER_CTX_SWITCH *pData)
    382382{
    383383    crStateSwitchPostprocess(pData->pOldCtx, pData->pNewCtx, pData->idDrawFBO, pData->idReadFBO);
    384384}
     385
     386void crServerInitTmpCtxDispatch();
     387
     388#ifdef VBOX_WITH_CRSERVER_DUMPER
     389void crServerDumpCheckTerm();
     390int crServerDumpCheckInit();
     391void crServerDumpBuffer();
     392void crServerDumpTextures();
     393
     394#define CR_SERVER_DUMP_F_DRAW_BUFF_ENTER 0x01
     395#define CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE  0x02
     396#define CR_SERVER_DUMP_F_DRAW_TEX_ENTER  0x10
     397#define CR_SERVER_DUMP_F_DRAW_TEX_LEAVE   0x20
     398
     399extern int g_CrDbgDumpDraw;
     400bool crServerDumpFilter(int event);
     401
     402#define CR_SERVER_DUMP_IF_ANY(_ev) ((g_CrDbgDumpDraw & (_ev)) && crServerDumpFilter((_ev)))
     403
     404#define CR_SERVER_DUMP_DRAW_ENTER() do { \
     405            if (!CR_SERVER_DUMP_IF_ANY(CR_SERVER_DUMP_F_DRAW_BUFF_ENTER | CR_SERVER_DUMP_F_DRAW_TEX_ENTER)) break; \
     406            crServerDumpCheckInit(); \
     407            crDmpStrF(cr_server.Recorder.pDumper, "==> %s\n", __FUNCTION__); \
     408            if (CR_SERVER_DUMP_IF_ANY(CR_SERVER_DUMP_F_DRAW_BUFF_ENTER)) { \
     409                crServerDumpBuffer(); \
     410            } \
     411            if (CR_SERVER_DUMP_IF_ANY(CR_SERVER_DUMP_F_DRAW_TEX_ENTER)) { \
     412                crServerDumpTextures(); \
     413            } \
     414        } while (0)
     415
     416#define CR_SERVER_DUMP_DRAW_LEAVE() do { \
     417            if (!CR_SERVER_DUMP_IF_ANY(CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE | CR_SERVER_DUMP_F_DRAW_TEX_LEAVE)) break; \
     418            crServerDumpCheckInit(); \
     419            crDmpStrF(cr_server.Recorder.pDumper, "<== %s\n", __FUNCTION__); \
     420            if (CR_SERVER_DUMP_IF_ANY(CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE)) { \
     421                crServerDumpBuffer(); \
     422            } \
     423            if (CR_SERVER_DUMP_IF_ANY(CR_SERVER_DUMP_F_DRAW_TEX_LEAVE)) { \
     424                crServerDumpTextures(); \
     425            } \
     426        } while (0)
     427#else /* if !defined VBOX_WITH_CRSERVER_DUMPER */
     428#define CR_SERVER_DUMP_DRAW_ENTER() do {} while (0)
     429#define CR_SERVER_DUMP_DRAW_LEAVE() do {} while (0)
     430#endif /* !VBOX_WITH_CRSERVER_DUMPER */
     431
    385432RT_C_DECLS_END
    386433
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r46173 r46343  
    380380
    381381    crServerInitDispatch();
     382    crServerInitTmpCtxDispatch();
    382383    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
    383384
     
    487488
    488489    crServerInitDispatch();
     490    crServerInitTmpCtxDispatch();
    489491    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
    490492
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r46173 r46343  
    12921292    return retval; /* WILL PROBABLY BE IGNORED */
    12931293}
     1294
     1295void SERVER_DISPATCH_APIENTRY
     1296crServerMakeTmpCtxCurrent( GLint window, GLint nativeWindow, GLint context )
     1297{
     1298    CRContext *pCtx = crStateGetCurrent();
     1299    CRContext *pCurCtx = NULL;
     1300    GLuint idDrawFBO = 0, idReadFBO = 0;
     1301    int fDoPrePostProcess = 0;
     1302
     1303    if (pCtx)
     1304    {
     1305        GLint curSrvSpuCtx = cr_server.currentCtxInfo && cr_server.currentCtxInfo->SpuContext > 0 ? cr_server.currentCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext;
     1306        bool fSwitchToTmpCtx = (curSrvSpuCtx != context);
     1307        CRMuralInfo *pCurrentMural = cr_server.currentMural;
     1308        CRContextInfo *pCurCtxInfo = cr_server.currentCtxInfo;
     1309        pCurCtx = pCurCtxInfo ? pCurCtxInfo->pContext : NULL;
     1310
     1311        CRASSERT(pCurCtx == pCtx);
     1312
     1313        if (pCurrentMural)
     1314        {
     1315            idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
     1316            idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
     1317        }
     1318        else
     1319        {
     1320            idDrawFBO = 0;
     1321            idReadFBO = 0;
     1322        }
     1323
     1324        fDoPrePostProcess = fSwitchToTmpCtx ? 1 : -1;
     1325    }
     1326    else
     1327    {
     1328        /* this is a GUI thread, so no need to do anything here */
     1329    }
     1330
     1331    if (fDoPrePostProcess > 0)
     1332        crStateSwitchPrepare(NULL, pCurCtx, idDrawFBO, idReadFBO);
     1333
     1334    cr_server.head_spu->dispatch_table.MakeCurrent( window, nativeWindow, context);
     1335
     1336    if (fDoPrePostProcess < 0)
     1337        crStateSwitchPostprocess(pCurCtx, NULL, idDrawFBO, idReadFBO);
     1338}
     1339
     1340void crServerInitTmpCtxDispatch()
     1341{
     1342    crSPUInitDispatchTable(&cr_server.TmpCtxDispatch);
     1343    crSPUCopyDispatchTable(&cr_server.TmpCtxDispatch, &cr_server.head_spu->dispatch_table);
     1344    cr_server.TmpCtxDispatch.MakeCurrent = crServerMakeTmpCtxCurrent;
     1345}
     1346
     1347/* dump stuff */
     1348#ifdef VBOX_WITH_CRSERVER_DUMPER
     1349
     1350/* first four bits are buffer dump config
     1351 * second four bits are texture dump config
     1352 * config flags:
     1353 * 1 - blit on enter
     1354 * 2 - blit on exit
     1355 *
     1356 *
     1357 * Example:
     1358 *
     1359 * 0x03 - dump buffer on enter and exit
     1360 * 0x22 - dump texture and buffer on exit */
     1361int g_CrDbgDumpDraw = 0; //CR_SERVER_DUMP_F_DRAW_BUFF_ENTER | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE;
     1362
     1363void crServerDumpCheckTerm()
     1364{
     1365    if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
     1366        return;
     1367
     1368    CrBltTerm(&cr_server.RecorderBlitter);
     1369}
     1370
     1371int crServerDumpCheckInit()
     1372{
     1373    int rc;
     1374    CR_BLITTER_WINDOW BltWin;
     1375    CR_BLITTER_CONTEXT BltCtx;
     1376    CRMuralInfo *pBlitterMural;
     1377
     1378    if (CrBltIsInitialized(&cr_server.RecorderBlitter))
     1379        return VINF_SUCCESS;
     1380
     1381    pBlitterMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.visualBits);
     1382    if (!pBlitterMural)
     1383    {
     1384        crWarning("crServerGetDummyMural failed");
     1385        return VERR_GENERAL_FAILURE;
     1386    }
     1387
     1388    crServerVBoxBlitterWinInit(&BltWin, pBlitterMural);
     1389    crServerVBoxBlitterCtxInit(&BltCtx, &cr_server.MainContextInfo);
     1390
     1391    rc = CrBltInit(&cr_server.RecorderBlitter, &BltCtx, true, true, &cr_server.TmpCtxDispatch);
     1392    if (!RT_SUCCESS(rc))
     1393    {
     1394        crWarning("CrBltInit failed rc %d", rc);
     1395        return rc;
     1396    }
     1397
     1398    rc = CrBltMuralSetCurrent(&cr_server.RecorderBlitter, &BltWin);
     1399    if (!RT_SUCCESS(rc))
     1400    {
     1401        crWarning("CrBltMuralSetCurrent failed rc %d", rc);
     1402        return rc;
     1403    }
     1404
     1405#if 0
     1406    crDmpDbgPrintInit(&cr_server.DbgPrintDumper);
     1407    cr_server.pDumper = &cr_server.DbgPrintDumper.Base;
     1408#else
     1409    crDmpHtmlInit(&cr_server.HtmlDumper, "S:\\projects\\virtualbox\\3d\\dumps\\1", "index.html");
     1410    cr_server.pDumper = &cr_server.HtmlDumper.Base;
     1411#endif
     1412
     1413    crRecInit(&cr_server.Recorder, &cr_server.RecorderBlitter, &cr_server.TmpCtxDispatch, cr_server.pDumper);
     1414    return VINF_SUCCESS;
     1415}
     1416
     1417void crServerDumpBuffer()
     1418{
     1419    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
     1420    CR_BLITTER_WINDOW BltWin;
     1421    CR_BLITTER_CONTEXT BltCtx;
     1422    CRContext *ctx = crStateGetCurrent();
     1423    GLint idx = crServerMuralFBOIdxFromBufferName(cr_server.currentMural, pCtxInfo->pContext->buffer.drawBuffer);
     1424    GLint idFBO;
     1425    GLint idTex;
     1426    VBOXVR_TEXTURE RedirTex;
     1427    int rc = crServerDumpCheckInit();
     1428    if (!RT_SUCCESS(rc))
     1429    {
     1430        crWarning("crServerDumpCheckInit failed, rc %d", rc);
     1431        return;
     1432    }
     1433
     1434    if (idx < 0)
     1435    {
     1436        crWarning("neg idx, unsupported");
     1437        return;
     1438    }
     1439
     1440    idFBO = CR_SERVER_FBO_FOR_IDX(cr_server.currentMural, idx);
     1441    idTex = CR_SERVER_FBO_TEX_FOR_IDX(cr_server.currentMural, idx);
     1442
     1443    crServerVBoxBlitterWinInit(&BltWin, cr_server.currentMural);
     1444    crServerVBoxBlitterCtxInit(&BltCtx, pCtxInfo);
     1445
     1446    RedirTex.width = cr_server.currentMural->fboWidth;
     1447    RedirTex.height = cr_server.currentMural->fboHeight;
     1448    RedirTex.target = GL_TEXTURE_2D;
     1449    RedirTex.hwid = idTex;
     1450
     1451    crRecDumpBuffer(&cr_server.Recorder, ctx, &BltCtx, &BltWin, idFBO, idTex ? &RedirTex : NULL);
     1452}
     1453
     1454void crServerDumpTextures()
     1455{
     1456    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
     1457    CR_BLITTER_WINDOW BltWin;
     1458    CR_BLITTER_CONTEXT BltCtx;
     1459    CRContext *ctx = crStateGetCurrent();
     1460    int rc = crServerDumpCheckInit();
     1461    if (!RT_SUCCESS(rc))
     1462    {
     1463        crWarning("crServerDumpCheckInit failed, rc %d", rc);
     1464        return;
     1465    }
     1466
     1467    crServerVBoxBlitterWinInit(&BltWin, cr_server.currentMural);
     1468    crServerVBoxBlitterCtxInit(&BltCtx, pCtxInfo);
     1469
     1470    crRecDumpTextures(&cr_server.Recorder, ctx, &BltCtx, &BltWin);
     1471}
     1472
     1473bool crServerDumpFilter(int event)
     1474{
     1475    return true;
     1476}
     1477#endif
     1478/* */
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r46229 r46343  
    914914        crServerRpwEntryDrawSettingsToTex(&mural->RpwEntry, &DstTex);
    915915
    916         cr_serverCtxSwitchPrepare(&CtxSwitch, NULL);
     916        crServerCtxSwitchPrepare(&CtxSwitch, NULL);
    917917
    918918        crServerVBoxBlitterWinInit(&CurrentBltInfo, pCurrentMural);
     
    933933        }
    934934
    935         cr_serverCtxSwitchPostprocess(&CtxSwitch);
     935        crServerCtxSwitchPostprocess(&CtxSwitch);
    936936
    937937#if 1
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_rpw.cpp

    r45376 r46343  
    368368                        CR_SERVER_CTX_SWITCH CtxSwitch;
    369369
    370                         cr_serverCtxSwitchPrepare(&CtxSwitch, NULL);
     370                        crServerCtxSwitchPrepare(&CtxSwitch, NULL);
    371371
    372372                        cr_server.head_spu->dispatch_table.Flush();
     
    383383                            cr_server.head_spu->dispatch_table.MakeCurrent(CR_RENDER_DEFAULT_WINDOW_ID, 0, CR_RENDER_DEFAULT_CONTEXT_ID);
    384384
    385                         cr_serverCtxSwitchPostprocess(&CtxSwitch);
     385                        crServerCtxSwitchPostprocess(&CtxSwitch);
    386386
    387387                        rc = RTThreadCreate(&pWorker->hThread, crServerRpwWorkerThread, pWorker, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "CrServerDw");
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r45942 r46343  
    465465    /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    466466    /* CrVrScrCompositorLock(&mural->Compositor); */
    467 #if 0
    468467    if (!mural->bReceivedRects)
    469468    {
     
    489488    }
    490489    else
    491 #endif
    492490    {
    493491        rc = CrVrScrCompositorEntryTexUpdate(&mural->Compositor, &mural->CEntry, &Tex);
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r45921 r46343  
    679679                DstRect.xRight = paDstRegions[i].xRight * scaleX;
    680680                DstRect.yBottom = paDstRegions[i].yBottom * scaleY;
    681                 CrBltBlitTexMural(pBlitter, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS);
     681                CrBltBlitTexMural(pBlitter, true, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS);
    682682            }
    683683        }
     
    701701        if (RT_SUCCESS(rc))
    702702        {
    703             CrBltBlitTexMural(pBlitter, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS);
     703            CrBltBlitTexMural(pBlitter, true, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS);
    704704        }
    705705        else
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r45673 r46343  
    12841284                    }
    12851285                   
    1286                     CrBltBlitTexMural(m_pBlitter, &pEntry->Tex, pSrcRect, pDstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS);
     1286                    CrBltBlitTexMural(m_pBlitter, true, &pEntry->Tex, pSrcRect, pDstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS);
    12871287                }
    12881288                CrBltLeave(m_pBlitter);
     
    14071407                            }
    14081408                   
    1409                             CrBltBlitTexMural(m_pBlitter, &pEntry->Tex, pSrcRect, pDstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_SRC_YCOORDS);
     1409                            CrBltBlitTexMural(m_pBlitter, true, &pEntry->Tex, pSrcRect, pDstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_SRC_YCOORDS);
    14101410                        }
    14111411                        CrBltLeave(m_pBlitter);
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