Repository navigation
Shaders: LDS halfwords straddling two dwords, and hardware tests of byte and halfword LDS accesses - #116
Shaders: LDS halfwords straddling two dwords, and hardware tests of byte and halfword LDS accesses#116dragoso wants to merge 3 commits into
Conversation
|
Correction (later the same night): with more runs, AMD run: the new tests pass one at a time, but the test process crashes ( Head
So it comes from these two tests running side by side, not from parallel GPU tests in general. The output stops after the non-GPU tests print AI use
|
|
Tested
No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent). |
|
RDNA2 hardware measurement of the read forms and of the two Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr), one wave of 32: 16 lanes store distinct dwords to LDS, then lane
So the extension and the kept half are as in this PR. The two shortcut cases:
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. |
|
Three PRs implement LDS byte and halfword accesses, and they differ in coverage:
So they're alternatives, not copies: this PR is the most complete and best tested, and #571 is the only one handling straddling halves. They all edit the same code in Checked by reading the diffs. Not run. AI-assisted (Claude Code). |
|
Triage note: same feature as #101 and #632 — byte/halfword LDS reads and writes were refused with "an LDS read/write of bytes or halves".
This one currently has |
ds_read_{u,i}{8,16}, their _d16/_d16_hi forms, and ds_write_b{8,16}
(and _d16_hi) went untranslated. Reads load the dword holding the data,
shift it down and extend it; the d16 forms fill one half of the VGPR and
keep the other, which the IR now records as a read of the destination.
Writes clear the bytes and set them with two atomics, so lanes writing
other bytes of the same dword at once keep theirs.
Synthetic GFX10 compute programs check every form against a model of
the console's LDS on the host GPU and WARP, including 64 lanes writing
neighbouring bytes of shared dwords.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8504777 to
d04de8a
Compare
The IR already records every vector instruction's destination as a read (for the lanes it leaves alone), so a ds_read_*_d16* sees the half it keeps without a rule of its own. The d16 tests pass on the GPU and WARP without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A halfword at byte 3 of a dword takes its high byte from byte 0 of the next one: an RDNA2 measurement on the PR showed the hardware reads (and writes) the two bytes at the address across the dword boundary, where the lowering took halfwords as 2-aligned. Reads now also load the next dword and writes clear and set its byte with two more atomics; neither adds a branch or loop. The tests run every form at every byte address from 2 to 7, odd and straddling halfwords included, over three dwords of LDS, and the write test reads back the next dword as well. They fail on the previous lowering and pass on the GPU and WARP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the runs and the review. Where things stand at
Tested on Windows 11, NVIDIA RTX 5060 Ti and WARP: AI use: Claude Code (Claude Opus 5.5) wrote the change, ran the tests above and posted this comment. |
|
@dragoso Not tested: the full AI-assisted (Claude Code, Claude Opus 5.5); no game data. |
|
Rescoped at
On plain @ghost: thanks for the RX 9060 XT run. That was on the previous head. The tests haven't changed in substance, but this head isn't tested on AMD. AI use: Claude Code (Claude Opus 5.5) made this change, ran the tests and posted this comment. |
|
The rescoped change (straddling halfwords on top of |
What
mainnow lowers byte and halfword LDS reads and writes itself (0b35b7f), with the same approach this PR had (shift and extend, the d16 halves,and/oratomics for writes). This PR is now just what that implementation doesn't cover:ds_read_u16at address 3 reads bytes 3-4 across the dword boundary, and the writes do the same. Before this, the lowering took halfwords as aligned and read or wrote the wrong bytes there. Reads now OR in the next dword's byte 0. Writes clear and set it with one moreand/oratomic pair, selected so other halfwords touch nothing past their own dword. No branch or loop. A newlds_straddlehelper sits next tolds_shift.shortcut:comment now says what the hardware keeps: the highest lane's value, measured on RDNA2. The lowering still leaves the OR of the values. A compare-exchange loop would be exact, but extra divergent loops have hung the AMD driver before.Tests
emit/lds_tests.rs: synthetic GFX10 compute programs (hand-encoded, nothing from any title), lowered, validated bydxil.dllwhen present, and run on the hardware GPU and WARP against a model of the console's LDS:They take the GPU tests' one-at-a-time lock (
valu_tests::ONE_AT_A_TIME). Onmainthey fail only for the straddling halfwords.Tested on Windows 11, NVIDIA RTX 5060 Ti and WARP: the LDS tests pass. In
cargo test --workspace --no-fail-fast, the only failures are 5 that fail the same way onmain70564ae on this machine:victory-shaderstride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosandsynthetic_tests::gathers_at_a_level_match_the_hardware, andvictory-gpudescriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views.cargo clippy -p victory-shader --all-targetsis clean, andcargo xtask policyis ok. Not run on AMD at this head.🤖 Generated with Claude Code