GPU: check a sampled texture once per submission, not once per list #79

Merged
TG0000 merged 1 commit from upstream-pr/79 into main 2026-11-24 00:41:12 +00:00
TG0000 commented 2026-11-24 00:16:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T00:16:53Z.


What

A title texture's staging refresh (texture::Staging::refresh) ran as a host step of every list that sampled it. When several lists in one submission sample the same texture, it was checked again for each list. In physical-page memory, which cannot be write-watched, each check is a VirtualQuery walk (texture::committed) plus a blake3 hash of the whole texture.

Checks after the first one in a submission did nothing:

  • every list's CopyTextureRegion reads the same staging buffer, and
  • the GPU runs those copies only after all of the submission's CPU-side steps (run_deferred for every list, then ExecuteCommandLists).

So a second check could change only what the GPU reads if title memory had been written in between.

How

  • Texture refreshes are now their own step: Step::Texture(Arc<Staging>), added via HostList::defer_texture. Before, they went through the generic defer_host closure.
  • The submission's Batch, which already merges buffer refreshes across lists, now also records the staging buffers it has refreshed (texture_due).
  • Step::Copy (a write into title memory) and Step::Run (work that may write title memory) call Batch::title_written(). It flushes pending buffer refreshes, as before, and clears the texture record, so a texture is checked again after any such write. This is the same rule Step::Refresh follows ("once per submission … until a Copy or Run intervenes").
  • GpuWrite still only flushes, because it doesn't write title memory.

Two files: crates/victory-gpu/src/host.rs and crates/victory-gpu/src/texture.rs (the Staging type and its refresh become pub(crate)).

Benchmark (synthetic)

host::tests::texture_checks_per_submission (ignored) runs on one submission. It times the blake3 hashing done when each of 12 lists checks the same 48 textures of 4 MiB, then the same with the new per-submission check. The list and texture counts are made up, not measured from a title.

cargo test --release -p victory-gpu --lib -- --ignored --nocapture texture_checks
12 lists sampling 48 textures of 4 MiB: before 576 hashes in 676.2ms, after 48 in 56.5ms (12.0x)
12 lists sampling 48 textures of 4 MiB: before 576 hashes in 685.3ms, after 48 in 64.7ms (10.6x)
12 lists sampling 48 textures of 4 MiB: before 576 hashes in 715.3ms, after 48 in 57.5ms (12.4x)

The real gain depends on how many lists of a world submission sample the same physical-page textures. This PR doesn't measure that, because the title wasn't run.

Tests

  • New: a_texture_is_checked_once_per_submission and title_writes_make_textures_due_again.
  • cargo test --workspace (stable MSVC): all pass.
  • cargo clippy --workspace --all-targets: same 16 warnings as main, none in the changed code.
  • cargo fmt --check: no new diffs. main already has rustfmt diffs in victory-gpu; those remain.
  • cargo xtask policy: asset policy: 150 files ok.
  • Windows 11. Not run against the title and not GPU-tested: the change is CPU-side submission bookkeeping, and the unit tests don't need a host device.

No game data is in the commit, the tests or this description.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6571641810 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/79). Originally posted by [TG0000](https://github.com/TG0000) on 2026-11-24T00:16:53Z. --- ## What A title texture's staging refresh (`texture::Staging::refresh`) ran as a host step of **every list** that sampled it. When several lists in one submission sample the same texture, it was checked again for each list. In physical-page memory, which cannot be write-watched, each check is a `VirtualQuery` walk (`texture::committed`) plus a **blake3 hash of the whole texture**. Checks after the first one in a submission did nothing: - every list's `CopyTextureRegion` reads the same staging buffer, and - the GPU runs those copies only after all of the submission's CPU-side steps (`run_deferred` for every list, then `ExecuteCommandLists`). So a second check could change only what the GPU reads if title memory had been written in between. ## How - Texture refreshes are now their own step: `Step::Texture(Arc<Staging>)`, added via `HostList::defer_texture`. Before, they went through the generic `defer_host` closure. - The submission's `Batch`, which already merges buffer refreshes across lists, now also records the staging buffers it has refreshed (`texture_due`). - `Step::Copy` (a write into title memory) and `Step::Run` (work that may write title memory) call `Batch::title_written()`. It flushes pending buffer refreshes, as before, and clears the texture record, so a texture is checked again after any such write. This is the same rule `Step::Refresh` follows ("once per submission … until a `Copy` or `Run` intervenes"). - `GpuWrite` still only flushes, because it doesn't write title memory. Two files: `crates/victory-gpu/src/host.rs` and `crates/victory-gpu/src/texture.rs` (the `Staging` type and its `refresh` become `pub(crate)`). ## Benchmark (synthetic) `host::tests::texture_checks_per_submission` (ignored) runs on one submission. It times the blake3 hashing done when each of 12 lists checks the same 48 textures of 4 MiB, then the same with the new per-submission check. The list and texture counts are made up, not measured from a title. ``` cargo test --release -p victory-gpu --lib -- --ignored --nocapture texture_checks 12 lists sampling 48 textures of 4 MiB: before 576 hashes in 676.2ms, after 48 in 56.5ms (12.0x) 12 lists sampling 48 textures of 4 MiB: before 576 hashes in 685.3ms, after 48 in 64.7ms (10.6x) 12 lists sampling 48 textures of 4 MiB: before 576 hashes in 715.3ms, after 48 in 57.5ms (12.4x) ``` The real gain depends on how many lists of a world submission sample the same physical-page textures. This PR doesn't measure that, because the title wasn't run. ## Tests - New: `a_texture_is_checked_once_per_submission` and `title_writes_make_textures_due_again`. - `cargo test --workspace` (stable MSVC): all pass. - `cargo clippy --workspace --all-targets`: same 16 warnings as `main`, none in the changed code. - `cargo fmt --check`: no new diffs. `main` already has rustfmt diffs in `victory-gpu`; those remain. - `cargo xtask policy`: `asset policy: 150 files ok`. - Windows 11. Not run against the title and not GPU-tested: the change is CPU-side submission bookkeeping, and the unit tests don't need a host device. No game data is in the commit, the tests or this description. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:51:13 +00:00
DaviTostes commented 2026-11-24 06:54:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:57:57Z.


Tested 73d776b under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.\n\n- victory_gpu: 38 passed, 3 failed, 1 ignored; the three are the environment-only failures (argument_clamp_builds, a_rejected_blob_gives_an_empty_library, #128's upload skip).\n- The change is a per-submission deduplication, and the suite still passes with it.\n\nNo game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118616889 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/79#issuecomment-7118616889). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T00:57:57Z. --- Tested `73d776b` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**.\n\n- `victory_gpu`: **38 passed, 3 failed, 1 ignored**; the three are the environment-only failures (`argument_clamp_builds`, `a_rejected_blob_gives_an_empty_library`, #128's upload skip).\n- The change is a per-submission deduplication, and the suite still passes with it.\n\nNo game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!79
No description provided.