Skip to content

rdna2spirv: 8/16-bit MUBUF loads and stores (buffer_load_ubyte/ushort/d16, buffer_store_byte/short) - #1864

Open
LouisRiverstone wants to merge 3 commits into
ItsNotRexed:mainfrom
LouisRiverstone:buffer-sub-dword
Open

LouisRiverstone wants to merge 3 commits into
ItsNotRexed:mainfrom
LouisRiverstone:buffer-sub-dword

Conversation

@LouisRiverstone

@LouisRiverstone LouisRiverstone commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

The 8/16-bit MUBUF loads and stores raised Unsupported: all fourteen of buffer_load_ubyte, sbyte, ushort, sshort, the _d16/_d16_hi loads, and buffer_store_byte/short with their _d16_hi forms. These are the byte-address-buffer accesses compiled HLSL uses for sub-dword data. This is the MUBUF counterpart of #1666 (global).

Semantics (RDNA2 ISA, MUBUF):

  • buffer_load_{u,s}byte and {u,s}short zero- or sign-extend to 32 bits.
  • The _d16 loads write one 16-bit half of vdata (_hi writes the high one; a byte is zero- or sign-extended to 16 bits) and keep the other half.
  • buffer_store_byte/short write the low 8/16 bits of vdata; _d16_hi writes its high half.

Implementation: Gen.buffer_sub.

  • The address is buffer_address's, including swizzle.
  • The bounds check covers the access's own size, 1 or 2 bytes, through buffer_address(elem="fmt") with format 1 or 7, as for a typed element of that size. A byte load at the last byte of num_records is in range; a short there is not.
  • Out of range, a load gives 0 (for d16, in the half it writes; not measured on hardware), and a store writes nothing.
  • Each byte is its own access, so a 16-bit access that crosses a dword is exact. In a swizzled buffer, the next dword is step bytes on, selected at run time.
  • Stores merge each byte into its dword with atomic AND/OR, as the buffer byte format stores do, so neighbours are kept.
  • Inactive lanes neither load nor store. read_before_write_vgprs counts a d16 load's vdata as read.

Tests: tests/semantic/test_buffer_sub_dword.py, compute shaders in spirv_mini_interp with a raw (OOB_SELECT 3) V#:

  • each of the four stores at byte offsets 0–7, checking all three dwords around it
  • each of the ten loads at offsets 0–7, checking the value, the kept half and sign extension
  • loads and a store at the num_records edge
  • an inactive lane doesn't store
  • rejected forms
  • the first-read analysis

Without the change the file fails (119 errors, 1 failure); with it, 6/6 pass. python -I -m unittest discover -s tests/semantic: 1573 tests OK (2 skipped). That includes #1720's merge-order check on every module.

docs/design.md: new row after "Buffer bounds checking".

Tested on CPU only (semantic interpreter); no GPU run. No game files.

AI-assisted (Claude Code): I reviewed and ran the change and the tests.

@Impre-visible

Copy link
Copy Markdown

Tested f49e92c on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18): pass, no regression.

Native build of runtime/ from this head (Ninja, RelWithDebInfo, clang 23.1.5), llvm-mc 23.1.5, SPIRV-Tools v2026.4.

  • spirv-val on the modules the PR's semantic tests translate (test_buffer_sub_dword.py): distinct modules: 119, pass spirv-val: 119, rejected: 0
  • tests/semantic: 1650 OK
  • build.py: 185 shaders, 185 translated, 185 pass spirv-val; check.py: 122 of 157 pass, 35 skipped (wave64 without emulation, mesh fixtures)
  • run_gpu_tests.py: 178 shaders: 178 translated, 178 pass spirv-val; 133/173 passed, 40 skipped, 0 failed
  • LEONIDA_W64_EMULATE=1 run_gpu_tests.py: 164/173 passed, 9 skipped (8 fixtures run by the d3d12 tests, 1 needs a 64-wide fragment subgroup), 0 failed

The PR adds no GPU fixture, so the new loads and stores are covered only by the semantic tests here.

AI-assisted run (Claude). Synthetic programs only, no game files involved.

@josevictorp

Copy link
Copy Markdown
Contributor

Tested f49e92c on Linux 6.8 (Python 3.12.3, CPU only, semantic interpreter): pass.

  • python -I tests/semantic/test_buffer_sub_dword.py: 6 tests, OK. tests/semantic/test_global_sub_dword.py (the rdna2spirv: 8/16-bit global stores and d16 global loads #1666 counterpart): 5 tests, OK.
  • Negative control: the new file against tools/ from the merge base (6a6704d, via LEONIDA_TOOLS_DIR) gives 119 errors and 1 failure, as the description says.

Extra 1, linear buffer against a byte model: 700 random cases over all fourteen ops (496 loads, 204 stores). Each one draws 24 random buffer bytes, a byte offset 0-21 split at random between vaddr (offen), offset:N and a register soffset, random vdata, and NUM_RECORDS either past the data, exactly at the access, one or two bytes after its start, or random. 274 cases use the run-time V# in s[0:3] instead of a literal the translator folds; 231 are out of range and 67 are a 16-bit access at byte 3 of a dword. The model is "bytes little-endian, in range when offset + size <= NUM_RECORDS, a load out of range gives 0 in the part it writes, a store out of range writes nothing". No disagreement, and stores never touched a byte outside the access.

Extra 2, the swizzled path, which the PR's tests do not reach: a literal V# with SWIZZLE_ENABLE, stride 0, INDEX_STRIDE 0 and 1, offsets 0-11, for buffer_load_ushort, sshort, short_d16_hi, ubyte, buffer_store_short and byte_d16_hi (144 cases). Expected addresses from the formula quoted in test_buffer_swizzle.py with index 0, (offset / 4 * 4) * IS + offset % 4, so the second byte of a short at offset % 4 == 3 is in the dword 4 * IS bytes on. All 144 agree, including the stores' untouched neighbours. That covers the step branch in buffer_sub; it would be cheap to keep one such row in the test file.

Not checked here: nothing on a GPU, and the out-of-range d16 result is unmeasured, as the description already says. A swizzled V# with a non-zero stride or idxen was not tried.

AI-assisted review.

@caua-an

caua-an commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thanks for the implementation! I ran the focused semantic tests on Linux and got 6/6 for test_buffer_sub_dword.py and 5/5 for test_global_sub_dword.py at f49e92cd.

I noticed the new MUBUF operations do not yet have a dedicated GPU fixture. Is anyone already working on one? If not, I would be interested in a separate synthetic GPU test on RX 7600/RADV, initially covering sign extension and preservation of neighboring bytes. It would depend on this PR and use no game files.

AI-assisted.

@Spaghetih

Copy link
Copy Markdown
Contributor

Corpus check on my own 1.0.2.1 package (26,503 shaders disassembled with llvm-mc 21, gfx1013), comparing this PR's head with its own base, not with today's main.

6a6704df vs f49e92cd: no shipped shader uses buffer_load_ubyte/sbyte/ushort/sshort/*_d16* or buffer_store_byte/short, so this PR changes no game shader's translation. Its new path is covered by its own tests only.

AI-assisted (Claude Code).

@KiryaAfimin

Copy link
Copy Markdown

Tested f49e92cdffdcad91c84c1ea6970a032b542ae8c6 on a desktop RTX 4070, NVIDIA 621.01, Windows 11 Pro, Vulkan 1.4.357.

All 119 GPU dispatches matched the expected values from test_buffer_sub_dword.py: 80 loads and 32 stores covering all 14 opcodes at byte offsets 0–7, plus 6 bounds checks and 1 inactive-lane case.

For example, buffer_store_short at byte offset 3 wrote 0xd3c4 across a dword boundary. The three words read back as c4332211 887766d3 ccbbaa99, with all neighboring bytes preserved.

I used the PR’s translator unchanged and a local copy of vk_compute_test with host-side buffer initialization to match the fixture. Workgroups had one or two invocations to match the CPU cases. Every module passed spirv-val --target-env vulkan1.3 before dispatch.

AI-assisted

@x2Tweek

x2Tweek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Static review — PR #1864

Branch: buffer-sub-dword (head of PR #1864)
Commit: f49e92c rdna2spirv: 8/16-bit MUBUF loads and stores
Author: LouisRiverstone
State: OPEN, CONFLICTING with main (needs rebase before merge)

What it does

tools/rdna2spirv.py — implements 8/16-bit MUBUF loads and stores (previously all fourteen raised Unsupported):

  • buffer_load_ubyte/sbyte, buffer_load_ushort/sshort: zero- or sign-extend to 32 bits.
  • buffer_load_*_d16[_hi]: write one 16-bit half of vdata (_hi = high half; ubyte/sbyte extended to 16 bits) and keep the other.
  • buffer_store_byte/short[_d16_hi]: write the low 8/16 bits of vdata (the _d16_hi forms the high half), merging each byte into its dword with atomic and/or; neighbouring bytes are left alone.
  • Bounds check covers the access's own size (1 or 2 bytes), as for a typed element of that size (elem="fmt", format 1 or 7); out-of-range loads give 0, out-of-range stores write nothing.
  • Each byte is its own access, so a 16-bit access crossing a dword is exact; a store merges per byte. Inactive lanes neither load nor store; the first-read analysis counts a d16 load's vdata as read.
  • Dispatch added in buffer_store(); read_before_write_vgprs() extended so _d16 buffer loads keep a half.

tests/semantic/test_buffer_sub_dword.py — new value-test file run through spirv_mini_interp on the CPU (standard library only, no GPU, no game files): every op at byte offsets 0–7, the edge of num_records, an inactive lane, rejected forms, neighbour-byte preservation for stores, kept-half tracking for d16 loads.

docs/design.md — documents the new row "8/16-bit MUBUF loads and stores".

Reviewer recommendation

Approve (static review + CPU tests). The implementation matches the documented semantics: per-byte access granularity, dword-crossing exactness, merge stores with atomic and/or, bounds per access size, d16 half keep/combine, inactive-lane skipping. All 6 tests / 119 subtests pass; compileall clean.

Note: PR is marked CONFLICTING on GitHub — the author needs to rebase on main before it can be merged.

Not GPU-verified (the PR itself notes this; 8/16-bit MUBUF has no RDNA2 desktop part coverage per the design doc).

CPU test results

  • tests/semantic/test_buffer_sub_dword.py: 6 passed, 119 subtests
  • python -m compileall: clean on all changed .py files

AI-assisted. Reviewed with Claude Code.

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested f49e92c on macOS 27.2.1, Apple M4 (MoltenVK), LLVM 23.1.6, against its merge base 6a6704d, with my own 1.0.2.1 copy. Pass. One non-blocking note is at the end.

  • Tests: tests/semantic/test_buffer_sub_dword.py gives 6/6 OK. Negative control: the same file against the base tools/rdna2spirv.py gives 119 errors and 1 failure, the same numbers you report. The full semantic suite passes 1,650 OK, and compileall is clean.

  • Corpus: none of the 26,503 gfx1013 listings contains any of the fourteen opcodes. 18,865 listings use MUBUF/MTBUF, but only the dword, format, tbuffer and atomic forms. The change therefore moves no translated or valid count on real shaders today.

  • Control slices (--wave64-emulate --mesh-compute --f16-interp-fallback):

    • --limit 200: 200/200 translated and 200/200 spirv-val-valid, on base and on the PR.
    • --shard 0/132 (201 shaders spread over the corpus): 197/197 on both, with the same 4 refusals (--f16-interp-fallback reasons).
    • Every .spvasm is byte-identical between base and PR. This includes the listings with buffer_load_format_d16_*, so the read_before_write_vgprs change, which excludes format, leaves them alone.
  • Hand-written shaders, with the build flags: 504 shaders covering all 14 ops in every combination of:

    • 3 V# kinds: literal raw, literal swizzled, and run-time.
    • 4 address forms: offset:3, offen, idxen, and idxen offen with an SGPR soffset and glc slc.
    • 3 shader kinds: wave32 CS, wave64 CS (emulated, with cross-lane ops around the access), and PS.

    llvm-mc 23.1.6 accepts every line for gfx1013. Base refuses all 504. The PR translates 504/504, and all 504 pass spirv-val.

  • Values beyond the PR's tests (spirv_mini_interp): your tests use a literal raw V# only, so I added 10 checks. All 10 give the expected words:

    • A swizzled V# (index stride 8), with a literal and with a run-time word1: a buffer_load_ushort and a buffer_store_short at offset:3 take their second byte from the next element, 32 bytes on, and a buffer_load_ubyte at offset:5 reads byte 1 of that element.
    • A run-time raw V#: a buffer_load_sshort across a dword.
    • A buffer_load_short_d16_hi that straddles num_records: it gives 0 in the high half and keeps the low half.
  • Note (non-blocking): in a swizzled buffer, the code decides whether the second byte of a 16-bit access crosses into the next element from the low two bits of the final address (lo & 3 == 3, tools/rdna2spirv.py:1259-1261). That address includes V# base + soffset. In swizzled addressing the element boundary comes from offset % 4, where offset is inst_offset + the vaddr offset, without soffset. The two agree whenever base + soffset is a multiple of 4. They differ only for an unaligned soffset/base in a swizzled buffer, which nothing in the corpus does and which isn't measured on hardware. ol from buffer_address would be the exact term if buffer_address returned it.

  • Same as global_sub: two lanes storing to the same byte in one instruction run AND then OR, so the byte can end up as the OR of both values instead of one of them. Both are racy in the program anyway. I mention it only because it differs from hardware, which keeps one value.

No game data. AI-assisted.

@wildheathen

Copy link
Copy Markdown
Contributor

Checked on the 52 XboxBvhBuilder.dll programs (1.0.2.1 package; extracted, unpacked and disassembled as in docs/embedded_shaders.md, with llvm-mc 21 and --mcpu gfx1013; the shaders stay local). This branch (f49e92c, 112 commits behind main) translates 44 of 52, all spirv-val-valid. The 8 it leaves are global_atomic_fmax/fmin (7 programs) and LeafRehydration (tbuffer_load_format_x GFX10_FORMAT_8_UINT, which main already handles).

What only this PR provides for the builder is buffer_store_short. #1968 translates 51 of 52, and the one left, Box16Rehydration, stops at buffer_store_short. The two together should cover all 52. I did not run them on a GPU. CPU only, Windows 11.

AI-assisted.

@throny

throny commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Package check of f49e92cd, on my own Xbox Series 1.0.2.1 copy, counts only. The 52 programs embedded in XboxBvhBuilder.dll were extracted and disassembled with the repo's tools:

  • On main (49475796), 51 of 52 translate and pass spirv-val. The one that fails is Box16Rehydration: Unsupported: buffer_store_short. It's the only program in that DLL that uses the instruction.
  • With this PR (f49e92cd), Box16Rehydration translates and passes spirv-val. That makes all 52 of 52.

This unblocks TEST-376, which runs the three rehydration programs on a GPU against the CPU reference in #2205. GitHub currently shows this PR as conflicting with main.

AI-assisted. Windows 11, SPIRV-Tools 2026.4.

@IAmNotSiob

Copy link
Copy Markdown
Contributor

hey @LouisRiverstone, this went conflicting after the round-39 merges, so i rebased it onto main 49475796 on my fork in case it saves you time :) (not pushing to your branch)

git fetch https://github.com/IAmNotSiob/Leonida mubuf-1864-rebased
git reset --hard FETCH_HEAD   # on buffer-sub-dword, then force-push

heads-up, there was a semantic conflict git didn't flag: main now has its own Gen.BUFFER_SUB class attribute (the plain buffer_load_{u,s}byte/{u,s}short, GPU-tested in TEST-510) defined after yours, so it silently shadowed your table and the d16 loads / byte+short stores fell through to Unsupported. in the rebase:

  • your table is BUFFER_SUB16 and only has the 10 d16 loads + stores; the 4 plain loads stay on main's handler
  • buffer_address(..., elem=nbytes) like main's sub-dword loads (instead of elem="fmt", fixed_fmt=1/7)
  • conflict in read_before_write_vgprs merged (kept main's v_pk_fmac_f16)
  • design.md: just your row added

plus one extra commit (mine, drop it if you don't want it): GPU fixture cs_buf_sub16.asm. one lane does buffer_store_byte, _byte_d16_hi, _short, _short_d16_hi (crossing a dword at byte 7), reads back with all six d16 loads, and does an out-of-range short_d16 load + byte store through a V# with num_records 24.

results on the rebased head 258cb7c5:

  • test_buffer_sub_dword.py + test_buffer_load_sub.py: 15/15
  • full tests/semantic: 2572 pass, 1 fail = test_fma_khr spirv-val, which is just cs3's SPIRV-Tools being too old (same on main)
  • tests/test_translate.py + test_shader_checks.py: 630 pass
  • GPU, NVIDIA RTX 6000 Ada (615.71.09, Linux): run_gpu_tests.py --filter cs_buf_sub16 PASS, 0xbbcc2244 0x66eeeeee 0xeeeeee55 0xffbb0044 0xbbcc5566 0x0022ffcc 0x99990000 0xeeeeeeee; cs_store still PASS

not checked: AMD hardware, d16 out-of-range on real RDNA2 (your "not measured" note still stands).

AI-assisted (Claude Code).

TL;DR: rebased onto main on my fork. Fixed a hidden name clash with main's BUFFER_SUB that would have broken the d16 ops. Added a GPU fixture, which passes on NVIDIA.

Vonsek added a commit to Vonsek/Leonida that referenced this pull request Nov 22, 2026
… rule (buffer_store_short) left (PROC-120)

Recounted with main 4947579 on the 1.0.2.1 package (counts only): 52/52 unpack,
42 clean and 10 with invalid words in the disassembly, 51 translate and pass
spirv-val. The four rules embedded_shaders.md listed are three since 427c137
(ItsNotRexed#1968); Box16Rehydration stops at buffer_store_short (ItsNotRexed#1864). d3d12_vulkan.md
and the docs index quoted 41/42 and four rules in seven places.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Rebased on main (thanks @IAmNotSiob for the offer). main meanwhile got buffer_load_{u,s}byte/short from 427c137 (buffer_load_sub, a table also named BUFFER_SUB), so this PR now keeps only what main lacks: the d16 loads and the 8/16-bit stores (BUFFER_SUB16), including the buffer_store_short that @wildheathen and @throny found keeps Box16Rehydration from translating. test_buffer_sub_dword.py still checks the plain loads, and main's code passes it. Suite 4148 OK. @sovljanskii's two notes (the swizzled cross-element test uses the final address's low bits, which includes base + soffset; two lanes on one byte end as the OR) are as described and not changed here.

Vonsek added a commit to Vonsek/Leonida that referenced this pull request Nov 22, 2026
…esn't go stale (review nit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adriaespii added a commit to adriaespii/Leonida that referenced this pull request Nov 22, 2026
Update docs/embedded_shaders.md §4 and §5 and related references in
docs/d3d12_vulkan.md to reflect current main: 51 of 52 XboxBvhBuilder.dll
compute shaders now translate and pass spirv-val since ItsNotRexed#1871
(GFX10_FORMAT_8_UINT) and ItsNotRexed#1968 (427c137: global_atomic_fmax/fmin and
buffer_load_ushort) landed.

Only Box16Rehydration remains blocked, awaiting buffer_store_short (ItsNotRexed#1864).

Claim: ItsNotRexed#2300 (comment)
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
Update docs/embedded_shaders.md §4 and §5 and related references in
docs/d3d12_vulkan.md to reflect current main: 51 of 52 XboxBvhBuilder.dll
compute shaders now translate and pass spirv-val since #1871
(GFX10_FORMAT_8_UINT) and #1968 (427c137: global_atomic_fmax/fmin and
buffer_load_ushort) landed.

Only Box16Rehydration remains blocked, awaiting buffer_store_short (#1864).

Claim: #2300 (comment)
Vonsek added a commit to Vonsek/Leonida that referenced this pull request Nov 22, 2026
…ed; the M6 row's count

The merge round took this PR's first commit and ItsNotRexed#2503, which say the same thing,
so section 4 carried both: the then/now table and, after a stray table row, the
bullet list and a second blocker table. Keep the table (now without 'open' after
ItsNotRexed#1864) and drop the repeat. d3d12_vulkan.md's M6 milestone row still said 42
pass and four rules left.
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Rebased onto main (130dd56c) and squashed the two commits into one. The diff is the same: the d16 loads and the 8/16-bit stores (BUFFER_SUB16). The plain loads stay main's buffer_load_sub. The only conflict was the read-before-write condition, which now combines main's longer op list with this PR's buffer_load_*_d16 clause. #1885 touches the same line, so whichever merges second needs a one-line rebase.

test_buffer_sub_dword.py, test_buffer_load_sub.py and test_global_sub_dword.py pass. The full semantic suite has only main's 10 known failures. The Windows CI failure on the previous head was d3d12_msaa_draw, which is also failing on main.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 130dd56c (base main aa2988cc) on an NVIDIA GeForce RTX 5070 Ti (Blackwell, driver 616.56, subgroup 32..32), Windows 11 10.0.26300; translator from this head, runtime test programs built from aa2988cc (MSVC 19.44): pass. scripts/run_gpu_tests.py: 164/210 passed, 46 skipped (wave64 fixtures without emulation on a 32-wide GPU), 0 failed, the same result as main on this machine for every test (diffed test by test). This PR adds no GPU fixture, so the run shows no regression in the existing suite rather than checking the new sub-dword MUBUF paths on hardware. No game files. AI-assisted (Claude Code).

@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 130dd56c (the rebased head) on NVIDIA GeForce RTX 3060 Ti (subgroup 32..32), driver 580.173.02, Linux (kernel 6.18), Python 3.14: pass. This adds a GPU run to the CPU-only results in the description.

  • scripts/run_gpu_tests.py: 164/210 passed, 46 skipped, 0 failed, the same as main. The translator change breaks none of the existing GPU tests.
  • ctest: 47/47 passed.
  • pytest tests/semantic/test_buffer_sub_dword.py: 6 passed, 119 subtests passed. With tools/ from the merge base (aa2988c): 85 failed, 3 passed.

No game files. AI-assisted (Claude Code).

buffer_load_{u,s}byte_d16[_hi], buffer_load_short_d16[_hi] and
buffer_store_byte/short[_d16_hi] (BUFFER_SUB16): one 16-bit half of vdata
is loaded or stored, the other kept; bounds checked at the access's own
size; stores merge each byte with atomic and/or. The plain
buffer_load_{u,s}byte / {u,s}short are main's buffer_load_sub; the tests
check them too. Fixes Box16Rehydration's buffer_store_short.
@DenRakEiw

Copy link
Copy Markdown

Tested e154905 on Windows 11, Python 3.12.10 (CPU/semantic check only, no GPU, no game files): pass.

  • Trial-merged onto origin/main (98fa503): merges cleanly; git diff --check clean.
  • python -m unittest discover -s tests/semantic -p test_buffer_sub_dword.py: 6/6 OK.
  • python -I tests/test_docs_design_rows.py: 4/4 OK.
  • Scope: CPU semantic tests and doc-row validation only (no GPU hardware run here). No blocking issues.

AI-assisted review (Gemini).

@caua-an asked on ItsNotRexed#1864 for a dedicated GPU fixture. Lane 0 seeds three
dwords and loads into a register holding 0xBEEF1234, so each of the six d16
loads (ubyte/sbyte/short, low and high half) shows the half it writes, the
half it keeps and sbyte's sign extension; buffer_store_byte_d16_hi and
buffer_store_short_d16_hi take bits 23:16 / 31:16. Passes on llvmpipe with
LLVM 21 and 23; main's translator can't translate it. Registered in check.py,
run_gpu_tests.py and regen_fixtures.py; tests/semantic/
test_buffer_sub16_fixture.py runs it on the CPU. docs/design.md row points
at it.
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

@caua-an asked earlier whether these MUBUF ops would get a dedicated GPU fixture, and now they have one: runtime/test/shaders/cs_w32_buffer_sub16.asm (9739594f).

  • What it covers: lane 0 seeds three dwords and loads into a register holding 0xBEEF1234. So each of the six d16 loads (ubyte/sbyte/short, low and high half) shows the half it writes, the half it keeps, and sbyte's sign extension. buffer_store_byte_d16_hi / buffer_store_short_d16_hi are checked to take bits 23:16 / 31:16.
  • llvmpipe (Mesa 26.0.8): passes with LLVM 21 and 23, all eight words as derived in the header. main's translator can't translate it, so it covers this PR's ops.
  • Also added: tests/semantic/test_buffer_sub16_fixture.py runs it on the CPU and checks that both runners expect the same words. The docs/design.md row now points at the fixture instead of saying Not GPU-verified.

Real-GPU runs are welcome.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 9739594f2b65dacbe0a6c394010a28ca23790073 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

The new wave32 fixture cs_w32_buffer_sub16 passed on hardware with the compute harness built from this head. All eight output words matched:

beef00aa 00aa1234 beefffaa ffaa1234 beef8899 88991234 1122cd44 abcd7788

The signed byte loads extended 0xaa to 0xffaa in either destination half, while the unsigned loads produced 0x00aa. The byte and short stores also preserved their neighboring bytes. The shader passed spirv-val. This was a filtered run of the new fixture.

AI-assisted verification.

@tylerstraub ran the new fixture on an NVIDIA RTX 5090 (595.99.02, Linux): all
eight words. The row named llvmpipe only.
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Thanks @tylerstraub. That's the fixture's first real-GPU run: all eight words, including sbyte's 0xffaa in both halves and the neighbouring bytes kept by the stores. The docs/design.md row now names the RTX 5090 next to llvmpipe (fe4feee9).

@CryingLaughing

Copy link
Copy Markdown
Contributor

Tested fe4feee9 on Windows 11 (build 26200), GeForce RTX 4080, NVIDIA 621.01, MSVC 19.44, LLVM 23.1.6 and Khronos validation 1.4.357.

run_gpu_tests.py --filter cs_w32_buffer_sub16 --require-pass passed 1/1, including spirv-val. A second run with GPU-assisted shader instrumentation at subgroup size 32 matched all eight words again. There were zero Vulkan validation errors. The only warnings were validation-layer setup notices.

BEEF00AA 00AA1234 BEEFFFAA FFAA1234 BEEF8899 88991234 1122CD44 ABCD7788

As a control, the base translator at 98fa503f received the same synthetic disassembly and stopped at buffer_load_ubyte_d16 without emitting a module. All three focused semantic tests passed on the PR.

AI-assisted (Codex).

@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Thanks @CryingLaughing (RTX 4080, LLVM 23, GPU-assisted validation). The base translator stopping at buffer_load_ubyte_d16 confirms the fixture only covers this PR's ops. Nothing is pending.

@YaBulochka

Copy link
Copy Markdown
Contributor

Independent run of head fe4feee9 on two more devices, native Linux Vulkan, the same fixture:

Device Driver Result
AMD Ryzen 5 9600X iGPU (gfx1036, RADV RAPHAEL_MENDOCINO), Mesa 27.0.0-devel Vulkan 1.4.363, subgroup 32..64 1/1 pass, spirv-val pass
NVIDIA GTX 1660 SUPER (TU116), Linux 7.3.3 NVIDIA 620.70.06, Vulkan 1.4.357, subgroup 32..32 1/1 pass, spirv-val pass

Both GPUs return the same words, bit for bit:

0xBEEF00AA 0x00AA1234 0xBEEFFFAA 0xFFAA1234 0xBEEF8899 0x88991234 0x1122CD44 0xABCD7788

The base translator (3faac557) refuses the same .s with buffer_load_ubyte_d16, so the fixture does exercise the new rules. The PR's CPU tests (test_buffer_sub_dword, test_buffer_sub16_fixture) also pass here.

One gap for the M6 claim: the fixture has the _d16_hi forms but no plain buffer_store_byte/buffer_store_short, and docs/embedded_shaders.md names plain buffer_store_short as the blocker for Box16Rehydration. A throwaway probe (not in the repo) with two plain byte stores and two plain short stores, the second crossing a dword boundary, gives 0xDD99EEBB 0x34ABCD44 0x00000012 on both RADV and Turing and passes spirv-val. Adding those two stores to this fixture (or a small second one) would make the GPU evidence match the rule that actually blocks the 52nd program. Closing 52/52 itself still needs Box16Rehydration translated and run (tools/bvh_gpu_smoke.py), not only the synthetic ops.

Note: the PR branch is 8 commits behind main 3faac557; it will need a rebase before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.