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/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp | 6 +++--- Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp index 9385d3c4..49b5ea54 100644 --- a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp @@ -31,10 +31,11 @@ /// Declaration of Diligent::FenceD3D11Impl class #include +#include + +#include "EngineD3D11ImplTraits.hpp" #include "FenceD3D11.h" -#include "RenderDeviceD3D11.h" #include "FenceBase.hpp" -#include "RenderDeviceD3D11Impl.hpp" namespace Diligent { @@ -81,7 +82,6 @@ private: {} }; std::deque m_PendingQueries; - volatile Uint64 m_LastCompletedFenceValue = 0; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp index 28da90ff..2bb2bdf5 100644 --- a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp @@ -26,9 +26,9 @@ */ #include "pch.h" -#include #include "FenceD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent @@ -55,8 +55,7 @@ Uint64 FenceD3D11Impl::GetCompletedValue() if (res == S_OK) { VERIFY_EXPR(Data == TRUE); - if (QueryData.Value > m_LastCompletedFenceValue) - m_LastCompletedFenceValue = QueryData.Value; + UpdateLastCompletedFenceValue(QueryData.Value); m_PendingQueries.pop_front(); } else @@ -65,7 +64,7 @@ Uint64 FenceD3D11Impl::GetCompletedValue() } } - return m_LastCompletedFenceValue; + return m_LastCompletedFenceValue.load(); } void FenceD3D11Impl::Wait(Uint64 Value, bool FlushCommands) @@ -81,9 +80,7 @@ void FenceD3D11Impl::Wait(Uint64 Value, bool FlushCommands) std::this_thread::yield(); VERIFY_EXPR(Data == TRUE); - if (QueryData.Value > m_LastCompletedFenceValue) - m_LastCompletedFenceValue = QueryData.Value; - + UpdateLastCompletedFenceValue(QueryData.Value); m_PendingQueries.pop_front(); } } @@ -91,8 +88,7 @@ void FenceD3D11Impl::Wait(Uint64 Value, bool FlushCommands) void FenceD3D11Impl::Reset(Uint64 Value) { DEV_CHECK_ERR(Value >= m_LastCompletedFenceValue, "Resetting fence '", m_Desc.Name, "' to the value (", Value, ") that is smaller than the last completed value (", m_LastCompletedFenceValue, ")"); - if (Value > m_LastCompletedFenceValue) - m_LastCompletedFenceValue = Value; + UpdateLastCompletedFenceValue(Value); } } // namespace Diligent -- cgit v1.2.3