diff options
| author | Andreas Bergmeier <abergmeier@gmx.net> | 2017-09-13 15:55:16 +0200 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2017-09-13 08:48:05 -0600 |
| commit | 02feae3697826e1f202f654cdba99b015df373d2 (patch) | |
| tree | badda43adaeb7e0c857a8ab3f996f7f54fe4775b | |
| parent | c847b3c704fb1d915f74a9c9df725a76f4c60d9c (diff) | |
| download | usermoji-02feae3697826e1f202f654cdba99b015df373d2.tar.xz | |
demos: Add support for headless XCB
For headless XCB we cannot create a surface. Simply ignore XCB if
connection could not be established or any other error occured.
Change-Id: I32db6aa3fc14887658d4290dcabbe8a1930cd8b3
| -rw-r--r-- | demos/vulkaninfo.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c index cfd0e0c9..949bd001 100644 --- a/demos/vulkaninfo.c +++ b/demos/vulkaninfo.c @@ -930,9 +930,9 @@ static void AppCreateXcbWindow(struct AppInstance *inst) { inst->xcb_connection = xcb_connect(NULL, &scr); int conn_error = xcb_connection_has_error(inst->xcb_connection); if (conn_error) { - fprintf(stderr, "XCB failed to connect to the X server due to error:%d.\nExiting ...\n", conn_error); + fprintf(stderr, "XCB failed to connect to the X server due to error:%d.\n", conn_error); fflush(stderr); - exit(1); + inst->xcb_connection = NULL; } setup = xcb_get_setup(inst->xcb_connection); @@ -956,6 +956,10 @@ static void AppCreateXcbWindow(struct AppInstance *inst) { } static void AppCreateXcbSurface(struct AppInstance *inst) { + if (!inst->xcb_connection) { + return; + } + VkResult U_ASSERT_ONLY err; VkXcbSurfaceCreateInfoKHR xcb_createInfo; xcb_createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; @@ -968,6 +972,10 @@ static void AppCreateXcbSurface(struct AppInstance *inst) { } static void AppDestroyXcbWindow(struct AppInstance *inst) { + if (!inst->xcb_connection) { + return; // Nothing to destroy + } + xcb_destroy_window(inst->xcb_connection, inst->xcb_window); xcb_disconnect(inst->xcb_connection); } |
