nir/print: print variable names
authorRob Clark <robclark@freedesktop.org>
Thu, 17 Sep 2015 22:18:45 +0000 (18:18 -0400)
committerRob Clark <robclark@freedesktop.org>
Fri, 18 Sep 2015 00:26:12 +0000 (20:26 -0400)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
src/glsl/nir/nir_print.c

index ca8059fc92035099e4c48dd9dc0f9c0bee1bbc4d..6e86140ed9d6c7622da286797f8bae1d63f330b0 100644 (file)
@@ -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