nir/linking: fix nir_assign_io_var_locations for scalarized dual blend

this would previously assign all scalar variables to the highest
driver location

cc: mesa-stable

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28753>
This commit is contained in:
Mike Blumenkrantz 2024-04-15 13:47:02 -04:00 committed by Marge Bot
parent e28061c502
commit ffe54ca293
2 changed files with 6 additions and 9 deletions

View File

@ -1455,7 +1455,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
unsigned *size, gl_shader_stage stage)
{
unsigned location = 0;
unsigned assigned_locations[VARYING_SLOT_TESS_MAX];
unsigned assigned_locations[VARYING_SLOT_TESS_MAX][2];
uint64_t processed_locs[2] = { 0 };
struct exec_list io_vars;
@ -1547,7 +1547,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
if (processed) {
/* TODO handle overlapping per-view variables */
assert(!var->data.per_view);
unsigned driver_location = assigned_locations[var->data.location];
unsigned driver_location = assigned_locations[var->data.location][var->data.index];
var->data.driver_location = driver_location;
/* An array may be packed such that is crosses multiple other arrays
@ -1568,7 +1568,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
unsigned num_unallocated_slots = last_slot_location - location;
unsigned first_unallocated_slot = var_size - num_unallocated_slots;
for (unsigned i = first_unallocated_slot; i < var_size; i++) {
assigned_locations[var->data.location + i] = location;
assigned_locations[var->data.location + i][var->data.index] = location;
location++;
}
}
@ -1576,7 +1576,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
}
for (unsigned i = 0; i < var_size; i++) {
assigned_locations[var->data.location + i] = location + i;
assigned_locations[var->data.location + i][var->data.index] = location + i;
}
var->data.driver_location = location;

View File

@ -228,11 +228,8 @@ lower_aaline_instr(nir_builder *b, nir_instr *instr, void *data)
nir_fmin(b, nir_channel(b, tmp, 1), max));
tmp = nir_fmul(b, nir_channel(b, out_input, out_input->num_components - 1), tmp);
nir_def *components[4];
for (unsigned i = 0; i < out_input->num_components - 1; i++)
components[i] = nir_channel(b, out_input, i);
components[out_input->num_components - 1] = tmp;
nir_def *out = nir_vec(b, components, out_input->num_components);
nir_def *out = nir_vector_insert_imm(b, out_input, tmp,
out_input->num_components - 1);
nir_src_rewrite(&intrin->src[1], out);
return true;
}