vulkan_test2
changeset 17:f8bd29f124a8 tip
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 27 Jun 2018 01:57:55 +0300 |
parents | 236f923a00a3 |
children | |
files | sdr/pixel.glsl sdr/vertex.glsl src/main.c src/vkgl.c src/vkpipe.c src/vku.c src/vku.h src/wsys.h src/wsys_x11.c vk_layer_settings.txt |
diffstat | 10 files changed, 231 insertions(+), 85 deletions(-) [+] |
line diff
1.1 --- a/sdr/pixel.glsl Tue Jun 26 08:42:12 2018 +0300 1.2 +++ b/sdr/pixel.glsl Wed Jun 27 01:57:55 2018 +0300 1.3 @@ -5,5 +5,5 @@ 1.4 1.5 void main() 1.6 { 1.7 - outcolor = vec4(1.0, 0.0, 0.0, 1.0); 1.8 + outcolor = vec4(0.8, 0.2, 0.1, 1.0); 1.9 }
2.1 --- a/sdr/vertex.glsl Tue Jun 26 08:42:12 2018 +0300 2.2 +++ b/sdr/vertex.glsl Wed Jun 27 01:57:55 2018 +0300 2.3 @@ -1,8 +1,6 @@ 2.4 #version 450 2.5 #extension GL_ARB_separate_shader_objects: enable 2.6 2.7 -layout(location = 0) out vec4 outpos; 2.8 - 2.9 const vec3 vdata[] = vec3[]( 2.10 vec3(-0.5, -0.5, 0.0), 2.11 vec3(0.5, -0.5, 0.0), 2.12 @@ -10,5 +8,5 @@ 2.13 2.14 void main() 2.15 { 2.16 - outpos = vec4(vdata[gl_VertexIndex], 1.0); 2.17 + gl_Position = vec4(vdata[gl_VertexIndex], 1.0); 2.18 }
3.1 --- a/src/main.c Tue Jun 26 08:42:12 2018 +0300 3.2 +++ b/src/main.c Wed Jun 27 01:57:55 2018 +0300 3.3 @@ -10,6 +10,8 @@ 3.4 3.5 static struct vku_pipeline pipeline; 3.6 static VkShaderModule vsdr, psdr; 3.7 +static VkSemaphore sem_draw_done; 3.8 +static VkFence fence_draw_done; 3.9 3.10 int main(void) 3.11 { 3.12 @@ -26,8 +28,6 @@ 3.13 wsys_reshape_callback(reshape); 3.14 wsys_keyboard_callback(keyboard); 3.15 3.16 - wsys_process_events(WSYS_NONBLOCK); 3.17 - 3.18 if(!(vsdr = vku_load_shader("sdr/vertex.spv")) || 3.19 !(psdr = vku_load_shader("sdr/pixel.spv"))) { 3.20 return 1; 3.21 @@ -37,14 +37,23 @@ 3.22 vku_pipeline_shader(&pipeline, vsdr, VK_SHADER_STAGE_VERTEX_BIT); 3.23 vku_pipeline_shader(&pipeline, psdr, VK_SHADER_STAGE_FRAGMENT_BIT); 3.24 vku_pipeline_viewport(&pipeline, 0, 0, 800, 600); 3.25 + vku_pipeline_scissor(&pipeline, 0, 0, 800, 600); 3.26 vku_pipeline_renderpass(&pipeline, vkrpass); 3.27 if(!vku_create_pipeline(&pipeline)) { 3.28 return 1; 3.29 } 3.30 3.31 + sem_draw_done = vku_create_semaphore(); 3.32 + fence_draw_done = vku_create_fence(); 3.33 3.34 while(wsys_process_events(WSYS_BLOCKING) != -1); 3.35 3.36 + vku_destroy_fence(fence_draw_done); 3.37 + vku_destroy_semaphore(sem_draw_done); 3.38 + vku_destroy_pipeline(&pipeline); 3.39 + vku_destroy_shader(vsdr); 3.40 + vku_destroy_shader(psdr); 3.41 + 3.42 wsys_destroy_window(); 3.43 vku_cleanup(); 3.44 return 0; 3.45 @@ -52,10 +61,10 @@ 3.46 3.47 static void display(void) 3.48 { 3.49 - vkgl_clear_color(1, 0, 0, 1); 3.50 + vku_begin_cmdbuf(vkcmdbuf, VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT); 3.51 + vkgl_clear_color(0.2, 0.2, 0.3, 1); 3.52 vkgl_clear(VKGL_COLOR_BUFFER_BIT); 3.53 3.54 - vku_begin_cmdbuf(vkcmdbuf, VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT); 3.55 vku_begin_renderpass(vkcmdbuf, vkrpass, swapchain_framebuf[next_swapchain_image], 3.56 VK_SUBPASS_CONTENTS_INLINE); 3.57 vkCmdBindPipeline(vkcmdbuf, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.pipeline); 3.58 @@ -63,9 +72,10 @@ 3.59 vku_end_renderpass(vkcmdbuf); 3.60 vku_end_cmdbuf(vkcmdbuf); 3.61 3.62 - vku_submit_cmdbuf(vkq, vkcmdbuf, 0); 3.63 + vku_submit_cmdbuf(vkq, vkcmdbuf, swapchain_getimg_sem, sem_draw_done, fence_draw_done); 3.64 3.65 - wsys_swap_buffers(); 3.66 + wsys_swap_buffers(sem_draw_done); 3.67 + vku_wait_fence(fence_draw_done); 3.68 } 3.69 3.70 static void reshape(int x, int y)
4.1 --- a/src/vkgl.c Tue Jun 26 08:42:12 2018 +0300 4.2 +++ b/src/vkgl.c Wed Jun 27 01:57:55 2018 +0300 4.3 @@ -27,7 +27,7 @@ 4.4 void vkgl_clear(unsigned int flags) 4.5 { 4.6 VkImageSubresourceRange wtf; 4.7 - VkSubmitInfo si; 4.8 + //VkSubmitInfo si; 4.9 4.10 memset(&wtf, 0, sizeof wtf); 4.11 4.12 @@ -43,7 +43,7 @@ 4.13 wtf.levelCount = 1; 4.14 wtf.layerCount = 1; 4.15 4.16 - vku_begin_cmdbuf(vkcmdbuf, VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT); 4.17 + //vku_begin_cmdbuf(vkcmdbuf, VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT); 4.18 if(flags & VKGL_COLOR_BUFFER_BIT) { 4.19 vkCmdClearColorImage(vkcmdbuf, swapchain_images[next_swapchain_image], 4.20 VK_IMAGE_LAYOUT_GENERAL, &st.clear.color, 1, &wtf); 4.21 @@ -52,12 +52,14 @@ 4.22 vkCmdClearDepthStencilImage(vkcmdbuf, swapchain_images[next_swapchain_image], 4.23 VK_IMAGE_LAYOUT_GENERAL, &st.clear.depthStencil, 1, &wtf); 4.24 } 4.25 - vku_end_cmdbuf(vkcmdbuf); 4.26 + //vku_end_cmdbuf(vkcmdbuf); 4.27 4.28 + /* 4.29 memset(&si, 0, sizeof si); 4.30 si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; 4.31 si.commandBufferCount = 1; 4.32 si.pCommandBuffers = &vkcmdbuf; 4.33 4.34 vkQueueSubmit(vkq, 1, &si, 0); 4.35 + */ 4.36 }
5.1 --- a/src/vkpipe.c Tue Jun 26 08:42:12 2018 +0300 5.2 +++ b/src/vkpipe.c Wed Jun 27 01:57:55 2018 +0300 5.3 @@ -30,6 +30,8 @@ 5.4 st->vport_data.minDepth = 0.0f; 5.5 st->vport_data.maxDepth = 1.0f; 5.6 5.7 + st->msaa.rasterizationSamples = 1; 5.8 + 5.9 st->blend.logicOp = VK_LOGIC_OP_COPY; 5.10 st->blend.attachmentCount = 1; 5.11 st->blend.pAttachments = &st->atblend;
6.1 --- a/src/vku.c Tue Jun 26 08:42:12 2018 +0300 6.2 +++ b/src/vku.c Wed Jun 27 01:57:55 2018 +0300 6.3 @@ -27,9 +27,8 @@ 6.4 static uint32_t vkext_count, vkdevext_count; 6.5 6.6 static VkDebugReportCallbackEXT debug_callback_obj; 6.7 -static VkResult (*vk_create_debug_report_callback)(VkInstance, 6.8 - const VkDebugReportCallbackCreateInfoEXT*, const VkAllocationCallbacks*, 6.9 - VkDebugReportCallbackEXT*); 6.10 +static PFN_vkCreateDebugReportCallbackEXT vk_create_debug_report_callback; 6.11 +static PFN_vkDestroyDebugReportCallbackEXT vk_destroy_debug_report_callback; 6.12 static void (*user_dbg_callback)(const char*, void*); 6.13 static void *user_dbg_callback_data; 6.14 6.15 @@ -137,7 +136,8 @@ 6.16 static const char *layer_names[] = { 6.17 "VK_LAYER_LUNARG_standard_validation", 6.18 "VK_LAYER_LUNARG_parameter_validation", 6.19 - "VK_LAYER_LUNARG_core_validation" 6.20 + "VK_LAYER_LUNARG_core_validation", 6.21 + "VK_LAYER_LUNARG_image" 6.22 }; 6.23 6.24 sel_dev = -1; 6.25 @@ -177,6 +177,7 @@ 6.26 fprintf(stderr, "FUCK EVERYTHING\n"); 6.27 return -1; 6.28 } 6.29 + vk_destroy_debug_report_callback = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(vk, "vkDestroyDebugReportCallbackEXT"); 6.30 vku_set_debug_callback(user_dbg_callback, user_dbg_callback_data); /* set debug callback */ 6.31 6.32 6.33 @@ -289,11 +290,20 @@ 6.34 return -1; 6.35 } 6.36 6.37 - if(!(vkcmdbuf = vku_alloc_cmdbuf(vkcmdpool, VK_COMMAND_BUFFER_LEVEL_PRIMARY))) { 6.38 - fprintf(stderr, "failed to create primary command buffer\n"); 6.39 + /* XXX hardcoded 2 command buffers for a swapchain with 2 images */ 6.40 + if(!(swapchain_cmdbuf = malloc(2 * sizeof *swapchain_cmdbuf))) { 6.41 + fprintf(stderr, "failed to allocate command buffer array\n"); 6.42 return -1; 6.43 } 6.44 6.45 + for(i=0; i<2; i++) { 6.46 + if(!(swapchain_cmdbuf[i] = vku_alloc_cmdbuf(vkcmdpool, VK_COMMAND_BUFFER_LEVEL_PRIMARY))) { 6.47 + fprintf(stderr, "failed to create primary command buffer\n"); 6.48 + return -1; 6.49 + } 6.50 + } 6.51 + vkcmdbuf = swapchain_cmdbuf[0]; 6.52 + 6.53 return 0; 6.54 } 6.55 6.56 @@ -303,6 +313,7 @@ 6.57 vkDeviceWaitIdle(vkdev); 6.58 vkDestroyCommandPool(vkdev, vkcmdpool, 0); 6.59 vkDestroyDevice(vkdev, 0); 6.60 + vk_destroy_debug_report_callback(vk, debug_callback_obj, 0); 6.61 vkDestroyInstance(vk, 0); 6.62 vk = 0; 6.63 } 6.64 @@ -355,7 +366,8 @@ 6.65 vkResetCommandBuffer(buf, 0); 6.66 } 6.67 6.68 -void vku_submit_cmdbuf(VkQueue q, VkCommandBuffer buf, VkFence done_fence) 6.69 +void vku_submit_cmdbuf(VkQueue q, VkCommandBuffer buf, VkSemaphore sem_wait, 6.70 + VkSemaphore sem_done, VkFence done_fence) 6.71 { 6.72 VkSubmitInfo info; 6.73 6.74 @@ -363,6 +375,14 @@ 6.75 info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; 6.76 info.commandBufferCount = 1; 6.77 info.pCommandBuffers = &buf; 6.78 + if(sem_wait) { 6.79 + info.pWaitSemaphores = &sem_wait; 6.80 + info.waitSemaphoreCount = 1; 6.81 + } 6.82 + if(sem_done) { 6.83 + info.pSignalSemaphores = &sem_done; 6.84 + info.signalSemaphoreCount = 1; 6.85 + } 6.86 6.87 vkQueueSubmit(q, 1, &info, done_fence); 6.88 } 6.89 @@ -412,13 +432,14 @@ 6.90 return images; 6.91 } 6.92 6.93 -int vku_get_next_image(VkSwapchainKHR sc) 6.94 +int vku_get_next_image(VkSwapchainKHR sc, VkSemaphore semdone) 6.95 { 6.96 uint32_t next; 6.97 6.98 - if(vkAcquireNextImageKHR(vkdev, sc, UINT64_MAX, 0, 0, &next) != 0) { 6.99 + if(vkAcquireNextImageKHR(vkdev, sc, UINT64_MAX, semdone, 0, &next) != 0) { 6.100 return -1; 6.101 } 6.102 + vkcmdbuf = swapchain_cmdbuf[next]; 6.103 return (int)next; 6.104 } 6.105 6.106 @@ -478,7 +499,7 @@ 6.107 vkDestroyFramebuffer(vkdev, fb, 0); 6.108 } 6.109 6.110 -void vku_present(VkSwapchainKHR sc, int img_idx) 6.111 +void vku_present(VkSwapchainKHR sc, int img_idx, VkSemaphore sem_wait) 6.112 { 6.113 VkPresentInfoKHR inf; 6.114 VkResult res; 6.115 @@ -490,6 +511,10 @@ 6.116 inf.pSwapchains = ≻ 6.117 inf.pImageIndices = &index; 6.118 inf.pResults = &res; 6.119 + if(sem_wait) { 6.120 + inf.pWaitSemaphores = &sem_wait; 6.121 + inf.waitSemaphoreCount = 1; 6.122 + } 6.123 6.124 vkQueuePresentKHR(vkq, &inf); 6.125 } 6.126 @@ -622,6 +647,53 @@ 6.127 vkCmdEndRenderPass(cmdbuf); 6.128 } 6.129 6.130 +VkSemaphore vku_create_semaphore(void) 6.131 +{ 6.132 + VkSemaphore s; 6.133 + VkSemaphoreCreateInfo sinf; 6.134 + 6.135 + memset(&sinf, 0, sizeof sinf); 6.136 + sinf.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; 6.137 + 6.138 + if(vkCreateSemaphore(vkdev, &sinf, 0, &s) != 0) { 6.139 + fprintf(stderr, "vku_create_semaphore failed\n"); 6.140 + return 0; 6.141 + } 6.142 + return s; 6.143 +} 6.144 + 6.145 +void vku_destroy_semaphore(VkSemaphore s) 6.146 +{ 6.147 + vkDestroySemaphore(vkdev, s, 0); 6.148 +} 6.149 + 6.150 +VkFence vku_create_fence(void) 6.151 +{ 6.152 + VkFence f; 6.153 + VkFenceCreateInfo finf; 6.154 + 6.155 + memset(&finf, 0, sizeof finf); 6.156 + finf.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; 6.157 + 6.158 + if(vkCreateFence(vkdev, &finf, 0, &f) != 0) { 6.159 + fprintf(stderr, "vku_create_fence failed\n"); 6.160 + return 0; 6.161 + } 6.162 + return f; 6.163 +} 6.164 + 6.165 +void vku_destroy_fence(VkFence f) 6.166 +{ 6.167 + vkDestroyFence(vkdev, f, 0); 6.168 +} 6.169 + 6.170 +void vku_wait_fence(VkFence f) 6.171 +{ 6.172 + vkWaitForFences(vkdev, 1, &f, VK_TRUE, UINT64_MAX); 6.173 + vkResetFences(vkdev, 1, &f); 6.174 +} 6.175 + 6.176 + 6.177 #ifdef VK_USE_PLATFORM_XLIB_KHR 6.178 int vku_xlib_usable_visual(Display *dpy, VisualID vid) 6.179 {
7.1 --- a/src/vku.h Tue Jun 26 08:42:12 2018 +0300 7.2 +++ b/src/vku.h Wed Jun 27 01:57:55 2018 +0300 7.3 @@ -19,6 +19,8 @@ 7.4 VkImageView *swapchain_views; 7.5 int next_swapchain_image; 7.6 VkFramebuffer *swapchain_framebuf; 7.7 +VkSemaphore swapchain_getimg_sem; 7.8 +VkCommandBuffer *swapchain_cmdbuf; 7.9 7.10 VkViewport vkvport; 7.11 VkRenderPass vkrpass; 7.12 @@ -45,13 +47,14 @@ 7.13 void vku_end_cmdbuf(VkCommandBuffer buf); 7.14 void vku_reset_cmdbuf(VkCommandBuffer buf); 7.15 7.16 -void vku_submit_cmdbuf(VkQueue q, VkCommandBuffer buf, VkFence done_fence); 7.17 +void vku_submit_cmdbuf(VkQueue q, VkCommandBuffer buf, VkSemaphore sem_wait, 7.18 + VkSemaphore sem_done, VkFence done_fence); 7.19 7.20 VkSwapchainKHR vku_create_swapchain(VkSurfaceKHR surf, int xsz, int ysz, int n, 7.21 VkFormat fmt, VkPresentModeKHR pmode, VkSwapchainKHR prev); 7.22 VkImage *vku_get_swapchain_images(VkSwapchainKHR sc, int *count); 7.23 -int vku_get_next_image(VkSwapchainKHR sc); 7.24 -void vku_present(VkSwapchainKHR sc, int img_idx); 7.25 +int vku_get_next_image(VkSwapchainKHR sc, VkSemaphore semdone); 7.26 +void vku_present(VkSwapchainKHR sc, int img_idx, VkSemaphore sem_wait); 7.27 7.28 VkImageView vku_create_view(VkImage img, VkFormat fmt); 7.29 void vku_destroy_view(VkImageView view); 7.30 @@ -71,6 +74,13 @@ 7.31 VkSubpassContents cont); 7.32 void vku_end_renderpass(VkCommandBuffer cmdbuf); 7.33 7.34 +VkSemaphore vku_create_semaphore(void); 7.35 +void vku_destroy_semaphore(VkSemaphore s); 7.36 + 7.37 +VkFence vku_create_fence(void); 7.38 +void vku_destroy_fence(VkFence f); 7.39 +void vku_wait_fence(VkFence f); 7.40 + 7.41 /* platform-specific */ 7.42 #ifdef VK_USE_PLATFORM_XLIB_KHR 7.43 #include <X11/Xlib.h>
8.1 --- a/src/wsys.h Tue Jun 26 08:42:12 2018 +0300 8.2 +++ b/src/wsys.h Wed Jun 27 01:57:55 2018 +0300 8.3 @@ -1,6 +1,8 @@ 8.4 #ifndef WSYS_H_ 8.5 #define WSYS_H_ 8.6 8.7 +#include <vulkan/vulkan.h> 8.8 + 8.9 /* pass to wsys_process_events */ 8.10 enum { 8.11 WSYS_BLOCKING = 0, 8.12 @@ -20,7 +22,7 @@ 8.13 void wsys_motion_callback(void (*func)(int, int)); 8.14 void wsys_passive_motion_callback(void (*func)(int, int)); 8.15 8.16 -void wsys_swap_buffers(void); 8.17 +void wsys_swap_buffers(VkSemaphore sem_wait); 8.18 void wsys_redisplay(void); 8.19 void wsys_quit(void); 8.20
9.1 --- a/src/wsys_x11.c Tue Jun 26 08:42:12 2018 +0300 9.2 +++ b/src/wsys_x11.c Wed Jun 27 01:57:55 2018 +0300 9.3 @@ -20,6 +20,7 @@ 9.4 REDISPLAY = 4 9.5 }; 9.6 9.7 +static int reshape(int x, int y); 9.8 static void proc_event(XEvent *ev); 9.9 9.10 static Display *dpy; 9.11 @@ -102,7 +103,14 @@ 9.12 9.13 win_width = xsz; 9.14 win_height = ysz; 9.15 - pending = RESHAPE | REDISPLAY; 9.16 + 9.17 + if(reshape(xsz, ysz) == -1) { 9.18 + XDestroyWindow(dpy, win); 9.19 + XCloseDisplay(dpy); 9.20 + return -1; 9.21 + } 9.22 + 9.23 + pending = REDISPLAY; 9.24 9.25 return 0; 9.26 } 9.27 @@ -196,10 +204,10 @@ 9.28 } 9.29 } 9.30 9.31 -void wsys_swap_buffers(void) 9.32 +void wsys_swap_buffers(VkSemaphore sem_wait) 9.33 { 9.34 - vku_present(swapchain, next_swapchain_image); 9.35 - next_swapchain_image = vku_get_next_image(swapchain); 9.36 + vku_present(swapchain, next_swapchain_image, sem_wait); 9.37 + next_swapchain_image = vku_get_next_image(swapchain, swapchain_getimg_sem); 9.38 } 9.39 9.40 void wsys_redisplay(void) 9.41 @@ -212,67 +220,74 @@ 9.42 pending |= QUIT; 9.43 } 9.44 9.45 +static int reshape(int x, int y) 9.46 +{ 9.47 + int i; 9.48 + VkSwapchainKHR sc; 9.49 + VkFormat fmt = VK_FORMAT_B8G8R8A8_UNORM; /* TODO enumerate and choose */ 9.50 + 9.51 + printf("DBG reshape\n"); 9.52 + 9.53 + if(!vkrpass) { 9.54 + if(!(vkrpass = vku_create_renderpass(fmt, VK_FORMAT_UNDEFINED))) { 9.55 + abort(); 9.56 + } 9.57 + } 9.58 + 9.59 + if(!(sc = vku_create_swapchain(surf, x, y, 2, fmt, 9.60 + VK_PRESENT_MODE_FIFO_KHR, swapchain))) { 9.61 + fprintf(stderr, "Failed to create %dx%d double-buffered swapchain\n", x, y); 9.62 + return -1; 9.63 + } 9.64 + swapchain = sc; 9.65 + 9.66 + free(swapchain_images); 9.67 + swapchain_size = 2; 9.68 + swapchain_images = vku_get_swapchain_images(sc, 0); 9.69 + next_swapchain_image = vku_get_next_image(swapchain, swapchain_getimg_sem); 9.70 + 9.71 + if(!swapchain_views) { 9.72 + if(!(swapchain_views = calloc(swapchain_size, sizeof *swapchain_views))) { 9.73 + fprintf(stderr, "Failed to allocate image views\n"); 9.74 + return -1; 9.75 + } 9.76 + } 9.77 + 9.78 + for(i=0; i<swapchain_size; i++) { 9.79 + if(swapchain_views[i]) { 9.80 + vku_destroy_view(swapchain_views[i]); 9.81 + } 9.82 + swapchain_views[i] = vku_create_view(swapchain_images[i], fmt); 9.83 + } 9.84 + 9.85 + if(!swapchain_framebuf) { 9.86 + if(!(swapchain_framebuf = calloc(swapchain_size, sizeof *swapchain_framebuf))) { 9.87 + fprintf(stderr, "Failed to allocate framebuffers\n"); 9.88 + return -1; 9.89 + } 9.90 + } 9.91 + 9.92 + for(i=0; i<swapchain_size; i++) { 9.93 + if(swapchain_framebuf[i]) { 9.94 + vku_destroy_framebuffer(swapchain_framebuf[i]); 9.95 + } 9.96 + swapchain_framebuf[i] = vku_create_framebuffer(swapchain_views[i], x, y, vkrpass); 9.97 + } 9.98 + 9.99 + if(cb.reshape) { 9.100 + cb.reshape(x, y); 9.101 + } 9.102 + return 0; 9.103 +} 9.104 + 9.105 int wsys_process_events(int mode) 9.106 { 9.107 - int i; 9.108 XEvent xev; 9.109 9.110 if(pending & RESHAPE) { 9.111 - VkSwapchainKHR sc; 9.112 - VkFormat fmt = VK_FORMAT_B8G8R8A8_UNORM; /* TODO enumerate and choose */ 9.113 - 9.114 - printf("DBG reshape\n"); 9.115 - 9.116 - if(!vkrpass) { 9.117 - if(!(vkrpass = vku_create_renderpass(fmt, VK_FORMAT_UNDEFINED))) { 9.118 - abort(); 9.119 - } 9.120 - } 9.121 - 9.122 - if(!(sc = vku_create_swapchain(surf, win_width, win_height, 2, fmt, 9.123 - VK_PRESENT_MODE_FIFO_KHR, swapchain))) { 9.124 - fprintf(stderr, "Failed to create %dx%d double-buffered swapchain\n", win_width, win_height); 9.125 + if(reshape(win_width, win_height) == -1) { 9.126 return -1; 9.127 } 9.128 - swapchain = sc; 9.129 - 9.130 - free(swapchain_images); 9.131 - swapchain_size = 2; 9.132 - swapchain_images = vku_get_swapchain_images(sc, 0); 9.133 - next_swapchain_image = vku_get_next_image(swapchain); 9.134 - 9.135 - if(!swapchain_views) { 9.136 - if(!(swapchain_views = calloc(swapchain_size, sizeof *swapchain_views))) { 9.137 - fprintf(stderr, "Failed to allocate image views\n"); 9.138 - return -1; 9.139 - } 9.140 - } 9.141 - 9.142 - for(i=0; i<swapchain_size; i++) { 9.143 - if(swapchain_views[i]) { 9.144 - vku_destroy_view(swapchain_views[i]); 9.145 - } 9.146 - swapchain_views[i] = vku_create_view(swapchain_images[i], fmt); 9.147 - } 9.148 - 9.149 - if(!swapchain_framebuf) { 9.150 - if(!(swapchain_framebuf = calloc(swapchain_size, sizeof *swapchain_framebuf))) { 9.151 - fprintf(stderr, "Failed to allocate framebuffers\n"); 9.152 - return -1; 9.153 - } 9.154 - } 9.155 - 9.156 - for(i=0; i<swapchain_size; i++) { 9.157 - if(swapchain_framebuf[i]) { 9.158 - vku_destroy_framebuffer(swapchain_framebuf[i]); 9.159 - } 9.160 - swapchain_framebuf[i] = vku_create_framebuffer(swapchain_views[i], 9.161 - win_width, win_height, vkrpass); 9.162 - } 9.163 - 9.164 - if(cb.reshape) { 9.165 - cb.reshape(win_width, win_height); 9.166 - } 9.167 pending &= ~RESHAPE; 9.168 } 9.169
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/vk_layer_settings.txt Wed Jun 27 01:57:55 2018 +0300 10.3 @@ -0,0 +1,35 @@ 10.4 +# VK_LAYER_LUNARG_device_limits Settings 10.5 +lunarg_device_limits.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.6 +lunarg_device_limits.report_flags = error,warn,perf 10.7 +lunarg_device_limits.log_filename = vkdebug.log 10.8 + 10.9 +# VK_LAYER_LUNARG_core_validation Settings 10.10 +lunarg_core_validation.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.11 +lunarg_core_validation.report_flags = error,warn,perf 10.12 +lunarg_core_validation.log_filename = vkdebug.log 10.13 + 10.14 +# VK_LAYER_LUNARG_image Settings 10.15 +lunarg_image.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.16 +lunarg_image.report_flags = error,warn,perf 10.17 +lunarg_image.log_filename = vkdebug.log 10.18 + 10.19 +# VK_LAYER_LUNARG_object_tracker Settings 10.20 +lunarg_object_tracker.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.21 +lunarg_object_tracker.report_flags = error,warn,perf 10.22 +lunarg_object_tracker.log_filename = vkdebug.log 10.23 + 10.24 +# VK_LAYER_LUNARG_parameter_validation Settings 10.25 +lunarg_parameter_validation.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.26 +lunarg_parameter_validation.report_flags = error,warn,perf 10.27 +lunarg_parameter_validation.log_filename = vkdebug.log 10.28 + 10.29 +# VK_LAYER_LUNARG_swapchain Settings 10.30 +lunarg_swapchain.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.31 +lunarg_swapchain.report_flags = error,warn,perf 10.32 +lunarg_swapchain.log_filename = vkdebug.log 10.33 + 10.34 +# VK_LAYER_GOOGLE_threading Settings 10.35 +google_threading.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG 10.36 +google_threading.report_flags = error,warn,perf 10.37 +google_threading.log_filename = vkdebug.log 10.38 +