Repository navigation
Conversation
|
Hardware answer to the open question (the masked rotation), plus a check of both modes: on RDNA2 the ISA's pseudocode is what the hardware does; the mask = 1 example is not. Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written
Rotate left by 1 with mask 1 ( Against this PR:
The raw lane lists (JSON, every offset above, both wave sizes) are available if useful. AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run. |
A rotation with a mask (offset[4:0]) was refused, because the pseudocode of 12.13.1 and its examples for mask 1 give different lanes. Lyrnc measured it on RDNA2 hardware (gfx1036, Marvisak#606): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, and bits 11 and 12 are ignored: j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated with bit 10 It is lowered so now. A test holds the measured lane lists for 0xC021, 0xC421 and 0xC023, and 0xD821 for the ignored bits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@Lyrnc thank you, that settles the one thing this PR had to leave open, and it is a far better check than anything I could run here. Pushed
On the RTX 3070 (driver 616.56): If you still have the probe set up, would you run your GPU check against AI-assisted (Claude Code). |
|
@upipibi ran it against What ran.
So in wave64 every lane 32-63 reads within its own half, as on the hardware. Your four AI use: Claude Code (Claude Opus 5.5) wrote the local test, ran it on both GPUs and drafted this comment. |
|
AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of
|
catminou4
left a comment
There was a problem hiding this comment.
Conflicts with current main (ffe310e, post-#566 waterfall loops) in lower.rs/valu_tests.rs — needs a rebase before I can run the suite on the merged tree.
Static review of the change itself: offsets ≥ 0xE000 (FFT) and 0xC000-0xE000 (rotate) are now carved out of the quad/mask swizzle paths, both stay within the lane's group of 32, the FFT path bit-reverses the 5 index bits via unary.i32 op 30 and shifts down by the mask's popcount while keeping the mask bits, and the rotate path follows the ISA pseudocode with the direction bit 0x400 negating the count. The comment honestly flags that the ISA's examples for mask 1 disagree with its pseudocode and states which one hardware follows — good. The host-execution tests (Windows) cover the modes; macOS can't run them.
Rebase and I'll run cargo test -p victory-shader and finish the review.
|
Rebased onto AI-assisted (Claude Code). |
A rotation with a mask (offset[4:0]) was refused, because the pseudocode of 12.13.1 and its examples for mask 1 give different lanes. Lyrnc measured it on RDNA2 hardware (gfx1036, Marvisak/VIctory#606): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, and bits 11 and 12 are ignored: j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated with bit 10 It is lowered so now. A test holds the measured lane lists for 0xC021, 0xC421 and 0xC023, and 0xD821 for the ignored bits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit da1a1f7ba3b4eb28cc46e9e2352b7e32e1bd5c4b)
A rotation with a mask (offset[4:0]) was refused, because the pseudocode of 12.13.1 and its examples for mask 1 give different lanes. Lyrnc measured it on RDNA2 hardware (gfx1036, Marvisak#606): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, and bits 11 and 12 are ignored: j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated with bit 10 It is lowered so now. A test holds the measured lane lists for 0xC021, 0xC421 and 0xC023, and 0xD821 for the ignored bits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
da1a1f7 to
95b58c1
Compare
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested head 95b58c1 (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:
cargo test -p victory-shader valu_tests: 17 passed, 0 failed (including all 4 newds_swizzle_*tests:ds_swizzle_basic_modes,ds_swizzle_masked_rotations,ds_swizzle_fft_mode, andds_swizzle_rotate_modeon both RTX 5090 and WARP)cargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy: ok
Clean lowering of ds_swizzle_b32 rotate and FFT modes for offsets >= 0xC000, with solid wave-level GPU test coverage. Approving.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
Careful work on the two previously-unsupported ds_swizzle_b32 offset ranges:
- Mode decoding is right:
offset >= 0xE000→ FFT,0xC000..0xE000→ rotate, and both are excluded from the legacy quad/and-or-xor paths (!(fft || rotate)guard). The "other bits don't matter" case (0xFFF0 behaves as 0xE010) falls out of masking correctly. - FFT path:
unary.i32op 30 isbfrev(same opv_bfrev_b32uses),>> 27brings the reversed 5 index bits down,>> popcount(mask)shifts by the mask width, andi & maskkeeps the lane's own mask bits — matches the ISA pseudocode. Identity at mask 0x1F checks out. - Rotate path:
(i + n) & !mask | (i & mask)withnnegated by bit 10 implements "rotate the non-mask bits, keep the mask bits", truncated to 5 bits by the mask — wraparound mod 32 correct. Bits 11/12 ignored as measured. - The ISA-example discrepancy is handled honestly: the comment states the ISA's examples for masked rotations list other lanes, and the test comment credits the hardware measurement (all 2048 offsets 0xC000-0xC7FF on gfx1036) that the pseudocode matches. Encoding that measured behavior in
valu_testsis exactly the right call. - Test harness improvement (
build_cswith configurable thread count,swizzle_32running both hardware and warp backends with graceful skips) is clean and reusable.
Verified locally: test-merge with current main (ffe310e) clean; cargo test -p victory-shader --locked (macOS arm64, rustc 1.98.1) → 96 passed / 0 failed / 1 ignored.
Scope note: all four new tests execute real hardware via the host harness (valu_tests-style), so on this macOS run they compile but the execution paths skip without an SM 6.6 device — the Windows/GPU lane is where they actually assert. The lowering structure itself is platform-independent.
|
AMD check at
Synthetic tests only, no game files. Tested with AI assistance (Claude Code). |
The lowering read bit 15 of the offset as the quad permutation, whatever the rest. The ISA (12.13.1) has two more modes above it: from 0xE000 the FFT order of offset[4:0], and from 0xC000 a rotation of the 32 lanes by offset[9:5], right with offset[10]. Both are lowered as the pseudocode gives them. A rotation with a mask (offset[4:0]) is refused by name: the pseudocode and the examples for mask 1 give different lanes. Three synthetic GPU tests over one 32-lane wave, expected values from the ISA's examples; the FFT and rotate ones fail before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A rotation with a mask (offset[4:0]) was refused, because the pseudocode of 12.13.1 and its examples for mask 1 give different lanes. Lyrnc measured it on RDNA2 hardware (gfx1036, Marvisak#606): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, and bits 11 and 12 are ignored: j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated with bit 10 It is lowered so now. A test holds the measured lane lists for 0xC021, 0xC421 and 0xC023, and 0xD821 for the ignored bits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… helper Rebased onto 70564ae: try_build_valu_cs now returns a Result, so build_cs does too and the swizzle test expects it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95b58c1 to
05babc0
Compare
|
Rebased onto |
|
Automated triage for the maintainers. Merge candidate. What I checked:
The four Note: the swizzle tests are skipped on hosts without 32-lane waves. CI: no check runs on the head commit. Generated by Claude Code |
Pull request Marvisak#606 of fxceless/victory-gta6: the staging states are indexed by the memory of their texture, and one over memory the runtime maps or unmaps is marked, so that the first list that samples it uploads the new bytes and not the next one. The index keeps each texture's bytes beside it here, so that a mapping looks only at the textures it overlaps (a title that streams maps thousands of ranges a second), and none is let go under the index's lock. AI-assisted. Its tests pass on an RTX 5080. Not run with the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two commits on
maind2a4bae:3ad06fb(the two modes),da1a1f7(rotations with a mask).What
ds_swizzle_b32incrates/victory-shader/src/emit/lower.rstook bit 15 of the offset as "quad permutation" for every offset from 0x8000. Offsets from 0xC000 are two other modes, and were lowered as a quad permutation of offset[7:0]:(reverse5(i) >> popcount(mask)) | (i & mask), mask = offset[4:0].((i & mask) | ((i + rot) & ~mask)) & 31, rot = offset[9:5], negated when offset[10] is set, mask = offset[4:0]. Bits 11 and 12 are not read.Both modes stay inside the lane's group of 32 (
i & 32is kept), like the and/or/xor mode. Offsets below 0xC000 are unchanged. As before, reads of invalid lanes are not zeroed.Why
RDNA2 ISA (30-November-2020), 12.13.1 "DS_SWIZZLE_B32 Details", pp. 207-209:
Pseudocode, same section:
Rotations with a mask. The ISA's two worked examples for mask 1 disagree with this pseudocode (rotate left by 1: the pseudocode makes lanes read 0, 3, 2, 5, ...; the example lists 1, 0, 3, 6, ...). The first version of this PR refused that case. @Lyrnc then measured it on RDNA2 hardware (gfx1036, comment below): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, bits 11 and 12 are ignored, and the FFT formula matches all 37 offsets tried.
da1a1f7lowers masked rotations accordingly.Tests
Four tests in
valu_tests.rs, from hand-written instruction words: one 32-thread wave32 compute program whose lanes hold 1..=32 (the input of the ISA's examples), swizzle, and store what they read.build_valu_csis split so that the lowering part (build_cs) takes the thread count; modules go throughdxil.dllvalidation (the Windows SDK's) as before.Where the expected values come from:
ds_swizzle_fft_modeds_swizzle_rotate_modeds_swizzle_masked_rotationsds_swizzle_basic_modescargo test -p victory-shader -- --test-threads=1:maind2a4bae: 69 passed.offset 0xe000: left[1, 1, 1, 1, 5, 5, 5, 5, 9, ...], right[1, 17, 9, 25, 5, 21, 13, 29, 3, ...]offset 0xc020: left[1, 1, 3, 1, 5, 5, 7, 5, ...], right[2, 3, 4, ..., 32, 1]3ad06fb: 72 passed, 0 failed.da1a1f7: 73 passed, 0 failed.The swizzle tests need a host with 32-lane waves (
WaveSize(32)). They ran on the GPU; WARP refuses the pipeline and is skipped by name, so on a WARP-only runner they pass without checking anything.cargo xtask policy: ok (151 files).cargo build -p victoryandcargo build -p victory --profile diag --features diagnostics: both build;cargo clippy -p victory-shader --testsadds no warnings.GPU: NVIDIA RTX 3070, driver 616.56, Windows 11. These runs show what the translated DXIL computes; that the lanes are the hardware's rests on the ISA and on Lyrnc's RDNA2 measurement.
Not tested here: wave64 programs, mesh and pixel stages (cross-lane swizzles are refused there as before), a title's shaders. I know of no compiler that emits these two modes, so this is correctness for legal ISA, not a known in-game fix.
No game files were used. AI-assisted (Claude Code).
🤖 Generated with Claude Code