Vulkan: Ask for portability drivers on Mac

Through the Khronos loader (like the Vulkan SDK's, needed for the
validation layers), MoltenVK is only listed if the instance enables
VK_KHR_portability_enumeration. Without it, instance creation failed with
VK_ERROR_INCOMPATIBLE_DRIVER and we fell back to OpenGL. Loading MoltenVK
directly, as the app normally does, works as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-22 18:46:43 +02:00
1 parent 679d804c26
commit db6cc41b9d
2 files changed
+19

No files matched your search

+9
View File
@@ -239,6 +239,15 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
#if PPSSPP_VK_STATIC
inst_info.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
#elif PPSSPP_PLATFORM(MAC)
// Through the Khronos loader (like the SDK's, for the validation layers), MoltenVK is only
// listed if we ask for portability drivers.
if (IsInstanceExtensionAvailable(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME)) {
instance_extensions_enabled_.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
inst_info.enabledExtensionCount = (uint32_t)instance_extensions_enabled_.size();
inst_info.ppEnabledExtensionNames = instance_extensions_enabled_.data();
inst_info.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
}
#endif
#if SIMULATE_VULKAN_FAILURE == 2
+10
View File
@@ -494,6 +494,7 @@ bool VulkanMayBeAvailable() {
std::vector<VkPhysicalDevice> devices;
bool anyGood = false;
const char *instanceExtensions[10]{};
bool portabilityFound = false;
VkInstance instance = VK_NULL_HANDLE;
VkResult res = VK_SUCCESS;
uint32_t physicalDeviceCount = 0;
@@ -544,6 +545,11 @@ bool VulkanMayBeAvailable() {
platformSurfaceExtensionFound = true;
// Note: Can't stop here - the enumeration order isn't specified anywhere, so VK_KHR_surface
// may well come after the platform one, and we need both.
#if PPSSPP_PLATFORM(MAC)
} else if (!strcmp(iter.extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME)) {
// See VulkanContext::CreateInstance.
portabilityFound = true;
#endif
} else if (!strcmp(iter.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) {
instanceExtensions[ci.enabledExtensionCount++] = VK_KHR_SURFACE_EXTENSION_NAME;
surfaceExtensionFound = true;
@@ -576,6 +582,10 @@ bool VulkanMayBeAvailable() {
info.pEngineName = "VulkanCheckerEngine";
ci.pApplicationInfo = &info;
ci.flags = 0;
if (portabilityFound) {
instanceExtensions[ci.enabledExtensionCount++] = VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME;
ci.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
}
INFO_LOG(Log::G3D, "VulkanMayBeAvailable: Calling vkCreateInstance");
res = localCreateInstance(&ci, nullptr, &instance);
if (res != VK_SUCCESS) {