translate --cache [--pipelines]: pipeline pre-build ported from upstream (first run loads instead of making) #1226
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1226
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1226"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@regiumlepidi on GitHub · 2026-11-26 00:53 UTC · original
regiumlepidi:prebuild-pr→main· +2823 −48 · 15 files · 4 commits · openPorts upstream VIctory's pipeline pre-build (
victory translate --cache [--pipelines], Marvisak/VIctory 13f91ca) to this fork, so a first run loads the shader pack's pipelines from the library instead of making them while the title waits.What it adds
victory-game: upstream'scityhash,shaderpackandpipelines(the pack's pipeline records), and the SGD5 databases' state tables. This fork's zlib-rs unpacking andrecords()are kept.translate --cache: translates every shader of the given archives into the shader cache.--pipelinesalso makes every nameable pipeline of the pack into the pipeline library, by the same code a run makes it with (host::HostPipeline::new). The library key comes from one function (make::key) shared by the run and the pre-build, so a run finds them under the same names.prebuilt-pipelines.txtin the cache dir lets a stopped pre-build go on where it was. A run never reads or writes it.VICTORY_PREBUILD_KEYS=<file>lists the keys and makes nothing.Use: run it with the same
VICTORY_*switches as the run (VICTORY_SHADER_OPT,VICTORY_WAVE_DEEP_SKIPS_NOT, heap map/window, root SRV switches change translations or names), the same build profile and features, and the run'sVICTORY_CACHE_DIR. Don't pre-build into a cache a run is using: both save the same library file.Measured on an RTX 5070 Ti (16 GB, 9800X3D, NVIDIA 617.42), diagnostics build, Series S profile, run-279 switch set:
Tests:
victory-game16/16,victory1/1.victory-gpupasses apart fromwarp_budget_saturates_without_wraparound_and_preserves_draw_fields, which is flaky onmaintoo (3 of 4 runs fail on WARP: it assumes group order). Not formatted beyond the existing style;mainisn'trustfmt-clean either.No game files or data are included. The port was made and tested with an AI assistant (Claude Code).
🤖 Generated with Claude Code
bare_command_costsays about the indirect clamp #696@slauko on GitHub · 2026-11-26 07:30 UTC · original
Ran it under Linux/Wine (RTX 3080 Ti, vkd3d-proton
ec20719, uiliannn's line; your two commits from006c3530, withShader::newcarrying that line's three ambient fields). Three observations:thread '<unknown>' (872) has overflowed its stack, once, 20 seconds in; the tool went on, and with it one pipeline. The pre-build's threads are plainstd::thread::scopespawns (prebuild.rs,translate.rs): unlike the run's workers (make.rs: 16 MiB, VIctory#1528) they set no stack size.VKD3D_SHADER_DUMP_PATHset, vkd3d-proton translated 1,092 shaders to SPIR-V again (246 MB of it), and its cache file is 1 MB. So on this stack the pre-build moves the cost from making to loading; the minutes to the first scene stayed (459 s before, 497 s after).VICTORY_PIPELINE_TIMES=1(in my line) is what gave the numbers of the third point: every load and every making with its time.@regiumlepidi on GitHub · 2026-11-26 08:19 UTC · original
Thanks for running it on that stack — useful numbers.
Stack overflow: right, the pre-build's scoped threads had the default stack. Fixed in a small helper (
prebuild::worker) that gives every pre-build worker the run's 16 MiB (pipeline/make.rs, VIctory#1528), used by all four of the PR's spawns (the three inprebuild.rsand the one intranslate.rs); pushed just now. Smoke-tested on Windows/D3D12: 22,525 shader containers translated in 90 s into an empty cache with the new workers, no panic. I can't reproduce the overflow here (native D3D12), so if you get the chance, a rerun on your line would confirm it.Cost per made pipeline under vkd3d-proton (~35×): that is the driver/translation stack's compile cost, not something the pre-build changes; the pre-build only moves it ahead of the run. On a stack where one make is ~13 worker-seconds the whole pack is probably not worth pre-building —
VICTORY_PREBUILD_KEYSplus the early list (the ~2,400 pipelines earlier runs drew with, which it already does first) is the part that pays off. I can add a--early-onlystyle limit if that would help on Linux; say so.Library loads at ~279 ms median under vkd3d-proton: agreed this caps what a pre-build can give there: D3D12 pipeline library loads that trigger a SPIR-V re-translation are on vkd3d-proton's side (its own shader cache /
VKD3D_SHADER_CACHE_PATHwould be the lever, not this PR). On native D3D12 here a load is cheap: 942 loaded, 1 made in a 25-minute run, no stalls.(Replying with Claude Code's help.)
8ff556842ftob55f71372f@slauko on GitHub · 2026-11-26 09:25 UTC · original
A correction to my earlier comment here, from a library rebuilt after the translator changed (same
translate --cache --pipelines, 15 workers, 3,491 of 27,160 pipelines, 1,443 made in 15 minutes):m3/m5, library from before the changem18, library rebuilt with--pipelinesThe scene came at 107 s (160 s before, 497 s on the first library) and the run ended at 183 s.
So "the pre-build moves the cost from making to loading, and the minutes stay" was about a stale library, not about loading:
translate --pipelinesmakes the host device and translates with its facts (wave size, view heap clamp), and blobs made under an older translator — or made without the device — no longer match, so nearly every load was a miss that re-made the pipeline in the driver. With a matching library a load is a hit and costs about nothing.Worth saying in the tool's output, I think: the library's age/fingerprint next to "N found in the library, M made" would have told me this on day one. (
vkd3d-proton.cachein the run's cache directory also grows over runs; I cannot separate the two hits, but the median going from 279 ms to 1 ms is not a cache that filled up gradually.)@regiumlepidi on GitHub · 2026-11-26 10:44 UTC · original
Thanks for the correction: that makes sense, and the stale library was a trap the tool should have pointed out. Pushed
b55f713:host-pipelines.stampis written with every library save: the "namer" of whoever saved it (the translator's fingerprint with the host facts and switches it reads, plus the shader cache / host description / library code: what decides a pipeline's name) and the save time. At start, a run or pre-build compares it with its own and logs eitherhost pipeline library last saved under this run's translator and switches(with its age), or a warning that the library was saved under another translator or other switches, so most loads will miss and remake the pipeline, and thatvictory translate --cache --pipelinesin the run's environment rebuilds it. A library with no stamp (saved by an older build) gets a one-line hint instead.mod rejected_bind_tests;inpipeline.rswith no such file, socargo test -p victory-gpu --libdidn't compile on this branch. Removed.victory-gpulib tests: 213 passed, 6 ignored (Windows/D3D12, RTX 5070 Ti), plus a small unit test for the stamp.The stamp tracks the last save. A library that held pipelines from two translators still says "this run's" after the newer one saved; the old entries then miss quietly. That seems the right trade-off over fingerprinting every entry.
(Written with Claude Code's help.)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.