[Mesa-dev] [PATCH 20/92] st/glsl_to_nir: fix edgeflag passthrough

Nicolai Hähnle nhaehnle at gmail.com
Mon Jun 26 14:09:59 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

We have to mark the additional shader input as used, otherwise it will
be eliminated, and we have to setup its index correctly.

This is a bit of a hack, but so is everything surrounding edgeflag
passthrough.
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 3 +++
 src/mesa/state_tracker/st_program.c       | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 0a86373..5c4ae81 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -85,20 +85,23 @@ st_nir_assign_vs_in_locations(struct gl_program *prog, nir_shader *nir)
          num_inputs++;
          if ((prog->info.double_inputs_read & BITFIELD64_BIT(attr)) != 0) {
             /* add placeholder for second part of a double attribute */
             num_inputs++;
          }
       } else {
          input_to_index[attr] = ~0;
       }
    }
 
+   /* bit of a hack, mirroring st_translate_vertex_program */
+   input_to_index[VERT_ATTRIB_EDGEFLAG] = num_inputs;
+
    nir->num_inputs = 0;
    nir_foreach_variable_safe(var, &nir->inputs) {
       attr = var->data.location;
       assert(attr < ARRAY_SIZE(input_to_index));
 
       if (input_to_index[attr] != ~0u) {
          var->data.driver_location = input_to_index[attr];
          nir->num_inputs++;
       } else {
          /* Move unused input variables to the globals list (with no
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index a3b8bbf..7faee62 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -550,22 +550,24 @@ st_create_vp_variant(struct st_context *st,
 
    vpv->key = *key;
    vpv->tgsi.stream_output = stvp->tgsi.stream_output;
    vpv->num_inputs = stvp->num_inputs;
 
    if (stvp->tgsi.type == PIPE_SHADER_IR_NIR) {
       vpv->tgsi.type = PIPE_SHADER_IR_NIR;
       vpv->tgsi.ir.nir = nir_shader_clone(NULL, stvp->tgsi.ir.nir);
       if (key->clamp_color)
          NIR_PASS_V(vpv->tgsi.ir.nir, nir_lower_clamp_color_outputs);
-      if (key->passthrough_edgeflags)
+      if (key->passthrough_edgeflags) {
          NIR_PASS_V(vpv->tgsi.ir.nir, nir_lower_passthrough_edgeflags);
+         vpv->num_inputs++;
+      }
 
       st_finalize_nir(st, &stvp->Base, vpv->tgsi.ir.nir);
 
       vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
       /* driver takes ownership of IR: */
       vpv->tgsi.ir.nir = NULL;
       return vpv;
    }
 
    vpv->tgsi.tokens = tgsi_dup_tokens(stvp->tgsi.tokens);
-- 
2.9.3



More information about the mesa-dev mailing list