Skip to content

Package translated graphics shaders for the slot-57 cache - #9153

Open
nova-aryan wants to merge 1 commit into
ItsNotRexed:mainfrom
nova-aryan:contrib/04-slot57-graphics-cache
Open

nova-aryan wants to merge 1 commit into
ItsNotRexed:mainfrom
nova-aryan:contrib/04-slot57-graphics-cache

Conversation

@nova-aryan

Copy link
Copy Markdown

Claimed in the coordination issue: Package translated graphics shader modules for the slot-57 cache.

Depends on: #8890 (runtime consumer)

What and why

The slot-57 boot repro needs translated graphics modules indexed by native program hash. The loader in #8890 consumes fspx_gfx/index.json, and the current repro assembles that directory by hand.

tools/pack_fspx_gfx.py builds the cache from the existing rdna2spirv.py output. It keeps the stage and translation metadata and writes each module under its full native program SHA-256. A boot repro can pass --require-hashes to select its programs and fail if any are missing. Conflicting translations for one digest fail rather than letting the loader choose an ambiguous candidate. A new cache becomes visible to the loader after its modules are written.

Tests

  • Windows 11, Python 3.13.14: 10 new packer tests and 10 shader-library tests passed. The FSPX unpack suite ran 34 tests with one skip.
  • WSL Linux: 10 new packer tests passed. Assembled and validated two synthetic modules with SPIRV-Tools for Vulkan 1.2. Compiled the real d3d12_xs: slot 57 DeserializeGraphicsPipelineStateX, fspx_gfx index, and pipeline blob input layout #8890 ShaderLibrary at f1ab75ac with GCC and verified it loaded both modules by hash, preserved their stage and push-constant metadata, and returned no entry for a missing hash.
  • The WSL semantic suite ran 5,957 tests and reproduced the baseline failures in test_image_atomics_guard and test_image_store_d16. The text newline and docs CLI flag checks also reproduced their baseline failures.
  • git diff --check, compileall and the changed-file game-data check passed. CPU-only tests with synthetic inputs. Retail boot and GPU pipeline creation remain unverified.

AI-assisted: Yes (Codex).

@catminou4

Copy link
Copy Markdown

Tested on Apple M1 Max, macOS 27.2.1 arm64, Python 3.12.16: python -I tests/test_pack_fspx_gfx.py → 10 tests OK. No game files. AI-assisted (Devin).

@dcastell1

Copy link
Copy Markdown
Contributor

Tested on RTX 5090, 621.24, Windows 11: no change on its own, which is what its "Depends on #8890" says — worth pinning so nobody concludes the packer is wrong.

Base: ASTROWwwW:ladder-frame@a1751a9 + #6943 + #8591 + #9153 (merged locally), corpus index.json + bvh/ + fspx/, --run 50 s with --trace-d3d12 and LEONIDA_SKIP_INT3=1:

before #9153   50468 CreatePipelineState  10241 CreateLifetimeTracker  0 ExecuteCommandLists  0 draws  1 PresentX
with #9153     50469 CreatePipelineState  10242 CreateLifetimeTracker  0 ExecuteCommandLists  0 draws  1 PresentX

So the slot-57 cache is not consulted because the runtime consumer (#8890) is not in the tree; the counters are identical within noise. The packer itself is fine — I did not run it in this configuration.

Two facts for whoever lands #8890: it currently conflicts with ladder-frame in runtime/shims/d3d12_xs_device.{cpp,h}, runtime/src/shader_library.h and runtime/test/device_proxy_test.cpp, so a rebase onto that branch is needed before this pair can be measured together here. On a clean main + the boot stack the pair may apply; I did not try that combination yet.

@GonZiin

GonZiin commented Nov 23, 2026 •

Copy link
Copy Markdown

Review (AI-assisted, static; no game files, and I did not run the packer on a real library).

1. Default mode aborts on an index entry that rdna2spirv.py itself writes. tools/rdna2spirv.py (around line 18172) stores meta[name] = {"error": "<Type>: <message>"} when collecting metadata for a translated, spirv-val-valid shader raises ("metadata must never cost a translation"). In select_programs, with no --require-hashes, such an entry has no stage, so the code reaches raise ValueError(... has no valid stage) and the whole pack stops, with no cache written. The same entry is silently skipped when --require-hashes is given (the digest test comes first), which is what test_required_list_selects_only_requested_graphics exercises with its "other": {"error": ...} entry. So one metadata failure among ~20k programs blocks the full build but not the targeted one. Please make the two modes agree: skip entries that carry error (or lack both stage and a digest), count them and print the count, and keep the hard failure for a graphics-stage entry that has a stage but no valid digest.

2. A graphics entry without fspx_code_sha256 is also fatal. shader_meta.collect only sets that key when no fssm/<name>.fssm sidecar exists next to the disassembly. If any graphics program in the library has such a sidecar, its entry carries fssm_sha256 instead and the same has no valid fspx_code_sha256 error stops the pack. Say in the doc whether the slot-57 library can have FSSM sidecars, or accept fssm_sha256 for graphics programs the way docs/fspx.md describes for compute ("Entries are found by fssm_sha256 or by fspx_code_sha256, in two separate tables").

3. No run against real output. The tests are synthetic and the documented run (shader_library.py -> rdna2spirv.py -> pack_fspx_gfx.py) is not reported. Because one conflicting pair aborts the pack (conflicting translations for <digest>), the useful numbers are: graphics programs in the index, distinct digests, and how many digests have more than one entry (and whether any of those differ in metadata, for example input_signature, which collect reads per name from <name>.dxbc). A one-line count over a real library would show whether the strict equality check is right or whether it needs to compare only the fields the runtime reads.

4. Small. docs/fspx.md says compute programs may share kind-6 bytes and differ by fspx_state_sha256. A graphics program with a .state file would hit conflicting translations here for the same reason, rather than be told apart by the state key. If graphics programs never carry kind 0, say so in the doc so the next reader does not wonder.

The rollback with ExitStack, the publish-index-last order, the module-name check and the refusal to replace an existing directory read correctly to me.

@dcastell1

Copy link
Copy Markdown
Contributor

Measured on the retail package, and it changes what this pair can do here: the FSPX corpus of 1.0.2.1 is compute-only, so there is nothing to pack for the slot-57 graphics cache.

That is not a defect of the packer: it is what this package's FidelityFX DLL offers. Unless the 8 undecodable programs are the graphics ones (a decode gap, worth knowing on its own), the slot-57 graphics cache cannot come from FSPX on 1.0.2.1 and the cache has to be fed from somewhere else.

I did not run --require-hashes (no boot repro hash list here). If the repro's list is graphics FSPX, it would have failed on this package, which is the same finding from the other end. agent: yes

@Yoshi-OOF

Copy link
Copy Markdown

Independent Windows 11 validation on 95ccdd1: extracted the five native programs used by the first three reference graphics records, with their matched VS/PS container interfaces. All five translated and passed spirv-val. The packer with --require-hashes produced exactly the five requested keys; each matched SHA-256 of the full source program. This checks the real producer/packer boundary, not rendered pixels or a full-catalog result.

@Yoshi-OOF

Copy link
Copy Markdown

Producer coverage follow-up: my demanded-only cache packed all 1,266 distinct native graphics programs observed across startup, each translated and validated; a retail run with it recorded 9,866 successful slot-57 calls before a separate queue/device stop. The full VS/PS catalog experiment separately translated and spirv-val validated 9,211 of 11,339 programs. These counts validate the producer boundary; displayed frames are still black and the title is not playable.

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.

5 participants