diff options
| author | Charles Giessen <charles@lunarg.com> | 2024-08-05 10:17:50 -0500 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2024-08-15 10:36:43 -0500 |
| commit | 32379b03f828619cb54eed874a11ab7e5ceafb3a (patch) | |
| tree | 2119a33e7b1a9501d480ab5471a2380e0e1607a5 | |
| parent | 7d5cdf62e4f2935425faab1270fe1c9a401fa664 (diff) | |
| download | usermoji-32379b03f828619cb54eed874a11ab7e5ceafb3a.tar.xz | |
vulkaninfo: Fix deprecation of MVK/IOS surface extensions
These surface extensions shouldn't be enabled if the metal
surface extension is present. This fixes a deprecation notice
the validation layers emit - as well as not provide redundant
information (since the metal extension is a direct replacement
for the mvk/ios extensions).
| -rw-r--r-- | vulkaninfo/vulkaninfo.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h index 7abe10bd..57d49041 100644 --- a/vulkaninfo/vulkaninfo.h +++ b/vulkaninfo/vulkaninfo.h @@ -349,7 +349,9 @@ class APIVersion { uint32_t api_version_; }; -std::ostream &operator<<(std::ostream &out, const APIVersion &v) { return out << v.Major() << "." << v.Minor() << "." << v.Patch(); } +std::ostream &operator<<(std::ostream &out, const APIVersion &v) { + return out << v.Major() << "." << v.Minor() << "." << v.Patch(); +} struct AppInstance { VkInstance instance; @@ -451,7 +453,8 @@ struct AppInstance { VkResult err = vkCreateInstance(&inst_info, nullptr, &instance); if (err == VK_ERROR_INCOMPATIBLE_DRIVER) { std::cerr << "Cannot create " API_NAME " instance.\n"; - std::cerr << "This problem is often caused by a faulty installation of the " API_NAME " driver or attempting to use a GPU " + std::cerr << "This problem is often caused by a faulty installation of the " API_NAME + " driver or attempting to use a GPU " "that does not support " API_NAME ".\n"; THROW_VK_ERR("vkCreateInstance", err); } else if (err) { @@ -495,6 +498,15 @@ struct AppInstance { global_extensions = AppGetGlobalLayerExtensions(nullptr); } void AppCompileInstanceExtensionsToEnable() { +#if defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_IOS_MVK) + bool metal_surface_available = false; + for (const auto &ext : global_extensions) { + if (strcmp("VK_EXT_metal_surface", ext.extensionName) == 0) { + metal_surface_available = true; + } + } +#endif + for (const auto &ext : global_extensions) { if (strcmp(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, ext.extensionName) == 0) { inst_extensions.push_back(ext.extensionName); @@ -519,12 +531,12 @@ struct AppInstance { } #endif #ifdef VK_USE_PLATFORM_IOS_MVK - if (strcmp(VK_MVK_IOS_SURFACE_EXTENSION_NAME, ext.extensionName) == 0) { + if (strcmp(VK_MVK_IOS_SURFACE_EXTENSION_NAME, ext.extensionName) == 0 && !metal_surface_available) { inst_extensions.push_back(ext.extensionName); } #endif #ifdef VK_USE_PLATFORM_MACOS_MVK - if (strcmp(VK_MVK_MACOS_SURFACE_EXTENSION_NAME, ext.extensionName) == 0) { + if (strcmp(VK_MVK_MACOS_SURFACE_EXTENSION_NAME, ext.extensionName) == 0 && !metal_surface_available) { inst_extensions.push_back(ext.extensionName); } #endif @@ -1077,7 +1089,7 @@ void SetupWindowExtensions(AppInstance &inst) { //--MACOS-- #ifdef VK_USE_PLATFORM_MACOS_MVK SurfaceExtension surface_ext_macos; - if (inst.CheckExtensionEnabled(VK_MVK_MACOS_SURFACE_EXTENSION_NAME)) { + if (inst.CheckExtensionEnabled(VK_MVK_MACOS_SURFACE_EXTENSION_NAME) && !inst.CheckExtensionEnabled("VK_EXT_metal_surface")) { surface_ext_macos.name = VK_MVK_MACOS_SURFACE_EXTENSION_NAME; surface_ext_macos.create_window = AppCreateMacOSWindow; surface_ext_macos.create_surface = AppCreateMacOSSurface; |
