texture: VICTORY_PARTIAL_DELTA=1 and VICTORY_REFRESH_ONCE=1 (Scarlett deltas, off by default) #306

Open
github-bot wants to merge 2 commits from github-bot/gh-306 into main AGit
Owner

@⁠zocram4cc on GitHub · 2026-11-26 15:19 UTC · original
zocram4cc:feat/texture-delta-scarlett → main · +596 −3 · 4 files · 2 commits · open

What

Two texture-upload deltas from Scarlett's tree, both off by default:

  • VICTORY_PARTIAL_DELTA=1: a host copy uploaded before gets only the subresources (level x array slice) whose title bytes changed since its last submitted upload. Content-addressed per host copy and subresource; 2D, thin, single-sample layouts only.
  • VICTORY_REFRESH_ONCE=1: a copy's range that a flush brought up to date is not asked again in that submission until a write of ours lands there. =verify (diagnostics builds) checks each skip without changing the result.

VICTORY_BAKE_DELTA is not in this PR. It depends on the texture write-watch asking (ASK_TEXTURES, our fc25c61) and its state, which is not on v7900/main; it will follow once that is upstream.

Credit: Op-lite/victory-scarlett 7c8f019 (scarlett-local, GPL-3.0). Ported with the original author kept (094611a, 8477461 are cherry-picks of 096e9f0 and 1b652c4).

Why

When more of a texture picked by index maps, its staging buffer is made again and uploaded whole, even when most of it did not change. The refresh-once skip avoids re-asking ranges a flush already brought up to date.

Measured

Linux, Proton, Series S, release build, single 300 s runs (world time) each. Arms differ only in the switches named:

  • base: 73.3 ms;
  • PORT_GUARD + PORT_JOURNAL + PARTIAL_DELTA + REFRESH_ONCE: 69.8 ms (best on every metric in that set);
  • PARTIAL_DELTA alone: 77.2 ms;
  • REFRESH_ONCE alone: 74.5 ms.

The gain appears only in combination with ports 6 and 7 (PORT_GUARD, PORT_JOURNAL, both on v7900/main); alone, each switch is slower than base. These are single runs, so treat the ~3.5 ms gap as indicative, not established.

Linux/Proton only measured. Windows untested.

Tests

texture::delta::tests (four, PARTIAL_DELTA state machine) and host::refresh_once_tests (two, join and trim rules). Red against stubs, green after, under Proton with --test-threads 1 in the original tree. The upload hooks are compile-checked only.

Run under Proton on this head (8477461), one test exe, --test-threads 1:

  • texture::delta::tests and host::refresh_once_tests (6) with VICTORY_PARTIAL_DELTA=1 VICTORY_REFRESH_ONCE=1: 6 pass.
  • watch:: (48 tests) with the two switches on: 45 pass, 3 fail; unset: 45 pass, 3 fail. The same 3 fail in both, and they are the Wine-only failures that also fail on upstream: holes_are_known_until_the_runtime_tells, no_mapping_is_lost_between_askers, what_is_left_alone_is_no_known_hole.

Build

cargo xwin build --profile release -p victory --target x86_64-pc-windows-msvc: passes on this branch.

AI-assisted (Claude Code).

**@⁠zocram4cc** on GitHub · 2026-11-26 15:19 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/306) `zocram4cc:feat/texture-delta-scarlett` → `main` · +596 −3 · 4 files · 2 commits · open ## What Two texture-upload deltas from Scarlett's tree, both off by default: - `VICTORY_PARTIAL_DELTA=1`: a host copy uploaded before gets only the subresources (level x array slice) whose title bytes changed since its last submitted upload. Content-addressed per host copy and subresource; 2D, thin, single-sample layouts only. - `VICTORY_REFRESH_ONCE=1`: a copy's range that a flush brought up to date is not asked again in that submission until a write of ours lands there. `=verify` (diagnostics builds) checks each skip without changing the result. `VICTORY_BAKE_DELTA` is not in this PR. It depends on the texture write-watch asking (ASK_TEXTURES, our fc25c61) and its state, which is not on `v7900/main`; it will follow once that is upstream. Credit: Op-lite/victory-scarlett 7c8f019 (scarlett-local, GPL-3.0). Ported with the original author kept (094611a, 8477461 are cherry-picks of 096e9f0 and 1b652c4). ## Why When more of a texture picked by index maps, its staging buffer is made again and uploaded whole, even when most of it did not change. The refresh-once skip avoids re-asking ranges a flush already brought up to date. ## Measured Linux, Proton, Series S, release build, single 300 s runs (world time) each. Arms differ only in the switches named: - base: 73.3 ms; - PORT_GUARD + PORT_JOURNAL + PARTIAL_DELTA + REFRESH_ONCE: 69.8 ms (best on every metric in that set); - PARTIAL_DELTA alone: 77.2 ms; - REFRESH_ONCE alone: 74.5 ms. The gain appears only in combination with ports 6 and 7 (PORT_GUARD, PORT_JOURNAL, both on `v7900/main`); alone, each switch is slower than base. These are single runs, so treat the ~3.5 ms gap as indicative, not established. Linux/Proton only measured. Windows untested. ## Tests `texture::delta::tests` (four, PARTIAL_DELTA state machine) and `host::refresh_once_tests` (two, join and trim rules). Red against stubs, green after, under Proton with `--test-threads 1` in the original tree. The upload hooks are compile-checked only. Run under Proton on this head (8477461), one test exe, `--test-threads 1`: - `texture::delta::tests` and `host::refresh_once_tests` (6) with `VICTORY_PARTIAL_DELTA=1 VICTORY_REFRESH_ONCE=1`: 6 pass. - `watch::` (48 tests) with the two switches on: 45 pass, 3 fail; unset: 45 pass, 3 fail. The same 3 fail in both, and they are the Wine-only failures that also fail on upstream: `holes_are_known_until_the_runtime_tells`, `no_mapping_is_lost_between_askers`, `what_is_left_alone_is_no_known_hole`. ## Build `cargo xwin build --profile release -p victory --target x86_64-pc-windows-msvc`: passes on this branch. AI-assisted (Claude Code).
When more of a texture picked by index maps, its staging buffer is made
again and uploaded whole into the host copy that was uploaded before.
With the switch on, a host copy uploaded before gets only the
subresources (level x array slice) whose title bytes differ from what it
got at its last submitted upload. The record is content-addressed: per
host copy serial and subresource, the digest of the title bytes the
subresource was detiled from at the submission that copied it. A part is
left out only if its bytes digest the same at recording and at that
submission's own detiling. Otherwise the record is forgotten, the host
copy is not said to hold the bytes read, and the texture's slots are made
due again, so the next pass uploads it whole.

Only 2D, thin, single-sample layouts whose subresources detile from their
own span take it (`delta::spans`; a test pins that a detiling reads
nothing outside its span). Bake uploads, levels on demand and copies the
card writes (`alias`) are not delta uploads.

Counter, a line every 5 s while the switch is on, in release and
diagnostics builds (tracing::info!, the run's console log):
  partial delta (VICTORY_PARTIAL_DELTA=1), last 5 s: ...

Ported from Op-lite/victory-scarlett 7c8f019 (scarlett-local, GPL-3.0):
crates/victory-gpu/src/texture/delta.rs and its hooks in texture.rs,
adapted to this tree's Staging, HostTexture and detile path. Not ported:
scarlett's band detiling (detile_rows) and their meters.

Tests: texture::delta::tests, four, run under Proton with
--test-threads 1. Red: state machine stubbed, all four fail. Green: all
four pass. The upload hooks in texture.rs are compile-checked only.
A copy's range that a flush of a submission brought up to date is not
asked again in that submission until a step of ours writes title memory
there. The skip this tree already has (`Batch::ahead`, from
VICTORY_REFRESH_AHEAD / _FRONT) holds what is refreshed ahead of the
steps and is cleared whole at every title copy. This one is filled by
every flush (`flush_all` -> `Batch::brought`), and a title copy
(Step::Copy -> `title_written_at`) trims only the ranges it overlaps,
the larger side of each staying. Other title writes (placed copies,
steps of ours) clear it, as they clear `ahead`. With the switch off,
`title_written_at` does what `title_written` did.

`=verify` (diagnostics builds): every skip is decided and the refresh
done all the same; a refresh that took bytes is counted, the first 16
(then powers of two) logged. Lines (tracing, the run's console log):
  WARN  VICTORY_REFRESH_ONCE=verify: a refresh the skip would have left out took bytes
  INFO  VICTORY_REFRESH_ONCE=verify, since the start: skips checked N, refreshes the skip would have missed M (X MB)
Skips are counted in the copystat line's "N skipped M MB" (diagnostics
builds).

Ported from Op-lite/victory-scarlett 7c8f019 (scarlett-local, GPL-3.0),
crates/victory-gpu/src/host.rs: `Batch::once`, `refresh_once`,
`once_verify`, `title_written_at`, `brought`. Their join and trim rules
are pure functions here (`join_once`, `trim_once`). Not ported: the
VICTORY_CHUNK_FINAL hooks scarlett has in the same functions (another
switch).

Tests: host::refresh_once_tests, two, run under Proton with
--test-threads 1. Red: join_once and trim_once stubbed, both fail.
Green: both pass. The Batch hooks are compile-checked only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:20:44 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/texture.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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