st/glsl_to_nir: fix edgeflag passthrough
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sun, 25 Jun 2017 16:13:39 +0000 (18:13 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 5 Jul 2017 10:27:12 +0000 (12:27 +0200)
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.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_program.c

index 524eefa236c655ae962663fed5862c84a0845271..89f78884389ff25bb2314e6782a88d7e877175b1 100644 (file)
@@ -92,6 +92,9 @@ st_nir_assign_vs_in_locations(struct gl_program *prog, nir_shader *nir)
       }
    }
 
+   /* 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;
index eb44fc57b57b618de0ad5a9ca5d7046dcaa07af4..6b6d41536cf1b65b61d7a1f74652ecca415803ee 100644 (file)
@@ -557,8 +557,10 @@ st_create_vp_variant(struct st_context *st,
       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);