From 0726413b1b04a1a2a83c5f4c490b8277be4b0bc0 Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Tue, 28 Apr 2015 11:35:02 -0600 Subject: demos: Improve tri/cube error if incompatible driver found. --- demos/cube.c | 46 ++++++++++++++++++++++++++++++++-------------- demos/tri.c | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/demos/cube.c b/demos/cube.c index 645de5e2..b126a7a0 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -33,6 +33,28 @@ #define U_ASSERT_ONLY #endif +#ifdef _WIN32 +#define ERR_EXIT(err_msg, err_class) \ + do { \ + MessageBox(NULL, err_msg, err_class, MB_OK); \ + exit(1); \ + } while (0) + +// NOTE: If the following values (copied from "loader_platform.h") change, they +// need to change here as well: +#define LAYER_NAMES_ENV "VK_LAYER_NAMES" +#define LAYER_NAMES_REGISTRY_VALUE "VK_LAYER_NAMES" + +#else // _WIN32 + +#define ERR_EXIT(err_msg, err_class) \ + do { \ + printf(err_msg); \ + fflush(stdout); \ + exit(1); \ + } while (0) +#endif // _WIN32 + /* * structure to track all objects related to a texture. */ @@ -1632,13 +1654,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, WPARAM wParam, LPARAM lParam) { -<<<<<<< HEAD - char tmp_str[] = "Test Vulkan Cube Program"; -======= PAINTSTRUCT paint_struct; HDC hDC; // Device context char tmp_str[] = APP_LONG_NAME; ->>>>>>> 7224550... demos: Use macros for the app name, and window name. switch(uMsg) { @@ -1864,16 +1882,16 @@ static void demo_init_vk(struct demo *demo) uint32_t queue_count; err = vkCreateInstance(&inst_info, &demo->inst); - if (err) { -#ifdef _WIN32 - MessageBox(NULL, "vkCreateInstance failed - do you have a Vulkan graphics driver installed?", - "vkCreateInstance Failure", MB_OK); -#else - printf("vkCreateInstance failed - Do you have a Vulkan graphics driver installed?" - "(\nExiting ...\n"); - fflush(stdout); -#endif - exit(1); + if (err == VK_ERROR_INCOMPATIBLE_DRIVER) { + ERR_EXIT("Cannot find a compatible Vulkan installable client driver " + "(ICD).\nPlease look at the Getting Started guide for " + "additional information.\n", + "vkCreateInstance Failure"); + } else if (err) { + ERR_EXIT("vkCreateInstance failed. Do you have a compatible Vulkan " + "installable client driver (ICD) installed. Please look at " + "the Getting Started guide for additional information.\n", + "vkCreateInstance Failure"); } gpu_count = 1; diff --git a/demos/tri.c b/demos/tri.c index 9611a34c..00392613 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -59,6 +59,26 @@ #define U_ASSERT_ONLY #endif +#ifdef _WIN32 +#define ERR_EXIT(err_msg, err_class) \ + do { \ + MessageBox(NULL, err_msg, err_class, MB_OK); \ + exit(1); \ + } while (0) + +// NOTE: If the following values (copied from "loader_platform.h") change, they +// need to change here as well: +#define LAYER_NAMES_ENV "VK_LAYER_NAMES" +#define LAYER_NAMES_REGISTRY_VALUE "VK_LAYER_NAMES" +#else // _WIN32 + +#define ERR_EXIT(err_msg, err_class) \ + do { \ + printf(err_msg); \ + fflush(stdout); \ + exit(1); \ + } while (0) +#endif // _WIN32 struct texture_object { VkSampler sampler; @@ -1407,16 +1427,16 @@ static void demo_init_vk(struct demo *demo) uint32_t queue_count; err = vkCreateInstance(&inst_info, &demo->inst); - if (err) { -#ifdef _WIN32 - MessageBox(NULL, "vkCreateInstance failed - do you have a Vulkan graphics driver installed?", - "vkCreateInstance Failure", MB_OK); -#else - printf("vkCreateInstance failed - Do you have a Vulkan graphics driver installed?" - "(\nExiting ...\n"); - fflush(stdout); -#endif - exit(1); + if (err == VK_ERROR_INCOMPATIBLE_DRIVER) { + ERR_EXIT("Cannot find a compatible Vulkan installable client driver " + "(ICD).\nPlease look at the Getting Started guide for " + "additional information.\n", + "vkCreateInstance Failure"); + } else if (err) { + ERR_EXIT("vkCreateInstance failed. Do you have a compatible Vulkan " + "installable client driver (ICD) installed. Please look at " + "the Getting Started guide for additional information.\n", + "vkCreateInstance Failure"); } gpu_count = 1; -- cgit v1.2.3