fix(agc): settle dma-buf imports on Linux on the settle queue #5905

Merged
hugodearaujo merged 2 commits from upstream-pr/5905 into main 2026-10-16 19:05:31 +00:00
hugodearaujo commented 2026-10-14 15:12:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-14T15:12:28Z.


What

Hades (PPSA03355) stops about 9 s after launch on current main (Linux, RADV), every time, with no input: a SIGSEGV in its bundled libc's memcpy, writing to address 0, called from app.elf+0x308059. The title's texture upload copies into a texture whose creation failed: its own renderer (The-Forge/Prospero/Common_3/Renderer/Prospero.cpp) takes the "Failed to allocate memory for texture" path at app.elf+0x31aa39, because a 256 MiB staging pool it allocates from (mapped at 0x301a00000) is full.

How the pool fills (measured on 4469ea22f):

  1. At start-up the title maps a 3 GiB range (0x311a00000+0xc0000000), which is imported as a sparse dma-buf (#5309).
  2. The kernel maps a dma-buf import's pages for the GPU at the first submission that uses it, not when it is imported. On RADV the first vkQueueSubmit after that import took 1.85 to 1.89 s (measured inside Recorder::Submit), and it lands in the title's second frame. The flip submission of that frame is held behind the queue 0 worker for that time (#1745), so the frame lasts about 2.5 s.
  3. The title's loader keeps queueing textures meanwhile, and its render thread creates every queued texture in the next frame, each with 4 MiB of texture memory and 4 MiB of staging. Staging is only recycled when later frames complete.

Allocations per frame, counted at the title's allocator (app.elf+0x315e00), keyed by its frame fence:

frame duration 4 MiB requests
1 3.4 ms 8
2 1,875 ms 7
3 72 ms 93 (391 MiB)
4 allocation fails

This PR settles every dma-buf import of 1 MiB or more right after it is made, the way #6060 settles Windows host imports of write-watched private memory: settleImport copies 4 bytes out of the new import on the settle queue and waits for that copy. The kernel then maps the pages in that submission, on the thread that made the import.

  • Linux makes the settle queue when the device imports dma-buf memory. On RADV the graphics family has a single queue, so the settle queue is a compute queue. Where the sparse queue already took the settle queue's family, the settle queue is that family's second queue, when it has one.
  • A dma-buf import's buffer is concurrent with the settle queue's family (shareDmaBufImport) instead of aliased as on Windows, since a sparse import is bound to many memory objects.
  • The settle takes neither the GPU mutex nor the main queue. An import made at map time is settled even while another thread holds the GPU mutex, and the wait covers only the copy.
  • An import made at map time is settled inside the guest's map call, so the thread that maps the range now waits while the kernel maps the pages, where on main the first submission that used the import did. That took 0.47 to 2.2 s for the 3 GiB range of Hades and 0.49 and 4.3 s for the 4.5 GiB range of ASTRO BOT in the runs below; both titles map these ranges at start-up. A title that maps large ranges during gameplay would block its mapping thread for as long (TechnicalDebt, Settled dma-buf imports).
  • An import made from a submission is settled under the GPU mutex, so its frame still pays for it (TechnicalDebt, Settled dma-buf imports).

The Windows path is unchanged: the same queue selection, alias and call site, with the #ifdefs moved.

Measured

RX 9070 XT (RADV, Mesa 26.2.4), Linux 7.2.9, udmabuf size_limit_mb 64, no input. The runs alternate between main (4224d240a) and this PR:

build Hades runs (40 s) stopped at ~9 s
main 12 12
this PR 12 0

One more run of this PR on its own also reached the end.

Settle times with APS5_TRACE_HOST_IMPORT=1:

title runs settles per run median longest
Hades (PPSA03355), 40 s 13 4–8 45 ms 2.2 s (the 3 GiB import: 0.47–2.2 s)
Hollow Knight: Silksong (PPSA12544), 60 s 2 96 0.2 ms 31 ms
ASTRO BOT (PPSA21567), 60 s 2 31–32 2.8 ms 4.3 s (a 4.5 GiB import)

Silksong and ASTRO BOT reach the end of their runs, as on main. About 19 GiB of swap was in use on the machine during these runs, which makes pinning the large imports slower.

Tested

  • Linux: full CTest passes except agc_pending_key_stores and agc_driver_tessellation, which fail the same way on main (4224d240a).
  • agc_driver_sparse_dma_buf_import now checks that the 1 MiB import and the sparse import made at map time are each settled (HostImportsSettled) when they are dma-buf imports. A device can import shared memory through host pointers instead, as lavapipe does, and such imports are not settled (9bd554a64); a device with a settle queue that imports that way would have failed the check. The #5390 report suggests ANV on an Intel Arc B390 imports that way, which I could not check. On RADV both checks run and pass 3 of 3, and with the settle call removed the test fails at the first of them. Under lavapipe (Mesa 26.2.4, one queue) there is no settle queue, and the test passes 3 of 3 with that note, as @jotitadev found.
  • The 21 tests matching ^agc.*(import|dma|sparse|shadow|unit) pass on RADV and under lavapipe, except agc_shadowed_key_stores, which skips on both.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: the build passes, and CTest fails audio_out_shutdown and guest_kqueue (0xc0000409) out of 1288; main (4224d240a) on the same VM fails those two and audio_out2_shutdown. The GPU tests skip in this VM.
  • tools/check_conventions.py passes. tools/pr_overlap.py lists only file overlaps; no open PR settles imports or changes the settle queue.

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:4860035073 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-14T15:12:28Z. --- ### What Hades (PPSA03355) stops about 9 s after launch on current `main` (Linux, RADV), every time, with no input: a SIGSEGV in its bundled libc's `memcpy`, writing to address 0, called from `app.elf+0x308059`. The title's texture upload copies into a texture whose creation failed: its own renderer (`The-Forge/Prospero/Common_3/Renderer/Prospero.cpp`) takes the "Failed to allocate memory for texture" path at `app.elf+0x31aa39`, because a 256 MiB staging pool it allocates from (mapped at `0x301a00000`) is full. How the pool fills (measured on `4469ea22f`): 1. At start-up the title maps a 3 GiB range (`0x311a00000+0xc0000000`), which is imported as a sparse dma-buf (#5309). 2. The kernel maps a dma-buf import's pages for the GPU at the first submission that uses it, not when it is imported. On RADV the first `vkQueueSubmit` after that import took 1.85 to 1.89 s (measured inside `Recorder::Submit`), and it lands in the title's second frame. The flip submission of that frame is held behind the queue 0 worker for that time (#1745), so the frame lasts about 2.5 s. 3. The title's loader keeps queueing textures meanwhile, and its render thread creates every queued texture in the next frame, each with 4 MiB of texture memory and 4 MiB of staging. Staging is only recycled when later frames complete. Allocations per frame, counted at the title's allocator (`app.elf+0x315e00`), keyed by its frame fence: | frame | duration | 4 MiB requests | |---|---|---| | 1 | 3.4 ms | 8 | | 2 | 1,875 ms | 7 | | 3 | 72 ms | 93 (391 MiB) | | 4 | | allocation fails | This PR settles every dma-buf import of 1 MiB or more right after it is made, the way #6060 settles Windows host imports of write-watched private memory: `settleImport` copies 4 bytes out of the new import on the settle queue and waits for that copy. The kernel then maps the pages in that submission, on the thread that made the import. - Linux makes the settle queue when the device imports dma-buf memory. On RADV the graphics family has a single queue, so the settle queue is a compute queue. Where the sparse queue already took the settle queue's family, the settle queue is that family's second queue, when it has one. - A dma-buf import's buffer is concurrent with the settle queue's family (`shareDmaBufImport`) instead of aliased as on Windows, since a sparse import is bound to many memory objects. - The settle takes neither the GPU mutex nor the main queue. An import made at map time is settled even while another thread holds the GPU mutex, and the wait covers only the copy. - An import made at map time is settled inside the guest's map call, so the thread that maps the range now waits while the kernel maps the pages, where on `main` the first submission that used the import did. That took 0.47 to 2.2 s for the 3 GiB range of Hades and 0.49 and 4.3 s for the 4.5 GiB range of ASTRO BOT in the runs below; both titles map these ranges at start-up. A title that maps large ranges during gameplay would block its mapping thread for as long (TechnicalDebt, Settled dma-buf imports). - An import made from a submission is settled under the GPU mutex, so its frame still pays for it (TechnicalDebt, Settled dma-buf imports). The Windows path is unchanged: the same queue selection, alias and call site, with the `#ifdef`s moved. ### Measured RX 9070 XT (RADV, Mesa 26.2.4), Linux 7.2.9, udmabuf `size_limit_mb` 64, no input. The runs alternate between `main` (`4224d240a`) and this PR: | build | Hades runs (40 s) | stopped at ~9 s | |---|---|---| | `main` | 12 | 12 | | this PR | 12 | 0 | One more run of this PR on its own also reached the end. Settle times with `APS5_TRACE_HOST_IMPORT=1`: | title | runs | settles per run | median | longest | |---|---|---|---|---| | Hades (PPSA03355), 40 s | 13 | 4–8 | 45 ms | 2.2 s (the 3 GiB import: 0.47–2.2 s) | | Hollow Knight: Silksong (PPSA12544), 60 s | 2 | 96 | 0.2 ms | 31 ms | | ASTRO BOT (PPSA21567), 60 s | 2 | 31–32 | 2.8 ms | 4.3 s (a 4.5 GiB import) | Silksong and ASTRO BOT reach the end of their runs, as on `main`. About 19 GiB of swap was in use on the machine during these runs, which makes pinning the large imports slower. ### Tested - Linux: full CTest passes except `agc_pending_key_stores` and `agc_driver_tessellation`, which fail the same way on `main` (`4224d240a`). - `agc_driver_sparse_dma_buf_import` now checks that the 1 MiB import and the sparse import made at map time are each settled (`HostImportsSettled`) when they are dma-buf imports. A device can import shared memory through host pointers instead, as lavapipe does, and such imports are not settled (9bd554a64); a device with a settle queue that imports that way would have failed the check. The #5390 report suggests ANV on an Intel Arc B390 imports that way, which I could not check. On RADV both checks run and pass 3 of 3, and with the settle call removed the test fails at the first of them. Under lavapipe (Mesa 26.2.4, one queue) there is no settle queue, and the test passes 3 of 3 with that note, as @jotitadev found. - The 21 tests matching `^agc.*(import|dma|sparse|shadow|unit)` pass on RADV and under lavapipe, except `agc_shadowed_key_stores`, which skips on both. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: the build passes, and CTest fails `audio_out_shutdown` and `guest_kqueue` (`0xc0000409`) out of 1288; `main` (`4224d240a`) on the same VM fails those two and `audio_out2_shutdown`. The GPU tests skip in this VM. - `tools/check_conventions.py` passes. `tools/pr_overlap.py` lists only file overlaps; no open PR settles imports or changes the settle queue. ### 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)
CnRJay commented 2026-10-14 17:17:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T17:17:56Z.

Review: COMMENTED


The diagnosis is careful. A 1.9 s first vkQueueSubmit while the kernel maps a 3 GiB dma-buf lands in the title's second frame, and its own staging pool can't cover it. Moving that cost to map time is a reasonable answer.

My concern is the skip. When another thread holds the GPU mutex, touchDmaBufImports is skipped (as the debt entry says), so the fix only applies when the map happens while nothing is recording. That holds for Hades' start-up mapping. For a title that maps a large range while rendering, the GPU mutex is likely held: the queue worker takes it for every packet. The stall then returns to the frame, and whether it does depends on timing. Two things would make this easier to judge:

  • Count the skips. MappedDmaBufImportsTouched counts the touches. A counter for skipped touches, printed with the import stats, would show whether the Hades runs (and Silksong/ASTRO BOT) ever hit the skip, and would make a regression visible when a title does.
  • Don't drop a skipped import. The import could be noted as untouched and touched by the queue worker the next time it takes the GPU mutex, before it records a submission that references it. That keeps the 1.9 s outside the frame in the cases this PR targets. When the import is needed right away, it is no worse than main.

Small point: each call creates and destroys a command pool, a scratch buffer, its memory and a fence. That's fine for a start-up-only path, but if the sparse path runs for every large map, keeping one pool and scratch buffer on the import state would avoid the churn.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5521826751 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#pullrequestreview-5521826751). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-14T17:17:56Z. **Review:** COMMENTED --- The diagnosis is careful. A 1.9 s first `vkQueueSubmit` while the kernel maps a 3 GiB dma-buf lands in the title's second frame, and its own staging pool can't cover it. Moving that cost to map time is a reasonable answer. My concern is the skip. When another thread holds the GPU mutex, `touchDmaBufImports` is skipped (as the debt entry says), so the fix only applies when the map happens while nothing is recording. That holds for Hades' start-up mapping. For a title that maps a large range while rendering, the GPU mutex is likely held: the queue worker takes it for every packet. The stall then returns to the frame, and whether it does depends on timing. Two things would make this easier to judge: - **Count the skips.** `MappedDmaBufImportsTouched` counts the touches. A counter for skipped touches, printed with the import stats, would show whether the Hades runs (and Silksong/ASTRO BOT) ever hit the skip, and would make a regression visible when a title does. - **Don't drop a skipped import.** The import could be noted as untouched and touched by the queue worker the next time it takes the GPU mutex, before it records a submission that references it. That keeps the 1.9 s outside the frame in the cases this PR targets. When the import is needed right away, it is no worse than `main`. Small point: each call creates and destroys a command pool, a scratch buffer, its memory and a fence. That's fine for a start-up-only path, but if the sparse path runs for every large map, keeping one pool and scratch buffer on the import state would avoid the churn.
hugodearaujo commented 2026-10-14 18:02:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-14T18:02:55Z.


Thanks. I made all three changes in 3b7090fa0.

  • Skips are counted and printed. MappedDmaBufTouches() returns how many imports were used at the map, deferred, used by the worker, or retired before it got to them. The first 8 skips print a [gpu] line. With APS5_TRACE_HOST_IMPORT=1, every copy prints its size, where it ran (at the map or by the queue worker) and its time.
  • A skipped import is no longer dropped. It is kept on the import state, and the queue worker uses it on the GPU the next time it takes the GPU mutex: right before it executes its next submission, or in its idle reap. The test now also holds the GPU mutex on another thread while a range is mapped, and checks that the import is deferred, left pending, and used under the mutex afterwards. With either half removed, the test fails at the matching check.
  • The command pool, command buffer, scratch buffer and fence are made once per device and released with its imports (ClearHostImports). Each use resets the pool and the fence.

Where the skip happens, from runs with the trace on (RX 9070 XT, RADV, no input):

Title Runs Used at the map Deferred, then used by the worker Largest deferred Worker's longest copy
Hades (PPSA03355), 40 s 4 3–4 per run, including the 3 GiB pool (0.66–1.03 s) 2–4 per run 256 MiB 15.4 ms
Silksong (PPSA12544), 60 s 2 68–74 per run 23–26 per run 96 MiB 27.9 ms
ASTRO BOT (PPSA21567), 60 s 2 5 per run, including 4.5 GiB (1.2–2.4 s) 0

So Hades does hit the skip, but only for the 256 MiB ranges it maps after start-up. The worker then pays up to about 15 ms for them, before it executes its next submission (on main, that submission's vkQueueSubmit paid it). All 8 runs reached the end of their time limit with no crash.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174945867 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6174945867). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-14T18:02:55Z. --- Thanks. I made all three changes in 3b7090fa0. - **Skips are counted and printed.** `MappedDmaBufTouches()` returns how many imports were used at the map, deferred, used by the worker, or retired before it got to them. The first 8 skips print a `[gpu]` line. With `APS5_TRACE_HOST_IMPORT=1`, every copy prints its size, where it ran (at the map or by the queue worker) and its time. - **A skipped import is no longer dropped.** It is kept on the import state, and the queue worker uses it on the GPU the next time it takes the GPU mutex: right before it executes its next submission, or in its idle reap. The test now also holds the GPU mutex on another thread while a range is mapped, and checks that the import is deferred, left pending, and used under the mutex afterwards. With either half removed, the test fails at the matching check. - **The command pool, command buffer, scratch buffer and fence are made once per device** and released with its imports (`ClearHostImports`). Each use resets the pool and the fence. Where the skip happens, from runs with the trace on (RX 9070 XT, RADV, no input): | Title | Runs | Used at the map | Deferred, then used by the worker | Largest deferred | Worker's longest copy | |---|---|---|---|---|---| | Hades (PPSA03355), 40 s | 4 | 3–4 per run, including the 3 GiB pool (0.66–1.03 s) | 2–4 per run | 256 MiB | 15.4 ms | | Silksong (PPSA12544), 60 s | 2 | 68–74 per run | 23–26 per run | 96 MiB | 27.9 ms | | ASTRO BOT (PPSA21567), 60 s | 2 | 5 per run, including 4.5 GiB (1.2–2.4 s) | 0 | | | So Hades does hit the skip, but only for the 256 MiB ranges it maps after start-up. The worker then pays up to about 15 ms for them, before it executes its next submission (on `main`, that submission's `vkQueueSubmit` paid it). All 8 runs reached the end of their time limit with no crash.
CnRJay commented 2026-10-14 19:11:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T19:11:42Z.


Thanks. The deferral and the counters answer both points, and the table shows Hades does hit the skip.

The new path shows one more cost. touchDmaBufImports waits on its fence (vkWaitForFences, UINT64_MAX) while it holds the GPU mutex. The touch goes to context.queue, the same queue the recorder submits to. On a single hardware queue, the fence signals only after the GPU has finished everything already queued there. On the worker path, that means a full GPU drain before each submission that follows a deferred map, and every other thread that needs the GPU mutex waits behind it. That is probably part of the 15–28 ms "worker's longest copy" in the table, on top of the page mapping itself. The map path has the same wait, so with Silksong's 68–74 touches per run at the map, a guest thread now drains the queue during play.

The cost this PR targets is paid in vkQueueSubmit (the 1.9 s first submit in the description), not in the GPU running a 4-byte copy. So the submit alone should be enough. Wait for the fence only before the command buffer is reused, at the next touch (where it will almost always have signalled already) and in ClearHostImports. The trace line could then time the submit and the wait separately, which would show where the time goes.

Smaller: on the map path, touchDmaBufImports runs after the state.mutex scope has ended, but it still iterates state.imports and uses state.touch. Its comment says it runs under the import state's mutex, and the worker path does take it. Another thread mapping at the same time can change state.imports while this one reads it. Two fixes would work. One is to take state.mutex around the call (GPU mutex first, then state.mutex, as in TouchDeferredDmaBufImports). The other is to collect the buffers under it, as long as an import can't be released without the GPU mutex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6176245121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6176245121). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-14T19:11:42Z. --- Thanks. The deferral and the counters answer both points, and the table shows Hades does hit the skip. The new path shows one more cost. `touchDmaBufImports` waits on its fence (`vkWaitForFences`, `UINT64_MAX`) while it holds the GPU mutex. The touch goes to `context.queue`, the same queue the recorder submits to. On a single hardware queue, the fence signals only after the GPU has finished everything already queued there. On the worker path, that means a full GPU drain before each submission that follows a deferred map, and every other thread that needs the GPU mutex waits behind it. That is probably part of the 15–28 ms "worker's longest copy" in the table, on top of the page mapping itself. The map path has the same wait, so with Silksong's 68–74 touches per run at the map, a guest thread now drains the queue during play. The cost this PR targets is paid in `vkQueueSubmit` (the 1.9 s first submit in the description), not in the GPU running a 4-byte copy. So the submit alone should be enough. Wait for the fence only before the command buffer is reused, at the next touch (where it will almost always have signalled already) and in `ClearHostImports`. The trace line could then time the submit and the wait separately, which would show where the time goes. Smaller: on the map path, `touchDmaBufImports` runs after the `state.mutex` scope has ended, but it still iterates `state.imports` and uses `state.touch`. Its comment says it runs under the import state's mutex, and the worker path does take it. Another thread mapping at the same time can change `state.imports` while this one reads it. Two fixes would work. One is to take `state.mutex` around the call (GPU mutex first, then `state.mutex`, as in `TouchDeferredDmaBufImports`). The other is to collect the buffers under it, as long as an import can't be released without the GPU mutex.
github-actions[bot] commented 2026-10-15 12:11:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:11:27Z.


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
PR 6457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L2559-2560
PR 6479 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L2559-2560
PR 6499 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L274
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L274-275
PR 6678 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp L72-73
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L195-196, L274, L652-655, L735-736, L2297-2298, L2559
docs/dev/ARCHITECTURE.md L112
docs/dev/debt/libSceAgcDriver.md L77-78
PR 6730 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L2559-2560
PR 6763 docs/dev/ARCHITECTURE.md L111-112

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1324 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 1896 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4072 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4449 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4650 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4891 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5431 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5480 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5499 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5761 docs/dev/debt/libSceAgcDriver.md
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ARCHITECTURE.md
docs/dev/debt/libSceAgcDriver.md
PR 6044 docs/dev/ARCHITECTURE.md
PR 6177 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6222 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SparseDmaBufImport.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6252 docs/dev/debt/libSceAgcDriver.md
PR 6259 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6262 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6320 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6412 docs/dev/ARCHITECTURE.md
docs/dev/debt/libSceAgcDriver.md
PR 6447 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6615 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6718 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191736291 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6191736291). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:11:27Z. --- <!-- 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 | |---|---|---|---| | [PR 6457](https://www.github.com/boykopovar/AnyPS5/pull/6457) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` [L2559-2560](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L2559-L2560) | | | | [PR 6479](https://www.github.com/boykopovar/AnyPS5/pull/6479) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` [L2559-2560](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L2559-L2560) | | | | [PR 6499](https://www.github.com/boykopovar/AnyPS5/pull/6499) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` [L274](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L274) | | | | [PR 6548](https://www.github.com/boykopovar/AnyPS5/pull/6548) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` [L274-275](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L274-L275) | | | | [PR 6678](https://www.github.com/boykopovar/AnyPS5/pull/6678) | `core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp` [L72-73](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp#L72-L73)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` [L195-196](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L195-L196), [L274](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L274), [L652-655](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L652-L655), [L735-736](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L735-L736), [L2297-2298](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L2297-L2298), [L2559](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L2559)<br>`docs/dev/ARCHITECTURE.md` [L112](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/docs/dev/ARCHITECTURE.md#L112)<br>`docs/dev/debt/libSceAgcDriver.md` [L77-78](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/docs/dev/debt/libSceAgcDriver.md#L77-L78) | | | | [PR 6730](https://www.github.com/boykopovar/AnyPS5/pull/6730) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` [L2559-2560](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L2559-L2560) | | | | [PR 6763](https://www.github.com/boykopovar/AnyPS5/pull/6763) | `docs/dev/ARCHITECTURE.md` [L111-112](https://github.com/boykopovar/AnyPS5/blob/c84249186528cf14356f9fee51022c3f165ff262/docs/dev/ARCHITECTURE.md#L111-L112) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1324](https://www.github.com/boykopovar/AnyPS5/pull/1324) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 1896](https://www.github.com/boykopovar/AnyPS5/pull/1896) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 4040](https://www.github.com/boykopovar/AnyPS5/pull/4040) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 4072](https://www.github.com/boykopovar/AnyPS5/pull/4072) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 4449](https://www.github.com/boykopovar/AnyPS5/pull/4449) | `core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 4472](https://www.github.com/boykopovar/AnyPS5/pull/4472) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 4891](https://www.github.com/boykopovar/AnyPS5/pull/4891) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 5058](https://www.github.com/boykopovar/AnyPS5/pull/5058) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5441](https://www.github.com/boykopovar/AnyPS5/pull/5441) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5480](https://www.github.com/boykopovar/AnyPS5/pull/5480) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 5761](https://www.github.com/boykopovar/AnyPS5/pull/5761) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`docs/dev/ARCHITECTURE.md`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `docs/dev/ARCHITECTURE.md` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/execution/SparseDmaBufImport.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6252](https://www.github.com/boykopovar/AnyPS5/pull/6252) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6259](https://www.github.com/boykopovar/AnyPS5/pull/6259) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6262](https://www.github.com/boykopovar/AnyPS5/pull/6262) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6320](https://www.github.com/boykopovar/AnyPS5/pull/6320) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `docs/dev/ARCHITECTURE.md`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6718](https://www.github.com/boykopovar/AnyPS5/pull/6718) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` |
hugodearaujo commented 2026-10-15 14:22:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-15T14:22:25Z.


Thanks. Both points went away with a different approach, now in e8b7361a1, rebased on main.

#6060 landed this morning with a settle queue on Windows: settleImport copies 4 bytes out of a new import on a queue of its own and waits for that copy, because the imports lock comes after the GPU mutex and the main queue can't be used there. That is the constraint this PR had, so it now uses that path on Linux instead of the main queue. The settle queue is made when the device imports dma-buf memory, and every dma-buf import of 1 MiB or more is settled right after it is made. Nothing on that path takes the GPU mutex, so nothing is skipped or left to the queue worker, and the fence covers only the copy: the settle queue has no other work, so the recorder's queue is no longer drained. The command pool, the deferred list and the counters from the earlier heads are gone.

What I measured on the old path before switching, since it answers your question about the cost:

  • The page mapping is paid in vkQueueSubmit, as you expected: without the wait, the 3 GiB import's submit took 0.27–1.8 s at the map.
  • Waiting only before reusing the command buffer was not enough for Silksong. Its maps come in bursts while a frame's work is queued, so the next copy found the previous fence unsignalled in 13–15 of the 96–112 copies per run, and waited up to 41 ms under the GPU mutex.

On the smaller point: in 3b7090fa0 the map path did take state.mutex after the GPU mutex, right before the call (GuestBufferMemory.cpp:2501), but that code is gone now.

A correction to my last reply: "All 8 runs reached the end of their time limit with no crash" left out that two Silksong runs and one ASTRO BOT run then crashed at exit, after SIGTERM. Those are the known exit crashes (#5614, #5864), not this path.

The description has the numbers for the new head: in runs alternating with main, Hades stopped in 12 of 12 runs on main and in 0 of 12 with this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194363933 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6194363933). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-15T14:22:25Z. --- Thanks. Both points went away with a different approach, now in e8b7361a1, rebased on `main`. #6060 landed this morning with a settle queue on Windows: `settleImport` copies 4 bytes out of a new import on a queue of its own and waits for that copy, because the imports lock comes after the GPU mutex and the main queue can't be used there. That is the constraint this PR had, so it now uses that path on Linux instead of the main queue. The settle queue is made when the device imports dma-buf memory, and every dma-buf import of 1 MiB or more is settled right after it is made. Nothing on that path takes the GPU mutex, so nothing is skipped or left to the queue worker, and the fence covers only the copy: the settle queue has no other work, so the recorder's queue is no longer drained. The command pool, the deferred list and the counters from the earlier heads are gone. What I measured on the old path before switching, since it answers your question about the cost: - The page mapping is paid in `vkQueueSubmit`, as you expected: without the wait, the 3 GiB import's submit took 0.27–1.8 s at the map. - Waiting only before reusing the command buffer was not enough for Silksong. Its maps come in bursts while a frame's work is queued, so the next copy found the previous fence unsignalled in 13–15 of the 96–112 copies per run, and waited up to 41 ms under the GPU mutex. On the smaller point: in 3b7090fa0 the map path did take `state.mutex` after the GPU mutex, right before the call (`GuestBufferMemory.cpp:2501`), but that code is gone now. A correction to my last reply: "All 8 runs reached the end of their time limit with no crash" left out that two Silksong runs and one ASTRO BOT run then crashed at exit, after SIGTERM. Those are the known exit crashes (#5614, #5864), not this path. The description has the numbers for the new head: in runs alternating with `main`, Hades stopped in 12 of 12 runs on `main` and in 0 of 12 with this PR.
hugodearaujo commented 2026-10-15 15:14:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-15T15:14:32Z.


A second title that needs this: ASTRO BOT (PPSA21567). On main, right after it maps its largest ranges (4.5 GiB at 0x10ca000000, and in one run 3.2 GiB at 0x1000000000), the first graphics-queue submission that uses them pays the page mapping. Compute queues 0x40 and 0x48 wait on that queue's labels, and their WAIT_REG_MEM_64 gives up after 1000 ms:

[gpu] host import of 0x10ca000000+0x120000000 ok (3 live, 6964.0 MiB live, 6964.0 MiB ever)
...
[gpu] queue 0x48 WAIT_REG_MEM_64 at 0x400202d80 timed out after 1000ms (function 3 ref 0x1 mask 0xffffffff value 0x0)
[gpu] queue 0x40 WAIT_REG_MEM_64 at 0x400202d00 timed out after 1000ms (function 3 ref 0x1 mask 0xffffffff value 0x0)

60 s runs from launch with no input, RX 9070 XT (RADV), APS5_TRACE_HOST_IMPORT=1:

build runs runs with a timeout timeouts
main (4224d240a) 4 4 10
this PR on 4224d240a 2 0 0
this PR with #5390 and #5614 on ff23657f3 3 0 0

With this PR the same imports are settled at the map (the 4.5 GiB one in 0.5–4.3 s), and no queue waits past its timeout.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195486809 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6195486809). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-15T15:14:32Z. --- A second title that needs this: ASTRO BOT (PPSA21567). On `main`, right after it maps its largest ranges (4.5 GiB at `0x10ca000000`, and in one run 3.2 GiB at `0x1000000000`), the first graphics-queue submission that uses them pays the page mapping. Compute queues `0x40` and `0x48` wait on that queue's labels, and their `WAIT_REG_MEM_64` gives up after 1000 ms: ``` [gpu] host import of 0x10ca000000+0x120000000 ok (3 live, 6964.0 MiB live, 6964.0 MiB ever) ... [gpu] queue 0x48 WAIT_REG_MEM_64 at 0x400202d80 timed out after 1000ms (function 3 ref 0x1 mask 0xffffffff value 0x0) [gpu] queue 0x40 WAIT_REG_MEM_64 at 0x400202d00 timed out after 1000ms (function 3 ref 0x1 mask 0xffffffff value 0x0) ``` 60 s runs from launch with no input, RX 9070 XT (RADV), `APS5_TRACE_HOST_IMPORT=1`: | build | runs | runs with a timeout | timeouts | |---|---|---|---| | `main` (`4224d240a`) | 4 | 4 | 10 | | this PR on `4224d240a` | 2 | 0 | 0 | | this PR with #5390 and #5614 on `ff23657f3` | 3 | 0 | 0 | With this PR the same imports are settled at the map (the 4.5 GiB one in 0.5–4.3 s), and no queue waits past its timeout.
CnRJay commented 2026-10-15 18:20:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-15T18:20:57Z.


The settle queue is the right home for this. The fence covers only the copy, nothing waits on the GPU mutex, and the recorder's queue is no longer drained. The ASTRO BOT WAIT_REG_MEM_64 timeouts are a more convincing case than the Hades stall alone. Thanks for measuring the fence-reuse variant too: 13–15 waits of up to 41 ms per Silksong run shows why waiting only before reuse wasn't enough.

One thing worth saying in the description: the 0.5–4.3 s for the 4.5 GiB import is now paid by the guest thread inside its map call, where on main it landed in a submission. At load time that's the better place. A title that maps large ranges during gameplay would see that thread block for the same time, so a line in the debt entry would help whoever traces such a stall later.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6199203546 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6199203546). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-15T18:20:57Z. --- The settle queue is the right home for this. The fence covers only the copy, nothing waits on the GPU mutex, and the recorder's queue is no longer drained. The ASTRO BOT `WAIT_REG_MEM_64` timeouts are a more convincing case than the Hades stall alone. Thanks for measuring the fence-reuse variant too: 13–15 waits of up to 41 ms per Silksong run shows why waiting only before reuse wasn't enough. One thing worth saying in the description: the 0.5–4.3 s for the 4.5 GiB import is now paid by the guest thread inside its map call, where on `main` it landed in a submission. At load time that's the better place. A title that maps large ranges during gameplay would see that thread block for the same time, so a line in the debt entry would help whoever traces such a stall later.
jotitadev commented 2026-10-15 22:16:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T22:16:08Z.

Review: COMMENTED


Linux results on NVIDIA and lavapipe. On both, the new path is not taken and the two new checks in agc_driver_sparse_dma_buf_import do not run.

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release, BUILD_TESTING=ON. Head e8b7361a1 merged onto main 31cbb55d7, no conflicts. /dev/udmabuf is accessible and size_limit_mb is 64. ANYPS5_GPU="NVIDIA GeForce RTX 3070", confirmed in the logs.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux; llvmpipe (Mesa 26.0.3), Linux

  • RTX 3070: dmaBufImport is false on the proprietary driver (VulkanDevice.cpp excludes VK_DRIVER_ID_NVIDIA_PROPRIETARY, and this driver does not expose VK_EXT_external_memory_dma_buf anyway). So settles is false, no settle queue is created, and the test prints note: the device has no settle queue, so dma-buf imports are not settled and passes. The imports in that test go through host pointers here. This is not a regression, just a path this device never takes. The graphics family has 16 queues, so the device would get a settle queue if it imported dma-bufs.
  • llvmpipe (VK_DRIVER_FILES set to the lavapipe ICD only): lavapipe does expose VK_EXT_external_memory_dma_buf, but it has a single queue family with one queue. So no settle queue is created there either, and the test prints the same note and passes. The fork CI runs on lavapipe, so CI does not exercise the two HostImportsSettled checks.
  • agc_driver_sparse_dma_buf_import, agc_host_import_sparse, agc_host_import_retire and agc_driver_host_import_at_map pass 3/3 with this PR and 2/2 on main, with APS5_TRACE_HOST_IMPORT=1.
  • ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 60: 591/593 pass, the same as unchanged main here. agc_driver_stencil_ref_export is skipped (no VK_EXT_shader_stencil_export), and agc_driver_store_over_untracked fails as it does on main (#6385).

So far only the RADV run in the description covers the settle itself.

Written with AI assistance (Claude Code). I ran the tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5540589696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#pullrequestreview-5540589696). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T22:16:08Z. **Review:** COMMENTED --- Linux results on NVIDIA and lavapipe. On both, the new path is not taken and the two new checks in `agc_driver_sparse_dma_buf_import` do not run. **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release, `BUILD_TESTING=ON`. Head `e8b7361a1` merged onto `main` `31cbb55d7`, no conflicts. `/dev/udmabuf` is accessible and `size_limit_mb` is 64. `ANYPS5_GPU="NVIDIA GeForce RTX 3070"`, confirmed in the logs. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux; llvmpipe (Mesa 26.0.3), Linux - **RTX 3070:** `dmaBufImport` is false on the proprietary driver (`VulkanDevice.cpp` excludes `VK_DRIVER_ID_NVIDIA_PROPRIETARY`, and this driver does not expose `VK_EXT_external_memory_dma_buf` anyway). So `settles` is false, no settle queue is created, and the test prints `note: the device has no settle queue, so dma-buf imports are not settled` and passes. The imports in that test go through host pointers here. This is not a regression, just a path this device never takes. The graphics family has 16 queues, so the device would get a settle queue if it imported dma-bufs. - **llvmpipe** (`VK_DRIVER_FILES` set to the lavapipe ICD only): lavapipe does expose `VK_EXT_external_memory_dma_buf`, but it has a single queue family with one queue. So no settle queue is created there either, and the test prints the same note and passes. The fork CI runs on lavapipe, so CI does not exercise the two `HostImportsSettled` checks. - `agc_driver_sparse_dma_buf_import`, `agc_host_import_sparse`, `agc_host_import_retire` and `agc_driver_host_import_at_map` pass 3/3 with this PR and 2/2 on `main`, with `APS5_TRACE_HOST_IMPORT=1`. - `ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 60`: 591/593 pass, the same as unchanged `main` here. `agc_driver_stencil_ref_export` is skipped (no `VK_EXT_shader_stencil_export`), and `agc_driver_store_over_untracked` fails as it does on `main` (#6385). So far only the RADV run in the description covers the settle itself. Written with AI assistance (Claude Code). I ran the tests above on my machine.
hugodearaujo commented 2026-10-16 11:29:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-16T11:29:49Z.


@CnRJay Done in 9bd554a64. The debt entry (Settled dma-buf imports) and the description now say that an import made at map time settles inside the guest's map call, so the mapping thread waits while the kernel maps the pages: 0.47 to 2.2 s for Hades' 3 GiB range and 0.49 and 4.3 s for ASTRO BOT's 4.5 GiB range in the measured runs. Both titles map these ranges at start-up, and the entry says that a title mapping large ranges during gameplay stalls its mapping thread for as long.

@jotitadev Thanks for running it on both. Your results led to one more fix in the same commit. createImport tries a host-pointer import first and uses dma-buf only when that fails, and lavapipe accepts host pointers for shared memory; on #5390 that broke a lead check. The settle applies only to dma-buf imports, so on a device that has a settle queue and imports shared memory through host pointers, the two HostImportsSettled checks would have failed. The test now expects a settle only for a dma-buf import and prints a note otherwise. Neither of your devices reaches that case, since neither has a settle queue, but a device with more queues that accepts host pointers would. ANV on Intel may be one; I could not check that.

I ran it again on RADV and with lavapipe from Mesa 26.2.4. On RADV both settle checks run and pass 3 of 3, and with the settle call removed the test fails at the first of them. Under lavapipe it passes 3 of 3 with the note that there is no settle queue, as you saw. The 21 tests matching ^agc.*(import|dma|sparse|shadow|unit) pass on both, except agc_shadowed_key_stores, which skips on both. So the settle itself is still covered only on RADV, as you said.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6214523693 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6214523693). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-16T11:29:49Z. --- @CnRJay Done in 9bd554a64. The debt entry (Settled dma-buf imports) and the description now say that an import made at map time settles inside the guest's map call, so the mapping thread waits while the kernel maps the pages: 0.47 to 2.2 s for Hades' 3 GiB range and 0.49 and 4.3 s for ASTRO BOT's 4.5 GiB range in the measured runs. Both titles map these ranges at start-up, and the entry says that a title mapping large ranges during gameplay stalls its mapping thread for as long. @jotitadev Thanks for running it on both. Your results led to one more fix in the same commit. `createImport` tries a host-pointer import first and uses dma-buf only when that fails, and lavapipe accepts host pointers for shared memory; on #5390 that broke a lead check. The settle applies only to dma-buf imports, so on a device that has a settle queue and imports shared memory through host pointers, the two `HostImportsSettled` checks would have failed. The test now expects a settle only for a dma-buf import and prints a note otherwise. Neither of your devices reaches that case, since neither has a settle queue, but a device with more queues that accepts host pointers would. ANV on Intel may be one; I could not check that. I ran it again on RADV and with lavapipe from Mesa 26.2.4. On RADV both settle checks run and pass 3 of 3, and with the settle call removed the test fails at the first of them. Under lavapipe it passes 3 of 3 with the note that there is no settle queue, as you saw. The 21 tests matching `^agc.*(import|dma|sparse|shadow|unit)` pass on both, except `agc_shadowed_key_stores`, which skips on both. So the settle itself is still covered only on RADV, as you said.
adriadam10 commented 2026-10-16 12:14:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T12:14:39Z.


Checked the settle-queue selection on Linux (second queue of the main family, or another copy-capable family), the concurrent sharing of dma-buf import buffers with the settle family, that the Windows path is unchanged apart from the moved #ifdefs, and the debt/ARCHITECTURE entries (the map-time stall is documented). Build and AgcDriver ctest on RADV pass (agc_driver_tessellation crashes, reported as failing on main too); agc_driver_sparse_dma_buf_import fails to build without the change. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6215278394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6215278394). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T12:14:39Z. --- Checked the settle-queue selection on Linux (second queue of the main family, or another copy-capable family), the concurrent sharing of dma-buf import buffers with the settle family, that the Windows path is unchanged apart from the moved `#ifdef`s, and the debt/ARCHITECTURE entries (the map-time stall is documented). Build and AgcDriver ctest on RADV pass (`agc_driver_tessellation` crashes, reported as failing on `main` too); `agc_driver_sparse_dma_buf_import` fails to build without the change. Merging once the full Build is green.
adriadam10 commented 2026-10-16 18:03:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:03:48Z.


Re-checked against current main (93e54cedd, includes #5950): merges cleanly, AgcDriver build and ctest pass on RADV (agc_driver_sparse_dma_buf_import passes; agc_driver_tessellation crashes, reported as failing on main too). Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221674404 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5905#issuecomment-6221674404). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T18:03:48Z. --- Re-checked against current `main` (93e54cedd, includes #5950): merges cleanly, AgcDriver build and ctest pass on RADV (`agc_driver_sparse_dma_buf_import` passes; `agc_driver_tessellation` crashes, reported as failing on `main` too). Merging once the 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!5905
No description provided.