feat(agc): import shared ranges above 64 MiB as sparse buffers over udmabuf chunks #5309

Merged
hugodearaujo merged 2 commits from upstream-pr/5309 into main 2026-10-14 08:50:50 +00:00
hugodearaujo commented 2026-10-13 16:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-13T16:52:34Z.


What

On Linux, a guest range with shared (memfd) backing is imported for the GPU through one udmabuf over the whole range, unless the resource fits inside one 64 MiB chunk. udmabuf refuses buffers above its size_limit_mb (64 MiB by default), so every larger range fell back to copies:

[gpu] host import of 0x500000000+0x87c00000 failed at UDMABUF_CREATE (-1000072003); falling back to copies

For ASTRO BOT (PPSA21567) that is the cause of its stall. A compute dispatch that reaches that 2.1 GiB range through addresses (BDA) gets an image mirror, and acquireMirror → syncRange syncs the whole range on every acquire. That stores back every pending storage image inside it (FlushForAccess over 0x500000000+0x87c00000, about 15 images each time), synchronously, layer by layer. The compute queues wait for labels behind those stores (WAIT_REG_MEM_64 x52 10059ms in 10 s on queue 0x48), and the GPU sits idle.

Related: #5329 (the same limit in Dragon Quest III HD-2D Remake; not run here).

This PR imports such a range as one sparse buffer bound to the existing 64 MiB chunk imports (ImportChunk, the same udmabuf objects the per-chunk import already shares). The range keeps one contiguous device address, so address-based dispatches use the import in place and no mirror is made.

  • VulkanDevice enables sparseBinding when dma-buf import is active and a queue family binds sparse memory. When the device has a second family that binds sparse memory (RADV has a sparse-only family), it creates one queue there for the binds, guarded by its own mutex. The import made at map time runs without the GPU mutex, and this queue lets it bind there too. Without a second family the bind uses the main queue and only runs under the GPU mutex.
  • createSparseDmaBufImport runs after the single-chunk import does not fit and before the whole-range udmabuf. It binds every chunk the buffer covers, waits for the bind's fence, and keeps the chunks alive through HostImport::chunk.
  • It falls back to the existing whole-range import when the range's backing offset is not a multiple of the buffer's sparse block size (64 KiB on RADV), when a chunk cannot be imported, or when the memory types do not match. The NVIDIA proprietary driver offers no memory type shared by dma-buf memory and sparse buffers, but dmaBufImport is already off there, so nothing changes for it. Windows does not change either.

A TechnicalDebt entry records the fallback cases, and the /dev/udmabuf paragraph in docs/user/USAGE.md says when ranges above size_limit_mb are still copied.

Results

ASTRO BOT (PPSA21567, dumped from my PS5), Linux, RX 9070 XT (RADV), 80 s runs with APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1, per 10 s window (the main column, except the first row, with size_limit_mb at 1024):

main this PR
presents default size_limit_mb (64): 28, then 1, then 0 (the game stops submitting); size_limit_mb 1024: 40–52 44 → 238 → 409 → 214 → 153
storage write-backs, reason "memory access" 2,109 (21.4 GB) 0
guest memory read 84.3 GB 20.8 GB
failed imports 9–15, including 0x500000000+0x87c00000 and 0x10ca000000+0x120000000 only ranges whose backing offset is not 64 KiB aligned
furthest screen "Sony Interactive Entertainment presents" (never advances) title screen, "PRESS ANY BUTTON", ~21 FPS

Hollow Knight: Silksong (PPSA12544) runs as before. Hades (PPSA03355) imports its 256 MiB and 3 GiB ranges now and gets further (1,533 file opens before the stop, 1,227 on main). It still stops on its known null-destination copy, which main hits the same way.

Tested

  • Linux: full CTest 1069/1070. The new agc_driver_sparse_dma_buf_import maps a memfd-backed range larger than the current size_limit_mb, imports it at map time (without the GPU mutex), and fills 64 KiB across the first chunk boundary through the import. It checks the backing memory and the bytes on both sides. On main it fails with "a range larger than udmabuf's size limit was not imported". It skips when /dev/udmabuf is not accessible or when the device does not import a one-chunk range. agc_driver_tessellation segfaults the same way on current main.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1096 tests with no failures (the GPU tests skip in this VM); agc_driver_sparse_dma_buf_import reports a skip there, since udmabuf imports are Linux only.
  • Measured with udmabuf's size_limit_mb raised to 1024, then again with it back at the default of 64: ASTRO BOT still reaches its title screen (about 19 FPS against 21) with no "memory access" write-backs. Ranges above 64 MiB take the sparse import whatever the limit, so the limit only affects the fallback cases (two ranges whose offset is not 64 KiB aligned are copied in ASTRO BOT; #5390 imports them).

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846574129 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-13T16:52:34Z. --- ### What On Linux, a guest range with shared (memfd) backing is imported for the GPU through one udmabuf over the whole range, unless the resource fits inside one 64 MiB chunk. udmabuf refuses buffers above its `size_limit_mb` (64 MiB by default), so every larger range fell back to copies: ``` [gpu] host import of 0x500000000+0x87c00000 failed at UDMABUF_CREATE (-1000072003); falling back to copies ``` For ASTRO BOT (PPSA21567) that is the cause of its stall. A compute dispatch that reaches that 2.1 GiB range through addresses (BDA) gets an image mirror, and `acquireMirror` → `syncRange` syncs the whole range on every acquire. That stores back every pending storage image inside it (`FlushForAccess` over `0x500000000+0x87c00000`, about 15 images each time), synchronously, layer by layer. The compute queues wait for labels behind those stores (`WAIT_REG_MEM_64 x52 10059ms` in 10 s on queue 0x48), and the GPU sits idle. Related: #5329 (the same limit in Dragon Quest III HD-2D Remake; not run here). This PR imports such a range as **one sparse buffer bound to the existing 64 MiB chunk imports** (`ImportChunk`, the same udmabuf objects the per-chunk import already shares). The range keeps one contiguous device address, so address-based dispatches use the import in place and no mirror is made. - `VulkanDevice` enables `sparseBinding` when dma-buf import is active and a queue family binds sparse memory. When the device has a second family that binds sparse memory (RADV has a sparse-only family), it creates one queue there for the binds, guarded by its own mutex. The import made at map time runs without the GPU mutex, and this queue lets it bind there too. Without a second family the bind uses the main queue and only runs under the GPU mutex. - `createSparseDmaBufImport` runs after the single-chunk import does not fit and before the whole-range udmabuf. It binds every chunk the buffer covers, waits for the bind's fence, and keeps the chunks alive through `HostImport::chunk`. - It falls back to the existing whole-range import when the range's backing offset is not a multiple of the buffer's sparse block size (64 KiB on RADV), when a chunk cannot be imported, or when the memory types do not match. The NVIDIA proprietary driver offers no memory type shared by dma-buf memory and sparse buffers, but `dmaBufImport` is already off there, so nothing changes for it. Windows does not change either. A TechnicalDebt entry records the fallback cases, and the `/dev/udmabuf` paragraph in `docs/user/USAGE.md` says when ranges above `size_limit_mb` are still copied. ### Results ASTRO BOT (PPSA21567, dumped from my PS5), Linux, RX 9070 XT (RADV), 80 s runs with `APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1`, per 10 s window (the `main` column, except the first row, with `size_limit_mb` at 1024): | | `main` | this PR | |---|---|---| | presents | default `size_limit_mb` (64): 28, then 1, then **0** (the game stops submitting); `size_limit_mb` 1024: 40–52 | 44 → 238 → 409 → 214 → 153 | | storage write-backs, reason "memory access" | 2,109 (21.4 GB) | 0 | | guest memory read | 84.3 GB | 20.8 GB | | failed imports | 9–15, including `0x500000000+0x87c00000` and `0x10ca000000+0x120000000` | only ranges whose backing offset is not 64 KiB aligned | | furthest screen | "Sony Interactive Entertainment presents" (never advances) | title screen, "PRESS ANY BUTTON", ~21 FPS | Hollow Knight: Silksong (PPSA12544) runs as before. Hades (PPSA03355) imports its 256 MiB and 3 GiB ranges now and gets further (1,533 file opens before the stop, 1,227 on `main`). It still stops on its known null-destination copy, which `main` hits the same way. ### Tested - Linux: full CTest 1069/1070. The new `agc_driver_sparse_dma_buf_import` maps a memfd-backed range larger than the current `size_limit_mb`, imports it at map time (without the GPU mutex), and fills 64 KiB across the first chunk boundary through the import. It checks the backing memory and the bytes on both sides. On `main` it fails with "a range larger than udmabuf's size limit was not imported". It skips when `/dev/udmabuf` is not accessible or when the device does not import a one-chunk range. `agc_driver_tessellation` segfaults the same way on current `main`. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1096 tests with no failures (the GPU tests skip in this VM); `agc_driver_sparse_dma_buf_import` reports a skip there, since udmabuf imports are Linux only. - Measured with udmabuf's `size_limit_mb` raised to 1024, then again with it back at the default of 64: ASTRO BOT still reaches its title screen (about 19 FPS against 21) with no "memory access" write-backs. Ranges above 64 MiB take the sparse import whatever the limit, so the limit only affects the fallback cases (two ranges whose offset is not 64 KiB aligned are copied in ASTRO BOT; #5390 imports them). ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
simonbbby commented 2026-10-13 17:28:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-13T17:28:17Z.


Independent RADV verification of exact head 00053abd5fdef4b83444b30a0156bc321a5a3f3a with udmabuf's default size_limit_mb=64, left unchanged throughout:

  • gfx1036 RDNA2 iGPU (1002:13c0), RADV Mesa 25.2.8; Ubuntu 24.04 / Linux 7.0, GCC 13.3, Ninja Release, SPIRV-Tools ON.
  • agc_driver_sparse_dma_buf_import, agc_driver_sparse_buffer_holes and agc_driver_bda_span_reads each pass three consecutive runs. No skips, failures or timeouts. The new fixture executes the at-map import without the GPU mutex, GPU fill across the first 64 MiB chunk boundary, backing-memory comparison and outside-range canaries.
  • Production-only negative control: replaced the three changed production files with their exact parent versions from 0214069e33ccfab4bd97ec973637299895f786d0, retained the PR's new fixture, and rebuilt. The new test fails on its 192 MiB range: UDMABUF_CREATE (-1000072003), then a range larger than udmabuf's size limit was not imported.
  • Restored all three PR files byte-for-byte, rebuilt, and repeated all three tests three times each: all pass again. Checkout clean; kernel limit still 64.

Each run pins radeon_icd.json, ANYPS5_GPU=RADV, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, serial CTest and a 30 s per-test bound. Logs identify the intended AMD device. Build used the existing private XRandR prefix; no system package or kernel-parameter changes.

This adds default-limit coverage on another RADV GPU for #5329's failure shape. No title run, full-suite result, NVIDIA/Windows test or performance claim. Logs retained.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6151310968 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309#issuecomment-6151310968). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-13T17:28:17Z. --- Independent RADV verification of exact head `00053abd5fdef4b83444b30a0156bc321a5a3f3a` with **udmabuf's default `size_limit_mb=64`**, left unchanged throughout: - gfx1036 RDNA2 iGPU (`1002:13c0`), RADV Mesa 25.2.8; Ubuntu 24.04 / Linux 7.0, GCC 13.3, Ninja Release, SPIRV-Tools ON. - `agc_driver_sparse_dma_buf_import`, `agc_driver_sparse_buffer_holes` and `agc_driver_bda_span_reads` each pass three consecutive runs. No skips, failures or timeouts. The new fixture executes the at-map import without the GPU mutex, GPU fill across the first 64 MiB chunk boundary, backing-memory comparison and outside-range canaries. - Production-only negative control: replaced the three changed production files with their exact parent versions from `0214069e33ccfab4bd97ec973637299895f786d0`, retained the PR's new fixture, and rebuilt. The new test fails on its 192 MiB range: `UDMABUF_CREATE (-1000072003)`, then `a range larger than udmabuf's size limit was not imported`. - Restored all three PR files byte-for-byte, rebuilt, and repeated all three tests three times each: all pass again. Checkout clean; kernel limit still 64. Each run pins `radeon_icd.json`, `ANYPS5_GPU=RADV`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, serial CTest and a 30 s per-test bound. Logs identify the intended AMD device. Build used the existing private XRandR prefix; no system package or kernel-parameter changes. This adds default-limit coverage on another RADV GPU for #5329's failure shape. No title run, full-suite result, NVIDIA/Windows test or performance claim. Logs retained.
hugodearaujo commented 2026-10-13 20:15:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-13T20:15:00Z.


A second title takes this path: Hades (PPSA03355), RX 9070 XT (RADV), udmabuf size_limit_mb at its default of 64.

On main (a0f5916a2) one of its shared ranges falls back to copies:

[gpu] host import of 0x3d6600000+0x10000000 failed at UDMABUF_CREATE (-1000072003); falling back to copies

On this PR's head (00053abd5), with APS5_TRACE_HOST_IMPORT=1, the same 256 MiB range is imported:

[gpu] host import of 0x3d6600000+0x10000000 ok (5 live, 3648.0 MiB live, 3648.0 MiB ever)

Both runs were 60 to 70 s from launch with no input. I did not measure a frame-rate change for Hades.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154310934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309#issuecomment-6154310934). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-13T20:15:00Z. --- A second title takes this path: Hades (PPSA03355), RX 9070 XT (RADV), udmabuf `size_limit_mb` at its default of 64. On `main` (a0f5916a2) one of its shared ranges falls back to copies: ``` [gpu] host import of 0x3d6600000+0x10000000 failed at UDMABUF_CREATE (-1000072003); falling back to copies ``` On this PR's head (00053abd5), with `APS5_TRACE_HOST_IMPORT=1`, the same 256 MiB range is imported: ``` [gpu] host import of 0x3d6600000+0x10000000 ok (5 live, 3648.0 MiB live, 3648.0 MiB ever) ``` Both runs were 60 to 70 s from launch with no input. I did not measure a frame-rate change for Hades.
github-actions[bot] commented 2026-10-13 20:31:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T20:31:09Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5453 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L1639
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154603859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309#issuecomment-6154603859). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T20:31:09Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5453 | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L1639](https://github.com/boykopovar/AnyPS5/blob/872f52320382aff45faa4b70f9c03d28228b6991/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L1639) | | |
oneandonlydean commented 2026-10-14 00:10:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T00:10:12Z.


Once the sparse path is chosen, a failure of importChunk, the bind, the fence wait or the device address returns false and the range goes on to the whole-range udmabuf and then copies (GuestBufferMemory.cpp:513-536). Please decide the path before importing (size, sparse support, block alignment, memory type) and throw on any failure after that. Has PPSA20612 from #5329 been run with this at the default size_limit_mb?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157888777 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309#issuecomment-6157888777). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T00:10:12Z. --- Once the sparse path is chosen, a failure of `importChunk`, the bind, the fence wait or the device address returns false and the range goes on to the whole-range udmabuf and then copies (`GuestBufferMemory.cpp:513-536`). Please decide the path before importing (size, sparse support, block alignment, memory type) and throw on any failure after that. Has PPSA20612 from #5329 been run with this at the default `size_limit_mb`?
simonbbby commented 2026-10-14 05:26:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-14T05:26:48Z.


Independent Linux check of revised head 4e136dd3230af4ac50ef1d20f37d959af32153b5. The default udmabuf size_limit_mb=64 was left unchanged.

Release, GCC 13.3, bundled dependencies, SPIRV-Tools ON. agc_host_import_sparse, agc_driver_sparse_dma_buf_import, agc_driver_sparse_buffer_holes and agc_driver_bda_span_reads each pass 3/3 (12 passes, 1.53 s total). The three execution fixtures select gfx1036 (1002:13c0) / RADV Mesa 25.2.8, with the Radeon ICD pinned, Vulkan required and application shader caching disabled. Serial CTest, unchanged 30-second timeout; no internal skips printed.

The new mock fixture checks the complete chunk-bind layout, declines an unaligned backing offset before importing chunks, and verifies selected-path chunk-import and sparse-bind failures throw and release the sparse buffer. Restoring only GuestBufferMemory.cpp from parent 5894feff7e0e7074d67a50f39be341a9ce6ffa94, retaining the new fixture, makes its UDMABUF_CREATE and vkQueueBindSparse throw assertions fail. Restored the PR production source, rebuilt, and ran the matrix above.

I also extended the mock fixture locally for the two other failure stages in the review: vkWaitForFences returning VK_ERROR_DEVICE_LOST, and a zero device address for the sparse buffer only. Both throw with the intended stage and release the sparse buffer, three complete extended-fixture runs. With the parent's production file, all four throw assertions fail. These are mocked failures; neither real GPU was faulted.

All temporary test/production edits were restored, rebuilt, and the checkout is clean at the stated PR head. No title run here, so this does not answer the PPSA20612 runtime question.

Test-only extension used for fence/address failure coverage
diff --git a/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp b/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp
index a6d05d4dc..6430669ed 100644
--- a/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp
@@ -56,6 +56,8 @@ struct MockDevice {
     std::map<VkDeviceMemory, VkDeviceSize> memories;
     std::vector<Bind> binds;
     VkResult bindResult = VK_SUCCESS;
+    VkResult waitResult = VK_SUCCESS;
+    bool zeroSparseAddress = false;
     std::uint64_t nextAddress = 0x500000000ull;
 };
 
@@ -69,7 +71,7 @@ VKAPI_ATTR VkResult VKAPI_CALL mockCreateFence(VkDevice, const VkFenceCreateInfo
 VKAPI_ATTR void VKAPI_CALL mockDestroyFence(VkDevice, VkFence, const VkAllocationCallbacks*) {}
 
 VKAPI_ATTR VkResult VKAPI_CALL mockWaitForFences(VkDevice, std::uint32_t, const VkFence*, VkBool32, std::uint64_t) {
-    return VK_SUCCESS;
+    return mock.waitResult;
 }
 
 VKAPI_ATTR VkResult VKAPI_CALL mockGetMemoryHostPointerProperties(VkDevice, VkExternalMemoryHandleTypeFlagBits, const void*, VkMemoryHostPointerPropertiesEXT*) {
@@ -125,6 +127,7 @@ VKAPI_ATTR VkResult VKAPI_CALL mockQueueBindSparse(VkQueue, std::uint32_t count,
 }
 
 VKAPI_ATTR VkDeviceAddress VKAPI_CALL mockGetBufferDeviceAddress(VkDevice, const VkBufferDeviceAddressInfo* info) {
+    if (mock.zeroSparseAddress && mock.sparse.contains(info->buffer)) return 0;
     const auto address = mock.nextAddress;
     mock.nextAddress += (mock.sizes.at(info->buffer) + Alignment - 1) / Alignment * Alignment;
     return address;
@@ -293,6 +296,12 @@ int main() {
         UnalignedOffsetIsDecidedBeforeImporting();
         FailureAfterTheDecisionThrows(false, VK_SUCCESS, "UDMABUF_CREATE");
         FailureAfterTheDecisionThrows(true, VK_ERROR_DEVICE_LOST, "vkQueueBindSparse");
+        mock.waitResult = VK_ERROR_DEVICE_LOST;
+        FailureAfterTheDecisionThrows(true, VK_SUCCESS, "vkWaitForFences");
+        mock.waitResult = VK_SUCCESS;
+        mock.zeroSparseAddress = true;
+        FailureAfterTheDecisionThrows(true, VK_SUCCESS, "vkGetBufferDeviceAddressKHR");
+        mock.zeroSparseAddress = false;
     } catch (const std::exception& error) {
         std::fprintf(stderr, "%s\n", error.what());
         return 1;
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161581664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309#issuecomment-6161581664). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-14T05:26:48Z. --- Independent Linux check of revised head **`4e136dd3230af4ac50ef1d20f37d959af32153b5`**. The default udmabuf `size_limit_mb=64` was left unchanged. Release, GCC 13.3, bundled dependencies, SPIRV-Tools ON. `agc_host_import_sparse`, `agc_driver_sparse_dma_buf_import`, `agc_driver_sparse_buffer_holes` and `agc_driver_bda_span_reads` each pass **3/3** (12 passes, 1.53 s total). The three execution fixtures select gfx1036 (`1002:13c0`) / RADV Mesa 25.2.8, with the Radeon ICD pinned, Vulkan required and application shader caching disabled. Serial CTest, unchanged 30-second timeout; no internal skips printed. The new mock fixture checks the complete chunk-bind layout, declines an unaligned backing offset before importing chunks, and verifies selected-path chunk-import and sparse-bind failures throw and release the sparse buffer. Restoring only `GuestBufferMemory.cpp` from parent `5894feff7e0e7074d67a50f39be341a9ce6ffa94`, retaining the new fixture, makes its UDMABUF_CREATE and vkQueueBindSparse throw assertions fail. Restored the PR production source, rebuilt, and ran the matrix above. I also extended the mock fixture locally for the two other failure stages in the review: `vkWaitForFences` returning `VK_ERROR_DEVICE_LOST`, and a zero device address for the sparse buffer only. **Both throw with the intended stage and release the sparse buffer**, three complete extended-fixture runs. With the parent's production file, all four throw assertions fail. These are mocked failures; neither real GPU was faulted. All temporary test/production edits were restored, rebuilt, and the checkout is clean at the stated PR head. No title run here, so this does not answer the PPSA20612 runtime question. <details><summary>Test-only extension used for fence/address failure coverage</summary> ```diff diff --git a/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp b/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp index a6d05d4dc..6430669ed 100644 --- a/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/HostImportSparseDmaBuf.cpp @@ -56,6 +56,8 @@ struct MockDevice { std::map<VkDeviceMemory, VkDeviceSize> memories; std::vector<Bind> binds; VkResult bindResult = VK_SUCCESS; + VkResult waitResult = VK_SUCCESS; + bool zeroSparseAddress = false; std::uint64_t nextAddress = 0x500000000ull; }; @@ -69,7 +71,7 @@ VKAPI_ATTR VkResult VKAPI_CALL mockCreateFence(VkDevice, const VkFenceCreateInfo VKAPI_ATTR void VKAPI_CALL mockDestroyFence(VkDevice, VkFence, const VkAllocationCallbacks*) {} VKAPI_ATTR VkResult VKAPI_CALL mockWaitForFences(VkDevice, std::uint32_t, const VkFence*, VkBool32, std::uint64_t) { - return VK_SUCCESS; + return mock.waitResult; } VKAPI_ATTR VkResult VKAPI_CALL mockGetMemoryHostPointerProperties(VkDevice, VkExternalMemoryHandleTypeFlagBits, const void*, VkMemoryHostPointerPropertiesEXT*) { @@ -125,6 +127,7 @@ VKAPI_ATTR VkResult VKAPI_CALL mockQueueBindSparse(VkQueue, std::uint32_t count, } VKAPI_ATTR VkDeviceAddress VKAPI_CALL mockGetBufferDeviceAddress(VkDevice, const VkBufferDeviceAddressInfo* info) { + if (mock.zeroSparseAddress && mock.sparse.contains(info->buffer)) return 0; const auto address = mock.nextAddress; mock.nextAddress += (mock.sizes.at(info->buffer) + Alignment - 1) / Alignment * Alignment; return address; @@ -293,6 +296,12 @@ int main() { UnalignedOffsetIsDecidedBeforeImporting(); FailureAfterTheDecisionThrows(false, VK_SUCCESS, "UDMABUF_CREATE"); FailureAfterTheDecisionThrows(true, VK_ERROR_DEVICE_LOST, "vkQueueBindSparse"); + mock.waitResult = VK_ERROR_DEVICE_LOST; + FailureAfterTheDecisionThrows(true, VK_SUCCESS, "vkWaitForFences"); + mock.waitResult = VK_SUCCESS; + mock.zeroSparseAddress = true; + FailureAfterTheDecisionThrows(true, VK_SUCCESS, "vkGetBufferDeviceAddressKHR"); + mock.zeroSparseAddress = false; } catch (const std::exception& error) { std::fprintf(stderr, "%s\n", error.what()); return 1; ``` </details>
oneandonlydean commented 2026-10-14 08:50:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T08:50:27Z.


Rebased onto main and added a commit on top. The sparse path is now chosen before anything is imported: sparse binding, a range above one chunk, the bind queue, /dev/udmabuf open, the backing offset on the sparse block size, every memory type a chunk import can have accepted by the sparse buffer, and the backing file covering the last chunk. Once it is chosen, a failed chunk import, fence creation, bind, fence wait or device address throws instead of going on to the whole-range udmabuf and copies. The debt entry lists the cases that still take the single udmabuf.

New test agc_host_import_sparse runs the import against a mocked device and the real /dev/udmabuf at the default size_limit_mb: a 129 MiB range becomes one sparse buffer bound to one chunk import per 64 MiB, an unaligned backing offset imports no chunk, and UDMABUF_CREATE and vkQueueBindSparse failures after the decision throw. On main all three import checks fail; with the earlier head of this PR the two throw checks fail.

Linux, RTX 4090, size_limit_mb 64: the dma-buf path is off on the NVIDIA driver, so this was a regression check only. PPSA21564 reaches its first level on main and on this PR (level 29.1 / 28.9 fps on main, 28.6 / 29.4 and 32.8 / 27.7 here), and PPSA02929 passes on both. Full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164571022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5309#issuecomment-6164571022). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T08:50:27Z. --- Rebased onto main and added a commit on top. The sparse path is now chosen before anything is imported: sparse binding, a range above one chunk, the bind queue, `/dev/udmabuf` open, the backing offset on the sparse block size, every memory type a chunk import can have accepted by the sparse buffer, and the backing file covering the last chunk. Once it is chosen, a failed chunk import, fence creation, bind, fence wait or device address throws instead of going on to the whole-range udmabuf and copies. The debt entry lists the cases that still take the single udmabuf. New test `agc_host_import_sparse` runs the import against a mocked device and the real `/dev/udmabuf` at the default `size_limit_mb`: a 129 MiB range becomes one sparse buffer bound to one chunk import per 64 MiB, an unaligned backing offset imports no chunk, and `UDMABUF_CREATE` and `vkQueueBindSparse` failures after the decision throw. On main all three import checks fail; with the earlier head of this PR the two throw checks fail. Linux, RTX 4090, `size_limit_mb` 64: the dma-buf path is off on the NVIDIA driver, so this was a regression check only. PPSA21564 reaches its first level on main and on this PR (level 29.1 / 28.9 fps on main, 28.6 / 29.4 and 32.8 / 27.7 here), and PPSA02929 passes on both. Full build is green.
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!5309
No description provided.