Placed buffer-to-texture copy reads stale data after a same-list GPU write #785
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#785
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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-24 10:40 UTC · original
On
ffe310e, the placed-buffer source ofCopyTextureRegionis filled from CPU memory before the GPU list runs. When a GPU command writes the source buffer earlier in that same list, the texture receives the old bytes even though the source contains the new bytes after submission.I reproduced this through the guest copy call with a synthetic 4×4 RGBA8 texture on RTX 5090 and WARP. Stock and main + #334 both read back 0/16 new pixels after a tracked same-list GPU copy. With the follow-up both read back 16/16. A tracked native UAV dispatch also passed with source offsets 512 and 516, including replay with changed inputs. CPU uploads recorded before a late CPU write, two ordered CPU snapshots, and the partial-write snapshot control all passed. The probes reported zero D3D12 debug-layer errors.
Source follow-up
517a2a5is stacked on #334 ataf2aecf. It uses the host buffer with #334's read transition when the latest tracked GPU write in that list covers the footprint. Other cases use the existing upload snapshot path. The unaligned offset is rebased with a GPU buffer copy.@DrDarkDK on GitHub · 2026-11-24 10:46 UTC · original
I tested a boxed-copy case on
517a2a5with a 4×4 RGBA8 placed footprint, 256-byte row pitch, and source box[0, 0, 0, 2, 1, 1]. An earlier trackedCopyBufferRegionon the same list wrote the first 8 bytes, covering both pixels the box reads.On both RTX 4070 Ti (621.01) and WARP, all 8 source bytes contained
0x6dafter submission, but both destination pixels still contained the old0x11bytes. With the same box and a 1024-byte GPU write covering the full footprint, both destination pixels contained0x6don both adapters.placed_copy_sourcechecks write coverage against the full footprint, so the 8-byte case takes the CPU snapshot path even though the GPU produced every byte the box reads.AI-assisted. Both tests ran locally on my machine using synthetic data.
@fuzeofficlal on GitHub · 2026-11-24 10:56 UTC · original
I reproduced DrDarkDK's two-pixel case on
517a2a5and added two layout controls. RTX 5090 and WARP gave the same results.517a2a5Follow-up
e8e5f49uses the byte span of the source box when choosing the tracked producer. It still checks that the backing buffer fits the full placed footprint and preserves the box-relative offsets if an unaligned source needs rebasing.All 40 destination pixels outside the boxes kept their initial values. The original full-copy, CPU snapshot, and UAV replay probes also passed, with zero D3D12 errors on either adapter.
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 11:17 UTC · original
One more case on
e8e5f49: I used a 4-by-4 RGBA8 footprint with a 256-byte row pitch, a two-pixel box spanning two rows, and two separate tracked GPU copies. Each write covered exactly the eight bytes read from its row. The padding between the rows was left at its original value.The guest
CopyTextureRegionstill read the old CPU bytes at placed offset 512, even though both source rows held the new values after submission. The enclosing span has a gap, so no single producer covers it.The follow-up keeps the enclosing-span check first. When that misses, it checks the actual row ranges and uses the host copy if all selected rows have a covering write to the same shadow. Both offsets 512 and 516 read back all four expected pixels on WARP. The CPU-upload control and the BC1/3D footprint checks passed. The diagnostics suite passed 56 tests, and library Clippy passed with warnings denied.
AI-assisted. Verified with synthetic data on WARP. The D3D12 debug layer was unavailable in this run.
Incremental patch on e8e5f49
@LAKSHYA-cmd-tech on GitHub · 2026-11-24 11:24 UTC · original
Verified and integrated with BufferStates on our integration branch (PR https://github.com/LAKSHYA-cmd-tech/VIctory/pull/16). Resolves stale texture uploads when placed copies read from buffers modified earlier in the same command list, and correctly bounds read spans for boxed copies.
@MichaelSmithAI on GitHub · 2026-11-24 11:23 UTC · original · edited 2026-11-24 11:34 UTC
One more ordering case for the boxed-source change, complementary to the two-row example above. Melissa tested a single row containing two pixels, both backed by the same host buffer. On one guest command list, an earlier GPU clear writes both pixels, a later clear overwrites one, then a boxed copy reads both.
We applied the
e8e5f49box change to a branch with resource-backed typed buffer clears. A single covering clear produced[31, 31]as expected. With the partial overwrite, both destination pixels instead retained their old CPU values. In the backwards scan, the most recent overlapping producer covered only part of the row.Continuing the scan across partial writes to the same host buffer finds the earlier covering producer. With that change the copy returned
[17, 31]and all eight resource tests passed on RTX 4090 under Wine/GE 3.2. The scan still stops at a different backing buffer or an intervening CPU write. The linked commit contains the change and regression on the typed-clear comparison branch. Game use remains unmeasured. Comparison commit and testWe also combined andrewpozdnakov7-jpg’s pitched-row fallback with the partial-overwrite check. In one command list, separate GPU writes supplied two rows and a third write replaced only one pixel of the first row. With row fallback disabled, the destination retained its CPU markers. With both changes, the rows read back as
[17, 31]and[43, 43]on RTX 4090 under Wine/GE 3.2. All eight resource tests passed. Combined patch and two-row test@Marvisak on GitHub · 2026-11-25 03:52 UTC · original
Automated triage for the maintainers. Confirmed on
main: for a placed-footprint source,copy_texture_regionincrates/victory-gpu/src/list.rscopies the source bytes from title memory into a new upload buffer (list.defer_fill) and copies the texture from that buffer. A GPU write to the source earlier in the same list is not in title memory yet when that fill runs, so the texture gets the old bytes.Open PR #1374 (read same-list GPU writes in placed buffer-to-texture copies) addresses this. The boxed, pitched-row and partial-overwrite cases in the comments should be checked against it there.
Generated by Claude Code