VirtualBox

Changeset 46368 in vbox for trunk/src/VBox/GuestHost/OpenGL


Ignore:
Timestamp:
Jun 3, 2013 5:24:51 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: more debugging

Location:
trunk/src/VBox/GuestHost/OpenGL
Files:
4 edited

Legend:

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

    r45132 r46368  
    722722/*configures host to create windows initially hidden*/
    723723#define GL_HOST_WND_CREATED_HIDDEN    0x8B2B
     724/* guest requests host whether e debug break is needed*/
     725#define GL_DBG_CHECK_BREAK_CR         0x8B2C
    724726
    725727/**********************************************************************/
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_dump.h

    r46344 r46368  
    3232RT_C_DECLS_BEGIN
    3333
    34 DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg);
     34DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc);
    3535
    3636DECLEXPORT(void) crDmpDumpStrDbgPrint(struct CR_DUMPER * pDumper, const char*pszStr);
     
    3838struct CR_DUMPER;
    3939
    40 typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg);
     40typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc);
    4141typedef DECLCALLBACKPTR(void, PFNCRDUMPSTR)(struct CR_DUMPER * pDumper, const char*pszStr);
    4242
     
    4747} CR_DUMPER;
    4848
    49 #define crDmpImg(_pDumper, _pDesc, _pImg) do { \
    50             (_pDumper)->pfnDumpImg((_pDumper), (_pDesc), (_pImg)); \
     49#define crDmpImg(_pDumper, _pImg, _pDesc) do { \
     50            (_pDumper)->pfnDumpImg((_pDumper), (_pImg), (_pDesc)); \
    5151        } while (0)
    5252
     
    6767    va_start(pArgList, pszStr);
    6868    crDmpStrV(pDumper, pszStr, pArgList);
     69    va_end(pArgList);
     70}
     71
     72DECLINLINE(void) crDmpImgV(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, va_list pArgList)
     73{
     74    char szBuffer[4096] = {0};
     75    RTStrPrintfV(szBuffer, sizeof (szBuffer), pszStr, pArgList);
     76    crDmpImg(pDumper, pImg, szBuffer);
     77}
     78
     79DECLINLINE(void) crDmpImgF(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, ...)
     80{
     81    va_list pArgList;
     82    va_start(pArgList, pszStr);
     83    crDmpImgV(pDumper, pImg, pszStr, pArgList);
    6984    va_end(pArgList);
    7085}
     
    108123VBOXDUMPDECL(void) crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex);
    109124VBOXDUMPDECL(void) crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin);
     125VBOXDUMPDECL(void) crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
     126VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
     127VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx);
     128
     129
     130typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj);
     131void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey);
    110132
    111133RT_C_DECLS_END
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h

    r46343 r46368  
    541541#endif
    542542
     543    int RcToGuest;
     544    int RcToGuestOnce;
     545
    543546    /* @todo: should we use just one blitter?
    544547     * we use two currently because the drawable attribs can differ*/
  • trunk/src/VBox/GuestHost/OpenGL/util/dump.cpp

    r46344 r46368  
    105105}
    106106
     107typedef struct CRDUMPGETHWID_DATA
     108{
     109    GLuint hwid;
     110    PFNCRDUMPGETHWID pfnGetHwid;
     111    unsigned long Key;
     112    void* pvObj;
     113} CRDUMPGETHWID_DATA;
     114
     115static void crDmpHashtableSearchByHwidCB(unsigned long key, void *pData1, void *pData2)
     116{
     117    CRDUMPGETHWID_DATA *pData = (CRDUMPGETHWID_DATA*)pData2;
     118    if (pData->pvObj)
     119        return;
     120
     121    if (pData->hwid == pData->pfnGetHwid(pData1))
     122    {
     123        pData->Key = key;
     124        pData->pvObj = pData1;
     125    }
     126}
     127
     128void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey)
     129{
     130    CRDUMPGETHWID_DATA Data = {0};
     131    Data.hwid = hwid;
     132    Data.pfnGetHwid = pfnGetHwid;
     133    crHashtableWalk(pHash, crDmpHashtableSearchByHwidCB, &Data);
     134
     135    Assert(Data.pvObj);
     136
     137    if (pKey)
     138        *pKey = Data.Key;
     139    return Data.pvObj;
     140}
     141
     142
    107143#ifdef VBOX_WITH_CRDUMPER
    108144#if 0
     
    113149} CR_SERVER_DUMP_FIND_TEX;
    114150
    115 void crServerDumpFindTexCb(unsigned long key, void *data1, void *data2)
    116 {
    117     CR_SERVER_DUMP_FIND_TEX *pTex = (CR_SERVER_DUMP_FIND_TEX*)data2;
    118     CRTextureObj *pTobj = (CRTextureObj *)data1;
     151void crServerDumpFindTexCb(unsigned long key, void *pData1, void *pData2)
     152{
     153    CR_SERVER_DUMP_FIND_TEX *pTex = (CR_SERVER_DUMP_FIND_TEX*)pData2;
     154    CRTextureObj *pTobj = (CRTextureObj *)pData1;
    119155    if (pTobj->hwid == pTex->hwid)
    120156        pTex->pTobj = pTobj;
    121157}
    122158#endif
     159
     160#define CR_DUMP_MAKE_CASE(_val) case _val: return #_val
     161#define CR_DUMP_MAKE_CASE_UNKNOWN(_val, _str, _pDumper) default: { \
     162    crWarning("%s %d", (_str), _val); \
     163    crDmpStrF((_pDumper), "WARNING: %s %d", (_str), _val); \
     164    return (_str); \
     165}
    123166
    124167void crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex)
     
    247290    if (RT_SUCCESS(rc))
    248291    {
    249         crDmpImg(pRec->pDumper, "buffer_data", &Img);
     292        crDmpImg(pRec->pDumper, &Img, "buffer_data");
    250293        CrBltImgFree(pRec->pBlitter, &Img);
    251294    }
     
    256299
    257300    CrBltLeave(pRec->pBlitter);
     301}
     302
     303static const char *crRecDumpShaderTypeString(GLenum enmType, CR_DUMPER *pDumper)
     304{
     305    switch (enmType)
     306    {
     307        CR_DUMP_MAKE_CASE(GL_VERTEX_SHADER_ARB);
     308        CR_DUMP_MAKE_CASE(GL_FRAGMENT_SHADER_ARB);
     309        CR_DUMP_MAKE_CASE(GL_GEOMETRY_SHADER_ARB);
     310        CR_DUMP_MAKE_CASE_UNKNOWN(enmType, "Unknown Shader Type", pDumper);
     311    }
     312}
     313
     314static char *crRecDumpGetLine(char **ppszStr, uint32_t *pcbStr)
     315{
     316    char *pszStr, *pNewLine;
     317    const uint32_t cbStr = *pcbStr;
     318
     319    if (!cbStr)
     320    {
     321        /* zero-length string */
     322        return NULL;
     323    }
     324
     325    if ((*ppszStr)[cbStr-1] != '\0')
     326    {
     327        crWarning("string should be null-rerminated, forcing it!");
     328        (*ppszStr)[cbStr-1] = '\0';
     329    }
     330    pszStr = *ppszStr;
     331    if (!*pszStr)
     332    {
     333        *pcbStr = 0;
     334        return NULL;
     335    }
     336
     337    if (!(pNewLine = strstr(pszStr, "\n")))
     338    {
     339        /* the string contains a single line! */
     340        *ppszStr += strlen(pszStr);
     341        *pcbStr = 0;
     342        return pszStr;
     343    }
     344
     345    *pNewLine = '\0';
     346    *pcbStr = cbStr - (((uintptr_t)pNewLine) - ((uintptr_t)pszStr)) - 1;
     347    Assert((*pcbStr) >= 0);
     348    Assert((*pcbStr) < cbStr);
     349    *ppszStr = pNewLine + 1;
     350
     351    return pszStr;
     352}
     353
     354static void crRecDumpStrByLine(CR_DUMPER *pDumper, char *pszStr, uint32_t cbStr)
     355{
     356    char *pszCurLine;
     357    while ((pszCurLine = crRecDumpGetLine(&pszStr, &cbStr)) != NULL)
     358    {
     359        crDmpStrF(pDumper, "%s", pszCurLine);
     360    }
     361}
     362
     363static DECLCALLBACK(GLuint) crDmpGetHwidShaderCB(void *pvObj)
     364{
     365    return ((CRGLSLShader*)pvObj)->hwid;
     366}
     367
     368static DECLCALLBACK(GLuint) crDmpGetHwidProgramCB(void *pvObj)
     369{
     370    return ((CRGLSLProgram*)pvObj)->hwid;
     371}
     372
     373void crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid)
     374{
     375    GLint length = 0;
     376    GLint type = 0;
     377    GLint compileStatus = 0;
     378    CRGLSLShader *pShad;
     379
     380    if (!id)
     381    {
     382        unsigned long tstKey = 0;
     383        Assert(hwid);
     384        pShad = (CRGLSLShader *)crDmpHashtableSearchByHwid(ctx->glsl.shaders, hwid, crDmpGetHwidShaderCB, &tstKey);
     385        Assert(pShad);
     386        if (!pShad)
     387            return;
     388        id = pShad->id;
     389        Assert(tstKey == id);
     390    }
     391    else
     392    {
     393        pShad = (CRGLSLShader *)crHashtableSearch(ctx->glsl.shaders, id);
     394        Assert(pShad);
     395        if (!pShad)
     396            return;
     397    }
     398
     399    if (!hwid)
     400        hwid = pShad->hwid;
     401
     402    Assert(pShad->hwid == hwid);
     403    Assert(pShad->id == id);
     404
     405    pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_SUBTYPE_ARB, &type);
     406    pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_COMPILE_STATUS_ARB, &compileStatus);
     407    crDmpStrF(pRec->pDumper, "SHADER ctx(%d) id(%d) hwid(%d) type(%s) status(%d):", ctx->id, id, hwid, crRecDumpShaderTypeString(type, pRec->pDumper), compileStatus);
     408
     409    pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &length);
     410
     411    char *pszSource = (char*)crCalloc(length + 1);
     412    if (!pszSource)
     413    {
     414        crWarning("crCalloc failed");
     415        crDmpStrF(pRec->pDumper, "WARNING: crCalloc failed");
     416        return;
     417    }
     418
     419    pRec->pDispatch->GetShaderSource(hwid, length, NULL, pszSource);
     420    crRecDumpStrByLine(pRec->pDumper, pszSource, length);
     421
     422    crFree(pszSource);
     423
     424    crDmpStr(pRec->pDumper, "===END SHADER====");
     425}
     426
     427void crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid)
     428{
     429    GLint cShaders = 0, linkStatus = 0;
     430    char *source = NULL;
     431    CRGLSLProgram *pProg;
     432
     433    if (!id)
     434    {
     435        unsigned long tstKey = 0;
     436        Assert(hwid);
     437        pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey);
     438        Assert(pProg);
     439        if (!pProg)
     440            return;
     441        id = pProg->id;
     442        Assert(tstKey == id);
     443    }
     444    else
     445    {
     446        pProg = (CRGLSLProgram *) crHashtableSearch(ctx->glsl.programs, id);
     447        Assert(pProg);
     448        if (!pProg)
     449            return;
     450    }
     451
     452    if (!hwid)
     453        hwid = pProg->hwid;
     454
     455    Assert(pProg->hwid == hwid);
     456    Assert(pProg->id == id);
     457
     458    pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_ATTACHED_OBJECTS_ARB, &cShaders);
     459    pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_LINK_STATUS_ARB, &linkStatus);
     460
     461    crDmpStrF(pRec->pDumper, "PROGRAM ctx(%d) id(%d) hwid(%d) status(%d) shaders(%d):", ctx->id, id, hwid, linkStatus, cShaders);
     462
     463    GLhandleARB *pShaders = (GLhandleARB*)crCalloc(cShaders * sizeof (*pShaders));
     464    if (!pShaders)
     465    {
     466        crWarning("crCalloc failed");
     467        crDmpStrF(pRec->pDumper, "WARNING: crCalloc failed");
     468        return;
     469    }
     470
     471    pRec->pDispatch->GetAttachedObjectsARB(hwid, cShaders, NULL, pShaders);
     472    for (GLint i = 0; i < cShaders; ++i)
     473    {
     474        crRecDumpShader(pRec, ctx, 0, pShaders[i]);
     475    }
     476
     477    crFree(pShaders);
     478
     479    crDmpStr(pRec->pDumper, "===END PROGRAM====");
     480}
     481
     482VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx)
     483{
     484    GLint curProgram = 0;
     485    pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram);
     486    if (curProgram)
     487    {
     488        Assert(ctx->glsl.activeProgram);
     489        if (!ctx->glsl.activeProgram)
     490            crWarning("no active program state with active hw program");
     491        else
     492            Assert(ctx->glsl.activeProgram->hwid == curProgram);
     493        crRecDumpProgram(pRec, ctx, 0, curProgram);
     494    }
     495    else
     496    {
     497        Assert(!ctx->glsl.activeProgram);
     498        crDmpStrF(pRec->pDumper, "--no active program");
     499    }
    258500}
    259501
     
    293535        CRTextureUnit *tu = &ctx->texture.unit[i];
    294536
     537        if (i > 1)
     538            break;
     539
    295540        if (curTexUnit != i + GL_TEXTURE0)
    296541        {
     
    316561        }
    317562
    318         if (enabled2D)
     563//        if (enabled2D)
    319564        {
    320565            GLint hwTex = 0;
     
    351596                    if (RT_SUCCESS(rc))
    352597                    {
    353                         crDmpImg(pRec->pDumper, "TEXTURE_2D data", &Img);
     598                        crDmpImgF(pRec->pDumper, &Img, "ctx(%d), Unit %d: TEXTURE_2D id(%d) hwid(%d)", ctx, i, pTobj->id, pTobj->hwid);
    354599                        CrBltImgFree(pRec->pBlitter, &Img);
    355600                    }
     
    365610                }
    366611            }
    367             else
    368             {
    369                 Assert(!pTobj || pTobj->hwid == 0);
    370                 crWarning("no TEXTURE_2D bound!");
    371             }
    372         }
    373 
     612//            else
     613//            {
     614//                Assert(!pTobj || pTobj->hwid == 0);
     615//                crWarning("no TEXTURE_2D bound!");
     616//            }
     617        }
     618#if 0
    374619        if (enabled3D)
    375620        {
     
    382627        }
    383628
    384         if (enabledRect)
    385         {
    386 
     629//        if (enabledRect)
     630        {
    387631            GLint hwTex = 0;
    388632            CR_BLITTER_IMG Img = {0};
     
    418662                    if (RT_SUCCESS(rc))
    419663                    {
    420                         crDmpImg(pRec->pDumper, "TEXTURE_RECTANGLE data", &Img);
     664                        crDmpImgF(pRec->pDumper, &Img, "Unit %d: TEXTURE_RECTANGLE data", i);
    421665                        CrBltImgFree(pRec->pBlitter, &Img);
    422666                    }
     
    432676                }
    433677            }
    434             else
    435             {
    436                 Assert(!pTobj || pTobj->hwid == 0);
    437                 crWarning("no TEXTURE_2D bound!");
    438             }
    439         }
     678//            else
     679//            {
     680//                Assert(!pTobj || pTobj->hwid == 0);
     681//                crWarning("no TEXTURE_RECTANGLE bound!");
     682//            }
     683        }
     684#endif
    440685    }
    441686
     
    470715}
    471716
    472 DECLCALLBACK(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg)
     717DECLCALLBACK(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc)
    473718{
    474719    crDmpPrintDumpDmlCmd(pszEntryDesc, pImg->pvData, pImg->width, pImg->height, pImg->bpp, pImg->pitch);
     
    484729{
    485730    fprintf(pDumper->pFile, "%s", pszStr);
     731    fflush(pDumper->pFile);
    486732}
    487733
     
    489735{
    490736    CR_HTML_DUMPER * pHtmlDumper = (CR_HTML_DUMPER*)pDumper;
    491     fprintf(pHtmlDumper->pFile, "<pre>%s</pre><br>", pszStr);
    492 }
    493 
    494 static DECLCALLBACK(void) crDmpHtmlDumpImg(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg)
     737    fprintf(pHtmlDumper->pFile, "<pre>%s</pre>\n", pszStr);
     738    fflush(pHtmlDumper->pFile);
     739}
     740
     741static DECLCALLBACK(void) crDmpHtmlDumpImg(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc)
    495742{
    496743    CR_HTML_DUMPER * pHtmlDumper = (CR_HTML_DUMPER*)pDumper;
     
    498745    size_t cbWritten = RTStrPrintf(szBuffer, sizeof(szBuffer), "%s/", pHtmlDumper->pszDir);
    499746    char *pszFileName = szBuffer + cbWritten;
    500     RTStrPrintf(pszFileName, sizeof(szBuffer) - cbWritten, "img%d.tga", ++pHtmlDumper->cImg);
     747    RTStrPrintf(pszFileName, sizeof(szBuffer) - cbWritten, "img%d.bmp", ++pHtmlDumper->cImg);
    501748    crDmpImgBmp(pImg, szBuffer);
    502     fprintf(pHtmlDumper->pFile, "<a href=\"%s\"><pre>%s</pre><img src=\"%s\" alt=\"%s\" width=\"150\" height=\"100\" /></a><br>",
     749    fprintf(pHtmlDumper->pFile, "<a href=\"%s\"><pre>%s</pre><img src=\"%s\" alt=\"%s\" width=\"150\" height=\"100\" /></a><br>\n",
    503750            pszFileName, pszEntryDesc, pszFileName, pszEntryDesc);
     751    fflush(pHtmlDumper->pFile);
    504752}
    505753
    506754static void crDmpHtmlPrintHeader(struct CR_HTML_DUMPER * pDumper)
    507755{
    508     fprintf(pDumper->pFile, "<html><body>");
     756    fprintf(pDumper->pFile, "<html><body>\n");
     757    fflush(pDumper->pFile);
    509758}
    510759
    511760static void crDmpHtmlPrintFooter(struct CR_HTML_DUMPER * pDumper)
    512761{
    513     fprintf(pDumper->pFile, "</body></html>");
     762    fprintf(pDumper->pFile, "</body></html>\n");
     763    fflush(pDumper->pFile);
    514764}
    515765
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