Repository navigation
Conversation
ivall#123 again (reverted in 70f8dc4): with several memory windows, smem, MUBUF and FLAT / global picked the window from the base's high dword before the offsets were added, so an offset that carried out of the low dword went to the base's window at the wrapped address. ivall#123 summed the address in uint64_t at every access, and the AMD shader compiler crashed on that in XDefiant (CS 8e4af296b9d7fd9c). window_at now adds the terms in 32 bits and counts the carries with a compare per term (a borrow for a negative constant offset); no 64-bit integers. With one window it emits nothing, so the single-window HLSL is unchanged. Test gpu_memory_window_carry, now also checking that the window lines have no 64-bit arithmetic.
|
One remaining carry case in For a synthetic, in-range structured buffer, take base The emitter already has |
|
Tested #138
No new failures vs main. The PR's new test passes on RDNA2. The one failure on both, |
|
Read: AI-assisted review (Gemini + Claude); code read only, not run. |
|
Not merged in this round on purpose: it changes the HLSL of every multi-window program, so the next run of a title recompiles all of its shaders, and I wanted the other merges checked on a warm cache first. It is next. Could you rebase on main (6da33fa)? |
|
The carry fix holds where lanes disagree: one load whose even lanes stay in window 0 and odd lanes carry into window 1 (4 GiB apart) reads 17 / 31 with this PR in all 64 lanes, and 17 / 23 on main (the carry lost). Same on the merge with main 6da33fa. Tested A single translated
RTX 5070 Ti, 610.74, Windows x64, native D3D12. Built with Not tested Retail shaders, AMD, native wave64, ADDTID, or stride-product overflow. The mixed-lane case used the split wave64 implementation on 32-lane hardware. AI use — Codex, GPT-6.2 Astra. |
|
RDNA3 run plus the two open review points (@tronLives111's Rebase: The two points, fixed in 32 bits
Patch below (on the rebased commit). The HLSL changes only for multi-window programs with an indexed MUBUF access or an addtid access. New GPU test:
|
|
Driver cost of this PR's 32-bit carry when combined with #187's heap windows, on an access-dense compute program: with #187, #138 makes first creation in the driver about 50–65 % slower. That is still about 25× faster than the switch form without #138. The shape is split wave64 compute with a load and a store of title memory every round and an exec-masked block every 4 rounds. Each cell is 2 programs the driver had never seen, and the driver times are min / max:
Tested
Not tested
🤖 Claude Fable 5.2, Claude Opus 5.5 |
#123 was reverted in 70f8dc4: AMD's shader compiler crashed on XDefiant's CS
8e4af296b9d7fd9c. This PR is a second try, in the form suggested there: a 32-bit carry compare instead ofuint64_t.The problem it fixes is the same. With several memory windows, smem, MUBUF and FLAT / global picked the window from the base's high dword before adding the offsets. So an offset that carried out of the low dword went to the base's window at the wrapped address.
What changed from #123:
window_atadds the low dword and the offsets in 32 bits and counts the carries with one compare per term:xcl_ws += t; xcl_wc += (uint)(xcl_ws < t);.stride * indexproduct is now 32-bit, so it no longer catches a product above 4 GiB.For example, a global load with SADDR emits:
{ uint xcl_ws = s16, xcl_wc = 0u, xcl_wt; xcl_wt = v1; xcl_ws += xcl_wt; xcl_wc += (uint)(xcl_ws < xcl_wt); xcl_w = ((s17) + xcl_wc) & 3u; }As in #123, with one window it emits nothing, so the single-window HLSL and its DXIL cache are unchanged;
gpu_memory_windows_above_4_gibchecks that.Test
gpu_memory_window_carry(from #123): the base sits at0xFFFF_F000of window 0, and s_load, s_buffer_load, buffer load / store, global load with SADDR and a global atomic each reach window 1. It now also checks that thexcl_w =lines contain no 64-bit arithmetic. Without the emit change it fails; with it, it passes on a GTX 1650 under Wine, and so do the other lib tests that run there.I can't run XDefiant or an AMD GPU here, so whether this shape avoids the
amdxc64.dllcrash needs your RX 9070 check. If it still crashes, the next step would be your other suggestion: emit the carry only where an offset can actually cross the dword.