VirtualBox

Changeset 46453 in vbox


Ignore:
Timestamp:
Jun 7, 2013 9:27:03 PM (11 years ago)
Author:
vboxsync
Message:

crOpenGL: more dump/debug stuff

Location:
trunk/src/VBox
Files:
6 edited

Legend:

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

    r46395 r46453  
    8585}
    8686
    87 VBOXDUMPDECL(size_t) crDmpFormatArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal);
    88 VBOXDUMPDECL(size_t) crDmpFormatRawArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal);
    89 VBOXDUMPDECL(size_t) crDmpFormatMatrixArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cX, uint32_t cY);
     87VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cVal);
     88VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cVal);
     89VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cX, uint32_t cY);
    9090
    9191typedef struct CR_DBGPRINT_DUMPER
     
    134134VBOXDUMPDECL(void) crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx);
    135135VBOXDUMPDECL(void) crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx);
     136VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal);
     137VBOXDUMPDECL(void) crRecDumpVertAttrF(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, ...);
     138VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList);
    136139
    137140typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj);
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp

    r46402 r46453  
    165165}
    166166
    167 VBOXDUMPDECL(size_t) crDmpFormatRawArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal)
     167DECLINLINE(size_t) crDmpFormatVal(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbVal, const void *pvVal)
     168{
     169    if (pszElFormat[0] != '%' || pszElFormat[1] == '\0')
     170    {
     171        crWarning("invalid format %s", pszElFormat);
     172        return 0;
     173    }
     174    switch (cbVal)
     175    {
     176        case 8:
     177            return sprintf_s(pString, cbString, pszElFormat, *((double*)pvVal));
     178        case 4:
     179        {
     180            /* we do not care only about type specifiers, all the rest is not accepted */
     181            switch (pszElFormat[1])
     182            {
     183                case 'f':
     184                    /* float would be promoted to double */
     185                    return sprintf_s(pString, cbString, pszElFormat, *((float*)pvVal));
     186                default:
     187                    return sprintf_s(pString, cbString, pszElFormat, *((uint32_t*)pvVal));
     188            }
     189        }
     190        case 2:
     191            return sprintf_s(pString, cbString, pszElFormat, *((uint16_t*)pvVal));
     192        case 1:
     193            return sprintf_s(pString, cbString, pszElFormat, *((uint8_t*)pvVal));
     194        default:
     195            crWarning("unsupported size %d", cbVal);
     196            return 0;
     197    }
     198}
     199
     200VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
    168201{
    169202    if (cbString < 2)
     
    177210    --cbString;
    178211    size_t cbWritten;
     212    const uint8_t *pu8Val = (const uint8_t *)pvVal;
    179213    for (uint32_t i = 0; i < cVal; ++i)
    180214    {
    181         cbWritten = sprintf_s(pString, cbString,
    182                 (i != cVal - 1) ? "%f, " : "%f", *pVal);
     215        cbWritten = crDmpFormatVal(pString, cbString, pszElFormat, cbEl, (const void *)pu8Val);
     216        pu8Val += cbEl;
    183217        Assert(cbString >= cbWritten);
    184218        pString += cbWritten;
    185219        cbString -= cbWritten;
     220        if (i != cVal - 1)
     221        {
     222            cbWritten = sprintf_s(pString, cbString, ", ");
     223            Assert(cbString >= cbWritten);
     224            pString += cbWritten;
     225            cbString -= cbWritten;
     226        }
    186227    }
    187228
     
    204245}
    205246
    206 VBOXDUMPDECL(size_t) crDmpFormatMatrixArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cX, uint32_t cY)
     247VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cX, uint32_t cY)
    207248{
    208249    if (cbString < 2)
     
    216257    --cbString;
    217258    size_t cbWritten;
     259    const uint8_t *pu8Val = (const uint8_t *)pvVal;
    218260    for (uint32_t i = 0; i < cY; ++i)
    219261    {
    220         cbWritten = crDmpFormatRawArrayf(pString, cbString, pVal, cX);
     262        cbWritten = crDmpFormatRawArray(pString, cbString, pszElFormat, cbEl, (const void *)pu8Val, cX);
     263        pu8Val += (cbEl * cX);
    221264        Assert(cbString >= cbWritten);
    222265        pString += cbWritten;
     
    253296}
    254297
    255 VBOXDUMPDECL(size_t) crDmpFormatArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal)
     298VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
    256299{
    257300    switch(cVal)
    258301    {
    259302        case 1:
    260             return sprintf_s(pString, cbString, "%f", *pVal);
     303            return crDmpFormatVal(pString, cbString, pszElFormat, cbEl, pvVal);
    261304        case 16:
    262             return crDmpFormatMatrixArrayf(pString, cbString, pVal, 4, 4);
     305            return crDmpFormatMatrixArray(pString, cbString, pszElFormat, cbEl, pvVal, 4, 4);
    263306        case 9:
    264             return crDmpFormatMatrixArrayf(pString, cbString, pVal, 3, 3);
     307            return crDmpFormatMatrixArray(pString, cbString, pszElFormat, cbEl, pvVal, 3, 3);
    265308        case 0:
    266309            crWarning("value array is empty");
    267310            return 0;
    268311        default:
    269             return crDmpFormatRawArrayf(pString, cbString, pVal, cVal);
    270     }
     312            return crDmpFormatRawArray(pString, cbString, pszElFormat, cbEl, pvVal, cVal);
     313    }
     314}
     315
     316VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
     317{
     318    char aBuf[1024];
     319    crDmpFormatRawArray(aBuf, sizeof (aBuf), pszElFormat, cbEl, pvVal, cVal);
     320    crDmpStrF(pRec->pDumper, "(%u, %s)", idx, aBuf);
     321}
     322
     323VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList)
     324{
     325    crDmpStrV(pRec->pDumper, pszFormat, pArgList);
     326}
     327
     328VBOXDUMPDECL(void) crRecDumpVertAttrF(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, ...)
     329{
     330    va_list pArgList;
     331    va_start(pArgList, pszFormat);
     332    crRecDumpVertAttrV(pRec, ctx, pszFormat, pArgList);
     333    va_end(pArgList);
    271334}
    272335
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py

    r46401 r46453  
    7373{
    7474    char aBuf[4096];
    75     crDmpFormatArrayf(aBuf, sizeof (aBuf), pfData, pDesc->num_values);
     75    crDmpFormatArray(aBuf, sizeof (aBuf), "%f", sizeof (float), pfData, pDesc->num_values);
    7676    crDmpStrF(pDumper, "%s = %s;", pDesc->pszName, aBuf);
    7777}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r46395 r46453  
    398398void crServerDumpFramesCheck();
    399399void crServerDumpState();
     400void crServerDumpDrawel(const char*pszFormat, ...);
     401void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal);
     402
    400403
    401404extern unsigned long g_CrDbgDumpEnabled;
     
    461464#define CR_SERVER_DUMP_F_DRAW_STATE_ENTER                0x00000004
    462465#define CR_SERVER_DUMP_F_DRAW_STATE_LEAVE                0x00000008
    463 
    464466#define CR_SERVER_DUMP_F_DRAW_ENTER_ALL (CR_SERVER_DUMP_F_DRAW_BUFF_ENTER \
    465467        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER \
     
    477479
    478480#define CR_SERVER_DUMP_F_COMPILE_SHADER         0x00001000
    479 #define CR_SERVER_DUMP_F_LINK_PROGRAM           0x00002000
     481#define CR_SERVER_DUMP_F_SHADER_SOURCE          0x00002000
     482#define CR_SERVER_DUMP_F_LINK_PROGRAM           0x00004000
    480483#define CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER      0x00010000
    481484#define CR_SERVER_DUMP_F_SWAPBUFFERS_LEAVE      0x00020000
     485#define CR_SERVER_DUMP_F_DRAWEL                 0x00100000
     486
    482487
    483488#define CR_SERVER_DUMP_DEFAULT_FILTER_OP(_ev) ((((_ev) & g_CrDbgDumpDraw) != 0) \
     
    505510            crServerDumpCheckInit(); \
    506511            crDmpStrF(cr_server.Recorder.pDumper, "<== %s", __FUNCTION__); \
     512            if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_TEX_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpTextures(); } \
    507513            if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpBuffer(-1); } \
    508             if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_TEX_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpTextures(); } \
    509514            if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramUniforms(); } \
    510515            if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgram(); } \
     
    516521            if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_COMPILE_SHADER, cr_server.Recorder.pDumper)) break; \
    517522            crServerDumpCheckInit(); \
     523            crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
    518524            crServerDumpShader((_id)); \
     525            crDmpStrF(cr_server.Recorder.pDumper, "====="); \
     526        } while (0)
     527
     528#define CR_SERVER_DUMP_SHADER_SOURCE(_id) do { \
     529            if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SHADER_SOURCE, cr_server.Recorder.pDumper)) break; \
     530            crServerDumpCheckInit(); \
     531            crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
     532            crServerDumpShader((_id)); \
     533            crDmpStrF(cr_server.Recorder.pDumper, "====="); \
    519534        } while (0)
    520535
     
    522537            if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_LINK_PROGRAM, cr_server.Recorder.pDumper)) break; \
    523538            crServerDumpCheckInit(); \
     539            crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
    524540            crServerDumpProgram((_id)); \
     541            crDmpStrF(cr_server.Recorder.pDumper, "====="); \
    525542        } while (0)
    526543
     
    536553            if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SWAPBUFFERS_LEAVE, cr_server.Recorder.pDumper)) break; \
    537554            crServerDumpCheckInit(); \
    538         } while (0)
     555            crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
     556        } while (0)
     557
     558#define CR_SERVER_DUMP_DRAWEL_F(_msg) do { \
     559        if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAWEL, cr_server.Recorder.pDumper)) break; \
     560        crServerDumpCheckInit(); \
     561        crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
     562        crServerDumpDrawel _msg; \
     563    } while (0)
     564
     565#define CR_SERVER_DUMP_DRAWEL_V(_index, _pszElFormat, _cbEl, _pvVal, _cVal) do { \
     566        if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAWEL, cr_server.Recorder.pDumper)) break; \
     567        crServerDumpCheckInit(); \
     568        crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
     569        crServerDumpDrawelv((_index), (_pszElFormat), (_cbEl), (_pvVal), (_cVal)); \
     570    } while (0)
    539571#else /* if !defined VBOX_WITH_CRSERVER_DUMPER */
    540572#define CR_SERVER_DUMP_DRAW_ENTER() do {} while (0)
     
    544576#define CR_SERVER_DUMP_SWAPBUFFERS_ENTER() do {} while (0)
    545577#define CR_SERVER_DUMP_SWAPBUFFERS_LEAVE() do {} while (0)
     578#define CR_SERVER_DUMP_SHADER_SOURCE() do {} while (0)
     579#define CR_SERVER_DUMP_DRAWEL_F(_msg) do {} while (0)
     580#define CR_SERVER_DUMP_DRAWEL_V(_pszElFormat, _cbEl, _pvVal, _cVal) do {} while (0)
    546581#endif /* !VBOX_WITH_CRSERVER_DUMPER */
    547582
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.c

    r46368 r46453  
    3838    CRASSERT(err == GL_NO_ERROR);
    3939#endif
     40    CR_SERVER_DUMP_SHADER_SOURCE(shader);
    4041}
    4142
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r46396 r46453  
    13981398        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
    13991399        | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
    1400         | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
     1400        | CR_SERVER_DUMP_F_DRAW_TEX_LEAVE
    14011401        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
    14021402        | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
    14031403        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
     1404        | CR_SERVER_DUMP_F_DRAWEL
    14041405        ; //CR_SERVER_DUMP_F_DRAW_BUFF_ENTER | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE;
    14051406unsigned long g_CrDbgDumpDrawFramesSettings = CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
     
    14951496{
    14961497    CRContext *ctx = crStateGetCurrent();
    1497     Assert(0);
    14981498    crRecDumpGlGetState(&cr_server.Recorder, ctx);
    14991499    crRecDumpGlEnableState(&cr_server.Recorder, ctx);
     1500}
     1501
     1502void crServerDumpDrawel(const char*pszFormat, ...)
     1503{
     1504    CRContext *ctx = crStateGetCurrent();
     1505    va_list pArgList;
     1506    va_start(pArgList, pszFormat);
     1507    crRecDumpVertAttrV(&cr_server.Recorder, ctx, pszFormat, pArgList);
     1508    va_end(pArgList);
     1509}
     1510
     1511void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
     1512{
     1513    CRContext *ctx = crStateGetCurrent();
     1514    crRecDumpVertAttrv(&cr_server.Recorder, ctx, idx, pszElFormat, cbEl, pvVal, cVal);
    15001515}
    15011516
     
    15561571}
    15571572
    1558 static uint32_t g_VDbgCDraws = 0;
    1559 static uint32_t g_VDbgCFrames = 0;
    1560 static uint32_t g_VDbgDoFrameDump = 0;
    1561 static uint32_t g_VDbgInitFrameDump = 0;
    1562 
    1563 
    15641573bool crServerDumpFilterOp(unsigned long event, CR_DUMPER *pDumper)
    15651574{
    1566     CRContext *ctx = crStateGetCurrent();
    1567     if (event & CR_SERVER_DUMP_F_DRAW_ALL)
    1568     {
    1569         if(!ctx->glsl.activeProgram || ctx->glsl.activeProgram->id != 21)
    1570             return false;
    1571 
    1572         if (event & CR_SERVER_DUMP_F_DRAW_ENTER_ALL)
    1573         {
    1574             ++g_VDbgCDraws;
    1575 //            crDmpStrF(cr_server.Recorder.pDumper, "DRAW(%d:%d)", g_VDbgCFrames, g_VDbgCDraws);
    1576         }
    1577 
    1578         if (!g_VDbgDoFrameDump)
    1579             return false;
    1580 
    1581 #define CR_SERVER_DUMP_MARKER_ENTER_STR "VBox.Cr.DrawEnter"
    1582 #define CR_SERVER_DUMP_MARKER_LEAVE_STR "VBox.Cr.DrawLeave"
    1583 
    1584         if (0)//(g_VDbgCFrames == 53 && g_VDbgCDraws == 13)
    1585         {
    1586             if (event & CR_SERVER_DUMP_F_DRAW_ENTER_ALL)
    1587                 cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_SERVER_DUMP_MARKER_ENTER_STR), CR_SERVER_DUMP_MARKER_ENTER_STR);
    1588             else
    1589                 cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_SERVER_DUMP_MARKER_LEAVE_STR), CR_SERVER_DUMP_MARKER_LEAVE_STR);
    1590         }
    1591     }
    1592     else if (event & CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER)
    1593     {
    1594         bool fSkip = true;
    1595         ++g_VDbgCFrames;
    1596 //        crDmpStrF(cr_server.Recorder.pDumper, "FRAME(%d)", g_VDbgCFrames);
    1597         g_VDbgCDraws = 0;
    1598         if (g_VDbgDoFrameDump)
    1599         {
    1600             g_VDbgDoFrameDump = 0;
    1601             fSkip = false;
    1602         }
    1603 
    1604         if (g_VDbgInitFrameDump)
    1605         {
    1606             g_VDbgDoFrameDump = 1;
    1607             g_VDbgInitFrameDump = 0;
    1608         }
    1609 
    1610         if (fSkip)
    1611             return false;
    1612     }
    1613 
    16141575    return CR_SERVER_DUMP_DEFAULT_FILTER_OP(event);
    16151576}
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