From 8054e4a772ce35641082e566d8495a38ac9d20ba Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 1 Nov 2018 13:24:42 +0100 Subject: [PATCH] [dxvk] Add DXVK context method to transparently flush the command list This is identical to what the D3D11 function did, but having it in this place will allow us to potentially implement better flush heuristics based on work done on the CS thread. --- src/d3d11/d3d11_context_imm.cpp | 9 ++------- src/dxvk/dxvk_context.cpp | 10 ++++++++++ src/dxvk/dxvk_context.h | 8 ++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 523c8e5b8..9bfded2e0 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -101,13 +101,8 @@ namespace dxvk { if (m_csIsBusy || m_csChunk->commandCount() != 0) { // Add commands to flush the threaded // context, then flush the command list - EmitCs([dev = m_device] (DxvkContext* ctx) { - dev->submitCommandList( - ctx->endRecording(), - nullptr, nullptr); - - ctx->beginRecording( - dev->createCommandList()); + EmitCs([] (DxvkContext* ctx) { + ctx->flushCommandList(); }); FlushCsChunk(); diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 19b7fea94..eb0a9a4e9 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -63,6 +63,16 @@ namespace dxvk { m_cmd->endRecording(); return std::exchange(m_cmd, nullptr); } + + + void DxvkContext::flushCommandList() { + m_device->submitCommandList( + this->endRecording(), + nullptr, nullptr); + + this->beginRecording( + m_device->createCommandList()); + } void DxvkContext::beginQuery(const DxvkQueryRevision& query) { diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 6943a70c7..01e0d1464 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -62,6 +62,14 @@ namespace dxvk { * \returns Active command list */ Rc endRecording(); + + /** + * \brief Flushes command buffer + * + * Transparently submits the current command + * buffer and allocates a new one. + */ + void flushCommandList(); /** * \brief Begins generating query data