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

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3174 into main
andrewpozdnakov7-jpg commented 2026-11-26 11:07:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T11:07:37Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6625315564 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3174). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T11:07:37Z. --- 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.
Dukestar69 commented 2026-11-26 12:05:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T11:29:06Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6073374063 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3174#pullrequestreview-6073374063). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T11:29:06Z. **Review:** APPROVED --- 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).
steven-seagull27 commented 2026-11-26 12:05:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T11:17:50Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7190543930 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3174#issuecomment-7190543930). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T11:17:50Z. --- 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.
andrewpozdnakov7-jpg commented 2026-11-26 12:05:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T11:22:52Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7190651801 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3174#issuecomment-7190651801). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T11:22:52Z. --- 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3174:upstream-pr/3174'
git switch 'upstream-pr/3174'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3174'
git switch 'upstream-pr/3174'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3174'
git switch 'upstream-pr/3174'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3174'
git switch 'main'
git merge --squash 'upstream-pr/3174'
git switch 'main'
git merge --ff-only 'upstream-pr/3174'
git switch 'main'
git merge 'upstream-pr/3174'
git push origin 'main'
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!3172
No description provided.