From ae289a9d49ab469a5fc1962274b4b0fd7eb8dfb1 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 13 Mar 2021 18:57:23 -0800 Subject: Unified fence implementations in all backends --- Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp | 5 ----- Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp | 15 +++------------ 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp index d0095402..727886cb 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp @@ -67,13 +67,8 @@ public: void Wait(Uint64 Value, bool FlushCommands); -private: - void UpdateFenceValue(Uint64 NewValue); - private: std::deque> m_PendingFences; - - std::atomic_uint64_t m_LastCompletedFenceValue{0}; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp index fe88669e..677e1db9 100644 --- a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp @@ -52,15 +52,6 @@ FenceGLImpl::~FenceGLImpl() { } -void FenceGLImpl::UpdateFenceValue(Uint64 NewValue) -{ - auto CurrValue = m_LastCompletedFenceValue.load(); - while (!m_LastCompletedFenceValue.compare_exchange_strong(CurrValue, std::max(CurrValue, NewValue))) - { - // If exchange fails, CurrValue will hold the actual value of m_LastCompletedFenceValue - } -} - Uint64 FenceGLImpl::GetCompletedValue() { while (!m_PendingFences.empty()) @@ -74,7 +65,7 @@ Uint64 FenceGLImpl::GetCompletedValue() ); if (res == GL_ALREADY_SIGNALED) { - UpdateFenceValue(val_fence.first); + UpdateLastCompletedFenceValue(val_fence.first); m_PendingFences.pop_front(); } else @@ -98,7 +89,7 @@ void FenceGLImpl::Wait(Uint64 Value, bool FlushCommands) VERIFY_EXPR(res == GL_ALREADY_SIGNALED || res == GL_CONDITION_SATISFIED); (void)res; - UpdateFenceValue(val_fence.first); + UpdateLastCompletedFenceValue(val_fence.first); m_PendingFences.pop_front(); } } @@ -106,7 +97,7 @@ void FenceGLImpl::Wait(Uint64 Value, bool FlushCommands) void FenceGLImpl::Reset(Uint64 NewValue) { DEV_CHECK_ERR(NewValue >= m_LastCompletedFenceValue, "Resetting fence '", m_Desc.Name, "' to the value (", NewValue, ") that is smaller than the last completed value (", m_LastCompletedFenceValue, ")"); - UpdateFenceValue(NewValue); + UpdateLastCompletedFenceValue(NewValue); } } // namespace Diligent -- cgit v1.2.3