nir/opt_vectorize_io: Fix allow_holes option

Only allow holes between the first and last used component.
Do not load unused components before the first used component.

This fixes test failures with a bunch of VK CTS tests
with allow_holes enabled on RADV:
dEQP-VK.tessellation.tess_io.max_in_out.with_f16.*

Fixes: 6286c1c66f
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
(cherry picked from commit 1981b9836b)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39462>
This commit is contained in:
Timur Kristóf 2025-12-21 17:04:03 -06:00 committed by Dylan Baker
parent dfb6ec7f93
commit e82b446a32
2 changed files with 7 additions and 5 deletions

View file

@ -1604,7 +1604,7 @@
"description": "nir/opt_vectorize_io: Fix allow_holes option",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "6286c1c66fb0ed21e1dfd0aaf0db9e1a8360e82b",
"notes": null

View file

@ -414,16 +414,18 @@ vectorize_slot(nir_intrinsic_instr *chan[8], unsigned mask, bool allow_holes)
scan_mask = mask & BITFIELD_RANGE(4, 4);
mask &= ~scan_mask;
if (is_load && allow_holes) {
if (is_load && allow_holes && scan_mask) {
unsigned num = util_last_bit(scan_mask);
scan_mask = BITFIELD_RANGE(4, num - 4);
unsigned start = ffs(scan_mask) - 1;
scan_mask = BITFIELD_RANGE(start, num - start);
}
} else {
scan_mask = mask;
if (is_load && allow_holes) {
if (is_load && allow_holes && scan_mask) {
unsigned num = util_last_bit(scan_mask);
scan_mask = BITFIELD_MASK(num);
unsigned start = ffs(scan_mask) - 1;
scan_mask = BITFIELD_RANGE(start, num - start);
}
}