vulkan: Only enable KHR_portability_enumeration when available

This commit is contained in:
Ethan Lee
2026-02-20 10:31:53 -05:00
parent 1223767b2c
commit fa9bad2e4b
2 changed files with 71 additions and 11 deletions

View File

@@ -1171,6 +1171,7 @@ struct VulkanRenderer
bool supportsDebugUtils;
bool supportsColorspace;
bool supportsPhysicalDeviceProperties2;
bool supportsPortabilityEnumeration;
bool supportsFillModeNonSolid;
bool supportsMultiDrawIndirect;
@@ -11153,6 +11154,7 @@ static Uint8 VULKAN_INTERNAL_CheckInstanceExtensions(
bool *supportsDebugUtils,
bool *supportsColorspace,
bool *supportsPhysicalDeviceProperties2,
bool *supportsPortabilityEnumeration,
int *firstUnsupportedExtensionIndex)
{
Uint32 extensionCount, i;
@@ -11199,6 +11201,12 @@ static Uint8 VULKAN_INTERNAL_CheckInstanceExtensions(
availableExtensions,
extensionCount);
// Only needed for MoltenVK!
*supportsPortabilityEnumeration = SupportsInstanceExtension(
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME,
availableExtensions,
extensionCount);
SDL_free(availableExtensions);
return allExtensionsSupported;
}
@@ -11824,13 +11832,6 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer, VulkanFeat
nextInstanceExtensionNamePtr += extraInstanceExtensionCount;
}
#ifdef SDL_PLATFORM_APPLE
*nextInstanceExtensionNamePtr++ = VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME;
instanceExtensionCount++;
createFlags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
#endif
int firstUnsupportedExtensionIndex = 0;
if (!VULKAN_INTERNAL_CheckInstanceExtensions(
instanceExtensionNames,
@@ -11838,6 +11839,7 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer, VulkanFeat
&renderer->supportsDebugUtils,
&renderer->supportsColorspace,
&renderer->supportsPhysicalDeviceProperties2,
&renderer->supportsPortabilityEnumeration,
&firstUnsupportedExtensionIndex)) {
if (renderer->debugMode) {
SDL_LogError(SDL_LOG_CATEGORY_GPU,
@@ -11873,6 +11875,12 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer, VulkanFeat
instanceExtensionCount++;
}
if (renderer->supportsPortabilityEnumeration) {
*nextInstanceExtensionNamePtr++ = VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME;
instanceExtensionCount++;
createFlags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
}
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.pNext = NULL;
createInfo.flags = createFlags;