vulkaninfo: Fix error message when gpus.size()==0
authorVladimir Panteleev <CyberShadow@users.noreply.github.com>
Sat, 4 Sep 2021 06:16:46 +0000 (06:16 +0000)
committerjeremyk-lunarg <jeremyk@lunarg.com>
Tue, 7 Sep 2021 14:53:57 +0000 (08:53 -0600)
Avoid an amusing and slightly misleading error message:

"The selected gpu (0) is not a valid GPU index. The available GPUs are
in the range of 0 to 18446744073709551615."

vulkaninfo/vulkaninfo.cpp

index a4face9..d25cf1f 100644 (file)
@@ -936,7 +936,9 @@ int main(int argc, char **argv) {
 
         if (selected_gpu >= gpus.size()) {
             std::cout << "The selected gpu (" << selected_gpu << ") is not a valid GPU index. ";
-            if (gpus.size() == 1)
+            if (gpus.size() == 0)
+                std::cout << "There are no available GPUs.\n";
+            else 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";