Fix #2638: texture subresource in untracked memory never uploaded #3103
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!3103
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3103"
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?
@tharun-37 on GitHub · 2026-11-26 08:09 UTC · original
tharun-37:fix/texture-untracked-refresh→main· +83 −6 · 3 files · 2 commits · closed without mergingStaging::refresh_now only used t.take() results, which returns changed tracked pages. Pages in t.untracked() (memory outside the runtime) were never returned, so subresources lying wholly in untracked pages were never read or uploaded - their host texture stayed zero forever.
Now untracked ranges are fetched via t.untracked() and merged with tracked changed ranges, so subresources touching untracked pages are always re-read and re-uploaded, matching how buffer copies handle untracked memory (copied whole at each use).
@Marvisak on GitHub · 2026-11-26 08:24 UTC · original
Automated triage for the maintainers.
Proposed close: duplicate of #2639, and it bundles #3063.
The texture fix (
crates/victory-gpu/src/texture.rs,Staging::refresh_now) addresses #2638, which open PR #2639 already fixes. #2639 is a better fit:draw::tests::a_mip_off_the_runtimes_memory_is_uploaded).Here, untracked ranges feed the whole-page shortcut, so a subresource covering an untracked page is re-detiled and re-uploaded at every refresh, and there is no test. The added
t.clean() && untracked.is_empty()check also has no effect: a tracker with untracked parts has no clean bit and is never clean (watch::track_as).The
crates/victory-hle/src/modules/xmem.rschange (commit3ce6a89, not mentioned in the description) is the same commit as your #3063. That PR is already proposed for close as a duplicate of #2504.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel. Anything #2639 misses is best raised as a review comment there.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 08:25 UTC · original · requested changes
Good catch on
#2638—Staging::refresh_nowindeed misses subresources lying solely int.untracked(...). However, there are a few issues in the current patch that should be fixed before merging:1. Unconditional re-detile / re-upload on every submission for untracked >=64 KiB subresources (
crates/victory-gpu/src/texture.rs)Merging
t.untracked(start, start + size)intorangesfeeds static untracked spans into the skip-hash shortcut at line 610:That shortcut assumes every entry in
rangescame fromt.take(...)(pages confirmed written by the write watch). Becauset.untracked(...)returns the same spans on every refresh even when nothing changed, any subresource covering at least one full 64 KiB page of untracked memory will clearlast.hashes[i], skipblake3::hash, and re-detile/re-upload on every submission forever — worse than the fully untracked path (self.tracked.is_none()at lines 653-658), which hashes withblake3and skips unchanged subresources.Please keep
tracked = t.take(start, start + size)anduntracked = t.untracked(start, start + size)separate:tracked.iter().chain(&untracked)for thetouchedcheck (which also removes the need to sort/merge into an extraVec).tracked, so untracked subresources fall through to theblake3comparison and only re-upload when their bytes actually change.2. Avoid allocating
t.untracked(...)beforeif t.clean()(crates/victory-gpu/src/texture.rs)t.untracked(start, start + size)is currently called beforeif t.clean(), which is on the ~123,000 calls/frame fast path. Inwatch.rs(Tracked::new), any tracker with non-emptyuntrackedgetsbit = None, sot.clean()is already guaranteed to returnfalsewheneveruntrackedis non-empty. Leavingif t.clean() { return (0, None); }first preserves the zero-allocation fast path for clean tracked textures.3. Unrelated
crates/victory-hle/src/modules/xmem.rschangesThe changes in
xmem.rsare not mentioned in the PR title/description and appear unrelated to#2638. They also introduce regressions:View::mapwrites through a separate kernel view rather than the guarded title views, so holding per-pageKernelWriteguards open across the lifetime ofPageWindow(which spans DirectStorage decompression) keepsGUARDS.busyentries and extraVirtualProtectchurn alive unnecessarily.PageWindow::drop, callingdrop(kernel_will_write(addr, PAGE))per page and then droppingself._writingacquiresGUARDSfour times per page.write_physical, callingreport_written(&shown)beforeView::map(slice, *n)mutates write-watch state even ifView::mapfails mid-loop and returnsfalse.Please revert
crates/victory-hle/src/modules/xmem.rsfrom this PR (and open a separate PR with a reproducer if there is an independentxmemwrite-watch issue).4. Missing regression test
Please add a unit test covering a texture spanning both tracked and untracked memory (matching
#2638) that verifies:@oni-swr on GitHub · 2026-11-26 08:28 UTC · original
Independent Windows WARP verification of PR #3103 at
17bb212c6484525e98b1025e1b3e284efc9c01a1(claim: #1633). This is a factual test report only; it makes no source-review judgment.Compared: head
17bb212cagainst its exact parent3ce6a893(the head commit changes onlycrates/victory-gpu/src/texture.rs). Parent source was tested by swapping only that file, with the same tests.Environment: Windows 11 26200, Rust 1.98.1,
cargo --locked -j 4 -p victory-gpu --features diagnostics,VICTORY_D3D12_WARP=1,VICTORY_DXIL= Windows SDK 10.0.26100.0dxil.dll(the new tests compile DXBCcs_5_1viaD3DCompile, so that dll was set but not exercised by them). The adapter was checked before any GPU-backed test: the host device's LUID equalsEnumWarpAdapter's, withMicrosoft Basic Render Driver, vendor 0x1414,DXGI_ADAPTER_FLAG_SOFTWARE; every new test re-asserts it. No physical GPU was used. Inputs are synthetic only (byte-pattern fills of anonymous memory); no game files, dumps, shader names or hashes.Method: local-only tests (not part of the PR) build a 512x512 RGBA8, two-mip linear texture over adjacent 64 KiB pages, some write-watched (tracked) and the rest ordinary committed memory (untracked). The title-side bytes are written, a D3D12 compute shader samples 64 texels per mip through the host SRV, and the readback is compared to an oracle computed from the memory bytes. The pages of each mip come from the layout (here mip 1 is pages 0..4, mip 0 is pages 4..20). After the first submit, each case does an unchanged resubmit, then rewrites mip 1 pages, mip 0 pages, and everything.
Results on WARP (D3D12 upload + readback):
3ce6a89317bb212cUpload counts on an unchanged resubmit (no title writes), as reported by the staging counters:
So at head the subresources that touch untracked pages were re-uploaded on every submission here, even with no writes; the tracked and untracked controls re-uploaded nothing. I did not assert on this count, only observed it.
Also run: the existing
victory-gpulib suite on WARP at head,--test-threads=1: 254 passed, 0 failed, 1 ignored (includes the 8 new local tests and the existing texture upload tests such asa_write_into_one_mip_uploads_that_mip_alone). The review's request for a no-re-upload assertion and #2639 were not tested here.CPU-only coverage (no D3D12):
zz_cpu_tracker_classificationchecksTracked::untrackedfor a mixed range returns exactly the untracked run,takenever returns it, and the tracker is never clean. Everything in the table above ran on D3D12 under WARP.AI use: Claude Code (Claude Sonnet 5.5,
claude-sonnet-5-5) ran the verification and wrote this report; per the claim, Codex (gpt-6.2-sol) coordinated it. Test patch is local; I can attach it on request. Build output onD:was kept under the 40 GB floor.17bb212c64to619285aee6@tharun-37 on GitHub · 2026-11-26 08:46 UTC · original
Responding to review:
Untracked kept separate from tracked - racked and untracked are now separate variables. racked goes through the hash-based skip path; untracked only feeds the ouched filter so subresources are re-read but still hash-checked before re-upload.
Fast path preserved - .clean() is checked before .untracked(), so no allocation on the ~123k calls/frame path. A tracker with untracked parts has clean() == false (per watch.rs), so the fast path correctly skips when untracked is empty.
Unrelated xmem.rs changes removed - this PR now only touches crates/victory-gpu/src/texture.rs.
Regression test added - untracked_memory_pages_are_refreshed_like_buffer_copies verifies untracked pages are reported separately, ake() excludes them, and tracker is never clean.
CI is passing and clippy is clean. Please re-review.
@tharun-37 on GitHub · 2026-11-26 09:14 UTC · original
Closed as duplicate of #2639, which fixes the same issue (#2638) with the same approach and is already approved/merge-ready. #3103's fix is now identical in approach (tracked and untracked ranges separate, untracked pages copied whole at each use) but #2639 arrived first.
@fuzeofficlal on GitHub · 2026-11-26 09:39 UTC · original · requested changes
Re-reviewed at
7c72cf49. The production fix incrates/victory-gpu/src/texture.rs:562-625itself looks good (xmem.rsreverted,t.clean()fast path preserved beforet.untracked(...), andtrackedkept separate fromuntrackedso >=64 KiB untracked subresources still go throughblake3::hashdeduplication).However, there are three blocking issues in the test changes:
1. Revert out-of-scope test weakenings in
7c72cf49(descriptor/host.rsandmemory.rs)7c72cf49weakens two unrelated NVIDIA-capped-heap test assertions instead of leaving them to the real heap fix (#3122):crates/victory-gpu/src/descriptor/host.rs:2226: changingNumDescriptors >= HEAP_VIEWStoNumDescriptors >= 4disables heap-sizing coverage on every GPU.crates/victory-gpu/src/memory.rs:1029-1033: changingpairs.0 >= 1 << 18 && pairs.1 >= 1 << 18topairs.0 < caps && pairs.1 < caps(while keeping the"past the dynamic slots"message) completely drops the invariant that page-table view pairs do not consume per-draw dynamic slots.Please revert both
descriptor/host.rsandmemory.rsfrom this PR.2. New test in
texture.rs:897-954does not exerciseStaging::refresh_nowuntracked_memory_pages_are_refreshed_like_buffer_copiesonly callswatch::track,t.untracked(),t.take(), andt.clean(). It never creates aStagingor invokesrefresh_now, so it would still pass even if the entirerefresh_nowfix were reverted. Please testStaging::refresh_nowdirectly across: (a) initial upload of a subresource in untracked memory (Some), (b) repeat refresh with unchanged bytes skipped byblake3(None), and (c) re-upload after modifying bytes (Some).3. Invalid Win32
VirtualFreecall and inaccurate comments (texture.rs:903-953)VirtualFree(committed as *mut _, 0, MEM_RELEASE)on an interior address (base + PAGE).MEM_RELEASErequires the exact base address fromVirtualAlloc(MEM_RESERVE), so line 951 silently fails (ERROR_INVALID_ADDRESS); releasingbaseon line 953 alone frees the full reservation."4 KiB window", whereasWINDOW = 2 * PAGEis 128 KiB (PAGE = 64 KiB).Verified locally (
7c72cf49):cargo clippy --workspace --all-targets [--all-features] -- -D warningsclean,cargo xtask policy(191 files ok),texture::3/3 passed on RTX 5090 and WARP. (Also noting triage previously flagged overlap with#2639for#2638.)Pull request closed