Repository navigation
GPU: a tracked texture write detiles and copies only the rows it touches (#1135) - #2985
wwwwwwww3333333 wants to merge 4 commits into
Conversation
…hes (Marvisak#1135) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: touched_rows over-approximates a row's tiled byte span via the run extent [min start, max end), which is exact for packed layouts and conservative for padded ones — a hit between row extents yields an empty range and correctly detiles nothing. detile_rows keeps linear offsets at original y so the copy box maps staging rows 1:1 onto texture rows. The test is properly discriminating: one dirty page moves only its rows, untouched rows provably keep prior host content, and >50 genuinely-partial cases are asserted.
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed 632d05e1 against main (63bcca43) — row geometry, BC 4-texel Y-interval alignment, mip/slice bounds, and sorted disjoint dirty ranges look solid, but there are two subtle partial-upload data-corruption bugs worth fixing before merge:
-
First upload can omit initialized rows in a partially tracked mip (
crates/victory-gpu/src/texture.rs:588-636,watch.rs:331-365):watch.rsallows tracking to cover only part of a texture's allocation. Becausetexture.rs:588-636builds its row plan solely from tracked dirty ranges, if a mip overlaps at least one full tracked page (own(i)enables partial upload) alongside adjacent rows living on untracked pages, the first upload copies only the tracked rows and omits valid initialized data on the untracked pages (mainuploaded the whole touched mip).- Falling back to the full-subresource upload path whenever a mip overlaps untracked memory (plus a mixed-coverage test) would prevent dropping untracked rows.
-
A failed staging upload can leave rows permanently stale after a later write (
crates/victory-gpu/src/texture.rs:594, 681-685):- Dirty pages are consumed at line
594before staging succeeds, while the staging-failure path at681-685only clears hashes. - If staging fails while page A is dirty, and later page B of the same mip becomes dirty, the subsequent upload copies only B's rows, leaving A's rows stale (on
main, B's upload re-copied the full mip and healed A). - Preserving failed dirty ranges for retry (or marking the affected subresource for a full upload on the next attempt) closes that gap.
- Dirty pages are consumed at line
(Minor test note: the GPU test in crates/victory-gpu/src/draw.rs:3152-3202 uses RGBA8 and counts subresources, which a full-mip upload could also satisfy — adding a BC GPU test verifying partial copy bounds would lock in the 4×4 block-aligned copy path.)
|
Independent Wine/vkd3d-proton 3.2.0 verification, exact head 632d05e: |
|
The conflict with #2626 is resolved on The committed On the RTX the writable versions used RGBA8 and took their initial pixels from title memory once. They kept those pixels after the two later guest writes, as #2626 intends. WARP used native writable formats. The two existing partial-copy and padding tests from #2626 also passed three times on each adapter. For the BC and pitched-copy question in the review, a separate test drove the staging and copy routines directly. Each adapter matched 81,084 packed texels and 1,278 BC1 blocks across 3D mips and array slices, including the last rows of 34×18 and 17×9 BC mips and an untouched middle array slice. These are synthetic Windows readbacks. I’m checking mixed tracking coverage and retry behavior separately. Format suite 47 passed, six ignored. Strict Clippy and asset policy passed. AI-assisted with Codex. |
|
@fuzeofficlal I confirmed both review findings on the RTX 5080 and Windows WARP. Each row below gives wrong pixels out of 49,152, identical on both adapters in three runs each. Page A and page B belong to the same sampled RGBA8 mip.
The test checks the live tracker’s coverage and reads every pixel through the ordinary descriptor table. The retry fixture returns To apply on the current PR head: git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2985-tracked-retry
git cherry-pick 2fa3f3dc74dc9c2c0dda705a9b72dda5ad268a69
cargo test -p victory-gpu --lib mixed_pages_and_deferred_rows -- --nocapture --test-threads=1Final committed tests passed three times per adapter. Strict Clippy, asset policy and the format suite passed (47 tests, six ignored). AI-assisted with Codex. |
|
Note for whoever merges this together with #2639: #2639 adds the tracker's untracked parts ( |
|
Your proposed After confirming the old values, I changed the ordinary page from I put the optional combined branch and simultaneous-write test on my fork. It retains both original PR histories and |
Address both cases reported by fuzeofficlal on Marvisak#2985. Hash the entire affected subresource when some of it is ordinary memory, and requeue consumed tracked pages when staging returns no upload. Exercise initial contents, a write to ordinary memory alone, and retry with and without a later tracked write.
The test freed its three pools while the guards of their tracked pages were still held. A later test's pool, given the same addresses, never saw its writes (a_copy_is_refreshed_once_per_submission_by_the_pages_written read 0 changed bytes when run after it). Like the other draw tests, leave the pools allocated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
|
Thanks @fuzeofficlal and @steven-seagull27. Both findings are confirmed and fixed on this branch.
@steven-seagull27: you may want the same change in your branch if you carry the test there. |
|
Automated triage for the maintainers. Merge candidate. When a tracked write lands on pages a subresource owns alone, Both findings from the earlier review are fixed in
The format test checks that a row-limited detile matches a full one over 7 layouts, including BC and 3D. Independent runs on NVIDIA and WARP in the comments agree. Worth knowing:
CI: passing. Recommending a look, not approving. Generated by Claude Code |
|
@wwwwwwww3333333 Thanks for catching the pool lifetime in my test. I carried your I ran Your four full-suite runs cover the broader ordering. My rerun targeted the two tests you identified. AI-assisted with Codex. |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):
- Diff review: Computing the touched row band per subresource from tracked dirty page ranges, detiling only those rows, and issuing bounded
CopyTextureRegionboxes cleanly avoids full-texture detiles/uploads for partial tracked writes (#1135). cargo test -p victory-formats texture: 17 passed, 0 failed (includingdetiling_the_touched_rows_matches_detiling_all).cargo test -p victory-gpu texture::tests -- --test-threads=1: 2 passed, 0 failed.cargo test -p victory-gpu tracked_rows -- --test-threads=1(RTX 5090 & WARP): 1 passed, 0 failed on both (mixed_pages_and_deferred_rows_reach_the_sampled_texture).cargo clippy -p victory-formats -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
Verified Tests & Microbenchmark
Live Title Verification (RX 9070 XT)
Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
|
Added a GPU test for the block-compressed case you mentioned ( |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Re-reviewed at aca9f15a (including 91284ea9..aca9f15a). The follow-up commits cleanly address the untracked-page, deferred-staging retry (Tracked::retry), and BCn block-row alignment cases:
own(i)excludes subresources overlappinguntrackedpages so mixed tracked/untracked textures stay on the full-subresource hash path.detilefailure requeues taken pages viat.retry(&ranges)and clearslast.hashes[i], preventing dropped page updates.copies()scales element row ranges bystaging.layout.desc.block.max(1)(clamped tof.Height) and falls back toNonewhen the full subresource is touched;Layout::touched_rows/detile_rowspreserve slice/3D depth alignment.
Verified locally on Windows 11 (RTX 5090 + WARP + VICTORY_D3D12_DEBUG=1, git merge-tree against 63bcca43 clean):
cargo clippy --workspace --all-targets [--all-features] -- -D warnings: clean;cargo xtask policy:192 files okvictory-formats:detiling_the_touched_rows_matches_detiling_allpassed; release benchmark on 4096x4096 BC7 mip 0:1.582 mswhole vs57.7 usfor 64 touched rows (rows 512..576, 1024 KiB read, 27.4x faster)- RTX 5090:
texture::+watch::+tracked_rows::+a_write_into_one_page_uploads_its_rows_alone— 20/20 passed - RTX 5090 +
VICTORY_D3D12_DEBUG=1:tracked_rows::+a_write_into_one_page_uploads_its_rows_alone— 3/3 passed (zero debug layer errors on BC1 block-rowCopyTextureRegionboxes) - WARP (
--features diagnostics,VICTORY_D3D12_WARP=1) +VICTORY_D3D12_DEBUG=1: 5/5 passed
LGTM.
|
@wwwwwwww3333333 I measured the row counts left open in your BC1 test update. On
I logged the source box at the production |
Ports the idea of #1135 to current main (63bcca4). Credit to @talakasse, whose patch #1135 carries, to @divyeshganta, who opened #1135, and to @akimfomin, whose comment there points the same way for the GPU copy.
Main already reads and detiles only the subresources a tracked write reaches. It still re-reads and detiles each of those whole: one 64 KiB page written into mip 0 of a 4K BC7 texture costs all 16 MiB of that mip.
What changes
victory-formats:Layout::touched_rowsreturns the rows of a subresource whose tiled bytes overlap the written ranges, and the tiled bytes those rows read.Layout::detile_rowsdetiles only those rows.walktakes an optional row range; its run computation moved intoLayout::runs, unchanged.victory-gpu(texture.rs): for a subresource that owns a written page (the path that already skips hashing), only the band's tiled bytes are read, only its rows are detiled, and only those rows are copied, through aD3D12_BOX. Staging buffers come from a shared pool, so the rows outside the band hold stale bytes and are never copied. Subresources on shared pages, untracked memory and layouts the layout code cannot address keep the whole-subresource path.Uploadnow carries(subresource, Option<rows>).Tests (RX 6750 XT, i5-13400F, Windows 11, Rust 1.98.1 MSVC, on 63bcca4)
detiling_the_touched_rows_matches_detiling_all(victory-formats): 7 layouts (linear, 256B/4KB/64KB S and D, BC, arrays, 3D), random pages written. A change stays inside the rows reported, and detiling those rows from only the reported bytes (the rest garbage) matches a full detile. It asserts that more than 50 cases are partial bands.a_write_into_one_page_uploads_its_rows_alone(victory-gpu, on hardware): a 512x512 texture, one page written then another. The written rows arrive, the other rows keep their earlier contents, and one subresource is copied each time.cargo clippy -p victory-formats -p victory-gpu --all-targets -- -D warnings: clean.Timing (release, ignored test
detile_the_rows_of_one_written_page_of_a_4k_bc7_texture): 4096x4096 BC7, one 64 KiB page in mip 0. Whole mip: 2.73 ms. Touched rows (64 of 1024, 1 MiB of tiled memory read instead of 16 MiB): 0.086 ms. CPU detile only; the smaller read and GPU copy are not timed.Not measured: the effect on a frame in a title.
Unit tests only, no game files.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1