fix(agc): import shared direct memory as dma-buf without VK_EXT_external_memory_host #16474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16474"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Rad0van on 2026-11-06T19:45:20Z.
What
The guest memory import machinery (import alignment, import window and size limit, and the dma-buf import of shared direct memory) was enabled only when the device exposes
VK_EXT_external_memory_host. Linux drivers that haveVK_KHR_external_memory_fdandVK_EXT_external_memory_dma_bufbut no host pointer import (Honeykrisp, the Asahi Linux Vulkan driver for Apple GPUs) therefore never imported anything: every guest range was copied, and GPU stores through FLAT/GLOBAL addresses into direct memory failed withBDA access failed ... read-only in the BDA table.The machinery is now enabled when either import is available:
hostPointerImport(new, in the device state andGraphics::Context) records whetherVK_EXT_external_memory_hostis usable;dmaBufImportis decided independently of it.VK_EXT_external_memory_hostis not requested, and importable GDS is not requested.createHostPointerImportfails up front when host pointer import is unavailable, socreateImportfalls through to the existing udmabuf backing import (createBackingImport).Graphics::Context::hostPointerImportdefaults totrue, so contexts built by tests keep their behaviour;APS5_NO_HOST_IMPORTstill disables both imports.Related, no dependency: #2434 changes the order of the two imports when both exist; it does not touch this gate.
Tested
Ubuntu 26.04 (Asahi Linux, kernel 7.2.0-1001-asahi-arm), Apple M2 Max. The host is aarch64, so the libraries were cross-compiled with Ubuntu's
g++-15-x86-64-linux-gnu(GCC 15.2) and the x86-64 test executables run under FEX 2610 inside muvm 0.7 (4 KiB pages), with Vulkan forwarded to the native Honeykrisp driver (Mesa 26.0.8) through FEX thunks. Build-time tools (glslang, nid_patcher, relinker, the SQLite generators) were native aarch64 builds of the same sources.Focused tests, same machine and GPU,
main(9f2b939) and this change on top of it (the branch was then rebased onto7b7edf6; none of the 27 new commits touch these files),ctest -R '^agc_.*(import|shared_write|guest_memory_lifetime|bda_device)' -E windows -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(layer 1.4.341):was not found but was requested by env var VK_INSTANCE_LAYERS; neither log contains aVUID-validation error.main: 11 passed, 27 skipped, 2 failed. This change: 11 passed, 24 skipped, 5 failed.agc_host_import_sparse(its mock device table has novkCmdFillBuffer),agc_driver_guest_memory_lifetime_converted(the converted executable it starts picks up the emulator's glibc 2.42; environment).agc_driver_msaa_dcc_compared_import_{2,4,8}were skipped onmain(the device imports no host memory) and now run; they stop atRequire(GuestMemory::WriteWatched())because neither FEX nor Box64 implementsuserfaultfd, so the guest arena is not write-watched in this environment. That check precedes and does not depend on this change.Homebrew: DOOM (PPSA99666, AGC compute presentation) relinked with
main's relinker, 30 s, no Vulkan layer,VK_EXT_external_memory_host: extension optional missingin the host report:main: 57BDA access failedwrite-backs into the display buffer (0x200c00000+0x2000000); the frame is not updated.[write-watch] ... dma-buf imports are CPU-coherent (0 of 4 pages stale after a GPU store over CPU writes).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by mashingaan on 2026-11-08T10:47:11Z.
Review: APPROVED
The hostPointerImport/dmaBufImport split is clean, the dma-buf path no longer requires VK_EXT_external_memory_host, and the probe is skipped when host pointer import is unavailable. The Windows and Linux runs plus the DOOM dma-buf check cover the restructure. No findings.