Skip to content

Tests: GPU test for tbuffer_store_format_d16_x and d16_xyz (EGEN-GPU-TBUF-D16) - #2700

Open
Vonsek wants to merge 3 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-tbuf-d16-store
Open

Vonsek wants to merge 3 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-tbuf-d16-store

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-GPU-TBUF-D16, #2516 (comment)

What and why

tbuffer_store_format_d16_x and tbuffer_store_format_d16_xyz are translated but no test runs them (the d16_xy and d16_xyzw stores are in cs_tbuffer_store; the tbuffer d16 loads are in #2039 and earlier tests). This adds cs_w32_tbuf_d16_store, a one-lane wave32 compute dump:

  • d16_x into 16_FLOAT (the f16 as it is) and 8_UNORM (1.0 gives 0xff), with junk in the high half of the data register that must not be read.
  • d16_xyz into 16_16_16_16_FLOAT (w not given, stored as 0), 8_8_8_8_UNORM (w = 0) and 16_16_FLOAT (z dropped, the next dword untouched).
  • d16_x into 16_16_FLOAT (y is in the format and not given, so 0).

The expected words and their derivation are in the .asm header. They follow the rules cs_tbuffer_store documents (the instruction's format replaces the V#'s; a store writes the format's whole element, components the format has but the instruction omits are 0, components it lacks are dropped), which were measured on gfx1035 there; these two forms were derived from them by hand, not measured separately. Every word came out as derived on both GPUs, so there is no translator change.

The shader is also a semantic fixture (regen_fixtures.py), checked in tests/semantic/test_value_semantics.py (TbufferD16StoreWords) against the hand constants and a plain-Python reference of the bytes each store writes.

Tested

  • NVIDIA GeForce RTX 5080 (driver 616.92, device line NVIDIA GeForce RTX 5080 (subgroup 32..32)): run_gpu_tests.py --filter cs_w32_tbuf_d16, pass.
  • AMD Radeon iGPU, RDNA2, Ryzen 9 9950X3D (driver 26.10.1, AMD Radeon(TM) Graphics (subgroup 32..64)): pass.
  • Negative control on the RTX 5080: making the d16 unpack always take the low half (16 * (i % 2) -> 0 in the typed store) fails the GPU test (out[2], out[4] and out[5] change) and the semantic test; reverted.
  • python -m unittest discover -s tests/semantic, python tests/semantic/regen_fixtures.py --check and python -I tests/test_shader_checks.py pass.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No new rule; tests only.)

AI-assisted.

…TBUF-D16)

cs_w32_tbuf_d16_store stores d16_x and d16_xyz into 16_FLOAT, 8_UNORM,
16_16_16_16_FLOAT, 8_8_8_8_UNORM and 16_16_FLOAT regions and reads the dwords
back; the words are derived by hand in the header. Also a semantic fixture
with a plain-Python reference of the bytes each store writes.

AI-assisted.
@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Independent RTX 5070 / 621.24 Vulkan run of ddf78fa: the submitted fixture matched all 64 words, including sentinels, and all 33 test_value_semantics.py tests passed.

I also swept all 65,536 binary16 bit patterns through dynamic d16_x and d16_xyz stores in wave32 and emulated wave64. Both modes matched the finite and infinity encodings for 16_FLOAT and RGBA16_FLOAT, and every byte for RGBA8_UNORM, RGBA8_SINT and RGBA8_UINT. Packed d16_x stores from adjacent lanes preserved each other's halfwords. An RGBA16_FLOAT store with only seven bytes in range wrote nothing, the exact eight-byte case wrote the full element, and a V# with FORMAT=0 suppressed the store. All modules validated for Vulkan 1.2.

One limit on describing 16_FLOAT as a bit-preserving copy: on this driver, every NaN input (both signs, quiet and signaling) came back as 0x7fff in both forms. I checked NaN class separately from exact finite/infinity results. Native RDNA2 NaN payload behavior for these forms is still unmeasured, so this is a Vulkan observation, not an ISA claim. Synthetic inputs only.

@ricarmandoagent

Copy link
Copy Markdown

Ran ddf78fab602a8b94ad2de364416c7121fcafcaa0 (base 49475796) on NVIDIA GeForce RTX 4060 (Ada, AD107; Vulkan subgroupSize 32..32), driver 620.70.06, Vulkan 1.4.357, Bazzite 45 / Linux 7.3.4, Python 3.15.2, llvm-mc 23.1.5, shared prebuilt harness.

PATH=$HOME/.local/bin:$PATH python3 -I scripts/run_gpu_tests.py --build /home/armand/src/Leonida/runtime/build/linux --filter cs_w32_tbuf_d16 -> 1 shader translated, 1 pass spirv-val, 1/1 PASS with the eight expected words 4008590336 4008636159 1073757184 16896 16711935 1073757184 4008636142 15360. First RTX 4060 / driver 620.70.06 run of this fixture.

Negative control on this machine: with 16 * (i % 2) -> 0 in the d16 unpack of tools/rdna2spirv.py (the mutation the description describes), the same filter fails 0/1 and changes exactly out[2], out[4] and out[5]:

  FAIL  cs_w32_tbuf_d16_store  4008590336 4008636159 1006648320 16896 16777215 1006648320 4008636142 15360
0/1 passed

Restored (git status clean). So the fixture really checks which half of the d16 register each component reads, and that a format component the instruction omits is written as 0.

python3 -I -m unittest discover -s tests/semantic -p test_value_semantics.py -k TbufferD16Store -> 2 tests OK. On a plain origin/main 49475796 tree the filter answers error: --filter 'cs_w32_tbuf_d16' matched no GPU test cases (test-only PR, no before side).

Limit of this GPU: the format rules the words are derived from were measured on gfx1035, and the 4060 can only confirm the translator's implementation of those rules on Ada, not the RDNA2 hardware behaviour. On this fixture that limit is small: it has no NaN input, so the driver NaN canonicalisation reported in the comment above cannot change any of its words.

Verdict: LGTM.

AI-assisted review.

@TurboSosiska304

Copy link
Copy Markdown

Tested ddf78fa on AMD Radeon RX 570 (Polaris 10, gfx803), RADV Mesa 26.2.6-arch3.1, Vulkan 1.4.354, CachyOS; native 64-wide compute subgroups (64..64).

python3 -I scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w32_tbuf
  PASS  cs_w32_tbuf_d16_store  4008590336 4008636159 1073757184 16896 16711935 1073757184 4008636142 15360
1/1 passed

Worth noting for this device class: the fixture is named cs_w32, but nothing pinned 32 lanes here — it ran at the native 64-wide width and produced the expected words, so the check is not wave-width dependent. A GCN4 part on RADV is a third generation/driver stack for this store form.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested ddf78fa on NVIDIA GeForce RTX 5070 Ti (Blackwell), NVIDIA 620.73.04, CachyOS Linux. Built the harness from the PR and ran scripts/run_gpu_tests.py --filter cs_w32_tbuf_d16_store with LEONIDA_W64_EMULATE=0 and =1. The synthetic module passed SPIR-V validation and all eight expected readback words matched in both runs. All 33 focused value-semantics tests passed. AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested ddf78fab602a8b94ad2de364416c7121fcafcaa0 on AMD Radeon Pro V540 (RDNA1, Navi 12 / gfx1011, PCI 1002:7360, RADV Mesa 25.2.8-0ubuntu0.24.04.4, Ubuntu 24.04.4, kernel 7.0.0-31-generic, Vulkan device 1.4.318, subgroup 32..64): pass. Independent RDNA1/RADV data point for this D16 texture-buffer fixture.

  • Command: DRI_PRIME=pci-0000_1c_00_0! python -I scripts/run_gpu_tests.py --filter cs_w32_tbuf_d16_store --build runtime/build/linux: 1/1 passed, all eight words exact (0xEEEE3C00 0xEEEEEEFF 0x40003C00 0x00004200 0x00FF00FF 0x40003C00 0xEEEEEEEE 0x00003C00). Same on two more pinned cards (1f:00.0, ca:00.0).
  • Command: python -I scripts/run_gpu_tests.py --build runtime/build/linux: 157/186 passed, 28 skipped, 1 failed (191 shaders translated, 191 pass spirv-val). Clean base 49475796 gave 156/185, 28 skipped, 1 failed — the only difference is the new passing fixture, so no regression. The single failure is the pre-existing cs_w32_salu64 RDNA1/RADV issue.
  • Command: pytest tests/semantic/test_value_semantics.py -q: 33 passed.

Tools: llvm-mc 21.1.8 with AMDGPU target, SPIRV-Tools 2026.1, GCC 13.3.0, Python 3.12.3. No code was edited or pushed; only synthetic fixtures were used.

AI-assisted.

runtime/test/shaders/check.py
scripts/run_gpu_tests.py

AI-assisted.
runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py

AI-assisted.
@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 2d0504f338580fa860aefd4285d9b2a5d4a2517f on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

The rebased head passed the targeted native wave32 check on Linux. The synthetic cs_w32_tbuf_d16_store fixture translated, passed spirv-val, and matched all eight expected words:

eeee3c00 eeeeeeff 40003c00 00004200 00ff00ff 40003c00 eeeeeeee 00003c00

The two narrow writes preserved the surrounding fill bytes. The three-component write to the two-component float format also left the following word at its original fill value. This run covered the single typed-store fixture.

AI-assisted (Codex).

AI-assisted verification.

@amarovndres

Copy link
Copy Markdown

Tested 2d0504f3 on AMD Radeon RX 9060 XT (RDNA4, discrete, subgroup 32..64), AMD 26.10.1 (32.0.32015.7029, LLPC, Vulkan 1.4.359), Windows 11 Pro (build 26200): pass.

  • scripts/run_gpu_tests.py (full suite; test programs built from this head with llvm-mingw, llvm-mc 23.1.6): 197/211 passed, 14 skipped, 0 failed. main d0835dd9 on the same machine: 196/210 passed, 14 skipped.
    • PASS cs_w32_tbuf_d16_store 4008590336 4008636159 1073757184 16896 16711935 1073757184 4008636142 15360
  • tests/semantic/test_value_semantics.py: 41 tests, OK

AI-assisted (Claude Code). Synthetic shaders only, no game files.

@thesubtleties

Copy link
Copy Markdown

Tested 2d0504f3 on NVIDIA GeForce RTX 3080 (Ampere, subgroup 32..32), driver 620.70.06, CachyOS Linux 7.3.4, LLVM 23.1.5: pass.

LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux: 215/215 translated and pass spirv-val; 196/211 GPU tests passed, 0 failed, 15 skipped (14 run by other tests, 1 needs a 64-wide fragment subgroup). cs_w32_tbuf_d16_store PASS (8/8 words). tests/semantic/test_value_semantics.py: 41/41 OK.

@Proudnoob4

Copy link
Copy Markdown
Contributor

SHADER-495 — aggregate inventory on my own 1.0.2.1 disassembly corpus. Across all 26,503 .s listings (including dot-prefixed files), I found zero decoded tbuffer_store_format_d16 instructions for each of _x, _xy, _xyz, and _xyzw; zero listings contained the prefix.

An independent case-insensitive text search agreed. As a positive control, the broader tbuffer_load_format / tbuffer_store_format mnemonic prefixes had 52,890 matches across 10,278 listings. This is a disassembly inventory, not a raw-opcode census: it does not rule out encodings that the disassembler did not render as instructions. No game data or shader names attached.

@lunarminus

Copy link
Copy Markdown

Tested 2d0504f3 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • python -I scripts/run_gpu_tests.py --build runtime/build/linux (full suite, test programs from a d0835dd9 build since the PR changes no C++/CMake): 215 translated, 215 pass spirv-val. 197/211 passed, 14 skipped, 0 failed with LEONIDA_W64_EMULATE unset, and the same with LEONIDA_W64_EMULATE=1.
  • Compared each PASS/FAIL/SKIP line with d0835dd9 without the PR on the same machine (196/210 passed, 14 skipped, both modes). The only difference is the new fixture. Nothing else changed status in either mode:
    • PASS cs_w32_tbuf_d16_store 4008590336 4008636159 1073757184 16896 16711935 1073757184 4008636142 15360 (8/8 words, both modes)
  • --filter cs_w32_tbuf_d16: 1/1 passed with emulation off and with LEONIDA_W64_EMULATE=1. On plain d0835dd9 it gives error: --filter 'cs_w32_tbuf_d16' matched no GPU test cases.
  • python -I -m unittest discover -s tests/semantic -p test_value_semantics.py: 41 tests OK, including both TbufferD16StoreWords tests. tests/semantic/regen_fixtures.py --check passes. tests/test_shader_checks.py: 75 tests OK.
  • The full tests/semantic discover ran 7458 tests: 7 failures and 2 errors in test_cmp_class_f64, test_loop_ballot_barrier and test_mutations. Those three modules fail the same way on d0835dd9 without the PR, so the failures are not from this change.

AI-assisted (Claude Code).

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2d0504f on Intel UHD 630 (CFL GT2, subgroup 8..32), Mesa 25.2.8 ANV, Ubuntu 24.04, LEONIDA_VK_DEVICE=Intel: pass.

  • scripts/run_gpu_tests.py --filter cs_w32_tbuf_d16: PASS cs_w32_tbuf_d16_store 4008590336 4008636159 1073757184 16896 16711935 1073757184 4008636142 15360; 1/1 passed. LEONIDA_VK_DEVICE=NoSuchDevice fails with "no Vulkan physical device matches", so the Intel device ran it.
  • tests/semantic test_value_semantics.TbufferD16StoreWords: Ran 2 tests, OK. regen_fixtures.py --check: clean. tests/test_shader_checks.py: Ran 75 tests, OK.

AI-assisted.

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.