Skip to content

shaders: build the graphics program index for device slot 57 (RT-SLOT57-NATIVE-GRAPHICS-PSO) - #1592

Open
Rain156 wants to merge 2 commits into
ProjectLeonida:mainfrom
Rain156:rain/slot57-graphics-library
Open

Rain156 wants to merge 2 commits into
ProjectLeonida:mainfrom
Rain156:rain/slot57-graphics-library

Conversation

@Rain156

@Rain156 Rain156 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-SLOT57-NATIVE-GRAPHICS-PSO. Original claim

Depends on: #497, #939, #984 and #974 (merged).

What and why

The normal shaders stage produced the compute pipeline library and the DXBC identity catalog. Device slot 57 could also look up raw graphics programs, but the build never populated that index. This follows up on the RDNA2 report in #497. Original report

  • Extract the pipeline-specific PS, VS and MS code with Leonida's existing reader, translate it and publish <shaders>/fspx_gfx/index.json. The graphics build has an independent resume marker that validates its index and module files.
  • The Vulkan factory first uses the container named by the stage records. It can resolve a missing identity by the full native program hash across all seven blocks, or retry a refused catalog PSO with indexed code of the same stage. It retains the decoded state, the input layout and the program bytes used by deferred binding. An ambiguous stage or an occupied block beyond the legacy fallback's two slots cannot silently produce an incomplete PSO.
  • The existing --trace-d3d12 switch reports catalog and kind-6 stage counts and the HRESULT. The full corpus test accounts for the new sub-index separately from carved DXBC containers.

Offline retail checks

Native Windows 11 x64, MSVC RelWithDebInfo, RTX 5070 Ti, NVIDIA 617.42, Xbox 1.0.2.1. The control runtime was unmodified c7e82e26e. The runs used a zero-capability AppContainer. The isolated control withheld only the DXBC identity catalog from the runtime inputs.

Build DXBC catalog Successful / observed slot-57 returns
main control present 25,450 / 25,450
follow-up present 25,450 / 25,450
main control withheld 0 / 25,450
follow-up withheld 9,958 / 9,958

The raw-only candidate trace attributed its successes to kind-6 lookups. The traces ended at title breakpoints after differing numbers of calls. They measure PSO creation during startup. World rendering and the reported RDNA2 iGPU still need their own verification.

Build and GPU validation

  • The standard make_game.py --stages shaders command backfilled the graphics library in an existing workspace. Its index was byte-identical to a separate full pass. A second standard invocation reused all six groups without changing any of their index bytes, index timestamps or module sizes/timestamps.
  • Native wave64 and wave64 emulation each passed spirv-val for 9,671/9,996 PS, 1,342/1,343 VS and 7,480/7,498 MS. All 18,493 published code hashes in each mode matched the complete extracted programs and had a module. The 344 remaining specialized programs were refused by the translator. Across 25,471 graphics records, raw keys alone supplied all stage links for 24,983. The DXBC catalog supplied all stage links for 25,450. Two records also refer to the unidentified slot 6.
  • The C++ corpus check loaded the 18,493 graphics entries and matched all 26,503 carved containers to their own primary entries, with zero failures. The primary and four pre-existing auxiliary indices matched the control byte for byte.
  • New synthetic VS+PS and MS+PS draws passed their GPU pixel checks in eager and on-demand compilation with synchronization validation. The VS case includes a PS reading its own code-base constants after the caller's buffers have been overwritten, a stale source container and a one-byte-wrong raw program. Fourteen related native CTests passed.
  • All 6,279 translator semantic tests passed across 487 files. The build regression sweep ran 661 checks with five skips and zero failures. The added graphics-only archive case, documentation links, compilation and repository game-data checks passed.

AI-assisted: Yes (Codex). The original claim is in #14. The successor tracker has the completion notice and the remaining specialized translation work.

@Snooozs

Snooozs commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

This has conflicted with main since the slot 57 state work (#1671, #1691, #1703) landed, so I merged main 446574e into it and tested that, in case it saves you the time: Snooozs/leonida branch merge-main-into-1592 (one merge commit on your 817b4be; take it with git pull https://github.com/Snooozs/leonida merge-main-into-1592, or redo it as you like - I am not opening a second pull request).

What needed a decision:

  • d3d12_xs_native_pso.h: main added the B4G4R4A4 stand-in blend retry after create_pipeline, in the body you moved into build(). I moved the retry into build(), so it runs for both stage sources, and before your retry with indexed code (a catalog pipeline that succeeds with the blend fallback is returned, as on main).
  • native_pso.h: git merges this without a conflict, but it would not compile: native_pso_blend_test and native_pso_depth_test on main call np::plan(desc, map), and here plan takes a third argument. I added a two-argument overload that only uses the records' containers.
  • d3d12_translated_draw_test.cpp: keeps both --native-fspx and --dual-source.

Tested on the merge, Windows 10 Pro 19045, RTX 5060 Ti, NVIDIA 621.01, MSVC 14.43 RelWithDebInfo: 24 of 24 of d3d12_translated_draw, xbox_native_base_draw, xbox_native_fspx_draw, xbox_derived_mask_*, d3d12_dual_source_draw(_eager), d3d12_mesh, xbox_native_fspx_mesh, native_pso_blend/depth/fallback, device_proxy*, xs_proxy*, shader_library; tests/test_library_shaders_stage.py 18 of 18 (before the overload was added; it is Python only). Not run: the whole ctest set, a boot, the dual-source path together with indexed (kind-6) stages.

I am translating the graphics programs from my own package with the merged make_game.py (llvm-mc 23.1.6, wave64 emulation) and will add the counts here.

AI-assisted (Claude Code).

@Snooozs

Snooozs commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Counts from my own 1.0.2.1 package, as promised: merged make_game.py (translate_library_stages, fspx_gfx only), llvm-mc 23.1.6, --wave64-emulate, 8 shards, 22 minutes including unpacking: 18,493 of 18,837 programs, all 18,493 pass spirv-val: 9,671 PS, 1,342 VS, 7,480 MS. Exactly your emulated numbers. AI-assisted (Claude Code).

@BubsMcgee

Copy link
Copy Markdown
Contributor

Retail-boot data point that this PR should fix (Windows 11, RTX 3080 Ti, driver 616.64; main-based runtime at 71a769d7d, shaders stage run from a 1.0.2.1 package):

  • The runtime reports 29277 translated shaders (2710 fspx, 0 fspx_compute, 0 fspx_gfx, 52 bvh, 12 exe) — the graphics program index is empty, matching DadaCap's "no fspx_gfx set" finding.
  • Slot 57 is used: device slot 57 (Xbox native graphics pipeline / PC lifetime tracker) first call, routed to DeserializeGraphicsPipelineStateX.
  • Exactly 4 ID3D12Device2::CreatePipelineState failures, paired fail/ok/fail/ok at trace records ~127452/127454 and ~128214/128215, then the boot continues to session d with non-black frames.

So those 4 failures line up with slot-57 native graphics PSOs that cannot resolve a graphics program without fspx_gfx. This PR builds that index and adds the catalog/kind-6 retry, so it should turn them into successes. For contrast, #1497 (bary-fallback) and #1818 (on-demand console streams) do not apply to this boot: the device has fragment-shader barycentrics, and the boot is eager, not LEONIDA_PIPELINE_COMPILE=on-demand.

I have not run this branch (it is CONFLICTING on current main), but I can test Snooozs/leonida:merge-main-into-1592 plus a full fspx_gfx build and re-run this boot if that is useful. Counts and record numbers only; no game data.

AI-assisted.

@DadaCap

DadaCap commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Retail result with this branch merged onto a tree of current main (RTX 5080, NVIDIA 621.24), 18,735 of 18,837 programs in fspx_gfx (18,493 from the pull request as it is, plus 242 of its refusals re-disassembled with tools/rdna2_decode.py; the remaining 102: 78 DPP on v_cmpx, 18 s_getpc_b64, 6 without a container). The ten hashes one run asked for at slot 57 are all covered. With it, native_hashes.txt and an indirect mesh merge, a run showed a world picture (#1608 finding).

Two things that may save someone a day:

  1. The catalog comes first. With fspx_gfx but no native_hashes.txt the title's frames were black from the intro on (the package splash stayed on screen); with both, or with the catalog alone, the intro plays. The log line is slot 57 has no native_hashes.txt; checking indexed native programs. My folder lacked it because I had re-translated with a script of mine.
  2. Compile cost is graphics now: the first world frame built 168 pipelines and the second 297, up to 41 s for one mesh pair.

Merge notes: the only semantic conflict was the B4G4R4A4 stand-in blend retry in d3d12_xs_native_pso.h (kept inside this pull request's build()). ctest on the merge: xbox_native_fspx_draw, xbox_native_fspx_mesh, d3d12_translated_draw, native_pso_blend, native_pso_depth, native_pso_fallback pass. AI-assisted (Claude Code).

@BubsMcgee

Copy link
Copy Markdown
Contributor

Tested Snooozs/leonida:merge-main-into-1592 (202d6d2) in the retail boot — RTX 3080 Ti, driver 616.64.

The slot-57 fix works:

  • the port loads spirv/fspx_gfx (18,493 programs) and logs device slot 57 routed to DeserializeGraphicsPipelineStateX, with slot 57 stage sources: catalog=1/2 kind6=0 hr=0x0;
  • the four slot-57 CreatePipelineState failures from the eager boot (~#127452/#128214) are gone;
  • the game now passes that point: session d at t75 s, 2,505 presents, 40/40 non-black frames, 0 device faults, and it starts streaming world data (160 file opens) from t97 s in a 240 s boot.

Remaining on the same boot:

  • 15 ID3D12Device2::CreatePipelineState failures, all on PipelineStream::Mesh streams (type 24, "contains a mesh shader; DXIL kind 13") — #137311/#137313/#138069/#138074 and #229763/#229766/#229771/#230854/#230861/#230868 (10 of 15 listed). Hundreds of other mesh streams created; the log gives no refusal reason for these 15.
  • The 240 s run then exits 0xC0000005 in amd_fidelityfx_upscaler_xbox.dll+0x65ff (read 0x10) at ~175 s, while the world is loading; a 120 s run does not reach it. That is the FSR path, not slot 57.
  • The boot also logs 0xC0000005 in leonida::fsdraw::has_tsharp; that is our local LEONIDA_LOCAL_DIAGNOSTICS probe, not this PR.

@Rain156 @Snooozs: is the 15-stream mesh-shader refusal expected (programs the library does not carry?), and is the FSR crash at world load known? I can re-run with local diagnostics off for a clean digest.

AI-assisted.

@BubsMcgee

Copy link
Copy Markdown
Contributor

Follow-up on the FSR crash: it is the FSPX translation, not slot 57.

  • spirv/fspx carries 27 of the DLL's 29 programs; amd_fidelityfx_upscaler_xbox_03 and _18 are the two missing (all 29 are unpacked under shaders/fspx).
  • The FSR4 DLL's slot-67 DeserializeComputePipelineStateX call 2694 returns 0x80070057 (E_INVALIDARG); that is the pass the DLL names FFX_FSR4_PASS_4. It falls back to "NewBE", the runtime marks that ID3D12Device2::CreatePipelineState unsupported (#123672), and the DLL's CreateModel(...) == FFX_API_RETURN_OK assertion fires → the 0xC0000005 in amd_fidelityfx_upscaler_xbox.dll+0x65ff at ~175 s (the 120 s boot never reaches it).
  • The rest of the 240 s boot is clean for this PR: session d, 2,505 presents, 40/40 non-black, 0 device faults, 160 world files opened, and the 18,493-program fspx_gfx resolving slot 57.

So the world-load blocker is translating the two missing FSPX programs (pass 4 is presumably _03/_18).

@Rain156 @Snooozs is this two-program FSPX gap already owned/tracked elsewhere? docs/fspx.md currently says 27 of 29 translate, so it may be known. I can file it as a finding if not.

AI-assisted.

@kurrutako

Copy link
Copy Markdown
Contributor

@BubsMcgee on the two missing FSPX programs: #1862 (SHADER-FSPX-DOT4-EXACT, open) is the fix for that gap. With it, all 29 FSPX programs translate on a retail copy here (27 of 29 on main). Retail boots on an RTX 5070 with #1862 merged no longer end in the amd_fidelityfx_upscaler_xbox.dll access violation; before it, my boot hit it at about 210 s. Those boots did not have this branch, so I can't say how the two interact. AI-assisted.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@OreoFR

OreoFR commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@Rain156 is this still on your side? It now conflicts with main (needs rebase). Two things that may help:

  • rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP) #1647 is merged, so the 78 DPP on v_cmpx refusals DadaCap counted here now translate. That leaves 18 s_getpc_b64 and 6 without a container.
  • Snooozs has main merged into this branch (Snooozs/leonida:merge-main-into-1592), and BubsMcgee confirmed slot 57 loads 18,493 programs with it.

Happy to test a rebased branch on an RTX 4070 Laptop (NVIDIA 621.40). If you'd rather hand it over, say so and someone can carry it on. AI-assisted (Claude Code, Claude Opus 5.5).

@Coderlord

Copy link
Copy Markdown

@Rain156 @OreoFR this conflicts with today's main (63185f4) in three files, all against the new slot-57 blend and depth state. Here's a resolution, in case it saves someone the work: Coderlord/leonida-ubiq:merge-main-into-1592 (de01b13, two commits on 817b4be: the merge, then a test fix).

  • d3d12_xs_native_pso.h: this PR's build() (catalog container or the library's indexed program, and the retry with the indexed bytes) now holds main's B4G4R4A4 stand-in blend retry, so both attempts get it. Includes from both sides.
  • d3d12_translated_draw_test.cpp: main's --dual-source and this PR's --native-fspx side by side, with the kind-6/FSSM wording in the closing line.
  • CMakeLists.txt: main's d3d12_mesh_heavy_cache and this PR's xbox_native_fspx_mesh.
  • Test fix: main's native_pso_blend_test and native_pso_depth_test call plan() with two arguments, so they don't build against this PR's three-argument plan(). They now pass a code-stage callback that knows no code ranges.

Tested on an RTX 5080 (NVIDIA 621.40, Windows 11) as part of an integration branch with these same four files plus other open PRs: the 11 tests on these files pass (d3d12_translated_draw, d3d12_dual_source_draw and _eager, xbox_native_fspx_draw, d3d12_mesh, d3d12_mesh_heavy_cache, xbox_native_fspx_mesh, native_pso_blend, native_pso_depth, native_pso_fallback, dual_source_fragment; the two native_pso_ ones after the test fix). This branch alone was not built. AI-assisted (Claude Code).

Snooozs added a commit to Snooozs/leonida that referenced this pull request Nov 27, 2026
Conflicts: the blend fallback of ProjectLeonida#1671/ProjectLeonida#1703 for B4G4R4A4 stand-ins moves into the build() that ProjectLeonida#1592 split out, so
it runs for both stage sources; the translated draw test keeps --native-fspx and --dual-source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants