mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
intel/fs: bound subgroup invocation read to dispatch size
This is to avoid out of bound register accesses (potentially leading to hangs) when the dispatch size is smaller than when is reported in the NIR subgroup_size. v2: Implement bounding with a mask (since workgroup sizes are powers of 2) (Faith) Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Fixes:530de844ef("intel,anv,iris,crocus: Drop subgroup size from the shader key") Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21282> (cherry picked from commit9ac192d79d)
This commit is contained in:
parent
14c0675135
commit
25e614486e
2 changed files with 14 additions and 2 deletions
|
|
@ -670,7 +670,7 @@
|
|||
"description": "intel/fs: bound subgroup invocation read to dispatch size",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "530de844ef4d6f8d64276ad4558dd8a3d787e390"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5428,10 +5428,22 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
|
|||
case nir_intrinsic_read_invocation: {
|
||||
const fs_reg value = get_nir_src(instr->src[0]);
|
||||
const fs_reg invocation = get_nir_src(instr->src[1]);
|
||||
|
||||
fs_reg tmp = bld.vgrf(value.type);
|
||||
|
||||
/* When for some reason the subgroup_size picked by NIR is larger than
|
||||
* the dispatch size picked by the backend (this could happen in RT,
|
||||
* FS), bound the invocation to the dispatch size.
|
||||
*/
|
||||
fs_reg bound_invocation;
|
||||
if (bld.dispatch_width() < bld.shader->nir->info.subgroup_size) {
|
||||
bound_invocation = bld.vgrf(BRW_REGISTER_TYPE_UD);
|
||||
bld.AND(bound_invocation, invocation, brw_imm_ud(dispatch_width - 1));
|
||||
} else {
|
||||
bound_invocation = invocation;
|
||||
}
|
||||
bld.exec_all().emit(SHADER_OPCODE_BROADCAST, tmp, value,
|
||||
bld.emit_uniformize(invocation));
|
||||
bld.emit_uniformize(bound_invocation));
|
||||
|
||||
bld.MOV(retype(dest, value.type), fs_reg(component(tmp, 0)));
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue