[dxvk] Add fence support to command list

Co-authored-by: Derek Lesho <dlesho@codeweavers.com>
This commit is contained in:
Philip Rebohle 2021-10-22 16:49:22 +02:00
parent 4167e1b887
commit 05a827703b
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 94 additions and 4 deletions

View File

@ -106,7 +106,7 @@ namespace dxvk {
VkSemaphoreSubmitInfo waitInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO };
waitInfo.semaphore = m_sdmaSemaphore;
waitInfo.stageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
waitInfo.stageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT;
m_submission.waitSync.push_back(waitInfo);
}
}
@ -126,7 +126,7 @@ namespace dxvk {
if (waitSemaphore) {
VkSemaphoreSubmitInfo waitInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO };
waitInfo.semaphore = waitSemaphore;
waitInfo.stageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
waitInfo.stageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT;
m_submission.waitSync.push_back(waitInfo);
}
@ -137,6 +137,22 @@ namespace dxvk {
m_submission.wakeSync.push_back(signalInfo);
}
for (const auto& entry : m_waitSemaphores) {
VkSemaphoreSubmitInfo waitInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO };
waitInfo.semaphore = entry.fence->handle();
waitInfo.value = entry.value;
waitInfo.stageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT;
m_submission.waitSync.push_back(waitInfo);
}
for (const auto& entry : m_signalSemaphores) {
VkSemaphoreSubmitInfo signalInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO };
signalInfo.semaphore = entry.fence->handle();
signalInfo.value = entry.value;
signalInfo.stageMask = VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT;
m_submission.wakeSync.push_back(signalInfo);
}
return submitToQueue(graphics.queueHandle, m_fence, m_submission);
}
@ -207,6 +223,9 @@ namespace dxvk {
descriptorPools.second->recycleDescriptorPool(descriptorPools.first);
m_descriptorPools.clear();
m_waitSemaphores.clear();
m_signalSemaphores.clear();
}

View File

@ -5,6 +5,7 @@
#include "dxvk_bind_mask.h"
#include "dxvk_buffer.h"
#include "dxvk_descriptor.h"
#include "dxvk_fence.h"
#include "dxvk_gpu_event.h"
#include "dxvk_gpu_query.h"
#include "dxvk_lifetime.h"
@ -195,6 +196,26 @@ namespace dxvk {
m_signalTracker.notify();
}
/**
* \brief Waits for fence
*
* \param [in] fence Fence to wait on
* \param [in] value Value to wait for
*/
void waitFence(Rc<DxvkFence> fence, uint64_t value) {
m_waitSemaphores.emplace_back(std::move(fence), value);
}
/**
* \brief Signals fence
*
* \param [in] fence Fence to signal
* \param [in] value Value to signal to
*/
void signalFence(Rc<DxvkFence> fence, uint64_t value) {
m_signalSemaphores.emplace_back(std::move(fence), value);
}
/**
* \brief Resets the command list
*
@ -784,7 +805,7 @@ namespace dxvk {
VkCommandBuffer m_sdmaBuffer = VK_NULL_HANDLE;
VkSemaphore m_sdmaSemaphore = VK_NULL_HANDLE;
DxvkCmdBufferFlags m_cmdBuffersUsed;
DxvkLifetimeTracker m_resources;
DxvkSignalTracker m_signalTracker;
@ -794,6 +815,9 @@ namespace dxvk {
DxvkStatCounters m_statCounters;
DxvkQueueSubmission m_submission;
std::vector<DxvkFenceValuePair> m_waitSemaphores;
std::vector<DxvkFenceValuePair> m_signalSemaphores;
std::vector<std::pair<
Rc<DxvkDescriptorPool>,
Rc<DxvkDescriptorManager>>> m_descriptorPools;

View File

@ -2646,6 +2646,16 @@ namespace dxvk {
}
void DxvkContext::waitFence(const Rc<DxvkFence>& fence, uint64_t value) {
m_cmd->waitFence(fence, value);
}
void DxvkContext::signalFence(const Rc<DxvkFence>& fence, uint64_t value) {
m_cmd->signalFence(fence, value);
}
void DxvkContext::beginDebugLabel(VkDebugUtilsLabelEXT *label) {
if (!m_device->instance()->extensions().extDebugUtils)
return;

View File

@ -1088,7 +1088,27 @@ namespace dxvk {
void signal(
const Rc<sync::Signal>& signal,
uint64_t value);
/**
* \brief Waits for fence
*
* Stalls current command list execution until
* the fence reaches the given value or higher.
* \param [in] fence Fence to wait on
* \param [in] value Value to wait on
*/
void waitFence(const Rc<DxvkFence>& fence, uint64_t value);
/**
* \brief Signals fence
*
* Signals fence to the given value once the current
* command list execution completes on the GPU.
* \param [in] fence Fence to signal
* \param [in] value Value to signal
*/
void signalFence(const Rc<DxvkFence>& fence, uint64_t value);
/**
* \brief Begins a debug label region
* \param [in] label The debug label

View File

@ -2,6 +2,8 @@
#include <functional>
#include <queue>
#include <utility>
#include <vector>
#include "dxvk_resource.h"
@ -10,6 +12,7 @@
namespace dxvk {
class DxvkDevice;
class DxvkFence;
using DxvkFenceEvent = std::function<void ()>;
@ -20,6 +23,20 @@ namespace dxvk {
uint64_t initialValue;
};
/**
* \brief Fence-value pair
*/
struct DxvkFenceValuePair {
DxvkFenceValuePair() { }
DxvkFenceValuePair(Rc<DxvkFence>&& fence_, uint64_t value_)
: fence(std::move(fence_)), value(value_) { }
DxvkFenceValuePair(const Rc<DxvkFence>& fence_, uint64_t value_)
: fence(fence_), value(value_) { }
Rc<DxvkFence> fence;
uint64_t value;
};
/**
* \brief Fence
*