Resolve overlapping staged Vulkan copy regions #243

Open
github-bot wants to merge 2 commits from github-bot/gh-243 into main AGit
Owner

@⁠Omar-Alme on GitHub · 2026-12-02 15:54 UTC · original
Omar-Alme:render/order-staged-buffer-writes → main · +134 −4 · 3 files · 2 commits · open

What

Closes #160. vkback can batch multiple staged writes into one vkCmdCopyBuffer call for a destination buffer. When queued writes overlap, Vulkan forbids those overlapping destination regions and the later write must still win as it does on the direct-write path. The resolver partitions the ranges by destination boundaries, keeps the latest queued write for each byte, and coalesces compatible adjacent regions. Both staged-copy flush paths use it.

Reference

The motivating behavior is the Vulkan validation error reported in #160 (VUID-vkCmdCopyBuffer-pRegions-12482). There is no D3D12 counterpart: this enforces Vulkan's copy-region validity while preserving vkback's existing queued-write semantics.

Evidence

  • cargo test --manifest-path greenfield/Cargo.toml -j 6 --locked -p vkback --lib staged_copies_: 2 passed; the tests cover exact duplicates, partial/nested overlaps, last-write-wins bytes, and unchanged disjoint copies.
  • The ignored production-resolver GPU readback test passed on RADV with VK_LAYER_KHRONOS_validation enabled.
  • Full cargo test --manifest-path greenfield/Cargo.toml -j 6 --locked -p vkback passed, including the host XCB and GPU tests; the six vkback policy tests passed.
  • cargo clippy --manifest-path greenfield/Cargo.toml -j 6 --locked -p vkback --all-targets -- -D warnings passed.
  • No FPS claim: this fixes invalid Vulkan copy regions and preserves the existing staging behavior.
**@⁠Omar-Alme** on GitHub · 2026-12-02 15:54 UTC · [original](https://github.com/vktory6/VKtory/pull/243) `Omar-Alme:render/order-staged-buffer-writes` → `main` · +134 −4 · 3 files · 2 commits · open ## What Closes #160. vkback can batch multiple staged writes into one `vkCmdCopyBuffer` call for a destination buffer. When queued writes overlap, Vulkan forbids those overlapping destination regions and the later write must still win as it does on the direct-write path. The resolver partitions the ranges by destination boundaries, keeps the latest queued write for each byte, and coalesces compatible adjacent regions. Both staged-copy flush paths use it. ## Reference The motivating behavior is the Vulkan validation error reported in #160 (`VUID-vkCmdCopyBuffer-pRegions-12482`). There is no D3D12 counterpart: this enforces Vulkan's copy-region validity while preserving vkback's existing queued-write semantics. ## Evidence - `cargo test --manifest-path greenfield/Cargo.toml -j 6 --locked -p vkback --lib staged_copies_`: 2 passed; the tests cover exact duplicates, partial/nested overlaps, last-write-wins bytes, and unchanged disjoint copies. - The ignored production-resolver GPU readback test passed on RADV with `VK_LAYER_KHRONOS_validation` enabled. - Full `cargo test --manifest-path greenfield/Cargo.toml -j 6 --locked -p vkback` passed, including the host XCB and GPU tests; the six vkback policy tests passed. - `cargo clippy --manifest-path greenfield/Cargo.toml -j 6 --locked -p vkback --all-targets -- -D warnings` passed. - No FPS claim: this fixes invalid Vulkan copy regions and preserves the existing staging behavior.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 15:56:18 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-02 17:37 UTC · original

Merged, thanks: overlapping staged writes in one copy now resolve to the latest write per byte, so the copy regions no longer overlap (the validation error in #160).

**@⁠vktory6** on GitHub · 2026-12-02 17:37 UTC · [original](https://github.com/vktory6/VKtory/pull/243#issuecomment-7353480784) Merged, thanks: overlapping staged writes in one copy now resolve to the latest write per byte, so the copy regions no longer overlap (the validation error in #160).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
The changes on this branch are already on the target branch. This will be an empty commit.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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