aboutsummaryrefslogtreecommitdiff
path: root/cube/cube.cpp
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2022-12-01 11:25:11 -0600
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-12-01 14:35:36 -0600
commitb17374498fcd4612e758a911fb11a8c2d0451dc0 (patch)
treec968a85dc1cb4b7e0c30a75d51e50b459652bcbc /cube/cube.cpp
parent8455f816a3663aaf31c5cf4ef10a2a6c15d36e5b (diff)
downloadusermoji-b17374498fcd4612e758a911fb11a8c2d0451dc0.tar.xz
cube & cubepp: Handle negative gpu selections
Previously, a negative gpu number (other than -1) would cause the program to assert. It is simple enough to handle it gracefully, so best to do so.
Diffstat (limited to 'cube/cube.cpp')
-rw-r--r--cube/cube.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/cube/cube.cpp b/cube/cube.cpp
index 94f91274..95dd5dc6 100644
--- a/cube/cube.cpp
+++ b/cube/cube.cpp
@@ -330,6 +330,7 @@ struct Demo {
bool use_staging_buffer = false;
bool use_xlib = false;
bool separate_present_queue = false;
+ bool invalid_gpu_selection = false;
int32_t gpu_number = 0;
vk::Instance inst;
@@ -902,7 +903,7 @@ void Demo::init(int argc, char **argv) {
}
if ((strcmp(argv[i], "--gpu_number") == 0) && (i < argc - 1)) {
gpu_number = atoi(argv[i + 1]);
- assert(gpu_number >= 0);
+ if (gpu_number < 0) invalid_gpu_selection = true;
i++;
continue;
}
@@ -1295,7 +1296,7 @@ void Demo::init_vk() {
"vkEnumeratePhysicalDevices Failure");
}
- if (gpu_number >= 0 && !(static_cast<uint32_t>(gpu_number) < physical_devices.size())) {
+ if (invalid_gpu_selection || (gpu_number >= 0 && !(static_cast<uint32_t>(gpu_number) < physical_devices.size()))) {
fprintf(stderr, "GPU %d specified is not present, GPU count = %zu\n", gpu_number, physical_devices.size());
ERR_EXIT("Specified GPU number is not present", "User Error");
}