perf(vk): use temporary pipelines for required draws by default #1643

Merged
HumanBean merged 3 commits from HumanBean/Longshot:perf/required-draw-quick-default into main 2026-11-18 19:59:52 +00:00
Owner

Type: perf · Risk: medium · Tested on: CachyOS Linux, GeForce RTX 3090 · Needs: Windows Intel, Mesa RADV

TL;DR

A graphics draw that needs an unfinished pipeline can now try a temporary one by default while the optimized build finishes. The game reached Link’s house with the default enabled. A separate cold-driver test found a small median improvement. The effect on gameplay stutter is still unconfirmed.

Breakdown

  • Who it helps: Players encountering a new graphics pipeline on a draw that must finish.
  • What was wrong: A required draw could spend its frame waiting for the optimized pipeline.
  • What changes: The renderer first tries a cached pipeline and can compile a temporary one without optimization.
  • What does not change: Skippable draws keep their existing policy by default.
  • How it was checked: Linux renderer build, game-free regressions, a headless game smoke run, and a synthetic Vulkan driver comparison.
  • What is still open: Cold gameplay frame-time comparisons on this revision and measurements on other drivers.
  • Risk: A temporary build can add CPU work and retain an extra pipeline for the session.

Why

Required draws can block a frame when the driver has yet to compile the pipeline. Giving that draw a usable pipeline earlier can shorten the wait.

What changed

The default for RX_VK_QUICK_MS is required. A positive numeric budget also permits temporary builds for skippable draws. Zero disables the feature. Native RADV mesh draws keep their optimized shaders on a cache miss because unoptimized execution can reset the GPU. See #1000.

The renderer checks whether the worker published the pipeline during a cache lookup before starting a duplicate compile. Temporary builds try Intel’s compiler lock without waiting behind the worker.

Measurements

Verdict: The temporary pipeline served 19 of 24 cold requests first in a synthetic RTX 3090 test. Median time to a usable pipeline changed from 8.83 to 8.55 ms. Only one control request exceeded 16.7 ms.

Hardware: RTX 3090, NVIDIA 620.70.06, CachyOS Linux, Ryzen 9 7900X, 32 GB RAM.

Scene: A game-free Vulkan test using twelve synthetic fragment shaders and a fullscreen vertex shader.

Method: Two runs per mode, in off/required/required/off order. Time from worker dispatch to the first usable pipeline handle, median of 24 requests per mode.

How to reproduce: Race the temporary pipeline against an optimized build for each synthetic shader using a new application pipeline cache and a fresh driver cache per run. Check the cold lookup before timing each request.

Baseline: Both columns use the explicit settings on 7850a7cb. The final default on this PR was checked separately in the game.

Time to a usable pipeline Before: RX_VK_QUICK_MS=0 @ 7850a7cb After: RX_VK_QUICK_MS=required @ 7850a7cb
Median 8.83 ms 8.55 ms
Worst 37.33 ms 12.86 ms

Flags and settings

The existing switch gains a required-draw mode and selects it by default.

Flag What it is Before this PR After this PR Effect Helps / untested Recommendation
RX_VK_QUICK_MS Quick-build policy Off required Required draws can use a temporary pipeline. Tested on RTX 3090. Use the default. Set 0 to opt out.

Testing

Tested: The final Linux renderer built and passed its symbol check. With the flag unset, the game reached Link’s house and completed the item setup on an RTX 3090. Its log selected required-only mode and recorded cached pipelines serving waiting draws. The quick-pipeline regression passed with GCC and Clang. The draw side-effect and Intel compiler gate tests passed.

Not tested: Displayed-frame pacing or a cold gameplay comparison on this revision. The full suite was not rerun. The switch-table test reports the same nine unrelated failures on the PR and the base commit.

Must be tested:

  • Windows, Intel graphics: by hand, enter a new area with a cold cache during active pipeline builds, expecting required draws to complete when the compiler gate becomes available.
  • Linux, Mesa RADV: by hand, enter Kokiri Forest with a cold cache, expecting native mesh draws to retain optimized shaders and the GPU to remain responsive.

Risks

Drivers may serialize the two builds internally. The temporary pipeline can compile slowly, use more GPU time, and consume additional memory until shutdown. Existing strict-wait mode still permits requiring the full pipeline for every draw.

Compatibility: The renderer reads the new default at launch. Existing numeric overrides still apply.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks. Extra compiler work and retained memory are documented, but their in-game cost has not been measured.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). Focused tests ran. The full suite was not rerun.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Docs updated.
**Type:** perf · **Risk:** medium · **Tested on:** CachyOS Linux, GeForce RTX 3090 · **Needs:** Windows Intel, Mesa RADV ## TL;DR A graphics draw that needs an unfinished pipeline can now try a temporary one by default while the optimized build finishes. The game reached Link’s house with the default enabled. A separate cold-driver test found a small median improvement. The effect on gameplay stutter is still unconfirmed. ## Breakdown - **Who it helps:** Players encountering a new graphics pipeline on a draw that must finish. - **What was wrong:** A required draw could spend its frame waiting for the optimized pipeline. - **What changes:** The renderer first tries a cached pipeline and can compile a temporary one without optimization. - **What does not change:** Skippable draws keep their existing policy by default. - **How it was checked:** Linux renderer build, game-free regressions, a headless game smoke run, and a synthetic Vulkan driver comparison. - **What is still open:** Cold gameplay frame-time comparisons on this revision and measurements on other drivers. - **Risk:** A temporary build can add CPU work and retain an extra pipeline for the session. ## Why Required draws can block a frame when the driver has yet to compile the pipeline. Giving that draw a usable pipeline earlier can shorten the wait. ## What changed The default for `RX_VK_QUICK_MS` is `required`. A positive numeric budget also permits temporary builds for skippable draws. Zero disables the feature. Native RADV mesh draws keep their optimized shaders on a cache miss because unoptimized execution can reset the GPU. See #1000. The renderer checks whether the worker published the pipeline during a cache lookup before starting a duplicate compile. Temporary builds try Intel’s compiler lock without waiting behind the worker. ## Measurements **Verdict:** The temporary pipeline served 19 of 24 cold requests first in a synthetic RTX 3090 test. Median time to a usable pipeline changed from 8.83 to 8.55 ms. Only one control request exceeded 16.7 ms. Hardware: RTX 3090, NVIDIA 620.70.06, CachyOS Linux, Ryzen 9 7900X, 32 GB RAM. Scene: A game-free Vulkan test using twelve synthetic fragment shaders and a fullscreen vertex shader. Method: Two runs per mode, in off/required/required/off order. Time from worker dispatch to the first usable pipeline handle, median of 24 requests per mode. How to reproduce: Race the temporary pipeline against an optimized build for each synthetic shader using a new application pipeline cache and a fresh driver cache per run. Check the cold lookup before timing each request. Baseline: Both columns use the explicit settings on 7850a7cb. The final default on this PR was checked separately in the game. | Time to a usable pipeline | Before: RX_VK_QUICK_MS=0 @ 7850a7cb | After: RX_VK_QUICK_MS=required @ 7850a7cb | |---|---:|---:| | Median | 8.83 ms | 8.55 ms | | Worst | 37.33 ms | 12.86 ms | ### Flags and settings The existing switch gains a required-draw mode and selects it by default. | Flag | What it is | Before this PR | After this PR | Effect | Helps / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_QUICK_MS` | Quick-build policy | Off | `required` | Required draws can use a temporary pipeline. | Tested on RTX 3090. | Use the default. Set `0` to opt out. | ## Testing **Tested:** The final Linux renderer built and passed its symbol check. With the flag unset, the game reached Link’s house and completed the item setup on an RTX 3090. Its log selected required-only mode and recorded cached pipelines serving waiting draws. The quick-pipeline regression passed with GCC and Clang. The draw side-effect and Intel compiler gate tests passed. **Not tested:** Displayed-frame pacing or a cold gameplay comparison on this revision. The full suite was not rerun. The switch-table test reports the same nine unrelated failures on the PR and the base commit. **Must be tested:** - Windows, Intel graphics: by hand, enter a new area with a cold cache during active pipeline builds, expecting required draws to complete when the compiler gate becomes available. - Linux, Mesa RADV: by hand, enter Kokiri Forest with a cold cache, expecting native mesh draws to retain optimized shaders and the GPU to remain responsive. ## Risks Drivers may serialize the two builds internally. The temporary pipeline can compile slowly, use more GPU time, and consume additional memory until shutdown. Existing strict-wait mode still permits requiring the full pipeline for every draw. Compatibility: The renderer reads the new default at launch. Existing numeric overrides still apply. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [ ] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. Extra compiler work and retained memory are documented, but their in-game cost has not been measured. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). Focused tests ran. The full suite was not rerun. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Docs updated.
Assisted-by: Codex
Assisted-by: Codex
perf(vk): use temporary pipelines for required draws by default
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 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Workflow lint (actionlint) (pull_request) Successful in 26s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 31s
Third-party parts / As their notes say (pull_request) Successful in 44s
PR description / Description follows the template (pull_request_target) Failing after 16s
1da97d7ed3
Assisted-by: Codex
Member

Possibly related, for context:

  • PR #234 feat(vk): quick pipelines for draws whose full build is not done — Original quick-pipeline implementation; this changes its default policy.
  • PR #1564 perf(vk): defer speculative pipeline probes when a draw needs its shader — Related renderer work reducing pipeline stalls for required draws.
Possibly related, for context: - PR #234 feat(vk): quick pipelines for draws whose full build is not done — Original quick-pipeline implementation; this changes its default policy. - PR #1564 perf(vk): defer speculative pipeline probes when a draw needs its shader — Related renderer work reducing pipeline stalls for required draws.
Author
Owner

Final Linux smoke test on an RTX 3090 with NVIDIA 620.70.06: the game reached Link’s house and finished item setup in 7,166 headless frames. With RX_VK_QUICK_MS unset, the renderer selected required-only mode and reported at least 200 cached pipelines serving waiting draws. Cold gameplay pacing remains unverified.

Final Linux smoke test on an RTX 3090 with NVIDIA 620.70.06: the game reached Link’s house and finished item setup in 7,166 headless frames. With RX_VK_QUICK_MS unset, the renderer selected required-only mode and reported at least 200 cached pipelines serving waiting draws. Cold gameplay pacing remains unverified.
HumanBean deleted branch perf/required-draw-quick-default 2026-11-18 19:59:55 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!1643
No description provided.