GPU: skip unchanged texture uploads via prelude copy recording #230
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!230
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-230"
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?
@wbkepler on GitHub · 2026-11-24 01:38 UTC · original
wbkepler:gpu/skip-clean-texture-uploads→main· +702 −153 · 4 files · 2 commits · openSummary
CopyTextureRegionrecording from command-list record time ontoHostList::preludeat submission time so unchanged textures are not DMA-copied every frame.texture::uploadnow registers(Arc<Staging>, Arc<HostTexture>)with theHostListwithout transitioning toCOPY_DESTor bakingCopyTextureRegioninto the main list (preservinghost_writtenskipping, per-listfirst_usededup, and resource lifetimes).Staging::refreshreturnsdirty: boolacross bothMEM_WRITE_WATCHandblake3hash paths.HostList::preludetransitions toCOPY_DEST, recordsCopyTextureRegion, and transitions into the main list's expected first state only whenrefreshreports dirty contents (including first upload), skipping all GPU copies and redundant barriers on clean frames.texture.rscovering initial pixel readback, zero copies on clean/reused/multi-list submissions (both hash andMEM_WRITE_WATCHpaths), single re-upload on CPU modification, andhost_writtenprotection.Verification
cargo clippy --workspace --all-targets— passed (zero new warnings)cargo clippy -p victory --features diagnostics --all-targets— passedcargo test --workspace— passed (46 passed, 1 ignored invictory-gpu)cargo xtask policy— passed (151 files ok)@jeremygold02 on GitHub · 2026-11-24 05:32 UTC · original
Thanks @wbkepler for adding upload-count checks for unchanged, CPU-written, and host-written textures.
I tested commit
6a96adbfb8fcb001686dc251a24cda3dd34ee51cwith:The texture-filter run completed with 6 passed, 0 failed, 1 ignored benchmark, and 40 filtered tests. The three new cases verify:
warp_skips_clean_texture_uploads_and_reuploads_on_changerecords one initial copy, no copies for unchanged memory across multiple lists or resubmission, exactly one new copy after CPU data changes, and no extra copy on the next clean submission; readback pixels and resource state are also checked.warp_write_watched_texture_uploads_only_when_writtenchecks initial upload, clean-page skipping, a fresh upload after a write to watched memory, and skipping again when clean.host_written_texture_never_queues_cpu_uploadverifies a host-written resource does not enqueue CPU-to-GPU work.The WARP tests return early when the software adapter is unavailable, and the harness reports that return as passed; this run does not distinguish that case from executing the assertions. The tests cover the D3D12 WARP path, not a hardware adapter or a title’s texture workload.
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 10:05 UTC · original
I checked a related ordering case on
6a96adbfor #758. Recording and closing aCopyResourcelist marks the destination host-written immediately. If that list is discarded, an independent list still skips the CPU texture upload. A Windows D3D12 WARP regression confirmed that the upload is queued before recording the copy and suppressed afterward, even though the copy list is never submitted.The patch keeps the write marker on the command list and applies it while preparing submitted lists in order. The unsubmitted-copy regression passes with it. A second test submits a real GPU copy followed by a reader in one batch, checks that it emitted zero staging copies, and reads back the GPU-copied pixels. With the submission-time guard disabled, that second test fails.
The diagnostic suite can still hit the existing write-watch flake documented in #185. That test failed in 2 of 5 full runs before this patch and 1 of 5 with it, and passed in isolation on both. Library Clippy with warnings denied passed. This patch covers discarded lists. The later CPU-write case in #758 is still separate.
AI-assisted. Synthetic WARP tests only.
Tested follow-up diff for
6a96adb@aycow on GitHub · 2026-11-24 18:54 UTC · original
The bindless refresh composition now retains pending #413 requests through discard/reorder/reset and delegates the native upload decision to your ordered prelude. All 42 ordinary/placed cases passed AMD/NVIDIA/WARP full GBV, including preservation of a #230-marked GPU producer. Production hunk eba699d is isolated for your and the #413 author's review. The validation extends only to GPU producers this composition marks through the existing copy/resolve path.
@wbkepler on GitHub · 2026-11-24 20:42 UTC · original
Rebased onto current main (
ffe310e) as067ece6; one trivial comment-only conflict in a host.rs test, and every texture-writing copy/resolve path (CopyResource, CopyTextureRegion, Resolve) still marks the texture host-written at submission time. Gate clean.AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.
@Marvisak on GitHub · 2026-11-25 00:22 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/host.rs,crates/victory-gpu/src/resource.rs,crates/victory-gpu/src/texture.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 01:03 UTC · original
Independent WARP confirmation for the submission-order fix, related to #1891. I recorded a CopyResource that snapshots a 4×4 RGBA8 texture and a second list that overwrites it. I tried both recording orders and both submission orders through VIctory, then read all 16 texels of the snapshot.
Upstream
42363ab6cdand your prelude-only parentfbec4e2c6aboth gave 16/16 when the two orders agreed and 0/16 in each reversed case. One reversed case read the old CPU color after the submitted copy. The other read zero when the snapshot was submitted first. Your067ece6b11gave 16/16 in all four cases.The regression is one test commit directly on
067ece6. Strict GPU Clippy and asset policy passed. The full WARP run had 57 passed, 1 failed, 1 ignored. The existing write-watch test failed with the new test both enabled and filtered out, and passed on its own. The merge with current main still conflicts in host.rs, resource.rs and texture.rs.@Calvix2k on GitHub · 2026-11-25 02:22 UTC · original
Independent confirmation of the fix on a third vendor, on your exact head
067ece6(no rebase), Windows 10 19045, RX 7800 XT (RDNA3), driver 32.0.32029.2010.list::tests::texture_copy_reads_follow_submission_orderfrom @andrewpozdnakov7-jpg's52cc201, applied verbatim to this branch,cargo test -p victory-gpu --features diagnostics --lib:940d32f: FAILED — the two opposite record/submit orders read 0/16 pixels, matching orders 16/16.067ece6: 1 passed, all four orders read 16/16; the class's other 58 tests filter out normally.So the upload-decision-at-recording-order dependency reproduces on WARP, Blackwell, Ada and RDNA3 here, and prelude recording plus the deferred
host_writtenmark fixes it on all four.One thing if you rebase: on
mainthe conflicts are real, not just context —host.rsgrew the prelude/barrier paths andtexture.rs's upload path changed sinceffe310e, sogit cherry-pickleaves 14 hunks in those two files. Happy to help work through them here, or to test a rebased branch on this GPU; the regression test above is the check I would use.@andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:13 UTC · original
I prepared a rebased branch on current main for #230 and #1891. The base is
940d32f69b22265690a0b5a15d6ded572ba33baf. The two rebased code commits are0794859andb5dffe8, with the original Git author preserved. The submission-order regression is a separate commit. The prior version on067ece6remains available.The same native WARP test reads all 16 texels from the snapshot. Current main gets 16/16 when recording and submission order match, and 0/16 in both reversed cases. The rebased branch reads 16/16 in all four orders. Full GPU suite with diagnostics went from 146 passed / 1 failed / 2 ignored to 151 passed / 0 failed / 2 ignored, including the four prelude tests. Strict GPU Clippy in both configurations, strict workspace Clippy with all features, and the asset policy passed.
The rebase keeps current main's shared host texture, staging bounds, write tracking, and depth-twin prelude. It defers host-write marks for copy, resolve, and alias-copy destinations.
If you include the test, please preserve its Git author. If you fold it into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@Slay326 on GitHub · 2026-11-25 14:13 UTC · original
A data point from an RTX 3070 (8 GB) in case it helps this PR along. On our local test branch (main
940d32fplus #1962 and the memory PRs #2129, #2180, #1873, #1969, #2161) we use an equivalent of this change: a list copies a texture's staging buffer only after its memory changed (about 3,000 texture copies per frame before, 22 ms of GPU time).On top of that we let a staging buffer go once a submitted list has copied it and its memory has not been detiled for 3 s; the next detiling makes it again. That only works when lists stop copying unchanged buffers, which is what this PR does. In a 480 s world run of Grand Theft Auto VI, staging memory stays at 14-36 MB instead of 3.3 GB and growing. The patch builds on this PR's behaviour and has a synthetic test; I can open it as a follow-up once this lands, or share the branch if that is easier.
AI-assisted.
@assttro on GitHub · 2026-11-26 13:02 UTC · original
A third ordering case that #230 and #1934 don't cover: two CPU versions of one texture in one submission
While testing #230 (as rebased in
andrewpozdnakov7-jpg/VIctory@rebase/230-texture-upload-order, head 3f363a6), I hit a case that the record-order fixes don't reach.The case. One
ExecuteCommandLists([A, W, B]):A should see the old bytes and B the new ones. Every prelude is prepared before the GPU runs anything, and #230 (and #1934, as far as I can read it) keeps one persistently mapped
Stagingbuffer per texture. So B's refresh detiles the new bytes into the same buffer that A's prelude copy still references, and A reads the new data.Result on 3f363a6 alone: 16 of 16 pixels wrong for A's read (RTX 3070, driver 610.88).
Fix (small, on top of #230): the
BatchinHost::executetracks which staging buffers a GPU copy in this submission already references (uploaded_textures).Batchholds those buffers (upload_buffers) until after the fence wait.texture::upload_changed(the bindless path) goes through the sameBatch::refresh_texture, so the ordinary and heap-indexed paths share the tracking.host::fail, so the version identity never advances silently.Tests (release + diagnostics, RTX 3070, all with zero-mismatch readback):
texture_upload_keeps_each_lists_cpu_generation: the [A, W, B] case. Pass. It failed with 16 of 16 pixels wrong before the fix.bindless_upload_keeps_each_generation_in_one_batch: the same case throughupload_changed. Pass.Batchper call, i.e. the old behaviour) loses all 16 of 16 early pixels.docs/direct-texture-upload-ownership.md:bindless_upload_preserves_an_earlier_submitted_gpu_producer: Pass.bindless_rebind_retires_the_upload_for_the_old_native_texture: Pass.bindless_alias_delivers_one_upload_per_submission: two placed aliases of one memory, three views, one copy per submission. Pass.texture_copy_reads_follow_submission_order,discarded_copy_list_still_uploads_cpu_texture,warp_*).VICTORY_D3D12_DEBUG=1, none of these tests logs a validation error. There's a positive-control test that proves the check is live.I can share the patch (against 3f363a6) or open it as a PR to the rebase branch, whichever is easier for whoever lands #230. Happy to rebase it onto current
mainonce #230 or #1934 is settled.AI-assisted (Claude); results above are from my own runs.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:10 UTC · original
@assttro Yes, please share the batch fix as a branch or commit on
3f363a6. Could you include both regressions,texture_upload_keeps_each_lists_cpu_generationandbindless_upload_keeps_each_generation_in_one_batch?I'll run the same tests before and after the patch on app-local WARP, including both readbacks in
ExecuteCommandLists([A, W, B]), and keep your Git authorship when applying it.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.