Recompiler: honor pixel shader EXP VM valid-mask bit in HLSL and DXIL #2008
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!2008
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2008/head"
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?
@Decodere on GitHub · 2026-11-25 00:40 UTC · original
Decodere:fix-1488-ps-exp-vm→main· +188 −29 · 3 files · 1 commits · merged 2026-11-25 01:11 UTCFixes pixel-shader
EXPVM(Valid Mask) handling in both the HLSL emitter and Direct DXIL graphics lowering (XCL-BT-012).In RDNA2 pixel shaders, lane survival (
discard) is determined by theEXECmask at the last executedENC_EXPinstruction withVM=1(eachVM=1export overwrites the valid mask, whileVM=0exports leave it unchanged). Previously bothrecomp/emit.rsanddxil/lower_gfx.rsignoredVMand OR-accumulatedxcl_live/live_varonDONE=1, so a laterVM=0, DONE=1export under a restoredEXECrevived discarded pixels and a narrower secondVM=1export failed to kill lanes active during an earlier export.Part of #1488
What is in it
crates/xcl/src/gpu/recomp/emit.rs: addEm::has_ps_vmpre-scanned inconfigure_round_modesfor pixel shaders with anyENC_EXPcarryingVM=1; inexport_graphics, unify the undeclaredSV_Targetbranch with the main pixel-survival update soVM=1overwritesxcl_live = ({act});andVM=0leavesxcl_liveuntouched whenhas_ps_vmis true, while preserving theDONE=1fallback (if ({act}) xcl_live = true;) when noVM=1export exists.crates/xcl/src/gpu/dxil/lower_gfx.rs: trackps_vmandlive_vm_varalongsideps_doneandlive_varinGfxCtx; overwritelive_vm_varwithsel(act, 1, 0)onVM=1inexport_gfx, and readlive_vm_varinfinish_gfxwheneverps_vmis true (falling back tolive_varwhen onlyps_doneis set).crates/xcl/src/gpu/recomp/tests.rs: addps_exp_vm_hlsl_and_direct_dxil_codegen(CPU HLSL codegen/DXC compile + Direct DXIL container validation) andgpu_ps_exp_vm_controls_pixel_survival(GPU draws on both HLSL and Direct DXIL across four cases:VM=1 DONE=0+ restoredEXEC+VM=0 DONE=1, narrower secondVM=1overwriting an earlierVM=1, undeclared MRTVM=1 DONE=0+ declared MRT0VM=0 DONE=1, and the no-VMDONE=1fallback).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5; targeted regression checks in debug, full suite and smoke runs in release.ps_exp_vm_hlsl_and_direct_dxil_codegenfails pre-fix, andgpu_ps_exp_vm_controls_pixel_survivalfails independently pre-fix on both HLSL and Direct DXIL (vm1_done0_then_vm0_done1 pixel (0,0) = [0.0, 0.0, 0.0, 0.0], expected [0.0, 0.0, 1.0, 1.0]).ps_exp_vm_hlsl_and_direct_dxil_codegen,gpu_ps_exp_vm_controls_pixel_survival(all 4 cases on both HLSL and Direct DXIL), andgpu_graphics_vs_ps_drawall pass.cargo build --release --workspace+cargo test --release --workspace -- --test-threads=4 --nocapture: 997 passed, 0 failed, 45 ignored across 20 test runs.SKIPPEDlines (26 total):no wave64(gpu::recomp::lower::tests::{a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,coalesced_guarded_runs_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,const_and_null_mask_operands_agree_with_hlsl_on_the_gpu,f16_programs_on_the_gpu (2),f32_programs_on_the_gpu (5),f64_programs_on_the_gpu,integer_programs_on_the_gpu (2)},gpu::recomp::tests::{gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware})gpu::recomp::lower_dxil::tests::{f16_programs_on_the_gpu (2),f32_programs_on_the_gpu (1)})shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(cannot disable driver cache without Windows Developer Mode)heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll,uploads_start_from_each_subresources_state: no D3D12 debug layer (0x887A002D))Regression run
main:
this PR:
Not tested
d3d12SDKLayers.dllnot installed on this machine).discard(not changed in this PR) and retail pixel shaders exercising multi-exportVMoverwrite; the smoke run above is a regression check only.AI use
XCL-BT-012(#1488), wrote the HLSL and Direct DXIL fixes, CPU/GPU regression tests, and this description, and ran the test suite and paired smoke runs on the hardware listed above.@nnonno91 on GitHub · 2026-11-25 01:05 UTC · original
Tested
Independent pixel readback on AMD Radeon(TM) Graphics (32.0.21042.62) and GeForce RTX 5090 (32.0.16.1742), at exact head
dc0d25fe82eb04bdb5710428d122ff1d25e5279a. Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Rust 1.100.0 x64 MSVC, and DXC/DXIL 1.8.2502.11. Unoptimized dev/test profiles with debug info off. GPU checks usedXCL_ADAPTERto select each adapter andXCL_REQUIRE_GPU=wave64to catch a skipped draw.cargo build --workspace --lockedpassed at the PR head.cargo test --locked -p xcl --lib ps_exp_vm -- --test-threads=1 --nocapturepassed on each GPU (2 passed, 0 failed, 0 ignored, 0 skipped). All four cases matched the expected 16×16 pixel grid through HLSL and Direct DXIL, for 2,048 pixel comparisons per GPU.cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_graphics_vs_ps_draw -- --test-threads=1 --nocapturealso passed on each GPU (1 passed, 0 failed, 0 ignored, 0 skipped).8c4a46a3c2d50498691cbda79cbbf4fadb45fbe8. Theps_exp_vmcommand failed both tests as expected on each adapter (0 passed, 2 failed). To reach the second backend before the first assertion stopped the test, I swapped only the test's backend order and rancargo test --locked -p xcl --lib gpu::recomp::tests::gpu_ps_exp_vm_controls_pixel_survival -- --exact --test-threads=1 --nocapture(0 passed, 1 failed on each adapter). In both backend orders on both GPUs,vm1_done0_then_vm0_done1gave[0, 0, 0, 0]at pixel (0,0) where the test expects the blue clear value[0, 0, 1, 1].Not tested
Full workspace suite, real-title smoke runs, and performance in this independent check.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) ran and checked the tests and drafted this report.
@oni-swr on GitHub · 2026-11-25 01:06 UTC · original
AMD RDNA3 (RX 7800 XT, native wave64) test report for #2008 at head
dc0d25femerged withmain2e1c9562(clean merge).Tested
Windows Kits\10\bin\10.0.26100.0\x64), debug build,XCL_ADAPTER="RX 7800 XT".cargo test -p xcl --lib ps_exp_vm_hlsl_and_direct_dxil_codegen -- --nocapture: 1 passed, 0 failed (0.10s)cargo test -p xcl --lib gpu_ps_exp_vm_controls_pixel_survival -- --nocapture: 1 passed, 0 failed (0.44s; all 4 cases on both HLSL and Direct DXIL)cargo test -p xcl --lib gpu_graphics_vs_ps_draw -- --nocapture: 1 passed, 0 failed (0.23s)cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture): 1002 passed, 1 failed, 45 ignored across 20 test binaries.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: res[30] = 0x1, CPU 0x7fffffff). Verified directly onorigin/main2e1c9562on the same RX 7800 XT: it fails identically there (pre-existing onmain, unrelated to this PR).SKIPPEDlines (7): the 6 intentional#1426per-lane refusals ingpu::recomp::lower_dxil::tests(V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32, wave32 and wave64) plusheap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows. Zerono wave64skips — all native wave64 GPU tests ran and passed.Not tested
scripts/smoke.ps1title run, or other AMD generations.AI use
@futurepro62 on GitHub · 2026-11-25 01:04 UTC · original · edited 2026-11-25 01:14 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
dc0d25f(on its base8c4a46a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 986 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_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,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.ps_exp_vm_hlsl_and_direct_dxil_codegen,gpu_ps_exp_vm_controls_pixel_survival.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 996 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main7994cd1too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@JJAutoCompare on GitHub · 2026-11-25 01:17 UTC · original
Tested
Intel Arc A770 verification on the clean PR head
dc0d25fe82eb04bdb5710428d122ff1d25e5279a. Intel driver 32.0.101.9175, AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 25H2 build 26200.9974 x64, Rust/Cargo 1.100.0 (x86_64-pc-windows-msvc), debug test profile. Both runs loaded DXC and DXIL 1.9.2609.5.SKIPPEDresults were 0.Not tested
Full workspace suite, release build, pre-fix control, merge commit, retail-title smoke tests, and other adapters.
AI use
Codex (
gpt-6.2-sol) ran the tests, verified the outputs, and wrote this report.@DavidM1911 on GitHub · 2026-11-25 03:51 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!