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/GraphicsEngine/include/FenceBase.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/FenceBase.hpp b/Graphics/GraphicsEngine/include/FenceBase.hpp index 0bcaae36..e9dc0f9f 100644 --- a/Graphics/GraphicsEngine/include/FenceBase.hpp +++ b/Graphics/GraphicsEngine/include/FenceBase.hpp @@ -30,6 +30,8 @@ /// \file /// Implementation of the Diligent::FenceBase template class +#include + #include "DeviceObjectBase.hpp" #include "GraphicsTypes.h" #include "RefCntAutoPtr.hpp" @@ -66,6 +68,18 @@ public: } IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Fence, TDeviceObjectBase) + +protected: + void UpdateLastCompletedFenceValue(uint64_t NewValue) + { + auto LastCompletedValue = m_LastCompletedFenceValue.load(); + while (!m_LastCompletedFenceValue.compare_exchange_strong(LastCompletedValue, std::max(LastCompletedValue, NewValue))) + { + // If exchange fails, LastCompletedValue will hold the actual value of m_LastCompletedFenceValue. + } + } + + std::atomic_uint64_t m_LastCompletedFenceValue{0}; }; } // namespace Diligent -- cgit v1.2.3