aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2019-10-30 16:44:04 -0600
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2019-10-30 17:45:09 -0600
commit0c2f51dc7a971b94c23db3022c16e235da1f214e (patch)
treeebd3ff9d473a456f31b6b1938103abfbaec1e593
parentb13baa7080a19aa797f4b3b1bf905484d9ee174d (diff)
downloadusermoji-0c2f51dc7a971b94c23db3022c16e235da1f214e.tar.xz
vulkaninfo: fix infinite sleep for non text outputs
Previous versions, in win32 would sleep infinitely if a crash occured. This commit will first check if its a text output first before sleeping, to preserve the error if it is in a console but return immediate if it isn't. Change-Id: Ib1b43001e970c8c3114e666d96b24dc3c557a579
-rw-r--r--vulkaninfo/vulkaninfo.cpp10
-rw-r--r--vulkaninfo/vulkaninfo.h27
2 files changed, 19 insertions, 18 deletions
diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp
index 71be8c4d..f12b370f 100644
--- a/vulkaninfo/vulkaninfo.cpp
+++ b/vulkaninfo/vulkaninfo.cpp
@@ -676,11 +676,7 @@ int main(int argc, char **argv) {
if (ConsoleIsExclusive()) ConsoleEnlarge();
#endif
- bool human_readable_output = true;
- bool html_output = false;
- bool json_output = false;
uint32_t selected_gpu = 0;
- bool show_formats = false;
// Combinations of output: html only, html AND json, json only, human readable only
for (int i = 1; i < argc; ++i) {
@@ -791,11 +787,7 @@ int main(int argc, char **argv) {
}
#endif
-#ifdef _WIN32
- if (ConsoleIsExclusive()) {
- Sleep(INFINITE);
- }
-#endif
+ WAIT_FOR_CONSOLE_DESTROY;
return 0;
}
diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h
index 3a10370a..bfa8d0e0 100644
--- a/vulkaninfo/vulkaninfo.h
+++ b/vulkaninfo/vulkaninfo.h
@@ -69,6 +69,12 @@
#define ERR(err) std::cerr << __FILE__ << ":" << __LINE__ << ": failed with " << VkResultString(err) << "\n";
+// global configuration
+bool human_readable_output = true;
+bool html_output = false;
+bool json_output = false;
+bool show_formats = false;
+
#ifdef _WIN32
#define strdup _strdup
@@ -81,9 +87,9 @@ static int ConsoleIsExclusive(void) {
return num_pids <= 1;
}
-#define WAIT_FOR_CONSOLE_DESTROY \
- do { \
- if (ConsoleIsExclusive()) Sleep(INFINITE); \
+#define WAIT_FOR_CONSOLE_DESTROY \
+ do { \
+ if (ConsoleIsExclusive() && human_readable_output) Sleep(INFINITE); \
} while (0)
#else
#define WAIT_FOR_CONSOLE_DESTROY
@@ -867,14 +873,17 @@ std::vector<VkPhysicalDeviceGroupProperties> GetGroups(AppInstance &inst) {
PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR =
(PFN_vkEnumeratePhysicalDeviceGroupsKHR)vkGetInstanceProcAddr(inst.instance, "vkEnumeratePhysicalDeviceGroupsKHR");
+ std::vector<VkPhysicalDeviceGroupProperties> groups;
uint32_t group_count;
- VkResult err = vkEnumeratePhysicalDeviceGroupsKHR(inst.instance, &group_count, NULL);
- if (err) ERR_EXIT(err);
-
- std::vector<VkPhysicalDeviceGroupProperties> groups(group_count);
- err = vkEnumeratePhysicalDeviceGroupsKHR(inst.instance, &group_count, groups.data());
- if (err) ERR_EXIT(err);
+ VkResult err;
+ do {
+ err = vkEnumeratePhysicalDeviceGroupsKHR(inst.instance, &group_count, NULL);
+ if (err != VK_SUCCESS && err != VK_INCOMPLETE) ERR_EXIT(err);
+ groups.resize(group_count);
+ err = vkEnumeratePhysicalDeviceGroupsKHR(inst.instance, &group_count, groups.data());
+ if (err != VK_SUCCESS && err != VK_INCOMPLETE) ERR_EXIT(err);
+ } while (err == VK_INCOMPLETE);
return groups;
}
return {};