From 337b3dabc0ee1b31343e76a316f4d0443552650d Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 19 Apr 2022 16:21:02 -0700 Subject: [PATCH] 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 Part-of: --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 76c1bd9f47f..398d59b957b 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -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);