Skip to content

Docs/Tests: confirm SHADER-4 system values on the corpus, add a mesh s3 wave-ID test - #240

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
eIBart0:shader4-corpus-confirm
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
eIBart0:shader4-corpus-confirm

Conversation

@eIBart0

@eIBart0 eIBart0 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Confirm the SHADER-4 system-value register assumptions across the full disassembled CS, MS, and GS shader corpus (counts only) and add a synthetic GPU test covering mesh s3[27:24] wave ID extraction.

Changes

  • scripts/audit_shader4_regs.py + tests/test_audit_shader4_regs.py: Stdlib-only audit script and synthetic unit test that count initial read-before-write SGPR/VGPR registers, COMPUTE_PGM_RSRC2 fields, PSV0 headers, and s3 bit-extraction patterns across CS/MS/GS disassemblies.
  • docs/design.md: Adds the ### System values confirmed on the corpus (SHADER-4) section below the contract table (leaving the table untouched) with aggregate counts only:
    • CS (2,689 shaders): TIDIG_COMP_CNT 0/1/2/3 = 724/1,786/179/0; TGID X/Y/Z 100/110/111 = 724/1,786/179; TG_SIZE_EN = 0, SCRATCH_EN = 0, TRAP_PRESENT = 0; RBW VGPRs v0 (2,602), v1 (893), v2 (57).
    • MS (9,282 shaders): all 128×1×1 in PSV0; 100% read v5 once (v_readfirstlane_b32 + s_lshr_b32 D, sX, 7); 100% read s3 exclusively via s_bfe_u32 D, s3, 0x40018 (bits [27:24]), 0 read other bit ranges.
    • GS (195 shaders): all read only v0 and v1 (0 read v2–v4).
  • runtime/test/shaders/ms_wave_info_s3.asm + test harness wiring (check.py, run_gpu_tests.py, tests/conftest.py, tests/test_shader_checks.py, tests/test_translate.py): Synthetic 128-thread (2-wave) NGG mesh shader verifying s3[27:24] == LocalInvocationIndex >> 6 across both waves via LDS atomics, plus translation/validation coverage (no KNOWN_VAL_ISSUES waiver needed on current main).

Rebase note

Rebased cleanly onto main (d937b7f), adapted tests/conftest.py (kept KNOWN_VAL_ISSUES = {}), tests/test_shader_checks.py (TOTAL and skipped counts), and tests/test_translate.py to current main.

@ItsNotRexed

Copy link
Copy Markdown
Owner

Thanks! The GPU test scripts (check.py, run_gpu_tests.py, test_shader_checks.py) changed several times in the last hour (#203, #212, #218, #222, #235, #246, #219), and this conflicts with them in ways that keeping both sides doesn't resolve. Could you rebase onto main? Please claim the work in #156 so two PRs don't edit the same lists.

@eIBart0

eIBart0 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (d937b7f) and adapted to the current check.py / run_gpu_tests.py / test_shader_checks.py. SHADER-4 is already listed for this PR in #374.

@AC-Storm-YT

Copy link
Copy Markdown
Contributor

GPU test of #240 at 0bb40d7: pass

  • GPU: AMD Radeon RX 9070 XT (RDNA4, native wave64, subgroup 32..64), driver 32.0.31041.1004, Windows 11
  • Tools: llvm-mc 21.1.8 (WSL Ubuntu 26.04), Vulkan SDK 1.4.363.1, MSVC (VS 2026)
  • run_gpu_tests.py: 59/59 passed, including ms_wave_info_s3: 4096/4096 pixels exact
  • The test bites: with s_bfe_u32 s4, s3, 0x40010 (bits [19:16]) instead of 0x40018, ms_wave_info_s3 fails at (0,0) (param0.b = 0.0, want 0.5)
  • tests/test_audit_shader4_regs.py and tests/semantic: pass. tests/test_translate.py not run (no pytest here).

Note: GitHub shows this conflicting with main again; the results above are for 0bb40d7 as it is.

AI-assisted (Claude Code).

@eIBart0

eIBart0 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @AC-Storm-YT for the GPU test! Rebased onto current main (only tests/test_shader_checks.py TOTAL updated for #193's CLIP_TESTS; shader and harness code identical to 0bb40d7).

@eIBart0
eIBart0 force-pushed the shader4-corpus-confirm branch from 0bb40d7 to e53b9e5 Compare November 22, 2026 00:06
@MrCheese5

MrCheese5 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested 0bb40d7 on the 1.0.2.1 package, RTX 4090 (621.14), Win11 26200: every corpus count in the description reproduces, and the GPU tests pass.

scripts/audit_shader4_regs.py on the full disassembled corpus (25,734 .s files), counts only:

  • CS (2,689): TIDIG_COMP_CNT 0/1/2/3 = 724/1,786/179/0; TGID X / XY / XYZ = 724/1,786/179; TG_SIZE_EN, SCRATCH_EN and TRAP_PRESENT set in 0. VGPRs read before written: v0 2,602, v1 893, v2 57. The higher VGPRs it lists are loop-carried reads, not system values.
  • MS (9,282): all 128×1×1, maxv/maxp 128/128. v5 read in 9,282/9,282, and s3 read only as s_bfe_u32 D, s3, 0x40018 in 9,282/9,282. FSSM 0x138..0x144 is all zero in every one.
  • GS (195): VGPRs read before written are v0 and v1 only (195/195), with no v2/v3/v4.

Two things the description doesn't mention, for the record (neither is a problem):

  • 5 mesh shaders declare groupshared memory in PSV0 (3 at 10,368 B, 2 at 3,072 B). The other 9,277 declare 0.
  • All 195 GS read s3, but only as s_bfe_i32 D, s3, 0x80008 and s_bfe_u32 D, s3, 0x80010, which is merged-wave-info bits [15:8] and [23:16]. Nobody has looked at those GS fields yet.

tests/test_audit_shader4_regs.py: 1 passed.

GPU (scripts/run_gpu_tests.py --filter, NVIDIA subgroup 32..32, LLVM llvm-mc with AMDGPU, Vulkan SDK 1.4.363.0):

  • ms_wave_info_s3: PASS, 4096/4096 pixels exact
  • ms_tri: PASS, 4096/4096
  • ms_v5_workgroup: PASS, 24/24 workgroup coordinates exact
  • gs_tri: PASS, 4096/4096
  • cs_lds, cs_workgroup_yz: PASS

The test programs (vk_harness etc.) came from a runtime/ build at b4e31e3 (#295's branch), not of this branch; the shaders were assembled and translated from this branch. The branch is behind main (as the earlier review comment said, it needs a rebase).

AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 2c6f763 into ItsNotRexed:main Nov 22, 2026
8 checks passed
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.

4 participants