summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineMetal
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/GraphicsEngineMetal
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/GraphicsEngineMetal')
-rw-r--r--Graphics/GraphicsEngineMetal/CMakeLists.txt3
-rw-r--r--Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h8
-rw-r--r--Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h2
-rw-r--r--Graphics/GraphicsEngineMetal/include/QueryMtlImpl.h58
-rw-r--r--Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h2
-rw-r--r--Graphics/GraphicsEngineMetal/interface/QueryMtl.h43
-rw-r--r--Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm19
-rw-r--r--Graphics/GraphicsEngineMetal/src/QueryMtlImpl.mm46
-rw-r--r--Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm13
9 files changed, 194 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngineMetal/CMakeLists.txt b/Graphics/GraphicsEngineMetal/CMakeLists.txt
index fe73029b..27b16620 100644
--- a/Graphics/GraphicsEngineMetal/CMakeLists.txt
+++ b/Graphics/GraphicsEngineMetal/CMakeLists.txt
@@ -11,6 +11,7 @@ set(INCLUDE
include/DeviceContextMtlImpl.h
include/FenceMtlImpl.h
include/PipelineStateMtlImpl.h
+ include/QueryMtlImpl.h
include/RenderDeviceMtlImpl.h
include/SamplerMtlImpl.h
include/ShaderMtlImpl.h
@@ -27,6 +28,7 @@ set(INTERFACE
interface/EngineFactoryMtl.h
interface/FenceMtl.h
interface/PipelineStateMtl.h
+ interface/QueryMtl.h
interface/RenderDeviceMtl.h
interface/SamplerMtl.h
interface/ShaderMtl.h
@@ -46,6 +48,7 @@ set(SRC
src/EngineFactoryMtl.mm
src/FenceMtlImpl.mm
src/PipelineStateMtlImpl.mm
+ src/QueryMtlImpl.mm
src/RenderDeviceMtlImpl.mm
src/SamplerMtlImpl.mm
src/ShaderMtlImpl.mm
diff --git a/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h b/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h
index eb7f1aa0..55495847 100644
--- a/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h
+++ b/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h
@@ -32,6 +32,7 @@
#include "BufferMtlImpl.h"
#include "TextureMtlImpl.h"
#include "PipelineStateMtlImpl.h"
+#include "QueryMtlImpl.h"
namespace Diligent
{
@@ -44,6 +45,7 @@ struct DeviceContextMtlImplTraits
using TextureType = TextureMtlImpl;
using PipelineStateType = PipelineStateMtlImpl;
using DeviceType = RenderDeviceMtlImpl;
+ using QueryType = QueryMtlImpl;
};
/// Implementation of the Diligent::IDeviceContextMtl interface
@@ -165,6 +167,12 @@ public:
virtual void WaitForIdle() override final;
+ /// Implementation of IDeviceContext::BeginQuery() in Metal backend.
+ virtual void BeginQuery(IQuery* pQuery) override final;
+
+ /// Implementation of IDeviceContext::EndQuery() in Metal backend.
+ virtual void EndQuery(IQuery* pQuery) override final;
+
virtual void Flush() override final;
private:
diff --git a/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h
index c39fa659..5cbead49 100644
--- a/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h
+++ b/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h
@@ -48,6 +48,8 @@ public:
const FenceDesc& Desc);
~FenceMtlImpl();
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_FenceMtl, TFenceBase);
+
virtual Uint64 GetCompletedValue() override final;
/// Resets the fence to the specified value.
diff --git a/Graphics/GraphicsEngineMetal/include/QueryMtlImpl.h b/Graphics/GraphicsEngineMetal/include/QueryMtlImpl.h
new file mode 100644
index 00000000..c30883aa
--- /dev/null
+++ b/Graphics/GraphicsEngineMetal/include/QueryMtlImpl.h
@@ -0,0 +1,58 @@
+/* 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
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * 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::QueryMtlImpl class
+
+#include <deque>
+#include "QueryMtl.h"
+#include "RenderDeviceMtl.h"
+#include "QueryBase.h"
+#include "RenderDeviceMtlImpl.h"
+
+namespace Diligent
+{
+
+class FixedBlockMemoryAllocator;
+
+/// Implementation of the Diligent::IQueryMtl interface
+class QueryMtlImpl final : public QueryBase<IQueryMtl, RenderDeviceMtlImpl>
+{
+public:
+ using TQueryBase = QueryBase<IQueryMtl, RenderDeviceMtlImpl>;
+
+ QueryMtlImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceMtlImpl* pDevice,
+ const QueryDesc& Desc);
+ ~QueryMtlImpl();
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_FenceMtl, TFenceBase);
+
+ virtual bool GetData(void* pData, Uint32 DataSize) override final;
+
+private:
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h
index b3953aea..1d2dd2cd 100644
--- a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h
+++ b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h
@@ -59,6 +59,8 @@ public:
virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence) override final;
+ virtual void CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) override final;
+
virtual void ReleaseStaleResources(bool ForceRelease = false) override final {}
virtual void IdleGPU() override final;
diff --git a/Graphics/GraphicsEngineMetal/interface/QueryMtl.h b/Graphics/GraphicsEngineMetal/interface/QueryMtl.h
new file mode 100644
index 00000000..79fbf306
--- /dev/null
+++ b/Graphics/GraphicsEngineMetal/interface/QueryMtl.h
@@ -0,0 +1,43 @@
+/* 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
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * 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::IQueryMtl interface
+
+#include "../../GraphicsEngine/interface/Query.h"
+
+namespace Diligent
+{
+
+// {514BAE55-C3E9-4D78-A013-63522FD595DA}
+static const INTERFACE_ID IID_QueryMtl =
+ {0x514bae55, 0xc3e9, 0x4d78, {0xa0, 0x13, 0x63, 0x52, 0x2f, 0xd5, 0x95, 0xda}};
+
+/// Exposes Metal-specific functionality of a Query object.
+class IQueryMtl : public IQuery
+{
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm
index afbfd43a..63fba7c3 100644
--- a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm
+++ b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm
@@ -413,6 +413,25 @@ namespace Diligent
LOG_ERROR_MESSAGE("DeviceContextMtlImpl::WaitForIdle() is not implemented");
}
+ /// Implementation of IDeviceContext::BeginQuery() in Metal backend.
+ void DeviceContextMtlImpl::BeginQuery(IQuery* pQuery)
+ {
+ if (!TDeviceContextBase::BeginQuery(pQuery, 0))
+ return;
+
+ LOG_ERROR_MESSAGE("DeviceContextMtlImpl::BeginQuery() is not implemented");
+ }
+
+ /// Implementation of IDeviceContext::EndQuery() in Metal backend.
+ void DeviceContextMtlImpl::EndQuery(IQuery* pQuery)
+ {
+ if (!TDeviceContextBase::EndQuery(pQuery, 0))
+ return;
+
+ LOG_ERROR_MESSAGE("DeviceContextMtlImpl::EndQuery() is not implemented");
+ }
+
+
void DeviceContextMtlImpl::TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)
{
LOG_ERROR_MESSAGE("DeviceContextMtlImpl::TransitionResourceStates() is not implemented");
diff --git a/Graphics/GraphicsEngineMetal/src/QueryMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/QueryMtlImpl.mm
new file mode 100644
index 00000000..58c68793
--- /dev/null
+++ b/Graphics/GraphicsEngineMetal/src/QueryMtlImpl.mm
@@ -0,0 +1,46 @@
+/* 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
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * 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 "QueryMtlImpl.h"
+#include "EngineMemory.h"
+
+namespace Diligent
+{
+
+QueryMtlImpl :: QueryMtlImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceMtlImpl* pDevice,
+ const QueryDesc& Desc) :
+ TQueryBase(pRefCounters, pDevice, Desc)
+{
+}
+
+QueryMtlImpl :: ~QueryMtlImpl()
+{
+}
+
+bool QueryMtlImpl :: GetData(void* pData, Uint32 DataSize)
+{
+ return false;
+}
+
+}
diff --git a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm
index 42783161..4ca20f2e 100644
--- a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm
+++ b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm
@@ -171,6 +171,19 @@ void RenderDeviceMtlImpl::CreateFence(const FenceDesc& Desc, IFence** ppFence)
);
}
+void RenderDeviceMtlImpl::CreateQuery(const QueryDesc& Desc, IQuery** ppQuery)
+{
+ CreateDeviceObject( "Query", Desc, ppQuery,
+ [&]()
+ {
+ QueryMtlImpl* pQueryMtl( NEW_RC_OBJ(m_QueryAllocator, "QueryMtlImpl instance", QueryMtlImpl)
+ (this, Desc) );
+ pQueryMtl->QueryInterface( IID_Query, reinterpret_cast<IObject**>(ppQuery) );
+ OnCreateDeviceObject( pQueryMtl );
+ }
+ );
+}
+
void RenderDeviceMtlImpl::IdleGPU()
{
LOG_ERROR_MESSAGE("RenderDeviceMtlImpl::IdleGPU() is not implemented");