Preserve untouched bytes during partial texture read-back #794

Open
github-bot wants to merge 1 commit from github-bot/gh-794 into main AGit
Owner

@⁠Lilith133T on GitHub · 2026-11-25 08:04 UTC · original
Lilith133T:fix/partial-texture-readback → main · +195 −33 · 3 files · 1 commits · draft

A texture-to-buffer copy can use a source box smaller than the destination footprint. The old write-back copied the whole footprint from staging, including bytes the GPU never wrote. In a synthetic 2×2 copy into a 4×4 footprint, the byte immediately after the first copied row changed from 0xa5 to zero.

Size the staging footprint to the source box and write only its rows. Keep the destination's original row and slice pitches when writing into guest memory. The same layout validates the destination span before recording the copy.

Verification

  • The synthetic D3D12 round-trip regression failed on 9376fd6 at byte 8 and passes with this change.
  • Verified on WARP and NVIDIA RTX with the D3D12 debug layer enabled. The test checks every byte of the destination, including both row padding and untouched rows.
  • Ran cargo test --locked --profile diag -p victory-gpu --features diagnostics --lib list::tests and Clippy for the library. Strict Clippy required allowing one existing unnecessary_sort_by diagnostic in draw.rs.
**@⁠Lilith133T** on GitHub · 2026-11-25 08:04 UTC · [original](https://github.com/fxceless/victory-fork/pull/794) `Lilith133T:fix/partial-texture-readback` → `main` · +195 −33 · 3 files · 1 commits · draft A texture-to-buffer copy can use a source box smaller than the destination footprint. The old write-back copied the whole footprint from staging, including bytes the GPU never wrote. In a synthetic 2×2 copy into a 4×4 footprint, the byte immediately after the first copied row changed from `0xa5` to zero. Size the staging footprint to the source box and write only its rows. Keep the destination's original row and slice pitches when writing into guest memory. The same layout validates the destination span before recording the copy. ## Verification - The synthetic D3D12 round-trip regression failed on `9376fd6` at byte 8 and passes with this change. - Verified on WARP and NVIDIA RTX with the D3D12 debug layer enabled. The test checks every byte of the destination, including both row padding and untouched rows. - Ran `cargo test --locked --profile diag -p victory-gpu --features diagnostics --lib list::tests` and Clippy for the library. Strict Clippy required allowing one existing `unnecessary_sort_by` diagnostic in `draw.rs`.
Only copy the rows and depth slices that CopyTextureRegion writes.
Keep the title's row and slice pitches when landing the staging buffer.
A synthetic D3D12 round trip tests pixels and destination padding.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:18 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 10:20 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head f61fe97 into main 9376fd6 in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins never used, depth_written never read, in victory-gpu); with --all-features it fails with the same number of errors as main (4). This PR adds none and removes none. cargo test --workspace --locked: 541 passed, 0 failed, 10 ignored, two runs (main alone: 540 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 10:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/794#issuecomment-7159559951) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `f61fe97` into `main` `9376fd6` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with exactly the errors `main` itself has on this machine (`placed_filler_twins` never used, `depth_written` never read, in `victory-gpu`); with `--all-features` it fails with the same number of errors as `main` (4). This PR adds none and removes none. `cargo test --workspace --locked`: 541 passed, 0 failed, 10 ignored, two runs (`main` alone: 540 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/794/head:github-bot/gh-794'
git switch 'github-bot/gh-794'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-794'
git switch 'github-bot/gh-794'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-794'
git switch 'github-bot/gh-794'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-794'
git switch 'main'
git merge --squash 'github-bot/gh-794'
git switch 'main'
git merge --ff-only 'github-bot/gh-794'
git switch 'main'
git merge 'github-bot/gh-794'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.