From b5cfa8c9944e2ff1650b0e708d4b7c4cefc21ec1 Mon Sep 17 00:00:00 2001 From: bmjask <11672696+bmjask@users.noreply.github.com> Date: Tue, 24 Nov 2026 16:54:52 -0500 Subject: [PATCH] dxil: load an in-range MSAA sample before zeroing past-the-count ones image_msaa_load / image_load on MSAA resources issued Texture2DMS.Load with sample indices at or past the resource's count and only zeroed the result afterwards. An out-of-range ld2dms index is undefined, and RDNA4 faults on it (gpu_direct_msaa_image_loads, STATUS_ACCESS_VIOLATION on RX 9070 / 9070 XT). The load now takes sample 0 for those lanes; the result mask is unchanged. Patch as suggested by imnicho in review. TRANSLATOR_VERSION 7 -> 8. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/gpu/dxil/kernel.rs | 2 +- crates/xcl/src/gpu/dxil/lower_image.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/xcl/src/gpu/dxil/kernel.rs b/crates/xcl/src/gpu/dxil/kernel.rs index d28a2ffcb..fb9d78e1a 100644 --- a/crates/xcl/src/gpu/dxil/kernel.rs +++ b/crates/xcl/src/gpu/dxil/kernel.rs @@ -37,7 +37,7 @@ pub struct KernelOptions { /// Version of the direct translator's output, part of the on-disk translation cache's /// identity (`recomp::pso`): bump it on any change that alters the emitted containers /// (the `gpu/dxil` sources are not in build.rs's translator source hash). -pub const TRANSLATOR_VERSION: u32 = 7; +pub const TRANSLATOR_VERSION: u32 = 8; /// `XCL_DIRECT_DXIL=1`: console compute shaders (and the kernel tests) go through this /// translator, with the HLSL path as the fallback for what it cannot translate yet. diff --git a/crates/xcl/src/gpu/dxil/lower_image.rs b/crates/xcl/src/gpu/dxil/lower_image.rs index 90ee245bf..041782c52 100644 --- a/crates/xcl/src/gpu/dxil/lower_image.rs +++ b/crates/xcl/src/gpu/dxil/lower_image.rs @@ -857,8 +857,13 @@ impl Lw { let dims = lw.s.get_dimensions(tex.handle, None); let count = lw.s.m.extract(dims, 3); for (si, &sv) in samples.iter().enumerate() { - let r = lw.s.texture_load_sample(tex, sv, &coords); + // load only a sample the resource has (sample 0 in place of one at or + // past its count: an out-of-range `ld2dms` index is undefined and faults + // on RDNA4); the result is still zeroed below let inside = lw.cmp(Pred::ULt, sv, count); + let first = lw.c(0); + let loaded = lw.sel(inside, sv, first); + let r = lw.s.texture_load_sample(tex, loaded, &coords); for k in 0..4 { let b = lw.bits(r[k]); let zz = lw.c(0);