13d67691897b8671562835aea4073650099d25f8
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_dump.c
1 /**************************************************************************
2 *
3 * Copyright 2007-2008 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "util/u_debug.h"
29 #include "util/u_string.h"
30 #include "util/u_math.h"
31 #include "util/u_memory.h"
32 #include "tgsi_dump.h"
33 #include "tgsi_info.h"
34 #include "tgsi_iterate.h"
35 #include "tgsi_strings.h"
36
37
38 /** Number of spaces to indent for IF/LOOP/etc */
39 static const int indent_spaces = 3;
40
41
42 struct dump_ctx
43 {
44 struct tgsi_iterate_context iter;
45
46 uint instno;
47 uint immno;
48 int indent;
49
50 uint indentation;
51
52 void (*dump_printf)(struct dump_ctx *ctx, const char *format, ...);
53 };
54
55 static void
56 dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
57 {
58 va_list ap;
59 (void)ctx;
60 va_start(ap, format);
61 _debug_vprintf(format, ap);
62 va_end(ap);
63 }
64
65 static void
66 dump_enum(
67 struct dump_ctx *ctx,
68 uint e,
69 const char **enums,
70 uint enum_count )
71 {
72 if (e >= enum_count)
73 ctx->dump_printf( ctx, "%u", e );
74 else
75 ctx->dump_printf( ctx, "%s", enums[e] );
76 }
77
78 #define EOL() ctx->dump_printf( ctx, "\n" )
79 #define TXT(S) ctx->dump_printf( ctx, "%s", S )
80 #define CHR(C) ctx->dump_printf( ctx, "%c", C )
81 #define UIX(I) ctx->dump_printf( ctx, "0x%x", I )
82 #define UID(I) ctx->dump_printf( ctx, "%u", I )
83 #define INSTID(I) ctx->dump_printf( ctx, "% 3u", I )
84 #define SID(I) ctx->dump_printf( ctx, "%d", I )
85 #define FLT(F) ctx->dump_printf( ctx, "%10.4f", F )
86 #define DBL(D) ctx->dump_printf( ctx, "%10.8f", D )
87 #define ENM(E,ENUMS) dump_enum( ctx, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
88
89 const char *
90 tgsi_swizzle_names[4] =
91 {
92 "x",
93 "y",
94 "z",
95 "w"
96 };
97
98 static void
99 _dump_register_src(
100 struct dump_ctx *ctx,
101 const struct tgsi_full_src_register *src )
102 {
103 TXT(tgsi_file_name(src->Register.File));
104 if (src->Register.Dimension) {
105 if (src->Dimension.Indirect) {
106 CHR( '[' );
107 TXT(tgsi_file_name(src->DimIndirect.File));
108 CHR( '[' );
109 SID( src->DimIndirect.Index );
110 TXT( "]." );
111 ENM( src->DimIndirect.Swizzle, tgsi_swizzle_names );
112 if (src->Dimension.Index != 0) {
113 if (src->Dimension.Index > 0)
114 CHR( '+' );
115 SID( src->Dimension.Index );
116 }
117 CHR( ']' );
118 if (src->DimIndirect.ArrayID) {
119 CHR( '(' );
120 SID( src->DimIndirect.ArrayID );
121 CHR( ')' );
122 }
123 } else {
124 CHR('[');
125 SID(src->Dimension.Index);
126 CHR(']');
127 }
128 }
129 if (src->Register.Indirect) {
130 CHR( '[' );
131 TXT(tgsi_file_name(src->Indirect.File));
132 CHR( '[' );
133 SID( src->Indirect.Index );
134 TXT( "]." );
135 ENM( src->Indirect.Swizzle, tgsi_swizzle_names );
136 if (src->Register.Index != 0) {
137 if (src->Register.Index > 0)
138 CHR( '+' );
139 SID( src->Register.Index );
140 }
141 CHR( ']' );
142 if (src->Indirect.ArrayID) {
143 CHR( '(' );
144 SID( src->Indirect.ArrayID );
145 CHR( ')' );
146 }
147 } else {
148 CHR( '[' );
149 SID( src->Register.Index );
150 CHR( ']' );
151 }
152 }
153
154
155 static void
156 _dump_register_dst(
157 struct dump_ctx *ctx,
158 const struct tgsi_full_dst_register *dst )
159 {
160 TXT(tgsi_file_name(dst->Register.File));
161 if (dst->Register.Dimension) {
162 if (dst->Dimension.Indirect) {
163 CHR( '[' );
164 TXT(tgsi_file_name(dst->DimIndirect.File));
165 CHR( '[' );
166 SID( dst->DimIndirect.Index );
167 TXT( "]." );
168 ENM( dst->DimIndirect.Swizzle, tgsi_swizzle_names );
169 if (dst->Dimension.Index != 0) {
170 if (dst->Dimension.Index > 0)
171 CHR( '+' );
172 SID( dst->Dimension.Index );
173 }
174 CHR( ']' );
175 if (dst->DimIndirect.ArrayID) {
176 CHR( '(' );
177 SID( dst->DimIndirect.ArrayID );
178 CHR( ')' );
179 }
180 } else {
181 CHR('[');
182 SID(dst->Dimension.Index);
183 CHR(']');
184 }
185 }
186 if (dst->Register.Indirect) {
187 CHR( '[' );
188 TXT(tgsi_file_name(dst->Indirect.File));
189 CHR( '[' );
190 SID( dst->Indirect.Index );
191 TXT( "]." );
192 ENM( dst->Indirect.Swizzle, tgsi_swizzle_names );
193 if (dst->Register.Index != 0) {
194 if (dst->Register.Index > 0)
195 CHR( '+' );
196 SID( dst->Register.Index );
197 }
198 CHR( ']' );
199 if (dst->Indirect.ArrayID) {
200 CHR( '(' );
201 SID( dst->Indirect.ArrayID );
202 CHR( ')' );
203 }
204 } else {
205 CHR( '[' );
206 SID( dst->Register.Index );
207 CHR( ']' );
208 }
209 }
210 static void
211 _dump_writemask(
212 struct dump_ctx *ctx,
213 uint writemask )
214 {
215 if (writemask != TGSI_WRITEMASK_XYZW) {
216 CHR( '.' );
217 if (writemask & TGSI_WRITEMASK_X)
218 CHR( 'x' );
219 if (writemask & TGSI_WRITEMASK_Y)
220 CHR( 'y' );
221 if (writemask & TGSI_WRITEMASK_Z)
222 CHR( 'z' );
223 if (writemask & TGSI_WRITEMASK_W)
224 CHR( 'w' );
225 }
226 }
227
228 static void
229 dump_imm_data(struct tgsi_iterate_context *iter,
230 union tgsi_immediate_data *data,
231 unsigned num_tokens,
232 unsigned data_type)
233 {
234 struct dump_ctx *ctx = (struct dump_ctx *)iter;
235 unsigned i ;
236
237 TXT( " {" );
238
239 assert( num_tokens <= 4 );
240 for (i = 0; i < num_tokens; i++) {
241 switch (data_type) {
242 case TGSI_IMM_FLOAT64: {
243 union di d;
244 d.ui = data[i].Uint | (uint64_t)data[i+1].Uint << 32;
245 DBL( d.d );
246 i++;
247 break;
248 }
249 case TGSI_IMM_FLOAT32:
250 FLT( data[i].Float );
251 break;
252 case TGSI_IMM_UINT32:
253 UID(data[i].Uint);
254 break;
255 case TGSI_IMM_INT32:
256 SID(data[i].Int);
257 break;
258 default:
259 assert( 0 );
260 }
261
262 if (i < num_tokens - 1)
263 TXT( ", " );
264 }
265 TXT( "}" );
266 }
267
268 static boolean
269 iter_declaration(
270 struct tgsi_iterate_context *iter,
271 struct tgsi_full_declaration *decl )
272 {
273 struct dump_ctx *ctx = (struct dump_ctx *)iter;
274
275 TXT( "DCL " );
276
277 TXT(tgsi_file_name(decl->Declaration.File));
278
279 /* all geometry shader inputs are two dimensional */
280 if (decl->Declaration.File == TGSI_FILE_INPUT &&
281 iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) {
282 TXT("[]");
283 }
284
285 if (decl->Declaration.Dimension) {
286 CHR('[');
287 SID(decl->Dim.Index2D);
288 CHR(']');
289 }
290
291 CHR('[');
292 SID(decl->Range.First);
293 if (decl->Range.First != decl->Range.Last) {
294 TXT("..");
295 SID(decl->Range.Last);
296 }
297 CHR(']');
298
299 _dump_writemask(
300 ctx,
301 decl->Declaration.UsageMask );
302
303 if (decl->Declaration.Array) {
304 TXT( ", ARRAY(" );
305 SID(decl->Array.ArrayID);
306 CHR(')');
307 }
308
309 if (decl->Declaration.Local)
310 TXT( ", LOCAL" );
311
312 if (decl->Declaration.Semantic) {
313 TXT( ", " );
314 ENM( decl->Semantic.Name, tgsi_semantic_names );
315 if (decl->Semantic.Index != 0 ||
316 decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD ||
317 decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
318 CHR( '[' );
319 UID( decl->Semantic.Index );
320 CHR( ']' );
321 }
322 }
323
324 if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
325 TXT(", ");
326 ENM(decl->Resource.Resource, tgsi_texture_names);
327 if (decl->Resource.Writable)
328 TXT(", WR");
329 if (decl->Resource.Raw)
330 TXT(", RAW");
331 }
332
333 if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
334 TXT(", ");
335 ENM(decl->SamplerView.Resource, tgsi_texture_names);
336 TXT(", ");
337 if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) &&
338 (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) &&
339 (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) {
340 ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names);
341 } else {
342 ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names);
343 TXT(", ");
344 ENM(decl->SamplerView.ReturnTypeY, tgsi_return_type_names);
345 TXT(", ");
346 ENM(decl->SamplerView.ReturnTypeZ, tgsi_return_type_names);
347 TXT(", ");
348 ENM(decl->SamplerView.ReturnTypeW, tgsi_return_type_names);
349 }
350 }
351
352 if (decl->Declaration.Interpolate) {
353 if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
354 decl->Declaration.File == TGSI_FILE_INPUT)
355 {
356 TXT( ", " );
357 ENM( decl->Interp.Interpolate, tgsi_interpolate_names );
358 }
359
360 if (decl->Interp.Location != TGSI_INTERPOLATE_LOC_CENTER) {
361 TXT( ", " );
362 ENM( decl->Interp.Location, tgsi_interpolate_locations );
363 }
364
365 if (decl->Interp.CylindricalWrap) {
366 TXT(", CYLWRAP_");
367 if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {
368 CHR('X');
369 }
370 if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) {
371 CHR('Y');
372 }
373 if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) {
374 CHR('Z');
375 }
376 if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) {
377 CHR('W');
378 }
379 }
380 }
381
382 if (decl->Declaration.Invariant) {
383 TXT( ", INVARIANT" );
384 }
385
386 EOL();
387
388 return TRUE;
389 }
390
391 void
392 tgsi_dump_declaration(
393 const struct tgsi_full_declaration *decl )
394 {
395 struct dump_ctx ctx;
396
397 ctx.dump_printf = dump_ctx_printf;
398
399 iter_declaration( &ctx.iter, (struct tgsi_full_declaration *)decl );
400 }
401
402 static boolean
403 iter_property(
404 struct tgsi_iterate_context *iter,
405 struct tgsi_full_property *prop )
406 {
407 unsigned i;
408 struct dump_ctx *ctx = (struct dump_ctx *)iter;
409
410 TXT( "PROPERTY " );
411 ENM(prop->Property.PropertyName, tgsi_property_names);
412
413 if (prop->Property.NrTokens > 1)
414 TXT(" ");
415
416 for (i = 0; i < prop->Property.NrTokens - 1; ++i) {
417 switch (prop->Property.PropertyName) {
418 case TGSI_PROPERTY_GS_INPUT_PRIM:
419 case TGSI_PROPERTY_GS_OUTPUT_PRIM:
420 ENM(prop->u[i].Data, tgsi_primitive_names);
421 break;
422 case TGSI_PROPERTY_FS_COORD_ORIGIN:
423 ENM(prop->u[i].Data, tgsi_fs_coord_origin_names);
424 break;
425 case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
426 ENM(prop->u[i].Data, tgsi_fs_coord_pixel_center_names);
427 break;
428 default:
429 SID( prop->u[i].Data );
430 break;
431 }
432 if (i < prop->Property.NrTokens - 2)
433 TXT( ", " );
434 }
435 EOL();
436
437 return TRUE;
438 }
439
440 void tgsi_dump_property(
441 const struct tgsi_full_property *prop )
442 {
443 struct dump_ctx ctx;
444
445 ctx.dump_printf = dump_ctx_printf;
446
447 iter_property( &ctx.iter, (struct tgsi_full_property *)prop );
448 }
449
450 static boolean
451 iter_immediate(
452 struct tgsi_iterate_context *iter,
453 struct tgsi_full_immediate *imm )
454 {
455 struct dump_ctx *ctx = (struct dump_ctx *) iter;
456
457 TXT( "IMM[" );
458 SID( ctx->immno++ );
459 TXT( "] " );
460 ENM( imm->Immediate.DataType, tgsi_immediate_type_names );
461
462 dump_imm_data(iter, imm->u, imm->Immediate.NrTokens - 1,
463 imm->Immediate.DataType);
464
465 EOL();
466
467 return TRUE;
468 }
469
470 void
471 tgsi_dump_immediate(
472 const struct tgsi_full_immediate *imm )
473 {
474 struct dump_ctx ctx;
475
476 ctx.dump_printf = dump_ctx_printf;
477
478 iter_immediate( &ctx.iter, (struct tgsi_full_immediate *)imm );
479 }
480
481 static boolean
482 iter_instruction(
483 struct tgsi_iterate_context *iter,
484 struct tgsi_full_instruction *inst )
485 {
486 struct dump_ctx *ctx = (struct dump_ctx *) iter;
487 uint instno = ctx->instno++;
488 const struct tgsi_opcode_info *info = tgsi_get_opcode_info( inst->Instruction.Opcode );
489 uint i;
490 boolean first_reg = TRUE;
491
492 INSTID( instno );
493 TXT( ": " );
494
495 ctx->indent -= info->pre_dedent;
496 for(i = 0; (int)i < ctx->indent; ++i)
497 TXT( " " );
498 ctx->indent += info->post_indent;
499
500 if (inst->Instruction.Predicate) {
501 CHR( '(' );
502
503 if (inst->Predicate.Negate)
504 CHR( '!' );
505
506 TXT( "PRED[" );
507 SID( inst->Predicate.Index );
508 CHR( ']' );
509
510 if (inst->Predicate.SwizzleX != TGSI_SWIZZLE_X ||
511 inst->Predicate.SwizzleY != TGSI_SWIZZLE_Y ||
512 inst->Predicate.SwizzleZ != TGSI_SWIZZLE_Z ||
513 inst->Predicate.SwizzleW != TGSI_SWIZZLE_W) {
514 CHR( '.' );
515 ENM( inst->Predicate.SwizzleX, tgsi_swizzle_names );
516 ENM( inst->Predicate.SwizzleY, tgsi_swizzle_names );
517 ENM( inst->Predicate.SwizzleZ, tgsi_swizzle_names );
518 ENM( inst->Predicate.SwizzleW, tgsi_swizzle_names );
519 }
520
521 TXT( ") " );
522 }
523
524 TXT( info->mnemonic );
525
526 switch (inst->Instruction.Saturate) {
527 case TGSI_SAT_NONE:
528 break;
529 case TGSI_SAT_ZERO_ONE:
530 TXT( "_SAT" );
531 break;
532 case TGSI_SAT_MINUS_PLUS_ONE:
533 TXT( "_SATNV" );
534 break;
535 default:
536 assert( 0 );
537 }
538
539 for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
540 const struct tgsi_full_dst_register *dst = &inst->Dst[i];
541
542 if (!first_reg)
543 CHR( ',' );
544 CHR( ' ' );
545
546 _dump_register_dst( ctx, dst );
547 _dump_writemask( ctx, dst->Register.WriteMask );
548
549 first_reg = FALSE;
550 }
551
552 for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
553 const struct tgsi_full_src_register *src = &inst->Src[i];
554
555 if (!first_reg)
556 CHR( ',' );
557 CHR( ' ' );
558
559 if (src->Register.Negate)
560 CHR( '-' );
561 if (src->Register.Absolute)
562 CHR( '|' );
563
564 _dump_register_src(ctx, src);
565
566 if (src->Register.SwizzleX != TGSI_SWIZZLE_X ||
567 src->Register.SwizzleY != TGSI_SWIZZLE_Y ||
568 src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||
569 src->Register.SwizzleW != TGSI_SWIZZLE_W) {
570 CHR( '.' );
571 ENM( src->Register.SwizzleX, tgsi_swizzle_names );
572 ENM( src->Register.SwizzleY, tgsi_swizzle_names );
573 ENM( src->Register.SwizzleZ, tgsi_swizzle_names );
574 ENM( src->Register.SwizzleW, tgsi_swizzle_names );
575 }
576
577 if (src->Register.Absolute)
578 CHR( '|' );
579
580 first_reg = FALSE;
581 }
582
583 if (inst->Instruction.Texture) {
584 if (!(inst->Instruction.Opcode >= TGSI_OPCODE_SAMPLE &&
585 inst->Instruction.Opcode <= TGSI_OPCODE_GATHER4)) {
586 TXT( ", " );
587 ENM( inst->Texture.Texture, tgsi_texture_names );
588 }
589 for (i = 0; i < inst->Texture.NumOffsets; i++) {
590 TXT( ", " );
591 TXT(tgsi_file_name(inst->TexOffsets[i].File));
592 CHR( '[' );
593 SID( inst->TexOffsets[i].Index );
594 CHR( ']' );
595 CHR( '.' );
596 ENM( inst->TexOffsets[i].SwizzleX, tgsi_swizzle_names);
597 ENM( inst->TexOffsets[i].SwizzleY, tgsi_swizzle_names);
598 ENM( inst->TexOffsets[i].SwizzleZ, tgsi_swizzle_names);
599 }
600 }
601
602 switch (inst->Instruction.Opcode) {
603 case TGSI_OPCODE_IF:
604 case TGSI_OPCODE_UIF:
605 case TGSI_OPCODE_ELSE:
606 case TGSI_OPCODE_BGNLOOP:
607 case TGSI_OPCODE_ENDLOOP:
608 case TGSI_OPCODE_CAL:
609 case TGSI_OPCODE_BGNSUB:
610 TXT( " :" );
611 UID( inst->Label.Label );
612 break;
613 }
614
615 /* update indentation */
616 if (inst->Instruction.Opcode == TGSI_OPCODE_IF ||
617 inst->Instruction.Opcode == TGSI_OPCODE_UIF ||
618 inst->Instruction.Opcode == TGSI_OPCODE_ELSE ||
619 inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP) {
620 ctx->indentation += indent_spaces;
621 }
622
623 EOL();
624
625 return TRUE;
626 }
627
628 void
629 tgsi_dump_instruction(
630 const struct tgsi_full_instruction *inst,
631 uint instno )
632 {
633 struct dump_ctx ctx;
634
635 ctx.instno = instno;
636 ctx.immno = instno;
637 ctx.indent = 0;
638 ctx.dump_printf = dump_ctx_printf;
639 ctx.indentation = 0;
640
641 iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst );
642 }
643
644 static boolean
645 prolog(
646 struct tgsi_iterate_context *iter )
647 {
648 struct dump_ctx *ctx = (struct dump_ctx *) iter;
649 ENM( iter->processor.Processor, tgsi_processor_type_names );
650 EOL();
651 return TRUE;
652 }
653
654 void
655 tgsi_dump(
656 const struct tgsi_token *tokens,
657 uint flags )
658 {
659 struct dump_ctx ctx;
660
661 ctx.iter.prolog = prolog;
662 ctx.iter.iterate_instruction = iter_instruction;
663 ctx.iter.iterate_declaration = iter_declaration;
664 ctx.iter.iterate_immediate = iter_immediate;
665 ctx.iter.iterate_property = iter_property;
666 ctx.iter.epilog = NULL;
667
668 ctx.instno = 0;
669 ctx.immno = 0;
670 ctx.indent = 0;
671 ctx.dump_printf = dump_ctx_printf;
672 ctx.indentation = 0;
673
674 tgsi_iterate_shader( tokens, &ctx.iter );
675 }
676
677 struct str_dump_ctx
678 {
679 struct dump_ctx base;
680 char *str;
681 char *ptr;
682 int left;
683 };
684
685 static void
686 str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
687 {
688 struct str_dump_ctx *sctx = (struct str_dump_ctx *)ctx;
689
690 if(sctx->left > 1) {
691 int written;
692 va_list ap;
693 va_start(ap, format);
694 written = util_vsnprintf(sctx->ptr, sctx->left, format, ap);
695 va_end(ap);
696
697 /* Some complicated logic needed to handle the return value of
698 * vsnprintf:
699 */
700 if (written > 0) {
701 written = MIN2(sctx->left, written);
702 sctx->ptr += written;
703 sctx->left -= written;
704 }
705 }
706 }
707
708 void
709 tgsi_dump_str(
710 const struct tgsi_token *tokens,
711 uint flags,
712 char *str,
713 size_t size)
714 {
715 struct str_dump_ctx ctx;
716
717 ctx.base.iter.prolog = prolog;
718 ctx.base.iter.iterate_instruction = iter_instruction;
719 ctx.base.iter.iterate_declaration = iter_declaration;
720 ctx.base.iter.iterate_immediate = iter_immediate;
721 ctx.base.iter.iterate_property = iter_property;
722 ctx.base.iter.epilog = NULL;
723
724 ctx.base.instno = 0;
725 ctx.base.immno = 0;
726 ctx.base.indent = 0;
727 ctx.base.dump_printf = &str_dump_ctx_printf;
728 ctx.base.indentation = 0;
729
730 ctx.str = str;
731 ctx.str[0] = 0;
732 ctx.ptr = str;
733 ctx.left = (int)size;
734
735 tgsi_iterate_shader( tokens, &ctx.base.iter );
736 }
737
738 void
739 tgsi_dump_instruction_str(
740 const struct tgsi_full_instruction *inst,
741 uint instno,
742 char *str,
743 size_t size)
744 {
745 struct str_dump_ctx ctx;
746
747 ctx.base.instno = instno;
748 ctx.base.immno = instno;
749 ctx.base.indent = 0;
750 ctx.base.dump_printf = &str_dump_ctx_printf;
751 ctx.base.indentation = 0;
752
753 ctx.str = str;
754 ctx.str[0] = 0;
755 ctx.ptr = str;
756 ctx.left = (int)size;
757
758 iter_instruction( &ctx.base.iter, (struct tgsi_full_instruction *)inst );
759 }