aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2021-11-16 18:56:13 -0700
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-02-02 16:22:12 -0700
commita535700b830b570146b7aa4f82c01373330629cd (patch)
treeb3013fb5f2763b15dd4c49268b2c7ef1e76fea39
parent4333f9943de07068f635015fe7014e02573782de (diff)
downloadusermoji-a535700b830b570146b7aa4f82c01373330629cd.tar.xz
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.
-rw-r--r--vulkaninfo/vulkaninfo.cpp20
-rw-r--r--vulkaninfo/vulkaninfo.h13
2 files changed, 24 insertions, 9 deletions
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<std::unique_ptr<AppGpu>> &gpus,
const std::vector<std::unique_ptr<AppSurface>> &surfaces) {
// Don't print anything if no surfaces are found
@@ -225,6 +226,7 @@ void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector<st
}
p.AddNewline();
}
+#endif // defined(VULKANINFO_WSI_ENABLED)
void DumpGroups(Printer &p, AppInstance &inst) {
if (inst.CheckExtensionEnabled(VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME)) {
@@ -1011,8 +1013,10 @@ void RunPrinter(Printer &p, ParsedResults parse_data, AppInstance &instance, std
p.AddNewline();
DumpLayers(p, instance.global_layers, gpus);
+#if defined(VULKANINFO_WSI_ENABLED)
// Doesn't print anything if no surfaces are available
DumpPresentableSurfaces(p, instance, gpus, surfaces);
+#endif // defined(VULKANINFO_WSI_ENABLED)
DumpGroups(p, instance);
p.SetHeader();
@@ -1082,6 +1086,7 @@ int main(int argc, char **argv) {
auto phys_devices = instance.FindPhysicalDevices();
std::vector<std::unique_ptr<AppSurface>> 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<AppSurface>(new AppSurface(instance, phys_device, surface_extension)));
}
}
+#endif // defined(VULKANINFO_WSI_ENABLED)
std::vector<std::unique_ptr<AppGpu>> 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";
diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h
index d49d3015..e2ef653b 100644
--- a/vulkaninfo/vulkaninfo.h
+++ b/vulkaninfo/vulkaninfo.h
@@ -620,10 +620,9 @@ struct AppInstance {
if (err) THROW_VK_ERR("vkEnumerateInstanceVersion", err);
}
- // fallback to baked header version if loader returns 0 for the patch version
- uint32_t patch_version = VK_VERSION_PATCH(instance_version);
- if (patch_version == 0) patch_version = VK_VERSION_PATCH(VK_HEADER_VERSION);
vk_version = make_vulkan_version(instance_version);
+ // fallback to baked header version if loader returns 0 for the patch version
+ if (VK_VERSION_PATCH(instance_version) == 0) vk_version.patch = VK_VERSION_PATCH(VK_HEADER_VERSION);
AppGetInstanceExtensions();
@@ -708,6 +707,11 @@ struct AppInstance {
// --------- Platform Specific Presentation Calls --------- //
+#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)
+#define VULKANINFO_WSI_ENABLED
+#endif
//---------------------------Win32---------------------------
#ifdef VK_USE_PLATFORM_WIN32_KHR
@@ -779,10 +783,11 @@ static void AppDestroyWin32Window(AppInstance &inst) { user32_handles->pfnDestro
#endif // VK_USE_PLATFORM_WIN32_KHR
//-----------------------------------------------------------
+#if defined(VULKANINFO_WSI_ENABLED)
static void AppDestroySurface(AppInstance &inst, VkSurfaceKHR surface) { // same for all platforms
inst.dll.fp_vkDestroySurfaceKHR(inst.instance, surface, nullptr);
}
-
+#endif // defined(VULKANINFO_WSI_ENABLED)
//----------------------------XCB----------------------------
#ifdef VK_USE_PLATFORM_XCB_KHR