create command pool and buffer

This commit is contained in:
Ivan Avdeev 2021-01-13 12:10:36 -08:00
parent 5600cf45ef
commit e7a99c2558
2 changed files with 28 additions and 0 deletions

View File

@ -540,6 +540,26 @@ static qboolean createSwapchain( void )
return true;
}
static qboolean createCommandPool( void ) {
VkCommandPoolCreateInfo cpci = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.queueFamilyIndex = 0,
.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
};
VkCommandBufferAllocateInfo cbai = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.commandBufferCount = 1,
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
};
XVK_CHECK(vkCreateCommandPool(vk_core.device, &cpci, NULL, &vk_core.command_pool));
cbai.commandPool = vk_core.command_pool;
XVK_CHECK(vkAllocateCommandBuffers(vk_core.device, &cbai, &vk_core.cb));
return true;
}
qboolean R_VkInit( void )
{
vk_core.debug = !!(gEngine.Sys_CheckParm("-vkdebug") || gEngine.Sys_CheckParm("-gldebug"));
@ -592,6 +612,9 @@ qboolean R_VkInit( void )
if (!createSwapchain())
return false;
if (!createCommandPool())
return false;
// TODO initAllocator()
// TODO initPipelines()

View File

@ -41,6 +41,9 @@ typedef struct vulkan_core_s {
VkImageView *image_views;
VkFramebuffer *framebuffers;
} swapchain;
VkCommandPool command_pool;
VkCommandBuffer cb;
} vulkan_core_t;
extern vulkan_core_t vk_core;
@ -68,6 +71,8 @@ const char *resultName(VkResult result);
X(vkCreatePipelineLayout) \
X(vkCreateGraphicsPipelines) \
X(vkCreateShaderModule) \
X(vkCreateCommandPool) \
X(vkAllocateCommandBuffers) \
#define X(f) extern PFN_##f f;
DEVICE_FUNCS(X)