diff --git a/src/dxvk/dxvk_device.h b/src/dxvk/dxvk_device.h index d7c606528..290b59d5a 100644 --- a/src/dxvk/dxvk_device.h +++ b/src/dxvk/dxvk_device.h @@ -333,6 +333,17 @@ namespace dxvk { void unlockSubmission() { m_submissionLock.unlock(); } + + /** + * \brief Number of pending submissions + * + * A return value of 0 indicates + * that the GPU is currently idle. + * \returns Pending submission count + */ + uint32_t pendingSubmissions() const { + return m_submissionQueue.pendingSubmissions(); + } /** * \brief Waits until the device becomes idle diff --git a/src/dxvk/dxvk_queue.cpp b/src/dxvk/dxvk_queue.cpp index 92fe171e7..571c50720 100644 --- a/src/dxvk/dxvk_queue.cpp +++ b/src/dxvk/dxvk_queue.cpp @@ -27,6 +27,7 @@ namespace dxvk { return m_entries.size() < MaxNumQueuedCommandBuffers; }); + m_submits += 1; m_entries.push(cmdList); m_condOnAdd.notify_one(); } @@ -65,6 +66,8 @@ namespace dxvk { "DxvkSubmissionQueue: Failed to sync fence: ", status)); } + + m_submits -= 1; } } } diff --git a/src/dxvk/dxvk_queue.h b/src/dxvk/dxvk_queue.h index 641286806..5c0b87c86 100644 --- a/src/dxvk/dxvk_queue.h +++ b/src/dxvk/dxvk_queue.h @@ -14,8 +14,6 @@ namespace dxvk { /** * \brief Submission queue - * - * */ class DxvkSubmissionQueue { @@ -23,7 +21,28 @@ namespace dxvk { DxvkSubmissionQueue(DxvkDevice* device); ~DxvkSubmissionQueue(); + + /** + * \brief Number of pending submissions + * + * A return value of 0 indicates + * that the GPU is currently idle. + * \returns Pending submission count + */ + uint32_t pendingSubmissions() const { + return m_submits.load(); + } + /** + * \brief Submits a command list + * + * Submits a command list to the queue thread. + * This thread will wait for the command list + * to finish executing on the GPU and signal + * any queries and events that are used by + * the command list in question. + * \param [in] cmdList The command list + */ void submit(const Rc& cmdList); private: @@ -31,6 +50,7 @@ namespace dxvk { DxvkDevice* m_device; std::atomic m_stopped = { false }; + std::atomic m_submits = { 0u }; std::mutex m_mutex; std::condition_variable m_condOnAdd;