GPU: a remap under an uploaded texture uploads it again (#574) #606
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!606
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-606"
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?
@laptopnotebook on GitHub · 2026-11-25 03:06 UTC · original
laptopnotebook:fix/574-remapped-staged-texture→main· +353 −2 · 3 files · 3 commits · openFixes #574.
A title texture that was uploaded and found unchanged since is only checked when a list samples it (
texture::upload): the copy into its host texture is not recorded, and a change the check finds is uploaded by the next list. A remap of the texture's memory did not reset that state, so the first list that sampled the texture after the remap read its old texels. Since placed textures are keyed without their filler words (c96b4f2), a view with new filler after a remap reuses the old texture, which made this common.Now
watch::title_memory_remappedcalls a newtexture::remapped, which marks every staged texture overlapping the range dirty. Its next upload records the copy, and the check at that list's submission reads the new memory into the staging buffer first, so the first list after the remap gets the new texels. Staged textures are indexed by address (weak entries, pruned when let go) and the search is bounded by the largest staged texture, so a remap looks only at textures that can overlap it instead of scanning all of them. Textures still share one host copy while their memory stays mapped, as #574 asks.Validation:
texture::remap_tests::a_remap_under_a_staged_texture_makes_it_upload_againstages a texture on the GPU and remaps memory next to it (left alone), an empty range (left alone) and memory under it (marked). It fails with the fix disabled.cargo test --workspace --locked: all pass (Windows 11, NVIDIA).cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean. The run without--all-featuresfails only onplaced_filler_twinsbeing unused, whichmainfails too; #530 addresses that.@yualk on GitHub · 2026-11-25 04:15 UTC · original
Independent verification of
a45374449912db2dabbe0dc999501dfa522ed47eagainst the original #574 fixture, no title assets or title process. Locked MSVCdiag, Windows, four fresh processes on RTX 5070 Ti (10de:2c05) and D3D12 WARP (1414:008c), each with default normalization andVICTORY_PLACED_FILLER=1.draw::readable, returns all 64 expecteda5bytes on both adapters; the next list also returnsa5. The original default base returned5aon the first list.1/2/2, same as independent cold creation. Replaying the held pre-remap upload list does not restore the old5adata; this is not a claim about a previously recorded refresh-only list.This verifies completed texture bytes, not only the dirty flag. It does not cover indexed-slot reads, title visuals, or FPS. AI-assisted testing and write-up.
@SantannaCarlos on GitHub · 2026-11-25 04:38 UTC · original
Tested
a453744with two remap tests, on an RTX 4070 and on WARP: both pass, including with the host copy held across the remap.The tests follow yualk's reproducer from #574 step by step, through the host device:
0x5a. A placed SRV throughdescriptor::host::placed_texture(linear 4x4 RGBA8, one mip), first with filler 17, then 31. Each variant getstexture::upload, a copy-source transition and a fenced readback.title_memory_remapped, commit,title_memory_remappedagain, all undertitle_memory_remapping, then fill with0xa5.The second test is the same, except that a
host_copyof the texture is held across the remap, the way a descriptor slot that still shows it or a list not yet reset would hold it.First list after the remap (
5a= old bytes):c96b4f25a)5a)c96b4f2+ #4325a)VICTORY_PLACED_FILLER=1(WARP)The RTX 4070 runs use a diagnostics build. On the card, the PR's own
remap_tests::a_remap_under_a_staged_texture_makes_it_upload_againpasses as well. #606 and #432 apply together cleanly; each adds one line totitle_memory_remapped.So #606 also covers the case #432 leaves open: a host copy that stays alive across the remap.
One case these tests don't reach, from reading
refresh_timed: the guarded path is fine, since the remap takes the blocks out ofprotectedandclean, so the nextguardreports them written. But a texture that is still only partly mapped after the remap takes the partial-read branch. That branch returns early for 30 frames after the last partial read (last.partial), so even withdirtyset the upload copies the staging buffer as it was, and the pages the remap brought in show up as late as the shortcut allows. Clearinglast.partialalong with thedirtymark would let a remap end that pause. This is the streaming case the shortcut already accepts, not the stale first list from #574. I have not measured it.The two tests can go in as a commit on top of this if that is useful.
@laptopnotebook on GitHub · 2026-11-25 04:41 UTC · original
Thanks, this is really thorough. The held-copy case is a good one to have covered, and good to know it stacks cleanly with #432.
Yes please on the tests. Since you can't push to my branch, the easiest is probably a PR against
laptopnotebook/victory-fork:fix/574-remapped-staged-texture(or just paste them here and I'll add them with you as the author).On
last.partial: agreed it's a real gap, but I'd rather keep this PR to the stale first list and do that separately. One thing to watch when someone does it:remapped()runs while the runtime holds the mapping write guard, andrefresh_timedtakeslastand then waits ontitle_memory_reading, so lockinglastfromremapped()can deadlock. It'll need an atomic onStaging(something like a "remapped" flag thatrefresh_timedswaps and uses to clearpartial) rather than touchinglastdirectly. I'll look at it after this one, with a measurement of how often a remap actually lands on a partly mapped texture.@laptopnotebook on GitHub · 2026-11-25 04:42 UTC · original
@yualk thanks for running your original fixture against it, and on WARP too. Good to see the first list after the remap come back with the new bytes, and that the unrelated recommit stays at zero uploads. That was the part I couldn't check from a unit test.
@SantannaCarlos on GitHub · 2026-11-25 05:26 UTC · original
The two tests are laptopnotebook/victory-fork#1, against your branch.
@laptopnotebook on GitHub · 2026-11-25 05:27 UTC · original
Merged @SantannaCarlos's two tests into this branch (
638afd2). I ran them here too: both pass with the fix and both fail at the first list after the mapping with it reverted, so they pin down #574, including the case where the host copy is held across the remap.@laptopnotebook on GitHub · 2026-11-25 18:44 UTC · original
Pushed one follow-up (
7476e80) for a case the first fix missed.A partly mapped texture (some pages there, as while it streams in) is read at most every 30 frames. A remap inside that window marked the texture dirty, so the list recorded the copy, but the read at submission still waited its turn and the copy took the old texels.
The texture now remembers that it was remapped, and the next partial read skips the wait once. Otherwise the 30-frame limit works as before.
The new test (
a_remap_under_a_partly_mapped_texture_is_read_at_once) fails without the change (the staging buffer still holds the old byte) and passes with it.cargo test --workspacepasses (509). I found this by reading the code and haven't seen a visible difference from it in game.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.