Path: blob/21.2-virgl/src/gallium/auxiliary/tgsi/tgsi_dump.c
4565 views
/**************************************************************************1*2* Copyright 2007-2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include <inttypes.h>2829#include "util/u_debug.h"30#include "util/u_string.h"31#include "util/u_math.h"32#include "util/u_memory.h"33#include "util/u_math.h"34#include "tgsi_dump.h"35#include "tgsi_info.h"36#include "tgsi_iterate.h"37#include "tgsi_strings.h"383940/** Number of spaces to indent for IF/LOOP/etc */41static const int indent_spaces = 3;424344struct dump_ctx45{46struct tgsi_iterate_context iter;4748boolean dump_float_as_hex;4950uint instno;51uint immno;52int indent;5354uint indentation;55FILE *file;5657void (*dump_printf)(struct dump_ctx *ctx, const char *format, ...);58};5960static void61dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)62{63va_list ap;64(void)ctx;65va_start(ap, format);66if (ctx->file)67vfprintf(ctx->file, format, ap);68else69_debug_vprintf(format, ap);70va_end(ap);71}7273static void74dump_enum(75struct dump_ctx *ctx,76uint e,77const char **enums,78uint enum_count )79{80if (e >= enum_count)81ctx->dump_printf( ctx, "%u", e );82else83ctx->dump_printf( ctx, "%s", enums[e] );84}8586#define EOL() ctx->dump_printf( ctx, "\n" )87#define TXT(S) ctx->dump_printf( ctx, "%s", S )88#define CHR(C) ctx->dump_printf( ctx, "%c", C )89#define UIX(I) ctx->dump_printf( ctx, "0x%x", I )90#define UID(I) ctx->dump_printf( ctx, "%u", I )91#define SI64D(I) ctx->dump_printf( ctx, "%"PRId64, I )92#define UI64D(I) ctx->dump_printf( ctx, "%"PRIu64, I )93#define INSTID(I) ctx->dump_printf( ctx, "% 3u", I )94#define SID(I) ctx->dump_printf( ctx, "%d", I )95#define FLT(F) ctx->dump_printf( ctx, "%10.4f", F )96#define DBL(D) ctx->dump_printf( ctx, "%10.8f", D )97#define HFLT(F) ctx->dump_printf( ctx, "0x%08x", fui((F)) )98#define ENM(E,ENUMS) dump_enum( ctx, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )99100const char *101tgsi_swizzle_names[4] =102{103"x",104"y",105"z",106"w"107};108109static void110_dump_register_src(111struct dump_ctx *ctx,112const struct tgsi_full_src_register *src )113{114TXT(tgsi_file_name(src->Register.File));115if (src->Register.Dimension) {116if (src->Dimension.Indirect) {117CHR( '[' );118TXT(tgsi_file_name(src->DimIndirect.File));119CHR( '[' );120SID( src->DimIndirect.Index );121TXT( "]." );122ENM( src->DimIndirect.Swizzle, tgsi_swizzle_names );123if (src->Dimension.Index != 0) {124if (src->Dimension.Index > 0)125CHR( '+' );126SID( src->Dimension.Index );127}128CHR( ']' );129if (src->DimIndirect.ArrayID) {130CHR( '(' );131SID( src->DimIndirect.ArrayID );132CHR( ')' );133}134} else {135CHR('[');136SID(src->Dimension.Index);137CHR(']');138}139}140if (src->Register.Indirect) {141CHR( '[' );142TXT(tgsi_file_name(src->Indirect.File));143CHR( '[' );144SID( src->Indirect.Index );145TXT( "]." );146ENM( src->Indirect.Swizzle, tgsi_swizzle_names );147if (src->Register.Index != 0) {148if (src->Register.Index > 0)149CHR( '+' );150SID( src->Register.Index );151}152CHR( ']' );153if (src->Indirect.ArrayID) {154CHR( '(' );155SID( src->Indirect.ArrayID );156CHR( ')' );157}158} else {159CHR( '[' );160SID( src->Register.Index );161CHR( ']' );162}163}164165166static void167_dump_register_dst(168struct dump_ctx *ctx,169const struct tgsi_full_dst_register *dst )170{171TXT(tgsi_file_name(dst->Register.File));172if (dst->Register.Dimension) {173if (dst->Dimension.Indirect) {174CHR( '[' );175TXT(tgsi_file_name(dst->DimIndirect.File));176CHR( '[' );177SID( dst->DimIndirect.Index );178TXT( "]." );179ENM( dst->DimIndirect.Swizzle, tgsi_swizzle_names );180if (dst->Dimension.Index != 0) {181if (dst->Dimension.Index > 0)182CHR( '+' );183SID( dst->Dimension.Index );184}185CHR( ']' );186if (dst->DimIndirect.ArrayID) {187CHR( '(' );188SID( dst->DimIndirect.ArrayID );189CHR( ')' );190}191} else {192CHR('[');193SID(dst->Dimension.Index);194CHR(']');195}196}197if (dst->Register.Indirect) {198CHR( '[' );199TXT(tgsi_file_name(dst->Indirect.File));200CHR( '[' );201SID( dst->Indirect.Index );202TXT( "]." );203ENM( dst->Indirect.Swizzle, tgsi_swizzle_names );204if (dst->Register.Index != 0) {205if (dst->Register.Index > 0)206CHR( '+' );207SID( dst->Register.Index );208}209CHR( ']' );210if (dst->Indirect.ArrayID) {211CHR( '(' );212SID( dst->Indirect.ArrayID );213CHR( ')' );214}215} else {216CHR( '[' );217SID( dst->Register.Index );218CHR( ']' );219}220}221static void222_dump_writemask(223struct dump_ctx *ctx,224uint writemask )225{226if (writemask != TGSI_WRITEMASK_XYZW) {227CHR( '.' );228if (writemask & TGSI_WRITEMASK_X)229CHR( 'x' );230if (writemask & TGSI_WRITEMASK_Y)231CHR( 'y' );232if (writemask & TGSI_WRITEMASK_Z)233CHR( 'z' );234if (writemask & TGSI_WRITEMASK_W)235CHR( 'w' );236}237}238239static void240dump_imm_data(struct tgsi_iterate_context *iter,241union tgsi_immediate_data *data,242unsigned num_tokens,243unsigned data_type)244{245struct dump_ctx *ctx = (struct dump_ctx *)iter;246unsigned i ;247248TXT( " {" );249250assert( num_tokens <= 4 );251for (i = 0; i < num_tokens; i++) {252switch (data_type) {253case TGSI_IMM_FLOAT64: {254union di d;255d.ui = data[i].Uint | (uint64_t)data[i+1].Uint << 32;256DBL( d.d );257i++;258break;259}260case TGSI_IMM_INT64: {261union di d;262d.i = data[i].Uint | (uint64_t)data[i+1].Uint << 32;263SI64D( d.i );264i++;265break;266}267case TGSI_IMM_UINT64: {268union di d;269d.ui = data[i].Uint | (uint64_t)data[i+1].Uint << 32;270UI64D( d.ui );271i++;272break;273}274case TGSI_IMM_FLOAT32:275if (ctx->dump_float_as_hex)276HFLT( data[i].Float );277else278FLT( data[i].Float );279break;280case TGSI_IMM_UINT32:281UID(data[i].Uint);282break;283case TGSI_IMM_INT32:284SID(data[i].Int);285break;286default:287assert( 0 );288}289290if (i < num_tokens - 1)291TXT( ", " );292}293TXT( "}" );294}295296static boolean297iter_declaration(298struct tgsi_iterate_context *iter,299struct tgsi_full_declaration *decl )300{301struct dump_ctx *ctx = (struct dump_ctx *)iter;302boolean patch = decl->Semantic.Name == TGSI_SEMANTIC_PATCH ||303decl->Semantic.Name == TGSI_SEMANTIC_TESSINNER ||304decl->Semantic.Name == TGSI_SEMANTIC_TESSOUTER ||305decl->Semantic.Name == TGSI_SEMANTIC_PRIMID;306307TXT( "DCL " );308309TXT(tgsi_file_name(decl->Declaration.File));310311/* all geometry shader inputs and non-patch tessellation shader inputs are312* two dimensional313*/314if (decl->Declaration.File == TGSI_FILE_INPUT &&315(iter->processor.Processor == PIPE_SHADER_GEOMETRY ||316(!patch &&317(iter->processor.Processor == PIPE_SHADER_TESS_CTRL ||318iter->processor.Processor == PIPE_SHADER_TESS_EVAL)))) {319TXT("[]");320}321322/* all non-patch tess ctrl shader outputs are two dimensional */323if (decl->Declaration.File == TGSI_FILE_OUTPUT &&324!patch &&325iter->processor.Processor == PIPE_SHADER_TESS_CTRL) {326TXT("[]");327}328329if (decl->Declaration.Dimension) {330CHR('[');331SID(decl->Dim.Index2D);332CHR(']');333}334335CHR('[');336SID(decl->Range.First);337if (decl->Range.First != decl->Range.Last) {338TXT("..");339SID(decl->Range.Last);340}341CHR(']');342343_dump_writemask(344ctx,345decl->Declaration.UsageMask );346347if (decl->Declaration.Array) {348TXT( ", ARRAY(" );349SID(decl->Array.ArrayID);350CHR(')');351}352353if (decl->Declaration.Local)354TXT( ", LOCAL" );355356if (decl->Declaration.Semantic) {357TXT( ", " );358ENM( decl->Semantic.Name, tgsi_semantic_names );359if (decl->Semantic.Index != 0 ||360decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD ||361decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {362CHR( '[' );363UID( decl->Semantic.Index );364CHR( ']' );365}366367if (decl->Semantic.StreamX != 0 || decl->Semantic.StreamY != 0 ||368decl->Semantic.StreamZ != 0 || decl->Semantic.StreamW != 0) {369TXT(", STREAM(");370UID(decl->Semantic.StreamX);371TXT(", ");372UID(decl->Semantic.StreamY);373TXT(", ");374UID(decl->Semantic.StreamZ);375TXT(", ");376UID(decl->Semantic.StreamW);377CHR(')');378}379}380381if (decl->Declaration.File == TGSI_FILE_IMAGE) {382TXT(", ");383ENM(decl->Image.Resource, tgsi_texture_names);384TXT(", ");385TXT(util_format_name(decl->Image.Format));386if (decl->Image.Writable)387TXT(", WR");388if (decl->Image.Raw)389TXT(", RAW");390}391392if (decl->Declaration.File == TGSI_FILE_BUFFER) {393if (decl->Declaration.Atomic)394TXT(", ATOMIC");395}396397if (decl->Declaration.File == TGSI_FILE_MEMORY) {398switch (decl->Declaration.MemType) {399/* Note: ,GLOBAL is optional / the default */400case TGSI_MEMORY_TYPE_GLOBAL: TXT(", GLOBAL"); break;401case TGSI_MEMORY_TYPE_SHARED: TXT(", SHARED"); break;402case TGSI_MEMORY_TYPE_PRIVATE: TXT(", PRIVATE"); break;403case TGSI_MEMORY_TYPE_INPUT: TXT(", INPUT"); break;404}405}406407if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {408TXT(", ");409ENM(decl->SamplerView.Resource, tgsi_texture_names);410TXT(", ");411if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) &&412(decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) &&413(decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) {414ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names);415} else {416ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names);417TXT(", ");418ENM(decl->SamplerView.ReturnTypeY, tgsi_return_type_names);419TXT(", ");420ENM(decl->SamplerView.ReturnTypeZ, tgsi_return_type_names);421TXT(", ");422ENM(decl->SamplerView.ReturnTypeW, tgsi_return_type_names);423}424}425426if (decl->Declaration.Interpolate) {427if (iter->processor.Processor == PIPE_SHADER_FRAGMENT &&428decl->Declaration.File == TGSI_FILE_INPUT)429{430TXT( ", " );431ENM( decl->Interp.Interpolate, tgsi_interpolate_names );432}433434if (decl->Interp.Location != TGSI_INTERPOLATE_LOC_CENTER) {435TXT( ", " );436ENM( decl->Interp.Location, tgsi_interpolate_locations );437}438439if (decl->Interp.CylindricalWrap) {440TXT(", CYLWRAP_");441if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {442CHR('X');443}444if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) {445CHR('Y');446}447if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) {448CHR('Z');449}450if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) {451CHR('W');452}453}454}455456if (decl->Declaration.Invariant) {457TXT( ", INVARIANT" );458}459460EOL();461462return TRUE;463}464465void466tgsi_dump_declaration(467const struct tgsi_full_declaration *decl )468{469struct dump_ctx ctx;470memset(&ctx, 0, sizeof(ctx));471472ctx.dump_printf = dump_ctx_printf;473474iter_declaration( &ctx.iter, (struct tgsi_full_declaration *)decl );475}476477static boolean478iter_property(479struct tgsi_iterate_context *iter,480struct tgsi_full_property *prop )481{482int i;483struct dump_ctx *ctx = (struct dump_ctx *)iter;484485TXT( "PROPERTY " );486ENM(prop->Property.PropertyName, tgsi_property_names);487488if (prop->Property.NrTokens > 1)489TXT(" ");490491for (i = 0; i < prop->Property.NrTokens - 1; ++i) {492switch (prop->Property.PropertyName) {493case TGSI_PROPERTY_GS_INPUT_PRIM:494case TGSI_PROPERTY_GS_OUTPUT_PRIM:495ENM(prop->u[i].Data, tgsi_primitive_names);496break;497case TGSI_PROPERTY_FS_COORD_ORIGIN:498ENM(prop->u[i].Data, tgsi_fs_coord_origin_names);499break;500case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:501ENM(prop->u[i].Data, tgsi_fs_coord_pixel_center_names);502break;503case TGSI_PROPERTY_NEXT_SHADER:504ENM(prop->u[i].Data, tgsi_processor_type_names);505break;506default:507SID( prop->u[i].Data );508break;509}510if (i < prop->Property.NrTokens - 2)511TXT( ", " );512}513EOL();514515return TRUE;516}517518void tgsi_dump_property(519const struct tgsi_full_property *prop )520{521struct dump_ctx ctx;522memset(&ctx, 0, sizeof(ctx));523524ctx.dump_printf = dump_ctx_printf;525526iter_property( &ctx.iter, (struct tgsi_full_property *)prop );527}528529static boolean530iter_immediate(531struct tgsi_iterate_context *iter,532struct tgsi_full_immediate *imm )533{534struct dump_ctx *ctx = (struct dump_ctx *) iter;535536TXT( "IMM[" );537SID( ctx->immno++ );538TXT( "] " );539ENM( imm->Immediate.DataType, tgsi_immediate_type_names );540541dump_imm_data(iter, imm->u, imm->Immediate.NrTokens - 1,542imm->Immediate.DataType);543544EOL();545546return TRUE;547}548549void550tgsi_dump_immediate(551const struct tgsi_full_immediate *imm )552{553struct dump_ctx ctx;554memset(&ctx, 0, sizeof(ctx));555556ctx.dump_printf = dump_ctx_printf;557558iter_immediate( &ctx.iter, (struct tgsi_full_immediate *)imm );559}560561static boolean562iter_instruction(563struct tgsi_iterate_context *iter,564struct tgsi_full_instruction *inst )565{566struct dump_ctx *ctx = (struct dump_ctx *) iter;567uint instno = ctx->instno++;568const struct tgsi_opcode_info *info = tgsi_get_opcode_info( inst->Instruction.Opcode );569uint i;570boolean first_reg = TRUE;571572INSTID( instno );573TXT( ": " );574575ctx->indent -= info->pre_dedent;576for(i = 0; (int)i < ctx->indent; ++i)577TXT( " " );578ctx->indent += info->post_indent;579580TXT( tgsi_get_opcode_name(inst->Instruction.Opcode) );581582if (inst->Instruction.Saturate) {583TXT( "_SAT" );584}585586if (inst->Instruction.Precise) {587TXT( "_PRECISE" );588}589590for (i = 0; i < inst->Instruction.NumDstRegs; i++) {591const struct tgsi_full_dst_register *dst = &inst->Dst[i];592593if (!first_reg)594CHR( ',' );595CHR( ' ' );596597_dump_register_dst( ctx, dst );598_dump_writemask( ctx, dst->Register.WriteMask );599600first_reg = FALSE;601}602603for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {604const struct tgsi_full_src_register *src = &inst->Src[i];605606if (!first_reg)607CHR( ',' );608CHR( ' ' );609610if (src->Register.Negate)611CHR( '-' );612if (src->Register.Absolute)613CHR( '|' );614615_dump_register_src(ctx, src);616617if (src->Register.SwizzleX != TGSI_SWIZZLE_X ||618src->Register.SwizzleY != TGSI_SWIZZLE_Y ||619src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||620src->Register.SwizzleW != TGSI_SWIZZLE_W) {621CHR( '.' );622ENM( src->Register.SwizzleX, tgsi_swizzle_names );623ENM( src->Register.SwizzleY, tgsi_swizzle_names );624ENM( src->Register.SwizzleZ, tgsi_swizzle_names );625ENM( src->Register.SwizzleW, tgsi_swizzle_names );626}627628if (src->Register.Absolute)629CHR( '|' );630631first_reg = FALSE;632}633634if (inst->Instruction.Texture) {635if (!(inst->Instruction.Opcode >= TGSI_OPCODE_SAMPLE &&636inst->Instruction.Opcode <= TGSI_OPCODE_GATHER4)) {637TXT( ", " );638ENM( inst->Texture.Texture, tgsi_texture_names );639}640for (i = 0; i < inst->Texture.NumOffsets; i++) {641TXT( ", " );642TXT(tgsi_file_name(inst->TexOffsets[i].File));643CHR( '[' );644SID( inst->TexOffsets[i].Index );645CHR( ']' );646CHR( '.' );647ENM( inst->TexOffsets[i].SwizzleX, tgsi_swizzle_names);648ENM( inst->TexOffsets[i].SwizzleY, tgsi_swizzle_names);649ENM( inst->TexOffsets[i].SwizzleZ, tgsi_swizzle_names);650}651}652653if (inst->Instruction.Memory) {654uint32_t qualifier = inst->Memory.Qualifier;655while (qualifier) {656int bit = ffs(qualifier) - 1;657qualifier &= ~(1U << bit);658TXT(", ");659ENM(bit, tgsi_memory_names);660}661if (inst->Memory.Texture) {662TXT( ", " );663ENM( inst->Memory.Texture, tgsi_texture_names );664}665if (inst->Memory.Format) {666TXT( ", " );667TXT( util_format_name(inst->Memory.Format) );668}669}670671if (inst->Instruction.Label) {672switch (inst->Instruction.Opcode) {673case TGSI_OPCODE_IF:674case TGSI_OPCODE_UIF:675case TGSI_OPCODE_ELSE:676case TGSI_OPCODE_BGNLOOP:677case TGSI_OPCODE_ENDLOOP:678case TGSI_OPCODE_CAL:679case TGSI_OPCODE_BGNSUB:680TXT( " :" );681UID( inst->Label.Label );682break;683}684}685686/* update indentation */687if (inst->Instruction.Opcode == TGSI_OPCODE_IF ||688inst->Instruction.Opcode == TGSI_OPCODE_UIF ||689inst->Instruction.Opcode == TGSI_OPCODE_ELSE ||690inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP) {691ctx->indentation += indent_spaces;692}693694EOL();695696return TRUE;697}698699void700tgsi_dump_instruction(701const struct tgsi_full_instruction *inst,702uint instno )703{704struct dump_ctx ctx;705memset(&ctx, 0, sizeof(ctx));706707ctx.instno = instno;708ctx.immno = instno;709ctx.indent = 0;710ctx.dump_printf = dump_ctx_printf;711ctx.indentation = 0;712ctx.file = NULL;713714iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst );715}716717static boolean718prolog(719struct tgsi_iterate_context *iter )720{721struct dump_ctx *ctx = (struct dump_ctx *) iter;722ENM( iter->processor.Processor, tgsi_processor_type_names );723EOL();724return TRUE;725}726727static void728init_dump_ctx(struct dump_ctx *ctx, uint flags)729{730memset(ctx, 0, sizeof(*ctx));731732ctx->iter.prolog = prolog;733ctx->iter.iterate_instruction = iter_instruction;734ctx->iter.iterate_declaration = iter_declaration;735ctx->iter.iterate_immediate = iter_immediate;736ctx->iter.iterate_property = iter_property;737738if (flags & TGSI_DUMP_FLOAT_AS_HEX)739ctx->dump_float_as_hex = TRUE;740}741742void743tgsi_dump_to_file(const struct tgsi_token *tokens, uint flags, FILE *file)744{745struct dump_ctx ctx;746memset(&ctx, 0, sizeof(ctx));747748init_dump_ctx(&ctx, flags);749750ctx.dump_printf = dump_ctx_printf;751ctx.file = file;752753tgsi_iterate_shader( tokens, &ctx.iter );754}755756void757tgsi_dump(const struct tgsi_token *tokens, uint flags)758{759tgsi_dump_to_file(tokens, flags, NULL);760}761762struct str_dump_ctx763{764struct dump_ctx base;765char *str;766char *ptr;767int left;768bool nospace;769};770771static void772str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)773{774struct str_dump_ctx *sctx = (struct str_dump_ctx *)ctx;775776if (!sctx->nospace) {777int written;778va_list ap;779va_start(ap, format);780written = vsnprintf(sctx->ptr, sctx->left, format, ap);781va_end(ap);782783/* Some complicated logic needed to handle the return value of784* vsnprintf:785*/786if (written > 0) {787if (written >= sctx->left) {788sctx->nospace = true;789written = sctx->left;790}791sctx->ptr += written;792sctx->left -= written;793}794}795}796797bool798tgsi_dump_str(799const struct tgsi_token *tokens,800uint flags,801char *str,802size_t size)803{804struct str_dump_ctx ctx;805memset(&ctx, 0, sizeof(ctx));806807init_dump_ctx(&ctx.base, flags);808809ctx.base.dump_printf = &str_dump_ctx_printf;810811ctx.str = str;812ctx.str[0] = 0;813ctx.ptr = str;814ctx.left = (int)size;815ctx.nospace = false;816817tgsi_iterate_shader( tokens, &ctx.base.iter );818819return !ctx.nospace;820}821822void823tgsi_dump_instruction_str(824const struct tgsi_full_instruction *inst,825uint instno,826char *str,827size_t size)828{829struct str_dump_ctx ctx;830memset(&ctx, 0, sizeof(ctx));831832ctx.base.instno = instno;833ctx.base.immno = instno;834ctx.base.indent = 0;835ctx.base.dump_printf = &str_dump_ctx_printf;836ctx.base.indentation = 0;837ctx.base.file = NULL;838839ctx.str = str;840ctx.str[0] = 0;841ctx.ptr = str;842ctx.left = (int)size;843ctx.nospace = false;844845iter_instruction( &ctx.base.iter, (struct tgsi_full_instruction *)inst );846}847848849