# HG changeset patch # User John Tsiombikas # Date 1506091698 -10800 # Node ID cec4b0e7fce81cb19dc9210cd469c7aa411b0cf0 # Parent c31c4115d44a3c988cd0690c3016520e1ca7b3a6 created swapchain diff -r c31c4115d44a -r cec4b0e7fce8 src/vku.c --- a/src/vku.c Fri Sep 22 15:26:29 2017 +0300 +++ b/src/vku.c Fri Sep 22 17:48:18 2017 +0300 @@ -99,6 +99,9 @@ #endif "VK_KHR_surface" }; + static const char *devext_names[] = { + "VK_KHR_swapchain" + }; sel_dev = -1; sel_qfamily = -1; @@ -189,6 +192,14 @@ return -1; } + for(i=0; i int vku_xlib_usable_visual(Display *dpy, VisualID vid); +VkSurfaceKHR vku_xlib_create_surface(Display *dpy, Window win); #endif #endif /* VKU_H_ */ diff -r c31c4115d44a -r cec4b0e7fce8 src/wsys_x11.c --- a/src/wsys_x11.c Fri Sep 22 15:26:29 2017 +0300 +++ b/src/wsys_x11.c Fri Sep 22 17:48:18 2017 +0300 @@ -24,6 +24,8 @@ static Display *dpy; static Window win; +static VkSurfaceKHR surf; +static VkSwapchainKHR swapchain; static Atom xa_wm_delete; static int win_width, win_height; static int win_mapped; @@ -87,6 +89,14 @@ XSelectInput(dpy, win, evmask); XSetWMProtocols(dpy, win, &xa_wm_delete, 1); + if(!(surf = vku_xlib_create_surface(dpy, win))) { + fprintf(stderr, "failed to create vulkan surface for the window\n"); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + return -1; + } + /* swapchain gets created before the first reshape invocation */ + wsys_set_window_title("X11 window"); XMapWindow(dpy, win); @@ -206,6 +216,13 @@ XEvent xev; if(pending & RESHAPE) { + VkSwapchainKHR sc; + if(!(sc = vku_create_swapchain(surf, win_width, win_height, 2, VK_PRESENT_MODE_FIFO_KHR, swapchain))) { + fprintf(stderr, "Failed to create %dx%d double-buffered swapchain\n", win_width, win_height); + return -1; + } + swapchain = sc; + if(cb.reshape) { cb.reshape(win_width, win_height); }