summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-03 06:29:01 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-03 06:29:01 +0000
commit7501af2487700060526c5b0c7fc78cc1ee2965cf (patch)
treeed71d7704284e995bfbf17361fb82f4aa7e8dd79 /Graphics/GraphicsEngineOpenGL
parentUpdated third-party submodules (diff)
downloadDiligentCore-7501af2487700060526c5b0c7fc78cc1ee2965cf.tar.gz
DiligentCore-7501af2487700060526c5b0c7fc78cc1ee2965cf.zip
Added query interface; implemented queries in D3D11 and D3D12
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/CMakeLists.txt3
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h8
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.h62
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h3
-rw-r--r--Graphics/GraphicsEngineOpenGL/interface/QueryGL.h48
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp16
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp59
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp17
9 files changed, 217 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt
index 73fcb5ba..dda4887b 100644
--- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt
+++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt
@@ -18,6 +18,7 @@ set(INCLUDE
include/GLTypeConversions.h
include/pch.h
include/PipelineStateGLImpl.h
+ include/QueryGLImpl.h
include/RenderDeviceGLImpl.h
include/SamplerGLImpl.h
include/ShaderGLImpl.h
@@ -44,6 +45,7 @@ set(INTERFACE
interface/EngineFactoryOpenGL.h
interface/FenceGL.h
interface/PipelineStateGL.h
+ interface/QueryGL.h
interface/RenderDeviceGL.h
interface/SamplerGL.h
interface/ShaderGL.h
@@ -67,6 +69,7 @@ set(SOURCE
src/GLProgramResources.cpp
src/GLTypeConversions.cpp
src/PipelineStateGLImpl.cpp
+ src/QueryGLImpl.cpp
src/RenderDeviceGLImpl.cpp
src/SamplerGLImpl.cpp
src/ShaderGLImpl.cpp
diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
index 4473f444..b18fd7c1 100644
--- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
@@ -34,6 +34,7 @@
#include "GLObjectWrapper.h"
#include "BufferGLImpl.h"
#include "TextureBaseGL.h"
+#include "QueryGLImpl.h"
#include "PipelineStateGLImpl.h"
namespace Diligent
@@ -48,6 +49,7 @@ struct DeviceContextGLImplTraits
using TextureType = TextureBaseGL;
using PipelineStateType = PipelineStateGLImpl;
using DeviceType = RenderDeviceGLImpl;
+ using QueryType = QueryGLImpl;
};
/// Device context implementation in OpenGL backend.
@@ -205,6 +207,12 @@ public:
/// Implementation of IDeviceContext::WaitForIdle() in OpenGL backend.
virtual void WaitForIdle() override final;
+ /// Implementation of IDeviceContext::BeginQuery() in OpenGL backend.
+ virtual void BeginQuery(IQuery* pQuery) override final;
+
+ /// Implementation of IDeviceContext::EndQuery() in OpenGL backend.
+ virtual void EndQuery(IQuery* pQuery) override final;
+
/// Implementation of IDeviceContext::Flush() in OpenGL backend.
virtual void Flush() override final;
diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h
index 3dd1e6bd..88669737 100644
--- a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h
@@ -53,6 +53,8 @@ public:
const FenceDesc& Desc);
~FenceGLImpl();
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_FenceGL, TFenceBase);
+
/// Implementation of IFence::GetCompletedValue() in OpenGL backend.
virtual Uint64 GetCompletedValue() override final;
diff --git a/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.h
new file mode 100644
index 00000000..08b2ed74
--- /dev/null
+++ b/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Declaration of Diligent::QueryGLImpl class
+
+#include "QueryGL.h"
+#include "RenderDeviceGL.h"
+#include "QueryBase.h"
+#include "GLObjectWrapper.h"
+#include "RenderDeviceGLImpl.h"
+
+namespace Diligent
+{
+
+class FixedBlockMemoryAllocator;
+
+/// Query object implementation in OpenGL backend.
+class QueryGLImpl final : public QueryBase<IQueryGL, RenderDeviceGLImpl>
+{
+public:
+ using TQueryBase = QueryBase<IQueryGL, RenderDeviceGLImpl>;
+
+ QueryGLImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceGLImpl* pDevice,
+ const QueryDesc& Desc);
+ ~QueryGLImpl();
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_QueryGL, TQueryBase);
+
+ virtual bool GetData(void* pData, Uint32 DataSize) override final;
+
+private:
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h
index d643f612..a048eee2 100644
--- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h
@@ -90,6 +90,9 @@ public:
/// Implementation of IRenderDevice::CreateFence() in OpenGL backend.
virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence) override final;
+ /// Implementation of IRenderDevice::CreateQuery() in OpenGL backend.
+ virtual void CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) override final;
+
/// Implementation of IRenderDeviceGL::CreateTextureFromGLHandle().
virtual void CreateTextureFromGLHandle(Uint32 GLHandle, const TextureDesc& TexDesc, RESOURCE_STATE InitialState, ITexture** ppTexture) override final;
diff --git a/Graphics/GraphicsEngineOpenGL/interface/QueryGL.h b/Graphics/GraphicsEngineOpenGL/interface/QueryGL.h
new file mode 100644
index 00000000..9339626a
--- /dev/null
+++ b/Graphics/GraphicsEngineOpenGL/interface/QueryGL.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Definition of the Diligent::IQueryGL interface
+
+#include "../../GraphicsEngine/interface/Query.h"
+
+namespace Diligent
+{
+
+// {D8A02AB7-0720-417D-AA9B-20A2C05A3EE0}
+static constexpr INTERFACE_ID IID_QueryGL =
+ {0xd8a02ab7, 0x720, 0x417d, {0xaa, 0x9b, 0x20, 0xa2, 0xc0, 0x5a, 0x3e, 0xe0}};
+
+
+/// Exposes OpenGL-specific functionality of a Query object.
+class IQueryGL : public IQuery
+{
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index 31dd326c..beb549f8 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -1061,6 +1061,22 @@ void DeviceContextGLImpl::WaitForIdle()
glFinish();
}
+void DeviceContextGLImpl::BeginQuery(IQuery* pQuery)
+{
+ if (!TDeviceContextBase::BeginQuery(pQuery, 0))
+ return;
+
+ auto* pQueryGLImpl = ValidatedCast<QueryGLImpl>(pQuery);
+}
+
+void DeviceContextGLImpl::EndQuery(IQuery* pQuery)
+{
+ if (!TDeviceContextBase::EndQuery(pQuery, 0))
+ return;
+
+ auto* pQueryGLImpl = ValidatedCast<QueryGLImpl>(pQuery);
+}
+
bool DeviceContextGLImpl::UpdateCurrentGLContext()
{
auto NativeGLContext = m_pDevice->m_GLContext.GetCurrentNativeGLContext();
diff --git a/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
new file mode 100644
index 00000000..f65f8809
--- /dev/null
+++ b/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+
+#include "QueryGLImpl.h"
+#include "EngineMemory.h"
+
+namespace Diligent
+{
+
+QueryGLImpl::QueryGLImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceGLImpl* pDevice,
+ const QueryDesc& Desc) :
+ // clang-format off
+ TQueryBase
+ {
+ pRefCounters,
+ pDevice,
+ Desc
+ }
+// clang-format on
+{
+}
+
+QueryGLImpl::~QueryGLImpl()
+{
+}
+
+bool QueryGLImpl::GetData(void* pData, Uint32 DataSize)
+{
+ return false;
+}
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index 139a03e5..6ee33d9c 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -45,6 +45,7 @@
#include "PipelineStateGLImpl.h"
#include "ShaderResourceBindingGLImpl.h"
#include "FenceGLImpl.h"
+#include "QueryGLImpl.h"
#include "EngineMemory.h"
#include "StringTools.h"
@@ -73,7 +74,8 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
sizeof(SamplerGLImpl),
sizeof(PipelineStateGLImpl),
sizeof(ShaderResourceBindingGLImpl),
- sizeof(FenceGLImpl)
+ sizeof(FenceGLImpl),
+ sizeof(QueryGLImpl)
}
},
// Device caps must be filled in before the constructor of Pipeline Cache is called!
@@ -375,6 +377,19 @@ void RenderDeviceGLImpl::CreateFence(const FenceDesc& Desc, IFence** ppFence)
);
}
+void RenderDeviceGLImpl::CreateQuery(const QueryDesc& Desc, IQuery** ppQuery)
+{
+ CreateDeviceObject(
+ "Query", Desc, ppQuery,
+ [&]() //
+ {
+ QueryGLImpl* pQueryOGL(NEW_RC_OBJ(m_QueryAllocator, "QueryGLImpl instance", QueryGLImpl)(this, Desc));
+ pQueryOGL->QueryInterface(IID_Query, reinterpret_cast<IObject**>(ppQuery));
+ OnCreateDeviceObject(pQueryOGL);
+ } //
+ );
+}
+
bool RenderDeviceGLImpl::CheckExtension(const Char* ExtensionString)
{
return m_ExtensionStrings.find(ExtensionString) != m_ExtensionStrings.end();