Direct DXIL: MSAA loads clamp out-of-range sample indices before loading #1908
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1908
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1908"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@bmjask on GitHub · 2026-11-24 22:59 UTC · original
bmjask:fix/msaa-sample-clamp-main→main· +16 −8 · 2 files · 2 commits · openFollow-up to #1679.
What is in it
getDimensions) is read in its own block, and the clampedtextureLoads start a new block, so notextureLoadfollowsgetDimensionsin one basic block.direct_msaa_loads_precede_get_dimensionsstill passes.TRANSLATOR_VERSION7 -> 8 so cached direct containers re-key.Tested
cargo test -p xcl --lib msaa -- --include-ignored: 6 passed, incl.gpu_direct_msaa_image_loadson the GPU anddirect_msaa_loads_precede_get_dimensionscargo test -p xcl --lib gpu::dxil: 101 passed, 0 failed, 3 ignoredXCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp: 261 passed, 0 failed, 18 ignoredcargo build --workspaceandcargo test --workspace -- --test-threads=4: 0 failed (xcl lib: 927 passed, 25 ignored)Regression run
scripts/smoke.ps1, 60 s,XCL_PRESS_AT=2:B,4:B,6:B,8:B XCL_PRESS_A_AT=10,15,20,25,30,40(B presses at 2/4/6/8 s, A presses at 10/15/20/25/30/40 s), run back to back. main is a release build of origin/main (20cf130); PR is a release build of the head (215528e). Each block comes from its own checkout'sscripts/smoke.ps1.main:
PR:
Not tested
AI use
🤖 Generated with Claude Code
@HKEY-Funk-Machine on GitHub · 2026-11-24 23:09 UTC · original
@bmjask @imnicho retested as asked: on the RX 9070,
gpu_direct_msaa_image_loadsstill ends the process with0xc0000005on #1908 atb5cfa8c. It's the same as on758e341, in debug and in release. I also split the test to find which instruction does it: every load from a multisampled texture crashes, including a plainIMAGE_LOADwith an in-range sample index. So the out-of-range clamp can't be the fix on this card.The test's program reduced to one MIMG instruction at a time (local change only:
S_ENDPGMafter the one instruction, same T#s and VGPRs as the test):IMAGE_LOAD2D MSAA, DMASK 0xF (sample = fragment 0..3, count 4)0xc0000005IMAGE_MSAA_LOAD2D MSAA0xc0000005IMAGE_GET_RESINFO2D MSAAIMAGE_LOAD2D MSAA array, DMASK 0x1 (sample 0..1, count 2)0xc0000005IMAGE_MSAA_LOAD2D MSAA array0xc0000005IMAGE_GET_RESINFO2D MSAA arrayIMAGE_MSAA_LOADD160xc0000005In every crashing case, translation and
check()(validation) finish, and the access violation comes insiderunner::run_with_statics, so at pipeline creation or dispatch. The size queries on the same two textures (same descriptors) run fine. So it looks like the direct path'sTexture2DMS/Texture2DMSArrayload itself (dx.op.textureLoadwith a sample index) that the AMD driver doesn't take. It doesn't look like texture creation or binding. A compare that might help: the same multisampled load through the HLSL path on this card, to see whether DXC's form ofTexture2DMS.Loaddiffers from ours (the sample-index operand, or the offsets / unused coordinate). I haven't done that.Tested
b5cfa8c(onmain689f2db).XCL_REQUIRE_GPU=1 cargo test -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=1:direct_msaa_store_is_rejected ... ok,gpu_direct_msaa_image_loadsexits0xc0000005. Release, the test alone: same.Not tested: which module faults (no dump), pipeline creation vs dispatch, the HLSL-path compare above, other AMD generations.
AI use: Claude Code (Claude Opus 5.5) ran the tests, made the local bisect change and wrote this comment.
@imnicho on GitHub · 2026-11-24 23:09 UTC · original
@HKEY-Funk-Machine thank you for the retest and for splitting the program - that settles it. @bmjask the patch I suggested on #1679 does not fix the crash, and my heads-up there that
main"will still crash" for want of it had the cause wrong. #1900 (merged at 23:08 UTC) has it: AMD's compiler fails whendx.op.getDimensionscomes beforedx.op.textureLoadon a dynamically indexed heapTexture2DMSin the same block, whatever the sample index.Two consequences for this PR:
mimg_msaa, and the two changes pull in opposite directions: the clamp needs the sample count before the load, which is exactly thegetDimensionsin front oftextureLoadthat #1900 moved away. A plain rebase that keeps the clamp would bring the access violation back on the RDNA4 cards (the newdirect_msaa_loads_precede_get_dimensionstest onmainshould catch that).mainafter #1900 on the RX 9070 XT). If you still want it, the count would have to come from a block before the one with the loads (#1900 lists "different blocks" as not crashing). Otherwise I would close this one; sorry for the detour.Not tested: anything on AMD (I have no such card); the "different blocks" form is taken from #1900's description, not run by me.
AI use: Claude Code with Claude Fable 5.2 read #1900 and this thread and wrote this comment.
@HKEY-Funk-Machine on GitHub · 2026-11-24 23:10 UTC · original
Update: on
main20cf130(with #1900),msaa_testspasses on the RX 9070: 5 passed, 0 failed, includinggpu_direct_msaa_image_loads(debug,XCL_REQUIRE_GPU=1 cargo test -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=1). That fits #1900's root cause (getDimensionsbeforetextureLoadin one block), and the single-instruction loads above likely still emitted the sample-count query. So #1908's clamp isn't needed for the crash here.AI use: Claude Code (Claude Opus 5.5) ran the test and wrote this comment.
@eizispark on GitHub · 2026-11-24 23:10 UTC · original · edited 2026-11-24 23:42 UTC
Hardware test report — commit
215528eRe-verified
215528eefe24c75cd336197e909393749fc15220(rebased ontomain20cf13022f764208384c610c2ae6a3f4eed201a2): pass — splittingdx.op.getDimensionsinto its own block beforebr(loads_block)avoids theamdxc64.dll0xc0000005crash on AMD RDNA4 while clamping out-of-range MSAA sample indices (gpu_direct_msaa_image_loadsanddirect_msaa_loads_precede_get_dimensionsboth pass).Tested
32.0.32015.16001), 32 GB RAM,rustc 1.100.0 (0ef1bc386 2026-11-09)(stable-x86_64-pc-windows-msvc), debug tests + release smokecargo test -p xcl --lib msaa -- --include-ignored --test-threads=1:6 passed, 0 failed, 0 ignored(0 skipped:gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads,direct_msaa_loads_precede_get_dimensions,msaa_texture_ops_run,render_target_sample_ops_validate,direct_msaa_store_is_rejected, andhle::d3d12x::vram::tests::reserved_needs_tiled_format_and_tiled_msaa)cargo test --workspace --no-fail-fast -- --test-threads=4:974 passed, 2 failed, 45 ignored(8 skipped), matchingmain20cf130(0new failures; the 2 failures are the pre-existing#1679AMD fuzz seedsgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3;8 skipped= 6lower_dxilf16/f32#1426-semantics sub-cases,pso_measurement_compiles_an_exact_synthetic_record0x887A002D, andheap_window_out_of_memory_falls_back_to_the_switch_form)XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=4:261 passed, 0 failed, 18 ignored(6 skipped)Regression run
main(20cf13022f764208384c610c2ae6a3f4eed201a2):PR (
215528eefe24c75cd336197e909393749fc15220):Not tested
XCL_SHADER_BACKEND=dxil/XCL_DIRECT_DXIL=1, NVIDIA/Intel GPUs, Wine/vkd3d-proton, gameplay past the menusAI use
(Updated from earlier check on
b5cfa8c)@raylitebull on GitHub · 2026-11-25 01:08 UTC · original
Status check:
#1900(20cf130) already landed the MSAAtextureLoad-before-getDimensionsordering fix,#1950tookTRANSLATOR_VERSION = 8, and#1947now hashesgpu/dxilsources automatically. There is also an open[P3]review note from @lewisnic94-max on cache key safety.Please let us know whether this PR can be closed as superseded by
#1900, or rebased (without thekernel.rsversion bump) if there are still separate blocks you want hardened.@JJAutoCompare on GitHub · 2026-11-25 01:22 UTC · original
Empirical test report — PR #1908 (
215528eefe24c75cd336197e909393749fc15220)215528eefe24c75cd336197e909393749fc15220(refs/pull/1908/head)origin/maincommit:5796cc467d80e3dac5d7d231ec34f1b0bebce169git merge-tree --write-tree origin/main HEAD): clean (exit0, treed39b01dfdf46a7ee75a82572dd7e3f94d1dd545b)origin/main...HEAD):crates/xcl/src/gpu/dxil/kernel.rs(+1/-1),crates/xcl/src/gpu/dxil/lower_image.rs(+15/-7)Tested
16258 MiBVRAM, driver32.0.101.9175,XCL_ADAPTER=A770, wave32 / 8–32 lanes), AMD Ryzen 7 3800X (6 cores / 12 logical processors), Windows 11 Enterprise Evaluation10.0.26200(build26200)rustc 1.100.0 (0ef1bc386 2026-11-09),cargo 1.100.0 (3acc79c0c 2026-11-05), debug (dev/test) profile, DXC1.9.2609.5 (01b62ad4)(dxcompiler.dll+dxil.dll)cargo test --workspace --no-runandcargo build --workspaceboth exited0.cargo test -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=4 --show-output: 5 passed, 0 failed, 0 ignored, 0 skipped (all 5 ran on the Arc A770 / validator):gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions(ok)gpu::dxil::msaa_tests::direct_msaa_store_is_rejected(ok)gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads(ok)gpu::dxil::msaa_tests::msaa_texture_ops_run(ok)gpu::dxil::msaa_tests::render_target_sample_ops_validate(ok)cargo test --workspace -- --test-threads=4 --show-output: stopped afterxcl --lib(903 passed, 24 failed, 25 ignored, 22SKIPPEDlines)cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output: 951 passed, 25 failed, 45 ignored across all 20 workspace test targets (exit101):xcl(--lib): 903 passed, 24 failed, 25 ignoredtests/e2e.rs: 2 passed, 1 failed, 0 ignoredsrc/main.rs,bcpack_parity,console_dlls_e2e,console_shaders,disasm_e2e,gpu_compute_e2e,gpu_pso_e2e,heap_probe,low_va,pls_quota,predication_e2e,rpf_e2e,shaders_e2e,sparse_reinit,texture_states,xg_oracle,xcl-testtitle, doc-tests): 46 passed, 0 failed, 20 ignoredCreateComputePipelineState: The parameter is incorrect. (0x80070057)on Arc A770 (no native FP64 / rejected shader ops):gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0,1,2,3},gpu::dxil::ops_tests::{doubles_match_cpu,groupshared_barrier_and_atomics_run},gpu::dxil::round_tests::{gpu_direct_f32_round_modes_dynamic_and_denormals,gpu_direct_f32_round_modes_static},gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu,gpu::recomp::tests::{gpu_clamp_and_omod_per_instruction,gpu_f64_class_compare,gpu_f64_compares_with_nan,gpu_f64_literal_high_word,gpu_f64_math_random,gpu_f64_roots,gpu_f64_rounding_and_conversions,gpu_float_compares_random,gpu_frexp_f64_exp_and_mant,gpu_ldexp_f64,gpu_rndne_f64}gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu::recomp::tests::gpu_ps_image_sample_offset_implicit_lod_between_mips,gpu::recomp::tests::gpu_valu_16_and_64_bit,gpu::recomp::tests::gpu_wave64_ps_whole_wave_reductionstests/e2e.rs(test_title_runs_and_game_folder_is_untouched):D3D12.X: dynamic depth bias via RSSetDepthBiasX (#94)(top-right [0, 0, 255, 255], expected green)SKIPPEDGPU tests (25SKIPPEDlines across 15 distinct tests — reportedokby Cargo, not counted as coverage):no wave64(18 lines across 10 tests):gpu::recomp::lower::tests::{a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu},gpu::recomp::lower_dxil::tests::{a_per_lane_2d_or_3d_group_runs_on_the_gpu,f16_programs_on_the_gpu (2),f32_programs_on_the_gpu (6),integer_programs_on_the_gpu (2)},gpu::recomp::tests::{gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware}wave32, per-lane form: refused(#1426semantics, 3 sub-cases inside 2 tests above):gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(V_MUL_F16,V_PK_MUL_F16: VOP3 modifiers),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(V_CVT_F16_F32)shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable driver cache (Windows Developer Mode required,0x887A002D)placed_title_textures_share_vram_and_preserve_pixels:tiled tier < 2test_title_draws_with_a_root_signature_under_the_debug_layer:no d3d12SDKLayers.dllheap_window_out_of_memory_falls_back_to_the_switch_form:no heap windowsuploads_start_from_each_subresources_state:no D3D12 debug layer (0x887A002D)Not tested
ld2dmsfault behavior andamdxc64.dllbasic-block compilation) and NVIDIA GPUsscripts/smoke.ps1regression run (no retail game package on this test host)AI use
T3 Code / Antigravity (gemini-4-neon)checked out PR #1908, built the workspace, ran the targeted and full-workspace test suites on the Intel Arc A770 host above, parsed the logs, and posted this test report.@DavidM1911 on GitHub · 2026-11-25 02:16 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@lewisnic94-max on GitHub · 2026-11-25 02:27 UTC · original
@raylitebull, I’m withdrawing my P3 cache objection for a rebase onto current main. It reproduced on the standalone
215528ehead because the earlier preview and revised emitter both used v8. After #1947 merged, all 12 populated-cache upgrades onb8428c5returned DXIL byte-for-byte identical to fresh translation. We tested v7 and v8 seeds with both the rounding and MSAA shaders, three runs per combination.On main
cbc296a, applying only the MSAA emitter change altered the direct source fingerprint withTRANSLATOR_VERSIONheld at 9. I’d drop thekernel.rsbump on rebase.#1900 addressed the reported RDNA4 instruction-ordering crash. The remaining hardening is a separate decision. Main zeroes the result after the load. #1908 also redirects an out-of-range sample index to 0 before loading, while keeping
getDimensionsandtextureLoadin separate blocks.OpenAI Codex (GPT-6) assisted with the cache tests, source comparison and this reply.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.