perf(vk): convert complete texture tiles eight rows at a time #1603

Merged
HumanBean merged 3 commits from HumanBean/Longshot:perf/texture-upload-tile-rows into main 2026-11-18 16:47:19 +00:00
Owner

Type perf · Risk medium

Change

The CPU texture uploader now converts one complete horizontal strip of eight rows at a time. This keeps destination cache lines hot while it converts the GPU block layout to linear pixels or compressed blocks. Both the single-thread and split-row callers use the same conversion. Partial tiles and 3D levels use the existing decoder.

Measurements

On a Ryzen 9 7900X with resident synthetic RGBA8 input, the median for six alternating trials fell from 0.161 to 0.096 ms at 1024×1024 and from 0.308 to 0.157 ms at 1920×960. Across four shapes the conversion speedup ranged from 1.68× to 2.60×. No synthetic trial met the cold-page residency criterion.

One instrumented run per arm used the same host build and warmed driver cache. Stock recorded 56.54 FPS in Market and 63.58 FPS in Field. The new renderer recorded 67.74 and 79.60 FPS respectively. Host pressure varies between runs and repeated lightly instrumented controls are still needed to attribute a gameplay FPS change. The largest complete Field crossing interval was 370.05 ms on stock and 357.35 ms with the change. Linux sampled 642 replay-thread major faults in the new conversion routine during that interval.

Testing

The generic fallback and the diagnostic reference now use the same block pitch as the host and GPU layout for odd-width RGB textures. The expanded synthetic pixel comparison first failed on the previous revision and passed with the fix under GCC and Clang. The corrected renderer completed the headless Market and Field route on the RTX 3090. That run verifies the route. The fixture supplies the odd-width coverage. The full Linux suite on this revision had 721 passes, 41 control-reproduced failures and 19 skips.

GCC and Clang passed the synthetic byte-for-byte comparison against the project's reference decoder. The fixture compares the entire destination including guard bytes, checks short spans and exercises both the fast path and the fallback across 1- to 16-byte blocks, multiple depths and tile heights. Review added an explicit fallback-call count so the fixture will detect changes that send complete tiles down the reference path. The updated check passed under GCC and Clang. A queued Linux pack build and a headless fixed-marker Market and Field route completed on an RTX 3090 with NVIDIA 620.70.06, CachyOS Linux and 32 GiB RAM.

Remaining work

  • Exercised the changed production path in game and recorded the route in docs/tested.
  • Recorded Codex assistance in the HumanBean commit.
  • Full suite on the corrected fixture returned 721 passes, 41 control-reproduced failures and 19 skips. GCC and Clang passed the tile conversion and sparse guest-memory fixtures.
  • Repeat end-to-end timings and exercise Windows and other GPU vendors.
**Type** perf · **Risk** medium ## Change The CPU texture uploader now converts one complete horizontal strip of eight rows at a time. This keeps destination cache lines hot while it converts the GPU block layout to linear pixels or compressed blocks. Both the single-thread and split-row callers use the same conversion. Partial tiles and 3D levels use the existing decoder. ## Measurements On a Ryzen 9 7900X with resident synthetic RGBA8 input, the median for six alternating trials fell from 0.161 to 0.096 ms at 1024×1024 and from 0.308 to 0.157 ms at 1920×960. Across four shapes the conversion speedup ranged from 1.68× to 2.60×. No synthetic trial met the cold-page residency criterion. One instrumented run per arm used the same host build and warmed driver cache. Stock recorded 56.54 FPS in Market and 63.58 FPS in Field. The new renderer recorded 67.74 and 79.60 FPS respectively. Host pressure varies between runs and repeated lightly instrumented controls are still needed to attribute a gameplay FPS change. The largest complete Field crossing interval was 370.05 ms on stock and 357.35 ms with the change. Linux sampled 642 replay-thread major faults in the new conversion routine during that interval. ## Testing The generic fallback and the diagnostic reference now use the same block pitch as the host and GPU layout for odd-width RGB textures. The expanded synthetic pixel comparison first failed on the previous revision and passed with the fix under GCC and Clang. The corrected renderer completed the headless Market and Field route on the RTX 3090. That run verifies the route. The fixture supplies the odd-width coverage. The full Linux suite on this revision had 721 passes, 41 control-reproduced failures and 19 skips. GCC and Clang passed the synthetic byte-for-byte comparison against the project's reference decoder. The fixture compares the entire destination including guard bytes, checks short spans and exercises both the fast path and the fallback across 1- to 16-byte blocks, multiple depths and tile heights. Review added an explicit fallback-call count so the fixture will detect changes that send complete tiles down the reference path. The updated check passed under GCC and Clang. A queued Linux pack build and a headless fixed-marker Market and Field route completed on an RTX 3090 with NVIDIA 620.70.06, CachyOS Linux and 32 GiB RAM. ## Remaining work - [x] Exercised the changed production path in game and recorded the route in docs/tested. - [x] Recorded Codex assistance in the HumanBean commit. - [x] Full suite on the corrected fixture returned 721 passes, 41 control-reproduced failures and 19 skips. GCC and Clang passed the tile conversion and sparse guest-memory fixtures. - [ ] Repeat end-to-end timings and exercise Windows and other GPU vendors.
Author
Owner

Tested in game: CachyOS Linux, RTX 3090, driver 620.70.06, Ryzen 9 7900X. Ran the changed renderer headless through Market and into Hyrule Field. Replay major-fault samples confirmed execution of the optimized path during the crossing.

Tested in game: CachyOS Linux, RTX 3090, driver 620.70.06, Ryzen 9 7900X. Ran the changed renderer headless through Market and into Hyrule Field. Replay major-fault samples confirmed execution of the optimized path during the crossing.
Member

Possibly related, for context:

  • issue #1268 Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) — Texture-upload stalls and FPS; this optimizes CPU tile conversion, not the measured GPU fence wait
  • PR #923 fix(vk): widen RGB rows with each format's own alpha one — Open overlapping edits in vk_texture.cpp; coordinate to avoid conflicts
Possibly related, for context: - issue #1268 Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) — Texture-upload stalls and FPS; this optimizes CPU tile conversion, not the measured GPU fence wait - PR #923 fix(vk): widen RGB rows with each format's own alpha one — Open overlapping edits in vk_texture.cpp; coordinate to avoid conflicts
Author
Owner

Updated the source fixture after the full suite caught an overly broad function cut. Both GCC and Clang pass the guest-memory fixture and the conversion routing regression. The 41 other suite failures reproduced on the control.

Updated the source fixture after the full suite caught an overly broad function cut. Both GCC and Clang pass the guest-memory fixture and the conversion routing regression. The 41 other suite failures reproduced on the control.
HumanBean force-pushed perf/texture-upload-tile-rows from 2ac87bcea9
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
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 9s
CI / Conventional Commit title (pull_request) Successful in 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
to 681d11ff97
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
Website / Website on Cloudflare (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 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
PR description / Description follows the template (pull_request_target) Successful in 4s
2026-11-18 15:37:32 +00:00
Compare
Author
Owner

The full game-free suite rerun finished with 721 passed, 41 failures also seen on the control and 19 skips. Both GCC and Clang passed the updated conversion and guest-memory checks.

The full game-free suite rerun finished with 721 passed, 41 failures also seen on the control and 19 skips. Both GCC and Clang passed the updated conversion and guest-memory checks.
Assisted-by: OpenAI Codex
fix(vk): match the generic decoder to the guest block pitch
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
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 14s
Third-party parts / As their notes say (pull_request) Successful in 14s
PR description / Description follows the template (pull_request_target) Failing after 4s
95a837b4d2
Assisted-by: OpenAI Codex
Author
Owner

The generic fallback and the diagnostic reference now use the same block pitch as the host and GPU layout for odd-width RGB textures. The expanded synthetic pixel comparison first failed on the previous revision and passed with the fix under GCC and Clang. The corrected renderer completed the headless Market and Field route on the RTX 3090. That run verifies the route. The fixture supplies the odd-width coverage. The full Linux suite on this revision had 721 passes, 41 control-reproduced failures and 19 skips.

The generic fallback and the diagnostic reference now use the same block pitch as the host and GPU layout for odd-width RGB textures. The expanded synthetic pixel comparison first failed on the previous revision and passed with the fix under GCC and Clang. The corrected renderer completed the headless Market and Field route on the RTX 3090. That run verifies the route. The fixture supplies the odd-width coverage. The full Linux suite on this revision had 721 passes, 41 control-reproduced failures and 19 skips.
HumanBean changed title from WIP: perf(vk): convert complete texture tiles eight rows at a time to perf(vk): convert complete texture tiles eight rows at a time 2026-11-18 16:47:09 +00:00
HumanBean deleted branch perf/texture-upload-tile-rows 2026-11-18 16:47:19 +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!1603
No description provided.