tgsi: Extend array lengths when merging usage_masks.

With nir-to-tgsi, virgl saw a case where a previous declaration of array
.x and scalar .y (turning into an array with .xy) ended up being a
declaration of scalar .x and array .y (turning into a scalar with .xy).
Make sure we extend the declared array length as well.

One might think that the fix would be to union the .first/.last between
the two declarations being merged, but note that ureg_DECL_output() passes
in the current nr_output_regs as the index, so the .last would end up
getting extended for those callers (such as nir_to_tgsi fs outputs) every
time you merged.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13295>
This commit is contained in:
Emma Anholt 2022-04-19 16:21:02 -07:00 committed by Marge Bot
parent 4205039a9f
commit 337b3dabc0
1 changed files with 4 additions and 0 deletions

View File

@ -308,6 +308,8 @@ ureg_DECL_fs_input_centroid_layout(struct ureg_program *ureg,
assert(ureg->input[i].interp_location == interp_location);
if (ureg->input[i].array_id == array_id) {
ureg->input[i].usage_mask |= usage_mask;
ureg->input[i].last = MAX2(ureg->input[i].last, ureg->input[i].first + array_size - 1);
ureg->nr_input_regs = MAX2(ureg->nr_input_regs, ureg->input[i].last + 1);
goto out;
}
assert((ureg->input[i].usage_mask & usage_mask) == 0);
@ -445,6 +447,8 @@ ureg_DECL_output_layout(struct ureg_program *ureg,
ureg->output[i].semantic_index == semantic_index) {
if (ureg->output[i].array_id == array_id) {
ureg->output[i].usage_mask |= usage_mask;
ureg->output[i].last = MAX2(ureg->output[i].last, ureg->output[i].first + array_size - 1);
ureg->nr_output_regs = MAX2(ureg->nr_output_regs, ureg->output[i].last + 1);
goto out;
}
assert((ureg->output[i].usage_mask & usage_mask) == 0);