Repository navigation
GPU: sync aliased texture sources before copy commands - #3170
fuzeofficlal wants to merge 1 commit into
Conversation
draw.rs already calls resource::alias_source and texture::alias_copy before sampling a texture whose console memory is GPU-written through an incompatible alias (such as a block-compressed view aliasing an uncompressed render target or UAV, or a texture keeping a replaced host copy). list::copy_resource, texture-to-texture list::copy_texture_region, and list::read_back only checked texture::title_written / texture::upload and never synced from resource::alias_source, causing copies and read-backs of aliased textures to observe stale or zeroed title memory instead of GPU-written texels. Route all three copy source paths through a shared sync_copy_source helper that calls resource::alias_source / texture::alias_copy before texture::upload, matching draw.rs.
Dukestar69
left a comment
There was a problem hiding this comment.
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).
|
@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:
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 git fetch https://github.com/steven-seagull27/VIctory.git codex/pr3170-repeated-alias-copy
git cherry-pick 1ca407f
cargo test -p victory-gpu --features diagnostics --lib copy_commands_sync_aliased_texture_sources -- --nocaptureSet |
Summary
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.