Skip to content

w64_tier_c_cost: count how many pixels of each tier C fixture move with the partition (SHADER-836, synthetic) - #7161

Open
Invictus2076 wants to merge 1 commit into
ItsNotRexed:mainfrom
Invictus2076:shader-836-tier-c-cost
Open

Invictus2076 wants to merge 1 commit into
ItsNotRexed:mainfrom
Invictus2076:shader-836-tier-c-cost

Conversation

@Invictus2076

Copy link
Copy Markdown

Claimed in the coordination issue as: SHADER-836 (#6910). This is the synthetic part only: the corpus count the task asks for needs a copy of the game, which I don't have, so it does not close SHADER-836.

What and why

SHADER-836 asks how much tier C costs. This adds runtime/test/shaders/w64_tier_c_cost.py, which draws the eight ps_w64_c_* fixtures and counts, per fixture, the pixels (of 64 x 64) whose partition-dependent words (the None entries of FIXTURES in w64_graphics.py) differ from a reference run. The reference is the device's own draw required to 64, against the one required to 32, where it can require both (RADV). Otherwise it is a --ref directory: the W64G_SAVE_REF files of a 64-lane device, or --save files of any device. Counts only, no shader code or game data. docs/testing.md documents it.

Tested

On main at 26e56f5 (shaders built with LLVM 21.1.8 and SPIRV-Tools on Linux, all 266 translate and pass spirv-val; runtime built with MSVC on Windows 11). RTX 4080 Laptop (NVIDIA 621.24, 32 live lanes) saved as the reference, Intel Arc Graphics iGPU (Meteor Lake, Intel 101.6314, 16 live lanes) as the run:

  • vote read as data (ps_w64_c_scc_vote, _vote_else, _vote_stale, _execz_sgpr): 16 of 4,096 pixels (0.4%)
  • lane id (_lane_id): 3,584 (87.5%)
  • count or v_readlane of a varying value (_bcnt_export, _readlane, _waterfall_count): 4,096 (100%)

Limits, also in the docs: both devices are narrower than a wave64, so this is how far the words move with the partition width (32 to 16 lanes), not the cost against a real wave64. I had no 64-lane device. A run on a RADV GPU (no --ref needed there) and the corpus count are still wanted. Unit tests: tests/test_w64_tier_c_cost.py (8 tests, the draws are stubbed), and pytest -k "docs or w64_tier or wave64_halves_fixtures" passes (57) on Linux.

AI-assisted: yes (Claude).

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. (Not applicable: no translator rule changes.)

…th the partition (SHADER-836, synthetic)

SHADER-836 asks how much tier C costs. The real answer is a count over the corpus, which needs the game; this
is the part that needs none. runtime/test/shaders/w64_tier_c_cost.py draws the eight ps_w64_c_* fixtures and
counts, per fixture, the pixels whose partition-dependent words (the None entries of FIXTURES) differ from a
reference run: the device's own draw required to 64 vs 32 where it can, else a --ref directory (W64G_SAVE_REF
files of a 64-lane device, or --save files of any device). Counts only.

Measured on main 26e56f5, RTX 4080 Laptop (32 live lanes) as the reference and the Intel Arc Graphics iGPU
(Meteor Lake, 16 live lanes) as the run: votes read as data 16 of 4096 pixels, lane id 3584, counts and
v_readlane of a varying value 4096. Both devices are narrower than a wave64, so this is the sensitivity to the
partition width, not the cost against a real wave64; docs/testing.md says so and that a 64-lane run and the
corpus count are still wanted.

tests/test_w64_tier_c_cost.py stubs the GPU draws (8 tests, no GPU or LLVM needed).
@sskver

sskver commented Nov 23, 2026

Copy link
Copy Markdown

Tested 40066d76 merged onto main 8575d36ed (clean) on AMD Ryzen 7 7800X3D iGPU (gfx1036, Raphael), RADV / Mesa 26.3.1, Linux, kernel 7.3.5-zen1: pass, and this is the 64-lane reference run the body says is still wanted.

The device can require both fragment subgroup sizes, so this is the default mode with no --ref: the reference is the same device's own draw required to 64, the run is the one required to 32. live lanes per fragment subgroup: 32, and the probe confirms the 64-lane run really runs 64.

fixture dependent words pixels moved your 32-vs-16 proxy
ps_w64_c_bcnt_export [0] 4096 of 4096 (100.0%) 100%
ps_w64_c_execz_sgpr [0] 32 of 4096 (0.8%) 0.4%
ps_w64_c_lane_id [0, 1] 2048 of 4096 (50.0%) 87.5%
ps_w64_c_readlane [0, 2] 4096 of 4096 (100.0%) 100%
ps_w64_c_scc_vote [0] 32 of 4096 (0.8%) 0.4%
ps_w64_c_vote_else [0] 32 of 4096 (0.8%) 0.4%
ps_w64_c_vote_stale [0] 32 of 4096 (0.8%) 0.4%
ps_w64_c_waterfall_count [1] 4096 of 4096 (100.0%) 100%

What the real 64-vs-32 comparison adds, against the RTX 4080 (32 live lanes) to Intel Arc (16 live lanes) run in the body:

  • The three "always moves" fixtures (bcnt_export, readlane, waterfall_count) are 100% both ways, so that part of your reading holds on a true wave64 reference.
  • The vote family moves twice as much as the proxy suggests: 32 of 4,096 (0.8%) rather than 16 of 4,096 (0.4%). The proxy's 16 comes from the narrower device's own live-lane count, so it scales with the run width and is not a measurement of the partition effect.
  • lane_id moves half as much as the proxy suggests: 2,048 of 4,096 (50.0%) rather than 3,584 (87.5%). That is the expected shape against a real 64-lane reference: the low 5 bits of the lane id are the same in the wave and in the half, so only the pixels whose word carries the wave bit move, which is exactly one of the two halves of the image. The 32-vs-16 proxy has no such bit to hold still, so it reads higher.

So the tool works as documented on a device that can require both sizes, and the counts it prints there differ from the proxy in the direction the fixture headers predict. The body's own limits section already says a 32-wide device gives no 64-lane reference; this run is that reference, and it is worth folding into the docs/testing.md section as a second row so the proxy numbers are not read as the cost.

Environment: scripts from the merged worktree; the harness is vk_harness built at main 09b9ba8 (git diff 09b9ba8 HEAD -- runtime/ touches only runtime/test/file_system_test.cpp, so the harness source is identical to the tested head). Fixtures built by build.py at that commit: 268 shaders, 268 translated, 268 pass spirv-val. Python 3.14.10, llvm-mc 21.1.8 (amdgcn), SPIRV-Tools v2026.4, gcc 16.2.0. LEONIDA_VK_DEVICE=raphael pins the run to the AMD device (this box also has an RTX 5080).

tests/test_w64_tier_c_cost.py: 8 passed in 0.33 s under python -m pytest (the file imports pytest, so it is not runnable with -I alone).

For the record, this device's baseline at main 09b9ba8, which this PR does not touch (it adds one tool, one test file and a docs section, and changes no translator, fixture or harness code): run_gpu_tests.py native 222/239 passed, 16 skipped, with the single ms_wave_info_s3 FAIL that #7136 fixes, and w64_graphics.py 29/29 ok (tier A 11 / B 8 / C 13, both widths confirmed by the probe). Those two numbers are here so the tier C counts above can be read as coming from a device where the surrounding suite is otherwise healthy.

No game files; counts only. AI-assisted (Claude Code).

@nonverifiedperson

Copy link
Copy Markdown
Contributor

Tested 40066d7 on Windows 10 22H2 with an AMD Radeon iGPU (gfx1036, Windows driver 32.0.13036.4, Vulkan driverInfo 24.30.36) and an NVIDIA RTX 5070 Ti (621.35), Vulkan SDK 1.4.363. These are the first AMD numbers for this tool.

AMD on Windows cannot require a fragment subgroup size. Its requiredSubgroupSizeStages is COMPUTE only; vulkaninfo gives count = 1, SHADER_STAGE_COMPUTE_BIT. So the default mode prints skipped: this device cannot require 64 lanes for all 8 fixtures on the Radeon, and also on the NVIDIA (max subgroup 32). That is correct behaviour. But the module docstring says, in the "default" row, that a device that can require it includes "AMD on Windows". Only RADV belongs there. docs/testing.md already says only RADV, so this is just the docstring line.

The cross-device path works. I saved the Radeon's default-size draws with --save, then compared them with --ref on each GPU:

fixture dependent words NVIDIA against the Radeon draw Radeon against its own saved draw
ps_w64_c_bcnt_export [0] 4096 of 4096 (100%) 0
ps_w64_c_execz_sgpr [0] 32 (0.8%) 0
ps_w64_c_lane_id [0, 1] 3840 (93.8%) 0
ps_w64_c_readlane [0, 2] 4096 (100%) 0
ps_w64_c_scc_vote [0] 32 (0.8%) 0
ps_w64_c_vote_else [0] 32 (0.8%) 0
ps_w64_c_vote_stale [0] 32 (0.8%) 0
ps_w64_c_waterfall_count [1] 4096 (100%) 0

No row moved pixels in a word that must not move. The self-comparison gives 0 everywhere, so the counts are not run-to-run noise.

Both runs print live lanes per fragment subgroup: not measured, so the tool reports the reference as "partition unknown". The Radeon's live fragment width under the AMD Windows driver isn't pinned down here.

These counts sit between your 16-against-32 Intel/NVIDIA numbers (16 / 3,584 / 4,096) and what a full wave64 would give. That is consistent with the Radeon running fragment waves wider than 32, but I haven't proved it, so I leave the 64-lane reference to a RADV run as you planned.

Other checks

  • Built with runtime/test/shaders/build.py <out> vs_ids ps_w64_c_*: 9 translated, 9 pass spirv-val. Note that vs_ids is needed too; with only the 8 ps_w64_c_* every draw fails at the VS module. A line in the docs example would save the next tester that step.
  • pytest tests/test_w64_tier_c_cost.py: 8 passed.

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

@nonverifiedperson

Copy link
Copy Markdown
Contributor

Follow-up to my table above: the Radeon reference is a 64-lane run, so the NVIDIA column there is the cost against a real wave64 that the description said was still wanted.

Evidence. In the Radeon's saved default-size draw of ps_w64_c_lane_id:

  • r0, the v_mbcnt lane id, takes all 64 values 0..63.
  • r1, lane & 31, takes 0..31.

On 32-lane subgroups r0 would stop at 31. This matches what the repo already records for this driver: tools/wave32_pixel_scan.py:7 says AMD's Windows driver on RDNA2 lists only COMPUTE in requiredSubgroupSizeStages, with a default size of 64.

So, measured on gfx1036 with the AMD Windows driver as the 64-lane reference and the RTX 5070 Ti as the 32-lane run:

group fixtures pixels moved (of 4,096)
vote read as data _scc_vote, _vote_else, _vote_stale, _execz_sgpr 32 each (0.8%)
lane id _lane_id 3,840 (93.8%)
count or v_readlane of a varying value _bcnt_export, _readlane, _waterfall_count 4,096 (100%)

A possible small change: live lanes per fragment subgroup: not measured and the "partition unknown" label could come from this same fixture. The maximum of r0 in a --save draw gives the device's live width, so a --ref directory saved on AMD Windows could be labelled 64-lane automatically. That's your call; the counts above stand either way.

Windows 10 22H2, Radeon iGPU gfx1036 (32.0.13036.4) and RTX 5070 Ti (621.35). Synthetic fixtures only. AI-assisted (Claude Code).

@moistman7

Copy link
Copy Markdown

Ran 40066d76 merged onto main e0816d6a on native Windows 11 26200 with two devices in one machine. This is not the 64-lane run the PR asks for: the AMD Windows driver I hoped would provide it measures 32 live lanes. But it adds a cross-vendor 32-vs-32 point.

  • AMD Radeon Graphics (Ryzen 7 9800X3D iGPU, RDNA2/gfx1036), AMD driver 32.0.21042.62: live lanes per fragment subgroup: 32, and every fixture reports skipped: this device cannot require 64 lanes. So this AMD Windows driver runs pixel shaders at 32 live lanes, not at the 64-wide default docs/testing.md describes for an RX 6800 on 26.11.2. It cannot stand in as the 64-lane reference.

  • RTX 5090 (617.42, 32 live lanes) with --ref = the AMD default-size draws (--save, also 32 lanes):

    fixture pixels moved
    ps_w64_c_scc_vote, _vote_else, _vote_stale, _execz_sgpr 32 of 4,096 (0.8%) each
    ps_w64_c_lane_id 3,840 (93.8%)
    ps_w64_c_bcnt_export, _readlane, _waterfall_count 4,096 (100%) each

    Same width on both sides, yet the tier C words still move: the two vendors pack pixels into lanes differently. That gives the same ranking as your 32-vs-16 run (votes few, lane id most, counts/readlane all).

  • Two small things: w64_tier_c_cost.py --help takes --help as the build dir and ends in a WinError 2 traceback from live_width. The docs example starts from /tmp/w64g without saying the ps_w64_c_* SPIR-V must first be built there (runtime/test/shaders/build.py <dir>; run_gpu_tests.py --work doesn't build them, as they are w64_graphics.py-only).

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

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