Skip to content

make_game, runtime: translate and load game_scarlett_master.exe embedded shaders - #7746

Open
Faterek wants to merge 2 commits into
ItsNotRexed:mainfrom
Faterek:rt5-exe-embedded-shaders
Open

Faterek wants to merge 2 commits into
ItsNotRexed:mainfrom
Faterek:rt5-exe-embedded-shaders

Conversation

@Faterek

@Faterek Faterek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claim: #7599 (comment)
Depends on: none

Summary

Wires game_scarlett_master.exe's 10 embedded console DXBC/XBCH/FSSM shaders (1 VS + 9 PS, documented in docs/embedded_shaders.md §2 via #6840) into make_game.py's shaders stage and runtime/src/shader_library.h, mirroring bvh_shaders() and <dir>/bvh/index.json:

  • make_game.py: adds EXE_FILE = "game_scarlett_master.exe", exe_settings(), exe_report(), and exe_shaders(), invoked from shaders() right after bvh_shaders().
    • Extracts into <work>/shaders/exe and translates into <work>/shaders/spirv/exe (without --max-shared-memory, since these are graphics shaders, while forwarding --no-asm, --wave64-emulate, and fallback flags).
    • Tracks inputs in <work>/shaders/spirv/exe/exe_build.json, cleans stale .dxbc/.fssm/.s/.spv/.spvasm before re-extracting, reports translated and missing stems on every run, and fails if 0 programs translate.
    • When game_scarlett_master.exe is absent, drops any stale spirv/exe/index.json + exe_build.json and skips cleanly so packages without the executable are unaffected.
  • runtime/src/shader_library.h: loads <dir>/exe/index.json alongside fspx and bvh under the "exe/" prefix (keyed by (stage, fssm_sha256)) and exposes exe_size(). Missing or malformed exe/index.json leaves the other indexes loaded.
  • runtime/test/shader_library_corpus_test.cpp: subtracts library.exe_size() from rpf_entries and prints executable index entry counts.
  • runtime/test/shader_library_test.cpp: adds synthetic tests for <dir>/exe/index.json (VS + PS lookup, input_signature, spirv(), exe_size(), coexistence with fspx//bvh//main, duplicate hash ordering, and missing/malformed exe/index.json).
  • tests/test_exe_shaders_stage.py: adds 10 synthetic standard-library unit tests (no game data) covering PSV0 VS/PS extraction + fssm_sha256 metadata, caching/invalidation, missing/removed executable cleanup, partial/empty translation handling, and whole-shaders() integration.
  • docs/embedded_shaders.md: updates §7 to document exe_shaders(), <dir>/exe/index.json, exe_size(), and the measured end-to-end counts.

Testing

  • python3 -m compileall -q make_game.py tools tests — pass
  • python3 -I make_game.py --help — pass
  • python3 -I tests/test_exe_shaders_stage.py — 10/10 OK
  • python3 -I tests/test_bvh_shaders_stage.py — 13/13 OK
  • python3 -I tests/test_fspx_shaders_stage.py — 22/22 OK
  • python3 -I tests/test_pe_shader_containers.py — 19/19 OK
  • python3 -I tests/test_docs_list_items.py and tests/test_docs_repo_paths.py — OK
  • python3 -I scripts/check_no_game_data.py on all 6 changed/added files — pass
  • cmake -S runtime -B runtime/build && cmake --build runtime/build && ctest --test-dir runtime/build --output-on-failure — 62/62 passed (2 skipped: shader_library_corpus, vk_sync_validation); shader_library_test passed
  • End-to-end check on local retail 1.0.2.1 game_scarlett_master.exe (temporary folder outside repo, deleted afterward):
    • make_game.exe_shaders() native: 10/10 translated and spirv-val valid (1 VS + 9 PS), 0.52 s; cached reuse 0.05 s
    • make_game.exe_shaders() --wave64-emulate: 10/10 translated and spirv-val valid (1 VS + 9 PS), 0.40 s; cached reuse 0.05 s
    • ShaderLibrary::load() on <work>/shaders/spirv: size=10, exe_size=10, all 10/10 (1 VS + 9 PS) found by (stage, fssm_sha256) with non-empty spirv()
    • vk_pipeline_check (native and --wave64-emulate):
      • AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.2.6, Linux 7.3.4): 10/10 modules OK, 10/10 pipelines OK (0 failed, 0 skipped)
      • AMD Ryzen 7 9800X3D iGPU / Radeon 610M (RADV RAPHAEL_MENDOCINO, Mesa 26.2.6, Linux 7.3.4): 10/10 modules OK, 10/10 pipelines OK (0 failed, 0 skipped)

AI-assisted.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

AI-assisted review of ab03d8dd1 on Windows 11. The executable shader stage accepts an empty cached translation index. A fresh run treats the same result as a failure.

From the repository root, run this script with py -3.14 -I. It uses the PR’s synthetic fixture.

import sys
from pathlib import Path
sys.path[:0] = ["tests", "."]
from test_exe_shaders_stage import ExeStage
case = ExeStage()
case.setUp()
try:
    print(case.run_step())
    Path(case.spirv, "index.json").write_text("{}", encoding="utf-8")
    for attempt in range(2):
        print(case.run_step(), case.logs)
finally:
    case.doCleanups()

The first run calls all four tools. After the index changes to {}, both retries return [] and report 0 of 3. The runtime cannot find any executable shaders through that index. Please apply the fresh-build check to the cached result before returning. With these three translatable inputs, the first retry should rebuild the index and the second should reuse it.

py -3.14 -I tests/test_exe_shaders_stage.py passes all 10 tests on this head.

@LukeOsland1

Copy link
Copy Markdown

Verified on native Windows at PR head ab03d8dd1 using a local Xbox Series 1.0.2.1 package. Both Windows drivers created all ten graphics pipelines in each translation mode, with zero failures or skips.

GPU and Windows driver Native translation Wave64 emulation enabled
NVIDIA GeForce RTX 4070 Ti SUPER, 610.88 10/10 10/10
AMD Radeon integrated graphics, 32.0.21042.62 10/10 10/10

Each run covered one vertex shader and nine pixel shaders. In both translation modes, all ten modules passed spirv-val --target-env vulkan1.2. I also checked lookup from the original containers: the runtime library resolved all ten to their expected executable-index entries and read a nonempty SPIR-V module for each.

A second shader-stage run in each mode preserved the translated output files and their modification times. All ten executable-shader stage tests and the synthetic runtime shader-library test passed. The hardware checks exercised pipeline creation; pixel output and retail boot remain unverified.

MSVC 19.51, RelWithDebInfo. AI-assisted with Codex. Coordination claim

@Impre-visible

Copy link
Copy Markdown

Tested ab03d8d on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18), Python 3.14.10, llvm-mc 23.1.5, SPIRV-Tools v2026.4, with my own package 1.0.2.1 including game_scarlett_master.exe (--check: "all files present. Executable found."): pass.

exe_shaders() and bvh_shaders() called from this head on a scratch --work folder, once with wave64 emulation and once without:

  • game_scarlett_master.exe: 10 of 10 programs translated (1 VS + 9 PS, as the PR says), 10 of 10 pass spirv-val, in both modes.
  • XboxBvhBuilder.dll (unchanged step, as a control): 52 of 52 translated, 52 of 52 pass spirv-val, in both modes.
  • vk_pipeline_check (built at 4c52ce2) on spirv/exe: 1 VS and 9 PS modules ok, 10 of 10 pipelines created, 0 failed, 0 skipped, in both modes. All 10 are wave64 graphics, created here without a required subgroup size (32-wide device).
  • vk_pipeline_check on spirv/bvh: 52 of 52 compute pipelines created, 0 failed, in both modes.
  • python -I tests/test_exe_shaders_stage.py: 10 tests OK.

Not run: the full shaders stage through make_game.py (I called the two steps directly), and the runtime's shader_library tests.

AI-assisted run (Claude). Counts only; nothing from the game leaves this machine.

@Faterek

Faterek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @shdann for catching that — fixed in bc5fc47b9. exe_shaders() now checks if programs and len(programs[1]) < len(programs[0]): before reusing a cached result (matching the fresh-build check), and tests/test_exe_shaders_stage.py::ExeStage::test_empty_cached_index_is_rebuilt now covers both empty {} and all-error cached index.json files (rebuilding on the first retry and reusing on the second). Verified with your reproducer and python3 -I tests/test_exe_shaders_stage.py (11/11 OK).

Thanks also to @LukeOsland1 and @Impre-visible for the independent Windows and Linux hardware checks. AI-assisted.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

AI-assisted recheck of bc5fc47b9 on Windows. My empty-index case now passes. The first retry runs all four tools and restores all three synthetic shaders. The second retry reuses the index. All 11 tests pass with py -3.14 -I tests/test_exe_shaders_stage.py. I also ran the new regression test against parent ab03d8dd1. It fails there because the first retry runs zero tools. This resolves my finding.

@Doffi4

Doffi4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent synthetic integration check for the boot stack: I combined #7529 b93ffa5 with both #7746 commits through bc5fc47. The three merge conflicts were in make_game.py (keep both stages), shader_library.h (keep both optional indexes), and shader_library_test.cpp (keep both fixtures). On Windows x64 MSVC Release / CPython 3.12.10, executable stage 11/11, compute-library stage 6/6, and CTest shader_library all passed. I also checked one ShaderLibrary instance loading both indexes simultaneously: the embedded VS resolved by its stage/FSSM key, and the library CS by FSPX code/state keys. This is synthetic integration, not retail boot or a rendered frame. AI-assisted testing.

@freemanovec

Copy link
Copy Markdown
Contributor

Tested bc5fc47b9 on the retail executable, AMD RX 7900 XTX, RADV Mesa 26.3.1, Linux (CachyOS, kernel 7.3.5), Python 3.14.10, llvm-mc 23.1.5: pass. This is the first check of the current head with an executable, and the first on RADV. Run by an AI agent (Claude Code) on this account; outcomes only.

  • exe_shaders() was called from this head on my own 1.0.2.1 package, with game_scarlett_master.exe (all 108 manifest files at their sizes), into a scratch work folder. It extracts 10 containers (1 rejected DXBC hit), and fssm_unpack finds 10 FSSM blobs with no problems. The disassembly is 10 clean. The translation gives 10 translated, 10 pass spirv-val, all tier A.

  • The same with emulate=True (--wave64-emulate) gives 10/10 translated and valid.

  • vk_pipeline_check (from main, with MESA_SHADER_CACHE_DISABLE=true):

    mode PS VS
    native 9/9 pipelines ok 1/1 pipelines ok
    --wave64-emulate 9/9 pipelines ok 1/1 pipelines ok
  • python -I tests/test_exe_shaders_stage.py: 11 tests OK.

  • Not run: the runtime shader_library tests and the full make_game.py shaders stage with this head.

@Doffi4

Doffi4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Windows x64 integration result, using #7746 bc5fc47 with #7529 b93ffa5 and #6446 fb40ed3. Static extraction from a local 1.0.2.1 executable produced one VS and nine PS. LLVM 23.1.6 and SPIRV-Tools 2026.4: 10/10 translated and passed spirv-val for Vulkan 1.2 in each of the native and wave64-emulated configurations. vk_pipeline_check created 10/10 pipelines with zero skips in both configurations on Radeon 780M and RTX 5060 Laptop. The probe could not request 64-wide subgroups for those stages on the RTX, so this establishes compilation only, not native wave64 execution or a rendered frame. The executable was not run; all inputs and generated files stayed local. AI-assisted testing.

@ramenbellic

Copy link
Copy Markdown

Tested bc5fc47b against the retail executable under Proton (wine 11), RTX 3070, clang-cl 23.1.6 + xwin, own 1.0.2.1 copy, on the boot chain past stop 20 (#7154; ramenbellic:boot/retail-stack). Outcomes only: pass.

  • This PR's exe_shaders(), run alone on an existing work folder: 10 containers, 10/10 translated, 10 pass spirv-val (wave64 tier A: 10).
  • gta6rt --run: the shader library loads 26,586 entries (26,576 without the step). no translated vs lines go from 14 to 0, and failed CreatePipelineState calls from 16 to 2 (the remaining two aren't vertex-shader lookups).

I opened #8303 for the same change without seeing this one, and it is closed in favour of this PR. The results above are this PR's own code: the step was rerun from its branch and gta6rt built from it.

AI-assisted (Claude Code); outcomes only, no game data.

@Stalkerino

Copy link
Copy Markdown

I ran retail 1.0.2.1 under Proton CachyOS 11.0-20261015 with an RX 9070 XT (RADV) and Gamescope. I compared the same six graphics pipeline creations at device slot 86 on our local boot integration, which also includes #7880, #7286 and #7593.

Embedded programs available to Leonida Result of the six early CreatePipelineState calls
None 0 succeeded. All six stopped at the same missing VS.
Original VS only 0 succeeded. All six reached the PS lookup and stopped there.
Original VS + all nine PS 6 succeeded. No missing VS/PS messages.

The first three runs used the same binary with only the shader catalogue changed. I also built the integration with both commits from this PR, placed the ten translations in its normal spirv/exe directory, and repeated the retail launch without a catalogue override. All six creations again succeeded. The shader stage from bc5fc47b9 produced one VS and nine PS in native mode, and all ten modules passed spirv-val --target-env vulkan1.3.

This gives the executable shader change a measurable effect during retail startup. On this integration the runtime then accepted two ExecuteCommandLists calls and presented one black plane; the engine still reported Game Init, frame 0. No DrawInstanced or DrawIndexedInstanced appeared before exit. AI-assisted testing.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested bc5fc47 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_exe_shaders_stage.py - all exit 0.

AI-assisted (Claude Code).

@Yoshi-OOF

Copy link
Copy Markdown

Independent Windows 11 / RTX 5070 Ti (621.24) integration: extracted 10 executable shaders (1 VS / 9 PS), all 10 translated and passed spirv-val with wave64 emulation (tier A). The runtime loaded all 10 from the optional exe subindex alongside the original corpus and FSPX/BVH/library subindexes. With the audio memory shims also integrated, the title reached its frame loop without skipping guest assertions: 118 DrawInstanced calls and 41 successful PresentX in 300 s. There were still 41 failed command-list closes and captured frames were black; this is evidence for shader ingestion and frame-loop progress, not visible output.

@MarcPique

Copy link
Copy Markdown

Tested bc5fc47b9c7b57f155166963b880154a7c0aa95d on native Windows 11 build 26200, CPython 3.12, LLVM 23.1.6 and SPIRV-Tools 2026.4. tests/test_exe_shaders_stage.py passed 11/11. Calling the PR's exe_shaders() on the local 1.0.2.1 executable translated and validated all 10 embedded programs with wave64 emulation.

Separate retail A/B on an RTX 4090 (driver 32.0.16.1656, Vulkan 1.4.351), using one offline integration binary based on #8134, with the slot-86 pipeline route and the A8 fix from #7403 already in both runs. The only A/B change was whether the runtime could see the optional index of the 10 embedded programs.

Embedded index Slot-86 pipeline objects DrawInstanced calls PresentX successes
Absent 0/14 (14 missing vertex shader lookups) 0 1
Present 14/14 1 1

Both runs still hit a later 0xC0000005. This isolates the value of the embedded shader stage without conflating it with the A8 change or claiming a playable boot. AI-assisted testing.

@miguelsilva5989

Copy link
Copy Markdown

Tested bc5fc47 on CachyOS, LLVM 23.1.5, RTX 5080 (620.70.06) and Ryzen 9 9900X Raphael iGPU (RADV Mesa 26.2.6). Called the PR's executable shader stage with a local copy. Both native and wave64-emulated translation produced 10/10 modules (1 VS, 9 PS). All passed spirv-val for Vulkan 1.2. vk_pipeline_check created 10/10 pipelines per GPU in each configuration, with zero skips. The probe compiled stages without a forced subgroup size where the device does not support requesting it.

The synthetic stage tests passed 11/11 and the shader-library unit test passed. This covers Linux translation, loading logic and pipeline creation. No title execution or captured frame. AI-assisted verification.

@KevinPratap

Copy link
Copy Markdown

Tested bc5fc47b9 on RTX 4050 Laptop (NVIDIA 592.82), Windows 11, MSVC 14.44 RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, gta6rt --run offline: pass.

Merged onto @tibzejoker's rt5-integration 5fef1f1b1 (no conflicts), with #7922. I ran this PR's exe_shaders steps by hand: pe_shader_containers.py --extract, fssm_unpack.py, shader_disasm.py --mcpu gfx1013, then rdna2spirv.py --no-asm --wave64-emulate. That gave 10 containers extracted, 10/10 disassembled clean and 10/10 translated, all wave64 tier A, into <work>/shaders/spirv/exe.

  • Before: the runtime logged no translated vs for FSSM sha256 … six times, and six ID3D12Device2::CreatePipelineState calls failed.
  • With it: the library loads 26,594 modules (the 10 from exe/ included), there are 0 no translated vs lines, and those six PSOs are created. The run's D3D12 trace goes from 7 failed calls to 1 (an unrelated Close).

Traces stay local; no game data. 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.