draw: limit pre-bake work to prepared texture sources #310

Manually merged
github merged 2 commits from github-bot/gh-310 into main 2026-12-03 17:03:05 +00:00 AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-03 12:20 UTC · original
tommiehansen:perf/phase3-bake-sources → main · +185 −28 · 2 files · 2 commits · merged 2026-12-03 16:56 UTC

Problem

The decoration-bake path can process thousands of unrelated texture slots before drawing. The first implementation could treat a limited candidate list as complete and could attempt source preparation twice on fallback.

Implementation and correctness

Separate discovery from preparation. Accept the scoped pass only for a recognized bake pixel program and its documented table-1 constant/304-byte record layout. Reject unsupported bindings, unbounded record ranges, failed reads, truncated inputs and candidate overflow. A complete, nonempty candidate set must then prepare successfully before the broad pass can be omitted. On discovery failure the broad pass runs first, followed by one best-effort preparation. If already attempted, preparation is not repeated. The existing per-source recording and #248 GPU-written texture coverage remain in place. The code still scans the words of the bounded inputs; per-shader field offsets are not inferred without captures.

The opt-in path logs preparation time, skipped and fallback passes, candidate count and a labeled prior queue census. It does not count that census as proven avoided uploads. Unset VICTORY_BAKE_SOURCES_ONLY to retain the broad path.

Source and comparison

Inspired by foxhound #525.

Measurement Original Variant
Foxhound report, bake CPU time 154–322 ms in the broad pass alone 1–4 ms total per bake in a later run
Xmem game and GPU timings Not run Not run

The Foxhound test used an RTX 4070 SUPER (3440×1440, DLSS Performance, frame generation off) in two different play sessions. One bake needed 13 source slots, but the general pass uploaded about 8,100 of 10,458 due slots. The reported long frames in seconds containing bakes were 305–438 ms before the change. These figures motivate the xmem optimization; they do not establish its skip rate or FPS improvement.

Quick A/B test

Configuration Setting
Baseline (default) Unset VICTORY_BAKE_SOURCES_ONLY
Scoped preparation VICTORY_BAKE_SOURCES_ONLY=1

Compare broad-pass frequency and time, successful skip/fallback counts, bake preparation time, frames over 100 ms and matched screenshots. A low skip rate indicates that layout recognition or source eligibility needs more work; it is not evidence that the underlying bottleneck is absent.

Validation and testing

Two targeted portable tests passed for failed/truncated reads, candidate overflow and fallback eligibility. Diagnostics Windows-target type checking also passed. Hardware benchmarking was unavailable. Please test matched decoration and character bakes and the same RT-enabled route on RX 9060 XT 16 GB at native 1080p and RX 9070 XT at native 1440p. Confirm the recognized layout and baked image parity before relying on the switch. No dependency on #313.

**@⁠tommiehansen** on GitHub · 2026-12-03 12:20 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/310) `tommiehansen:perf/phase3-bake-sources` → `main` · +185 −28 · 2 files · 2 commits · merged 2026-12-03 16:56 UTC ## Problem The decoration-bake path can process thousands of unrelated texture slots before drawing. The first implementation could treat a limited candidate list as complete and could attempt source preparation twice on fallback. ## Implementation and correctness Separate discovery from preparation. Accept the scoped pass only for a recognized bake pixel program and its documented table-1 constant/304-byte record layout. Reject unsupported bindings, unbounded record ranges, failed reads, truncated inputs and candidate overflow. A complete, nonempty candidate set must then prepare successfully before the broad pass can be omitted. On discovery failure the broad pass runs first, followed by one best-effort preparation. If already attempted, preparation is not repeated. The existing per-source recording and #248 GPU-written texture coverage remain in place. The code still scans the words of the bounded inputs; per-shader field offsets are not inferred without captures. The opt-in path logs preparation time, skipped and fallback passes, candidate count and a labeled prior queue census. It does not count that census as proven avoided uploads. Unset `VICTORY_BAKE_SOURCES_ONLY` to retain the broad path. ## Source and comparison Inspired by [foxhound #525](https://github.com/readmet3xt-lab/foxhound/pull/525). | Measurement | Original | Variant | |---|---:|---:| | Foxhound report, bake CPU time | 154–322 ms in the broad pass alone | 1–4 ms total per bake in a later run | | Xmem game and GPU timings | Not run | Not run | The Foxhound test used an RTX 4070 SUPER (3440×1440, DLSS Performance, frame generation off) in two different play sessions. One bake needed 13 source slots, but the general pass uploaded about 8,100 of 10,458 due slots. The reported long frames in seconds containing bakes were 305–438 ms before the change. These figures motivate the xmem optimization; they do not establish its skip rate or FPS improvement. ## Quick A/B test | Configuration | Setting | |---|---| | Baseline (default) | Unset `VICTORY_BAKE_SOURCES_ONLY` | | Scoped preparation | `VICTORY_BAKE_SOURCES_ONLY=1` | Compare broad-pass frequency and time, successful skip/fallback counts, bake preparation time, frames over 100 ms and matched screenshots. A low skip rate indicates that layout recognition or source eligibility needs more work; it is not evidence that the underlying bottleneck is absent. ## Validation and testing Two targeted portable tests passed for failed/truncated reads, candidate overflow and fallback eligibility. Diagnostics Windows-target type checking also passed. Hardware benchmarking was unavailable. Please test matched decoration and character bakes and the same RT-enabled route on RX 9060 XT 16 GB at native 1080p and RX 9070 XT at native 1440p. Confirm the recognized layout and baked image parity before relying on the switch. No dependency on #313.
Use xmem’s existing exact source preparation on the recording list before considering the broad texture queue pass. Skip that pass only with a nonempty, fully accounted candidate set; keep the prior path for incomplete preparation. Inspired by foxhound #525. The targeted readiness test and diagnostics Windows-target check passed. The candidate heuristic and image parity need game captures.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 12:26:26 +00:00
Separate source discovery from preparation. Reject unrecognized binding layouts, short or failed reads, and collector overflow. Keep the broad pass for unproven input sets and prepare sources at most once per bake.

Use the known bake pixel layout for eligibility and report skipped passes, fallback counts and preparation time. Two portable regression tests and the diagnostics Windows-target check passed. Captured game parity remains unverified.
github manually merged commit 276f22c501 into main 2026-12-03 17:03:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.