Skip to content

make_game: seed the BVH pipelines into the runtime cache - #7586

Open
karearl wants to merge 2 commits into
ItsNotRexed:mainfrom
karearl:rt-601-bvh-cache
Open

karearl wants to merge 2 commits into
ItsNotRexed:mainfrom
karearl:rt-601-bvh-cache

Conversation

@karearl

@karearl karearl commented Nov 23, 2026

Copy link
Copy Markdown

Item: RT-601 cache-seeding integration
Claim: #7496 (comment)
Depends on: #7474 for checker/runtime feature matching

What changed

The shaders stage translates XboxBvhBuilder programs into spirv/bvh, but the pipelines stage only checked the main index. The runtime seed therefore missed every builder pipeline. After the main corpus succeeds, the stage now checks the BVH index with the same pipeline_cache.bin and jobs setting. Builds without a BVH index keep the existing single invocation.

This wires the offline seed needed for RT-601. An AMD boot timing run is still required, so this does not claim the watchdog stop is fixed.

Tested

Windows 11, CPython 3.14.10, synthetic indexes and checker processes only, no game data or GPU.

  • New integration regression: the original stage leaves the BVH entry out of the cache; this patch runs the BVH catalog and appends its entry to the same runtime seed.
  • test_make_game_pipeline_batches.py: 16 tests OK.
  • test_make_game_pipelines.py: 13 tests OK.
  • test_bvh_shaders_stage.py: 13 tests OK.
  • test_fspx_shaders_stage.py: 22 tests OK.
  • test_make_game_pipeline_preflight.py: 16 tests OK, 1 skipped.
  • compileall, git diff --check, and scripts/check_no_game_data.py passed.

Not yet measured on the affected AMD driver or against the retail boot.

AI-assisted (Kimi).

@Alpha325

Copy link
Copy Markdown

Independent check of 4db6ea09 on Windows 11 with CPython 3.12.14:

  • python -I tests/test_make_game_pipeline_batches.py -v: all 16 tests passed. The BVH regression confirmed the synthetic builder entry was appended after the main entries in the same cache.
  • python -I tests/test_make_game_pipelines.py -v: all 13 tests passed.

These tests cover the Python orchestration using synthetic checker processes or mocks. No game data, Vulkan driver, GPU execution, or AMD boot timing was tested.

AI-assisted (Codex).

@FelipeFrancca

Copy link
Copy Markdown

Independent Windows / CPython 3.13 check of 4db6ea0, including a negative control on its parent 3e1e6ea.

  • test_make_game_pipeline_batches.py: 16 tests OK.
  • test_make_game_pipelines.py: 13 tests OK.
  • test_bvh_shaders_stage.py: 13 tests OK.
  • test_fspx_shaders_stage.py: 22 tests OK.
  • test_make_game_pipeline_preflight.py: 16 tests run, OK with 1 skipped.

Copied the head's pipeline-batches test into an isolated parent checkout and ran only test_bvh_pipelines_are_added_to_the_runtime_seed. It fails on the parent because the resulting synthetic cache contains m_00 through m_06 but omits b_0. The same test passes at head. This independently confirms the regression test detects the missing BVH cache-seeding invocation. The temporary test change on the parent was restored afterward.

Scope is Python orchestration with synthetic checker processes and mocks. GPU cache hits, timing, feature compatibility from dependency #7474, and the AMD retail boot stop were not measured. Initial use of Python 3.11 hit the project's minimum-version preflight; all results above were rerun with installed Python 3.13.

AI-assisted (Codex).

@sennecools

Copy link
Copy Markdown

AMD data for the validation this still lists as open (RX 9070 XT, driver 32.0.32029.2010, Windows 11; own 1.0.2.1 copy). Not a test of this head's stage code, which I did not run.

One more thing a git merge-tree showed: this conflicts with #7509, which makes the same stage change.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 4db6ea0 merged with main dde82f2 on Linux/Python 3.12.16: pass

Merge is clean (make_game.py, tests/test_make_game_pipeline_batches.py). pipelines() gains seed_bvh(), which runs the checker over <spirv>/bvh (when its index.json exists) with the same --jobs, on the normal path after a successful run and on the old-build path; the failure path still calls fail() first. I read the diff and found no problem.

  • python -I tests/test_make_game_pipeline_batches.py: Ran 16 tests, OK. The test mocks the checker; I did not run vk_pipeline_check or any GPU work.
  • Negative control (make_game.py restored from upstream/main): Ran 16 tests, FAILED (failures=1): test_bvh_pipelines_are_added_to_the_runtime_seed (['m_00', ..., 'm_06'] != the same list plus 'b_0'), so the new test discriminates.

@FelipeFrancca

Copy link
Copy Markdown

Independent composition check following the AMD report above (Windows, CPython 3.13, synthetic inputs).

Trial-merged #7586 at 4db6ea0 with #7501 at c8a102d and #7538 at 29972c4 in an isolated worktree. The merge is clean. The combined tree passes:

  • test_make_game_pipeline_batches.py: 16 tests.
  • test_make_game_pipelines.py: 17 tests.
  • test_make_game_dry_run.py: 24 tests.
  • test_make_game_pipeline_preflight.py: 16 tests run, 1 skipped, remainder passed.

Code inspection confirms seed_bvh uses the same selected exe as the root run, so the Windows gta6rt.exe staging from #7538 applies to both.

Also independently confirmed the overlap: git merge-tree --write-tree between 4db6ea0 and #7509 at af68a9e reports a content conflict in make_game.py. #7509 already addresses both indexes with per-index recovery/diagnostics, whereas this head invokes the BVH run directly. Could the authors reconcile around one stage implementation and preserve that recovery behavior? Based on the hardware report, please also record Depends on: #7501 and #7538 in the surviving PR, alongside any remaining dependencies.

This checks Python orchestration and merge compatibility only. I did not build or run the Vulkan C++ changes, measure GPU cache hits, or reproduce retail boot. The AMD timings remain the reporting collaborator's measurements. AI-assisted (Codex).

@emirduran707

Copy link
Copy Markdown
Contributor

RDNA4 data point for the AMD timing this PR leaves open (RT-601). Setup: Windows 11, AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44, MSVC 2022 RelWithDebInfo, main + this PR (4db6ea09) merged at 155e5acce, and my own 1.0.2.1 copy. I report times and counts only.

  • BVH shaders: bvh_shaders() from this tree translates 52 of 52 XboxBvhBuilder programs, and all 52 pass spirv-val.

  • The constructor alone without a seed (bvh_builder_test, LEONIDA_BVH_DEVICE=vulkan, no pipeline_cache.bin; wall time of the whole test, every check passes):

    • first run on this machine, with the driver cache cold for these modules: 55.8 s;
    • second run, warm: 3.0 s.

    This is the same picture as the RX 7900 XTX row (52.8 s, then 31 ms for the constructor itself). RDNA4 is affected the same way.

  • The pipelines step this PR adds: vk_pipeline_check <spirv>/bvh pipeline_cache.bin takes 28.6 s on 6 threads over a copy of the 52 modules that the driver has never compiled. I made that copy by changing only the SPIR-V generator word, so the cache is cold without touching the driver's cache folder. The real modules give a 1,548,452-byte seed.

  • The runtime picks the seed up: with that file beside the executable, the device prints [rt] d3d12: loaded 1548452 bytes from pipeline_cache.bin and the test passes in 3.1 s.

One thing I could not measure: the effect of the seed alone on a cold driver cache. The AMD driver's VkCache folder is locked on this machine, and every run that writes a seed also warms the driver's own cache, so the 3.1 s cannot be split between the two caches.

What this does show is that the cold compile moves out of the boot and into the pipelines stage of make_game: about 29 s, done once, against 55.8 s inside the title's roughly 30 s window. Whether a seed made under one driver version survives a driver update (where the driver cache is dropped and the seed would be the only thing left) still needs a run across an update.

AI-assisted (Claude Code).

@nnonno91

Copy link
Copy Markdown

Independent Windows GPU check of #7586 (4db6ea092) with #7474, #7501 and #7538 applied to main at 99d799a. This also exercises the actual pipelines stage on AMD, alongside the RX 9070 XT retail-boot result.

On a Radeon gfx1036 iGPU, the combined stage ran its one synthetic main-index pipeline and then all 52 locally translated BVH pipelines, writing to the same pipeline_cache.bin. The stage launched the checker as gta6rt.exe through #7538. An isolated bvh_builder_test under that same basename then hit 52/52 distinct application-cache entries. All 53 creations succeeded with zero reported Vulkan validation errors. The Vulkan calls took 24.00 ms total, of which 8.16 ms was LoadInstances.

I also compared seed sources while keeping the checker binary and isolated builder fixed. Each row reports the median of three fresh builder processes. Driver-managed caches were left intact. Hits count the first creation of each distinct pipeline.

GPU Seed Application-cache hits per run Total Vulkan creation time LoadInstances
Radeon gfx1036 Empty 0/52 14.83 s 6.784 s
Radeon gfx1036 Default checker name 0/52 14.87 s 6.681 s
Radeon gfx1036 Matching executable name 52/52 20.64 ms 7.25 ms
RTX 5090 Empty 0/52 149.24 ms 44.43 ms
RTX 5090 Default checker name 52/52 16.83 ms 4.84 ms
RTX 5090 Matching executable name 52/52 16.92 ms 4.99 ms

The Radeon loaded the default-name seed file successfully and still reported zero application-cache hits. The same checker under the builder executable's basename hit every entry on that driver. The integrated-stage check covers the AMD constructor, and the full boot was outside this test.

Windows 11 build 26200, MSVC 19.51, Radeon Windows driver 32.0.21042.62, NVIDIA 617.42. Native wave64 for Radeon and emulated wave64 for NVIDIA, 52/52 modules passed spirv-val in each mode. The synthetic pipeline_cache_seed CTest passed on both GPUs, and 70 targeted Python tests passed on the combined changes. AI-assisted.

@karearl

karearl commented Nov 23, 2026

Copy link
Copy Markdown
Author

Real GPU validation on this branch including #7474:

  • 52 of 52 builder programs translated and passed spirv-val.
  • AMD gfx1036: 52 of 52 pipelines created; cold checker pass 28.9 s, LoadInstances 13.4 s. Second pass: 52 of 52 application-cache hits, effectively 0 s. The actual builder cannot run on this iGPU because the runtime has not implemented its separate 128-byte push-constant fallback.
  • RTX 5080: cold checker pass 33.9 s; second pass 52 of 52 application-cache hits in 0.3 s. With that seed beside the runtime, bvh_builder_test loaded the cache, completed all 53 slot-62 calls, constructor returned in 359 ms, destructor returned, and the test reported 0 failures.

This validates the seed and runtime cache path. The affected RX 9070 XT boot still needs its own timing run.

@karearl

karearl commented Nov 23, 2026

Copy link
Copy Markdown
Author

Standard CTest validation on the same build: pipeline_cache_file, pipeline_cache_snapshot, shader_library, bvh_builder, and vk_pipeline_check_cli all passed, 5 of 5.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested 2794429 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_make_game_pipeline_batches.py - all exit 0.

AI-assisted (Claude Code).

@Doffi4

Doffi4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent end-to-end synthetic cache check on Windows x64. Combined the #7586 BVH seeding commit 4db6ea0 with #7538 29972c4, #7501 ffeb250 and the #7474 feature commit acc4812 (local 204330f). I placed three distinct synthetic compute SPIR-V modules in the root, bvh and library indexes, ran the real make_game.pipelines stage with the built checker, and queried application-cache feedback on the Leonida Vulkan runtime device in separate processes. On Radeon 780M and RTX 5060 Laptop, the resulting cache hit for root and bvh and missed for library. An explicit third checker invocation on library, using the same gta6rt.exe copy and cache, made all three hit on both GPUs without losing the earlier entries. Focused Python suites passed 16/16 and 17/17. This confirms BVH coverage and isolates the remaining library-index omission for descriptor-free compute only. No game data or boot timings. AI-assisted testing.

@PytechNo

Copy link
Copy Markdown

Independent GPU verification of 2794429e on Windows 11 x64, GTX 1050 Ti, NVIDIA 581.80, Vulkan 1.4.312.

I ran this PR's make_game.pipelines() with a synthetic compute shader in the root index and a distinct synthetic compute shader in bvh/index.json. I tested both the upstream CI checker at 4eb6155d for the compatibility path and a locally built checker from upstream 867d922f for the current batched path. Each configuration passed twice.

The build stage called the checker for both indexes and used a single pipeline_cache.bin. A fresh checker process then reported 1/1 application-cache hits for the BVH shader with --cache-feedback. In the root-only control, the first BVH check reported 0/1 hits with the same compute fixture.

This covers the BVH index wiring and cache reuse in the checker. The runtime's descriptor layout and live boot remain separate measurements. Synthetic shaders only. AI-assisted by Codex.

@SoRadGaming

Copy link
Copy Markdown

The AMD boot timing run this PR asks for, on an AMD Radeon RX 9070 XT (RDNA4, Windows 11 build 26200, driver 32.0.31041.1004 / amdvlk64, Ryzen 7 5800X3D), with this PR at 4db6ea092 and #7474 at 2029116f3 on top of main@dde82f27e plus the boot-path PRs listed in this #7154 line. Own 1.0.2.1 copy, LEONIDA_D3D12=vulkan, LEONIDA_SHADERS set, MSVC 19.42 RelWithDebInfo.

The seed itself works. seed_bvh()'s call, vk_pipeline_check <work>/shaders/spirv/bvh pipeline_cache.bin, run on its own:

cs pipelines: 52 ok, 0 failed, 0 skipped
  cs wave32: 42 ok, 0 failed; wave64: 10 ok, 0 failed
  cs compile time: 59.02s total, 1.135s mean, slowest 28.31s
wall time: 29.6s on 8 threads
pipeline cache: 1548452 bytes

So on this AMD driver the 52 programs take about 59 s compiled one after another, and the slowest alone is close to the title's 30 s watchdog.

The boot does not get past stop 18 with it. With that pipeline_cache.bin beside gta6rt.exe, the runtime logs loaded 1548452 bytes from pipeline_cache.bin (no "does not match this Vulkan device"), and the boot stops exactly as without it: 1,640 D3D12 calls, then the watchdog at 36.5 s (39.0 s without the seed). A thread-stack sample 20 s in shows the title's thread inside amdvlk64.dll compiling, under proxy_slot<62> -> Device::CreateComputePipelineState -> PipelineState::create_compute (PipelineState::subgroup_size_for is also on that stack). So the seeded entries do not turn the runtime's first slot 62 pipeline into a cache hit here. I have not found which part of the pipeline key differs; the subgroup-size choice is one candidate, since the checker reports 10 wave64 and 42 wave32 pipelines and the runtime picks a size per pipeline in subgroup_size_for.

For comparison, #7516 on the same base gets past stop 18 (1,656 calls in 9 s, then stop 19).

Note for reproducing: the Vulkan SDK here is 1.3.296; SPIRV-Tools 2026.4 from conda-forge is first on PATH for the shaders stage (see #8173).

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.