Skip to content

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

Open
andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/texture-staging-retry
Open

andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/texture-staging-retry

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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.

@steven-seagull27

Copy link
Copy Markdown

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.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

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.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants