[dxvk] Some minor refactoring

This commit is contained in:
Philip Rebohle 2017-12-01 14:27:53 +01:00
parent cc408e3329
commit 802fbe3cfd
3 changed files with 39 additions and 24 deletions

View File

@ -35,6 +35,30 @@ namespace dxvk {
}
void DxvkCommandList::submit(
VkQueue queue,
VkSemaphore waitSemaphore,
VkSemaphore wakeSemaphore,
VkFence fence) {
const VkPipelineStageFlags waitStageMask
= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
VkSubmitInfo info;
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.pNext = nullptr;
info.waitSemaphoreCount = waitSemaphore == VK_NULL_HANDLE ? 0 : 1;
info.pWaitSemaphores = &waitSemaphore;
info.pWaitDstStageMask = &waitStageMask;
info.commandBufferCount = 1;
info.pCommandBuffers = &m_buffer;
info.signalSemaphoreCount = wakeSemaphore == VK_NULL_HANDLE ? 0 : 1;
info.pSignalSemaphores = &wakeSemaphore;
if (m_vkd->vkQueueSubmit(queue, 1, &info, fence) != VK_SUCCESS)
throw DxvkError("DxvkDevice::submitCommandList: Command submission failed");
}
void DxvkCommandList::beginRecording() {
VkCommandBufferBeginInfo info;
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;

View File

@ -26,12 +26,18 @@ namespace dxvk {
~DxvkCommandList();
/**
* \brief Command buffer handle
* \returns Command buffer handle
* \brief Submits command list
*
* \param [in] queue Device queue
* \param [in] waitSemaphore Semaphore to wait on
* \param [in] wakeSemaphore Semaphore to signal
* \param [in] fence Fence to signal
*/
VkCommandBuffer handle() const {
return m_buffer;
}
void submit(
VkQueue queue,
VkSemaphore waitSemaphore,
VkSemaphore wakeSemaphore,
VkFence fence);
/**
* \brief Begins recording

View File

@ -105,9 +105,8 @@ namespace dxvk {
const Rc<DxvkSemaphore>& wakeSync) {
Rc<DxvkFence> fence = new DxvkFence(m_vkd);
VkCommandBuffer commandBuffer = commandList->handle();
VkSemaphore waitSemaphore = VK_NULL_HANDLE;
VkSemaphore wakeSemaphore = VK_NULL_HANDLE;
VkSemaphore waitSemaphore = VK_NULL_HANDLE;
VkSemaphore wakeSemaphore = VK_NULL_HANDLE;
if (waitSync != nullptr) {
waitSemaphore = waitSync->handle();
@ -119,22 +118,8 @@ namespace dxvk {
commandList->trackResource(wakeSync);
}
const VkPipelineStageFlags waitStageMask
= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
VkSubmitInfo info;
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.pNext = nullptr;
info.waitSemaphoreCount = waitSemaphore == VK_NULL_HANDLE ? 0 : 1;
info.pWaitSemaphores = &waitSemaphore;
info.pWaitDstStageMask = &waitStageMask;
info.commandBufferCount = commandBuffer == VK_NULL_HANDLE ? 0 : 1;
info.pCommandBuffers = &commandBuffer;
info.signalSemaphoreCount = wakeSemaphore == VK_NULL_HANDLE ? 0 : 1;
info.pSignalSemaphores = &wakeSemaphore;
if (m_vkd->vkQueueSubmit(m_graphicsQueue, 1, &info, fence->handle()) != VK_SUCCESS)
throw DxvkError("DxvkDevice::submitCommandList: Command submission failed");
commandList->submit(m_graphicsQueue,
waitSemaphore, wakeSemaphore, fence->handle());
// TODO Delay synchronization by putting these into a ring buffer
fence->wait(std::numeric_limits<uint64_t>::max());