summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-09-08 21:56:26 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-09-08 21:56:26 +0000
commit52d1b5ab7fee4f2c4e63eaf5774d48111becba12 (patch)
tree9eac4952a2eb4765352270cc7993fbefec83c6ce /Graphics/GraphicsEngineOpenGL
parentUpdated constructor of RefCountedObject to forward arguments to its base class (diff)
downloadDiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.tar.gz
DiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.zip
Added IDeviceContext::Wait() method (updated API version to 240026)
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp9
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp17
4 files changed, 29 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
index 96653441..3d64ad3f 100644
--- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
@@ -150,6 +150,8 @@ public:
virtual void SignalFence(IFence* pFence, Uint64 Value)override final;
+ virtual void Wait(IFence* pFence, Uint64 Value)override final;
+
virtual bool UpdateCurrentGLContext()override final;
void BindProgramResources(Uint32& NewMemoryBarriers, IShaderResourceBinding* pResBinding);
diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h
index ceab0d57..bade8fd1 100644
--- a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h
@@ -59,6 +59,8 @@ public:
m_PendingFences.emplace_back(Value, std::move(Fence));
}
+ void Wait(Uint64 Value);
+
private:
std::deque<std::pair<Uint64, GLObjectWrappers::GLSyncObj> > m_PendingFences;
volatile Uint64 m_LastCompletedFenceValue = 0;
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index 2b19d5f1..ec77379d 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -1073,7 +1073,14 @@ namespace Diligent
CHECK_GL_ERROR( "Failed to create gl fence" );
auto* pFenceGLImpl = ValidatedCast<FenceGLImpl>(pFence);
pFenceGLImpl->AddPendingFence(std::move(GLFence), Value);
- };
+ }
+
+ void DeviceContextGLImpl::Wait(IFence* pFence, Uint64 Value)
+ {
+ VERIFY(!m_bIsDeferred, "Fence can only be waited from immediate context");
+ auto* pFenceGLImpl = ValidatedCast<FenceGLImpl>(pFence);
+ pFenceGLImpl->Wait(Value);
+ }
bool DeviceContextGLImpl::UpdateCurrentGLContext()
{
diff --git a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp
index 75983e18..7e39aa2f 100644
--- a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp
@@ -64,6 +64,23 @@ Uint64 FenceGLImpl :: GetCompletedValue()
return m_LastCompletedFenceValue;
}
+void FenceGLImpl :: Wait(Uint64 Value)
+{
+ while (!m_PendingFences.empty())
+ {
+ auto& val_fence = m_PendingFences.front();
+ if (val_fence.first > Value)
+ break;
+
+ auto res = glClientWaitSync(val_fence.second, GL_SYNC_FLUSH_COMMANDS_BIT, std::numeric_limits<GLuint64>::max());
+ VERIFY_EXPR(res == GL_ALREADY_SIGNALED || res == GL_CONDITION_SATISFIED);
+
+ if (val_fence.first > m_LastCompletedFenceValue)
+ m_LastCompletedFenceValue = val_fence.first;
+ m_PendingFences.pop_front();
+ }
+}
+
void FenceGLImpl :: 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, ")");