Mesa (main): nir/print: simplify printing of IO semantics

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 16 10:33:46 UTC 2021


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

Author: Marcin Ślusarz <marcin.slusarz at intel.com>
Date:   Mon Oct 18 15:29:23 2021 +0200

nir/print: simplify printing of IO semantics

Some of the tested flags are set for other intrinsics and they are
printed only when set, so there's no point in checking exact intrinsic
name or shader stage.

Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14222>

---

 src/compiler/nir/nir_print.c | 47 +++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 4ad933efe30..467230ca9a6 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -964,28 +964,29 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
          break;
       }
 
-      case NIR_INTRINSIC_IO_SEMANTICS:
-         fprintf(fp, " location=%u slots=%u",
-                 nir_intrinsic_io_semantics(instr).location,
-                 nir_intrinsic_io_semantics(instr).num_slots);
+      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);
+
+         if (io.dual_source_blend_index)
+            fprintf(fp, " dualsrc");
+
+         if (io.fb_fetch_output)
+            fprintf(fp, " fbfetch");
+
+         if (io.per_view)
+            fprintf(fp, " perview");
+
+         if (io.medium_precision)
+            fprintf(fp, " mediump");
+
+         if (io.high_16bits)
+            fprintf(fp, " high_16bits");
+
          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 (instr->intrinsic == nir_intrinsic_store_output &&
-                nir_intrinsic_io_semantics(instr).per_view) {
-               fprintf(fp, " perview=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;
+               unsigned gs_streams = io.gs_streams;
                fprintf(fp, " gs_streams(");
                for (unsigned i = 0; i < 4; i++) {
                   fprintf(fp, "%s%c=%u", i ? " " : "", "xyzw"[i],
@@ -993,14 +994,10 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
                }
                fprintf(fp, ")");
             }
-            if (nir_intrinsic_io_semantics(instr).medium_precision) {
-               fprintf(fp, " mediump");
-            }
-            if (nir_intrinsic_io_semantics(instr).high_16bits) {
-               fprintf(fp, " high_16bits");
-            }
          }
+
          break;
+      }
 
       case NIR_INTRINSIC_ROUNDING_MODE: {
          fprintf(fp, " rounding_mode=");



More information about the mesa-commit mailing list