1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxvk] Submit sparse binding operations alongside command buffers

This commit is contained in:
Philip Rebohle 2022-08-22 20:55:53 +02:00
parent d3b6502a17
commit 2615af7664
2 changed files with 36 additions and 3 deletions

View File

@ -194,6 +194,7 @@ namespace dxvk {
const auto& graphics = m_device->queues().graphics;
const auto& transfer = m_device->queues().transfer;
const auto& sparse = m_device->queues().sparse;
m_commandSubmission.reset();
@ -203,15 +204,41 @@ namespace dxvk {
const auto& cmd = m_cmdSubmissions[i];
auto sparseBind = cmd.sparseBind
? &m_cmdSparseBinds[cmd.sparseCmd]
: nullptr;
if (sparseBind) {
// Sparse bindig needs to serialize command execution, so wait
// for any prior submissions, then block any subsequent ones
sparseBind->waitSemaphore(semaphore, semaphoreValue);
sparseBind->signalSemaphore(semaphore, ++semaphoreValue);
m_commandSubmission.waitSemaphore(semaphore, semaphoreValue,
VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
}
if (isFirst) {
// Wait for per-command list semaphores on first submission
for (const auto& entry : m_waitSemaphores) {
m_commandSubmission.waitSemaphore(
entry.fence->handle(),
entry.value, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
if (sparseBind) {
sparseBind->waitSemaphore(
entry.fence->handle(),
entry.value);
} else {
m_commandSubmission.waitSemaphore(
entry.fence->handle(),
entry.value, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
}
}
}
// Execute sparse bind
if (sparseBind) {
if ((status = sparseBind->submit(m_device, sparse.queueHandle)))
return status;
}
// Submit transfer commands as necessary
if (cmd.usedFlags.test(DxvkCmdBuffer::SdmaBuffer))
m_commandSubmission.executeCommandBuffer(cmd.sdmaBuffer);
@ -353,7 +380,9 @@ namespace dxvk {
m_waitSemaphores.clear();
m_signalSemaphores.clear();
m_cmdSubmissions.clear();
m_cmdSparseBinds.clear();
m_wsiSemaphores = vk::PresenterSync();

View File

@ -15,6 +15,7 @@
#include "dxvk_limits.h"
#include "dxvk_pipelayout.h"
#include "dxvk_signal.h"
#include "dxvk_sparse.h"
#include "dxvk_staging.h"
#include "dxvk_stats.h"
@ -122,6 +123,8 @@ namespace dxvk {
VkCommandBuffer execBuffer = VK_NULL_HANDLE;
VkCommandBuffer initBuffer = VK_NULL_HANDLE;
VkCommandBuffer sdmaBuffer = VK_NULL_HANDLE;
VkBool32 sparseBind = VK_FALSE;
uint32_t sparseCmd = 0;
};
@ -990,6 +993,7 @@ namespace dxvk {
std::vector<DxvkFenceValuePair> m_signalSemaphores;
std::vector<DxvkCommandSubmissionInfo> m_cmdSubmissions;
std::vector<DxvkSparseBindSubmission> m_cmdSparseBinds;
std::vector<std::pair<
Rc<DxvkDescriptorPool>,