nir/opt_varyings: Fix assertion when deduplicating TCS outputs.

When deduplicating TCS outputs, we may find outputs that aren't
loaded by the shader itself. This previously hit a bad assertion.

Fixes: c66967b5cb
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12410
Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34317>
This commit is contained in:
Timur Kristóf 2025-04-02 01:27:04 +02:00 committed by Marge Bot
parent a29b5857f7
commit 96d11d0f56

View file

@ -2752,15 +2752,14 @@ deduplicate_outputs(struct linkage_info *linkage,
/* We also need to set the base to match the duplicate load, so
* that CSE can eliminate it.
*/
if (!list_is_empty(dst_loads)) {
if (list_index == 0) {
/* Outputs that aren't loaded by the consumer should be already deleted. */
assert(!list_is_empty(dst_loads));
struct list_node *first =
list_first_entry(dst_loads, struct list_node, head);
nir_intrinsic_set_base(loadi, nir_intrinsic_base(first->instr));
} else {
/* Use the base of the found store if there are no loads (it can
* only happen with TCS).
*/
assert(list_index == 0);
/* The duplicate output may not have any loads, use the base of the found store. */
nir_intrinsic_set_base(loadi, nir_intrinsic_base(store));
}
}