From b6c395c013df9da30bcfb13905699b39dd16fb04 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 17 Jul 2019 12:52:25 +0200 Subject: [PATCH] [dxvk] Don't track command count in CS chunks We weren't using this at all, and it's not necessary to check whether the chunk is empty either. --- src/d3d11/d3d11_context.h | 2 +- src/d3d11/d3d11_context_imm.cpp | 2 +- src/dxvk/dxvk_cs.cpp | 8 +++----- src/dxvk/dxvk_cs.h | 13 ++++--------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 30523934..5835a125 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -860,7 +860,7 @@ namespace dxvk { } void FlushCsChunk() { - if (likely(m_csChunk->commandCount())) { + if (likely(!m_csChunk->empty())) { EmitCsChunk(std::move(m_csChunk)); m_csChunk = AllocCsChunk(); m_cmdData = nullptr; diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index cc496a6f..3e8ae0d1 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -114,7 +114,7 @@ namespace dxvk { D3D10DeviceLock lock = LockContext(); - if (m_csIsBusy || m_csChunk->commandCount() != 0) { + if (m_csIsBusy || !m_csChunk->empty()) { // Add commands to flush the threaded // context, then flush the command list EmitCs([] (DxvkContext* ctx) { diff --git a/src/dxvk/dxvk_cs.cpp b/src/dxvk/dxvk_cs.cpp index 704e5bb1..8999a5d5 100644 --- a/src/dxvk/dxvk_cs.cpp +++ b/src/dxvk/dxvk_cs.cpp @@ -21,7 +21,6 @@ namespace dxvk { auto cmd = m_head; if (m_flags.test(DxvkCsChunkFlag::SingleUse)) { - m_commandCount = 0; m_commandOffset = 0; while (cmd != nullptr) { @@ -44,10 +43,7 @@ namespace dxvk { void DxvkCsChunk::reset() { auto cmd = m_head; - - m_commandCount = 0; - m_commandOffset = 0; - + while (cmd != nullptr) { auto next = cmd->next(); cmd->~DxvkCsCmd(); @@ -56,6 +52,8 @@ namespace dxvk { m_head = nullptr; m_tail = nullptr; + + m_commandOffset = 0; } diff --git a/src/dxvk/dxvk_cs.h b/src/dxvk/dxvk_cs.h index b22108c0..c0c25d6d 100644 --- a/src/dxvk/dxvk_cs.h +++ b/src/dxvk/dxvk_cs.h @@ -143,13 +143,11 @@ namespace dxvk { ~DxvkCsChunk(); /** - * \brief Number of commands recorded to the chunk - * - * Can be used to check whether the chunk needs to - * be dispatched or just to keep track of statistics. + * \brief Checks whether the chunk is empty + * \returns \c true if the chunk is empty */ - size_t commandCount() const { - return m_commandCount; + bool empty() const { + return m_commandOffset == 0; } /** @@ -179,7 +177,6 @@ namespace dxvk { else m_head = m_tail; - m_commandCount += 1; m_commandOffset += sizeof(FuncType); return true; } @@ -207,7 +204,6 @@ namespace dxvk { m_head = func; m_tail = func; - m_commandCount += 1; m_commandOffset += sizeof(FuncType); return func->data(); } @@ -238,7 +234,6 @@ namespace dxvk { private: - size_t m_commandCount = 0; size_t m_commandOffset = 0; DxvkCsCmd* m_head = nullptr;