/* SPDX-License-Identifier:BSD-3-Clause */ #include "command.h" #include "../../core/log.h" #include void vk_command_pool_init(struct renderer_context *context) { VkCommandPoolCreateInfo pool_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, .queueFamilyIndex = context->queue_indices.graphics }; if (vkCreateCommandPool(context->device, &pool_info, NULL, &context->command_pool) != VK_SUCCESS) { fatal("Can't create command pool.\n"); } log_info("Command pool created.\n"); } void vk_command_pool_deinit(struct renderer_context *context) { vkDestroyCommandPool(context->device, context->command_pool, NULL); } void vk_command_buffers_init(struct renderer_context *context) { context->command_buffers = malloc(sizeof(VkCommandBuffer) * context->swapchain.image_count); VkCommandBufferAllocateInfo alloc_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, .commandPool = context->command_pool, .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, .commandBufferCount = context->swapchain.image_count }; if (vkAllocateCommandBuffers(context->device, &alloc_info, context->command_buffers) != VK_SUCCESS) { fatal("Can't allocate command buffers.\n"); } log_info("Command buffers allocated.\n"); }