Skip to content

D3D-315: census of root-signature spill evidence (no below-base candidates) - #4163

Open
TortitasT wants to merge 2 commits into
ItsNotRexed:mainfrom
TortitasT:d3d-315-root-spill-census
Open

TortitasT wants to merge 2 commits into
ItsNotRexed:mainfrom
TortitasT:d3d-315-root-spill-census

Conversation

@TortitasT

@TortitasT TortitasT commented Nov 22, 2026 •

Copy link
Copy Markdown

Item: D3D-315 (claimed in #2516; tracked in #313).

What this does

D3D-315 asked to count how many root signatures and shaders in the corpus go over 32 user dwords and how the shaders read the overflow, then define the spill layout. This PR is the measuring half. The count finds zero below-base spill-pointer candidates in the translated shaders, so the spill layout stays unimplemented and pack() keeps refusing.

  • tools/root_spill_census.py (stdlib only, reads index files only, prints counts) reports per stage:
    • spill-pointer candidates: user-SGPR reads used as an address (ptr32_lo, ptr64_lo, ptr64_hi) below the stage base (default ps/vs/gs s8, cs s4, ms s16). For compute, that block is where section 7 measured the spill pointer s[0:1];
    • the highest user SGPR each shader reads, and whether that read is an address or a constant;
    • the RSRC2 USER_SGPR budget where index.json records it (compute), and the root dwords that leaves above the base;
    • with --carve <dxbc/index.json>, how many containers carry an RTS0 part;
    • --expect-no-spill exits 1 if any stage has a candidate;
    • --base STAGE=SGPR overrides only the stages it names; the others keep their defaults.
  • tests/test_root_spill_census.py: 11 tests on hand-written index data, no game files.
  • docs/d3d12_vulkan.md: the counts under "Spill policy" (section 3.5), plus pointers from the CreateRootSignature line and the "Root signature larger than 32 dwords" open item.

Counts (Xbox Series 1.0.2.1, my own copy)

26,503 carved containers, 26,501 translated shaders (the other 2 are the compute shaders refused for workgroup memory under wave64 emulation, SHADER-309):

  • No root signatures in the containers. 0 of 26,503 have an RTS0 part. The signatures are built at run time, so how many exceed 32 dwords is still open until someone dumps them from the executable.
  • No spill-pointer candidates in any stage. s0 and s1 are never read as an address. The only reads there are s1 as a 32-bit constant (109 CS, 551 PS, 12 VS).
  • Compute is far below the budget. The largest USER_SGPR count is 14 (31 of 2,687 shaders), so at most 10 of the 28 root dwords above s4 are used.
  • The highest reads are constants, not spill pointers. PS reaches s31 (8 shaders), s29 (7), s27 (1) and s25 (8); MS reaches s29 (2) and s27 (8); VS reaches s25 (2). Each is a 32-bit constant after a gap.

What this does not settle (listed in the docs too):

  • how many runtime-created signatures exceed the budget: the containers carry none, so that waits for signatures dumped from the executable;
  • why a particular pack() refusal happens: pack() counts two dwords per table from s0, which the §3.5 census disagrees with, so a refusal may be that model or a real spill;
  • a spill behind a pointer at or above the base, which reads the same as a table pointer.

Tested

  • python -I tests/test_root_spill_census.py: 11 tests pass (after the review: a partial --base keeps the other stages, and the base−1 / base / base+1 boundary for every default stage).
  • python -I tests/test_docs_links.py: passes.
  • python -m compileall -q tools/root_spill_census.py tests/test_root_spill_census.py: clean.
  • python -I tools/root_spill_census.py <spirv/index.json> --carve <dxbc/index.json> --expect-no-spill on a full work folder built with make_game.py at aa2988cc (wave64 emulation on): exit 0, with the counts above; also exit 0 with --base cs=4.
  • Windows 11, Python 3.12.10. No GPU work involved; the work folder was built on an NVIDIA GeForce RTX 4080, driver 621.24.

AI-assisted (Claude Code). No game data in this PR: counts only, no shader names, bytes or disassembly.

🤖 Generated with Claude Code

tools/root_spill_census.py counts, per stage, user-SGPR reads used as an
address below the stage base (where the compute spill pointer s[0:1] was
measured), the highest user SGPR read and its kind, the RSRC2 USER_SGPR
budget where index.json records it, and RTS0 parts in the carved
containers. --expect-no-spill turns it into a check. Counts only, from
index files; no game bytes.

On Xbox Series 1.0.2.1 (26,501 translated shaders, 26,503 containers):
0 RTS0 parts, 0 spill-pointer candidates in any stage, compute at most
14 user SGPRs (10 of 28 root dwords). docs/d3d12_vulkan.md records the
counts; pack() keeps refusing over 32 dwords, now with the measured
reason that no shader would read a spill.

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

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted Windows review of 6edda935, uv CPython 3.12.13, synthetic index data only. The 9 stock tests and 19 added CLI checks passed. For each default stage, a pointer at base−1 tripped the gate while pointers at base and base+1 passed. The synthetic carve check counted 2 of 3 containers with RTS0.

Please narrow the spill-policy conclusion and its cross-references. Zero classified address reads below the stage base supports “zero below-base candidates in the translated sample.” The number of runtime-created signatures that exceed the budget, and the reason for a particular pack() refusal, are still open. The section already notes that a pointer at or above the base can be indistinguishable from a table pointer. Spill policy

A partial CLI override also narrows the gate silently. A fixture with a PS address read at s7 exits 1 with defaults. Adding only --base cs=4 gives PS base: null and exit 0. Please document that --base replaces the entire stage map, or retain defaults for omitted stages. CLI

…aults

docs: the census shows zero below-base spill-pointer candidates in the
translated shaders, not that no signature spills. How many runtime
signatures exceed the budget and why a given pack() refusal happens stay
open; listed with the at-or-above-base blind spot.

root_spill_census.py: --base overrides only the stages it names. Before,
--base cs=4 alone dropped every other stage from the check (a PS address
read at s7 passed --expect-no-spill). Tests cover that case and the
base-1 / base / base+1 boundary for every default stage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TortitasT TortitasT changed the title D3D-315: census of root-signature spill evidence (none in the corpus) D3D-315: census of root-signature spill evidence (no below-base candidates) Nov 22, 2026
@TortitasT

Copy link
Copy Markdown
Author

Thanks @whattheflop. Both points were right; fixed in d34d165.

  • Spill-policy wording. The section now says "zero below-base spill-pointer candidates in the translated shaders" and lists what stays open: how many runtime-created signatures exceed the budget, why a particular pack() refusal happens, and the at-or-above-base blind spot. The CreateRootSignature line and the "Root signature larger than 32 dwords" item use the same narrower wording, and so do the PR title and description.
  • Partial --base. --base now overrides only the stages it names and keeps the defaults for the rest. New tests cover your case (PS address read at s7: exit 1 with defaults and with --base cs=4 alone, exit 0 with --base ps=7) and the base−1 / base / base+1 boundary for every default stage.

Re-checked: 11 tests pass, test_docs_links.py passes, and the census still exits 0 on the full 1.0.2.1 corpus, with defaults and with --base cs=4.

@whattheflop

Copy link
Copy Markdown
Contributor

Retested d34d165 on Windows, uv CPython 3.12.13. All 11 stock tests and 22 synthetic CLI checks passed. The original PS s7 case still exits 1 with only --base cs=4, and an empty override retains all five defaults. The revised docs leave runtime signature size and the cause of pack() refusals open. Both review findings are resolved. AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested d34d1654 against my own 1.0.2.1 work folder (Linux, Python 3.14, make_game.py --stages check,shaders at aa2988cc): pass, the counts reproduce.

  • python -I tests/test_root_spill_census.py: OK.

  • I ran tools/root_spill_census.py <spirv/index.json> --carve <dxbc/index.json> --expect-no-spill on two indexes from the same corpus:

    • the native one (make_game.py on RADV picks wave64 emulation off);
    • one from a full rdna2spirv.py --wave64-emulate run, which is your configuration.

    Both exit 0.

  • RTS0: 0 of 26,503 containers have an RTS0 part.

  • Spill-pointer candidates: 0 in every stage.

  • Compute: largest USER_SGPR is 14, in 31 shaders, so 10 of the 28 root dwords are used. No shader uses all 16. The full distribution (emulated index): 4→4, 5→327, 6→528, 7→279, 8→82, 9→74, 10→238, 11→58, 12→1,028, 13→14, 14→31.

  • Highest reads, the same as yours in both modes:

    • PS: s31 (8), s29 (7), s27 (1), s25 (8);
    • MS: s29 (2), s27 (8);
    • VS: s25 (2);
    • GS: up to s21, all constants.

    The highest read is a 32-bit constant in 10,307 PS, 1,489 MS, 175 VS, 195 GS and 191 CS.

  • Population note: my indexes hold only spirv-val-valid modules. At aa2988cc this machine's SPIRV-Tools rejects 81 modules natively and 30 emulated, the "requires a previous definition" regression that Translator: constants assemble asks for late are defined too #3902 fixes. So my emulated index has 2,663 CS and 12,097 PS, where yours has 2,687 and 12,101. None of the totals above depend on those few, and the s-register maxima are identical. I didn't count the s1-as-constant split (109/551/12), because the tool's output doesn't print it.

AI-assisted (Claude Code).

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.

3 participants