perf(texture): stream proven tight linear uploads directly into staging #655

Open
github-bot wants to merge 6 commits from github-bot/gh-655 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-06 00:57 UTC · original
tommiehansen:perf/phase13-linear-texture-stream-20261206 → main · +290 −4 · 2 files · 6 commits · open

Why

The watched texture refresh path materializes an intermediate CPU snapshot and detiles it even when the guest layout is already identical to the final upload footprint. Avoiding that redundant work reduces CPU preparation time without changing the GPU upload.

What changes

Opt-in VICTORY_LINEAR_TEXTURE_STREAM=1 admits only tightly packed single-mip, single-layer, single-sample 2D linear textures with exactly matching row pitch, zero footprint offset and checked byte extent. Copy directly into mapped staging and preserve the existing dirty flags and GPU copy. Guarded/aliased and unsupported layouts retain their original path.

Benchmark results

Windows D3D12 WARP, eight alternating ABBA/BAAB blocks per size, four arms/block, 96/96 byte-exact actual texture uploads/readbacks. Median per-arm preparation times and median paired block reduction:

Size Before After Paired reduction Prep wins
64x64 8.90 us 2.30 us 74.45% 8/8
256x256 35.75 us 8.50 us 76.38% 8/8
1024x1024 420.45 us 159.95 us 58.22% 8/8

Paired end-to-end reductions: 1.42%, 6.87%, 12.74% (5/8, 7/8, 6/8 wins). Small case median absolute totals 415.05 vs 421.40 us; timing is noisy. Larger case medians 512.10 vs 469.65 us and 1676.85 vs 1483.60 us. No physical GPU or gameplay FPS claim.

Why this should be merged

Eliminates a redundant CPU snapshot and conversion on a narrowly proven layout, preserves existing fallback and dirty tracking, and leaves default behavior unchanged.

Validation

CI 47589934748: actual texture upload and GPU readback exact; cargo check --locked -p victory-gpu --all-targets passed. Raw CSV/log. Earlier buffer-readback fixture 47589319395 independently passed 96 exact arms. This exercises the admission helper and copy mechanism, not full title activation.

Compatibility and dependencies

Independent of other optimization PRs; base 8c4e663, default off. Physical title activation, alias stress and full-scene timing remain validation gates. Not zero-copy into VRAM.

Current production-refresh validation and repeat measurement

dcbc7c9 CI 47592700737 passed. The actual Staging::refresh_timed path executed with the switch off/on, two independent replicas of the same watched address, three changed and three clean passes, dirty/claim-upload assertions, actual texture copies and byte-exact readback. The enabled arm requires six direct refresh activations; disabled requires zero. Decommitted source-tail copy preserves the reference's zero-fill behavior. The test submits both texture lists together; it does not establish asynchronous title lifetime or physical alias mapping. Production compile passed.

Repeated 96 exact paired texture uploads; median block medians (µs), paired percentages:

Size Preparation before → after Paired preparation Total before → after Paired total
64² 8.725 → 1.975 −77.65% (8/8) 411.875 → 403.125 −3.32% (7/8)
256² 32.700 → 7.925 −76.07% (8/8) 553.600 → 521.875 −6.07% (7/8)
1024² 394.350 → 128.500 −66.72% (8/8) 2130.350 → 1640.875 −19.84% (8/8)

Ready for review as a scoped opt-in CPU preparation improvement. Keep default off pending representative title eligibility and independent AMD validation; no gameplay FPS or physical upload speed claim. Reproduce with VICTORY_LINEAR_TEXTURE_STREAM=0/1 cargo test --locked -p victory-gpu --features diagnostics --lib linear_stream_production_refresh_exact -- --ignored --nocapture --test-threads=1 on Windows with WARP selected.

**@⁠tommiehansen** on GitHub · 2026-12-06 00:57 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/655) `tommiehansen:perf/phase13-linear-texture-stream-20261206` → `main` · +290 −4 · 2 files · 6 commits · open ## Why The watched texture refresh path materializes an intermediate CPU snapshot and detiles it even when the guest layout is already identical to the final upload footprint. Avoiding that redundant work reduces CPU preparation time without changing the GPU upload. ## What changes Opt-in `VICTORY_LINEAR_TEXTURE_STREAM=1` admits only tightly packed single-mip, single-layer, single-sample 2D linear textures with exactly matching row pitch, zero footprint offset and checked byte extent. Copy directly into mapped staging and preserve the existing dirty flags and GPU copy. Guarded/aliased and unsupported layouts retain their original path. ## Benchmark results Windows D3D12 WARP, eight alternating ABBA/BAAB blocks per size, four arms/block, 96/96 byte-exact actual texture uploads/readbacks. Median per-arm preparation times and median paired block reduction: | Size | Before | After | Paired reduction | Prep wins | |---|---:|---:|---:|---:| | 64x64 | 8.90 us | 2.30 us | 74.45% | 8/8 | | 256x256 | 35.75 us | 8.50 us | 76.38% | 8/8 | | 1024x1024 | 420.45 us | 159.95 us | 58.22% | 8/8 | Paired end-to-end reductions: 1.42%, 6.87%, 12.74% (5/8, 7/8, 6/8 wins). Small case median absolute totals 415.05 vs 421.40 us; timing is noisy. Larger case medians 512.10 vs 469.65 us and 1676.85 vs 1483.60 us. No physical GPU or gameplay FPS claim. ## Why this should be merged Eliminates a redundant CPU snapshot and conversion on a narrowly proven layout, preserves existing fallback and dirty tracking, and leaves default behavior unchanged. ## Validation [CI 47589934748](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47589934748): actual texture upload and GPU readback exact; cargo check --locked -p victory-gpu --all-targets passed. [Raw CSV/log](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47589934748/artifacts/15962845409). Earlier buffer-readback fixture [47589319395](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47589319395) independently passed 96 exact arms. This exercises the admission helper and copy mechanism, not full title activation. ## Compatibility and dependencies Independent of other optimization PRs; base 8c4e663, default off. Physical title activation, alias stress and full-scene timing remain validation gates. Not zero-copy into VRAM. ### Current production-refresh validation and repeat measurement [dcbc7c9 CI 47592700737](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47592700737) passed. The actual Staging::refresh_timed path executed with the switch off/on, two independent replicas of the same watched address, three changed and three clean passes, dirty/claim-upload assertions, actual texture copies and byte-exact readback. The enabled arm requires six direct refresh activations; disabled requires zero. Decommitted source-tail copy preserves the reference's zero-fill behavior. The test submits both texture lists together; it does not establish asynchronous title lifetime or physical alias mapping. Production compile passed. Repeated 96 exact paired texture uploads; median block medians (µs), paired percentages: | Size | Preparation before → after | Paired preparation | Total before → after | Paired total | |---|---:|---:|---:|---:| | 64² | 8.725 → 1.975 | −77.65% (8/8) | 411.875 → 403.125 | −3.32% (7/8) | | 256² | 32.700 → 7.925 | −76.07% (8/8) | 553.600 → 521.875 | −6.07% (7/8) | | 1024² | 394.350 → 128.500 | −66.72% (8/8) | 2130.350 → 1640.875 | −19.84% (8/8) | Ready for review as a scoped opt-in CPU preparation improvement. Keep default off pending representative title eligibility and independent AMD validation; no gameplay FPS or physical upload speed claim. Reproduce with `VICTORY_LINEAR_TEXTURE_STREAM=0/1 cargo test --locked -p victory-gpu --features diagnostics --lib linear_stream_production_refresh_exact -- --ignored --nocapture --test-threads=1` on Windows with WARP selected.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:05:13 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/655/head:github-bot/gh-655'
git switch 'github-bot/gh-655'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-655'
git switch 'github-bot/gh-655'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-655'
git switch 'github-bot/gh-655'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-655'
git switch 'main'
git merge --squash 'github-bot/gh-655'
git switch 'main'
git merge --ff-only 'github-bot/gh-655'
git switch 'main'
git merge 'github-bot/gh-655'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.