mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
nir: avoid generating conflicting output variables
Because not all vertex outputs can have corresponding fragment inputs (eg. edgeflags) some logic is needed to correctly generate variables in a passthough gs. Before this change some output variables ened up with the same location. Fixes:d0342e28b3("nir: Add helper to create passthrough GS shader") Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21238> (cherry picked from commitedecb66b01)
This commit is contained in:
parent
a0224f1b3a
commit
b96362381b
2 changed files with 18 additions and 6 deletions
|
|
@ -2731,7 +2731,7 @@
|
|||
"description": "nir: avoid generating conflicting output variables",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "d0342e28b32d7aa4b25cf045ac9933348ec053a9"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
|
|||
|
||||
nir_variable *in_vars[VARYING_SLOT_MAX];
|
||||
nir_variable *out_vars[VARYING_SLOT_MAX];
|
||||
unsigned num_vars = 0;
|
||||
unsigned num_inputs = 0, num_outputs = 0;
|
||||
|
||||
/* Create input/output variables. */
|
||||
nir_foreach_shader_out_variable(var, prev_stage) {
|
||||
|
|
@ -72,6 +72,15 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
|
|||
in->data.interpolation = var->data.interpolation;
|
||||
in->data.compact = var->data.compact;
|
||||
|
||||
in_vars[num_inputs++] = in;
|
||||
|
||||
nir->num_inputs++;
|
||||
if (in->data.location == VARYING_SLOT_EDGE)
|
||||
continue;
|
||||
|
||||
if (var->data.location != VARYING_SLOT_POS)
|
||||
nir->num_outputs++;
|
||||
|
||||
if (var->name)
|
||||
snprintf(name, sizeof(name), "out_%s", var->name);
|
||||
else
|
||||
|
|
@ -85,8 +94,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
|
|||
out->data.interpolation = var->data.interpolation;
|
||||
out->data.compact = var->data.compact;
|
||||
|
||||
in_vars[num_vars] = in;
|
||||
out_vars[num_vars++] = out;
|
||||
out_vars[num_outputs++] = out;
|
||||
}
|
||||
|
||||
unsigned int start_vert = 0;
|
||||
|
|
@ -109,11 +117,15 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
|
|||
|
||||
for (unsigned i = start_vert; i < end_vert; i += vert_step) {
|
||||
/* Copy inputs to outputs. */
|
||||
for (unsigned j = 0; j < num_vars; ++j) {
|
||||
for (unsigned j = 0, oj = 0; j < num_inputs; ++j) {
|
||||
if (in_vars[j]->data.location == VARYING_SLOT_EDGE) {
|
||||
continue;
|
||||
}
|
||||
/* no need to use copy_var to save a lower pass */
|
||||
nir_ssa_def *value = nir_load_array_var_imm(&b, in_vars[j], i);
|
||||
nir_store_var(&b, out_vars[j], value,
|
||||
nir_store_var(&b, out_vars[oj], value,
|
||||
(1u << value->num_components) - 1);
|
||||
++oj;
|
||||
}
|
||||
nir_emit_vertex(&b, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue