Preserve untouched bytes during partial texture read-back #794

Open
Lilith133T wants to merge 1 commit from upstream-pr/794 into main
Lilith133T commented 2026-11-25 08:04:18 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Lilith133T on 2026-11-25T08:04:18Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6599992025 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/794). Originally posted by [Lilith133T](https://github.com/Lilith133T) on 2026-11-25T08:04:18Z. --- 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`.
MamaLeVrai commented 2026-11-25 11:10:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T10:20:26Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7159559951 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/794#issuecomment-7159559951). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T10:20:26Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/794:upstream-pr/794'
git switch 'upstream-pr/794'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/794'
git switch 'upstream-pr/794'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/794'
git switch 'upstream-pr/794'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/794'
git switch 'main'
git merge --squash 'upstream-pr/794'
git switch 'main'
git merge --ff-only 'upstream-pr/794'
git switch 'main'
git merge 'upstream-pr/794'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!794
No description provided.