basic rendering for both opengl and vulkan
This commit is contained in:
parent
4b18afa040
commit
dadd2edaf1
29 changed files with 1140 additions and 38 deletions
42
rendering/vk/command.c
Normal file
42
rendering/vk/command.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* SPDX-License-Identifier:BSD-3-Clause */
|
||||
#include "command.h"
|
||||
#include "../../core/log.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
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");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue