2 * Copyright © 2014 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Connor Abbott (cwabbott0@gmail.com)
29 #include "shader_enums.h"
34 print_tabs(unsigned num_tabs
, FILE *fp
)
36 for (unsigned i
= 0; i
< num_tabs
; i
++)
43 /** map from nir_variable -> printable name */
44 struct hash_table
*ht
;
46 /** set of names used so far for nir_variables */
49 /* an index used to make new non-conflicting names */
54 print_register(nir_register
*reg
, print_state
*state
)
57 if (reg
->name
!= NULL
)
58 fprintf(fp
, "/* %s */ ", reg
->name
);
60 fprintf(fp
, "gr%u", reg
->index
);
62 fprintf(fp
, "r%u", reg
->index
);
65 static const char *sizes
[] = { "error", "vec1", "vec2", "vec3", "vec4" };
68 print_register_decl(nir_register
*reg
, print_state
*state
)
71 fprintf(fp
, "decl_reg %s ", sizes
[reg
->num_components
]);
73 fprintf(fp
, "(packed) ");
74 print_register(reg
, state
);
75 if (reg
->num_array_elems
!= 0)
76 fprintf(fp
, "[%u]", reg
->num_array_elems
);
81 print_ssa_def(nir_ssa_def
*def
, print_state
*state
)
84 if (def
->name
!= NULL
)
85 fprintf(fp
, "/* %s */ ", def
->name
);
86 fprintf(fp
, "%s ssa_%u", sizes
[def
->num_components
], def
->index
);
90 print_ssa_use(nir_ssa_def
*def
, print_state
*state
)
93 if (def
->name
!= NULL
)
94 fprintf(fp
, "/* %s */ ", def
->name
);
95 fprintf(fp
, "ssa_%u", def
->index
);
98 static void print_src(nir_src
*src
, print_state
*state
);
101 print_reg_src(nir_reg_src
*src
, print_state
*state
)
103 FILE *fp
= state
->fp
;
104 print_register(src
->reg
, state
);
105 if (src
->reg
->num_array_elems
!= 0) {
106 fprintf(fp
, "[%u", src
->base_offset
);
107 if (src
->indirect
!= NULL
) {
109 print_src(src
->indirect
, state
);
116 print_reg_dest(nir_reg_dest
*dest
, print_state
*state
)
118 FILE *fp
= state
->fp
;
119 print_register(dest
->reg
, state
);
120 if (dest
->reg
->num_array_elems
!= 0) {
121 fprintf(fp
, "[%u", dest
->base_offset
);
122 if (dest
->indirect
!= NULL
) {
124 print_src(dest
->indirect
, state
);
131 print_src(nir_src
*src
, print_state
*state
)
134 print_ssa_use(src
->ssa
, state
);
136 print_reg_src(&src
->reg
, state
);
140 print_dest(nir_dest
*dest
, print_state
*state
)
143 print_ssa_def(&dest
->ssa
, state
);
145 print_reg_dest(&dest
->reg
, state
);
149 print_alu_src(nir_alu_instr
*instr
, unsigned src
, print_state
*state
)
151 FILE *fp
= state
->fp
;
153 if (instr
->src
[src
].negate
)
155 if (instr
->src
[src
].abs
)
158 print_src(&instr
->src
[src
].src
, state
);
160 bool print_swizzle
= false;
161 for (unsigned i
= 0; i
< 4; i
++) {
162 if (!nir_alu_instr_channel_used(instr
, src
, i
))
165 if (instr
->src
[src
].swizzle
[i
] != i
) {
166 print_swizzle
= true;
173 for (unsigned i
= 0; i
< 4; i
++) {
174 if (!nir_alu_instr_channel_used(instr
, src
, i
))
177 fprintf(fp
, "%c", "xyzw"[instr
->src
[src
].swizzle
[i
]]);
181 if (instr
->src
[src
].abs
)
186 print_alu_dest(nir_alu_dest
*dest
, print_state
*state
)
188 FILE *fp
= state
->fp
;
189 /* we're going to print the saturate modifier later, after the opcode */
191 print_dest(&dest
->dest
, state
);
193 if (!dest
->dest
.is_ssa
&&
194 dest
->write_mask
!= (1 << dest
->dest
.reg
.reg
->num_components
) - 1) {
196 for (unsigned i
= 0; i
< 4; i
++)
197 if ((dest
->write_mask
>> i
) & 1)
198 fprintf(fp
, "%c", "xyzw"[i
]);
203 print_alu_instr(nir_alu_instr
*instr
, print_state
*state
)
205 FILE *fp
= state
->fp
;
207 print_alu_dest(&instr
->dest
, state
);
209 fprintf(fp
, " = %s", nir_op_infos
[instr
->op
].name
);
210 if (instr
->dest
.saturate
)
214 for (unsigned i
= 0; i
< nir_op_infos
[instr
->op
].num_inputs
; i
++) {
218 print_alu_src(instr
, i
, state
);
223 print_var_decl(nir_variable
*var
, print_state
*state
)
225 FILE *fp
= state
->fp
;
227 fprintf(fp
, "decl_var ");
229 const char *const cent
= (var
->data
.centroid
) ? "centroid " : "";
230 const char *const samp
= (var
->data
.sample
) ? "sample " : "";
231 const char *const inv
= (var
->data
.invariant
) ? "invariant " : "";
232 const char *const mode
[] = { "shader_in ", "shader_out ", "", "",
233 "uniform ", "shader_storage", "system " };
235 fprintf(fp
, "%s%s%s%s%s ",
236 cent
, samp
, inv
, mode
[var
->data
.mode
],
237 glsl_interp_qualifier_name(var
->data
.interpolation
));
239 glsl_print_type(var
->type
, fp
);
241 struct set_entry
*entry
= NULL
;
243 entry
= _mesa_set_search(state
->syms
, var
->name
);
248 /* we have a collision with another name, append an @ + a unique index */
249 name
= ralloc_asprintf(state
->syms
, "%s@%u", var
->name
, state
->index
++);
254 fprintf(fp
, " %s", name
);
256 if (var
->data
.mode
== nir_var_shader_in
||
257 var
->data
.mode
== nir_var_shader_out
||
258 var
->data
.mode
== nir_var_uniform
||
259 var
->data
.mode
== nir_var_shader_storage
) {
260 const char *loc
= NULL
;
263 switch (state
->shader
->stage
) {
264 case MESA_SHADER_VERTEX
:
265 if (var
->data
.mode
== nir_var_shader_in
)
266 loc
= gl_vert_attrib_name(var
->data
.location
);
267 else if (var
->data
.mode
== nir_var_shader_out
)
268 loc
= gl_varying_slot_name(var
->data
.location
);
270 case MESA_SHADER_GEOMETRY
:
271 if ((var
->data
.mode
== nir_var_shader_in
) ||
272 (var
->data
.mode
== nir_var_shader_out
))
273 loc
= gl_varying_slot_name(var
->data
.location
);
275 case MESA_SHADER_FRAGMENT
:
276 if (var
->data
.mode
== nir_var_shader_in
)
277 loc
= gl_varying_slot_name(var
->data
.location
);
278 else if (var
->data
.mode
== nir_var_shader_out
)
279 loc
= gl_frag_result_name(var
->data
.location
);
281 case MESA_SHADER_TESS_CTRL
:
282 case MESA_SHADER_TESS_EVAL
:
283 case MESA_SHADER_COMPUTE
:
290 snprintf(buf
, sizeof(buf
), "%u", var
->data
.location
);
294 fprintf(fp
, " (%s, %u)", loc
, var
->data
.driver_location
);
300 _mesa_set_add(state
->syms
, name
);
301 _mesa_hash_table_insert(state
->ht
, var
, name
);
306 print_var(nir_variable
*var
, print_state
*state
)
308 FILE *fp
= state
->fp
;
311 struct hash_entry
*entry
= _mesa_hash_table_search(state
->ht
, var
);
313 assert(entry
!= NULL
);
319 fprintf(fp
, "%s", name
);
323 print_deref_var(nir_deref_var
*deref
, print_state
*state
)
325 print_var(deref
->var
, state
);
329 print_deref_array(nir_deref_array
*deref
, print_state
*state
)
331 FILE *fp
= state
->fp
;
333 switch (deref
->deref_array_type
) {
334 case nir_deref_array_type_direct
:
335 fprintf(fp
, "%u", deref
->base_offset
);
337 case nir_deref_array_type_indirect
:
338 if (deref
->base_offset
!= 0)
339 fprintf(fp
, "%u + ", deref
->base_offset
);
340 print_src(&deref
->indirect
, state
);
342 case nir_deref_array_type_wildcard
:
350 print_deref_struct(nir_deref_struct
*deref
, const struct glsl_type
*parent_type
,
353 FILE *fp
= state
->fp
;
354 fprintf(fp
, ".%s", glsl_get_struct_elem_name(parent_type
, deref
->index
));
358 print_deref(nir_deref_var
*deref
, print_state
*state
)
360 nir_deref
*tail
= &deref
->deref
;
361 nir_deref
*pretail
= NULL
;
362 while (tail
!= NULL
) {
363 switch (tail
->deref_type
) {
364 case nir_deref_type_var
:
365 assert(pretail
== NULL
);
366 assert(tail
== &deref
->deref
);
367 print_deref_var(deref
, state
);
370 case nir_deref_type_array
:
371 assert(pretail
!= NULL
);
372 print_deref_array(nir_deref_as_array(tail
), state
);
375 case nir_deref_type_struct
:
376 assert(pretail
!= NULL
);
377 print_deref_struct(nir_deref_as_struct(tail
),
378 pretail
->type
, state
);
382 unreachable("Invalid deref type");
386 tail
= pretail
->child
;
391 print_intrinsic_instr(nir_intrinsic_instr
*instr
, print_state
*state
)
393 unsigned num_srcs
= nir_intrinsic_infos
[instr
->intrinsic
].num_srcs
;
394 FILE *fp
= state
->fp
;
396 if (nir_intrinsic_infos
[instr
->intrinsic
].has_dest
) {
397 print_dest(&instr
->dest
, state
);
401 fprintf(fp
, "intrinsic %s (", nir_intrinsic_infos
[instr
->intrinsic
].name
);
403 for (unsigned i
= 0; i
< num_srcs
; i
++) {
407 print_src(&instr
->src
[i
], state
);
412 unsigned num_vars
= nir_intrinsic_infos
[instr
->intrinsic
].num_variables
;
414 for (unsigned i
= 0; i
< num_vars
; i
++) {
418 print_deref(instr
->variables
[i
], state
);
423 unsigned num_indices
= nir_intrinsic_infos
[instr
->intrinsic
].num_indices
;
425 for (unsigned i
= 0; i
< num_indices
; i
++) {
429 fprintf(fp
, "%u", instr
->const_index
[i
]);
437 struct exec_list
*var_list
= NULL
;
439 switch (instr
->intrinsic
) {
440 case nir_intrinsic_load_uniform
:
441 case nir_intrinsic_load_uniform_indirect
:
442 var_list
= &state
->shader
->uniforms
;
444 case nir_intrinsic_load_input
:
445 case nir_intrinsic_load_input_indirect
:
446 var_list
= &state
->shader
->inputs
;
448 case nir_intrinsic_store_output
:
449 case nir_intrinsic_store_output_indirect
:
450 var_list
= &state
->shader
->outputs
;
456 foreach_list_typed(nir_variable
, var
, node
, var_list
) {
457 if ((var
->data
.driver_location
== instr
->const_index
[0]) &&
459 fprintf(fp
, "\t/* %s */", var
->name
);
466 print_tex_instr(nir_tex_instr
*instr
, print_state
*state
)
468 FILE *fp
= state
->fp
;
470 print_dest(&instr
->dest
, state
);
490 case nir_texop_txf_ms
:
491 fprintf(fp
, "txf_ms ");
502 case nir_texop_query_levels
:
503 fprintf(fp
, "query_levels ");
505 case nir_texop_texture_samples
:
506 fprintf(fp
, "texture_samples ");
510 unreachable("Invalid texture operation");
514 for (unsigned i
= 0; i
< instr
->num_srcs
; i
++) {
515 print_src(&instr
->src
[i
].src
, state
);
519 switch(instr
->src
[i
].src_type
) {
520 case nir_tex_src_coord
:
521 fprintf(fp
, "(coord)");
523 case nir_tex_src_projector
:
524 fprintf(fp
, "(projector)");
526 case nir_tex_src_comparitor
:
527 fprintf(fp
, "(comparitor)");
529 case nir_tex_src_offset
:
530 fprintf(fp
, "(offset)");
532 case nir_tex_src_bias
:
533 fprintf(fp
, "(bias)");
535 case nir_tex_src_lod
:
536 fprintf(fp
, "(lod)");
538 case nir_tex_src_ms_index
:
539 fprintf(fp
, "(ms_index)");
541 case nir_tex_src_ddx
:
542 fprintf(fp
, "(ddx)");
544 case nir_tex_src_ddy
:
545 fprintf(fp
, "(ddy)");
547 case nir_tex_src_sampler_offset
:
548 fprintf(fp
, "(sampler_offset)");
552 unreachable("Invalid texture source type");
559 bool has_nonzero_offset
= false;
560 for (unsigned i
= 0; i
< 4; i
++) {
561 if (instr
->const_offset
[i
] != 0) {
562 has_nonzero_offset
= true;
567 if (has_nonzero_offset
) {
568 fprintf(fp
, "[%i %i %i %i] (offset), ",
569 instr
->const_offset
[0], instr
->const_offset
[1],
570 instr
->const_offset
[2], instr
->const_offset
[3]);
573 if (instr
->op
== nir_texop_tg4
) {
574 fprintf(fp
, "%u (gather_component), ", instr
->component
);
577 if (instr
->sampler
) {
578 print_deref(instr
->sampler
, state
);
580 fprintf(fp
, "%u", instr
->sampler_index
);
583 fprintf(fp
, " (sampler)");
587 print_call_instr(nir_call_instr
*instr
, print_state
*state
)
589 FILE *fp
= state
->fp
;
591 fprintf(fp
, "call %s ", instr
->callee
->function
->name
);
593 for (unsigned i
= 0; i
< instr
->num_params
; i
++) {
597 print_deref(instr
->params
[i
], state
);
600 if (instr
->return_deref
!= NULL
) {
601 if (instr
->num_params
!= 0)
603 fprintf(fp
, "returning ");
604 print_deref(instr
->return_deref
, state
);
609 print_load_const_instr(nir_load_const_instr
*instr
, print_state
*state
)
611 FILE *fp
= state
->fp
;
613 print_ssa_def(&instr
->def
, state
);
615 fprintf(fp
, " = load_const (");
617 for (unsigned i
= 0; i
< instr
->def
.num_components
; i
++) {
622 * we don't really know the type of the constant (if it will be used as a
623 * float or an int), so just print the raw constant in hex for fidelity
624 * and then print the float in a comment for readability.
627 fprintf(fp
, "0x%08x /* %f */", instr
->value
.u
[i
], instr
->value
.f
[i
]);
634 print_jump_instr(nir_jump_instr
*instr
, print_state
*state
)
636 FILE *fp
= state
->fp
;
638 switch (instr
->type
) {
640 fprintf(fp
, "break");
643 case nir_jump_continue
:
644 fprintf(fp
, "continue");
647 case nir_jump_return
:
648 fprintf(fp
, "return");
654 print_ssa_undef_instr(nir_ssa_undef_instr
* instr
, print_state
*state
)
656 FILE *fp
= state
->fp
;
657 print_ssa_def(&instr
->def
, state
);
658 fprintf(fp
, " = undefined");
662 print_phi_instr(nir_phi_instr
*instr
, print_state
*state
)
664 FILE *fp
= state
->fp
;
665 print_dest(&instr
->dest
, state
);
666 fprintf(fp
, " = phi ");
667 nir_foreach_phi_src(instr
, src
) {
668 if (&src
->node
!= exec_list_get_head(&instr
->srcs
))
671 fprintf(fp
, "block_%u: ", src
->pred
->index
);
672 print_src(&src
->src
, state
);
677 print_parallel_copy_instr(nir_parallel_copy_instr
*instr
, print_state
*state
)
679 FILE *fp
= state
->fp
;
680 nir_foreach_parallel_copy_entry(instr
, entry
) {
681 if (&entry
->node
!= exec_list_get_head(&instr
->entries
))
684 print_dest(&entry
->dest
, state
);
686 print_src(&entry
->src
, state
);
691 print_instr(const nir_instr
*instr
, print_state
*state
, unsigned tabs
)
693 FILE *fp
= state
->fp
;
694 print_tabs(tabs
, fp
);
696 switch (instr
->type
) {
697 case nir_instr_type_alu
:
698 print_alu_instr(nir_instr_as_alu(instr
), state
);
701 case nir_instr_type_call
:
702 print_call_instr(nir_instr_as_call(instr
), state
);
705 case nir_instr_type_intrinsic
:
706 print_intrinsic_instr(nir_instr_as_intrinsic(instr
), state
);
709 case nir_instr_type_tex
:
710 print_tex_instr(nir_instr_as_tex(instr
), state
);
713 case nir_instr_type_load_const
:
714 print_load_const_instr(nir_instr_as_load_const(instr
), state
);
717 case nir_instr_type_jump
:
718 print_jump_instr(nir_instr_as_jump(instr
), state
);
721 case nir_instr_type_ssa_undef
:
722 print_ssa_undef_instr(nir_instr_as_ssa_undef(instr
), state
);
725 case nir_instr_type_phi
:
726 print_phi_instr(nir_instr_as_phi(instr
), state
);
729 case nir_instr_type_parallel_copy
:
730 print_parallel_copy_instr(nir_instr_as_parallel_copy(instr
), state
);
734 unreachable("Invalid instruction type");
740 compare_block_index(const void *p1
, const void *p2
)
742 const nir_block
*block1
= *((const nir_block
**) p1
);
743 const nir_block
*block2
= *((const nir_block
**) p2
);
745 return (int) block1
->index
- (int) block2
->index
;
748 static void print_cf_node(nir_cf_node
*node
, print_state
*state
,
752 print_block(nir_block
*block
, print_state
*state
, unsigned tabs
)
754 FILE *fp
= state
->fp
;
756 print_tabs(tabs
, fp
);
757 fprintf(fp
, "block block_%u:\n", block
->index
);
759 /* sort the predecessors by index so we consistently print the same thing */
762 malloc(block
->predecessors
->entries
* sizeof(nir_block
*));
764 struct set_entry
*entry
;
766 set_foreach(block
->predecessors
, entry
) {
767 preds
[i
++] = (nir_block
*) entry
->key
;
770 qsort(preds
, block
->predecessors
->entries
, sizeof(nir_block
*),
771 compare_block_index
);
773 print_tabs(tabs
, fp
);
774 fprintf(fp
, "/* preds: ");
775 for (unsigned i
= 0; i
< block
->predecessors
->entries
; i
++) {
776 fprintf(fp
, "block_%u ", preds
[i
]->index
);
782 nir_foreach_instr(block
, instr
) {
783 print_instr(instr
, state
, tabs
);
787 print_tabs(tabs
, fp
);
788 fprintf(fp
, "/* succs: ");
789 for (unsigned i
= 0; i
< 2; i
++)
790 if (block
->successors
[i
]) {
791 fprintf(fp
, "block_%u ", block
->successors
[i
]->index
);
797 print_if(nir_if
*if_stmt
, print_state
*state
, unsigned tabs
)
799 FILE *fp
= state
->fp
;
801 print_tabs(tabs
, fp
);
803 print_src(&if_stmt
->condition
, state
);
805 foreach_list_typed(nir_cf_node
, node
, node
, &if_stmt
->then_list
) {
806 print_cf_node(node
, state
, tabs
+ 1);
808 print_tabs(tabs
, fp
);
809 fprintf(fp
, "} else {\n");
810 foreach_list_typed(nir_cf_node
, node
, node
, &if_stmt
->else_list
) {
811 print_cf_node(node
, state
, tabs
+ 1);
813 print_tabs(tabs
, fp
);
818 print_loop(nir_loop
*loop
, print_state
*state
, unsigned tabs
)
820 FILE *fp
= state
->fp
;
822 print_tabs(tabs
, fp
);
823 fprintf(fp
, "loop {\n");
824 foreach_list_typed(nir_cf_node
, node
, node
, &loop
->body
) {
825 print_cf_node(node
, state
, tabs
+ 1);
827 print_tabs(tabs
, fp
);
832 print_cf_node(nir_cf_node
*node
, print_state
*state
, unsigned int tabs
)
834 switch (node
->type
) {
835 case nir_cf_node_block
:
836 print_block(nir_cf_node_as_block(node
), state
, tabs
);
840 print_if(nir_cf_node_as_if(node
), state
, tabs
);
843 case nir_cf_node_loop
:
844 print_loop(nir_cf_node_as_loop(node
), state
, tabs
);
848 unreachable("Invalid CFG node type");
853 print_function_impl(nir_function_impl
*impl
, print_state
*state
)
855 FILE *fp
= state
->fp
;
857 fprintf(fp
, "\nimpl %s ", impl
->overload
->function
->name
);
859 for (unsigned i
= 0; i
< impl
->num_params
; i
++) {
863 print_var(impl
->params
[i
], state
);
866 if (impl
->return_var
!= NULL
) {
867 if (impl
->num_params
!= 0)
869 fprintf(fp
, "returning ");
870 print_var(impl
->return_var
, state
);
875 foreach_list_typed(nir_variable
, var
, node
, &impl
->locals
) {
877 print_var_decl(var
, state
);
880 foreach_list_typed(nir_register
, reg
, node
, &impl
->registers
) {
882 print_register_decl(reg
, state
);
885 nir_index_blocks(impl
);
887 foreach_list_typed(nir_cf_node
, node
, node
, &impl
->body
) {
888 print_cf_node(node
, state
, 1);
891 fprintf(fp
, "\tblock block_%u:\n}\n\n", impl
->end_block
->index
);
895 print_function_overload(nir_function_overload
*overload
,
898 FILE *fp
= state
->fp
;
900 fprintf(fp
, "decl_overload %s ", overload
->function
->name
);
902 for (unsigned i
= 0; i
< overload
->num_params
; i
++) {
906 switch (overload
->params
[i
].param_type
) {
907 case nir_parameter_in
:
910 case nir_parameter_out
:
913 case nir_parameter_inout
:
914 fprintf(fp
, "inout ");
917 unreachable("Invalid parameter type");
920 glsl_print_type(overload
->params
[i
].type
, fp
);
923 if (overload
->return_type
!= NULL
) {
924 if (overload
->num_params
!= 0)
926 fprintf(fp
, "returning ");
927 glsl_print_type(overload
->return_type
, fp
);
932 if (overload
->impl
!= NULL
) {
933 print_function_impl(overload
->impl
, state
);
939 print_function(nir_function
*func
, print_state
*state
)
941 foreach_list_typed(nir_function_overload
, overload
, node
, &func
->overload_list
) {
942 print_function_overload(overload
, state
);
947 init_print_state(print_state
*state
, nir_shader
*shader
, FILE *fp
)
950 state
->shader
= shader
;
951 state
->ht
= _mesa_hash_table_create(NULL
, _mesa_hash_pointer
,
952 _mesa_key_pointer_equal
);
953 state
->syms
= _mesa_set_create(NULL
, _mesa_key_hash_string
,
954 _mesa_key_string_equal
);
959 destroy_print_state(print_state
*state
)
961 _mesa_hash_table_destroy(state
->ht
, NULL
);
962 _mesa_set_destroy(state
->syms
, NULL
);
966 nir_print_shader(nir_shader
*shader
, FILE *fp
)
969 init_print_state(&state
, shader
, fp
);
971 fprintf(fp
, "shader: %s\n", gl_shader_stage_name(shader
->stage
));
973 foreach_list_typed(nir_variable
, var
, node
, &shader
->uniforms
) {
974 print_var_decl(var
, &state
);
977 foreach_list_typed(nir_variable
, var
, node
, &shader
->inputs
) {
978 print_var_decl(var
, &state
);
981 foreach_list_typed(nir_variable
, var
, node
, &shader
->outputs
) {
982 print_var_decl(var
, &state
);
985 foreach_list_typed(nir_variable
, var
, node
, &shader
->globals
) {
986 print_var_decl(var
, &state
);
989 foreach_list_typed(nir_variable
, var
, node
, &shader
->system_values
) {
990 print_var_decl(var
, &state
);
993 foreach_list_typed(nir_register
, reg
, node
, &shader
->registers
) {
994 print_register_decl(reg
, &state
);
997 foreach_list_typed(nir_function
, func
, node
, &shader
->functions
) {
998 print_function(func
, &state
);
1001 destroy_print_state(&state
);
1005 nir_print_instr(const nir_instr
*instr
, FILE *fp
)
1007 print_state state
= {
1010 print_instr(instr
, &state
, 0);