fix(agc): allocate the sampled depth shadow through the image allocator #15855

Merged
BunnyFl merged 1 commit from upstream-pr/15855 into main 2026-11-04 20:28:50 +00:00
BunnyFl commented 2026-11-04 19:57:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T19:57:15Z.


What

main at 0263899e99 doesn't compile libSceAgcDriver:

core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:1623:38: error: cannot convert 'VkMemoryAllocateInfo' to 'const VkImageCreateInfo&'

#15301 (merged 19:20 UTC today) moved the sampled depth shadow in createSampleShadow onto OwnedImage::Allocate(context, VkMemoryAllocateInfo, mask, operation). Its branch is based on 9090972b7e, which predates #10472 (9c6391d5a1, merged 04:48 UTC today). #10472 replaced that overload with Allocate(const Context&, const VkImageCreateInfo&, const char* operation, bool newImage = false, bool budgeted = false) (Texture.hpp:54 on main). Reported on #15301 in issuecomment-6640160657.

This PR moves the call to the form #10472 gave every other OwnedImage caller: pass the image's VkImageCreateInfo and bind at owned->allocation.Memory() and owned->allocation.Offset(), the same as the depth plane copy at DepthSurface.cpp:1917 on main. The VkMemoryRequirements / VkMemoryAllocateInfo locals that only fed the old overload are removed. The allocator reads the requirements itself with vkGetImageMemoryRequirements2 (core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:749 on main). newImage and budgeted stay at their defaults, as #15301 passed neither.

What #15301 wanted is kept: the standalone path of BufferPool::AllocateImage still allocates through TakeImageMemory with RefusedDeviceMemoryFallback (core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:778 and core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:779 on main), and the slab path falls back to that standalone path on VK_ERROR_OUT_OF_DEVICE_MEMORY (core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:810 and core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:811 on main). The difference from #15301 as written is that a shadow small enough for an image slab can now be placed in a shared 4 MiB block, as #10472 does for the other sampled images.

hugodearaujo noted the same break on #15710 and patched it locally to the mask form of AllocateImageMemory to test that merge; that patch is not in any PR. I took the OwnedImage::Allocate form instead so the shadow follows #10472's allocator like the other OwnedImage users.

Tested

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, AMD Radeon RX 9070 XT (driver 32.0.32015.12012), Vulkan SDK 1.4.363 validation layer.

  • main 0263899e99, fresh configure on a clean checkout: building DepthSurface.cpp.obj fails with the error above.
  • This branch d792684630 (only commit on 0263899e99): libSceAgcDriver builds.
  • The 18 tests of agc_driver_native_multisample_depth_tests and agc_driver_native_depth_bda_clear_tests (agc_driver_native_multisample_depth, agc_driver_native_depth_*), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and ctest -V: 18 of 18 pass on this branch (agc_driver_native_depth_driver_queued_fill reports Skipped on this device). No VUID- or SYNC-HAZARD lines, and no was not found but was requested by env var VK_INSTANCE_LAYERS line.
  • main itself doesn't build (first bullet above). The comparison side is fca7decda9, main just before #15301's merge: the same 18 tests, same environment, 18 of 18 pass with the same skip, no VUID- or SYNC-HAZARD lines.
  • To confirm these tests reach the changed lines: with a throw added at the top of createSampleShadow on this branch, 17 of the 18 fail (the 18th is the skipped one).
  • tools/check_conventions.py --base upstream/main on the committed head: all checks pass.
  • tools/pr_overlap.py: 39 open PRs share DepthSurface.cpp, and 19 of them conflict with main so the tool couldn't compare lines. I compared those 19 and #15750 by hand against the range of createSampleShadow in each PR's own base. Only #15750 (info.usage of the shadow, three lines above this change) and #13920 (a CommandBorrow line after the barrier setup) change lines inside the function; neither touches these lines, and this branch merges cleanly with #15750.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 9070 XT, AMD proprietary driver 32.0.32015.12012, Windows 11 Pro 10.0.26300
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5160700845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15855). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T19:57:15Z. --- ### What `main` at `0263899e99` doesn't compile `libSceAgcDriver`: ``` core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:1623:38: error: cannot convert 'VkMemoryAllocateInfo' to 'const VkImageCreateInfo&' ``` #15301 (merged 19:20 UTC today) moved the sampled depth shadow in `createSampleShadow` onto `OwnedImage::Allocate(context, VkMemoryAllocateInfo, mask, operation)`. Its branch is based on `9090972b7e`, which predates #10472 (`9c6391d5a1`, merged 04:48 UTC today). #10472 replaced that overload with `Allocate(const Context&, const VkImageCreateInfo&, const char* operation, bool newImage = false, bool budgeted = false)` (`Texture.hpp:54` on `main`). Reported on #15301 in issuecomment-6640160657. This PR moves the call to the form #10472 gave every other `OwnedImage` caller: pass the image's `VkImageCreateInfo` and bind at `owned->allocation.Memory()` and `owned->allocation.Offset()`, the same as the depth plane copy at `DepthSurface.cpp:1917` on `main`. The `VkMemoryRequirements` / `VkMemoryAllocateInfo` locals that only fed the old overload are removed. The allocator reads the requirements itself with `vkGetImageMemoryRequirements2` (`core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:749` on `main`). `newImage` and `budgeted` stay at their defaults, as #15301 passed neither. What #15301 wanted is kept: the standalone path of `BufferPool::AllocateImage` still allocates through `TakeImageMemory` with `RefusedDeviceMemoryFallback` (`core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:778` and `core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:779` on `main`), and the slab path falls back to that standalone path on `VK_ERROR_OUT_OF_DEVICE_MEMORY` (`core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:810` and `core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:811` on `main`). The difference from #15301 as written is that a shadow small enough for an image slab can now be placed in a shared 4 MiB block, as #10472 does for the other sampled images. hugodearaujo noted the same break on #15710 and patched it locally to the mask form of `AllocateImageMemory` to test that merge; that patch is not in any PR. I took the `OwnedImage::Allocate` form instead so the shadow follows #10472's allocator like the other `OwnedImage` users. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, AMD Radeon RX 9070 XT (driver 32.0.32015.12012), Vulkan SDK 1.4.363 validation layer. - `main` `0263899e99`, fresh configure on a clean checkout: building `DepthSurface.cpp.obj` fails with the error above. - This branch `d792684630` (only commit on `0263899e99`): `libSceAgcDriver` builds. - The 18 tests of `agc_driver_native_multisample_depth_tests` and `agc_driver_native_depth_bda_clear_tests` (`agc_driver_native_multisample_depth`, `agc_driver_native_depth_*`), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `ctest -V`: 18 of 18 pass on this branch (`agc_driver_native_depth_driver_queued_fill` reports Skipped on this device). No `VUID-` or `SYNC-HAZARD` lines, and no `was not found but was requested by env var VK_INSTANCE_LAYERS` line. - `main` itself doesn't build (first bullet above). The comparison side is `fca7decda9`, `main` just before #15301's merge: the same 18 tests, same environment, 18 of 18 pass with the same skip, no `VUID-` or `SYNC-HAZARD` lines. - To confirm these tests reach the changed lines: with a `throw` added at the top of `createSampleShadow` on this branch, 17 of the 18 fail (the 18th is the skipped one). - `tools/check_conventions.py --base upstream/main` on the committed head: all checks pass. - `tools/pr_overlap.py`: 39 open PRs share `DepthSurface.cpp`, and 19 of them conflict with `main` so the tool couldn't compare lines. I compared those 19 and #15750 by hand against the range of `createSampleShadow` in each PR's own base. Only #15750 (`info.usage` of the shadow, three lines above this change) and #13920 (a `CommandBorrow` line after the barrier setup) change lines inside the function; neither touches these lines, and this branch merges cleanly with #15750. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 9070 XT, AMD proprietary driver 32.0.32015.12012, Windows 11 Pro 10.0.26300 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
boykopovar/AnyPS5!15855
No description provided.