Repository navigation
Conversation
Both paths ignored ADD_TID_ENABLE (V# word 3 bit 23): every lane of a buffer load without IDXEN read element 0. RDNA2 takes the lane as the index when IDXEN is clear and ignores ADD_TID with IDXEN (AnyPS5#21970, measured on gfx1036; #24781 applies it to graphics stages). Loads, stores and atomics, both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…groups
Neither path implemented the buffer swizzle: a V# with SWIZZLE_EN (word 1
bit 31) and a nonzero stride was addressed linearly, base + soffset +
offset + stride * index. Both paths now use the rule AnyPS5#21970 measured
on RDNA2 (gfx1036 through HIP, compute loads and stores, wave32 and
wave64):
step = 8 << INDEX_STRIDE (word 3 [22:21])
addr = ((index / step) * stride + (off & ~3)) * step
+ (index % step) * 4 + (off & 3) + soffset
where off is the VGPR offset plus the instruction offset and ELEMENT_SIZE
has no effect. The swizzle applies only with IDXEN, or with ADD_TID and no
IDXEN; anything else stays linear. Without IDXEN each dword of a
multi-dword access is swizzled at off + 4k (4 * step bytes apart); with
IDXEN the dwords are contiguous from the first one's swizzled address.
The V# is dynamic, so the address is a runtime select. On the direct
path a multi-dword load without IDXEN keeps its single vector load for
the linear case and takes a second guarded per-dword load when swizzled
(the V# is uniform, so one of the two runs); the window is chosen from
the swizzled 64-bit offset (new Ea::W term). The bounds check is
unchanged (index < num_records when the stride is nonzero).
Atomics, d16 and sub-dword accesses and MTBUF / format loads and stores
go through the same address code, so a swizzled V# swizzles their first
byte too, but #21970 did not measure atomics, tbuffer, typed accesses or
SOFFSET, and a multi-component format access still reads its components
contiguously. Not measured either: that the console GPU swizzles like
gfx1036, and the (off & 3) term in DWORD alignment mode (#21970 ran
UNALIGNED).
New GPU tests gpu_buffer_swizzle_* (ADD_TID with and without an
instruction offset, INDEX_STRIDE 3, IDXEN x2 with a VGPR index and
ADD_TID set, ADD_TID x2 load and store, linear controls) fail on the
parent and pass here with XCL_DIRECT_DXIL=0 and =1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lower_window.rs from main (547886c: window_at carries in 32 bits without i64). lower_mem.rs buf_addr computes the windowed swizzled offset's high half with 32-bit carries as window_at does, and takes the window from the swizzled offset, so the direct path stays free of 64-bit integer ops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he swizzled offset gpu_buffer_swizzle_window_from_swizzled_offset: three swizzled loads with two memory windows - an offset carry from below window 0 into window 1, an index * stride product that carries into window 1, and a product past 2^32 that must read 0. Fails on main + xcl-dev#2066 on both paths, passes with the swizzle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
|
Stacked on #2066, whose ADD_TID commit (b81d47c) is now on main; the swizzled addressing on top of it ( AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Depends on: #2066. Stacked on it: the branch is #2066's commit
b81d47c, then this PR's commits:4ee401e(the swizzle), a merge ofmain06c9f550that adapts the direct path to main's 32-bit window carry (547886c), and68b6034(a test for swizzled accesses across memory windows).A V# with its swizzle bit set (word 1 bit 31) and a nonzero stride interleaves records in dword groups. XCL addressed every buffer access linearly, as
offset + stride * index, on both translators. That includes the per-lane index #2066 adds for ADD_TID. So a swizzled access read and wrote the wrong bytes: with stride 16 and ADD_TID, lane 1 reads byte offset 16 instead of 4.The rule, as boykopovar/AnyPS5#21970 measured it on gfx1036 (RDNA2, compute loads and stores, through HIP; that PR is still open):
step = 8 << INDEX_STRIDE(word 3 [22:21]).((index / step) * stride + (off & ~3)) * step + (index % step) * 4 + (off & 3), plus SOFFSET unscaled. Hereoffis the VGPR offset plus the instruction offset. ELEMENT_SIZE has no effect.off + 4k. With IDXEN the dwords are contiguous from the first one's address.What is in it
recomp/emit.rs(HLSL path):Em::buf_relcomputes the relative address, including the 64-bit windowed form. Loads, stores, atomics and the D16 forms use it, and multi-dword accesses space their dwords by the swizzle step.dxil/lower_mem.rs(direct path):Lw::buf_addr, the same rule. A multi-dword load without IDXEN keeps its single vector load when the V# is linear, and does a guarded per-dword load when it's swizzled. The V# is uniform, so only one of the two runs.dxil/lower_mem.rs, windowed form:buf_addrcomputes the high half of the swizzled (or linear) offset with 32-bit carries, as main'swindow_atdoes since 547886c, and adds it to the V# base, so the window is chosen from the swizzled offset and the direct path keeps no 64-bit integer ops.dxil/lower_window.rsis main's, unchanged.recomp/tests.rs:gpu_buffer_swizzle_window_from_swizzled_offset, three swizzled loads with two memory windows: an offset carry from window 0 into window 1, anindex * strideproduct that carries into window 1, and a product past 2^32 that must read 0.recomp/tests.rs: six GPU tests (gpu_buffer_swizzle_*). They cover ADD_TID (lane 1 at +4, not +16), INDEX_STRIDE 3, IDXEN with a vindex and DWORDX2, DWORDX2 without IDXEN, a two-dword store, and controls (SWIZZLE_EN=0 stays linear; SWIZZLE_EN=1 with neither IDXEN nor ADD_TID is linear too).Tested
At
68b6034(this tree is main06c9f550+ #2066 + this PR), RTX 3070 (616.56), Windows 11, debug:gpu_buffertests, 5 fail (the five swizzled cases), and 2 pass (Recompiler: a V# with ADD_TID_ENABLE indexes buffers by lane #2066's ADD_TID test and the linear control).gpu_buffer_swizzle_window_from_swizzled_offsetfails at its first case (lane 0 reads window 0 + 0x1000). Both onXCL_DIRECT_DXIL=0and=1. With the PR:gpu_buffer8 of 8 on both paths.XCL_DIRECT_DXIL=1). (Edited: I removed a second mutation I had listed, because it has no log.)gpu_suite (--skip gpu_sparse_vram, single-threaded): main06c9f550144 passed, 0 failed, 1 ignored on both paths; this PR 152 passed, 0 failed, 1 ignored on both paths (the +8 are Recompiler: a V# with ADD_TID_ENABLE indexes buffers by lane #2066's test, the six swizzle tests and the window test).SKIPPED(counted as passed):gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64), on both.windowtests 32 of 32, including main'swindow_at_lowers_to_32bit_carry_without_int64andgpu_window_at_32bit_carry_edge_cases, on both paths.gpu::dxil::157 passed, 3 ignored.git merge-treeagainst currentmain08294413: clean.4ee401e(before the merge): nnonno91 (comment, thanks) rangpu_buffer7 of 7 on an AMD Radeon iGPU (32.0.21042.62) and an RTX 5090 (32.0.16.1742) on both paths, plus a temporary nonzero-SOFFSET fixture, 128 of 128 readbacks matched. That run predates the 32-bit window change.DXIL size (direct path, wave32, one access per program,
insts= non-comment lines of themainbody; main + #2066 → this PR):That's +17 to +39 instructions per access with one window (+17 % to +45 % of these small programs) and +26 to +60 with two windows (+21 % to +53 %), linear V#s included, because the V# is only known at run time. A multi-dword load without IDXEN costs the most: it carries a second, guarded per-dword load for the swizzled case (only one of the two runs, the V# is uniform). Static counts only; I didn't measure compile or run time.
A question for the maintainer, given #2088's DXIL-size work: is this cost acceptable, or should the swizzle math be emitted only where it can apply? Options, none done here: skip it when the V# bits are known at translation time (rare), share the per-V# values between accesses through the same SRSRC in a block, or branch on the uniform swizzle bit instead of selecting.
Regression run
I have no retail title here. Could someone with one post
xcl-smokeblocks formainand this head? I'll paste them with credit.Not tested
(off & 3)term in DWORD alignment mode is not covered (#21970 measured it in UNALIGNED mode).gpu_buffer_swizzle_window_from_swizzled_offset). Swizzled stores and atomics across windows are not.NUM_RECORDS * stridefor swizzled groups, and this PR doesn't model that.AI use
Claude Code (Claude Opus 5.5) wrote the change and the tests and ran them. I reviewed the diff against the rule before opening this.
🤖 Generated with Claude Code