[PR #4608] [MERGED] Windows Vulkan: wait for the acquire fence only with VSync (gfx-rs/wgpu#10714) #5727

Closed
opened 2026-11-03 05:14:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4608
Author: @k3yh
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/vulkan-acquire-fence-fifo-only


📝 Commits (1)

📊 Changes

3 files changed (+15 additions, -6 deletions)

View changed files

📝 Cargo.toml (+4 -1)
📝 THIRD_PARTY_NOTICES.md (+3 -2)
📝 third_party/wgpu-hal/src/vulkan/swapchain/native.rs (+8 -3)

📄 Description

🤖 Opened by k3yh's AI agent (Claude Code, Claude Opus 5.5), not by k3yh personally.

What and why

Fixes #4604.

On Windows with Vulkan and VSync off, every frame waited for the GPU to finish the previous one before it started recording: get_current_texture held the CPU ~5.2 ms of a 7.3 ms frame with a shader pack, and the GPU sat idle 28% of the time (72% busy, Task Manager's 3D engine counter, RX 7900 XT).

The wait is wgpu-hal's: since gfx-rs/wgpu#8420 it creates a fence for vkAcquireNextImageKHR on Windows and waits on it, in every present mode. It is there for FIFO, where drivers that present through DXGI stuttered without it (gfx-rs/wgpu#8310). With Immediate or Mailbox the driver signals it only when the image is free, which is after the GPU finished the frame before (gfx-rs/wgpu#9559 measured the same on AMD: 74 µs → 4.8 ms per acquire).

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

None: this is wgpu's Vulkan backend, vanilla (OpenGL) has nothing like it.

Change

Apply the upstream fix, gfx-rs/wgpu#10714 (open, not in a release), to third_party/wgpu-hal, as #746 did for gfx-rs/wgpu#10124: the fence is created only for Fifo and FifoRelaxed. FIFO (VSync on) is unchanged. Other platforms and backends are unchanged (cfg!(target_os = "windows"), Vulkan only). Cargo.toml and THIRD_PARTY_NOTICES.md name the new upstream fix.

Proof

Test machine (one PC, every number below is from it):

OS Windows 11 Home 25H2, build 26200.9711
CPU AMD Ryzen 7 9800X3D, 8 cores (SMT off: 8 threads)
RAM 64 GB DDR5-6000 (2 × 32 GB ADATA XPG Lancer Blade)
Motherboard Gigabyte X870E AORUS PRO ICE
GPU AMD Radeon RX 7900 XT, 20 GB, driver Adrenalin 26.10.1 (Windows 32.0.32015.7029), Vulkan through AMD's LLPC driver
Integrated GPU Ryzen's Radeon Graphics, enabled but unused (Horizon picks the 7900 XT)
Display LG UltraGear 2560x1440 at 180 Hz, scale 100%; a second 1080p monitor (ASUS VG24V) connected
Storage NVMe

Game settings: borderless fullscreen 2560x1440, render distance 16, simulation distance 9, VSync off (present mode Mailbox), FPS unlimited, LOD off, TAA and FXAA off, upscaling at 100%, HDR off. Shader pack Complementary Reimagined r5.9.3 at its defaults. A clean temporary Horizon home (--game-dir/--home), browser closed.

Builds: two --profile fast builds of the same main (22ad79ba0; the branch is now rebased on 17b1f8fd1, no conflicts), one with the patch and one without, alternated run by run.

horizon-client --benchmark standard (the game's own four flights, two runs each, the mean):

Scene No pack: before → after 1% low Complementary Reimagined: before → after 1% low
Village 857 → 963 (+12%) 340 → 545 176 → 228 (+30%) 94 → 154
Forest 989 → 1308 (+32%) 377 → 590 149 → 174 (+17%) 99 → 138
Ocean 986 → 1332 (+35%) 455 → 697 144 → 169 (+18%) 110 → 136
Mountain 953 → 1352 (+42%) 296 → 538 179 → 219 (+23%) 91 → 148

The two runs of each build agree within 3% on the averages.

Standing still (horizon-ctl bench 8, Complementary Reimagined, same spot, two rounds): 135 → 156 fps, GPU busy 72% → 89%. Before the patch a temporary log in draw_frame put 5.15 ms of the 7.3 ms frame in get_current_texture. The GPU time per frame stays the same (5.2-5.7 ms): the GPU now works while the CPU records.

Nothing else moved:

  • VSync on (FIFO): same numbers before and after (the fence stays). Its 40 ms spikes are there on main too (gfx-rs/wgpu#8354).
  • DirectX 12: 168 → 169 fps (not touched). With the patch Vulkan matches it on average and its p99 is 7.5 ms against DirectX 12's 13 ms.
  • Switching VSync on and off, windowed and fullscreen, the pause menu, at runtime: each reconfigure makes its own fence or none, no errors in the log.
  • Screenshots (horizon-ctl screenshot): same image.
  • HDR: the setting on with a display that offers none falls back as before. Not checked with an HDR display (I have none); HDR goes through the same present modes.
  • Not measured on NVIDIA or Intel.

Self-check

pr_ready (tools/pr_ready.py --quick --base 17b1f8fd1 on DESKTOP-S9O4938, against 17b1f8fd1 at 17b1f8fd1, 11 min 15 s)

Check Result
Scope ✅ 3 files, +15 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 481 run, FAILED (errors=1, skipped=1) (47 s)
rustfmt ✅ (8 s)
clippy ✅ (1 min 0 s)
tests: workspace ❌ 809 passed, 1 failed (4 min 8 s)
doc tests ✅ 0 passed (5 s)
content root tests ✅ 5 passed (2 min 23 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (1 min 6 s)
launcher tests ✅ 287 passed (1 min 32 s)
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Both failures are in files this PR doesn't touch (it changes no Python and no horizon-client code) and come from this Windows machine: test_perf_bench's windows_version() gets no output from cmd /C ver on a Spanish Windows ('NoneType' object has no attribute 'strip'), and title::tests::each_world_preset_writes_its_own_generator fails with Windows error 267 (NotADirectory). The workspace test also fails on main without this change.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4608 **Author:** [@k3yh](https://github.com/k3yh) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/vulkan-acquire-fence-fifo-only` --- ### 📝 Commits (1) - [`da4ded1`](https://github.com/horizon-rust/horizon/commit/da4ded1d7cf9b750160a039244d2e07efd7c9207) Windows Vulkan: wait for the acquire fence only with VSync (gfx-rs/wgpu#10714) ### 📊 Changes **3 files changed** (+15 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.toml` (+4 -1) 📝 `THIRD_PARTY_NOTICES.md` (+3 -2) 📝 `third_party/wgpu-hal/src/vulkan/swapchain/native.rs` (+8 -3) </details> ### 📄 Description > 🤖 Opened by k3yh's AI agent (Claude Code, Claude Opus 5.5), not by k3yh personally. ## What and why Fixes #4604. On Windows with Vulkan and VSync off, every frame waited for the GPU to finish the previous one before it started recording: `get_current_texture` held the CPU ~5.2 ms of a 7.3 ms frame with a shader pack, and the GPU sat idle 28% of the time (72% busy, Task Manager's 3D engine counter, RX 7900 XT). The wait is wgpu-hal's: since gfx-rs/wgpu#8420 it creates a fence for `vkAcquireNextImageKHR` on Windows and waits on it, in every present mode. It is there for FIFO, where drivers that present through DXGI stuttered without it (gfx-rs/wgpu#8310). With Immediate or Mailbox the driver signals it only when the image is free, which is after the GPU finished the frame before (gfx-rs/wgpu#9559 measured the same on AMD: 74 µs → 4.8 ms per acquire). ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [x] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference None: this is wgpu's Vulkan backend, vanilla (OpenGL) has nothing like it. ## Change Apply the upstream fix, gfx-rs/wgpu#10714 (open, not in a release), to `third_party/wgpu-hal`, as #746 did for gfx-rs/wgpu#10124: the fence is created only for `Fifo` and `FifoRelaxed`. FIFO (VSync on) is unchanged. Other platforms and backends are unchanged (`cfg!(target_os = "windows")`, Vulkan only). `Cargo.toml` and `THIRD_PARTY_NOTICES.md` name the new upstream fix. ## Proof **Test machine** (one PC, every number below is from it): | | | |---|---| | OS | Windows 11 Home 25H2, build 26200.9711 | | CPU | AMD Ryzen 7 9800X3D, 8 cores (SMT off: 8 threads) | | RAM | 64 GB DDR5-6000 (2 × 32 GB ADATA XPG Lancer Blade) | | Motherboard | Gigabyte X870E AORUS PRO ICE | | GPU | AMD Radeon RX 7900 XT, 20 GB, driver Adrenalin 26.10.1 (Windows 32.0.32015.7029), Vulkan through AMD's LLPC driver | | Integrated GPU | Ryzen's Radeon Graphics, enabled but unused (Horizon picks the 7900 XT) | | Display | LG UltraGear 2560x1440 at 180 Hz, scale 100%; a second 1080p monitor (ASUS VG24V) connected | | Storage | NVMe | **Game settings:** borderless fullscreen 2560x1440, render distance 16, simulation distance 9, VSync off (present mode Mailbox), FPS unlimited, LOD off, TAA and FXAA off, upscaling at 100%, HDR off. Shader pack Complementary Reimagined r5.9.3 at its defaults. A clean temporary Horizon home (`--game-dir`/`--home`), browser closed. **Builds:** two `--profile fast` builds of the same main (22ad79ba0; the branch is now rebased on 17b1f8fd1, no conflicts), one with the patch and one without, alternated run by run. **`horizon-client --benchmark standard`** (the game's own four flights, two runs each, the mean): | Scene | No pack: before → after | 1% low | Complementary Reimagined: before → after | 1% low | |---|---|---|---|---| | Village | 857 → 963 (+12%) | 340 → 545 | 176 → 228 (+30%) | 94 → 154 | | Forest | 989 → 1308 (+32%) | 377 → 590 | 149 → 174 (+17%) | 99 → 138 | | Ocean | 986 → 1332 (+35%) | 455 → 697 | 144 → 169 (+18%) | 110 → 136 | | Mountain | 953 → 1352 (+42%) | 296 → 538 | 179 → 219 (+23%) | 91 → 148 | The two runs of each build agree within 3% on the averages. **Standing still** (`horizon-ctl bench 8`, Complementary Reimagined, same spot, two rounds): 135 → 156 fps, GPU busy 72% → 89%. Before the patch a temporary log in `draw_frame` put 5.15 ms of the 7.3 ms frame in `get_current_texture`. The GPU time per frame stays the same (5.2-5.7 ms): the GPU now works while the CPU records. **Nothing else moved:** - VSync on (FIFO): same numbers before and after (the fence stays). Its 40 ms spikes are there on main too (gfx-rs/wgpu#8354). - DirectX 12: 168 → 169 fps (not touched). With the patch Vulkan matches it on average and its p99 is 7.5 ms against DirectX 12's 13 ms. - Switching VSync on and off, windowed and fullscreen, the pause menu, at runtime: each reconfigure makes its own fence or none, no errors in the log. - Screenshots (`horizon-ctl screenshot`): same image. - HDR: the setting on with a display that offers none falls back as before. Not checked with an HDR display (I have none); HDR goes through the same present modes. - Not measured on NVIDIA or Intel. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base 17b1f8fd1` on DESKTOP-S9O4938, against 17b1f8fd1 at 17b1f8fd1, 11 min 15 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +15 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 481 run, FAILED (errors=1, skipped=1) (47 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (1 min 0 s) | | tests: workspace | ❌ 809 passed, 1 failed (4 min 8 s) | | doc tests | ✅ 0 passed (5 s) | | content root tests | ✅ 5 passed (2 min 23 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (1 min 6 s) | | launcher tests | ✅ 287 passed (1 min 32 s) | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Both failures are in files this PR doesn't touch (it changes no Python and no `horizon-client` code) and come from this Windows machine: `test_perf_bench`'s `windows_version()` gets no output from `cmd /C ver` on a Spanish Windows (`'NoneType' object has no attribute 'strip'`), and `title::tests::each_world_preset_writes_its_own_generator` fails with Windows error 267 (NotADirectory). The workspace test also fails on main without this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:35 +07:00
Sign in to join this conversation.
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
horizon-rust/horizon#5727
No description provided.