Textures: VICTORY_TEXTURES_IN_PC=1 places streamed textures in system memory when the card is full #3070

Closed
github-bot wants to merge 3 commits from github-bot/gh-3070 into main AGit
Owner

@⁠Adriwin06 on GitHub · 2026-11-29 19:52 UTC · original
Adriwin06:textures-in-pc → main · +357 −60 · 4 files · 3 commits · closed without merging

What it changes

Off by default. When a streamed texture's host copy cannot be placed
on the card (the budget has no room for it), VICTORY_TEXTURES_IN_PC=1
places it in system memory instead of failing the upload: in a
non-local (L0) custom heap where the adapter supports one, cut from a
pool of 16 MiB system-memory blocks (PC_TEXTURES, reclaimed with the
staging pool), or as a committed allocation of just the texture's size
when a new block would not fit. Admission keeps headroom in the shared
budget (pc_texture_room), the local-VRAM admission still comes first,
and a transient allocation failure is retried. The first spill is
logged once.

Tests: resource::system_texture_admission_keeps_shared_budget_headroom,
resource::system_texture_uses_a_nonlocal_heap_when_the_adapter_supports_it.

Ported from readmet3xt-lab/foxhound@7c53527 (readmet3xt-lab), ba04392
and 5b6ebb4 (dilim), GPL-3.0-or-later.

How it was tested

  • GPU and profile: RTX 4070 SUPER, Ryzen 7 5800X. Not measured in the title on these commits by themselves: they come from a fork of mine that carries them with the rest of this set, and the title ran there. What is below is the unit tests on this branch.
  • Before: n/a (no in-title measurement on this branch)
  • After: n/a
  • cargo test passed for the crates it touches:
    • this change: yes, cargo test -p victory-gpu --lib -- resource:: pool::: 73 passed. host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue fails now and then when it runs beside the resource:: tests, on main as on this branch (1 run in 4 on each here): it reads the process-wide UAV spare pool
  • cargo clippy --workspace --all-targets --locked: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself).
  • cargo xtask policy: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs).
  • With all eleven of my pull requests merged together: cargo clippy also with --all-features adds no finding, and cargo test --workspace --locked fails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related:
    None found for placing streamed textures in system memory (searched "system memory textures", "spill", "L0"). Touches the same alignment line as #3069 (small-alignment) (one line to merge).

🤖 Generated with Claude Code

**@⁠Adriwin06** on GitHub · 2026-11-29 19:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3070) `Adriwin06:textures-in-pc` → `main` · +357 −60 · 4 files · 3 commits · closed without merging ## What it changes Off by default. When a streamed texture's host copy cannot be placed on the card (the budget has no room for it), VICTORY_TEXTURES_IN_PC=1 places it in system memory instead of failing the upload: in a non-local (L0) custom heap where the adapter supports one, cut from a pool of 16 MiB system-memory blocks (PC_TEXTURES, reclaimed with the staging pool), or as a committed allocation of just the texture's size when a new block would not fit. Admission keeps headroom in the shared budget (pc_texture_room), the local-VRAM admission still comes first, and a transient allocation failure is retried. The first spill is logged once. Tests: resource::system_texture_admission_keeps_shared_budget_headroom, resource::system_texture_uses_a_nonlocal_heap_when_the_adapter_supports_it. Ported from readmet3xt-lab/foxhound@7c53527 (readmet3xt-lab), ba04392 and 5b6ebb4 (dilim), GPL-3.0-or-later. ## How it was tested - GPU and profile: RTX 4070 SUPER, Ryzen 7 5800X. Not measured in the title on these commits by themselves: they come from a fork of mine that carries them with the rest of this set, and the title ran there. What is below is the unit tests on this branch. - Before: n/a (no in-title measurement on this branch) - After: n/a - `cargo test` passed for the crates it touches: - this change: yes, `cargo test -p victory-gpu --lib -- resource:: pool::`: 73 passed. host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue fails now and then when it runs beside the resource:: tests, on main as on this branch (1 run in 4 on each here): it reads the process-wide UAV spare pool - `cargo clippy --workspace --all-targets --locked`: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself). - `cargo xtask policy`: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs). - With all eleven of my pull requests merged together: `cargo clippy` also with `--all-features` adds no finding, and `cargo test --workspace --locked` fails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: None found for placing streamed textures in system memory (searched "system memory textures", "spill", "L0"). Touches the same alignment line as #3069 (small-alignment) (one line to merge). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Off by default. When a streamed texture's host copy cannot be placed
on the card (the budget has no room for it), VICTORY_TEXTURES_IN_PC=1
places it in system memory instead of failing the upload: in a
non-local (L0) custom heap where the adapter supports one, cut from a
pool of 16 MiB system-memory blocks (PC_TEXTURES, reclaimed with the
staging pool), or as a committed allocation of just the texture's size
when a new block would not fit. Admission keeps headroom in the shared
budget (pc_texture_room), the local-VRAM admission still comes first,
and a transient allocation failure is retried. The first spill is
logged once.

Tests: resource::system_texture_admission_keeps_shared_budget_headroom,
resource::system_texture_uses_a_nonlocal_heap_when_the_adapter_supports_it.

Ported from readmet3xt-lab/foxhound@7c53527 (readmet3xt-lab), ba04392
and 5b6ebb4 (dilim), GPL-3.0-or-later.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:59:44 +00:00
@ -4441,1 +4452,4 @@
}
if pc_room.is_some() && texture.is_none() {
tells.tell(index, write, Told::Held(frame + most));
continue;
Author
Owner

@⁠Copilot on GitHub · 2026-11-29 19:57 UTC · original

If system-memory allocation is temporarily refused for a differently formatted view of a host-written texture, the retry can lose its source contents. seed_pending removes the seed before attempting allocation (texture.rs:869–880), so a later successful allocation has nothing to copy and title-memory uploads are skipped for this view. Preserve the seed until its copy is recorded, and keep the descriptor pending while seeding fails.

**@⁠Copilot** on GitHub · 2026-11-29 19:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3070#discussion_r4732926489) If system-memory allocation is temporarily refused for a differently formatted view of a host-written texture, the retry can lose its source contents. `seed_pending` removes the seed before attempting allocation (`texture.rs:869–880`), so a later successful allocation has nothing to copy and title-memory uploads are skipped for this view. Preserve the seed until its copy is recorded, and keep the descriptor pending while seeding fails.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-29 19:57 UTC · original · reviewed

Critical issues can lose host-written texture contents during allocation retries and let concurrent allocations exceed the shared-memory budget ceiling.

2 open issues
What changed in this PR

Adds an opt-in system-memory fallback for streamed textures when local video-memory admission rejects them, extending the GPU upload path without changing default behavior.

Changes:

  • Adds VICTORY_TEXTURES_IN_PC=1 with shared-budget checks and non-local texture allocations.
  • Introduces 16 MiB texture pools, committed-allocation fallback, and upload retry handling with deferred descriptor publication.
  • Adds tests for shared-budget headroom, nested allocation scopes, and non-local heap placement.
File Description
crates/​victory-gpu/​src/​resource.rs Adds fallback admission, allocation scope, system-memory accounting, and tests.
crates/​victory-gpu/​src/​pool.rs Supports configurable block sizes and a reclaimable system-memory texture pool.
crates/​victory-gpu/​src/​draw.rs Integrates fallback selection, allocation retries, and deferred descriptor publication.

Review effort: Balanced

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-29 19:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3070#pullrequestreview-6104536682) · **reviewed** <!-- ccr-overview-v2 --> ### 🟡 Changes recommended Critical issues can lose host-written texture contents during allocation retries and let concurrent allocations exceed the shared-memory budget ceiling. <details open> <summary><strong>2 open issues</strong></summary> - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Preserve texture seed when allocation fails](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/3070) · New - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Reserve shared budget during concurrent allocations](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/3070) · New </details> <details> <summary><strong>What changed in this PR</strong></summary> Adds an opt-in system-memory fallback for streamed textures when local video-memory admission rejects them, extending the GPU upload path without changing default behavior. **Changes:** - Adds `VICTORY_TEXTURES_IN_PC=1` with shared-budget checks and non-local texture allocations. - Introduces 16 MiB texture pools, committed-allocation fallback, and upload retry handling with deferred descriptor publication. - Adds tests for shared-budget headroom, nested allocation scopes, and non-local heap placement. | File | Description | | ---- | ----------- | | `crates/​victory-gpu/​src/​resource.rs` | Adds fallback admission, allocation scope, system-memory accounting, and tests. | | `crates/​victory-gpu/​src/​pool.rs` | Supports configurable block sizes and a reclaimable system-memory texture pool. | | `crates/​victory-gpu/​src/​draw.rs` | Integrates fallback selection, allocation retries, and deferred descriptor publication. | </details> <sub>Review effort: Balanced</sub>
@ -1191,0 +1229,4 @@
if pc.is_some() { Ripe::ALL } else { Ripe::now() }
}, || {
if pc.is_some_and(|(_, room)| room < block_size || crate::residency::critical_commit()) {
return BlockGrowth::Deferred;
Author
Owner

@⁠Copilot on GitHub · 2026-11-29 19:57 UTC · original

room is a captured DXGI usage sample, but take_from_with_growth releases the pool lock before this check. Concurrent uploads can each allocate a 16 MiB block against the same 16 MiB allowance, crossing the 75% shared-budget ceiling; committed fallbacks in resource::host_texture_as share this issue. Reserve pending bytes across both allocation paths, release reservations on failure, and reconcile successful allocations with usage samples before admitting further growth.

**@⁠Copilot** on GitHub · 2026-11-29 19:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3070#discussion_r4732926520) `room` is a captured DXGI usage sample, but `take_from_with_growth` releases the pool lock before this check. Concurrent uploads can each allocate a 16 MiB block against the same 16 MiB allowance, crossing the 75% shared-budget ceiling; committed fallbacks in `resource::host_texture_as` share this issue. Reserve pending bytes across both allocation paths, release reservations on failure, and reconcile successful allocations with usage samples before admitting further growth.
seed_pending took the seed out of SEEDS before the host textures and the
buffer it needs were made, so an allocation refused for a while (one in
system memory with VICTORY_TEXTURES_IN_PC=1) lost it: a later successful
allocation had nothing to copy, and the view's host copy never had the
texels the host wrote. The seed now stays until the copy is recorded
(textures of other shapes still drop it; releases already clear it), and
a slot placed in system memory is held while its seed waits
(seed_waits), rather than uploaded from title memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The room the texture pass sampled was checked after the pool's lock was
let go, so uploads on other threads each made a 16 MiB block against the
same 16 MiB of it, past the shared budget's 75% ceiling; the committed
fallback had the same gap. Each system-memory block and committed
texture now holds its bytes in PC_ALLOCATING first, then takes a fresh
DXGI sample and goes ahead only if what is in use and every allocation
under way stay under the ceiling (PcReservation, fits_shared); the bytes
are given back once it is made (the next sample counts it) or refused.
Test: allocations_under_way_share_one_allowance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original

Fixed in a8bec768: seed_pending now leaves the seed in SEEDS until the copy is recorded. Transient failures (no host texture yet, no buffer) keep it for the next use, a shape mismatch still drops it, and releases already clear it. In the texture pass, a system-memory slot is held while seed_waits(resource) is true, so title memory is not uploaded instead.

**@⁠Adriwin06** on GitHub · 2026-11-30 01:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3070#discussion_r4734087464) Fixed in a8bec768: `seed_pending` now leaves the seed in `SEEDS` until the copy is recorded. Transient failures (no host texture yet, no buffer) keep it for the next use, a shape mismatch still drops it, and releases already clear it. In the texture pass, a system-memory slot is held while `seed_waits(resource)` is true, so title memory is not uploaded instead.
@ -1191,0 +1229,4 @@
if pc.is_some() { Ripe::ALL } else { Ripe::now() }
}, || {
if pc.is_some_and(|(_, room)| room < block_size || crate::residency::critical_commit()) {
return BlockGrowth::Deferred;
Author
Owner

@⁠Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original

Fixed in e5fc66e9: each system-memory block (in the pool's growth closure) and each committed fallback now takes a PcReservation. It adds its bytes to PC_ALLOCATING first, takes a fresh DXGI sample, and goes ahead only if what is in use plus every allocation under way stays under 75% of the shared budget (fits_shared). The bytes are given back when the reservation drops, once the allocation is made (the next sample counts it) or refused. Regression test: allocations_under_way_share_one_allowance.

**@⁠Adriwin06** on GitHub · 2026-11-30 01:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3070#discussion_r4734087594) Fixed in e5fc66e9: each system-memory block (in the pool's growth closure) and each committed fallback now takes a `PcReservation`. It adds its bytes to `PC_ALLOCATING` first, takes a fresh DXGI sample, and goes ahead only if what is in use plus every allocation under way stays under 75% of the shared budget (`fits_shared`). The bytes are given back when the reservation drops, once the allocation is made (the next sample counts it) or refused. Regression test: `allocations_under_way_share_one_allowance`.
github-bot closed this pull request 2026-12-01 18:59:15 +00:00

Pull request closed

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/trustno1-coder--VIctory-NVIDIA!3070
No description provided.