fix(gpu): preserve source and destination pixels in texture readbacks #137
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!137
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/137/head"
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?
@jeremygold02 on GitHub · 2026-11-24 00:51 UTC · original
jeremygold02:codex/preserve-partial-readbacks→main· +664 −18 · 3 files · 4 commits · closed without mergingDepends on #67. Please merge #67 first. This branch adds two commits on top of #67 at
b5c38fa. The first preserves pixels outside the destination region. The second preserves the GPU-written source during readback. GitHub’s full diff also includes the two commits from #67.A texture-to-buffer copy may write only part of its destination. The GPU writes the requested rectangle into staging. The host then copies the entire destination footprint back into title memory, replacing pixels outside the rectangle. This follow-up copies only the affected row spans in each depth slice, using the source box or the selected subresource’s extent and the destination coordinates.
On a physical RTX 5070 (driver 621.01), I prefilled a 4×4 RGBA8 destination and copied a 2×2 source box into its top-left corner. At the dependency head all 4 requested pixels matched and 0 of the 12 neighboring pixels retained their values. With this change all 4 requested pixels matched and all 12 neighbors retained their values. A whole 4×4 source copied to (1,1) in a packed 6×6 destination also matched all 36 expected pixels. Both cases are included in the synthetic test.
All 37
victory-gpulibrary tests passed on Windows at the follow-up head. Diagnostics Clippy with warnings denied andgit diff --checkpassed. The original hardware verification on #67 records the comparison.Integration with main at
d2a4bae. The locally tested Git tree is identical to the clean merge of this branch withd2a4bae, including the merged test-module fix from #129. The GPU library suites passed with 44 default and 46 diagnostics tests, including the readback regression in both. Each configuration ignored one benchmark. Both library configurations also passedcargo checkon the earlier GitHub merge preview. AI-assisted.RTX 5070 mission-loading verification. Two interactive runs using the combined tree above reached a guest texture-to-buffer readback. In each run, a local probe queried the D3D12 queue fence and observed the requested submission value complete before copying two row spans (96 bytes total) into guest memory. The first run stopped at that checkpoint. The second continued for 20 more CPU present calls before manual closure. The synthetic sentinel test above remains the evidence that neighboring pixels are preserved. The live runs exercised #67 and this follow-up together. Later rendering and frame time remain unresolved.
GPU-written source regression at
31979ad2. On a physical RTX 5070 (driver 621.01), clearing a linear-layout 4×4 RGBA8 render target to magenta and immediately copying it through the guest texture-to-buffer path returned00 00 00 00at pixel (0,0) on219e3ce. The readback path uploaded stale title memory over the GPU clear. Applying the existingtexture::title_writtencheck before the upload preserves all 16 magenta pixels. A separate CPU-populated linear texture returned all 16 expected pixels. The regression uses synthetic inputs. All 37 default GPU library tests, diagnostics Clippy with warnings denied, andgit diff --checkpassed on Windows. The earlier mission trace lacks source layout and last-writer information for its two readback spans, so it cannot establish whether the mission exercised this case.@ghost on GitHub · 2026-11-24 01:12 UTC · original
AMD run: head
219e3ce.cargo test --workspaceonmain9aef3d9+ #129 (main'svictory-gputests don't compile without it) + this PR, AMD Radeon RX 9060 XT (RDNA4), Windows 11 Pro 26200, Rust 1.98.1, debug:copy_texture_region_reads_back_into_title_bufferand the rest ofvictory-gpupass.One run of the suite died with
0xC0000005invictory_shader's tests. That's not from this PR (it doesn't touch that crate): it's the intermittent parallel-GPU-test crash onmain, now #181.AI use
@miniongk on GitHub · 2026-11-24 05:11 UTC · original
Tested
219e3ce(including #67) combined with #413, #320, #483 and #89 on an RTX 5080, driver 621.24, Windows 11 26300, local Xbox Series 1.0.2.1.resource::tests::copy_texture_region_reads_back_into_title_bufferpassed on hardware in 0.23 s.cargo test --workspaceon the integrated tree: 291 passed, 0 failed, 4 ignored.texture to buffer copies not implementedwarning is gone.Only aggregate counts and error classes shared; no game data or raw game logs. AI-assisted (Kimi Code).
@alessiodeia on GitHub · 2026-11-25 00:41 UTC · original
@jeremygold02, the maintainer's triage on #67 asked to fold this fix into #67, so I've merged your two commits (
219e3ce,31979ad) into its branch with your authorship intact (#67 head1e59257). I also added the requested sentinel case (a 2×2 box atx = 1in a 4×4 footprint) next to your two partial cases, and merged currentmain. The only conflict was main's newwatch::writingguard inhost.rs. I kept your per-box logic and held the guard across the write. Thanks for the fix. If #67 lands, this draft should have nothing left to add, but I'll leave closing it to you.@jeremygold02 on GitHub · 2026-11-25 02:52 UTC · original · edited 2026-11-25 02:54 UTC
@alessiodeia Thanks for folding both fixes into #67 and adding the offset sentinel case. I verified that both of my commits,
219e3ceand31979ad, are in #67 at1e59257. I've closed this draft so review can continue in #67.Pull request closed