Fix RDNA 2 (RX 6000) 0x887A0006 view-heap page faults by unifying pixel-shader discard exits (Module::unify_pixel_discards) #61
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/iceboerg00--larp-amd!61
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-61"
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?
@hsiebsudbdu on GitHub · 2026-12-06 01:17 UTC · original
<html>hsiebsudbdu:fix/rdna2-unify-pixel-discards→main· +390 −2 · 7 files · 1 commits · openSummary
Fixes the AMD RDNA 2 (RX 6000 / GFX10.3 on Windows
amdxc64.dll)0x887A0006(DXGI_ERROR_DEVICE_HUNG,PageFaultVA = 0x1_xxxx_xxxx) GPU page fault that still occurs seconds into gameplay even withLARP_HEAP_FIRST_LANE=1(and without turning offLARP_QUAD_LIVE, which broke character bodies inamd-4).Targets the RDNA 2 page-fault class reported in #60, #59, #56, #55, #49, #48, #53, and #47.
Root Cause (Proved via Hardware Repro + GFX10.3
DxcCacheISA Disassembly)Direct hardware reproduction on an AMD Radeon RX 6800 XT (RDNA 2 / GFX10.3, Windows 11 D3D12) and disassembly of 29,075 compiled PAL ELFs from
%LOCALAPPDATA%\AMD\DxcCacheisolated the fault to a codegen bug in AMD's proprietary Windows DXIL compiler (amdxc64.dllSC) on GFX10.3:When a pixel shader has two or more reachable
Term::Retblocks and executesdx.op.discardin an early-return branch ahead of WQM texture sampling (Texture2D.Sample),amdxc64.dllemits a brokenSI_ELSEmask update that resurrects killed quads into the live sampling block with uninitialized VGPR heap indices:Corpus Scan Across All 29,075 Compiled PAL ELFs / 8,563 Pixel Shaders
Why Previous Workarounds Couldn't Fully Fix RDNA 2
LARP_HEAP_FIRST_LANE=1: Leaves the GFX10.3s_wqm -> s_and -> s_andn2quad-resurrection sequence intact in ISA, skipsNonUniformResourceIndex, and still reads uninitialized lane 0 / wrong slots on RDNA 2.LARP_QUAD_LIVE=0: Avoided somequad_livebranches but left characters rendered as hair-only without bodies (reverted in0f0ccbbf), while 698 multi-exit pixel shaders withoutquad_live(isHelperLane == false/abort_block) still triggered the same SC bug.dxc.exealways runs LLVM'sUnifyFunctionExitNodes, so pixel shaders never emitdiscard; ret voidin the middle of a function beforeSample.What This PR Changes
Applies cleanly on top of
main(7 files changed, +390 / -2):crates/larp-shader/src/emit/bitcode.rs(Module::unify_pixel_discards):>= 2reachableTerm::Retblocks, collectsdx.op.discardconditions from deferrable return blocks, merges them into a single unified exit block with aphi i1condition (dx.op.discard(82, killed); ret void), and rewrites those blocks to branch to the unified exit.quad_maskshaders cleanly).isHelperLane).Const::Int(0)(no-op discard) and non-zeroi1constants (Const::Int(1)andConst::Int(-1)both short-circuit totrue).Bin::Orcombining, single-ret no-op, entry-onlyquad_maskno-op, post-discard UAV/wave side-effect skipping, andConst::Int(1)/Const::Int(0)edge cases.crates/larp-shader/src/emit/shader.rs:self.m.unify_pixel_discards()beforeself.m.single_latches()whenkind == 0 && super::lower::defer_pixel_discards().crates/larp-shader/src/emit/lower.rs,emit/mod.rs,lib.rs:defer_pixel_discards()controlled byLARP_DEFER_DISCARDS=0|1(default: ON on AMD viaHOST_IS_AMD, OFF on NVIDIA) and registers"LARP_DEFER_DISCARDS"inSWITCHES.crates/larp-gpu/src/host.rs&shader_cache.rs:defer_discardsalongsiderdna2/bvh_fenceson AMD device init and hashesu8::from(larp_shader::emit::defer_pixel_discards())into the shader cache key.(Note: This PR intentionally leaves
heap_first_lane()untouched to avoid regressing RX 7000/9000 setups. On RX 6800 XT we verified zero faults even withLARP_HEAP_FIRST_LANEdisabled and onlyLARP_DEFER_DISCARDS=1active, so maintainers may optionally evaluate gatingheap_first_lane()off on RDNA 2 in a follow-up to save shader cache invalidation.)Verification
- Static / ISA Check: Verified all 8,514 pixel shaders emit
- Unit Tests:
- Live Hardware Testing (AMD Radeon RX 6800 XT 16 GB, Windows 11 D3D12, Ryzen 5 7500F, 16 GB DDR5):
- Run 1 (FSR 3.1.6): 22+ minutes continuous gameplay,
- Run 2 (FSR 4.1.2 INT8 +
</html>rets == 1, zeroWQM+SI_ELSEsequences remain in Wave32 and Wave64 compiled PAL ELFs, ands_mov_b32 exec_lobeforeEXP mrt0..2/EXP mrtzis preserved (character bodies, depth, and shadows intact).cargo test --locked -p larp-shader --lib emit::bitcode::tests— all 5unify_pixel_discards_*tests pass.exit 0, 0 GPU page faults, 0 missing character bodies/trees/shadows (AVG 25.5 FPS,MED 26.0 FPS,MAX 55.6 FPS).LARP_PIPELINE_WAIT_MS=16): 30+ minutes continuous gameplay, 45,679+ frames,runs="4.1.2", 0 GPU page faults, smooth stutter-free gameplay.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.