mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-24 04:54:14 +01:00
[dxvk] Pass present IDs to command submissions as necessary
This commit is contained in:
parent
f4dc269493
commit
00fc4af7ca
@ -50,9 +50,13 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkResult DxvkCommandSubmission::submit(
|
VkResult DxvkCommandSubmission::submit(
|
||||||
DxvkDevice* device,
|
DxvkDevice* device,
|
||||||
VkQueue queue) {
|
VkQueue queue,
|
||||||
|
uint64_t frameId) {
|
||||||
auto vk = device->vkd();
|
auto vk = device->vkd();
|
||||||
|
|
||||||
|
VkLatencySubmissionPresentIdNV latencyInfo = { VK_STRUCTURE_TYPE_LATENCY_SUBMISSION_PRESENT_ID_NV };
|
||||||
|
latencyInfo.presentID = frameId;
|
||||||
|
|
||||||
VkSubmitInfo2 submitInfo = { VK_STRUCTURE_TYPE_SUBMIT_INFO_2 };
|
VkSubmitInfo2 submitInfo = { VK_STRUCTURE_TYPE_SUBMIT_INFO_2 };
|
||||||
|
|
||||||
if (!m_semaphoreWaits.empty()) {
|
if (!m_semaphoreWaits.empty()) {
|
||||||
@ -70,6 +74,9 @@ namespace dxvk {
|
|||||||
submitInfo.pSignalSemaphoreInfos = m_semaphoreSignals.data();
|
submitInfo.pSignalSemaphoreInfos = m_semaphoreSignals.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frameId && device->features().nvLowLatency2)
|
||||||
|
latencyInfo.pNext = std::exchange(submitInfo.pNext, &latencyInfo);
|
||||||
|
|
||||||
VkResult vr = VK_SUCCESS;
|
VkResult vr = VK_SUCCESS;
|
||||||
|
|
||||||
if (!this->isEmpty())
|
if (!this->isEmpty())
|
||||||
@ -200,7 +207,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkResult DxvkCommandList::submit(
|
VkResult DxvkCommandList::submit(
|
||||||
const DxvkTimelineSemaphores& semaphores,
|
const DxvkTimelineSemaphores& semaphores,
|
||||||
DxvkTimelineSemaphoreValues& timelines) {
|
DxvkTimelineSemaphoreValues& timelines,
|
||||||
|
uint64_t trackedId) {
|
||||||
VkResult status = VK_SUCCESS;
|
VkResult status = VK_SUCCESS;
|
||||||
|
|
||||||
static const std::array<DxvkCmdBuffer, 2> SdmaCmdBuffers =
|
static const std::array<DxvkCmdBuffer, 2> SdmaCmdBuffers =
|
||||||
@ -259,7 +267,7 @@ namespace dxvk {
|
|||||||
m_commandSubmission.signalSemaphore(semaphores.transfer,
|
m_commandSubmission.signalSemaphore(semaphores.transfer,
|
||||||
++timelines.transfer, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
|
++timelines.transfer, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
|
||||||
|
|
||||||
if ((status = m_commandSubmission.submit(m_device, transfer.queueHandle)))
|
if ((status = m_commandSubmission.submit(m_device, transfer.queueHandle, trackedId)))
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
m_commandSubmission.waitSemaphore(semaphores.transfer,
|
m_commandSubmission.waitSemaphore(semaphores.transfer,
|
||||||
@ -301,7 +309,7 @@ namespace dxvk {
|
|||||||
++timelines.graphics, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
|
++timelines.graphics, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
|
||||||
|
|
||||||
// Finally, submit all graphics commands of the current submission
|
// Finally, submit all graphics commands of the current submission
|
||||||
if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle)))
|
if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle, trackedId)))
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
// If there are WSI semaphores involved, do another submit only
|
// If there are WSI semaphores involved, do another submit only
|
||||||
@ -311,7 +319,7 @@ namespace dxvk {
|
|||||||
m_commandSubmission.signalSemaphore(semaphores.graphics,
|
m_commandSubmission.signalSemaphore(semaphores.graphics,
|
||||||
++timelines.graphics, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
|
++timelines.graphics, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
|
||||||
|
|
||||||
if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle)))
|
if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle, trackedId)))
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +329,7 @@ namespace dxvk {
|
|||||||
m_commandSubmission.waitSemaphore(semaphores.graphics,
|
m_commandSubmission.waitSemaphore(semaphores.graphics,
|
||||||
timelines.graphics, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
|
timelines.graphics, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
|
||||||
|
|
||||||
if (isLast && (status = m_commandSubmission.submit(m_device, transfer.queueHandle)))
|
if (isLast && (status = m_commandSubmission.submit(m_device, transfer.queueHandle, trackedId)))
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,11 +103,13 @@ namespace dxvk {
|
|||||||
*
|
*
|
||||||
* \param [in] device DXVK device
|
* \param [in] device DXVK device
|
||||||
* \param [in] queue Queue to submit to
|
* \param [in] queue Queue to submit to
|
||||||
|
* \param [in] frameId Latency frame ID
|
||||||
* \returns Submission return value
|
* \returns Submission return value
|
||||||
*/
|
*/
|
||||||
VkResult submit(
|
VkResult submit(
|
||||||
DxvkDevice* device,
|
DxvkDevice* device,
|
||||||
VkQueue queue);
|
VkQueue queue,
|
||||||
|
uint64_t frameId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Resets object
|
* \brief Resets object
|
||||||
@ -215,11 +217,13 @@ namespace dxvk {
|
|||||||
*
|
*
|
||||||
* \param [in] semaphores Timeline semaphore pair
|
* \param [in] semaphores Timeline semaphore pair
|
||||||
* \param [in] timelines Timeline semaphore values
|
* \param [in] timelines Timeline semaphore values
|
||||||
|
* \param [in] frameId Latency frame ID
|
||||||
* \returns Submission status
|
* \returns Submission status
|
||||||
*/
|
*/
|
||||||
VkResult submit(
|
VkResult submit(
|
||||||
const DxvkTimelineSemaphores& semaphores,
|
const DxvkTimelineSemaphores& semaphores,
|
||||||
DxvkTimelineSemaphoreValues& timelines);
|
DxvkTimelineSemaphoreValues& timelines,
|
||||||
|
uint64_t frameId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Stat counters
|
* \brief Stat counters
|
||||||
|
@ -113,7 +113,7 @@ namespace dxvk {
|
|||||||
void DxvkContext::beginLatencyTracking(
|
void DxvkContext::beginLatencyTracking(
|
||||||
const Rc<DxvkLatencyTracker>& tracker,
|
const Rc<DxvkLatencyTracker>& tracker,
|
||||||
uint64_t frameId) {
|
uint64_t frameId) {
|
||||||
if (tracker && !m_latencyTracker) {
|
if (tracker && (!m_latencyTracker || m_latencyTracker == tracker)) {
|
||||||
tracker->notifyCsRenderBegin(frameId);
|
tracker->notifyCsRenderBegin(frameId);
|
||||||
|
|
||||||
m_latencyTracker = tracker;
|
m_latencyTracker = tracker;
|
||||||
|
@ -131,6 +131,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::unique_lock<dxvk::mutex> lock(m_mutex);
|
std::unique_lock<dxvk::mutex> lock(m_mutex);
|
||||||
|
|
||||||
|
uint64_t trackedSubmitId = 0u;
|
||||||
|
uint64_t trackedPresentId = 0u;
|
||||||
|
|
||||||
while (!m_stopped.load()) {
|
while (!m_stopped.load()) {
|
||||||
m_appendCond.wait(lock, [this] {
|
m_appendCond.wait(lock, [this] {
|
||||||
return m_stopped.load() || !m_submitQueue.empty();
|
return m_stopped.load() || !m_submitQueue.empty();
|
||||||
@ -150,10 +153,15 @@ namespace dxvk {
|
|||||||
m_callback(true);
|
m_callback(true);
|
||||||
|
|
||||||
if (entry.submit.cmdList != nullptr) {
|
if (entry.submit.cmdList != nullptr) {
|
||||||
if (entry.latency.tracker)
|
if (entry.latency.tracker) {
|
||||||
entry.latency.tracker->notifyQueueSubmit(entry.latency.frameId);
|
entry.latency.tracker->notifyQueueSubmit(entry.latency.frameId);
|
||||||
|
|
||||||
entry.result = entry.submit.cmdList->submit(m_semaphores, m_timelines);
|
if (!trackedSubmitId && entry.latency.frameId > trackedPresentId)
|
||||||
|
trackedSubmitId = entry.latency.frameId;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.result = entry.submit.cmdList->submit(
|
||||||
|
m_semaphores, m_timelines, trackedSubmitId);
|
||||||
entry.timelines = m_timelines;
|
entry.timelines = m_timelines;
|
||||||
} else if (entry.present.presenter != nullptr) {
|
} else if (entry.present.presenter != nullptr) {
|
||||||
if (entry.latency.tracker)
|
if (entry.latency.tracker)
|
||||||
@ -164,6 +172,9 @@ namespace dxvk {
|
|||||||
if (entry.latency.tracker) {
|
if (entry.latency.tracker) {
|
||||||
entry.latency.tracker->notifyQueuePresentEnd(
|
entry.latency.tracker->notifyQueuePresentEnd(
|
||||||
entry.latency.frameId, entry.result);
|
entry.latency.frameId, entry.result);
|
||||||
|
|
||||||
|
trackedPresentId = entry.latency.frameId;
|
||||||
|
trackedSubmitId = 0u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user