Skip to content

Kyty shader and pipeline precooking before first launch #338

Todo

Description

@simnJS

We're claiming this issue and will own the implementation.

Goal

Discover and prepare shader and Vulkan pipeline variants before a title's first interactive launch. With a prepared cache, the tested scenes should perform zero shader translations and zero driver pipeline compilations during gameplay.

The current manifest can warm known recipes. The file scanner can recover shader code from supported containers, and some variants still depend on descriptor shapes, linked code, or render state selected at runtime.

Work to do

  • Add an offline inventory mode that scans supported shader containers and extracts shader code, creation metadata, and any shipped pipeline recipes. Report inputs that could not be read or resolved.
  • Generate recipes from the available metadata. Start with generic compute variants that can serve multiple compatible descriptor shapes. Use available render state to prepare graphics pipelines or their reusable parts.
  • Merge recipes collected by instrumented playthroughs for states that become observable at draw or dispatch time. Use kyty_precache to prepare the merged manifest on the target GPU before the first interactive launch.
  • Measure coverage for guest shader discovery, host shader variants, and ready Vulkan pipelines. Record why each first-use miss occurred, including unavailable, incompatible, or unfinished recipes.

Acceptance criteria

  • A synthetic fixture verifies that offline inventory finds packaged shaders and produces the derivable recipes without launching the title executable.
  • Starting from an empty emulator cache, run the offline precook and launch with its output. On a documented reference route, record zero in-game shader translations, zero Vulkan pipeline compilations, and zero draws or dispatches skipped for a missing pipeline. Verify the expected output and report the GPU and driver.
  • A control that leaves out a known recipe reports the expected miss. Report coverage for the tested route and settings so gaps can be tracked as new paths are exercised.

Related to #33, #302, and #327.

Activity

  1. self-assigned this
    on Nov 26, 2026
  2. github-actions commented on Nov 26, 2026

    @github-actions

    Thanks for claiming this. In the PR, please distinguish a hit in Kyty’s recipe cache from evidence that the Vulkan driver did not compile a pipeline. Document how you measured that on the reference GPU and driver, and use the omitted-recipe control to verify that the first-use miss is reported.

  3. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    We extracted 16,040 distinct guest shader programs directly from the local files of a native PS5 title, without a prior session cache. Creation metadata matched 15,494 programs. The offline compute catalogue found complete creation inputs for 3,197 programs. This establishes shader and creation-record coverage. The full render-state recipes are still under investigation.

    The instrumented graphics run captured all 20 queued pipeline recipes observed in that run. Nineteen were absent from its saved manifests, and the local shader store contained every referenced code blob. The collector can now merge those recipes into the offline precook inputs.

    For driver-level evidence, the audit probes pipeline creation with VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT. It reports successful no-compile calls, calls requiring compilation, and unverified outcomes separately from Kyty recipe lookups. On an RTX 4080 SUPER with NVIDIA 595.99.02, a synthetic compute replay produced matching output. A cold driver-cache pass exposed a compile-required create, while both audited creates succeeded with compilation disabled on the warm repeat. The real reference route still needs an end-to-end run with its prepared and omitted-recipe inputs.

  4. github-actions commented on Nov 26, 2026

    @github-actions

    The cold/warm synthetic result validates the audit, but it doesn’t yet show that precooking alone prepares the reference route. For the end-to-end run, start each arm with an empty emulator cache and an isolated cold driver cache before precooking, so the prepared run can’t warm the omitted-recipe control. Report any unverified pipeline creates separately rather than counting them as no-compile successes.

  5. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    The native asset investigation found a shipped effect and pass database. Two bundles contain 934 effects and 29,912 passes, with stage selections and render-state references. The shader stage pairs for all 20 instrumented graphics misses occur in the shipped tables. The broader comparison matched 1,131 of 1,153 graphics recipes by stage pair. This is a practical source for first-launch graphics coverage. Attachment formats and concrete descriptor views still need to be mapped and verified.

    The executable also contains detached shader creation headers. Indexed relocation records and direct shader creation calls recover 577 validated header/code associations automatically. This brings the offline inventory to 16,040 of 16,040 indexed programs with creation headers, yielding 3,737 launch recipes for 3,729 compute programs. The recipes include the guest program hashes of every compute miss in the two measured runs. Exact variant compatibility and ready Vulkan handles are the remaining tests.

  6. github-actions commented on Nov 26, 2026

    @github-actions

    For the reference route, please report how many shipped stage-pair matches resolve to exact pipeline recipes after attachment formats and descriptor views are accounted for. Keep stage-pair-only matches separate so the coverage numbers show which recipes can actually be precooked.

  7. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    Two embedded effect tables in the executable account for another 18 graphics recipes. The offline stage-pair match is now 1,149 of 1,153 reference recipes. The four remaining recipes have a vertex-side program present in the shipped data but no fragment stage in the live depth/stencil pipeline. Comparing actual state still matters. We also observed identical host shader-module combinations used with different attachment formats.

    On the reference RTX 4080 SUPER, the long offline pass recorded 187 seconds of summed shader translation time and 2,738 seconds of summed pipeline creation time across four workers. These are cumulative worker times. The graphics manifest finished earlier, leaving a compute-only tail at the time limit. This makes repeated driver work and the long compute tail the main optimization targets.

    The matching-build PC repeat now restores 1,408 modules and enters the precook gate before guest entry. The earlier run with a mismatched shader-store stamp is excluded from the warm reference measurement. The audit will record the gate release and driver compile results for the measured route.

  8. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    The matching-build PC run completed all 3,097 startup jobs in 153.35 seconds before guest entry. The audit then recorded 14 shader builds and 29 create calls for which Vulkan returned VK_PIPELINE_COMPILE_REQUIRED during the observed route. Eighteen of the 29 were graphics library calls, ten were compute pipelines, and one was a full graphics pipeline. The test hit its time limit and did not establish zero in-game compilation.

    We also compared four and six preparation workers on the same RTX 4080 SUPER and NVIDIA 595.99.02. Each arm started with the same 41 shader modules and 32 pipelines, four concurrent Vulkan compute-call slots, and an empty Vulkan cache. NVIDIA's disk cache was disabled. The elapsed times were 9.086 s vs 8.094 s, and 9.104 s vs 8.101 s when the order was reversed. Both arms completed all jobs. This is about an 11% reduction on that batch.

    The fragment-output library change reduces distinct keys from 68 to 46 in the 1,153-recipe trace. Its actual rendering-path gain and the remaining speculative library work are still being measured.

  9. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    The shipped pass tables contain 29,926 pass records. Resolving the referenced shaders and explicit rasterizer, depth/stencil and blend state yields 12,513 distinct graphics signatures. In a reference capture, 581 graphics recipes used 482 distinct stage sets, with up to 38 recipes for one set. The attachment and resource state chosen at runtime still determines how many Vulkan variants these signatures produce.

    The targeted startup seed resolved the exact compute variant that previously caused a roughly nine-second wait. Vulkan confirmed a cache hit before guest entry, and all 3,445 scheduled precook jobs finished before the guest started. The subsequent loading route still requested 118 compute pipeline compilations and eleven graphics pipeline or library compilations within the validation window.

    Six synchronous stalls came from three compute programs with two buffer specializations each. The stalls took roughly 10–11 seconds each. CPU checks on the recorded resource plans confirm that the populated form can serve the observed empty descriptors with the existing guards. The populated form is therefore a candidate to prioritize during precook.

    Four cold driver replays of the original blocked module took 14.5–14.9 seconds on this PC. The Vulkan optimization-disable flag produced no useful improvement. Compatible image-table and image-heap variants can now be rebound in CPU tests. The next runtime validation will measure how many compile-required events this avoids.

  10. github-actions commented on Nov 26, 2026

    @github-actions

    The confirmed pre-entry cache hit is a useful result: the startup seed addressed the previously identified stall, but the loading route still falls short of the zero-compilation target.

    For the next runtime check, please compare the same route with and without compatible variant reuse. For the six previously stalled dispatches, verify output and report which still return VK_PIPELINE_COMPILE_REQUIRED and how much synchronous wait remains. The CPU checks establish compatibility for the recorded resource plans, but not yet correct GPU output or reuse without compilation.

  11. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    The 118 compute compile-required events correspond to 108 distinct guest shader programs. All 108 were matched to shader bytes and compute creation metadata in the offline inventory. We traced 105 programs to the shipped shader archive and three to the executable. The startup seed already contained recipes for 37 of the 108 programs. The result narrows the remaining work to precook selection and resource specializations supplied by guest dispatches.

    An earlier comparison revealed that the manifest scheduler still limited large jobs to four workers even when the offline driver budget was set to six. After wiring that budget through the scheduler, the same cold batch of 25 heavy recipes completed in 73.6 seconds with six concurrent Vulkan calls and 105.7 seconds with four. Both arms completed the same set of 24 compile-required pipeline creates. The roughly 30% reduction measures offline batch time on one PC.

    The four remaining graphics keys in that run share attachment and fixed state with prepared pipelines. One needs a changed indirect sampler mapping and its normal/plain companion. The other two use native table-binding shader modules. Capturing those exact native modules and pipeline routes is the next graphics work.

  12. github-actions commented on Nov 26, 2026

    @github-actions

    The scheduler fix cut cold batch time by about 30% on the reference PC with the same set of compile-required creates. That measures offline preparation time, not gameplay coverage.

    For the 37 programs already represented in the startup seed, how many had the exact runtime variant fully prepared before guest entry? That split will help distinguish missing specializations from cases where a prepared variant still resulted in VK_PIPELINE_COMPILE_REQUIRED.

  13. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    An offline holdout experiment used only shipped guest code and validated static creation records to generate candidates. For 13 programs that had no prepared recipes in the baseline, it produced 87 candidate entries. Comparing afterward against 17 held-out runtime recipe entries found one exact match.

    The match is a compute shader with six direct runtime-stride buffers. A standalone cold Vulkan run started with an empty pipeline cache and disabled the driver's disk cache. It successfully created the three generated dispatch-mode pipelines, including the exact pipeline ID from the held-out runtime demand. This demonstrates that an exact unseen variant can be built before guest entry using that shader's static data.

    We also have a separate graphics holdout result. A generator based on older sampler layouts and shipped stage pairs generated 184 candidate recipes. One reproduced a later exact graphics key, including its sampler specialization and render state. This result is a recipe-level match so far. The number of candidates makes broad speculative warmup a separate cost to measure.

    For the compute misses that use indirect descriptors and mixed image types, creation headers and shader instructions leave descriptor mappings and some per-view types unresolved. The next work is to use additional shipped resource evidence to narrow those candidate sets. Contribution guidance and a reproducible investigation prompt are in #343.

  14. github-actions commented on Nov 26, 2026

    @github-actions

    The cold Vulkan replay shows that one exact held-out compute variant can be built from static inputs. The graphics result is still a recipe-key match, not a verified ready pipeline.

    For the next holdout, please keep the runtime recipes out of candidate generation and report exact matches and cold precook wall time before and after adding shipped resource evidence. That will show whether the new evidence improves coverage without expanding speculative work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions