Skip to content

test(agc): load the Vulkan loader with portability enumeration on macOS - #7886

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
jotitadev:fix/agc-tests-vulkan-loader-macos
Oct 24, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
jotitadev:fix/agc-tests-vulkan-loader-macos

Conversation

@jotitadev

Copy link
Copy Markdown
Contributor

What

Nine AGC test fixtures create their own Vulkan instance instead of going through VulkanDevice: PresentationPass.cpp, PerformanceOverlay.cpp and, under tests/execution/, DepthPlaneGuestLayers.cpp, DepthStorage.cpp, DepthSurfaceLastWriter.cpp, NativeMultisampleDepth.cpp, PartiallyResidentSnapshot.cpp, PooledBufferRange.cpp and SparseBufferHoles.cpp. On macOS they load libvulkan.so.1, which doesn't exist there, so they print skipped, no usable Vulkan device: AGC graphics: cannot load Vulkan and ctest counts them as skipped. A libvulkan.so.1 symlink isn't enough: without VK_KHR_portability_enumeration the loader doesn't list MoltenVK and vkCreateInstance returns -9 (VK_ERROR_INCOMPATIBLE_DRIVER).

On __APPLE__ they now load libvulkan.1.dylib and create the instance with VK_KHR_portability_enumeration and VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR. This is the same change mugurc's macOS series makes to BdaDevice.cpp, Recorder.cpp, OversizedDescriptorSets.cpp and SampledCacheBudget.cpp (#1, branch ci/macos-series-2, commit 20ee39d). These nine fixtures aren't covered there, and the current head of #7332 doesn't cover them either. Windows and Linux are unchanged.

I noticed this while validating #6557: its new test case in NativeMultisampleDepth.cpp never ran on macOS.

Tested

Apple M2 Max, macOS 27.2, x86-64 build under Rosetta 2, Xcode 27. main doesn't build on macOS yet, so the tree is main a373e85 + mugurc's ci/macos-series-2 91e4ecc + #6667, #6668, #7524 and #6969, + two files of #7332 (DirectMemory/Jit.cpp, tests/GuestMemoryLifetimeSupport.hpp), with this commit's diff applied cleanly on top. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704. Run with -j1 --timeout 30.

11 ctest entries use these fixtures. Before this change all 11 were skipped. With it:

test before after
agc_driver_presentation_pass skipped passes
agc_performance_overlay_device_selection skipped passes
agc_driver_depth_plane_guest_layers skipped passes
agc_driver_depth_storage skipped passes
agc_driver_depth_surface_last_writer skipped passes
agc_driver_native_multisample_depth skipped passes (8 cases checked, 4 unavailable: no 8x depth on this GPU)
agc_driver_partially_resident_snapshot skipped passes
agc_driver_partially_resident_pending_stores skipped passes
agc_driver_sparse_buffer_holes skipped passes
agc_performance_overlay skipped fails: the process's private memory cannot be read
agc_driver_pooled_buffer_range skipped fails: a robust read of word 28 of a 100-byte pooled buffer returned 0xabababab, the bytes a 256-byte earlier user left in its memory

Results are the same on both drivers, and 3 of 3 with --repeat until-fail:3 on MoltenVK 1.4.2.

The two failures were already there; the tests just weren't running:

  • agc_performance_overlay fails the same way agc_performance_overlay_statistics already fails on macOS. ReadProcessPrivateBytes reads /proc/self/status on every host that isn't Windows. Locally, reading task_info(TASK_VM_INFO).phys_footprint on macOS made it pass. feat: macOS on Apple Silicon host support (Rosetta 2 and MoltenVK) #7332 already has that fix, so it is left out of this PR.
  • agc_driver_pooled_buffer_range: MoltenVK reports robustBufferAccess, but the read past the end of a 100-byte buffer still returns bytes from the pooled memory behind it. So the test catches the stale data on Apple. This is MoltenVK behaviour and isn't changed here.

python3 tools/check_conventions.py --base origin/main passes.

Checklist

🤖 Generated with Claude Code

Nine AGC test fixtures create their own Vulkan instance. On macOS they
asked for libvulkan.so.1 and created the instance without
VK_KHR_portability_enumeration, so the loader was not found (and with it,
MoltenVK would not be listed). Each test then printed "skipped, no usable
Vulkan device" and ctest counted it as passed.

They now load libvulkan.1.dylib on macOS and create the instance with
VK_KHR_portability_enumeration and
VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR. Other hosts are
unchanged.
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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 6300 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/PresentationPass.cpp
PR 9533 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 9717 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 9742 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/PresentationPass.cpp

ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 19, 2026
Jotitadev identified nine fixtures that silently skipped MoltenVK because they loaded the Linux Vulkan soname or omitted portability enumeration. Preserve the authored change in this branch so the tests exercise Apple GPUs and expose actual host limitations.
@github-actions github-actions Bot added the agc libSceAgc* label Oct 19, 2026
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 19, 2026
agc_driver_pooled_buffer_range used to skip on macOS for want of a
device; since the fixture enumerates MoltenVK through the portability
loader (boykopovar#7886) it runs, and it fails its robust read past the end of a
pooled buffer: MoltenVK bounds the read by the Metal buffer that holds
the pooled block, not by the VkBuffer range, so it returns what an
earlier user of the block left there. The behaviour and the unmeasured
cost of clearing a reused block's slack are recorded until a fix is
weighed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tkcm01

tkcm01 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Apple M4 data point for head 82059bed3.

Setup: Apple M4 (10-core GPU), macOS 27.0.1, Apple clang 21, x86-64 under Rosetta 2. MoltenVK 1.4.2 and the loader from the Vulkan SDK 1.4.363.0, through VK_DRIVER_FILES. Tree: mugurc's ci/macos-series-2 at 53db0ba (main 3fd1cc3) with #7524, the code of #7937 and the libSceSsl change of #7332, my local macOS fixes from #1, and this commit cherry-picked unchanged. It also has #9971, so agc_performance_overlay can read the RAM line; without #9971 that test fails at the process's private memory cannot be read.

Without this commit (same tree, full ctest -j4): all 14 ctest entries that use the nine fixtures skip with cannot load Vulkan.

With it, ctest -V on those 14 entries with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 13 pass.

  • agc_driver_pooled_buffer_range fails as on your M2 Max: a robust read of word 28 of a 100-byte pooled buffer returned 0xabababab, the bytes a 256-byte earlier user left in its memory.
  • The same 14 pass and fail the same way in two more full -j4 runs.

Validation: no was not found but was requested by env var VK_INSTANCE_LAYERS. Every one of the 14 logs VUID-VkDeviceCreateInfo-pProperties-04451 twice. These fixtures enumerate the portability driver but don't enable VK_KHR_portability_subset, which the spec requires once the device lists it. Because the subset isn't enabled, agc_driver_native_multisample_depth and the three agc_driver_native_depth_* entries also log VUID-VkImageViewCreateInfo-imageViewFormatSwizzle-04465 (swizzle is disabled for this device), twice each. They still pass. Adding VK_KHR_portability_subset to the device extensions where vkEnumerateDeviceExtensionProperties lists it would probably clear both. I haven't tried that.

Not tested: Linux or Windows; an exact-head build on current main (it doesn't link on macOS).

AI-assisted: yes

@jotitadev

Copy link
Copy Markdown
Contributor Author

Thanks. I tried enabling VK_KHR_portability_subset in the nine fixtures (M2 Max, macOS 27.2, #8658 @ 91adbf7 + this commit, MoltenVK 1.4.2, validation layer): 04451 goes away for the fixture devices, but the layer then reports imageViewFormatSwizzle-04465 and imageViewFormatReinterpretation-04466, because the subset features stay disabled. Chaining a queried VkPhysicalDevicePortabilitySubsetFeaturesKHR clears those (tried in two fixtures), which needs VK_ENABLE_BETA_EXTENSIONS, so I'm leaving it out of this PR; the driver's own device on #8658 also logs 04451. Results are unchanged either way.

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

@adriadam10 adriadam10 self-assigned this Oct 23, 2026
@maximilianfv

Copy link
Copy Markdown
Contributor

Tested at 82059bed3 on Apple M1 Pro, macOS 27.0.1 (x86_64 build under Rosetta 2, MoltenVK from the LunarG Vulkan SDK 1.4.363)

Applied to mugurc's macOS series (27e968974) merged with main at 1e20650e84, with other open macOS fixes, then toggled only this PR. Both runs: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R 'performance_overlay|presentation_pass|depth_plane_guest_layers|depth_storage|depth_surface_last_writer|native_multisample_depth|partially_resident_snapshot|pooled_buffer_range|sparse_buffer_holes' (16 tests).

passed
Without this PR 5 of 16: the 11 tests whose own instance this PR changes fail with cannot load Vulkan
With this PR 13 of 16

The three that still fail with this PR run into other gaps:

  • agc_performance_overlay and agc_performance_overlay_statistics: the process's private memory cannot be read, which fix(agc): read the process's private memory from task_info on macOS #9971 addresses.
  • agc_driver_pooled_buffer_range: a robust read of word 28 of a 100-byte pooled buffer returned 0xabababab, the bytes a 256-byte earlier user left in its memory, a MoltenVK robust-access difference.

Validation: the layer loaded (no was not found but was requested line). The run logs 10 VUID-VkDeviceCreateInfo-pProperties-04451 (devices created without VK_KHR_portability_subset) and 1 VUID-VkImageViewCreateInfo-imageViewFormatSwizzle-04465 from agc_driver_native_multisample_depth, which only runs with this PR.

Two more test files on current main load only libvulkan.so.1 and so fail on macOS with cannot load Vulkan: tests/GuestMemoryLifetimeSupport.hpp (the six agc_driver_guest_memory_lifetime* tests) and tests/execution/IndirectArgumentsPendingProducer.cpp. They use the driver's device, so they need only the loader name, not the instance flag. With that added here, those seven tests pass.

AI-assisted: yes (Claude Code applied the PR, ran the tests both ways and wrote this report).

@adriadam10
adriadam10 merged commit e4bb5fc into boykopovar:main Oct 24, 2026
11 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked that the nine fixture changes are identical and confined to __APPLE__, so Linux and Windows are unchanged, and that they still apply cleanly on current main after the DepthStorage.cpp change. macOS results confirmed by @tkcm01 (M4) and @maximilianfv (M1 Pro) as well as the M2 Max runs; the VK_KHR_portability_subset VUIDs and the two pre-existing failures are out of scope; merged.

adriadam10 pushed a commit that referenced this pull request Oct 28, 2026
ReadProcessPrivateBytes reads RssAnon and VmSwap from /proc/self/status
on every host other than Windows. macOS has no /proc, so the overlay's
RAM line stays empty and agc_performance_overlay_statistics fails with
"the process's private memory cannot be read". On macOS it now returns
the task's phys_footprint from task_info(TASK_VM_INFO): its resident and
compressed private memory, which is what Activity Monitor shows.

jotitadev measured that this makes the test pass on macOS (#7886).
The same change is part of the macOS port in #8658.

Co-Authored-By: iamthehimansh <67262056+iamthehimansh@users.noreply.github.com>
Co-Authored-By: jotitadev <139649225+jotitadev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tkcm01 added a commit to tkcm01/AnyPS5 that referenced this pull request Oct 29, 2026
…r more fixtures on macOS

BdaDevice, Recorder, OversizedDescriptorSets and SampledCacheBudget open
their own Vulkan instance but load only libvulkan.so.1 outside Windows and
create it without portability enumeration, so on macOS they cannot load
Vulkan and skip, or fail under ANYPS5_REQUIRE_VULKAN=1. They now load
libvulkan.1.dylib and enumerate portability drivers on macOS, as the nine
fixtures boykopovar#7886 changed already do.

Co-authored-by: mugurc <20699965+mugurc@users.noreply.github.com>
Co-authored-by: jermainee <34961982+jermainee@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tkcm01 added a commit to tkcm01/AnyPS5 that referenced this pull request Oct 29, 2026
…r more fixtures on macOS

BdaDevice, Recorder, OversizedDescriptorSets and SampledCacheBudget open
their own Vulkan instance but load only libvulkan.so.1 outside Windows and
create it without portability enumeration, so on macOS they cannot load
Vulkan and skip, or fail under ANYPS5_REQUIRE_VULKAN=1. They now load
libvulkan.1.dylib and enumerate portability drivers on macOS, as the nine
fixtures boykopovar#7886 changed already do.

Co-authored-by: mugurc <20699965+mugurc@users.noreply.github.com>
Co-authored-by: jermainee <34961982+jermainee@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants