static rhi_cmdlist Rhi_CreateCmdList(const char* name, rhi_queue_type queueType) { VkCommandPool cmdPool = GetDeviceQueue(queueType)->cmdPool; VkCommandBufferAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; allocInfo.commandPool = cmdPool; allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; allocInfo.commandBufferCount = 1; VkCommandBuffer commandBuffer; VK_CHECK(vkAllocateCommandBuffers(rhi->dev, &allocInfo, &commandBuffer)); rhi_cmdlist_data *Cmd = nullptr; for (uint32_t i = 0; i < rhi->limits.CmdListsCount; ++i) { if (!(rhi->CmdLists[i].Flags & VulkanFlag_Used)) { Cmd = &rhi->CmdLists[i]; break; } } MEM_ZERO(Cmd, 0); Cmd->Flags = VulkanFlag_Used; Cmd->cmdbuf = commandBuffer; Cmd->queueType = queueType; VulkanNameHandle(VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)Cmd->cmdbuf, name); return Cmd; } static void Rhi_ResetCmdList(rhi_cmdlist cmd) { rhi_cmdlist_data* Cmd = (rhi_cmdlist_data*)cmd; VkCommandBuffer cmdbuf = Cmd->cmdbuf; VK_CHECK(vkResetCommandBuffer(cmdbuf, 0)); Cmd->frameConstantHead = 0; Cmd->passConstantHead = Cmd->frameConstantHead; Cmd->drawConstantHead = Cmd->passConstantHead + (rhi->limits.MaxPassCount * CbvOffset(rhi->limits.PassConstantSize)); } static void Rhi_DestroyCmdList(rhi_cmdlist cmd) { rhi_cmdlist_data* Cmd = (rhi_cmdlist_data*)cmd; VkCommandPool cmdPool = GetDeviceQueue(Cmd->queueType)->cmdPool; vkFreeCommandBuffers(rhi->dev, cmdPool, 1, &Cmd->cmdbuf); }