intel/brw: Saturate shifted subgroup index to avoid reading past the end of register file.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32664>
This commit is contained in:
Francisco Jerez 2025-01-17 13:08:46 -08:00 committed by Marge Bot
parent db2a10150f
commit 7f59708422

View file

@ -329,9 +329,15 @@ brw_lower_scan(fs_visitor &s, bblock_t *block, fs_inst *inst)
* we can't do this with a normal stride; we have to use indirects.
*/
brw_reg shifted = bld.vgrf(src.type);
brw_reg idx = bld.vgrf(BRW_TYPE_W);
brw_reg idx = bld.vgrf(BRW_TYPE_UW);
ubld.ADD(idx, bld.LOAD_SUBGROUP_INVOCATION(), brw_imm_w(-1));
/* Set the saturate modifier in the offset index to ensure it's
* normalized within the expected range without negative values,
* since the situation can cause us to read past the end of the
* register file leading to hangs on Xe3.
*/
set_saturate(true, ubld.ADD(idx, bld.LOAD_SUBGROUP_INVOCATION(),
brw_imm_w(-1)));
ubld.emit(SHADER_OPCODE_SHUFFLE, shifted, scan, idx);
ubld.group(1, 0).MOV(horiz_offset(shifted, 0), info.identity);
scan = shifted;