From a535700b830b570146b7aa4f82c01373330629cd Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Tue, 16 Nov 2021 18:56:13 -0700 Subject: vulkaninfo: Simplify WSI macro defines Create a single macro define which is used everywhere rather than have 5 different places with the same giant macro if block. --- vulkaninfo/vulkaninfo.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'vulkaninfo/vulkaninfo.cpp') diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index 35fc62a6..a2e8e77d 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -189,6 +189,7 @@ bool operator==(AppSurface const &a, AppSurface const &b) { a.surface_capabilities2_khr == b.surface_capabilities2_khr && a.surface_capabilities2_ext == b.surface_capabilities2_ext; } +#if defined(VULKANINFO_WSI_ENABLED) void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector> &gpus, const std::vector> &surfaces) { // Don't print anything if no surfaces are found @@ -225,6 +226,7 @@ void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector> surfaces; +#if defined(VULKANINFO_WSI_ENABLED) for (auto &surface_extension : instance.surface_extensions) { surface_extension.create_window(instance); surface_extension.surface = surface_extension.create_surface(instance); @@ -1089,6 +1094,7 @@ int main(int argc, char **argv) { surfaces.push_back(std::unique_ptr(new AppSurface(instance, phys_device, surface_extension))); } } +#endif // defined(VULKANINFO_WSI_ENABLED) std::vector> gpus; @@ -1102,13 +1108,15 @@ int main(int argc, char **argv) { std::cout << "The selected gpu (" << parse_data.selected_gpu << ") is not a valid GPU index. "; if (gpus.size() == 0) { std::cout << "vulkaninfo could not find any GPU's.\n"; - } - if (gpus.size() == 1) { - std::cout << "The only available GPU selection is 0.\n"; + return 1; } else { - std::cout << "The available GPUs are in the range of 0 to " << gpus.size() - 1 << ".\n"; + if (gpus.size() == 1) { + std::cout << "The only available GPU selection is 0.\n"; + } else { + std::cout << "The available GPUs are in the range of 0 to " << gpus.size() - 1 << ".\n"; + } + return 1; } - return 1; } else if (parse_data.output_category == OutputCategory::devsim_json || parse_data.output_category == OutputCategory::portability_json) { std::cout << "vulkaninfo could not find any GPU's.\n"; @@ -1133,10 +1141,12 @@ int main(int argc, char **argv) { RunPrinter(*(printer.get()), parse_data, instance, gpus, surfaces); +#if defined(VULKANINFO_WSI_ENABLED) for (auto &surface_extension : instance.surface_extensions) { AppDestroySurface(instance, surface_extension.surface); surface_extension.destroy_window(instance); } +#endif // defined(VULKANINFO_WSI_ENABLED) } 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"; -- cgit v1.2.3