GPU: prepare and upload only dirty texture bands (opt-in) #2356
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2358"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by nicolasveilleux on 2026-11-25T11:44:22Z.
What changes
When a tracked, single-mip 2D texture is reached through the descriptor heap, a sparse update can now read and detile only the affected tile rows and copy just that band to the GPU. The first upload, dense changes and unsupported layouts keep the existing full path. This is opt-in (
VICTORY_TEXTURE_UPLOAD_BANDS=1) and off by default.The scope is within a subresource. #1135 skips unaffected mips and slices on the CPU but still uploads the full texture. This PR does not change the eager upload timing addressed by #230 and #1891.
Validation
On Windows 11, RTX 2070 Super (driver 610.60), 24 paired runs of a synthetic 4096 × 4096 RGBA8 texture:
Timing includes the CPU write, preparation, and submission through queue completion. The partial path won 24/24 pairs. Dense updates kept the full 64 MiB copy in both modes (45.31 vs. 43.53 ms median). Full GPU readback matched expected bytes in both modes for both patterns. No game files or gameplay measurements.
main(940d32f) and on this branch with bands off and on. The test was not included in this PR.AI-assisted (OpenAI Codex).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:52:04Z.
Review: COMMENTED
Prepare and upload only dirty texture bands (opt-in VICTORY_TEXTURE_UPLOAD_BANDS): detile_rows partial detiling in victory-formats + GPU wiring (+523). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. The formats-side detile_rows is the portable part — being batch-tested on macOS now, will follow up.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:56:19Z.
Review: COMMENTED
Follow-up to my earlier static note: the victory-formats side (
detile_rowspartial detiling) tested locally — merged into main940d32f69b,cargo test -p victory-formats --lockedon macOS arm64: 38 passed, 0 failed, 5 ignored. The portable detiling math is green; the GPU upload wiring remains Windows-only (static).Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T11:51:27Z.
I adapted the GPU band-copy fixture on
8da78cfto a 260×516 BC3 texture with a padded row pitch. A dirty page at the bottom selected texel rows512..516, exactly one BC3 block row.On native Windows with an RTX 4070 Ti (621.01) and WARP, the full readback matched on both adapters: the last block row held the new pattern, and all 128 preceding block rows kept their original bytes.
This exercises
dirty_bandand the GPU copy with prefilled staging data. Synthetic only.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:34:01Z.
Automated triage for the maintainers.
Recommendation: merge candidate (rebased; reviewed again against current
main).With
VICTORY_TEXTURE_UPLOAD_BANDS=1, a later sparse change to a tracked single-mip, single-slice 2D texture is uploaded differently. Only the tile rows covering the dirty byte envelope are read and detiled (texture.rs:dirty_band,Staging::detile_band), and one boxedCopyTextureRegioncopies them (record_band). The first upload, dense changes (more than half the height), mip tails and other layouts keep the existing full path. Default behaviour is unchanged.I checked these points:
Layout::detile_rowsreuseswalkwith a row range and keeps the existing callers onNone. Its new test compares a band with a full detile for linear, 4 KB and 64 KB swizzles.last.hashesis cleared, so the next full refresh redetiles everything.CI
checkpasses on this head. A synthetic BC3 check was independently confirmed in the thread.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by CocoBeans64 on 2026-11-25T19:29:56Z.
Native Windows run as asked, on Windows 10 22H2 (19045), RX 6800 XT (driver 32.0.21045.5002), Ryzen 7 7800X3D. The PR is merged with #2358 on
13f91ca, plus an Agility SDK runtime (#84), diag build.cargo test -p victory-gpu: 201 passed, 1 failed. The failure,a_texture_written_in_one_format_reads_in_another_through_a_placed_view, fails the same way on13f91cawithout the PR (#1999).Benchmark: the same saved game in the prologue, menus by hand, then a scripted camera loop. The figures cover the 300 s after the world shows. Two runs per side:
13f91caTwo identical baseline runs differ by about 6 % in mean frame time.
With
VICTORY_TEXTURE_UPLOAD_BANDS=1, texture preparation in the world drops from 43 to 37 ms per frame (−15 %). The worst frame of a manual run fell from 1.3 s to 0.5 s. Overall fps does not change measurably, because textures are about 5 % of the frame here.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:00:30Z.
Review: APPROVED
Reviewed
3159aa41703dmerged cleanly onto63bcca43.The opt-in dirty row-band upload path (
VICTORY_TEXTURE_UPLOAD_BANDS=1, off by default) is carefully bounded and mathematically sound:victory-formats(crates/victory-formats/src/texture.rs:622-638,656-735):Layout::detile_rowsrestricts to single-mip, single-slice 2D textures, validates!rows.is_empty() && rows.end <= m.height, computes exact compactslice_bytesforrows.len(), and shiftslinear_rowbyy - rows.startwhile indexingtiledfrom its original origin.crates/victory-gpu/src/texture.rs:512-550,796-821): Restrictingdirty_bandto addressable, single-mip, single-slice, single-sample, non-tail, block-aligned 2D textures guarantees viaLayout::row/columnthat every texel in element rowsfirst * group_rows .. end * group_rowslies strictly insidem.offset + first * stride .. m.offset + end * stride.detile_bandsuballocates fromstaging_space(512-byte aligned offsets) with block-alignedFootprint.Heightand destinationtop.texture.rs:683-697,749): Requiringlast.full_prepared && self.uploads != 0ensures a band copy never runs before a complete initial upload (or after a failed fulldetileor eviction/recreation ofHostTexture), and clearinglast.hashes.fill(None)after a band upload guarantees a subsequent full fallback re-uploads rather than hitting a stale hash.Hardware & D3D12 Debug Layer verification (RTX 5090 + Microsoft WARP,
VICTORY_D3D12_DEBUG=1):cargo xtask policyandcargo clippy --locked -p victory-formats -p victory-gpu --all-targets -- -D warnings(default and--all-features) pass cleanly.cargo test --locked -p victory-formatspasses 47/47 (includingcompact_detile_rows_match_the_same_rows_from_a_full_detile), andcargo test --locked -p victory-gpu texture::tests:: -- --test-threads=1passes on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1.VICTORY_D3D12_DEBUG=1comparing bands OFF vs ON byte-for-byte acrossSwizzle::LINEAR256x512RGBA8,Swizzle::SW_4KB_S256x512RGBA8, andSwizzle::SW_64KB_D516x1028BC1 (8-byte 4x4 blocks) through top-row band -> bottom-row band -> far-span (>50%) full fallback, plusdirty_band == Nonechecks for non-block-multiple258x514BC3, multi-mip, 2-slice array, empty range, and full-span range: exact row-by-row byte match andhost.log_messages() == Noneon both RTX 5090 and WARP.#2314and#2319on63bcca43.LGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.