Fix VK_KHR_portability_subset validation errors on macOS, fix OpenMP build issues on macOS
(cherry picked from commit d2f6713c418ea5bdd2c3fcee922def5854e534d4)
This commit is contained in:
parent
2810087752
commit
ae8ad09f6e
3 changed files with 52 additions and 7 deletions
|
|
@ -8,6 +8,10 @@
|
|||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
// SRS - This is needed to make visible VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME
|
||||
#define VK_ENABLE_BETA_EXTENSIONS
|
||||
#endif
|
||||
#include <VulkanDevice.h>
|
||||
#include <unordered_set>
|
||||
|
||||
|
|
@ -279,6 +283,14 @@ namespace vks
|
|||
enableDebugMarkers = true;
|
||||
}
|
||||
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
// SRS - When running on iOS/macOS with MoltenVK, must enable the VK_KHR_portability_subset device extension
|
||||
if (extensionSupported(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME))
|
||||
{
|
||||
deviceExtensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (deviceExtensions.size() > 0)
|
||||
{
|
||||
for (const char* enabledExtension : deviceExtensions)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,14 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
#elif defined(VK_USE_PLATFORM_HEADLESS_EXT)
|
||||
instanceExtensions.push_back(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
// SRS - When running on iOS/macOS with MoltenVK, enable VkPhysicalDeviceFeatures2 if not already enabled (required by VK_KHR_portability_subset)
|
||||
if (std::find(enabledInstanceExtensions.begin(), enabledInstanceExtensions.end(), VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == enabledInstanceExtensions.end())
|
||||
{
|
||||
enabledInstanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK) && (VK_HEADER_VERSION >= 216)
|
||||
instanceExtensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
||||
|
|
@ -75,6 +83,14 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(VK_KHR_portability_enumeration)
|
||||
// SRS - When VK_KHR_portability_enumeration is defined and supported, enable it to properly enumerate the physical device
|
||||
if (std::find(supportedInstanceExtensions.begin(), supportedInstanceExtensions.end(), VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) != supportedInstanceExtensions.end())
|
||||
{
|
||||
enabledInstanceExtensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Enabled requested instance extensions
|
||||
if (enabledInstanceExtensions.size() > 0)
|
||||
{
|
||||
|
|
@ -102,11 +118,19 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
{
|
||||
if (settings.validation)
|
||||
{
|
||||
instanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); // SRS - Dependency when VK_EXT_DEBUG_MARKER is enabled
|
||||
instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
}
|
||||
instanceCreateInfo.enabledExtensionCount = (uint32_t)instanceExtensions.size();
|
||||
instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data();
|
||||
}
|
||||
#if defined(VK_KHR_portability_enumeration)
|
||||
// SRS - When VK_KHR_portability_enumeration is defined and enabled, the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR flag must be set
|
||||
if (std::find(instanceExtensions.begin(), instanceExtensions.end(), VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) != instanceExtensions.end())
|
||||
{
|
||||
instanceCreateInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||
}
|
||||
#endif
|
||||
|
||||
// The VK_LAYER_KHRONOS_validation contains all current validation functionality.
|
||||
// Note that on Android this layer requires at least NDK r20
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue