Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenprog_print.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.3 00004 * 00005 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00031 #include "main/glheader.h" 00032 #include "main/context.h" 00033 #include "main/imports.h" 00034 #include "prog_instruction.h" 00035 #include "prog_parameter.h" 00036 #include "prog_print.h" 00037 #include "prog_statevars.h" 00038 00039 00040 00044 static const char * 00045 file_string(enum register_file f, gl_prog_print_mode mode) 00046 { 00047 switch (f) { 00048 case PROGRAM_TEMPORARY: 00049 return "TEMP"; 00050 case PROGRAM_LOCAL_PARAM: 00051 return "LOCAL"; 00052 case PROGRAM_ENV_PARAM: 00053 return "ENV"; 00054 case PROGRAM_STATE_VAR: 00055 return "STATE"; 00056 case PROGRAM_INPUT: 00057 return "INPUT"; 00058 case PROGRAM_OUTPUT: 00059 return "OUTPUT"; 00060 case PROGRAM_NAMED_PARAM: 00061 return "NAMED"; 00062 case PROGRAM_CONSTANT: 00063 return "CONST"; 00064 case PROGRAM_UNIFORM: 00065 return "UNIFORM"; 00066 case PROGRAM_VARYING: 00067 return "VARYING"; 00068 case PROGRAM_WRITE_ONLY: 00069 return "WRITE_ONLY"; 00070 case PROGRAM_ADDRESS: 00071 return "ADDR"; 00072 case PROGRAM_SAMPLER: 00073 return "SAMPLER"; 00074 case PROGRAM_UNDEFINED: 00075 return "UNDEFINED"; 00076 default: 00077 return "Unknown program file!"; 00078 } 00079 } 00080 00081 00085 static const char * 00086 arb_input_attrib_string(GLint index, GLenum progType) 00087 { 00088 /* 00089 * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. 00090 */ 00091 const char *vertAttribs[] = { 00092 "vertex.position", 00093 "vertex.weight", 00094 "vertex.normal", 00095 "vertex.color.primary", 00096 "vertex.color.secondary", 00097 "vertex.fogcoord", 00098 "vertex.(six)", 00099 "vertex.(seven)", 00100 "vertex.texcoord[0]", 00101 "vertex.texcoord[1]", 00102 "vertex.texcoord[2]", 00103 "vertex.texcoord[3]", 00104 "vertex.texcoord[4]", 00105 "vertex.texcoord[5]", 00106 "vertex.texcoord[6]", 00107 "vertex.texcoord[7]", 00108 "vertex.attrib[0]", 00109 "vertex.attrib[1]", 00110 "vertex.attrib[2]", 00111 "vertex.attrib[3]", 00112 "vertex.attrib[4]", 00113 "vertex.attrib[5]", 00114 "vertex.attrib[6]", 00115 "vertex.attrib[7]", 00116 "vertex.attrib[8]", 00117 "vertex.attrib[9]", 00118 "vertex.attrib[10]", 00119 "vertex.attrib[11]", 00120 "vertex.attrib[12]", 00121 "vertex.attrib[13]", 00122 "vertex.attrib[14]", 00123 "vertex.attrib[15]" 00124 }; 00125 const char *fragAttribs[] = { 00126 "fragment.position", 00127 "fragment.color.primary", 00128 "fragment.color.secondary", 00129 "fragment.fogcoord", 00130 "fragment.texcoord[0]", 00131 "fragment.texcoord[1]", 00132 "fragment.texcoord[2]", 00133 "fragment.texcoord[3]", 00134 "fragment.texcoord[4]", 00135 "fragment.texcoord[5]", 00136 "fragment.texcoord[6]", 00137 "fragment.texcoord[7]", 00138 "fragment.varying[0]", 00139 "fragment.varying[1]", 00140 "fragment.varying[2]", 00141 "fragment.varying[3]", 00142 "fragment.varying[4]", 00143 "fragment.varying[5]", 00144 "fragment.varying[6]", 00145 "fragment.varying[7]" 00146 }; 00147 00148 if (progType == GL_VERTEX_PROGRAM_ARB) { 00149 assert(index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); 00150 return vertAttribs[index]; 00151 } 00152 else { 00153 assert(index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); 00154 return fragAttribs[index]; 00155 } 00156 } 00157 00158 00162 static const char * 00163 arb_output_attrib_string(GLint index, GLenum progType) 00164 { 00165 /* 00166 * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. 00167 */ 00168 const char *vertResults[] = { 00169 "result.position", 00170 "result.color.primary", 00171 "result.color.secondary", 00172 "result.fogcoord", 00173 "result.texcoord[0]", 00174 "result.texcoord[1]", 00175 "result.texcoord[2]", 00176 "result.texcoord[3]", 00177 "result.texcoord[4]", 00178 "result.texcoord[5]", 00179 "result.texcoord[6]", 00180 "result.texcoord[7]", 00181 "result.varying[0]", 00182 "result.varying[1]", 00183 "result.varying[2]", 00184 "result.varying[3]", 00185 "result.varying[4]", 00186 "result.varying[5]", 00187 "result.varying[6]", 00188 "result.varying[7]" 00189 }; 00190 const char *fragResults[] = { 00191 "result.color", 00192 "result.color(half)", 00193 "result.depth", 00194 "result.color[0]", 00195 "result.color[1]", 00196 "result.color[2]", 00197 "result.color[3]" 00198 }; 00199 00200 if (progType == GL_VERTEX_PROGRAM_ARB) { 00201 assert(index < sizeof(vertResults) / sizeof(vertResults[0])); 00202 return vertResults[index]; 00203 } 00204 else { 00205 assert(index < sizeof(fragResults) / sizeof(fragResults[0])); 00206 return fragResults[index]; 00207 } 00208 } 00209 00210 00220 static const char * 00221 reg_string(enum register_file f, GLint index, gl_prog_print_mode mode, 00222 GLboolean relAddr, const struct gl_program *prog) 00223 { 00224 static char str[100]; 00225 00226 str[0] = 0; 00227 00228 switch (mode) { 00229 case PROG_PRINT_DEBUG: 00230 if (relAddr) 00231 sprintf(str, "%s[ADDR+%d]", file_string(f, mode), index); 00232 else 00233 sprintf(str, "%s[%d]", file_string(f, mode), index); 00234 break; 00235 00236 case PROG_PRINT_ARB: 00237 switch (f) { 00238 case PROGRAM_INPUT: 00239 sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); 00240 break; 00241 case PROGRAM_OUTPUT: 00242 sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); 00243 break; 00244 case PROGRAM_TEMPORARY: 00245 sprintf(str, "temp%d", index); 00246 break; 00247 case PROGRAM_ENV_PARAM: 00248 sprintf(str, "program.env[%d]", index); 00249 break; 00250 case PROGRAM_LOCAL_PARAM: 00251 sprintf(str, "program.local[%d]", index); 00252 break; 00253 case PROGRAM_VARYING: /* extension */ 00254 sprintf(str, "varying[%d]", index); 00255 break; 00256 case PROGRAM_CONSTANT: /* extension */ 00257 sprintf(str, "constant[%d]", index); 00258 break; 00259 case PROGRAM_UNIFORM: /* extension */ 00260 sprintf(str, "uniform[%d]", index); 00261 break; 00262 case PROGRAM_STATE_VAR: 00263 { 00264 struct gl_program_parameter *param 00265 = prog->Parameters->Parameters + index; 00266 sprintf(str, _mesa_program_state_string(param->StateIndexes)); 00267 } 00268 break; 00269 case PROGRAM_ADDRESS: 00270 sprintf(str, "A%d", index); 00271 break; 00272 default: 00273 _mesa_problem(NULL, "bad file in reg_string()"); 00274 } 00275 break; 00276 00277 case PROG_PRINT_NV: 00278 switch (f) { 00279 case PROGRAM_INPUT: 00280 if (prog->Target == GL_VERTEX_PROGRAM_ARB) 00281 sprintf(str, "v[%d]", index); 00282 else 00283 sprintf(str, "f[%d]", index); 00284 break; 00285 case PROGRAM_OUTPUT: 00286 sprintf(str, "o[%d]", index); 00287 break; 00288 case PROGRAM_TEMPORARY: 00289 sprintf(str, "R%d", index); 00290 break; 00291 case PROGRAM_ENV_PARAM: 00292 sprintf(str, "c[%d]", index); 00293 break; 00294 case PROGRAM_VARYING: /* extension */ 00295 sprintf(str, "varying[%d]", index); 00296 break; 00297 case PROGRAM_UNIFORM: /* extension */ 00298 sprintf(str, "uniform[%d]", index); 00299 break; 00300 case PROGRAM_CONSTANT: /* extension */ 00301 sprintf(str, "constant[%d]", index); 00302 break; 00303 case PROGRAM_STATE_VAR: /* extension */ 00304 sprintf(str, "state[%d]", index); 00305 break; 00306 default: 00307 _mesa_problem(NULL, "bad file in reg_string()"); 00308 } 00309 break; 00310 00311 default: 00312 _mesa_problem(NULL, "bad mode in reg_string()"); 00313 } 00314 00315 return str; 00316 } 00317 00318 00326 const char * 00327 _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended) 00328 { 00329 static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */ 00330 static char s[20]; 00331 GLuint i = 0; 00332 00333 if (!extended && swizzle == SWIZZLE_NOOP && negateBase == 0) 00334 return ""; /* no swizzle/negation */ 00335 00336 if (!extended) 00337 s[i++] = '.'; 00338 00339 if (negateBase & NEGATE_X) 00340 s[i++] = '-'; 00341 s[i++] = swz[GET_SWZ(swizzle, 0)]; 00342 00343 if (extended) { 00344 s[i++] = ','; 00345 } 00346 00347 if (negateBase & NEGATE_Y) 00348 s[i++] = '-'; 00349 s[i++] = swz[GET_SWZ(swizzle, 1)]; 00350 00351 if (extended) { 00352 s[i++] = ','; 00353 } 00354 00355 if (negateBase & NEGATE_Z) 00356 s[i++] = '-'; 00357 s[i++] = swz[GET_SWZ(swizzle, 2)]; 00358 00359 if (extended) { 00360 s[i++] = ','; 00361 } 00362 00363 if (negateBase & NEGATE_W) 00364 s[i++] = '-'; 00365 s[i++] = swz[GET_SWZ(swizzle, 3)]; 00366 00367 s[i] = 0; 00368 return s; 00369 } 00370 00371 00372 const char * 00373 _mesa_writemask_string(GLuint writeMask) 00374 { 00375 static char s[10]; 00376 GLuint i = 0; 00377 00378 if (writeMask == WRITEMASK_XYZW) 00379 return ""; 00380 00381 s[i++] = '.'; 00382 if (writeMask & WRITEMASK_X) 00383 s[i++] = 'x'; 00384 if (writeMask & WRITEMASK_Y) 00385 s[i++] = 'y'; 00386 if (writeMask & WRITEMASK_Z) 00387 s[i++] = 'z'; 00388 if (writeMask & WRITEMASK_W) 00389 s[i++] = 'w'; 00390 00391 s[i] = 0; 00392 return s; 00393 } 00394 00395 00396 const char * 00397 _mesa_condcode_string(GLuint condcode) 00398 { 00399 switch (condcode) { 00400 case COND_GT: return "GT"; 00401 case COND_EQ: return "EQ"; 00402 case COND_LT: return "LT"; 00403 case COND_UN: return "UN"; 00404 case COND_GE: return "GE"; 00405 case COND_LE: return "LE"; 00406 case COND_NE: return "NE"; 00407 case COND_TR: return "TR"; 00408 case COND_FL: return "FL"; 00409 default: return "cond???"; 00410 } 00411 } 00412 00413 00414 static void 00415 print_dst_reg(const struct prog_dst_register *dstReg, gl_prog_print_mode mode, 00416 const struct gl_program *prog) 00417 { 00418 _mesa_printf("%s%s", 00419 reg_string((enum register_file) dstReg->File, 00420 dstReg->Index, mode, dstReg->RelAddr, prog), 00421 _mesa_writemask_string(dstReg->WriteMask)); 00422 00423 if (dstReg->CondMask != COND_TR) { 00424 _mesa_printf(" (%s.%s)", 00425 _mesa_condcode_string(dstReg->CondMask), 00426 _mesa_swizzle_string(dstReg->CondSwizzle, GL_FALSE, GL_FALSE)); 00427 } 00428 00429 #if 0 00430 _mesa_printf("%s[%d]%s", 00431 file_string((enum register_file) dstReg->File, mode), 00432 dstReg->Index, 00433 _mesa_writemask_string(dstReg->WriteMask)); 00434 #endif 00435 } 00436 00437 static void 00438 print_src_reg(const struct prog_src_register *srcReg, gl_prog_print_mode mode, 00439 const struct gl_program *prog) 00440 { 00441 _mesa_printf("%s%s", 00442 reg_string((enum register_file) srcReg->File, 00443 srcReg->Index, mode, srcReg->RelAddr, prog), 00444 _mesa_swizzle_string(srcReg->Swizzle, 00445 srcReg->NegateBase, GL_FALSE)); 00446 #if 0 00447 _mesa_printf("%s[%d]%s", 00448 file_string((enum register_file) srcReg->File, mode), 00449 srcReg->Index, 00450 _mesa_swizzle_string(srcReg->Swizzle, 00451 srcReg->NegateBase, GL_FALSE)); 00452 #endif 00453 } 00454 00455 static void 00456 print_comment(const struct prog_instruction *inst) 00457 { 00458 if (inst->Comment) 00459 _mesa_printf("; # %s\n", inst->Comment); 00460 else 00461 _mesa_printf(";\n"); 00462 } 00463 00464 00465 static void 00466 print_alu_instruction(const struct prog_instruction *inst, 00467 const char *opcode_string, GLuint numRegs, 00468 gl_prog_print_mode mode, 00469 const struct gl_program *prog) 00470 { 00471 GLuint j; 00472 00473 _mesa_printf("%s", opcode_string); 00474 if (inst->CondUpdate) 00475 _mesa_printf(".C"); 00476 00477 /* frag prog only */ 00478 if (inst->SaturateMode == SATURATE_ZERO_ONE) 00479 _mesa_printf("_SAT"); 00480 00481 _mesa_printf(" "); 00482 if (inst->DstReg.File != PROGRAM_UNDEFINED) { 00483 print_dst_reg(&inst->DstReg, mode, prog); 00484 } 00485 else { 00486 _mesa_printf(" ???"); 00487 } 00488 00489 if (numRegs > 0) 00490 _mesa_printf(", "); 00491 00492 for (j = 0; j < numRegs; j++) { 00493 print_src_reg(inst->SrcReg + j, mode, prog); 00494 if (j + 1 < numRegs) 00495 _mesa_printf(", "); 00496 } 00497 00498 print_comment(inst); 00499 } 00500 00501 00502 void 00503 _mesa_print_alu_instruction(const struct prog_instruction *inst, 00504 const char *opcode_string, GLuint numRegs) 00505 { 00506 print_alu_instruction(inst, opcode_string, numRegs, PROG_PRINT_DEBUG, NULL); 00507 } 00508 00509 00510 void 00511 _mesa_print_instruction(const struct prog_instruction *inst) 00512 { 00513 /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ 00514 _mesa_print_instruction_opt(inst, 0, PROG_PRINT_DEBUG, NULL); 00515 } 00516 00517 00521 GLint 00522 _mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, 00523 gl_prog_print_mode mode, 00524 const struct gl_program *prog) 00525 { 00526 GLint i; 00527 00528 if (inst->Opcode == OPCODE_ELSE || 00529 inst->Opcode == OPCODE_ENDIF || 00530 inst->Opcode == OPCODE_ENDLOOP || 00531 inst->Opcode == OPCODE_ENDSUB) { 00532 indent -= 3; 00533 } 00534 for (i = 0; i < indent; i++) { 00535 _mesa_printf(" "); 00536 } 00537 00538 switch (inst->Opcode) { 00539 case OPCODE_PRINT: 00540 _mesa_printf("PRINT '%s'", inst->Data); 00541 if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { 00542 _mesa_printf(", "); 00543 _mesa_printf("%s[%d]%s", 00544 file_string((enum register_file) inst->SrcReg[0].File, 00545 mode), 00546 inst->SrcReg[0].Index, 00547 _mesa_swizzle_string(inst->SrcReg[0].Swizzle, 00548 inst->SrcReg[0].NegateBase, GL_FALSE)); 00549 } 00550 if (inst->Comment) 00551 _mesa_printf(" # %s", inst->Comment); 00552 print_comment(inst); 00553 break; 00554 case OPCODE_SWZ: 00555 _mesa_printf("SWZ"); 00556 if (inst->SaturateMode == SATURATE_ZERO_ONE) 00557 _mesa_printf("_SAT"); 00558 _mesa_printf(" "); 00559 print_dst_reg(&inst->DstReg, mode, prog); 00560 _mesa_printf(", %s[%d], %s", 00561 file_string((enum register_file) inst->SrcReg[0].File, 00562 mode), 00563 inst->SrcReg[0].Index, 00564 _mesa_swizzle_string(inst->SrcReg[0].Swizzle, 00565 inst->SrcReg[0].NegateBase, GL_TRUE)); 00566 print_comment(inst); 00567 break; 00568 case OPCODE_TEX: 00569 case OPCODE_TXP: 00570 case OPCODE_TXL: 00571 case OPCODE_TXB: 00572 _mesa_printf("%s", _mesa_opcode_string(inst->Opcode)); 00573 if (inst->SaturateMode == SATURATE_ZERO_ONE) 00574 _mesa_printf("_SAT"); 00575 _mesa_printf(" "); 00576 print_dst_reg(&inst->DstReg, mode, prog); 00577 _mesa_printf(", "); 00578 print_src_reg(&inst->SrcReg[0], mode, prog); 00579 _mesa_printf(", texture[%d], ", inst->TexSrcUnit); 00580 switch (inst->TexSrcTarget) { 00581 case TEXTURE_1D_INDEX: _mesa_printf("1D"); break; 00582 case TEXTURE_2D_INDEX: _mesa_printf("2D"); break; 00583 case TEXTURE_3D_INDEX: _mesa_printf("3D"); break; 00584 case TEXTURE_CUBE_INDEX: _mesa_printf("CUBE"); break; 00585 case TEXTURE_RECT_INDEX: _mesa_printf("RECT"); break; 00586 default: 00587 ; 00588 } 00589 print_comment(inst); 00590 break; 00591 00592 case OPCODE_KIL: 00593 _mesa_printf("%s", _mesa_opcode_string(inst->Opcode)); 00594 _mesa_printf(" "); 00595 print_src_reg(&inst->SrcReg[0], mode, prog); 00596 print_comment(inst); 00597 break; 00598 case OPCODE_KIL_NV: 00599 _mesa_printf("%s", _mesa_opcode_string(inst->Opcode)); 00600 _mesa_printf(" "); 00601 _mesa_printf("%s.%s", 00602 _mesa_condcode_string(inst->DstReg.CondMask), 00603 _mesa_swizzle_string(inst->DstReg.CondSwizzle, 00604 GL_FALSE, GL_FALSE)); 00605 print_comment(inst); 00606 break; 00607 00608 case OPCODE_ARL: 00609 _mesa_printf("ARL "); 00610 print_dst_reg(&inst->DstReg, mode, prog); 00611 _mesa_printf(", "); 00612 print_src_reg(&inst->SrcReg[0], mode, prog); 00613 print_comment(inst); 00614 break; 00615 case OPCODE_BRA: 00616 _mesa_printf("BRA %d (%s%s)", 00617 inst->BranchTarget, 00618 _mesa_condcode_string(inst->DstReg.CondMask), 00619 _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); 00620 print_comment(inst); 00621 break; 00622 case OPCODE_IF: 00623 if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { 00624 /* Use ordinary register */ 00625 _mesa_printf("IF "); 00626 print_src_reg(&inst->SrcReg[0], mode, prog); 00627 _mesa_printf("; "); 00628 } 00629 else { 00630 /* Use cond codes */ 00631 _mesa_printf("IF (%s%s);", 00632 _mesa_condcode_string(inst->DstReg.CondMask), 00633 _mesa_swizzle_string(inst->DstReg.CondSwizzle, 00634 0, GL_FALSE)); 00635 } 00636 _mesa_printf(" # (if false, goto %d)", inst->BranchTarget); 00637 print_comment(inst); 00638 return indent + 3; 00639 case OPCODE_ELSE: 00640 _mesa_printf("ELSE; # (goto %d)\n", inst->BranchTarget); 00641 return indent + 3; 00642 case OPCODE_ENDIF: 00643 _mesa_printf("ENDIF;\n"); 00644 break; 00645 case OPCODE_BGNLOOP: 00646 _mesa_printf("BGNLOOP; # (end at %d)\n", inst->BranchTarget); 00647 return indent + 3; 00648 case OPCODE_ENDLOOP: 00649 _mesa_printf("ENDLOOP; # (goto %d)\n", inst->BranchTarget); 00650 break; 00651 case OPCODE_BRK: 00652 case OPCODE_CONT: 00653 _mesa_printf("%s (%s%s); # (goto %d)", 00654 _mesa_opcode_string(inst->Opcode), 00655 _mesa_condcode_string(inst->DstReg.CondMask), 00656 _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), 00657 inst->BranchTarget); 00658 print_comment(inst); 00659 break; 00660 00661 case OPCODE_BGNSUB: 00662 if (mode == PROG_PRINT_NV) { 00663 _mesa_printf("%s:\n", inst->Comment); /* comment is label */ 00664 return indent; 00665 } 00666 else { 00667 _mesa_printf("BGNSUB"); 00668 print_comment(inst); 00669 return indent + 3; 00670 } 00671 case OPCODE_ENDSUB: 00672 if (mode == PROG_PRINT_DEBUG) { 00673 _mesa_printf("ENDSUB"); 00674 print_comment(inst); 00675 } 00676 break; 00677 case OPCODE_CAL: 00678 if (mode == PROG_PRINT_NV) { 00679 _mesa_printf("CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); 00680 } 00681 else { 00682 _mesa_printf("CAL %u", inst->BranchTarget); 00683 print_comment(inst); 00684 } 00685 break; 00686 case OPCODE_RET: 00687 _mesa_printf("RET (%s%s)", 00688 _mesa_condcode_string(inst->DstReg.CondMask), 00689 _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); 00690 print_comment(inst); 00691 break; 00692 00693 case OPCODE_END: 00694 _mesa_printf("END\n"); 00695 break; 00696 case OPCODE_NOP: 00697 if (mode == PROG_PRINT_DEBUG) { 00698 _mesa_printf("NOP"); 00699 print_comment(inst); 00700 } 00701 else if (inst->Comment) { 00702 /* ARB/NV extensions don't have NOP instruction */ 00703 _mesa_printf("# %s\n", inst->Comment); 00704 } 00705 break; 00706 /* XXX may need other special-case instructions */ 00707 default: 00708 /* typical alu instruction */ 00709 print_alu_instruction(inst, 00710 _mesa_opcode_string(inst->Opcode), 00711 _mesa_num_inst_src_regs(inst->Opcode), 00712 mode, prog); 00713 break; 00714 } 00715 return indent; 00716 } 00717 00718 00722 void 00723 _mesa_print_program(const struct gl_program *prog) 00724 { 00725 _mesa_print_program_opt(prog, PROG_PRINT_DEBUG, GL_TRUE); 00726 } 00727 00728 00732 void 00733 _mesa_print_program_opt(const struct gl_program *prog, 00734 gl_prog_print_mode mode, 00735 GLboolean lineNumbers) 00736 { 00737 GLuint i, indent = 0; 00738 00739 switch (prog->Target) { 00740 case GL_VERTEX_PROGRAM_ARB: 00741 if (mode == PROG_PRINT_ARB) 00742 _mesa_printf("!!ARBvp1.0\n"); 00743 else if (mode == PROG_PRINT_NV) 00744 _mesa_printf("!!VP1.0\n"); 00745 else 00746 _mesa_printf("# Vertex Program/Shader\n"); 00747 break; 00748 case GL_FRAGMENT_PROGRAM_ARB: 00749 case GL_FRAGMENT_PROGRAM_NV: 00750 if (mode == PROG_PRINT_ARB) 00751 _mesa_printf("!!ARBfp1.0\n"); 00752 else if (mode == PROG_PRINT_NV) 00753 _mesa_printf("!!FP1.0\n"); 00754 else 00755 _mesa_printf("# Fragment Program/Shader\n"); 00756 break; 00757 } 00758 00759 for (i = 0; i < prog->NumInstructions; i++) { 00760 if (lineNumbers) 00761 _mesa_printf("%3d: ", i); 00762 indent = _mesa_print_instruction_opt(prog->Instructions + i, 00763 indent, mode, prog); 00764 } 00765 } 00766 00767 00771 void 00772 _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) 00773 { 00774 GLuint i; 00775 00776 _mesa_printf("InputsRead: 0x%x\n", prog->InputsRead); 00777 _mesa_printf("OutputsWritten: 0x%x\n", prog->OutputsWritten); 00778 _mesa_printf("NumInstructions=%d\n", prog->NumInstructions); 00779 _mesa_printf("NumTemporaries=%d\n", prog->NumTemporaries); 00780 _mesa_printf("NumParameters=%d\n", prog->NumParameters); 00781 _mesa_printf("NumAttributes=%d\n", prog->NumAttributes); 00782 _mesa_printf("NumAddressRegs=%d\n", prog->NumAddressRegs); 00783 _mesa_printf("Samplers=[ "); 00784 for (i = 0; i < MAX_SAMPLERS; i++) { 00785 _mesa_printf("%d ", prog->SamplerUnits[i]); 00786 } 00787 _mesa_printf("]\n"); 00788 00789 _mesa_load_state_parameters(ctx, prog->Parameters); 00790 00791 #if 0 00792 _mesa_printf("Local Params:\n"); 00793 for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ 00794 const GLfloat *p = prog->LocalParams[i]; 00795 _mesa_printf("%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); 00796 } 00797 #endif 00798 _mesa_print_parameter_list(prog->Parameters); 00799 } 00800 00801 00802 void 00803 _mesa_print_parameter_list(const struct gl_program_parameter_list *list) 00804 { 00805 const gl_prog_print_mode mode = PROG_PRINT_DEBUG; 00806 GLuint i; 00807 00808 if (!list) 00809 return; 00810 00811 _mesa_printf("param list %p\n", (void *) list); 00812 for (i = 0; i < list->NumParameters; i++){ 00813 struct gl_program_parameter *param = list->Parameters + i; 00814 const GLfloat *v = list->ParameterValues[i]; 00815 _mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", 00816 i, param->Size, 00817 file_string(list->Parameters[i].Type, mode), 00818 param->Name, v[0], v[1], v[2], v[3]); 00819 if (param->Flags & PROG_PARAM_BIT_CENTROID) 00820 _mesa_printf(" Centroid"); 00821 if (param->Flags & PROG_PARAM_BIT_INVARIANT) 00822 _mesa_printf(" Invariant"); 00823 if (param->Flags & PROG_PARAM_BIT_FLAT) 00824 _mesa_printf(" Flat"); 00825 if (param->Flags & PROG_PARAM_BIT_LINEAR) 00826 _mesa_printf(" Linear"); 00827 _mesa_printf("\n"); 00828 } 00829 } Generated on Thu May 24 2012 04:20:50 for ReactOS by
1.7.6.1
|