Have demos give a useful error if no compatible ICD found.
authorIan Elliott <ian@LunarG.com>
Fri, 3 Apr 2015 21:24:55 +0000 (15:24 -0600)
committerIan Elliott <ian@LunarG.com>
Fri, 3 Apr 2015 21:24:55 +0000 (15:24 -0600)
demos/cube.c
demos/tri.c
demos/xglinfo.c

index dca5432..920a542 100644 (file)
@@ -1700,7 +1700,14 @@ static void demo_init_xgl(struct demo *demo)
     uint32_t i;
 
     err = xglCreateInstance(&app, NULL, &demo->inst);
-    assert(!err);
+    if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) {
+        printf("Cannot find a compatible Vulkan installable client driver "
+               "(ICD).\nExiting ...\n");
+        fflush(stdout);
+        exit(1);
+    } else {
+        assert(!err);
+    }
     err = xglEnumerateGpus(demo->inst, 1, &gpu_count, &demo->gpu);
     assert(!err && gpu_count == 1);
 
@@ -1727,6 +1734,12 @@ static void demo_init_connection(struct demo *demo)
     int scr;
 
     demo->connection = xcb_connect(NULL, &scr);
+    if (demo->connection == NULL) {
+        printf("Cannot find a compatible Vulkan installable client driver "
+               "(ICD).\nExiting ...\n");
+        fflush(stdout);
+        exit(1);
+    }
 
     setup = xcb_get_setup(demo->connection);
     iter = xcb_setup_roots_iterator(setup);
index 39b1513..efbd1a9 100644 (file)
@@ -1322,7 +1322,14 @@ static void demo_init_xgl(struct demo *demo)
     uint32_t i;
 
     err = xglCreateInstance(&app, NULL, &demo->inst);
-    assert(!err);
+    if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) {
+        printf("Cannot find a compatible Vulkan installable client driver "
+               "(ICD).\nExiting ...\n");
+        fflush(stdout);
+        exit(1);
+    } else {
+        assert(!err);
+    }
     err = xglEnumerateGpus(demo->inst, 1, &gpu_count, &demo->gpu);
     assert(!err && gpu_count == 1);
 
@@ -1352,6 +1359,12 @@ static void demo_init_connection(struct demo *demo)
     int scr;
 
     demo->connection = xcb_connect(NULL, &scr);
+    if (demo->connection == NULL) {
+        printf("Cannot find a compatible Vulkan installable client driver "
+               "(ICD).\nExiting ...\n");
+        fflush(stdout);
+        exit(1);
+    }
 
     setup = xcb_get_setup(demo->connection);
     iter = xcb_setup_roots_iterator(setup);
index 4544c23..e0887a2 100644 (file)
@@ -659,8 +659,14 @@ int main(int argc, char **argv)
     XGL_RESULT err;
 
     err = xglCreateInstance(&app_info, NULL, &inst);
-    if (err)
+    if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) {
+        printf("Cannot find a compatible Vulkan installable client driver "
+               "(ICD).\nExiting ...\n");
+        fflush(stdout);
+        exit(1);
+    } else if (err) {
         ERR_EXIT(err);
+    }
     err = xglEnumerateGpus(inst, MAX_GPUS, &gpu_count, objs);
     if (err)
         ERR_EXIT(err);