Changeset 46395 in vbox for trunk/src/VBox/GuestHost/OpenGL
- Timestamp:
- Jun 5, 2013 3:20:56 PM (12 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/Makefile.kmk
r46343 r46395 114 114 util/util.def \ 115 115 util/util.rc 116 ifdef VBOX_WITH_CRDUMPER 117 VBoxOGLcrutil_SOURCES += $(VBOX_PATH_CROGL_GENFILES)/dump_gen.cpp 118 endif 116 119 VBoxOGLcrutil_LIBS.win = \ 117 120 $(PATH_SDK_$(VBOX_WINDDK)_LIB)/ddraw.lib \ … … 138 141 ifdef VBOX_WITH_CRDUMPER 139 142 VBoxOGLcrutil_DEFS += VBOX_WITH_CRDUMPER 143 VBoxOGLcrutil_LIBS += \ 144 $(PATH_STAGE_LIB)/additions/VBoxOGLcrstate$(VBOX_SUFF_LIB) \ 145 $(PATH_STAGE_LIB)/additions/VBoxOGLspuload$(VBOX_SUFF_LIB) 140 146 endif 141 147 … … 161 167 VBoxOGLcrutil-x86_LIBS.win += $(VBOX_PATH_ADDITIONS_LIB)/VBoxDispMpLogger-x86$(VBOX_SUFF_LIB) 162 168 endif 169 ifdef VBOX_WITH_CRDUMPER 170 # VBOX_WITH_CRDUMPER is inheritted from VBoxOGLcrutil_DEFS 171 #VBoxOGLcrutil-x86_DEFS += VBOX_WITH_CRDUMPER 172 VBoxOGLcrutil-x86_LIBS += \ 173 $(PATH_STAGE_LIB)/additions/VBoxOGLcrstate-x86$(VBOX_SUFF_LIB) \ 174 $(PATH_STAGE_LIB)/additions/VBoxOGLspuload-x86$(VBOX_SUFF_LIB) 175 endif 163 176 # vc7 hangs during compilation of this file when optimizations are enabled. 164 177 VBoxOGLcrutil-x86_pixel.c_CFLAGS += -Od … … 181 194 ifdef VBOX_WITH_CRDUMPER 182 195 VBoxOGLhostcrutil_DEFS += VBOX_WITH_CRDUMPER 196 VBoxOGLhostcrutil_LIBS += \ 197 $(PATH_STAGE_LIB)/VBoxOGLhostcrstate$(VBOX_SUFF_LIB) \ 198 $(PATH_STAGE_LIB)/VBoxOGLhostspuload$(VBOX_SUFF_LIB) 183 199 endif 184 200 ifdef VBOX_WITH_CRHGSMI … … 196 212 $(call MSG_GENERATE,python,$@,$<) 197 213 $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) 214 215 ifdef VBOX_WITH_CRDUMPER 216 $(VBOX_PATH_CROGL_GENFILES)/dump_gen.cpp: $(PATH_SUB_CURRENT)/util/dump_gen.py $(PATH_ROOT)/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py $(addprefix $(PATH_SUB_CURRENT)/state_tracker/, state_isenabled.txt state_extensions_isenabled.txt) $(VBOX_CROGL_API_FILES) | $$(dir $$@) 217 $(call MSG_GENERATE,python,$@,$<) 218 $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D) 219 endif 198 220 199 221 # -
trunk/src/VBox/GuestHost/OpenGL/include/cr_dump.h
r46370 r46395 58 58 { 59 59 char szBuffer[4096] = {0}; 60 RTStrPrintfV(szBuffer, sizeof (szBuffer), pszStr, pArgList);60 vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList); 61 61 crDmpStr(pDumper, szBuffer); 62 62 } … … 73 73 { 74 74 char szBuffer[4096] = {0}; 75 RTStrPrintfV(szBuffer, sizeof (szBuffer), pszStr, pArgList);75 vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList); 76 76 crDmpImg(pDumper, pImg, szBuffer); 77 77 } … … 84 84 va_end(pArgList); 85 85 } 86 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); 86 90 87 91 typedef struct CR_DBGPRINT_DUMPER … … 126 130 VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); 127 131 VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx); 132 VBOXDUMPDECL(void) crRecDumpProgramUniforms(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); 133 VBOXDUMPDECL(void) crRecDumpCurrentProgramUniforms(CR_RECORDER *pRec, CRContext *ctx); 134 VBOXDUMPDECL(void) crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx); 135 VBOXDUMPDECL(void) crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx); 128 136 129 137 typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj); -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c
r44326 r46395 347 347 crStateFreeContext(CRContext *ctx) 348 348 { 349 #ifndef DEBUG_misha 349 350 CRASSERT(g_pAvailableContexts[ctx->id] == ctx); 351 #endif 350 352 if (g_pAvailableContexts[ctx->id] == ctx) 351 353 { … … 356 358 else 357 359 { 360 #ifndef DEBUG_misha 358 361 crWarning("freeing context 0x%x, id(%d) not being in the context list", ctx, ctx->id); 362 #endif 359 363 } 360 364 … … 406 410 crStateLightingInitBits( &(__currentBits->lighting) ); 407 411 } else 412 { 413 #ifndef DEBUG_misha 408 414 crWarning("State tracker is being re-initialized..\n"); 415 #endif 416 } 409 417 410 418 for (i=0;i<CR_MAX_CONTEXTS;i++) -
trunk/src/VBox/GuestHost/OpenGL/util/dump.cpp
r46370 r46395 165 165 } 166 166 167 VBOXDUMPDECL(size_t) crDmpFormatRawArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal) 168 { 169 if (cbString < 2) 170 { 171 crWarning("too few buffer size"); 172 return 0; 173 } 174 175 const size_t cbInitString = cbString; 176 *pString++ = '{'; 177 --cbString; 178 size_t cbWritten; 179 for (uint32_t i = 0; i < cVal; ++i) 180 { 181 cbWritten = sprintf_s(pString, cbString, 182 (i != cVal - 1) ? "%f, " : "%f", *pVal); 183 Assert(cbString >= cbWritten); 184 pString += cbWritten; 185 cbString -= cbWritten; 186 } 187 188 if (!cbString) 189 { 190 crWarning("too few buffer size"); 191 return 0; 192 } 193 *pString++ = '}'; 194 --cbString; 195 196 if (!cbString) 197 { 198 crWarning("too few buffer size"); 199 return 0; 200 } 201 *pString++ = '\0'; 202 203 return cbInitString - cbString; 204 } 205 206 VBOXDUMPDECL(size_t) crDmpFormatMatrixArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cX, uint32_t cY) 207 { 208 if (cbString < 2) 209 { 210 crWarning("too few buffer size"); 211 return 0; 212 } 213 214 const size_t cbInitString = cbString; 215 *pString++ = '{'; 216 --cbString; 217 size_t cbWritten; 218 for (uint32_t i = 0; i < cY; ++i) 219 { 220 cbWritten = crDmpFormatRawArrayf(pString, cbString, pVal, cX); 221 Assert(cbString >= cbWritten); 222 pString += cbWritten; 223 cbString -= cbWritten; 224 if (i != cY - 1) 225 { 226 if (cbString < 3) 227 { 228 crWarning("too few buffer size"); 229 return 0; 230 } 231 *pString++ = ','; 232 --cbString; 233 *pString++ = '\n'; 234 --cbString; 235 } 236 } 237 if (!cbString) 238 { 239 crWarning("too few buffer size"); 240 return 0; 241 } 242 *pString++ = '}'; 243 --cbString; 244 245 if (!cbString) 246 { 247 crWarning("too few buffer size"); 248 return 0; 249 } 250 *pString++ = '\0'; 251 252 return cbInitString - cbString; 253 } 254 255 VBOXDUMPDECL(size_t) crDmpFormatArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal) 256 { 257 switch(cVal) 258 { 259 case 1: 260 return sprintf_s(pString, cbString, "%f", *pVal); 261 case 16: 262 return crDmpFormatMatrixArrayf(pString, cbString, pVal, 4, 4); 263 case 9: 264 return crDmpFormatMatrixArrayf(pString, cbString, pVal, 3, 3); 265 case 0: 266 crWarning("value array is empty"); 267 return 0; 268 default: 269 return crDmpFormatRawArrayf(pString, cbString, pVal, cVal); 270 } 271 } 272 167 273 void crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex) 168 274 { … … 175 281 int rc; 176 282 177 Assert(0);178 179 283 pRec->pDispatch->GetIntegerv(GL_DRAW_BUFFER, &hwDrawBuf); 180 284 pRec->pDispatch->GetIntegerv(GL_FRAMEBUFFER_BINDING, &hwBuf); … … 309 413 CR_DUMP_MAKE_CASE(GL_GEOMETRY_SHADER_ARB); 310 414 CR_DUMP_MAKE_CASE_UNKNOWN(enmType, "Unknown Shader Type", pDumper); 415 } 416 } 417 418 static const char *crRecDumpVarTypeString(GLenum enmType, CR_DUMPER *pDumper) 419 { 420 switch (enmType) 421 { 422 CR_DUMP_MAKE_CASE(GL_FLOAT); 423 CR_DUMP_MAKE_CASE(GL_FLOAT_VEC2); 424 CR_DUMP_MAKE_CASE(GL_FLOAT_VEC3); 425 CR_DUMP_MAKE_CASE(GL_FLOAT_VEC4); 426 CR_DUMP_MAKE_CASE(GL_INT); 427 CR_DUMP_MAKE_CASE(GL_INT_VEC2); 428 CR_DUMP_MAKE_CASE(GL_INT_VEC3); 429 CR_DUMP_MAKE_CASE(GL_INT_VEC4); 430 CR_DUMP_MAKE_CASE(GL_BOOL); 431 CR_DUMP_MAKE_CASE(GL_BOOL_VEC2); 432 CR_DUMP_MAKE_CASE(GL_BOOL_VEC3); 433 CR_DUMP_MAKE_CASE(GL_BOOL_VEC4); 434 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT2); 435 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT3); 436 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT4); 437 CR_DUMP_MAKE_CASE(GL_SAMPLER_1D); 438 CR_DUMP_MAKE_CASE(GL_SAMPLER_2D); 439 CR_DUMP_MAKE_CASE(GL_SAMPLER_3D); 440 CR_DUMP_MAKE_CASE(GL_SAMPLER_CUBE); 441 CR_DUMP_MAKE_CASE(GL_SAMPLER_1D_SHADOW); 442 CR_DUMP_MAKE_CASE(GL_SAMPLER_2D_SHADOW); 443 CR_DUMP_MAKE_CASE(GL_SAMPLER_2D_RECT_ARB); 444 CR_DUMP_MAKE_CASE(GL_SAMPLER_2D_RECT_SHADOW_ARB); 445 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT2x3); 446 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT2x4); 447 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT3x2); 448 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT3x4); 449 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT4x2); 450 CR_DUMP_MAKE_CASE(GL_FLOAT_MAT4x3); 451 CR_DUMP_MAKE_CASE_UNKNOWN(enmType, "Unknown Variable Type", pDumper); 311 452 } 312 453 } … … 500 641 } 501 642 643 void crRecDumpProgramUniforms(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) 644 { 645 CRGLSLProgram *pProg; 646 647 if (!id) 648 { 649 unsigned long tstKey = 0; 650 Assert(hwid); 651 pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey); 652 Assert(pProg); 653 if (!pProg) 654 return; 655 id = pProg->id; 656 Assert(tstKey == id); 657 } 658 else 659 { 660 pProg = (CRGLSLProgram *) crHashtableSearch(ctx->glsl.programs, id); 661 Assert(pProg); 662 if (!pProg) 663 return; 664 } 665 666 if (!hwid) 667 hwid = pProg->hwid; 668 669 Assert(pProg->hwid == hwid); 670 Assert(pProg->id == id); 671 672 GLint maxUniformLen = 0, activeUniforms = 0, i, j, uniformsCount = 0; 673 GLenum type; 674 GLint size, location; 675 GLchar *pszName = NULL; 676 pRec->pDispatch->GetProgramiv(hwid, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLen); 677 pRec->pDispatch->GetProgramiv(hwid, GL_ACTIVE_UNIFORMS, &activeUniforms); 678 679 if (!maxUniformLen) 680 { 681 if (activeUniforms) 682 { 683 crWarning("activeUniforms (%d), while maxUniformLen is zero", activeUniforms); 684 activeUniforms = 0; 685 } 686 } 687 688 if (activeUniforms>0) 689 { 690 pszName = (GLchar *) crAlloc((maxUniformLen+8)*sizeof(GLchar)); 691 692 if (!pszName) 693 { 694 crWarning("crRecDumpProgramUniforms: out of memory"); 695 return; 696 } 697 } 698 699 for (i=0; i<activeUniforms; ++i) 700 { 701 pRec->pDispatch->GetActiveUniform(hwid, i, maxUniformLen, NULL, &size, &type, pszName); 702 uniformsCount += size; 703 } 704 Assert(uniformsCount>=activeUniforms); 705 706 if (activeUniforms>0) 707 { 708 GLfloat fdata[16]; 709 GLint idata[16]; 710 char *pIndexStr=NULL; 711 712 for (i=0; i<activeUniforms; ++i) 713 { 714 bool fPrintBraketsWithName = false; 715 pRec->pDispatch->GetActiveUniform(hwid, i, maxUniformLen, NULL, &size, &type, pszName); 716 717 if (size>1) 718 { 719 pIndexStr = crStrchr(pszName, '['); 720 if (!pIndexStr) 721 { 722 pIndexStr = pszName+crStrlen(pszName); 723 fPrintBraketsWithName = true; 724 } 725 } 726 727 if (fPrintBraketsWithName) 728 { 729 crDmpStrF(pRec->pDumper, "%s %s[%d];", crRecDumpVarTypeString(type, pRec->pDumper), pszName, size); 730 Assert(size > 1); 731 } 732 else 733 crDmpStrF(pRec->pDumper, "%s %s;", crRecDumpVarTypeString(type, pRec->pDumper), pszName); 734 735 GLint uniformTypeSize = crStateGetUniformSize(type); 736 Assert(uniformTypeSize >= 1); 737 738 for (j=0; j<size; ++j) 739 { 740 if (size>1) 741 { 742 sprintf(pIndexStr, "[%i]", j); 743 } 744 location = pRec->pDispatch->GetUniformLocation(hwid, pszName); 745 746 if (crStateIsIntUniform(type)) 747 { 748 pRec->pDispatch->GetUniformiv(hwid, location, &idata[0]); 749 switch (uniformTypeSize) 750 { 751 case 1: 752 crDmpStrF(pRec->pDumper, "%s = %d;", pszName, idata[0]); 753 break; 754 case 2: 755 crDmpStrF(pRec->pDumper, "%s = {%d, %d};", pszName, idata[0], idata[1]); 756 break; 757 case 3: 758 crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d};", pszName, idata[0], idata[1], idata[2]); 759 break; 760 case 4: 761 crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d, %d};", pszName, idata[0], idata[1], idata[2], idata[3]); 762 break; 763 default: 764 for (GLint k = 0; k < uniformTypeSize; ++k) 765 { 766 crDmpStrF(pRec->pDumper, "%s[%d] = %d;", pszName, k, idata[k]); 767 } 768 break; 769 } 770 } 771 else 772 { 773 pRec->pDispatch->GetUniformfv(hwid, location, &fdata[0]); 774 switch (uniformTypeSize) 775 { 776 case 1: 777 crDmpStrF(pRec->pDumper, "%s = %f;", pszName, fdata[0]); 778 break; 779 case 2: 780 crDmpStrF(pRec->pDumper, "%s = {%f, %f};", pszName, fdata[0], fdata[1]); 781 break; 782 case 3: 783 crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f};", pszName, fdata[0], fdata[1], fdata[2]); 784 break; 785 case 4: 786 crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f, %f};", pszName, fdata[0], fdata[1], fdata[2], fdata[3]); 787 break; 788 default: 789 for (GLint k = 0; k < uniformTypeSize; ++k) 790 { 791 crDmpStrF(pRec->pDumper, "%s[%d] = %f;", pszName, k, fdata[k]); 792 } 793 break; 794 } 795 } 796 } 797 } 798 799 crFree(pszName); 800 } 801 } 802 803 VBOXDUMPDECL(void) crRecDumpCurrentProgramUniforms(CR_RECORDER *pRec, CRContext *ctx) 804 { 805 GLint curProgram = 0; 806 pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram); 807 if (curProgram) 808 { 809 Assert(ctx->glsl.activeProgram); 810 if (!ctx->glsl.activeProgram) 811 crWarning("no active program state with active hw program"); 812 else 813 Assert(ctx->glsl.activeProgram->hwid == curProgram); 814 crRecDumpProgramUniforms(pRec, ctx, 0, curProgram); 815 } 816 else 817 { 818 Assert(!ctx->glsl.activeProgram); 819 crDmpStrF(pRec->pDumper, "--no active program"); 820 } 821 } 822 502 823 void crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin) 503 824 { … … 508 829 int rc; 509 830 int i; 510 511 Assert(0);512 831 513 832 pRec->pDispatch->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxUnits);
Note:
See TracChangeset
for help on using the changeset viewer.