nir: print IO semantics (v2)
authorMarek Olšák <marek.olsak@amd.com>
Fri, 14 Aug 2020 23:34:27 +0000 (19:34 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Aug 2020 19:07:18 +0000 (19:07 +0000)
v2: print GS streams readably

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6442>

src/compiler/nir/nir_print.c

index 9daaba7738575fb81638f9a47d4364f8b30e4525..ed7cccfc2cad9eb82ac5759dfb2264bfd994b99c 100644 (file)
@@ -808,7 +808,9 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
       [NIR_INTRINSIC_MEMORY_MODES] = "mem_modes",
       [NIR_INTRINSIC_MEMORY_SCOPE] = "mem_scope",
       [NIR_INTRINSIC_EXECUTION_SCOPE] = "exec_scope",
+      [NIR_INTRINSIC_IO_SEMANTICS] = "io_semantics",
    };
+
    for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
       if (!info->index_map[idx])
          continue;
@@ -923,6 +925,32 @@ 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);
+         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, ")");
+         }
+         break;
+
       default: {
          unsigned off = info->index_map[idx] - 1;
          assert(index_name[idx]);  /* forgot to update index_name table? */