From 7f597084224dcb138eeff3567b05c36c4fed3305 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Fri, 17 Jan 2025 13:08:46 -0800 Subject: [PATCH] intel/brw: Saturate shifted subgroup index to avoid reading past the end of register file. Reviewed-by: Caio Oliveira Part-of: --- src/intel/compiler/brw_lower_subgroup_ops.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw_lower_subgroup_ops.cpp b/src/intel/compiler/brw_lower_subgroup_ops.cpp index 6ecf328b624..e915347b74f 100644 --- a/src/intel/compiler/brw_lower_subgroup_ops.cpp +++ b/src/intel/compiler/brw_lower_subgroup_ops.cpp @@ -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;