[Mesa-dev] [PATCH 2/2] nir/print: print variable names

Rob Clark robdclark at gmail.com
Thu Sep 17 15:20:19 PDT 2015


From: Rob Clark <robclark at freedesktop.org>

Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
 src/glsl/nir/nir_print.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index ca8059f..6e86140 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -430,6 +430,36 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
    }
 
    fprintf(fp, ")");
+
+   if (!state->shader)
+      return;
+
+   struct exec_list *var_list = NULL;
+
+   switch (instr->intrinsic) {
+   case nir_intrinsic_load_uniform:
+   case nir_intrinsic_load_uniform_indirect:
+      var_list = &state->shader->uniforms;
+      break;
+   case nir_intrinsic_load_input:
+   case nir_intrinsic_load_input_indirect:
+      var_list = &state->shader->inputs;
+      break;
+   case nir_intrinsic_store_output:
+   case nir_intrinsic_store_output_indirect:
+      var_list = &state->shader->outputs;
+      break;
+   default:
+      return;
+   }
+
+   foreach_list_typed(nir_variable, var, node, var_list) {
+      if ((var->data.driver_location == instr->const_index[0]) &&
+          var->name) {
+         fprintf(fp, "\t/* %s */", var->name);
+         break;
+      }
+   }
 }
 
 static void
-- 
2.4.3



More information about the mesa-dev mailing list