gallium/tgsi: add helper tgsi_get_interp_mode
[mesa.git] / src / mesa / state_tracker / st_mesa_to_tgsi.c
index 03a2dee677813569dfc5a9d1ab0f84bb3fec62f7..dca9acb3f31d55745289e3371dc6b07168a87d7e 100644 (file)
@@ -37,6 +37,7 @@
 #include "pipe/p_shader_tokens.h"
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_ureg.h"
+#include "tgsi/tgsi_from_mesa.h"
 #include "st_mesa_to_tgsi.h"
 #include "st_context.h"
 #include "program/prog_instruction.h"
@@ -96,9 +97,12 @@ dst_register(struct st_translate *t, gl_register_file file, GLuint index)
       else
          assert(index < VARYING_SLOT_MAX);
 
-      assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
-
-      return t->outputs[t->outputMapping[index]];
+      if (t->outputMapping[index] < ARRAY_SIZE(t->outputs))
+         return t->outputs[t->outputMapping[index]];
+      else {
+         assert(t->procType == PIPE_SHADER_VERTEX);
+         return ureg_dst(ureg_DECL_constant(t->ureg, 0));
+      }
 
    case PROGRAM_ADDRESS:
       return t->address[index];
@@ -140,12 +144,20 @@ src_register(struct st_translate *t,
          return t->constants[index];
 
    case PROGRAM_INPUT:
-      assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs));
-      return t->inputs[t->inputMapping[index]];
+      if (t->inputMapping[index] < ARRAY_SIZE(t->inputs))
+         return t->inputs[t->inputMapping[index]];
+      else {
+         assert(t->procType == PIPE_SHADER_VERTEX);
+         return ureg_DECL_constant(t->ureg, 0);
+      }
 
    case PROGRAM_OUTPUT:
-      assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
-      return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */
+      if (t->outputMapping[index] < ARRAY_SIZE(t->outputs))
+         return ureg_src(t->outputs[t->outputMapping[index]]);
+      else {
+         assert(t->procType == PIPE_SHADER_VERTEX);
+         return ureg_DECL_constant(t->ureg, 0);
+      }
 
    case PROGRAM_ADDRESS:
       return ureg_src(t->address[index]);
@@ -954,7 +966,7 @@ st_translate_mesa_program(struct gl_context *ctx,
    GLbitfield64 sysInputs = program->info.system_values_read;
    for (i = 0; sysInputs; i++) {
       if (sysInputs & (1ull << i)) {
-         unsigned semName = _mesa_sysval_to_semantic(i);
+         unsigned semName = tgsi_get_sysval_semantic(i);
 
          t->systemValues[i] = ureg_DECL_system_value(ureg, semName, 0);