Changeset 46368 in vbox for trunk/src/VBox/GuestHost/OpenGL
- Timestamp:
- Jun 3, 2013 5:24:51 PM (12 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/chromium.h
r45132 r46368 722 722 /*configures host to create windows initially hidden*/ 723 723 #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 724 726 725 727 /**********************************************************************/ -
trunk/src/VBox/GuestHost/OpenGL/include/cr_dump.h
r46344 r46368 32 32 RT_C_DECLS_BEGIN 33 33 34 DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg);34 DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc); 35 35 36 36 DECLEXPORT(void) crDmpDumpStrDbgPrint(struct CR_DUMPER * pDumper, const char*pszStr); … … 38 38 struct CR_DUMPER; 39 39 40 typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg);40 typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc); 41 41 typedef DECLCALLBACKPTR(void, PFNCRDUMPSTR)(struct CR_DUMPER * pDumper, const char*pszStr); 42 42 … … 47 47 } CR_DUMPER; 48 48 49 #define crDmpImg(_pDumper, _p Desc, _pImg) do { \50 (_pDumper)->pfnDumpImg((_pDumper), (_p Desc), (_pImg)); \49 #define crDmpImg(_pDumper, _pImg, _pDesc) do { \ 50 (_pDumper)->pfnDumpImg((_pDumper), (_pImg), (_pDesc)); \ 51 51 } while (0) 52 52 … … 67 67 va_start(pArgList, pszStr); 68 68 crDmpStrV(pDumper, pszStr, pArgList); 69 va_end(pArgList); 70 } 71 72 DECLINLINE(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 79 DECLINLINE(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); 69 84 va_end(pArgList); 70 85 } … … 108 123 VBOXDUMPDECL(void) crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex); 109 124 VBOXDUMPDECL(void) crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin); 125 VBOXDUMPDECL(void) crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); 126 VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); 127 VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx); 128 129 130 typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj); 131 void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey); 110 132 111 133 RT_C_DECLS_END -
trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h
r46343 r46368 541 541 #endif 542 542 543 int RcToGuest; 544 int RcToGuestOnce; 545 543 546 /* @todo: should we use just one blitter? 544 547 * we use two currently because the drawable attribs can differ*/ -
trunk/src/VBox/GuestHost/OpenGL/util/dump.cpp
r46344 r46368 105 105 } 106 106 107 typedef struct CRDUMPGETHWID_DATA 108 { 109 GLuint hwid; 110 PFNCRDUMPGETHWID pfnGetHwid; 111 unsigned long Key; 112 void* pvObj; 113 } CRDUMPGETHWID_DATA; 114 115 static 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 128 void* 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 107 143 #ifdef VBOX_WITH_CRDUMPER 108 144 #if 0 … … 113 149 } CR_SERVER_DUMP_FIND_TEX; 114 150 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;151 void 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; 119 155 if (pTobj->hwid == pTex->hwid) 120 156 pTex->pTobj = pTobj; 121 157 } 122 158 #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 } 123 166 124 167 void crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex) … … 247 290 if (RT_SUCCESS(rc)) 248 291 { 249 crDmpImg(pRec->pDumper, "buffer_data", &Img);292 crDmpImg(pRec->pDumper, &Img, "buffer_data"); 250 293 CrBltImgFree(pRec->pBlitter, &Img); 251 294 } … … 256 299 257 300 CrBltLeave(pRec->pBlitter); 301 } 302 303 static 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 314 static 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 354 static 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 363 static DECLCALLBACK(GLuint) crDmpGetHwidShaderCB(void *pvObj) 364 { 365 return ((CRGLSLShader*)pvObj)->hwid; 366 } 367 368 static DECLCALLBACK(GLuint) crDmpGetHwidProgramCB(void *pvObj) 369 { 370 return ((CRGLSLProgram*)pvObj)->hwid; 371 } 372 373 void 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 427 void 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 482 VBOXDUMPDECL(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 } 258 500 } 259 501 … … 293 535 CRTextureUnit *tu = &ctx->texture.unit[i]; 294 536 537 if (i > 1) 538 break; 539 295 540 if (curTexUnit != i + GL_TEXTURE0) 296 541 { … … 316 561 } 317 562 318 if (enabled2D)563 // if (enabled2D) 319 564 { 320 565 GLint hwTex = 0; … … 351 596 if (RT_SUCCESS(rc)) 352 597 { 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); 354 599 CrBltImgFree(pRec->pBlitter, &Img); 355 600 } … … 365 610 } 366 611 } 367 else368 {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 374 619 if (enabled3D) 375 620 { … … 382 627 } 383 628 384 if (enabledRect) 385 { 386 629 // if (enabledRect) 630 { 387 631 GLint hwTex = 0; 388 632 CR_BLITTER_IMG Img = {0}; … … 418 662 if (RT_SUCCESS(rc)) 419 663 { 420 crDmpImg (pRec->pDumper, "TEXTURE_RECTANGLE data", &Img);664 crDmpImgF(pRec->pDumper, &Img, "Unit %d: TEXTURE_RECTANGLE data", i); 421 665 CrBltImgFree(pRec->pBlitter, &Img); 422 666 } … … 432 676 } 433 677 } 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 440 685 } 441 686 … … 470 715 } 471 716 472 DECLCALLBACK(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, const char*pszEntryDesc, CR_BLITTER_IMG *pImg)717 DECLCALLBACK(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc) 473 718 { 474 719 crDmpPrintDumpDmlCmd(pszEntryDesc, pImg->pvData, pImg->width, pImg->height, pImg->bpp, pImg->pitch); … … 484 729 { 485 730 fprintf(pDumper->pFile, "%s", pszStr); 731 fflush(pDumper->pFile); 486 732 } 487 733 … … 489 735 { 490 736 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 741 static DECLCALLBACK(void) crDmpHtmlDumpImg(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc) 495 742 { 496 743 CR_HTML_DUMPER * pHtmlDumper = (CR_HTML_DUMPER*)pDumper; … … 498 745 size_t cbWritten = RTStrPrintf(szBuffer, sizeof(szBuffer), "%s/", pHtmlDumper->pszDir); 499 746 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); 501 748 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", 503 750 pszFileName, pszEntryDesc, pszFileName, pszEntryDesc); 751 fflush(pHtmlDumper->pFile); 504 752 } 505 753 506 754 static void crDmpHtmlPrintHeader(struct CR_HTML_DUMPER * pDumper) 507 755 { 508 fprintf(pDumper->pFile, "<html><body>"); 756 fprintf(pDumper->pFile, "<html><body>\n"); 757 fflush(pDumper->pFile); 509 758 } 510 759 511 760 static void crDmpHtmlPrintFooter(struct CR_HTML_DUMPER * pDumper) 512 761 { 513 fprintf(pDumper->pFile, "</body></html>"); 762 fprintf(pDumper->pFile, "</body></html>\n"); 763 fflush(pDumper->pFile); 514 764 } 515 765
Note:
See TracChangeset
for help on using the changeset viewer.