Repository navigation
Recompiler: honor pixel shader EXP VM valid-mask bit in HLSL and DXIL - #2008
Conversation
In RDNA2 pixel shaders, lane survival (discard) is controlled by the EXEC mask at the last executed ENC_EXP instruction with VM=1 (each VM=1 export overwrites the valid mask, while VM=0 exports do not modify it). Both the HLSL emitter (emit.rs) and the Direct DXIL graphics lowering (dxil/lower_gfx.rs) previously ignored VM and OR-accumulated survival on DONE=1 instead, allowing later VM=0 DONE=1 exports under a restored EXEC to revive discarded pixels and preventing a narrower subsequent VM=1 export from killing lanes. Track VM=1 exports in both backends so any pixel shader with at least one VM=1 export overwrites xcl_live / live_vm_var with the current active-lane mask on VM=1 (including undeclared SV_Target exports) and leaves it untouched on VM=0, while preserving the existing DONE=1 fallback for synthetic shaders with zero VM=1 exports. Part of xcl-dev#1488 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Tested Independent pixel readback on AMD Radeon(TM) Graphics (32.0.21042.62) and GeForce RTX 5090 (32.0.16.1742), at exact head
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. |
|
AMD RDNA3 (RX 7800 XT, native wave64) test report for #2008 at head Tested
Not tested
AI use
|
|
Tested Intel Arc A770 verification on the clean PR head $env:CARGO_TARGET_DIR = 'L:/XclTooling/pr2008-dc0d25fe/target'
$env:TEMP = 'L:/XclTooling/pr2008-dc0d25fe/temp'
$env:TMP = $env:TEMP
$env:CARGO_BUILD_JOBS = '2'
$env:CARGO_INCREMENTAL = '0'
$env:XCL_ADAPTER = 'A770'
$env:XCL_DXC_DIR = "$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64"
cargo test --locked -p xcl --lib --no-run
cargo test --locked -p xcl --lib gpu::recomp::tests::ps_exp_vm_hlsl_and_direct_dxil_codegen -- --exact --nocapture --test-threads=1
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_ps_exp_vm_controls_pixel_survival -- --exact --nocapture --test-threads=1
}
Not tested Full workspace suite, release build, pre-fix control, merge commit, retail-title smoke tests, and other adapters. AI use Codex ( |
Fixes 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(Tracking & Static Audit: 50 New Source-Level Bugs + 150 Prioritized Backlog Items [Part 1/3] #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.