summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>2023-02-02 19:33:07 -0500
committerMarge Bot <emma+marge@anholt.net>2023-02-04 17:26:30 +0000
commitb235be1fd4a66c1b9779abe9a9c338ce81312d2e (patch)
tree1f3af6561ad1ce695f8ecd96a9a916e0f43d130c
parent435e7f5e6d8e5ce7ad76a922a82210c50ffbfc94 (diff)
nir/print: Pretty-print I/O semantic locations
Instead of printing the raw location number, which is pretty hard to interpret, let's print the name of the location. Example output: vec4 16 ssa_2 = intrinsic load_interpolated_input (ssa_0, ssa_1) (base=0, component=0, dest_type=float16 /*144*/, io location=VARYING_SLOT_VAR0 slots=1 mediump /*8388768*/) One of the "regressions" from moving to purely lowered I/O with all variables removed is a lack of debuggability, since otherwise these location strings don't show up anywhere in the printed shader! By contrast this should make the lowered I/O nice to read like the early I/O. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Acked-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21091>
-rw-r--r--src/compiler/nir/nir_print.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 01b8932b0cf..c8981102f61 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -1053,7 +1053,33 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
case NIR_INTRINSIC_IO_SEMANTICS: {
struct nir_io_semantics io = nir_intrinsic_io_semantics(instr);
- fprintf(fp, "io location=%u slots=%u", io.location, io.num_slots);
+
+ /* Try to figure out the mode so we can interpret the location */
+ nir_variable_mode mode = nir_var_mem_generic;
+ switch (instr->intrinsic) {
+ case nir_intrinsic_load_input:
+ case nir_intrinsic_load_interpolated_input:
+ mode = nir_var_shader_in;
+ break;
+
+ case nir_intrinsic_load_output:
+ case nir_intrinsic_store_output:
+ case nir_intrinsic_store_per_primitive_output:
+ case nir_intrinsic_store_per_vertex_output:
+ mode = nir_var_shader_out;
+ break;
+
+ default:
+ break;
+ }
+
+ /* Using that mode, we should be able to name the location */
+ char buf[4];
+ const char *loc = get_location_str(io.location,
+ state->shader->info.stage, mode,
+ buf);
+
+ fprintf(fp, "io location=%s slots=%u", loc, io.num_slots);
if (io.dual_source_blend_index)
fprintf(fp, " dualsrc");