Skip to content

rdna2spirv: mesh LDS need counts read2/write2 b32 offsets as dwords (SHADER-562) - #3436

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Raavve:shader-562
Nov 23, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Raavve:shader-562

Conversation

@Raavve

@Raavve Raavve commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Diego · project thread

Claimed in the coordination issue as: SHADER-562 (claim: #3047 (comment))

What and why

The compute-shader half of SHADER-562 landed in ce7a348 (SHADER-309): the CS LDS-need scan uses ds_const_extent, where offset counts bytes and offset0/offset1 count elements of the access's own size (4 bytes for _b32, 8 for _b64, x64 for st64). With it, the corpus's two 1024-lane 32 KiB wave64 CS that used to be refused under --wave64-emulate translate on main (lds_bytes 41,372).

The mesh-shader LDS-need scan still counted every read2/write2 element as 8 bytes (* 2 + 4 dwords). This PR makes the mesh loop use ds_const_extent too, so a 32 KiB mesh shader with st64 b32 offsets inside its allocation keeps a 32 KiB array instead of doubling it.

Tested

  • New tests/semantic/test_ms_lds_need.py (hand-written mesh programs with a PSV0 part, no game data): 3/3 pass with this change, 3/3 fail against main's translator.
  • python -m unittest discover -s tests/semantic: 7,325 tests OK (expected failures=1).
  • python -m compileall -q tools tests: clean.
  • Corpus (own Xbox 1.0.2.1 copy, Windows 11, RTX 4060 with driver 610.88, llvm-mc 21.1.8, existing disassembly): 0 of 9,282 mesh shaders change. No mesh shader has a constant ds offset past its PSV0 group-shared size, so this is a correctness fix for the rule, not a corpus change.
  • Main alone (f847748c) translates the 2 former CS failures under --wave64-emulate (spot-checked: wave64, lds_bytes 41,372).
  • Not run: a full corpus retranslation on this branch, vk_pipeline_check, GPU execution.

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: the mesh loop now follows the existing SHADER-309 sizing rule.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…SHADER-562)

The mesh-shader LDS-need scan still counted every read2/write2 offset element as 8 bytes (plus 4 dwords of slack).
The compute path has used ds_const_extent since ce7a348 (SHADER-309): offset counts bytes, offset0/offset1 count
elements of the access's own size (4 bytes for _b32, 8 for _b64, x64 for st64). The mesh loop now uses it too, so a
32 KiB mesh shader with st64 b32 offsets inside its allocation keeps a 32 KiB array instead of doubling it.

No corpus mesh shader changes (none has a constant ds offset past its PSV0 group-shared size); this is a
correctness fix for the rule, pinned by tests/semantic/test_ms_lds_need.py.

Claude-Session: https://claude.ai/code/session_01P3Q8kaLxCA6TbtZQ3KsbQq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Raavve Raavve changed the title rdna2spirv: read2/write2 b32 offsets count dwords in the LDS need (SHADER-562) rdna2spirv: mesh LDS need counts read2/write2 b32 offsets as dwords (SHADER-562) Nov 22, 2026
@TreXito

TreXito commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested 4902cbb1 (base f847748c) on NVIDIA GeForce RTX 3060 Ti (Ampere), driver 580.173.02 (Vulkan 1.4.312), Linux (Ubuntu 26.04 container on a TrueNAS 26.0 host): pass.

  • tests/semantic/test_ms_lds_need.py (pytest, in the same container): 3 passed on this head. With tools/ from f847748c all 3 fail, as your body says: ds_write2_b32 ..., 255 gives 1024 dwords instead of 256, and ds_write2_b64 gives 1024 instead of 512.
  • scripts/run_gpu_tests.py, whole suite: 152/199 passed, 46 skipped, 1 failed, identical per test to main f847748c on this card. The failure is ps_sdwa_f16_const, the NVIDIA f16 denormal flush on main (rdna2spirv: widen f16 denormal operands without UnpackHalf2x16 (NVIDIA reads them as 0) #3220 / rdna2spirv: declare DenormPreserve 16 so a driver keeps f16 denormals (SHADER-526) #3040), not this PR.
  • The mesh fixtures ms_tri, ms_clip, ms_f16_pack and ms_v5_workgroup pass, so mesh translation still runs on the GPU. cs_lds and cs_lds_b64_cmpst pass too.
  • ctest on the Linux build (CMake + Ninja, GCC): 41/41 passed.
  • Not covered: no GPU fixture is a mesh shader with read2/write2 offsets near its LDS size, so the smaller array wasn't run on hardware. The 64-wide mesh and LDS fixtures skip on this card (subgroup 32 only).

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

@zGLados

zGLados commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 4902cbb against main f847748c on Windows 11 26300 with my own 1.0.2.1 copy (counts only): pass.

All 9,282 corpus mesh shaders translated natively (no --wave64-emulate), 4 shards + --merge, llvm-mc 21.1.8, SPIRV-Tools from Vulkan SDK 1.4.363: 9,282/9,282 translate and pass spirv-val on both sides; 0 modules change, and index.json (including every lds_bytes) is identical. This matches your corpus result: no mesh shader in the corpus has a constant ds offset past its group-shared size. The unchanged modules are the ones main already builds on this GPU (AMD RX 7700 XT, driver 26.10.1).

No game data. AI-assisted.

@justr4mzi

Copy link
Copy Markdown
Contributor

Tested 4902cbb1 on Windows 11 25H2 (build 26200.9974), AMD Radeon RX 6700 XT (RDNA2, native wave64), driver AMD proprietary 26.11.2 (Vulkan 1.4.315), llvm-mc 21.1.8 native, Vulkan SDK 1.4.363.0 (SPIRV-Tools v2026.4):

  • python -m unittest tests/semantic/test_ms_lds_need.py -v: 3/3 passed (0.077 s).
  • Negative control (running tests/semantic/test_ms_lds_need.py with LEONIDA_TOOLS_DIR=E:\leonida\tools against main f847748c): 3/3 failed (1024 != 256, 1024 != 512, 16384 != 8192).
  • python -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc E:\leonida.work\tools\llvm-mc\llvm-mc.exe --filter ms_ --require-pass: 7/7 shaders translated and spirv-val-valid, 6/6 GPU tests passed (ms_clip, ms_f16_pack, ms_tri, ms_v5_workgroup, ms_w64x_ballot, ms_wave_info_s3).

AI-assisted (Gemini, Antigravity).

@ItsNotRexed
ItsNotRexed merged commit 98154e9 into ItsNotRexed:main Nov 23, 2026
@memorypressure

Copy link
Copy Markdown

Verified on the merged tree: the three mesh LDS-need cases (st64 / b32 / b64 offsets) pass under python -I through support.translate_lines, and the compute-side read2/write2 and shared-memory-limit suites confirm the reused ds_const_extent path is unchanged. Hand-built PSV0 in the test, no game data; an existing-rule bug fix, so no new contract row needed. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

6 participants