[Mesa-dev] [PATCH] [rfc] st/nir: handle components on fs outputs.
Dave Airlie
airlied at gmail.com
Thu Mar 1 00:52:14 UTC 2018
From: Dave Airlie <airlied at redhat.com>
fs outputs don't start above VARYING_SLOT_VAR0, but I assume
that is there for a reason, so make an exception for fragment
outputs.
This fixes with NIR:
tests/spec/arb_enhanced_layouts/execution/component-layout/fs-output.shader_test
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/state_tracker/st_glsl_to_nir.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 765c827d93..4e7d54e11d 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -123,13 +123,13 @@ st_nir_assign_vs_in_locations(struct gl_program *prog, nir_shader *nir)
static void
st_nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
- gl_shader_stage stage)
+ gl_shader_stage stage, bool outputs)
{
unsigned location = 0;
unsigned assigned_locations[VARYING_SLOT_TESS_MAX];
uint64_t processed_locs = 0;
uint32_t processed_patch_locs = 0;
-
+ bool is_fs_output = outputs && (stage == MESA_SHADER_FRAGMENT);
nir_foreach_variable(var, var_list) {
const struct glsl_type *type = var->type;
@@ -159,7 +159,7 @@ st_nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
/* Because component packing allows varyings to share the same location
* we may have already have processed this location.
*/
- if (processed && var->data.location >= VARYING_SLOT_VAR0) {
+ if (processed && (var->data.location >= VARYING_SLOT_VAR0 || is_fs_output)) {
var->data.driver_location = assigned_locations[var->data.location];
*size += type_size(type);
continue;
@@ -687,7 +687,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
sort_varyings(&nir->outputs);
st_nir_assign_var_locations(&nir->outputs,
&nir->num_outputs,
- nir->info.stage);
+ nir->info.stage, true);
st_nir_fixup_varying_slots(st, &nir->outputs);
} else if (nir->info.stage == MESA_SHADER_GEOMETRY ||
nir->info.stage == MESA_SHADER_TESS_CTRL ||
@@ -695,23 +695,23 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
sort_varyings(&nir->inputs);
st_nir_assign_var_locations(&nir->inputs,
&nir->num_inputs,
- nir->info.stage);
+ nir->info.stage, false);
st_nir_fixup_varying_slots(st, &nir->inputs);
sort_varyings(&nir->outputs);
st_nir_assign_var_locations(&nir->outputs,
&nir->num_outputs,
- nir->info.stage);
+ nir->info.stage, true);
st_nir_fixup_varying_slots(st, &nir->outputs);
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
sort_varyings(&nir->inputs);
st_nir_assign_var_locations(&nir->inputs,
&nir->num_inputs,
- nir->info.stage);
+ nir->info.stage, false);
st_nir_fixup_varying_slots(st, &nir->inputs);
st_nir_assign_var_locations(&nir->outputs,
&nir->num_outputs,
- nir->info.stage);
+ nir->info.stage, true);
} else if (nir->info.stage == MESA_SHADER_COMPUTE) {
/* TODO? */
} else {
--
2.14.3
More information about the mesa-dev
mailing list