GPU: retry tracked texture uploads after a staging allocation fails #3174

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 11:07 UTC · original
andrewpozdnakov7-jpg:codex2/texture-staging-retry → main · +112 −8 · 2 files · 1 commits · open

A tracked texture takes its changed pages before reserving an upload buffer. If that reservation fails, the next submission sees a clean tracker and skips the upload even when staging space is available again. Restore the taken pages to that texture's tracker when the allocation is refused.

The same Windows WARP regression filled a tracked 4×4 RGBA8 texture, refused its first staging allocation, and allowed the next allocation with no title writes between the two attempts.

Build Dirty after refusal Texels in the retry's D3D12 upload buffer
main 63bcca4 No 0 of 16
Patched Yes 16 of 16, all exact

A third refresh found the tracker clean. App-local WARP diagnostics passed 247 tests with one ignored. Strict GPU Clippy passed with default and all features. The asset policy passed.

$env:VICTORY_D3D12_WARP = '1'
cargo test -p victory-gpu --features diagnostics --locked tracked_texture_retries_after_staging_allocation_fails -- --nocapture

#3136 also edits the allocation site in texture.rs. The two current branches have a text conflict there. When combined, retry the taken pages if the allocation of the packed staging space fails.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 11:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3174) `andrewpozdnakov7-jpg:codex2/texture-staging-retry` → `main` · +112 −8 · 2 files · 1 commits · open A tracked texture takes its changed pages before reserving an upload buffer. If that reservation fails, the next submission sees a clean tracker and skips the upload even when staging space is available again. Restore the taken pages to that texture's tracker when the allocation is refused. The same Windows WARP regression filled a tracked 4×4 RGBA8 texture, refused its first staging allocation, and allowed the next allocation with no title writes between the two attempts. | Build | Dirty after refusal | Texels in the retry's D3D12 upload buffer | | --- | --- | --- | | main 63bcca4 | No | 0 of 16 | | Patched | Yes | 16 of 16, all exact | A third refresh found the tracker clean. App-local WARP diagnostics passed 247 tests with one ignored. Strict GPU Clippy passed with default and all features. The asset policy passed. $env:VICTORY_D3D12_WARP = '1' cargo test -p victory-gpu --features diagnostics --locked tracked_texture_retries_after_staging_allocation_fails -- --nocapture #3136 also edits the allocation site in texture.rs. The two current branches have a text conflict there. When combined, retry the taken pages if the allocation of the packed staging space fails.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:09:30 +00:00
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 11:17 UTC · original

Confirmed the conflict resolution with #3136 on an RTX 5080 and Windows inbox WARP. The allocator passed to detile must receive the packed byte count. Both adapters read back all 49,152/49,152 destination texels correctly after the retry. Tested merge of 656a143 and 0c59a0f · Regression test

The test seeds three 128×128 RGBA8 slices with different values. It writes slice 2, refuses its 64 KiB reservation, then writes slice 0 before retrying. The retry requests 128 KiB for slices 0 and 2. Each updated slice and the untouched middle slice matched all 16,384 expected texels after the GPU copy and fence. The next refresh requested no space.

Two controls behaved identically on both adapters with the D3D12 debug layer enabled:

Change to the combined build Readback after the retry
Remove only the restoration of dirty pages Slice 0 updated and slice 1 stayed intact. Slice 2 had 0/16,384 updated texels.
Reserve the whole texture while keeping retry and packed copies All texels matched, but both reservations grew to 192 KiB.

The existing single-mip readback and 4×4 retry regression also passed on both. To run the new synthetic test in a test checkout (PowerShell):

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/tracked-packed-retry
git switch --detach FETCH_HEAD
$env:VICTORY_D3D12_DEBUG = '1'
foreach ($warp in '0','1') {
    $env:VICTORY_D3D12_WARP = $warp
    cargo test --locked -p victory-gpu --all-features --lib packed_retry_preserves_old_and_new_writes -- --nocapture --test-threads=1
}

AI-assisted testing with Codex. Synthetic texture data only.

**@⁠steven-seagull27** on GitHub · 2026-11-26 11:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3174#issuecomment-7190543930) Confirmed the conflict resolution with #3136 on an RTX 5080 and Windows inbox WARP. The allocator passed to `detile` must receive the **packed** byte count. Both adapters read back all **49,152/49,152 destination texels** correctly after the retry. [Tested merge of `656a143` and `0c59a0f`](https://github.com/steven-seagull27/VIctory/commit/866ec0b503ef693066e2c93eca8f0625180c0307) · [Regression test](https://github.com/steven-seagull27/VIctory/commit/74c98263537843e0c564797337ccd2128ae2f24e) The test seeds three 128×128 RGBA8 slices with different values. It writes slice 2, refuses its 64 KiB reservation, then writes slice 0 before retrying. The retry requests 128 KiB for slices 0 and 2. Each updated slice and the untouched middle slice matched all 16,384 expected texels after the GPU copy and fence. The next refresh requested no space. Two controls behaved identically on both adapters with the D3D12 debug layer enabled: | Change to the combined build | Readback after the retry | |---|---| | Remove only the restoration of dirty pages | Slice 0 updated and slice 1 stayed intact. Slice 2 had **0/16,384** updated texels. | | Reserve the whole texture while keeping retry and packed copies | All texels matched, but both reservations grew to **192 KiB**. | The existing single-mip readback and 4×4 retry regression also passed on both. To run the new synthetic test in a test checkout (PowerShell): ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/tracked-packed-retry git switch --detach FETCH_HEAD $env:VICTORY_D3D12_DEBUG = '1' foreach ($warp in '0','1') { $env:VICTORY_D3D12_WARP = $warp cargo test --locked -p victory-gpu --all-features --lib packed_retry_preserves_old_and_new_writes -- --nocapture --test-threads=1 } ``` AI-assisted testing with Codex. Synthetic texture data only.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 11:22 UTC · original

Thanks @⁠steven-seagull27. I independently resolved the same conflict between 656a143 and 0c59a0f and checked a different layout with app-local Agility SDK 620 and WARP 1.0.22.

My tracked 512×512 RGBA8 fixture uploads both mips, changes only the 256×256 mip, then refuses its reservation once. The failed attempt and the retry both requested 262,144 bytes, compared with 1,310,720 bytes for the full texture. With no intervening title write, the retry staged mip 1 alone, all 65,536/65,536 texels matched, and the next refresh made no allocation. The combined suite also passed #3136's GPU mip readback and its untouched-mip control.

Full GPU diagnostics 249 passed, 1 ignored, strict GPU Clippy in both configurations, and asset policy passed. The composed detiler passes the packed size to the retry allocator. Your published merge and three-slice test provide a reproducible reference.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 11:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/3174#issuecomment-7190651801) Thanks @⁠steven-seagull27. I independently resolved the same conflict between `656a143` and `0c59a0f` and checked a different layout with app-local Agility SDK 620 and WARP 1.0.22. My tracked 512×512 RGBA8 fixture uploads both mips, changes only the 256×256 mip, then refuses its reservation once. The failed attempt and the retry both requested **262,144 bytes**, compared with **1,310,720 bytes** for the full texture. With no intervening title write, the retry staged mip 1 alone, all **65,536/65,536 texels** matched, and the next refresh made no allocation. The combined suite also passed #3136's GPU mip readback and its untouched-mip control. Full GPU diagnostics **249 passed, 1 ignored**, strict GPU Clippy in both configurations, and asset policy passed. The composed detiler passes the packed size to the retry allocator. Your published merge and three-slice test provide a reproducible reference. AI-assisted with Codex.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 11:29 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib texture:: -- --test-threads=1: 3/3 passed (including tracked_texture_retries_after_staging_allocation_fails).
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly marks tracked texture pages dirty again so uploads retry after a transient staging allocation failure.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 11:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3174#pullrequestreview-6073374063) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib texture:: -- --test-threads=1`: 3/3 passed (including `tracked_texture_retries_after_staging_allocation_fails`). - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20/20 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly marks tracked texture pages dirty again so uploads retry after a transient staging allocation failure. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/3174/head:github-bot/gh-3174'
git switch 'github-bot/gh-3174'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3174'
git switch 'github-bot/gh-3174'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3174'
git switch 'github-bot/gh-3174'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3174'
git switch 'main'
git merge --squash 'github-bot/gh-3174'
git switch 'main'
git merge --ff-only 'github-bot/gh-3174'
git switch 'main'
git merge 'github-bot/gh-3174'
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!3174
No description provided.