perf(gpu): add texture staging throttles, ripe-block guards, and post-upload slot visibility #3472

Open
github-bot wants to merge 1 commit from github-bot/gh-3472 into main AGit
Owner

@⁠legayclightning22 on GitHub · 2026-11-27 04:24 UTC · original
legayclightning22:perf/texture-staging-budget-and-visibility → main · +363 −50 · 6 files · 1 commits · open

Summary

Adds opt-in texture staging budget throttles (VICTORY_TEXTURE_STAGE_MB, VICTORY_TEXTURE_STAGE_MS, VICTORY_TEXTURE_CATCHUP), ripe-block release guards (VICTORY_RIPE_BLOCKS), and post-upload slot visibility (VICTORY_SHOW_AFTER, VICTORY_SHOW_NEW_LATER) scaled to memory tier.

Changes

  • Throttle queued texture staging and scale staging/block limits automatically on <= 8 GiB VRAM / <= 16 GiB RAM systems while preserving DirtyRanges / snapshot_generation coherency.
  • Gate texture block reuse on ripe completion and delay slot exposure until upload/copy readiness when enabled.
  • Add unit tests covering staging budget throttles, ripe-block reuse, and slot visibility behavior.

Verification

  • cargo test --locked -p victory-gpu --lib
  • cargo clippy --locked -p victory-gpu --all-targets --all-features -- -D warnings
  • cargo xtask policy
**@⁠legayclightning22** on GitHub · 2026-11-27 04:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/3472) `legayclightning22:perf/texture-staging-budget-and-visibility` → `main` · +363 −50 · 6 files · 1 commits · open ## Summary Adds opt-in texture staging budget throttles (`VICTORY_TEXTURE_STAGE_MB`, `VICTORY_TEXTURE_STAGE_MS`, `VICTORY_TEXTURE_CATCHUP`), ripe-block release guards (`VICTORY_RIPE_BLOCKS`), and post-upload slot visibility (`VICTORY_SHOW_AFTER`, `VICTORY_SHOW_NEW_LATER`) scaled to memory tier. ## Changes - Throttle queued texture staging and scale staging/block limits automatically on `<= 8 GiB` VRAM / `<= 16 GiB` RAM systems while preserving `DirtyRanges` / `snapshot_generation` coherency. - Gate texture block reuse on ripe completion and delay slot exposure until upload/copy readiness when enabled. - Add unit tests covering staging budget throttles, ripe-block reuse, and slot visibility behavior. ## Verification - `cargo test --locked -p victory-gpu --lib` - `cargo clippy --locked -p victory-gpu --all-targets --all-features -- -D warnings` - `cargo xtask policy` ```[cite: 3, 47]
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 04:25:51 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 04:46 UTC · original

WARP test report (victory-gpu, --features diagnostics --lib --locked --no-fail-fast -- --test-threads=1)

OS: Windows 11 Pro 10.0.26200 (build 26200.9974), x64
Host adapter: WARP only (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1; d3d10warp.dll 10.0.26100.9818); no physical GPU used. victory-gpu only honours VICTORY_D3D12_WARP with the diagnostics feature, so the run uses it; a test that prints its adapter reported "Microsoft Basic Render Driver".
dxil.dll: Windows SDK 10.0.26100.0, version 1.8.2502.11 (via VICTORY_DXIL)
rustc/cargo: 1.98.1 (48a229cea 2026-09-01)
Base: main 63bcca43c6
Head: ed4812941e (fast-forwards onto main, no conflicts, 6 files)

pass fail ignored
main 246 0 1
main + PR 250 0 1
  • 4 new tests, all run and pass (none ignored or skipped): descriptor::host::tests::new_slots_wait_for_upload_unless_a_draw_brings_them_on, pool::tests::pieces_are_cut_from_blocks_older_than_the_lists_that_run, texture::tests::staging_limits_scale_for_small_memory_and_backlog, texture::tests::uploads_are_remembered_for_slot_visibility. They test the pure helpers. Nothing exercises staging_space, so the problem below is not caught.

Review note (diff read, plus one throwaway probe):

  • Opt-in as described: the upload budget (VICTORY_TEXTURE_STAGE_MB/_MS) returns (u64::MAX, Duration::MAX) when neither is set, and slot_visible is true whenever VICTORY_SHOW_AFTER and VICTORY_SHOW_NEW_LATER are both off. VICTORY_TEXTURE_NO_WAIT is off unless =1.
  • Not opt-in, and it looks wrong: the rewrite of texture::staging_space. The old loop moved to the next chunk and reset the cursor ((current, used) = (current + 1, 0)). The new loop searches every chunk with the one shared cursor c.used and never resets it when a chunk is full. Once used + size > CHUNK for every existing chunk, the loop makes a new 32 MiB chunk, finds the cursor still too high, and makes another, with no end except the allocation failing. I checked this on the PR with a throwaway test (not committed, with an added cap so it could not run away): two staging_space(20 << 20) calls in a row hit the cap at the sixth chunk instead of returning the second piece from a second chunk. It needs only one pass whose pieces add up to more than one chunk, which a texture pass does at the default settings. The cursor should be kept per chunk, or reset when the search moves on.
  • Also not opt-in: small_memory() (a card of at most 8 GiB, or at most 16 GiB of RAM) lowers the kept staging buffers (64 to 16 MiB) and kept chunks (16 to 4), and VICTORY_RIPE_BLOCKS defaults to 12. These change behaviour on such machines with nothing set, which the description does not say.
  • With a budget set, bindless::uploads stops at the limit after refresh_all has already refreshed every texture in the pass; refresh has already run on the skipped ones and may have recorded their new hash, so I did not confirm that they are uploaded on a later pass.

AI-assisted (Claude). Aggregate counts only; no game files used.

**@⁠oni-swr** on GitHub · 2026-11-27 04:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/3472#issuecomment-7210084287) **WARP test report** (`victory-gpu`, `--features diagnostics --lib --locked --no-fail-fast -- --test-threads=1`) OS: Windows 11 Pro 10.0.26200 (build 26200.9974), x64 Host adapter: WARP only (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1; d3d10warp.dll 10.0.26100.9818); no physical GPU used. `victory-gpu` only honours `VICTORY_D3D12_WARP` with the `diagnostics` feature, so the run uses it; a test that prints its adapter reported "Microsoft Basic Render Driver". dxil.dll: Windows SDK 10.0.26100.0, version 1.8.2502.11 (via VICTORY_DXIL) rustc/cargo: 1.98.1 (48a229cea 2026-09-01) Base: main 63bcca43c6a0 Head: ed4812941edb (fast-forwards onto main, no conflicts, 6 files) | | pass | fail | ignored | |---|---|---|---| | main | 246 | 0 | 1 | | main + PR | 250 | 0 | 1 | - 4 new tests, all run and pass (none ignored or skipped): `descriptor::host::tests::new_slots_wait_for_upload_unless_a_draw_brings_them_on`, `pool::tests::pieces_are_cut_from_blocks_older_than_the_lists_that_run`, `texture::tests::staging_limits_scale_for_small_memory_and_backlog`, `texture::tests::uploads_are_remembered_for_slot_visibility`. They test the pure helpers. Nothing exercises `staging_space`, so the problem below is not caught. Review note (diff read, plus one throwaway probe): - Opt-in as described: the upload budget (`VICTORY_TEXTURE_STAGE_MB/_MS`) returns `(u64::MAX, Duration::MAX)` when neither is set, and `slot_visible` is true whenever `VICTORY_SHOW_AFTER` and `VICTORY_SHOW_NEW_LATER` are both off. `VICTORY_TEXTURE_NO_WAIT` is off unless `=1`. - **Not opt-in, and it looks wrong: the rewrite of `texture::staging_space`.** The old loop moved to the next chunk and reset the cursor (`(current, used) = (current + 1, 0)`). The new loop searches every chunk with the one shared cursor `c.used` and never resets it when a chunk is full. Once `used + size > CHUNK` for every existing chunk, the loop makes a new 32 MiB chunk, finds the cursor still too high, and makes another, with no end except the allocation failing. I checked this on the PR with a throwaway test (not committed, with an added cap so it could not run away): two `staging_space(20 << 20)` calls in a row hit the cap at the sixth chunk instead of returning the second piece from a second chunk. It needs only one pass whose pieces add up to more than one chunk, which a texture pass does at the default settings. The cursor should be kept per chunk, or reset when the search moves on. - Also not opt-in: `small_memory()` (a card of at most 8 GiB, or at most 16 GiB of RAM) lowers the kept staging buffers (64 to 16 MiB) and kept chunks (16 to 4), and `VICTORY_RIPE_BLOCKS` defaults to 12. These change behaviour on such machines with nothing set, which the description does not say. - With a budget set, `bindless::uploads` stops at the limit after `refresh_all` has already refreshed every texture in the pass; `refresh` has already run on the skipped ones and may have recorded their new hash, so I did not confirm that they are uploaded on a later pass. AI-assisted (Claude). Aggregate counts only; no game files used.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-27 10:25 UTC · original

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head ed48129 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 870 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: new_slots_wait_for_upload_unless_a_draw_brings_them_on, pieces_are_cut_from_blocks_older_than_the_lists_that_run, staging_limits_scale_for_small_memory_and_backlog, uploads_are_remembered_for_slot_visibility.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-27 10:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3472#issuecomment-7215877683) Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `ed48129` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **870 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `new_slots_wait_for_upload_unless_a_draw_brings_them_on`, `pieces_are_cut_from_blocks_older_than_the_lists_that_run`, `staging_limits_scale_for_small_memory_and_backlog`, `uploads_are_remembered_for_slot_visibility`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
github-bot force-pushed github-bot/gh-3472 from ed4812941e to d3e557df93 2026-11-27 14:03:24 +00:00 Compare
Author
Owner

@⁠legayclightning22 on GitHub · 2026-11-27 13:56 UTC · original

Thanks @⁠oni-swr for catching the staging_space cursor issue! Pushed d3e557d fixing texture::staging_space (crates/victory-gpu/src/texture.rs) so each chunk tracks its own used cursor rather than carrying a saturated offset across chunks, aligning bindless budget/hash checks (crates/victory-gpu/src/bindless.rs) so budget stops do not skip un-uploaded textures, and adding staging_space_reuses_chunks_across_large_allocations. Re-verified victory-gpu tests, clippy --all-targets --all-features -- -D warnings, and cargo xtask policy.

**@⁠legayclightning22** on GitHub · 2026-11-27 13:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/3472#issuecomment-7220123485) Thanks @⁠oni-swr for catching the `staging_space` cursor issue! Pushed `d3e557d` fixing `texture::staging_space` (`crates/victory-gpu/src/texture.rs`) so each chunk tracks its own `used` cursor rather than carrying a saturated offset across chunks, aligning `bindless` budget/hash checks (`crates/victory-gpu/src/bindless.rs`) so budget stops do not skip un-uploaded textures, and adding `staging_space_reuses_chunks_across_large_allocations`. Re-verified `victory-gpu` tests, `clippy --all-targets --all-features -- -D warnings`, and `cargo xtask policy`.
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/3472/head:github-bot/gh-3472'
git switch 'github-bot/gh-3472'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3472'
git switch 'github-bot/gh-3472'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3472'
git switch 'github-bot/gh-3472'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3472'
git switch 'main'
git merge --squash 'github-bot/gh-3472'
git switch 'main'
git merge --ff-only 'github-bot/gh-3472'
git switch 'main'
git merge 'github-bot/gh-3472'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3472
No description provided.