vulkan_test2
diff src/wsys_x11.c @ 14:9fb6c24691ea
this shit never ends...
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 26 Jun 2018 07:20:03 +0300 |
parents | d34f84bede17 |
children | f8bd29f124a8 |
line diff
1.1 --- a/src/wsys_x11.c Mon Jun 25 08:00:57 2018 +0300 1.2 +++ b/src/wsys_x11.c Tue Jun 26 07:20:03 2018 +0300 1.3 @@ -214,26 +214,62 @@ 1.4 1.5 int wsys_process_events(int mode) 1.6 { 1.7 + int i; 1.8 XEvent xev; 1.9 1.10 if(pending & RESHAPE) { 1.11 VkSwapchainKHR sc; 1.12 - if(!(sc = vku_create_swapchain(surf, win_width, win_height, 2, VK_PRESENT_MODE_FIFO_KHR, swapchain))) { 1.13 + VkFormat fmt = VK_FORMAT_B8G8R8A8_UNORM; /* TODO enumerate and choose */ 1.14 + 1.15 + printf("DBG reshape\n"); 1.16 + 1.17 + if(!vkrpass) { 1.18 + if(!(vkrpass = vku_create_renderpass(fmt, VK_FORMAT_UNDEFINED))) { 1.19 + abort(); 1.20 + } 1.21 + } 1.22 + 1.23 + if(!(sc = vku_create_swapchain(surf, win_width, win_height, 2, fmt, 1.24 + VK_PRESENT_MODE_FIFO_KHR, swapchain))) { 1.25 fprintf(stderr, "Failed to create %dx%d double-buffered swapchain\n", win_width, win_height); 1.26 return -1; 1.27 } 1.28 swapchain = sc; 1.29 1.30 free(swapchain_images); 1.31 + swapchain_size = 2; 1.32 swapchain_images = vku_get_swapchain_images(sc, 0); 1.33 next_swapchain_image = vku_get_next_image(swapchain); 1.34 1.35 - if(!vkrpass) { 1.36 - if(!(vkrpass = vku_create_renderpass(VK_FORMAT_R8G8B8_UNORM, VK_FORMAT_UNDEFINED))) { 1.37 - abort(); 1.38 + if(!swapchain_views) { 1.39 + if(!(swapchain_views = calloc(swapchain_size, sizeof *swapchain_views))) { 1.40 + fprintf(stderr, "Failed to allocate image views\n"); 1.41 + return -1; 1.42 } 1.43 } 1.44 1.45 + for(i=0; i<swapchain_size; i++) { 1.46 + if(swapchain_views[i]) { 1.47 + vku_destroy_view(swapchain_views[i]); 1.48 + } 1.49 + swapchain_views[i] = vku_create_view(swapchain_images[i], fmt); 1.50 + } 1.51 + 1.52 + if(!swapchain_framebuf) { 1.53 + if(!(swapchain_framebuf = calloc(swapchain_size, sizeof *swapchain_framebuf))) { 1.54 + fprintf(stderr, "Failed to allocate framebuffers\n"); 1.55 + return -1; 1.56 + } 1.57 + } 1.58 + 1.59 + for(i=0; i<swapchain_size; i++) { 1.60 + if(swapchain_framebuf[i]) { 1.61 + vku_destroy_framebuffer(swapchain_framebuf[i]); 1.62 + } 1.63 + swapchain_framebuf[i] = vku_create_framebuffer(swapchain_views[i], 1.64 + win_width, win_height, vkrpass); 1.65 + } 1.66 + 1.67 if(cb.reshape) { 1.68 cb.reshape(win_width, win_height); 1.69 }