fix(rdna2): lift LDS ds_sub as a CAS loop so NVIDIA can build the pipeline #26
No reviewers
Labels
No labels
accessibility
bug
cross-platform
documentation
duplicate
enhancement
gdk-shims
good first issue
graphics
hardware-report
help wanted
invalid
question
shaders
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/californiaAlmonds--OpenScarlett!26
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/26/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?
@marquezinii on GitHub · 2026-11-22 17:54 UTC · original
marquezinii:fix/lds-sub-cas-nvidia→main· +4 −1 · 1 files · 2 commits · merged 2026-11-22 18:50 UTCWhat
On current main (
85e2d3d),test_rdna2_corpus_benchandtest_rdna2_gpu_accuracyfail on an RTX 5070 with[EXT-GPU-FAIL] D3D12 HW (mem_ds_atomics):and an empty diff. The empty diff meansRunComputeDualUavreturned false before readback. Instrumenting it showedCreateComputePipelineStatefailing withE_OUTOFMEMORY(0x8007000E). The debug layer adds no message.Bisecting the generated HLSL brought it down to one construct: a groupshared
InterlockedAddwhose operand is a runtime negation. The lifter emits exactly that fords_sub_u32/ds_sub_rtn_u32(InterlockedAdd(_lds[_idx], (0u - v[n]), _prev)). Minimal reproducer (cs_6_0 to cs_6_6, root signature with two root UAVs):What I measured with that shader:
0u - y,(~y) + 1u,y * 0xFFFFFFFFu,asuint(-asint(y)),(y ^ 0xFFFFFFFFu) + 1u. DXC folds all of these toatomicrmw add (sub 0, y).0u - 5u), the same negated add on aRWByteAddressBuffer(constant or dynamic address), and a compare-exchange loop on groupshared.So it looks like a driver bug specific to LDS atomic add of a negated value. The buffer path (
.InterlockedAdd(_addr, 0u - v[n])) is fine.Change
ds_subon LDS (op 0x33,is_lds) now uses the existingemit_cas_loop("_cur - v[n]"), the same loop the lifter already uses fords_inc,ds_decand signedds_min/ds_max. The return value is the original value, as before. The buffer path and the typed-UAV (_rwtex_u32) path are unchanged. One file, four lines.Tested
Windows 11 26H2 (26300), VS Build Tools 18 (MSVC 14.52), SDK 10.0.26100.0, dxc 1.9.2602.17, RTX 5070, driver 621.24:
85e2d3d: 60/62, withtest_rdna2_corpus_benchandtest_rdna2_gpu_accuracyfailing onmem_ds_atomics(D3D12 HW).ctest62/62 passed, both tests included.mem_ds_atomicsnow runs and matches the CPU reference on D3D12 HW.The GTX 1650 Ti and other drivers may well accept the old form. The CAS loop is correct everywhere, so this doesn't depend on that.
@californiaAlmonds on GitHub · 2026-11-22 18:50 UTC · original · approved these changes
Clean, minimal CAS-loop fix for NVIDIA RTX 5070 LDS ds_sub E_OUTOFMEMORY, and 4/4 CI jobs are green. Thanks @marquezinii!