diff --git a/client/include/gpu.h b/client/include/gpu.h index 7019288..f2bf518 100644 --- a/client/include/gpu.h +++ b/client/include/gpu.h @@ -24,6 +24,16 @@ #include #include +#define MAX_FRAMES_IN_FLIGHT 2 +#define WINDOW_MIN_WIDTH 800 +#define WINDOW_MIN_HEIGHT 600 + +typedef struct GPUBufferStruct { + VkBuffer buffers[MAX_FRAMES_IN_FLIGHT]; + VmaAllocation memory[MAX_FRAMES_IN_FLIGHT]; + VkDeviceSize size; +} GPUBuffer; + typedef struct GPUQueueStruct { VkQueue handle; uint32_t family; @@ -46,10 +56,6 @@ VkResult command_transition_image_layout(VkDevice device, VkCommandPool transfer }\ } -extern const uint32_t MAX_FRAMES_IN_FLIGHT; -extern const uint32_t WINDOW_MIN_WIDTH; -extern const uint32_t WINDOW_MIN_HEIGHT; - typedef struct SwapchainDetailsStruct { VkSurfaceCapabilitiesKHR capabilities; @@ -60,11 +66,18 @@ typedef struct SwapchainDetailsStruct { uint32_t present_modes_count; } SwapchainDetails; +typedef struct FrameContextStruct { + VkFence ready; + VkSemaphore image; + VkSemaphore render; + VkSemaphore transfer; + VkSemaphore compute; +} FrameContext; + typedef struct RenderContextStruct { VkInstance instance; VkDebugUtilsMessengerEXT debug_messenger; VkPhysicalDevice physical_device; - VkPhysicalDeviceMemoryProperties memories; VkSurfaceKHR surface; GPUQueue graphics_queue; GPUQueue present_queue; @@ -96,10 +109,7 @@ typedef struct RenderContextStruct { VkCommandBuffer* swapchain_command_buffers; - VkSemaphore* image_available_semaphores; - VkSemaphore* render_finished_semaphores; - - VkFence* in_flight_fences; + FrameContext frame[MAX_FRAMES_IN_FLIGHT]; uint32_t current_frame; vec2 window_scale; diff --git a/client/src/draw.c b/client/src/draw.c index ce2d364..14a203c 100644 --- a/client/src/draw.c +++ b/client/src/draw.c @@ -1,7 +1,7 @@ #include "draw.h" #include "gpu.h" -void record_ui_compute(VkCommandBuffer command_buffer, RenderContext* gpu, UIContext* ui_context, double time) { +void record_ui_compute(VkCommandBuffer command_buffer, UIContext* ui_context, double time) { UIPushConstant push = { .time = (float)time, .layer = 0, @@ -85,18 +85,18 @@ VkResult draw_frame( double time) { VkResult result; - result = vkWaitForFences(context->device, 1, &context->in_flight_fences[context->current_frame], VK_TRUE, UINT64_MAX); + result = vkWaitForFences(context->device, 1, &context->frame[context->current_frame].ready, VK_TRUE, UINT64_MAX); if(result != VK_SUCCESS) { return result; } - result = vkResetFences(context->device, 1, &context->in_flight_fences[context->current_frame]); + result = vkResetFences(context->device, 1, &context->frame[context->current_frame].ready); if(result != VK_SUCCESS) { return result; } uint32_t image_index; - result = vkAcquireNextImageKHR(context->device, context->swapchain, UINT64_MAX, context->image_available_semaphores[context->current_frame], VK_NULL_HANDLE, &image_index); + result = vkAcquireNextImageKHR(context->device, context->swapchain, UINT64_MAX, context->frame[context->current_frame].image, VK_NULL_HANDLE, &image_index); if(result != VK_SUCCESS) { return result; } @@ -134,7 +134,7 @@ VkResult draw_frame( .pClearValues = clear_values, }; - record_ui_compute(command_buffer, context, ui, time); + record_ui_compute(command_buffer, ui, time); vkCmdBeginRenderPass(command_buffer, &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE); // Render World @@ -149,15 +149,15 @@ VkResult draw_frame( VkSubmitInfo submit_info = { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .waitSemaphoreCount = 1, - .pWaitSemaphores = &context->image_available_semaphores[context->current_frame], + .pWaitSemaphores = &context->frame[context->current_frame].image, .pWaitDstStageMask = wait_stages, .commandBufferCount = 1, .pCommandBuffers = &context->swapchain_command_buffers[image_index], .signalSemaphoreCount = 1, - .pSignalSemaphores = &context->render_finished_semaphores[context->current_frame], + .pSignalSemaphores = &context->frame[context->current_frame].render, }; - result = vkQueueSubmit(context->graphics_queue.handle, 1, &submit_info, context->in_flight_fences[context->current_frame]); + result = vkQueueSubmit(context->graphics_queue.handle, 1, &submit_info, context->frame[context->current_frame].ready); if(result != VK_SUCCESS) { return result; } @@ -165,7 +165,7 @@ VkResult draw_frame( VkPresentInfoKHR present_info = { .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1, - .pWaitSemaphores = &context->render_finished_semaphores[context->current_frame], + .pWaitSemaphores = &context->frame[context->current_frame].render, .swapchainCount = 1, .pSwapchains = &context->swapchain, .pImageIndices = &image_index, diff --git a/client/src/gpu.c b/client/src/gpu.c index f00a702..36418d7 100644 --- a/client/src/gpu.c +++ b/client/src/gpu.c @@ -5,10 +5,6 @@ #include "vk_mem_alloc.h" #include "vulkan/vulkan_core.h" -const uint32_t MAX_FRAMES_IN_FLIGHT = 2; -const uint32_t WINDOW_MIN_WIDTH = 800; -const uint32_t WINDOW_MIN_HEIGHT = 600; - const char * validation_layers[] = { "VK_LAYER_KHRONOS_validation", //"VK_LAYER_LUNARG_api_dump", @@ -135,10 +131,8 @@ VkResult create_instance(VkInstance* instance) { .flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR, }; - VkResult result = vkCreateInstance(&instance_info, 0, instance); - if(result != VK_SUCCESS) { - return result; - } + VkResult result; + VK_RESULT(vkCreateInstance(&instance_info, 0, instance)); free(requested_extensions); return VK_SUCCESS; @@ -171,10 +165,7 @@ VkResult create_debug_messenger(VkInstance instance, VkDebugUtilsMessengerEXT* d PFN_vkCreateDebugUtilsMessengerEXT func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"); VkResult result; - result = func(instance, &messenger_info, 0, debug_messenger); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(func(instance, &messenger_info, 0, debug_messenger)); return VK_SUCCESS; } @@ -182,10 +173,7 @@ VkResult create_debug_messenger(VkInstance instance, VkDebugUtilsMessengerEXT* d VkResult get_best_physical_device(VkInstance instance, VkPhysicalDevice* device) { uint32_t device_count = 0; VkResult result; - result = vkEnumeratePhysicalDevices(instance, &device_count, 0); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkEnumeratePhysicalDevices(instance, &device_count, 0)); VkPhysicalDevice* devices = malloc(sizeof(VkPhysicalDevice)*device_count); result = vkEnumeratePhysicalDevices(instance, &device_count, devices); @@ -375,10 +363,8 @@ VkResult create_logical_device(VkPhysicalDevice physical_device, VkSurfaceKHR su .pNext = &features_12, }; - VkResult result = vkCreateDevice(physical_device, &device_create_info, 0, device); - if(result != VK_SUCCESS) { - return result; - } + VkResult result; + VK_RESULT(vkCreateDevice(physical_device, &device_create_info, 0, device)); vkGetDeviceQueue(*device, graphics_queue->family, graphics_queue->index, &graphics_queue->handle); vkGetDeviceQueue(*device, present_queue->family, present_queue->index, &present_queue->handle); @@ -396,10 +382,8 @@ VkResult create_memory_allocator(VkInstance instance, VkPhysicalDevice physical_ .flags = VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT, }; - VkResult result = vmaCreateAllocator(&allocator_create_info, allocator); - if(result != VK_SUCCESS) { - return result; - } + VkResult result; + VK_RESULT(vmaCreateAllocator(&allocator_create_info, allocator)); return VK_SUCCESS; } @@ -410,16 +394,12 @@ VkResult get_swapchain_details(VkPhysicalDevice physical_device, VkSurfaceKHR su VkResult result; - result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, surface, &details->capabilities); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, surface, &details->capabilities)); + + VK_RESULT(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &details->formats_count, 0)); - result = vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &details->formats_count, 0); - if(result != VK_SUCCESS) { - return result; - } details->formats = malloc(sizeof(VkSurfaceFormatKHR)*details->formats_count); + result = vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &details->formats_count, details->formats); if(result != VK_SUCCESS) { free(details->formats); @@ -502,20 +482,14 @@ VkResult create_swapchain(VkDevice device, VkSurfaceFormatKHR format, VkPresentM VkResult result; - result = vkCreateSwapchainKHR(device, &swapchain_info, 0, swapchain); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkCreateSwapchainKHR(device, &swapchain_info, 0, swapchain)); return VK_SUCCESS; } VkResult get_swapchain_images(VkDevice device, VkSwapchainKHR swapchain, VkImage** images, uint32_t* image_count) { VkResult result; - result = vkGetSwapchainImagesKHR(device, swapchain, image_count, 0); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkGetSwapchainImagesKHR(device, swapchain, image_count, 0)); *images = malloc(sizeof(VkImage)*(*image_count)); if(*images == 0) { @@ -581,7 +555,7 @@ VkResult find_depth_format(VkPhysicalDevice physical_device, VkImageTiling tilin return VK_SUCCESS; } } - return VK_ERROR_UNKNOWN; + return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult create_render_pass(VkDevice device, VkSurfaceFormatKHR format, VkFormat depth_format, VkRenderPass* render_pass) { @@ -673,10 +647,8 @@ VkResult create_render_pass(VkDevice device, VkSurfaceFormatKHR format, VkFormat .pDependencies = dependencies, }; - VkResult result = vkCreateRenderPass(device, &render_info, 0, render_pass); - if(result != VK_SUCCESS) { - return result; - } + VkResult result; + VK_RESULT(vkCreateRenderPass(device, &render_info, 0, render_pass)); return VK_SUCCESS; } @@ -715,46 +687,44 @@ VkResult create_swapchain_framebuffers(VkDevice device, uint32_t image_count, Vk return VK_SUCCESS; } -VkSemaphore* create_semaphores(VkDevice device, VkSemaphoreCreateFlags flags, uint32_t count) { - VkSemaphore* semaphores = malloc(sizeof(VkSemaphore)*count); - if(semaphores == 0) { - return 0; - } +VkSemaphore create_semaphore(VkDevice device, VkSemaphoreCreateFlags flags) { VkSemaphoreCreateInfo semaphore_info = { .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, .flags = flags, }; - for(uint32_t i = 0; i < count; i++) { - VkResult result = vkCreateSemaphore(device, &semaphore_info, 0, &semaphores[i]); - if(result != VK_SUCCESS) { - free(semaphores); - return 0; - } - } - return semaphores; -} - -VkFence* create_fences(VkDevice device, VkFenceCreateFlags flags, uint32_t count) { - VkFence* fences = malloc(sizeof(VkFence)*count); - if(fences == 0) { + VkSemaphore semaphore; + VkResult result = vkCreateSemaphore(device, &semaphore_info, 0, &semaphore); + if(result != VK_SUCCESS) { return 0; } + return semaphore; +} + +VkFence create_fence(VkDevice device, VkFenceCreateFlags flags) { VkFenceCreateInfo fence_info = { .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .flags = flags, }; - for(uint32_t i = 0; i < count; i++) { - VkResult result = vkCreateFence(device, &fence_info, 0, &fences[i]); - if(result != VK_SUCCESS) { - free(fences); - return 0; - } + VkFence fence; + VkResult result = vkCreateFence(device, &fence_info, 0, &fence); + if(result != VK_SUCCESS) { + return VK_NULL_HANDLE; } - return fences; + + return fence; +} + +VkResult create_frame_context(VkDevice device, FrameContext* frame) { + frame->ready = create_fence(device, VK_FENCE_CREATE_SIGNALED_BIT); + frame->image = create_semaphore(device, 0); + frame->render = create_semaphore(device, 0); + frame->transfer = create_semaphore(device, 0); + frame->compute = create_semaphore(device, 0); + return VK_SUCCESS; } VkCommandBuffer* create_command_buffers(VkDevice device, VkCommandPool command_pool, uint32_t image_count) { @@ -805,10 +775,8 @@ VkResult create_depth_image(VkDevice device, VkFormat depth_format, VkExtent2D s .usage = VMA_MEMORY_USAGE_AUTO, }; - VkResult result = vmaCreateImage(allocator, &depth_image_info, &allocation_info, depth_image, depth_image_memory, NULL); - if(result != VK_SUCCESS) { - return result; - } + VkResult result; + VK_RESULT(vmaCreateImage(allocator, &depth_image_info, &allocation_info, depth_image, depth_image_memory, NULL)); VkImageViewCreateInfo depth_view_info = { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, @@ -830,15 +798,9 @@ VkResult create_depth_image(VkDevice device, VkFormat depth_format, VkExtent2D s }, }; - result = vkCreateImageView(device, &depth_view_info, 0, depth_image_view); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkCreateImageView(device, &depth_view_info, 0, depth_image_view)); - result = command_transition_image_layout(device, extra_graphics_pool, graphics_queue, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL, *depth_image, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, VK_IMAGE_ASPECT_DEPTH_BIT); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(command_transition_image_layout(device, extra_graphics_pool, graphics_queue, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL, *depth_image, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, VK_IMAGE_ASPECT_DEPTH_BIT)); return VK_SUCCESS; } @@ -853,131 +815,67 @@ VkResult init_vulkan(GLFWwindow* window, RenderContext* context) { GLFWmonitor** monitors = glfwGetMonitors(&monitor_count); glfwGetMonitorContentScale(monitors[0], &context->window_scale[0], &context->window_scale[1]); - result = create_instance(&context->instance); - if(result != VK_SUCCESS) { - return result; - } - - result = create_debug_messenger(context->instance, &context->debug_messenger); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_instance(&context->instance)); - result = get_best_physical_device(context->instance, &context->physical_device); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_debug_messenger(context->instance, &context->debug_messenger)); - vkGetPhysicalDeviceMemoryProperties(context->physical_device, &context->memories); + VK_RESULT(get_best_physical_device(context->instance, &context->physical_device)); - result = glfwCreateWindowSurface(context->instance, window, 0, &context->surface); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(glfwCreateWindowSurface(context->instance, window, 0, &context->surface)); - result = create_logical_device(context->physical_device, context->surface, &context->graphics_queue, &context->present_queue, &context->transfer_queue, &context->device); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_logical_device(context->physical_device, context->surface, &context->graphics_queue, &context->present_queue, &context->transfer_queue, &context->device)); - result = create_memory_allocator(context->instance, context->physical_device, context->device, &context->allocator); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_memory_allocator(context->instance, context->physical_device, context->device, &context->allocator)); VkCommandPoolCreateInfo extra_pool_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .queueFamilyIndex = context->graphics_queue.family, .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, }; - result = vkCreateCommandPool(context->device, &extra_pool_info, 0, &context->extra_graphics_pool); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkCreateCommandPool(context->device, &extra_pool_info, 0, &context->extra_graphics_pool)); VkCommandPoolCreateInfo graphics_pool_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, .queueFamilyIndex = context->graphics_queue.family, }; - result = vkCreateCommandPool(context->device, &graphics_pool_info, 0, &context->graphics_pool); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkCreateCommandPool(context->device, &graphics_pool_info, 0, &context->graphics_pool)); VkCommandPoolCreateInfo transfer_pool_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, .queueFamilyIndex = context->transfer_queue.family, }; - result = vkCreateCommandPool(context->device, &transfer_pool_info, 0, &context->transfer_pool); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(vkCreateCommandPool(context->device, &transfer_pool_info, 0, &context->transfer_pool)); - context->image_available_semaphores = create_semaphores(context->device, 0, MAX_FRAMES_IN_FLIGHT); - if(context->image_available_semaphores == NULL) { - return VK_ERROR_UNKNOWN; + for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { + VK_RESULT(create_frame_context(context->device, &context->frame[i])); } - context->render_finished_semaphores = create_semaphores(context->device, 0, MAX_FRAMES_IN_FLIGHT); - if(context->render_finished_semaphores == NULL) { - return VK_ERROR_UNKNOWN; - } - - context->in_flight_fences = create_fences(context->device, VK_FENCE_CREATE_SIGNALED_BIT, MAX_FRAMES_IN_FLIGHT); - if(context->in_flight_fences == NULL) { - return VK_ERROR_UNKNOWN; - } - - result = get_swapchain_details(context->physical_device, context->surface, &context->swapchain_details); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(get_swapchain_details(context->physical_device, context->surface, &context->swapchain_details)); context->swapchain_format = choose_swapchain_format(context->swapchain_details); context->swapchain_present_mode = choose_present_mode(context->swapchain_details); context->swapchain_extent = choose_swapchain_extent(context->swapchain_details); context->swapchain = VK_NULL_HANDLE; - result = create_swapchain(context->device, context->swapchain_format, context->swapchain_present_mode, context->swapchain_extent, context->surface, context->swapchain_details.capabilities, context->graphics_queue.family, context->present_queue.family, &context->swapchain); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_swapchain(context->device, context->swapchain_format, context->swapchain_present_mode, context->swapchain_extent, context->surface, context->swapchain_details.capabilities, context->graphics_queue.family, context->present_queue.family, &context->swapchain)); - result = get_swapchain_images(context->device, context->swapchain, &context->swapchain_images, &context->swapchain_image_count); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(get_swapchain_images(context->device, context->swapchain, &context->swapchain_images, &context->swapchain_image_count)); context->swapchain_command_buffers = create_command_buffers(context->device, context->graphics_pool, context->swapchain_image_count); if(context->swapchain_command_buffers == NULL) { - return VK_ERROR_UNKNOWN; + return VK_ERROR_VALIDATION_FAILED_EXT; } - result = create_image_views(context->device, context->swapchain_image_count, context->swapchain_images, context->swapchain_format, &context->swapchain_image_views); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_image_views(context->device, context->swapchain_image_count, context->swapchain_images, context->swapchain_format, &context->swapchain_image_views)); - result = find_depth_format(context->physical_device, VK_IMAGE_TILING_OPTIMAL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, &context->depth_format); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(find_depth_format(context->physical_device, VK_IMAGE_TILING_OPTIMAL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, &context->depth_format)); - result = create_render_pass(context->device, context->swapchain_format, context->depth_format, &context->render_pass); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_render_pass(context->device, context->swapchain_format, context->depth_format, &context->render_pass)); - result = create_depth_image(context->device, context->depth_format, context->swapchain_extent, context->allocator, context->extra_graphics_pool, context->graphics_queue, &context->depth_image, &context->depth_image_memory, &context->depth_image_view); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_depth_image(context->device, context->depth_format, context->swapchain_extent, context->allocator, context->extra_graphics_pool, context->graphics_queue, &context->depth_image, &context->depth_image_memory, &context->depth_image_view)); - result = create_swapchain_framebuffers(context->device, context->swapchain_image_count, context->swapchain_image_views, context->depth_image_view, context->render_pass, context->swapchain_extent, &context->swapchain_framebuffers); - if(result != VK_SUCCESS) { - return result; - } + VK_RESULT(create_swapchain_framebuffers(context->device, context->swapchain_image_count, context->swapchain_image_views, context->depth_image_view, context->render_pass, context->swapchain_extent, &context->swapchain_framebuffers)); context->current_frame = 0; return VK_SUCCESS; @@ -999,10 +897,8 @@ VkResult create_transfer_buffer( .usage = VMA_MEMORY_USAGE_CPU_TO_GPU, }; - VkResult result = vmaCreateBuffer(allocator, &buffer_info, &memory_info, buffer, memory, NULL); - if(result != VK_SUCCESS) { - return result; - } + VkResult result; + VK_RESULT(vmaCreateBuffer(allocator, &buffer_info, &memory_info, buffer, memory, NULL)); result = vmaMapMemory(allocator, *memory, mapped); if(result != VK_SUCCESS) { diff --git a/client/src/main.c b/client/src/main.c index fd4e5c8..156c238 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -200,10 +200,9 @@ int main_thread(void* data) { int x = 0; while(glfwWindowShouldClose(context->window) == 0) { glfwPollEvents(); - if(x == 1000) { + if(x == 0 && glfwGetTime() > 2.0) { + x = 1; test_ui(&context->render, &context->ui); - } else { - x += 1; } }