1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 22:29:15 +01:00

[dxvk] Use DxvkCommandPool

This commit is contained in:
Philip Rebohle 2022-08-22 14:14:06 +02:00
parent c3a721f562
commit e378be826e
2 changed files with 15 additions and 52 deletions

View File

@ -164,49 +164,18 @@ namespace dxvk {
if (m_vkd->vkCreateSemaphore(m_vkd->device(), &semaphoreInfo, nullptr, &m_sdmaSemaphore)) if (m_vkd->vkCreateSemaphore(m_vkd->device(), &semaphoreInfo, nullptr, &m_sdmaSemaphore))
throw DxvkError("DxvkCommandList: Failed to create semaphore"); throw DxvkError("DxvkCommandList: Failed to create semaphore");
VkCommandPoolCreateInfo poolInfo; m_graphicsPool = new DxvkCommandPool(device, graphicsQueue.queueFamily);
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
poolInfo.pNext = nullptr;
poolInfo.flags = 0;
poolInfo.queueFamilyIndex = graphicsQueue.queueFamily;
if (m_vkd->vkCreateCommandPool(m_vkd->device(), &poolInfo, nullptr, &m_graphicsPool) != VK_SUCCESS)
throw DxvkError("DxvkCommandList: Failed to create graphics command pool");
if (m_device->hasDedicatedTransferQueue()) {
poolInfo.queueFamilyIndex = transferQueue.queueFamily;
if (m_vkd->vkCreateCommandPool(m_vkd->device(), &poolInfo, nullptr, &m_transferPool) != VK_SUCCESS) if (transferQueue.queueFamily != graphicsQueue.queueFamily)
throw DxvkError("DxvkCommandList: Failed to create transfer command pool"); m_transferPool = new DxvkCommandPool(device, transferQueue.queueFamily);
} else
m_transferPool = m_graphicsPool;
VkCommandBufferAllocateInfo cmdInfoGfx;
cmdInfoGfx.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
cmdInfoGfx.pNext = nullptr;
cmdInfoGfx.commandPool = m_graphicsPool;
cmdInfoGfx.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
cmdInfoGfx.commandBufferCount = 1;
VkCommandBufferAllocateInfo cmdInfoDma;
cmdInfoDma.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
cmdInfoDma.pNext = nullptr;
cmdInfoDma.commandPool = m_transferPool ? m_transferPool : m_graphicsPool;
cmdInfoDma.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
cmdInfoDma.commandBufferCount = 1;
if (m_vkd->vkAllocateCommandBuffers(m_vkd->device(), &cmdInfoGfx, &m_cmd.execBuffer) != VK_SUCCESS
|| m_vkd->vkAllocateCommandBuffers(m_vkd->device(), &cmdInfoGfx, &m_cmd.initBuffer) != VK_SUCCESS
|| m_vkd->vkAllocateCommandBuffers(m_vkd->device(), &cmdInfoDma, &m_cmd.sdmaBuffer) != VK_SUCCESS)
throw DxvkError("DxvkCommandList: Failed to allocate command buffer");
} }
DxvkCommandList::~DxvkCommandList() { DxvkCommandList::~DxvkCommandList() {
this->reset(); this->reset();
m_vkd->vkDestroyCommandPool(m_vkd->device(), m_graphicsPool, nullptr);
m_vkd->vkDestroyCommandPool(m_vkd->device(), m_transferPool, nullptr);
m_vkd->vkDestroySemaphore(m_vkd->device(), m_sdmaSemaphore, nullptr); m_vkd->vkDestroySemaphore(m_vkd->device(), m_sdmaSemaphore, nullptr);
} }
@ -270,20 +239,10 @@ namespace dxvk {
void DxvkCommandList::beginRecording() { void DxvkCommandList::beginRecording() {
VkCommandBufferBeginInfo info; m_cmd = DxvkCommandSubmissionInfo();
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; m_cmd.execBuffer = m_graphicsPool->getCommandBuffer();
info.pNext = nullptr; m_cmd.initBuffer = m_graphicsPool->getCommandBuffer();
info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; m_cmd.sdmaBuffer = m_transferPool->getCommandBuffer();
info.pInheritanceInfo = nullptr;
if ((m_graphicsPool && m_vkd->vkResetCommandPool(m_vkd->device(), m_graphicsPool, 0) != VK_SUCCESS)
|| (m_transferPool && m_vkd->vkResetCommandPool(m_vkd->device(), m_transferPool, 0) != VK_SUCCESS))
Logger::err("DxvkCommandList: Failed to reset command buffer");
if (m_vkd->vkBeginCommandBuffer(m_cmd.execBuffer, &info) != VK_SUCCESS
|| m_vkd->vkBeginCommandBuffer(m_cmd.initBuffer, &info) != VK_SUCCESS
|| m_vkd->vkBeginCommandBuffer(m_cmd.sdmaBuffer, &info) != VK_SUCCESS)
Logger::err("DxvkCommandList: Failed to begin command buffer");
} }
@ -327,6 +286,10 @@ namespace dxvk {
m_signalSemaphores.clear(); m_signalSemaphores.clear();
m_wsiSemaphores = vk::PresenterSync(); m_wsiSemaphores = vk::PresenterSync();
// Reset actual command buffers and pools
m_graphicsPool->reset();
m_transferPool->reset();
} }
} }

View File

@ -952,8 +952,8 @@ namespace dxvk {
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
Rc<vk::InstanceFn> m_vki; Rc<vk::InstanceFn> m_vki;
VkCommandPool m_graphicsPool = VK_NULL_HANDLE; Rc<DxvkCommandPool> m_graphicsPool;
VkCommandPool m_transferPool = VK_NULL_HANDLE; Rc<DxvkCommandPool> m_transferPool;
VkSemaphore m_sdmaSemaphore = VK_NULL_HANDLE; VkSemaphore m_sdmaSemaphore = VK_NULL_HANDLE;