From 23044c8e43a7b900d556b09079c1b1c2660b05a0 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 19 Apr 2022 16:28:47 -0400 Subject: [PATCH 1/2] Enable VK_KHR_portability_enumeration for macOS on Vulkan SDK 1.3.211.0 or later --- neo/renderer/Vulkan/RenderBackend_VK.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index f147ba01..0e47dad8 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -309,8 +309,15 @@ static void CreateVulkanInstance() { vkcontext.instanceExtensions.AddUnique( VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME ); vkcontext.deviceProperties2Available = true; - break; } +#if defined(__APPLE__) && defined( VK_KHR_portability_enumeration ) + // SRS - Enable physical device enumeration when using the Vulkan loader on macOS (MoltenVK portability driver) + if( idStr::Icmp( instanceExtensionProps[ i ].extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME ) == 0 ) + { + vkcontext.instanceExtensions.AddUnique( VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME ); + createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR; + } +#endif } vkcontext.debugUtilsSupportAvailable = false; From 511e18d9fd23c4e09184376495b12a388d5319cd Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Wed, 30 Mar 2022 17:01:56 -0400 Subject: [PATCH 2/2] Check Vulkan header version for macro compatibility, improve VkPhysicalDeviceProperties2 variable names (cherry picked from commit 6399dc2a48829ea25be649213cc059d5bfd1b379) --- neo/renderer/Vulkan/RenderBackend_VK.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index 0e47dad8..1c26b34c 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -750,7 +750,12 @@ static void SelectPhysicalDevice() static idStr version_string; version_string.Clear(); +#if VK_HEADER_VERSION >= 176 version_string.Append( va( "Vulkan API %i.%i.%i", VK_API_VERSION_MAJOR( gpu.props.apiVersion ), VK_API_VERSION_MINOR( gpu.props.apiVersion ), VK_API_VERSION_PATCH( gpu.props.apiVersion ) ) ); +#else + // SRS - Allow deprecated version macros on older Vulkan SDKs < 1.2.176 + version_string.Append( va( "Vulkan API %i.%i.%i", VK_VERSION_MAJOR( gpu.props.apiVersion ), VK_VERSION_MINOR( gpu.props.apiVersion ), VK_VERSION_PATCH( gpu.props.apiVersion ) ) ); +#endif static idStr extensions_string; extensions_string.Clear(); @@ -768,13 +773,13 @@ static void SelectPhysicalDevice() if( vkcontext.deviceProperties2Available && driverPropertiesAvailable ) { - VkPhysicalDeviceProperties2 pProperties = {}; - VkPhysicalDeviceDriverProperties pDriverProperties = {}; - pProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; - pProperties.pNext = &pDriverProperties; - pDriverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; - vkGetPhysicalDeviceProperties2( vkcontext.physicalDevice, &pProperties ); - version_string.Append( va( " (%s %s)", pDriverProperties.driverName, pDriverProperties.driverInfo ) ); + VkPhysicalDeviceProperties2 deviceProperties = {}; + VkPhysicalDeviceDriverProperties driverProperties = {}; + deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; + deviceProperties.pNext = &driverProperties; + driverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; + vkGetPhysicalDeviceProperties2( vkcontext.physicalDevice, &deviceProperties ); + version_string.Append( va( " (%s %s)", driverProperties.driverName, driverProperties.driverInfo ) ); } glConfig.version_string = version_string.c_str();