Mesa (master): nir: Fix printing of individual instructions with io semantics.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 31 17:35:26 UTC 2020


Module: Mesa
Branch: master
Commit: a3a8322dcd7aaede8dedff131c7d73bdbe3f06f9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3a8322dcd7aaede8dedff131c7d73bdbe3f06f9

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Aug 27 11:33:31 2020 -0700

nir: Fix printing of individual instructions with io semantics.

The state->shader is missing when used outside of nir_print_shader, just
drop these details in that case.  We can fix nir_print_instr() to look up
the shader, but let's also make sure that an instr detached from a shader
(such as one you're constructing but haven't yet inserted) still works.

Fixes: 2b1ef5df4eac ("nir: print IO semantics (v2)")
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6496>

---

 src/compiler/nir/nir_print.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index ed7cccfc2ca..6e871b6c950 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -929,25 +929,27 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
          fprintf(fp, " location=%u slots=%u",
                  nir_intrinsic_io_semantics(instr).location,
                  nir_intrinsic_io_semantics(instr).num_slots);
-         if (state->shader->info.stage == MESA_SHADER_FRAGMENT &&
-             instr->intrinsic == nir_intrinsic_store_output &&
-             nir_intrinsic_io_semantics(instr).dual_source_blend_index) {
-            fprintf(fp, " dualsrc=1");
-         }
-         if (state->shader->info.stage == MESA_SHADER_FRAGMENT &&
-             instr->intrinsic == nir_intrinsic_load_output &&
-             nir_intrinsic_io_semantics(instr).fb_fetch_output) {
-            fprintf(fp, " fbfetch=1");
-         }
-         if (state->shader->info.stage == MESA_SHADER_GEOMETRY &&
-             instr->intrinsic == nir_intrinsic_store_output) {
-            unsigned gs_streams = nir_intrinsic_io_semantics(instr).gs_streams;
-            fprintf(fp, " gs_streams(");
-            for (unsigned i = 0; i < 4; i++) {
-               fprintf(fp, "%s%c=%u", i ? " " : "", "xyzw"[i],
-                       (gs_streams >> (i * 2)) & 0x3);
+         if (state->shader) {
+            if (state->shader->info.stage == MESA_SHADER_FRAGMENT &&
+                instr->intrinsic == nir_intrinsic_store_output &&
+                nir_intrinsic_io_semantics(instr).dual_source_blend_index) {
+               fprintf(fp, " dualsrc=1");
+            }
+            if (state->shader->info.stage == MESA_SHADER_FRAGMENT &&
+                instr->intrinsic == nir_intrinsic_load_output &&
+                nir_intrinsic_io_semantics(instr).fb_fetch_output) {
+               fprintf(fp, " fbfetch=1");
+            }
+            if (state->shader->info.stage == MESA_SHADER_GEOMETRY &&
+                instr->intrinsic == nir_intrinsic_store_output) {
+               unsigned gs_streams = nir_intrinsic_io_semantics(instr).gs_streams;
+               fprintf(fp, " gs_streams(");
+               for (unsigned i = 0; i < 4; i++) {
+                  fprintf(fp, "%s%c=%u", i ? " " : "", "xyzw"[i],
+                          (gs_streams >> (i * 2)) & 0x3);
+               }
+               fprintf(fp, ")");
             }
-            fprintf(fp, ")");
          }
          break;
 



More information about the mesa-commit mailing list