Skip to content

TEST-251: GPU checks of wave64 geometry shaders, and no false tier C for a GS's ring address - #2127

Closed
AwkGrep256 wants to merge 1 commit into
ItsNotRexed:mainfrom
AwkGrep256:test-251-gs-w64-gpu
Closed

AwkGrep256 wants to merge 1 commit into
ItsNotRexed:mainfrom
AwkGrep256:test-251-gs-w64-gpu

Conversation

@AwkGrep256

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-251, part 2 (#1902 (comment)). Part 1, the vertex shaders, is #1830 (merged).

What and why

The problem. A wave64 graphics shader on a 32-wide GPU runs as two 32-lane halves. tools/wave64_halves.py marks each one tier A, B or C by whether that split can change its results; tier C means "may be wrong" and is refused under --wave64-graphics=error. For geometry shaders the detector gave a false tier C.

A legacy GS writes each output vertex to LDS at lane's GSVS base + offset, where the base usually comes from the lane id (v_mbcnt_lo/hi). The translator never uses that base: rdna2spirv.gs_ds picks the output slot from the constant offset alone. So the lane id cannot reach any output. The detector still treated it as observable, because for ds_write vaddr, vdata... it read operand 0, the address, as the data. The result was tier C lane-id for a shader that is exact.

The fix (tools/wave64_halves.py, 4 lines): for a ds_write in a GS, check only the data operands. Data that depends on the lane, and a lane id in a real memory store's address, stay tier C.

Why it may matter for the game (a hypothesis, I have no game files): the corpus count in #94 finds v_mbcnt_hi_u32_b32 in all 195 corpus GS. If it forms their GSVS base, all 195 were a false tier C. python -I tools/wave64_halves.py --census <work>/shaders/spirv/index.json shows it (counts only).

GPU checks for geometry shaders. Until now they had none (docs/design.md: "geometry shaders are not tested"). As in #1830, RADV's RADV_PERFTEST=gewave32 switches the GS stage between wave64 and wave32:

  • gs_w64_c_lane_id: the lane id as data (tier C). It is also the probe that the wave size changed: the largest lane id is 41 by default and 31 with gewave32.
  • gs_w64_a_ring: the lane id only in the GSVS address, the shape described above (tier A).
  • build.py now builds gs_* fixtures. gs_container() writes the same ISG1/OSG1 as run_gpu_tests.py makes for gs_tri.

Docs.

  • docs/design.md: the SHADER-10 row records the rule and how it was confirmed.
  • docs/design.md: the "Geometry shaders" row said the corpus GS are wave32. The code says wave64: the EXEC prologue compares the thread count with 64 and writes a 64-bit EXEC, all 195 contain v_mbcnt_hi, and the translator marks them wave64. The row now says so, marked as inferred.
  • docs/testing.md: new section on running w64_graphics.py on RADV and adding a fixture.

Tested

AI-assisted (Claude Code). CachyOS, RADV Mesa 26.3.1, llvm-mc 23.1.5, SPIRV-Tools 2026.4, on main 4eb6155 plus this branch, test programs rebuilt from it. GPUs: RX 9070 XT (RDNA4, GFX1201) and Ryzen 7 9800X3D iGPU (RDNA2, GFX1036), each pinned with LEONIDA_VK_DEVICE.

  • Red, then green: before the fix, tests/test_wave64_halves_fixtures.py failed on gs_w64_a_ring (tier C lane-id), while the GPU already gave equal records at wave64 and wave32. After it, 8 passed.
  • Same program: a GS with the base lane id * 96 translates, after spirv-opt -O, to the same instructions as gs_tri (IDs aside).
  • w64_graphics.py: 23/23 on both GPUs (14 ps_w64_*, 7 vs_w64_*, 2 gs_w64_*).
  • Mutation: gs_w64_c_lane_id relabelled tier A fails on both GPUs (311 and 312 of 320 records wrong).
  • tests/semantic: 1674 tests OK, including 3 new GeometryRing cases. Without the fix, only the ring-address case fails.
  • run_gpu_tests.py (RX 9070 XT): 167/180 passed, 0 failed, 13 skipped native, 167/180 passed, 0 failed, 13 skipped with LEONIDA_W64_EMULATE=1. build.py: 202 translated, all pass spirv-val.
  • check.py: 155 of 160, 4 skipped. The one failure, cs_fma_fused, is the same on clean main. RADV splits GLSL Fma into two roundings on both GPUs, and LEONIDA_FMA=khr is exact. It is unrelated to this PR, and I'm reporting it separately.
  • compileall, tests/test_docs_links.py, tests/test_text_write_line_endings.py: OK.

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 (SHADER-10 row).

🤖 Generated with Claude Code

@Rainmaker33

Copy link
Copy Markdown

Tested fd20500 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass.

The PR's diff applied cleanly to main 4eb6155. VS 2022, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8; harness programs from a CMake build of that main; overlay layers off.

  • build.py: 202 translated, all pass spirv-val.
  • runtime/test/shaders/w64_graphics.py, at 32 lanes only on NVIDIA: gs_w64_a_ring (tier A) is ok. gs_w64_c_lane_id reports SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF), as expected. The existing ps_/vs_w64_* give the same split: 11 ok in total.
  • scripts/run_gpu_tests.py: 136/180 pass, 44 skipped, no failures, the same as main.
  • tests/semantic/test_wave64_halves.py: OK. I did not run tests/test_wave64_halves_fixtures.py (it needs pytest, which is not installed here).

@bvtterbroot

bvtterbroot commented Nov 22, 2026 •

Copy link
Copy Markdown

Tested fd20500 on AMD Radeon RX 7900 XTX (RDNA3, Navi 31), AMD driver 26.11.2, Vulkan 1.4.359, Windows 11: pass.

  • run_gpu_tests.py: 167/180 passed, 13 skipped.
  • python -I -m unittest discover -s tests/semantic -p test_wave64_halves.py: 60 tests OK.
  • runtime/test/shaders/w64_graphics.py: exit 0, 19 ok, 4 SKIP (AMD's Windows driver has no wave32 switch for VS/GS, so their tier C checks skip as documented). Last line: vs_w64_c_readlane C SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF)

Not run: tests/test_wave64_halves_fixtures.py (pytest, not installed here; CI covers it).

Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 14.44.

@LloydNicholson

Copy link
Copy Markdown
Contributor

Tested fd20500 on an RX 9060 XT (RDNA4, GFX1200), RADV Mesa 27.0.0-devel, Nobara Linux (Fedora 44, kernel 7.3): pass

This adds a third RDNA4 part to the two GPUs in the description: GFX1200, not GFX1201. Setup: llvm-mc 22.1.8 and SPIRV-Tools 2026.1. The head is on main 4eb6155, and the test programs were rebuilt from it with LEONIDA_VK_DEVICE=9060.

  • build.py: 202 translated, all 202 pass spirv-val. The tiers are A 5, B 7, C 13.
  • w64_graphics.py: 23/23 ok. That covers 14 ps_w64_*, 7 vs_w64_*, and both new ones: gs_w64_a_ring (A) and gs_w64_c_lane_id (C). The GS probe saw the wave size change under gewave32, since the tier C case ran rather than being skipped.
  • tests/test_wave64_halves_fixtures.py: 8 passed.
  • tests/semantic: 1674 tests OK.
  • Red, then green: with tools/wave64_halves.py put back to main's version, test_fixtures_are_classified_as_their_headers_say fails, as does GeometryRing.test_lane_id_in_the_ring_address_is_tier_a. Every other test in both files passes. With the PR's version, both pass.
  • run_gpu_tests.py: 167/180 passed, 0 failed, 13 skipped. It gives the same with LEONIDA_W64_EMULATE=1.

I didn't repeat the mutation test, or the spirv-opt comparison with gs_tri.

AI-assisted (Claude Code).

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested fd2050071a42b8f03286b6cba092ecdec01264d4 on AMD Custom GPU 0405 (Van Gogh, RDNA2 APU — Steam Deck LCD / Jupiter), RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5: pass.

Built the fixtures with the PR's build.py, then ran python3 -I runtime/test/shaders/w64_graphics.py <work> runtime/build:

23/23 fixtures ok — gs_w64_a_ring, gs_w64_c_lane_id, all 14 ps_w64_*, and all 7 vs_w64_*.

Tier A and B fixtures produce the words their headers derive. The tier C fixtures show the expected partition-dependent difference between the wave64 run and the RADV_PERFTEST=gewave32 run, so the tier classifier is behaving as intended on this device.

Note: I rebuilt runtime/build from the PR base 4eb6155d first; the pre-existing vk_harness binary was stale and ignored VKH_VERTICES.

@ddm-j

ddm-j commented Nov 22, 2026

Copy link
Copy Markdown

Tested fd20500 on AMD Radeon 610M (RDNA2 iGPU, gfx1036, RADV Mesa 26.2.6) and NVIDIA RTX 4070 Ti (615.78.08), Fedora 45: pass

New here: the cross-device tier-C check. NVIDIA can only require 32 lanes, so on its own it skips all 12 tier-C fixtures. I saved the RADV wave64 runs with W64G_SAVE_REF and compared the NVIDIA runs with them through W64G_REF. All 23 then run: tiers A and B are equal to the reference, and tier C differs, as its headers say. That includes both new GS fixtures.

w64_graphics.py result
RADV (gewave32 switch) 23/23 ok
NVIDIA alone 11 ok, 12 SKIP (tier C, expected)
NVIDIA vs RADV reference (W64G_REF) 23/23 ok, including gs_w64_a_ring A and gs_w64_c_lane_id C
  • build.py: tier A 5, B 7, C 13.
  • tests/test_wave64_halves_fixtures.py: 8 passed. With main's tools/wave64_halves.py put back, test_fixtures_are_classified_as_their_headers_say fails (1 failed, 7 passed).
  • test_wave64_halves.py: 60 OK. tests/semantic: 1674 OK.
  • run_gpu_tests.py gives the same as main 4eb6155: RADV 167/180, 13 skipped; NVIDIA 136/180, 44 skipped; NVIDIA with LEONIDA_W64_EMULATE=1 167/180, 13 skipped.
Commands
python3 -I runtime/test/shaders/build.py w64g
LEONIDA_VK_DEVICE=RAPHAEL W64G_SAVE_REF=$PWD/w64ref python3 -I runtime/test/shaders/w64_graphics.py w64g runtime/build/linux
LEONIDA_VK_DEVICE=4070    W64G_REF=$PWD/w64ref      python3 -I runtime/test/shaders/w64_graphics.py w64g runtime/build/linux

Test programs built from this head, llvm-mc 23.1.5, SPIRV-Tools 2026.2.

AI-assisted (Claude Code); numbers copied from the run logs.

…for a GS's ring address

rdna2spirv maps a legacy GS's LDS write to an output slot from its
offset alone and drops the VGPR address (the lane's GSVS area), but
wave64_halves read that address as the store's data, so a GS whose lane
id only forms its GSVS base was tier C lane-id. It now checks only the
data operands of a GS ds_write.

w64_graphics.py draws gs_w64_a_ring and gs_w64_c_lane_id at wave64 and
wave32 (RADV_PERFTEST=gewave32), build.py builds gs_* fixtures with
gs_tri's signatures, docs/testing.md explains how to run and extend the
wave64 graphics checks, and docs/design.md records the rule and that the
corpus GS are written for wave64. Checked on an RX 9070 XT (GFX1201) and
a Ryzen 9800X3D iGPU (GFX1036), RADV Mesa 26.3.1: 23/23.

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

Copy link
Copy Markdown
Contributor Author

Closing: this was merged into main as cdb907a (from fd20500, the head before my rebase), so GitHub didn't mark it merged. Everything is in main: the GS fixtures, the wave64_halves.py ds_write fix and the docs. The rebase only resolved a docs/design.md conflict that main has since cleaned up itself. Thanks to everyone who tested it.

@AwkGrep256 AwkGrep256 closed this Nov 22, 2026
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
# Conflicts:
#	docs/design.md
#	docs/testing.md
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