Skip to content

Commit

Permalink
vulkaninfo: Fix deprecation of MVK/IOS surface extensions
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
charles-lunarg committed Aug 5, 2024
1 parent 7d5cdf6 commit 6bba838
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions vulkaninfo/vulkaninfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6bba838

Please sign in to comment.