vulkan: preserve GPU contents across image aliases and buffer transfers #1518

Open
github-bot wants to merge 21 commits from github-bot/gh-1518 into main AGit
Owner

@⁠FxDrops on GitHub · 2026-10-14 21:57 UTC · original
FxDrops:publish/vulkan-memory-aliasing → main · +1601 −125 · 13 files · 21 commits · draft

GPU-written images can lose contents when another view changes format, mip/layer capacity, guest placement, or partially overlaps their backing. Buffer reads can return stale guest bytes, while partial Fill/Copy operations can discard untouched native texels. This series preserves guest-byte placement when publishing native image contents and synchronizes overlapping aliases before acquisition.

Architectural justification

  • Preserve color and depth image contents across subresource reshapes, format changes, capacity growth, and overlap retirement. Resolve uncertain CPU dirty state before deciding which native contents remain authoritative.
  • Refresh existing overlapping aliases from current writers; preserve disjoint writers and reject conflicting overlapping native writers explicitly.
  • Preserve complete native image contents before partial buffer writes. Read overlapping native sources before exposing buffer subranges without transferring image ownership.
  • Keep CPU Fill/Copy fast paths away from registered image ranges, including interior source addresses and destination aliases. Byte-sized copies retain untouched texel bytes.
  • Synchronize attachment stores and reject invalid depth aliases and out-of-bounds mip copies before issuing invalid GPU commands.

These are general resource-coherence prerequisites for complex engine workloads. This PR does not claim async-compute completeness, RDNA 2 ISA conformance, performance improvements, or GTA VI boot support. No title-specific conditions are introduced.

Validation method

  • Windows x64 clang-cl build of kyty_emulator, launcher and kyty_tests succeeds.
  • 18 affected regression tests passed after the final production changes (51.15 s), including texture-cache aliases, image transitions, depth alias rejection, mip-copy bounds, buffer ownership and GPU readback checks.
  • Complete shader_recompiler_compute suite passed after the final production changes (54.37 s).
  • An additional test-only commit verifies a three-byte unaligned copy across a native texel boundary; buffer_cache_ranges passed (7.78 s).
  • Before/after regressions separately reproduced stale interior reads, native-image Copy sources, and partial Fill/Copy destination data loss.
  • GPU verification used the Vulkan 1.3 test context on an NVIDIA RTX 3080. Khronos validation layers are unavailable in this environment. These results are functional readback and fail-fast checks, not a full Vulkan or RDNA 2 conformance certification. No shader translator changes are included.

Review scope

The series also contains the Windows regression-build fixes needed for this local baseline and a separately committed socket-option validation fix discovered by the wider tests. These independent commits can be split out during draft review.

Publication snapshot: 6728e0ab1e, based on upstream main 9e41d8320a. The unfinished stencil-plane investigation is excluded.

**@⁠FxDrops** on GitHub · 2026-10-14 21:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1518) `FxDrops:publish/vulkan-memory-aliasing` → `main` · +1601 −125 · 13 files · 21 commits · draft GPU-written images can lose contents when another view changes format, mip/layer capacity, guest placement, or partially overlaps their backing. Buffer reads can return stale guest bytes, while partial Fill/Copy operations can discard untouched native texels. This series preserves guest-byte placement when publishing native image contents and synchronizes overlapping aliases before acquisition. Architectural justification - Preserve color and depth image contents across subresource reshapes, format changes, capacity growth, and overlap retirement. Resolve uncertain CPU dirty state before deciding which native contents remain authoritative. - Refresh existing overlapping aliases from current writers; preserve disjoint writers and reject conflicting overlapping native writers explicitly. - Preserve complete native image contents before partial buffer writes. Read overlapping native sources before exposing buffer subranges without transferring image ownership. - Keep CPU Fill/Copy fast paths away from registered image ranges, including interior source addresses and destination aliases. Byte-sized copies retain untouched texel bytes. - Synchronize attachment stores and reject invalid depth aliases and out-of-bounds mip copies before issuing invalid GPU commands. These are general resource-coherence prerequisites for complex engine workloads. This PR does not claim async-compute completeness, RDNA 2 ISA conformance, performance improvements, or GTA VI boot support. No title-specific conditions are introduced. Validation method - Windows x64 clang-cl build of kyty_emulator, launcher and kyty_tests succeeds. - 18 affected regression tests passed after the final production changes (51.15 s), including texture-cache aliases, image transitions, depth alias rejection, mip-copy bounds, buffer ownership and GPU readback checks. - Complete shader_recompiler_compute suite passed after the final production changes (54.37 s). - An additional test-only commit verifies a three-byte unaligned copy across a native texel boundary; buffer_cache_ranges passed (7.78 s). - Before/after regressions separately reproduced stale interior reads, native-image Copy sources, and partial Fill/Copy destination data loss. - GPU verification used the Vulkan 1.3 test context on an NVIDIA RTX 3080. Khronos validation layers are unavailable in this environment. These results are functional readback and fail-fast checks, not a full Vulkan or RDNA 2 conformance certification. No shader translator changes are included. Review scope The series also contains the Windows regression-build fixes needed for this local baseline and a separately committed socket-option validation fix discovered by the wider tests. These independent commits can be split out during draft review. Publication snapshot: 6728e0ab1e1aeb14632094cf07aa5b62b981e386, based on upstream main 9e41d8320a2774b303fbad344c2347e8d0292e83. The unfinished stencil-plane investigation is excluded.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:31 +00:00
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/context.cpp
  • src/graphics/host_gpu/renderer/image/image.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/VdecswTests.cpp
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/1518/head:github-bot/gh-1518'
git switch 'github-bot/gh-1518'

Merge

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