perf(vk): defer speculative pipeline probes when a draw needs its shader #1564

Merged
HumanBean merged 1 commit from HumanBean/Longshot:perf/defer-shader-prewarm-until-draw into main 2026-11-18 07:27:48 +00:00
Owner

Type Performance · Risk Medium · Tested on Linux, Ryzen 9 7900X, GeForce RTX 3090, NVIDIA 620.70.06

Summary

When a draw needs a shader whose background load is unfinished, let the loader finish the shader records and defer speculative graphics pipeline probes. When a draw first requests a deferred state, it probes the cache for that exact pipeline. A cache miss follows the existing build path.

Why

A headed Market playtest recorded 45.9 ms in shader program handling on a 74.9 ms renderer frame. The draw was waiting for a load that could also prepare graphics states for future draws.

What changed

The worker checks for demand before reading each matching pipeline note and again before entering the driver. A driver call already in progress finishes. The renderer remembers deferred keys in its existing pipeline table. An already prepared handle takes precedence. Program and shader-cache layouts are preserved.

This PR contains only the shader change and its regression test. It can be reviewed independently of #1553.

Measurements

The Linux headed integration build deferred 49 probes and loaded the existing shader cache. During 29 seconds of settled Market gameplay it averaged 60.5 FPS with a 25.6 ms p99 and a 32.5 ms worst present. Field averaged 60.6 FPS with a 41.4 ms p99 over 45 seconds. Scene-entry stalls remained. These are observations from one manual pass. A same-route before-and-after comparison with populated pipeline notes remains outstanding.

Testing

The game-free fixture on the #1553 base showed that a draw running its own shader load also probed optional pipelines. It passes with this change, including the worker already in a driver probe, a draw arriving during a note read, publication of multiple program keys, and ordinary background prewarm. The headed game ran the same shader change alongside #1553. The standalone main-based tip is pending its own in-game smoke and full suite.

Risk and rollback

The first use of a deferred state may still incur a cache probe. The default renderer path handles absent pipelines. Compute program loads keep their existing behavior. Reverting the change restores eager graphics probes.

Checklist

  • Source-only change and synthetic regression fixture.
  • Assisted by Codex.
  • Shader behavior exercised in a local headed game.
  • Standalone main-based tip checked in game and full suite reported.
  • Independent repeatable FPS improvement established.
**Type** Performance · **Risk** Medium · **Tested on** Linux, Ryzen 9 7900X, GeForce RTX 3090, NVIDIA 620.70.06 ## Summary When a draw needs a shader whose background load is unfinished, let the loader finish the shader records and defer speculative graphics pipeline probes. When a draw first requests a deferred state, it probes the cache for that exact pipeline. A cache miss follows the existing build path. ## Why A headed Market playtest recorded 45.9 ms in shader program handling on a 74.9 ms renderer frame. The draw was waiting for a load that could also prepare graphics states for future draws. ## What changed The worker checks for demand before reading each matching pipeline note and again before entering the driver. A driver call already in progress finishes. The renderer remembers deferred keys in its existing pipeline table. An already prepared handle takes precedence. Program and shader-cache layouts are preserved. This PR contains only the shader change and its regression test. It can be reviewed independently of [#1553](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1553). ## Measurements The Linux headed integration build deferred 49 probes and loaded the existing shader cache. During 29 seconds of settled Market gameplay it averaged 60.5 FPS with a 25.6 ms p99 and a 32.5 ms worst present. Field averaged 60.6 FPS with a 41.4 ms p99 over 45 seconds. Scene-entry stalls remained. These are observations from one manual pass. A same-route before-and-after comparison with populated pipeline notes remains outstanding. ## Testing The game-free fixture on the #1553 base showed that a draw running its own shader load also probed optional pipelines. It passes with this change, including the worker already in a driver probe, a draw arriving during a note read, publication of multiple program keys, and ordinary background prewarm. The headed game ran the same shader change alongside #1553. The standalone main-based tip is pending its own in-game smoke and full suite. ## Risk and rollback The first use of a deferred state may still incur a cache probe. The default renderer path handles absent pipelines. Compute program loads keep their existing behavior. Reverting the change restores eager graphics probes. ## Checklist - [x] Source-only change and synthetic regression fixture. - [x] Assisted by Codex. - [x] Shader behavior exercised in a local headed game. - [ ] Standalone main-based tip checked in game and full suite reported. - [ ] Independent repeatable FPS improvement established.
Stop speculative graphics pipeline loads when a draw needs the program
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 9s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
Third-party parts / As their notes say (pull_request) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 4s
0a3486a689
Assisted-by: Codex
Author
Owner

Tested in game: Linux, GeForce RTX 3090, NVIDIA 620.70.06. Headed Market and Hyrule Field on the #1553 integration with this shader change. Existing pipeline notes loaded and 49 speculative probes deferred. The standalone tip's own smoke is pending.

Tested in game: Linux, GeForce RTX 3090, NVIDIA 620.70.06. Headed Market and Hyrule Field on the #1553 integration with this shader change. Existing pipeline notes loaded and 49 speculative probes deferred. The standalone tip's own smoke is pending.
HumanBean changed title from WIP: perf(vk): defer speculative pipeline probes when a draw needs its shader to perf(vk): defer speculative pipeline probes when a draw needs its shader 2026-11-18 07:27:37 +00:00
HumanBean deleted branch perf/defer-shader-prewarm-until-draw 2026-11-18 07:27:48 +00:00
Author
Owner

Post-merge verification of the exact PR head 0a3486a689 on Linux and RTX 3090: the standalone build completed the 25-second Market movement check and deferred 64 graphics pipeline probes with existing notes loaded. The queue detected an outside build, so this run verifies execution only. Full suite: 710 passed, 45 failed, 19 skipped. All 45 failures reproduced on the exact main base 1a29134d10. The shader-load regression passed.

Post-merge verification of the exact PR head 0a3486a6891c on Linux and RTX 3090: the standalone build completed the 25-second Market movement check and deferred 64 graphics pipeline probes with existing notes loaded. The queue detected an outside build, so this run verifies execution only. Full suite: 710 passed, 45 failed, 19 skipped. All 45 failures reproduced on the exact main base 1a29134d10ac. The shader-load regression passed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1564
No description provided.