GPU: sync aliased texture sources before copy commands #3170
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!3170
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3170"
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?
@fuzeofficlal on GitHub · 2026-11-26 10:52 UTC · original
fuzeofficlal:fix/copy-aliased-texture-source→main· +361 −9 · 1 files · 1 commits · openSummary
Sync GPU-written aliased texture sources via
resource::alias_sourceandtexture::alias_copybeforeCopyResource, texture-to-textureCopyTextureRegion, and texture-to-bufferread_backincrates/victory-gpu/src/list.rs.Root Cause
When a title places two format-incompatible textures over the same console memory (for example, an
R32G32B32A32_FLOAT/R32G32_UINTrender target or UAV aliased by a block-compressedBC*texture, or a texture retaining a pre-replacement host copy), they receive separateHostTextureinstances.draw.rsalready bridges them withresource::alias_sourceandtexture::alias_copybefore sampling an SRV, but the three texture-reading copy paths inlist.rs(copy_resource, texture-to-texturecopy_texture_region, andread_back) only checkedtexture::title_written/texture::upload. Copies and read-backs from the aliased texture therefore observed stale or zeroed title memory instead of GPU-written texels.Changes
crates/victory-gpu/src/list.rs: add a smallsync_copy_sourcehelper callingresource::alias_source/texture::alias_copybeforetexture::upload(matchingdraw.rs), and call it fromcopy_resource,copy_texture_region(texture-to-texture), andread_back.list::tests::copy_commands_sync_aliased_texture_sources) covering all three copy paths on independentR32G32B32A32_FLOAT/BC3_UNORMaliased pairs plus cross-submission updates.Verification
main(63bcca43) with all-zero output bytes whilealias_source(alias) == Some(writer), and passes after the fix on native D3D12 (with and withoutVICTORY_D3D12_DEBUG=1 --features diagnostics) and WARP (VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 --features diagnostics).cargo test -p victory-gpu --lib --features diagnostics --lockedon WARP: 247 passed, 0 failed, 1 ignored.cargo clippy --workspace --all-targets --locked -- -D warningsand--all-features: clean.cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.@Dukestar69 on GitHub · 2026-11-26 11:07 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-gpu --lib list:: -- --test-threads=1: passed on RTX 5090 and WARP.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed;resource::: 18/18 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly syncs aliased texture sources before copy commands.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@steven-seagull27 on GitHub · 2026-11-26 11:16 UTC · original
@fuzeofficlal I found a same-list case where this PR and #2341 cover different parts of the operation. I extended your fixture to clear the RTV, copy from its BC3 alias, clear the same RTV to a second colour, then copy the same alias again. Both snapshots go to distinct offsets of the readback buffer before the command list is closed and submitted once.
The RTX 5080 and Windows inbox WARP gave the same counts in two fresh runs per build and adapter. Each column totals 64 checked 32-bit words for each of the three routes:
CopyResource, texture-to-textureCopyTextureRegion, and direct texture-to-buffer readback.63bcca43075b2ac)97683bb)On #3170 alone, all 192 words of the second snapshot still matched the first colour. This PR adds the missing copy-time sync. #2341's source-write tracking makes that sync run again after the second clear. The current heads merge cleanly and the combined run also passes your existing cross-submission checks.
The test-only commit applies to
97683bb. Commit · Downloadable patchSet
VICTORY_D3D12_WARP=1for the WARP run. AI-assisted synthetic readbacks.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.