Preserve GPU writes during parallel readback refresh #1069

Merged
klimovich008 merged 1 commit from parallel-rb-refresh-hazards into main 2026-11-09 15:15:28 +00:00
klimovich008 commented 2026-11-09 09:04:41 +00:00 (Migrated from github.com)

What this fixes

With RX_VK_PARALLEL=4, every frame in Hyrule Field comes out too bright on an RX 9070 XT, while serial replay has normal exposure. The cause: a parallel replay's segments share one submission, and each segment's readback refresh copied the guest page over the exposure sum the GPU had already added.

Why merge

  • Makes the opt-in parallel replay correct, worth +7.0% native cadence in Hyrule Field (55.9 → 59.8 fps at the 60 cap).
  • Tracks overwrite hazards separately from copy-back, including bare and wide writers.
  • Keeps serial copies fixture-identical and parallel rendering opt-in.
  • RX_VK_RB_REFRESH_EACH=1 restores the old refresh for comparison.

Change

  • gpu/vk/vk_memory.cpp: track submission hazards and filter refreshes.
  • gpu/vk/vk_internal.h: declare recording/hazard hooks.
  • gpu/vk/vk_texture.cpp: initialize recording scope.
  • gpu/vk/vk_replay.cpp: register segment order.
  • gpu/vk/vk_draw.cpp: note bare/wide writes.
  • tests/parallel_rb_refresh_test.cpp: check exposure, untracked writes and serial control.
  • tests/test_parallel_rb_refresh.py: extract/run production paths.
  • tests/run_all.py: register the compiler argument.

Tested

  • python -I -B tests/test_parallel_rb_refresh.py --cxx clang++: actual-function overwrite regressions and serial control.
  • Fails on the old code, passes now.
  • RX 9070 XT/Windows, v2.0.6: three 130-second Hyrule runs per arm; native cadence 55.9 → 59.8 fps. Parallel luminance 133–143 versus serial 137–141; the old-refresh switch restores 185–188.

Not covered

  • Tested on AMD only; physical display timing is unmeasured.
  • Existing whole-page, late-first-read and out-of-order CPU-visibility limits remain.

No game data is included.

🤖 Generated with Claude Code

## What this fixes With `RX_VK_PARALLEL=4`, every frame in Hyrule Field comes out too bright on an RX 9070 XT, while serial replay has normal exposure. The cause: a parallel replay's segments share one submission, and each segment's readback refresh copied the guest page over the exposure sum the GPU had already added. ## Why merge - Makes the opt-in parallel replay correct, worth +7.0% native cadence in Hyrule Field (55.9 → 59.8 fps at the 60 cap). - Tracks overwrite hazards separately from copy-back, including bare and wide writers. - Keeps serial copies fixture-identical and parallel rendering opt-in. - `RX_VK_RB_REFRESH_EACH=1` restores the old refresh for comparison. ## Change - `gpu/vk/vk_memory.cpp`: track submission hazards and filter refreshes. - `gpu/vk/vk_internal.h`: declare recording/hazard hooks. - `gpu/vk/vk_texture.cpp`: initialize recording scope. - `gpu/vk/vk_replay.cpp`: register segment order. - `gpu/vk/vk_draw.cpp`: note bare/wide writes. - `tests/parallel_rb_refresh_test.cpp`: check exposure, untracked writes and serial control. - `tests/test_parallel_rb_refresh.py`: extract/run production paths. - `tests/run_all.py`: register the compiler argument. ## Tested - `python -I -B tests/test_parallel_rb_refresh.py --cxx clang++`: actual-function overwrite regressions and serial control. - Fails on the old code, passes now. - RX 9070 XT/Windows, v2.0.6: three 130-second Hyrule runs per arm; native cadence 55.9 → 59.8 fps. Parallel luminance 133–143 versus serial 137–141; the old-refresh switch restores 185–188. ## Not covered - Tested on AMD only; physical display timing is unmeasured. - Existing whole-page, late-first-read and out-of-order CPU-visibility limits remain. No game data is included. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Commenting is not possible because the repository is archived.
No description provided.