static boolean iter_instruction( struct tgsi_iterate_context *iter, struct tgsi_full_instruction *inst ) { struct dump_ctx *ctx = (struct dump_ctx *) iter; uint instno = ctx->instno++; const struct tgsi_opcode_info *info = tgsi_get_opcode_info( inst->Instruction.Opcode ); uint i; boolean first_reg = TRUE; INSTID( instno ); TXT( ": " ); ctx->indent -= info->pre_dedent; for(i = 0; (int)i < ctx->indent; ++i) TXT( " " ); ctx->indent += info->post_indent; if (inst->Instruction.Predicate) { CHR( '(' ); if (inst->Predicate.Negate) CHR( '!' ); TXT( "PRED[" ); SID( inst->Predicate.Index ); CHR( ']' ); if (inst->Predicate.SwizzleX != TGSI_SWIZZLE_X || inst->Predicate.SwizzleY != TGSI_SWIZZLE_Y || inst->Predicate.SwizzleZ != TGSI_SWIZZLE_Z || inst->Predicate.SwizzleW != TGSI_SWIZZLE_W) { CHR( '.' ); ENM( inst->Predicate.SwizzleX, tgsi_swizzle_names ); ENM( inst->Predicate.SwizzleY, tgsi_swizzle_names ); ENM( inst->Predicate.SwizzleZ, tgsi_swizzle_names ); ENM( inst->Predicate.SwizzleW, tgsi_swizzle_names ); } TXT( ") " ); } TXT( info->mnemonic ); switch (inst->Instruction.Saturate) { case TGSI_SAT_NONE: break; case TGSI_SAT_ZERO_ONE: TXT( "_SAT" ); break; case TGSI_SAT_MINUS_PLUS_ONE: TXT( "_SATNV" ); break; default: assert( 0 ); } for (i = 0; i < inst->Instruction.NumDstRegs; i++) { const struct tgsi_full_dst_register *dst = &inst->Dst[i]; if (!first_reg) CHR( ',' ); CHR( ' ' ); _dump_register_dst( ctx, dst ); _dump_writemask( ctx, dst->Register.WriteMask ); first_reg = FALSE; } for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { const struct tgsi_full_src_register *src = &inst->Src[i]; if (!first_reg) CHR( ',' ); CHR( ' ' ); if (src->Register.Negate) CHR( '-' ); if (src->Register.Absolute) CHR( '|' ); _dump_register_src(ctx, src); if (src->Register.SwizzleX != TGSI_SWIZZLE_X || src->Register.SwizzleY != TGSI_SWIZZLE_Y || src->Register.SwizzleZ != TGSI_SWIZZLE_Z || src->Register.SwizzleW != TGSI_SWIZZLE_W) { CHR( '.' ); ENM( src->Register.SwizzleX, tgsi_swizzle_names ); ENM( src->Register.SwizzleY, tgsi_swizzle_names ); ENM( src->Register.SwizzleZ, tgsi_swizzle_names ); ENM( src->Register.SwizzleW, tgsi_swizzle_names ); } if (src->Register.Absolute) CHR( '|' ); first_reg = FALSE; } if (inst->Instruction.Texture) { TXT( ", " ); ENM( inst->Texture.Texture, tgsi_texture_names ); for (i = 0; i < inst->Texture.NumOffsets; i++) { TXT( ", " ); ENM( inst->TexOffsets[i].File, tgsi_file_names); CHR( '[' ); SID( inst->TexOffsets[i].Index ); CHR( ']' ); CHR( '.' ); ENM( inst->TexOffsets[i].SwizzleX, tgsi_swizzle_names); ENM( inst->TexOffsets[i].SwizzleY, tgsi_swizzle_names); ENM( inst->TexOffsets[i].SwizzleZ, tgsi_swizzle_names); } } switch (inst->Instruction.Opcode) { case TGSI_OPCODE_IF: case TGSI_OPCODE_UIF: case TGSI_OPCODE_ELSE: case TGSI_OPCODE_BGNLOOP: case TGSI_OPCODE_ENDLOOP: case TGSI_OPCODE_CAL: TXT( " :" ); UID( inst->Label.Label ); break; } /* update indentation */ if (inst->Instruction.Opcode == TGSI_OPCODE_IF || inst->Instruction.Opcode == TGSI_OPCODE_UIF || inst->Instruction.Opcode == TGSI_OPCODE_ELSE || inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP) { ctx->indentation += indent_spaces; } EOL(); return TRUE; }
static boolean iter_declaration( struct tgsi_iterate_context *iter, struct tgsi_full_declaration *decl ) { struct dump_ctx *ctx = (struct dump_ctx *)iter; TXT( "DCL " ); ENM(decl->Declaration.File, tgsi_file_names); /* all geometry shader inputs are two dimensional */ if (decl->Declaration.File == TGSI_FILE_INPUT && iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { TXT("[]"); } if (decl->Declaration.Dimension) { CHR('['); SID(decl->Dim.Index2D); CHR(']'); } CHR('['); SID(decl->Range.First); if (decl->Range.First != decl->Range.Last) { TXT(".."); SID(decl->Range.Last); } CHR(']'); _dump_writemask( ctx, decl->Declaration.UsageMask ); if (decl->Declaration.Local) TXT( ", LOCAL" ); if (decl->Declaration.Semantic) { TXT( ", " ); ENM( decl->Semantic.Name, tgsi_semantic_names ); if (decl->Semantic.Index != 0 || decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) { CHR( '[' ); UID( decl->Semantic.Index ); CHR( ']' ); } } if (decl->Declaration.File == TGSI_FILE_RESOURCE) { TXT(", "); ENM(decl->Resource.Resource, tgsi_texture_names); if (decl->Resource.Writable) TXT(", WR"); if (decl->Resource.Raw) TXT(", RAW"); } if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) { TXT(", "); ENM(decl->SamplerView.Resource, tgsi_texture_names); TXT(", "); if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); } else { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeY, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeZ, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeW, tgsi_type_names); } } if (decl->Declaration.Interpolate) { if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && decl->Declaration.File == TGSI_FILE_INPUT) { TXT( ", " ); ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); } if (decl->Interp.Centroid) { TXT( ", CENTROID" ); } if (decl->Interp.CylindricalWrap) { TXT(", CYLWRAP_"); if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) { CHR('X'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) { CHR('Y'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) { CHR('Z'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) { CHR('W'); } } } if (decl->Declaration.Invariant) { TXT( ", INVARIANT" ); } if (decl->Declaration.File == TGSI_FILE_IMMEDIATE_ARRAY) { unsigned i; char range_indent[4]; TXT(" {"); if (decl->Range.Last < 10) range_indent[0] = '\0'; else if (decl->Range.Last < 100) { range_indent[0] = ' '; range_indent[1] = '\0'; } else if (decl->Range.Last < 1000) { range_indent[0] = ' '; range_indent[1] = ' '; range_indent[2] = '\0'; } else { range_indent[0] = ' '; range_indent[1] = ' '; range_indent[2] = ' '; range_indent[3] = '\0'; } dump_imm_data(iter, decl->ImmediateData.u, 4, TGSI_IMM_FLOAT32); for(i = 1; i <= decl->Range.Last; ++i) { /* indent by strlen of: * "DCL IMMX[0..1] {" */ CHR('\n'); TXT( " " ); TXT( range_indent ); dump_imm_data(iter, decl->ImmediateData.u + i, 4, TGSI_IMM_FLOAT32); } TXT(" }"); } EOL(); return TRUE; }
static boolean iter_declaration( struct tgsi_iterate_context *iter, struct tgsi_full_declaration *decl ) { struct dump_ctx *ctx = (struct dump_ctx *)iter; TXT( "DCL " ); ENM(decl->Declaration.File, tgsi_file_names); /* all geometry shader inputs are two dimensional */ if (decl->Declaration.File == TGSI_FILE_INPUT && iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { TXT("[]"); } if (decl->Declaration.Dimension) { CHR('['); SID(decl->Dim.Index2D); CHR(']'); } CHR('['); SID(decl->Range.First); if (decl->Range.First != decl->Range.Last) { TXT(".."); SID(decl->Range.Last); } CHR(']'); _dump_writemask( ctx, decl->Declaration.UsageMask ); if (decl->Declaration.Array) { TXT( ", ARRAY(" ); SID(decl->Array.ArrayID); CHR(')'); } if (decl->Declaration.Local) TXT( ", LOCAL" ); if (decl->Declaration.Semantic) { TXT( ", " ); ENM( decl->Semantic.Name, tgsi_semantic_names ); if (decl->Semantic.Index != 0 || decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD || decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) { CHR( '[' ); UID( decl->Semantic.Index ); CHR( ']' ); } } if (decl->Declaration.File == TGSI_FILE_RESOURCE) { TXT(", "); ENM(decl->Resource.Resource, tgsi_texture_names); if (decl->Resource.Writable) TXT(", WR"); if (decl->Resource.Raw) TXT(", RAW"); } if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) { TXT(", "); ENM(decl->SamplerView.Resource, tgsi_texture_names); TXT(", "); if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); } else { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeY, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeZ, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeW, tgsi_type_names); } } if (decl->Declaration.Interpolate) { if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && decl->Declaration.File == TGSI_FILE_INPUT) { TXT( ", " ); ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); } if (decl->Interp.Centroid) { TXT( ", CENTROID" ); } if (decl->Interp.CylindricalWrap) { TXT(", CYLWRAP_"); if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) { CHR('X'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) { CHR('Y'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) { CHR('Z'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) { CHR('W'); } } } if (decl->Declaration.Invariant) { TXT( ", INVARIANT" ); } EOL(); return TRUE; }
static boolean iter_declaration( struct tgsi_iterate_context *iter, struct tgsi_full_declaration *decl ) { struct dump_ctx *ctx = (struct dump_ctx *)iter; boolean patch = decl->Semantic.Name == TGSI_SEMANTIC_PATCH || decl->Semantic.Name == TGSI_SEMANTIC_TESSINNER || decl->Semantic.Name == TGSI_SEMANTIC_TESSOUTER || decl->Semantic.Name == TGSI_SEMANTIC_PRIMID; TXT( "DCL " ); TXT(tgsi_file_name(decl->Declaration.File)); /* all geometry shader inputs and non-patch tessellation shader inputs are * two dimensional */ if (decl->Declaration.File == TGSI_FILE_INPUT && (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY || (!patch && (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL || iter->processor.Processor == TGSI_PROCESSOR_TESS_EVAL)))) { TXT("[]"); } /* all non-patch tess ctrl shader outputs are two dimensional */ if (decl->Declaration.File == TGSI_FILE_OUTPUT && !patch && iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) { TXT("[]"); } if (decl->Declaration.Dimension) { CHR('['); SID(decl->Dim.Index2D); CHR(']'); } CHR('['); SID(decl->Range.First); if (decl->Range.First != decl->Range.Last) { TXT(".."); SID(decl->Range.Last); } CHR(']'); _dump_writemask( ctx, decl->Declaration.UsageMask ); if (decl->Declaration.Array) { TXT( ", ARRAY(" ); SID(decl->Array.ArrayID); CHR(')'); } if (decl->Declaration.Local) TXT( ", LOCAL" ); if (decl->Declaration.Semantic) { TXT( ", " ); ENM( decl->Semantic.Name, tgsi_semantic_names ); if (decl->Semantic.Index != 0 || decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD || decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) { CHR( '[' ); UID( decl->Semantic.Index ); CHR( ']' ); } } if (decl->Declaration.File == TGSI_FILE_IMAGE) { TXT(", "); ENM(decl->Image.Resource, tgsi_texture_names); TXT(", "); TXT(util_format_name(decl->Image.Format)); if (decl->Image.Writable) TXT(", WR"); if (decl->Image.Raw) TXT(", RAW"); } if (decl->Declaration.File == TGSI_FILE_BUFFER) { if (decl->Declaration.Atomic) TXT(", ATOMIC"); } if (decl->Declaration.File == TGSI_FILE_MEMORY) { if (decl->Declaration.Shared) TXT(", SHARED"); } if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) { TXT(", "); ENM(decl->SamplerView.Resource, tgsi_texture_names); TXT(", "); if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) { ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names); } else { ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeY, tgsi_return_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeZ, tgsi_return_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeW, tgsi_return_type_names); } } if (decl->Declaration.Interpolate) { if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && decl->Declaration.File == TGSI_FILE_INPUT) { TXT( ", " ); ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); } if (decl->Interp.Location != TGSI_INTERPOLATE_LOC_CENTER) { TXT( ", " ); ENM( decl->Interp.Location, tgsi_interpolate_locations ); } if (decl->Interp.CylindricalWrap) { TXT(", CYLWRAP_"); if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) { CHR('X'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) { CHR('Y'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) { CHR('Z'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) { CHR('W'); } } } if (decl->Declaration.Invariant) { TXT( ", INVARIANT" ); } EOL(); return TRUE; }