summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-10-18 13:02:15 -0400
committerMarek Olšák <[email protected]>2019-10-23 21:12:52 -0400
commit28199aeee5254d195b63a71c290a365da4496f75 (patch)
tree240055f5e25aa5c80218a6a4d967c692c5b62d27 /src
parenteaffdad10820661172aa8808cc20c00bc928809e (diff)
st/mesa: assign driver locations for VS inputs for NIR before caching
fix up edge flags in the NIR pass, because st/mesa doesn't touch the inputs after caching Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_lower_passthrough_edgeflags.c5
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp15
-rw-r--r--src/mesa/state_tracker/st_nir.h1
-rw-r--r--src/mesa/state_tracker/st_nir_builtins.c1
-rw-r--r--src/mesa/state_tracker/st_program.c2
5 files changed, 15 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_lower_passthrough_edgeflags.c b/src/compiler/nir/nir_lower_passthrough_edgeflags.c
index f34078c8999..0afcaa0b125 100644
--- a/src/compiler/nir/nir_lower_passthrough_edgeflags.c
+++ b/src/compiler/nir/nir_lower_passthrough_edgeflags.c
@@ -39,6 +39,11 @@ lower_impl(nir_function_impl *impl)
glsl_vec4_type(), "edgeflag_in");
in->data.location = VERT_ATTRIB_EDGEFLAG;
+ /* The edge flag is the last input in st/mesa. */
+ assert(shader->num_inputs == util_bitcount64(shader->info.inputs_read));
+ in->data.driver_location = shader->num_inputs++;
+ shader->info.inputs_read |= BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG);
+
out = nir_variable_create(shader, nir_var_shader_out,
glsl_vec4_type(), "edgeflag_out");
out->data.location = VARYING_SLOT_EDGE;
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 6ec14076b58..67d93d61f1c 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -83,9 +83,12 @@ st_nir_fixup_varying_slots(struct st_context *st, struct exec_list *var_list)
* (This isn't the case with, for ex, FS inputs, which only need to agree
* on varying-slot w/ the VS outputs)
*/
-static void
-st_nir_assign_vs_in_locations(nir_shader *nir)
+void
+st_nir_assign_vs_in_locations(struct nir_shader *nir)
{
+ if (nir->info.stage != MESA_SHADER_VERTEX)
+ return;
+
bool removed_inputs = false;
nir->num_inputs = util_bitcount64(nir->info.inputs_read);
@@ -93,10 +96,7 @@ st_nir_assign_vs_in_locations(nir_shader *nir)
/* NIR already assigns dual-slot inputs to two locations so all we have
* to do is compact everything down.
*/
- if (var->data.location == VERT_ATTRIB_EDGEFLAG) {
- /* bit of a hack, mirroring st_translate_vertex_program */
- var->data.driver_location = nir->num_inputs++;
- } else if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
+ if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
var->data.driver_location =
util_bitcount64(nir->info.inputs_read &
BITFIELD64_MASK(var->data.location));
@@ -851,9 +851,6 @@ void
st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir)
{
if (nir->info.stage == MESA_SHADER_VERTEX) {
- /* Needs special handling so drvloc matches the vbo state: */
- st_nir_assign_vs_in_locations(nir);
-
nir_assign_io_var_locations(&nir->outputs,
&nir->num_outputs,
nir->info.stage);
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index a46422413d9..21358419aa9 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -51,6 +51,7 @@ bool
st_link_nir(struct gl_context *ctx,
struct gl_shader_program *shader_program);
+void st_nir_assign_vs_in_locations(struct nir_shader *nir);
void st_nir_assign_varying_locations(struct st_context *st,
struct nir_shader *nir);
diff --git a/src/mesa/state_tracker/st_nir_builtins.c b/src/mesa/state_tracker/st_nir_builtins.c
index 7e52e5a8f11..b09d470bf3a 100644
--- a/src/mesa/state_tracker/st_nir_builtins.c
+++ b/src/mesa/state_tracker/st_nir_builtins.c
@@ -56,6 +56,7 @@ st_nir_finish_builtin_shader(struct st_context *st,
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
+ st_nir_assign_vs_in_locations(nir);
st_nir_assign_varying_locations(st, nir);
st_nir_lower_samplers(screen, nir, NULL, NULL);
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index e60a9924f81..21252492fc5 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -400,6 +400,8 @@ st_finalize_nir_before_variants(struct nir_shader *nir)
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true);
}
+
+ st_nir_assign_vs_in_locations(nir);
}
/**