Skip to content

make_game, runtime: the executable's embedded shaders are translated and loaded, again (RT-EXE-SHADERS) - #387

Open
Mumogg wants to merge 1 commit into
ProjectLeonida:mainfrom
Mumogg:exe-shaders
Open

Mumogg wants to merge 1 commit into
ProjectLeonida:mainfrom
Mumogg:exe-shaders

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in #14 as RT-EXE-SHADERS. Independent of my other open pull requests: it is based on main alone.

What and why

The retail executable carries a few shaders of its own (FSSM programs in DXIL containers, docs/embedded_shaders.md). At startup the title creates six pipelines from them. On main nothing translates them and the runtime's shader library does not look for them, so each creation fails with no translated vs for FSSM sha256 ....

Commit ab03d8dd1 by Faterek (-x, authorship kept; an ancestor of main whose content is not in the tree) does both halves:

  • make_game.py: an exe_shaders step in the shaders stage carves, unpacks, disassembles and translates the executable's containers into <work>/shaders/spirv/exe, after the BVH builder's.
  • runtime/src/shader_library.h: load() also reads <dir>/exe/index.json; its entries are named exe/<name>, found by fssm_sha256 like the game's own shaders, and counted by exe_size().

Adapted to main, as the commit message says: the exe folder is loaded after main's library folder (#19), shaders() calls exe_shaders after library_shaders, and the test's fake FSPX index carries fspx_code_sha256, which fspx_cache_complete needs now.

Overlap with #303: that draft carries tedin7's later version of the build half (old PR 10036) with its own tests/test_exe_shaders_stage.py. It does not have the runtime half. The two cannot both land as they are: if #303 is preferred for make_game.py, I will cut this down to the shader_library.h change and its tests. I took the one fix this copy of the test needed from that newer copy.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off. The boot run is on main ece4ba5b3 with my stacked pull requests up to #385 and with #142, #219 and #328, because the pipelines are only reached that far in; the work folder already held the translated exe folder (13 files) from an earlier build of the same step.

--run ID3D12Device2::CreatePipelineState
without this 6 failed
with this 6 ok

The run then goes on as before, to command-queue slot 35 being refused.

Tests, all without game files:

  • python -I tests/test_exe_shaders_stage.py: 10 tests, OK. tests/test_library_shaders_stage.py and tests/test_bvh_shaders_stage.py: OK. python -m compileall -q make_game.py tools tests: clean.
  • shader_library_test under Wine: passes, with the commit's exe folder case (entries found by FSSM hash, the main index first when both hold a program, a broken or missing exe/index.json leaves the others loaded).

Not run here: the exe_shaders step itself against my copy on this tree (the measurement above uses the folder an earlier build made), MSVC, Windows.

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

…ded shaders

(cherry picked from commit ab03d8d)

Adapted to main by Mumogg: the exe folder is loaded after main's library folder, shaders() calls exe_shaders
after library_shaders, and the test's fake FSPX index carries fspx_code_sha256, which fspx_cache_complete now
needs (as the newer copy of this test in old PR 10036 does).
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…, runtime: the executable's embedded shaders are translated and loaded, again (RT-EXE-SHADERS) [Mumogg]
@Snooozs

Snooozs commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

This still merges cleanly, but its own test is red on current main (a merge without a textual conflict). Merged onto main 3295055:

python -I tests/test_exe_shaders_stage.py
Ran 10 tests ... FAILED (errors=1)   test_exe_runs_after_bvh_and_alone_when_only_the_exe_changes
make_game.py:1369 native_pso_hashes -> tools/native_pso_hashes.py:49 json.decoder.JSONDecodeError
ERROR: shaders: could not index native graphics pipelines: Expecting value: line 1 column 1 (char 0)

The PR head alone passes (10 OK). main's shaders() now runs native_pso_hashes, which reads <spirv>/index.json, and this test's fake_translate writes an empty file there. tests/test_bvh_shaders_stage.py already writes a valid index in the same place. The same line here makes all 10 pass on the merged tree:

             def fake_translate(disasm, spirv, jobs, emulate=False, fallbacks=()):
                 ran.append("translate")
-                write("", spirv, "index.json")
+                write('{"shader": {"stage": "vs"}}', spirv, "index.json")

On the merged tree shader_library_test (rebuilt), tests/test_bvh_shaders_stage.py (13) and tests/test_make_game_preflight.py (98, 2 skipped) pass.

Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, CPython 3.12.10, no game files, so the real executable step was not run. AI-assisted (Claude Code): I read the code diff and ran this on that machine.

demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…ectLeonida#497's step reads

ProjectLeonida#387's test_exe_shaders_stage (on integration only) stands in for the
translation with an empty spirv/index.json. ProjectLeonida#497, which came with the upstream
fold, added make_game's native PSO step after the translation; it loads that
index and fails on an empty file. ProjectLeonida#497 changed the same fixture line in
test_bvh_shaders_stage (1740e09); this applies that change to ProjectLeonida#387's copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@slauko

slauko commented Nov 25, 2026

Copy link
Copy Markdown

Retail Wine data point: the executable's VS is missing, three PSOs fail, the boot continues

Build: main 42537e7b6 + the SDL3 artifact line (head f81cf9092), Wine 11.17, RTX 3080 Ti (595.112.07), retail 1.0.2.1, 26,555-program corpus (no exe/index.json).

The boot asks for FSSM sha256 01ac7810dcabd62afcd904b231e90d9a031a51808a700e3349290bec5f0d426f (VS), and three CreatePipelineState calls fail with no translated vs; the title continues to 129,459 D3D12 calls and 1,472 presents, so this is not the fatal stop on this run, but the frame-content gap is there. The exe_shaders stage in this PR is what supplies it.

The PR is currently CONFLICTING; a rebase plus a run with the stage would let a Wine boot confirm the frame side. Counts and call shapes only, no game data. AI-assisted.

@slauko

slauko commented Nov 25, 2026

Copy link
Copy Markdown

Frame-content data point under Wine: the first-run account-selection page renders its labels, but the artwork/background is black

Build: main 42537e7b6 + the SDL3 artifact line + #1558 (Wine 11.17, RTX 3080 Ti / NVIDIA 595.112.07, retail 1.0.2.1, 26,555-program corpus without exe/index.json).

The boot reaches the first-run account-selection page after ~300 s (29,354 presents, no exception): the page's labels and navigation arrows render, the background/artwork area is black. The log has 20 no translated vs lines for the executable's embedded VS and several CreatePipelineState failures. The exe_shaders stage in this PR is the missing half; it is not fatal (the page is usable with input), but it is a visible frame gap.

The PR is CONFLICTING; a rebase plus this stage would let a Wine boot confirm the artwork. Counts and call shapes only, no game data. AI-assisted.

@plamea

plamea commented Nov 26, 2026

Copy link
Copy Markdown

Windows / RTX 3050 Laptop GPU data point for the embedded executable shaders

I ran the standalone make_game.exe_shaders() step on main at fbf100b1b with the 1.0.2.1 executable and wave64 emulation enabled. All 12 embedded programs (1 VS, 11 PS, including both packed PS) translated and passed spirv-val. vk_pipeline_check created 12/12 modules and 12/12 test pipelines with zero failures or skips on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 621.24, on Windows 11. The checker used driver subgroups of 32. The checker binary came from my preceding local build based on a73a57e13.

python -I tests/test_exe_shaders_stage.py passed 11/11 on fbf100b1b. This covers the standalone translation step and the checker's Vulkan pipelines. Retail frame output remains unverified on this host.

AI-assisted (Codex).

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.

5 participants