From de6e3eed59dca4e8e9875e2c08255cc41322d8d4 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Fri, 18 Jun 2021 16:32:40 -0600 Subject: [PATCH] vulkaninfo: Remove unecessary surface macro guards Many of the macro guards in vulkaninfo are unecessary due to not directly touching the contents of the surfaces outside of already guarded functions. Thus, there is little point in having guards for stuff that is always able to compile. --- vulkaninfo/vulkaninfo.cpp | 17 +++-------------- vulkaninfo/vulkaninfo.h | 6 +----- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index 2a681b4..ef172bb 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -191,6 +191,8 @@ bool operator==(AppSurface const &a, AppSurface const &b) { void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector> &gpus, const std::vector> &surfaces) { + // Don't print anything if no surfaces are found + if (surfaces.size() == 0) return; p.SetHeader(); ObjectWrapper obj(p, "Presentable Surfaces"); IndentWrapper indent(p); @@ -912,9 +914,6 @@ int main(int argc, char **argv) { auto phys_devices = instance.FindPhysicalDevices(); std::vector> surfaces; -#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \ - defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ - defined(VK_USE_PLATFORM_DIRECTFB_EXT) for (auto &surface_extension : instance.surface_extensions) { surface_extension.create_window(instance); surface_extension.surface = surface_extension.create_surface(instance); @@ -923,7 +922,6 @@ int main(int argc, char **argv) { new AppSurface(instance, phys_device, surface_extension, pNext_chains.surface_capabilities2))); } } -#endif std::vector> gpus; @@ -1036,12 +1034,8 @@ int main(int argc, char **argv) { p->AddNewline(); DumpLayers(*p.get(), instance.global_layers, gpus); - -#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \ - defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ - defined(VK_USE_PLATFORM_DIRECTFB_EXT) + // Doesn't print anything if no surfaces are available DumpPresentableSurfaces(*p.get(), instance, gpus, surfaces); -#endif DumpGroups(*p.get(), instance); p->SetHeader(); @@ -1054,15 +1048,10 @@ int main(int argc, char **argv) { } } -#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \ - defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ - defined(VK_USE_PLATFORM_DIRECTFB_EXT) - for (auto &surface_extension : instance.surface_extensions) { AppDestroySurface(instance, surface_extension.surface); surface_extension.destroy_window(instance); } -#endif } catch (std::exception &e) { // Print the error to stderr and leave all outputs in a valid state (mainly for json) std::cerr << "ERROR at " << e.what() << "\n"; diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h index 2d36831..fa90845 100644 --- a/vulkaninfo/vulkaninfo.h +++ b/vulkaninfo/vulkaninfo.h @@ -800,17 +800,13 @@ static VkSurfaceKHR AppCreateWin32Surface(AppInstance &inst) { return surface; } -static void AppDestroyWin32Window(AppInstance &inst) { CALL_PFN(DestroyWindow)(inst.h_wnd); } +static void AppDestroyWin32Window(AppInstance &inst) { user32_handles->pfnDestroyWindow(inst.h_wnd); } #endif // VK_USE_PLATFORM_WIN32_KHR //----------------------------------------------------------- -#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \ - defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ - defined(VK_USE_PLATFORM_DIRECTFB_EXT) || defined(VK_USE_PLATFORM_ANDROID_KHR) static void AppDestroySurface(AppInstance &inst, VkSurfaceKHR surface) { // same for all platforms inst.dll.fp_vkDestroySurfaceKHR(inst.instance, surface, nullptr); } -#endif //----------------------------XCB---------------------------- -- 2.7.4