summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-07-20 05:41:05 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-07-20 05:41:05 +0000
commit908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4 (patch)
treed0ae2d5956d803b7f4ce11195bebed8deecb124a /Graphics/GraphicsEngineD3D12
parentAdded comment about shader reflection data (diff)
downloadDiligentCore-908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4.tar.gz
DiligentCore-908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4.zip
Added fence object stubs + code formatting
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/CMakeLists.txt3
-rw-r--r--Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h60
-rw-r--r--Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/interface/FenceD3D12.h51
-rw-r--r--Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp54
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp17
6 files changed, 186 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineD3D12/CMakeLists.txt b/Graphics/GraphicsEngineD3D12/CMakeLists.txt
index d124c353..f0902987 100644
--- a/Graphics/GraphicsEngineD3D12/CMakeLists.txt
+++ b/Graphics/GraphicsEngineD3D12/CMakeLists.txt
@@ -17,6 +17,7 @@ set(INCLUDE
include/DescriptorHeap.h
include/DeviceContextD3D12Impl.h
include/DynamicUploadHeap.h
+ include/FenceD3D12Impl.h
include/GenerateMips.h
include/pch.h
include/PipelineStateD3D12Impl.h
@@ -38,6 +39,7 @@ set(INTERFACE
interface/BufferViewD3D12.h
interface/CommandQueueD3D12.h
interface/DeviceContextD3D12.h
+ interface/FenceD3D12.h
interface/PipelineStateD3D12.h
interface/RenderDeviceD3D12.h
interface/RenderDeviceFactoryD3D12.h
@@ -62,6 +64,7 @@ set(SRC
src/DescriptorHeap.cpp
src/DeviceContextD3D12Impl.cpp
src/DynamicUploadHeap.cpp
+ src/FenceD3D12Impl.cpp
src/GenerateMips.cpp
src/PipelineStateD3D12Impl.cpp
src/RenderDeviceD3D12Impl.cpp
diff --git a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h
new file mode 100644
index 00000000..7412aeb0
--- /dev/null
+++ b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h
@@ -0,0 +1,60 @@
+/* Copyright 2015-2018 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::FenceD3D12Impl class
+
+#include "FenceD3D12.h"
+#include "RenderDeviceD3D12.h"
+#include "FenceBase.h"
+
+namespace Diligent
+{
+
+class FixedBlockMemoryAllocator;
+
+/// Implementation of the Diligent::IFenceD3D12 interface
+class FenceD3D12Impl : public FenceBase<IFenceD3D12>
+{
+public:
+ using TFenceBase = FenceBase<IFenceD3D12>;
+
+ FenceD3D12Impl(IReferenceCounters* pRefCounters,
+ IRenderDevice* pDevice,
+ const FenceDesc& Desc);
+ ~FenceD3D12Impl();
+
+ virtual Uint64 GetCompletedValue()override final;
+
+ /// Resets the fence to the specified value.
+ virtual void Reset(Uint64 Value)override final;
+
+ ID3D12Fence* GetD3D12Fence()override final{ return m_pD3D12Fence; }
+
+private:
+ CComPtr<ID3D12Fence> m_pD3D12Fence; ///< D3D12 Fence object
+};
+
+}
diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
index 47c58d99..036cf0b9 100644
--- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
@@ -68,6 +68,8 @@ public:
virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler **ppSampler)override final;
+ virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence)override final;
+
virtual ID3D12Device* GetD3D12Device()override final{return m_pd3d12Device;}
virtual void CreateTextureFromD3DResource(ID3D12Resource *pd3d12Texture, ITexture **ppTexture)override final;
diff --git a/Graphics/GraphicsEngineD3D12/interface/FenceD3D12.h b/Graphics/GraphicsEngineD3D12/interface/FenceD3D12.h
new file mode 100644
index 00000000..2df16af8
--- /dev/null
+++ b/Graphics/GraphicsEngineD3D12/interface/FenceD3D12.h
@@ -0,0 +1,51 @@
+/* Copyright 2015-2018 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::IFenceD3D12 interface
+
+#include "../../GraphicsEngine/interface/Fence.h"
+
+namespace Diligent
+{
+
+// {053C0D8C-3757-4220-A9CC-4749EC4794AD}
+static constexpr INTERFACE_ID IID_FenceD3D12 =
+{ 0x53c0d8c, 0x3757, 0x4220, { 0xa9, 0xcc, 0x47, 0x49, 0xec, 0x47, 0x94, 0xad } };
+
+
+/// Interface to the fence object implemented in D3D12
+class IFenceD3D12 : public IFence
+{
+public:
+
+ /// Returns a pointer to the ID3D12Fence interface of the internal Direct3D12 object.
+
+ /// The method does *NOT* call AddRef() on the returned interface,
+ /// so Release() must not be called.
+ virtual ID3D12Fence* GetD3D12Fence() = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp
new file mode 100644
index 00000000..92939fea
--- /dev/null
+++ b/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp
@@ -0,0 +1,54 @@
+/* Copyright 2015-2018 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 "pch.h"
+#include <atlbase.h>
+
+#include "FenceD3D12Impl.h"
+#include "EngineMemory.h"
+
+namespace Diligent
+{
+
+FenceD3D12Impl :: FenceD3D12Impl(IReferenceCounters* pRefCounters,
+ IRenderDevice* pDevice,
+ const FenceDesc& Desc) :
+ TFenceBase(pRefCounters, pDevice, Desc)
+{
+}
+
+FenceD3D12Impl :: ~FenceD3D12Impl()
+{
+}
+
+Uint64 FenceD3D12Impl :: GetCompletedValue()
+{
+ return m_pD3D12Fence->GetCompletedValue();
+}
+
+void FenceD3D12Impl :: Reset(Uint64 Value)
+{
+ m_pD3D12Fence->Signal(Value);
+}
+
+}
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 55068388..ea744aff 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -31,6 +31,7 @@
#include "BufferD3D12Impl.h"
#include "ShaderResourceBindingD3D12Impl.h"
#include "DeviceContextD3D12Impl.h"
+#include "FenceD3D12Impl.h"
#include "EngineMemory.h"
namespace Diligent
@@ -54,7 +55,8 @@ RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRef
sizeof(ShaderD3D12Impl),
sizeof(SamplerD3D12Impl),
sizeof(PipelineStateD3D12Impl),
- sizeof(ShaderResourceBindingD3D12Impl)
+ sizeof(ShaderResourceBindingD3D12Impl),
+ sizeof(FenceD3D12Impl)
},
m_pd3d12Device (pd3d12Device),
m_pCommandQueue (pCmdQueue),
@@ -587,6 +589,19 @@ void RenderDeviceD3D12Impl :: CreateSampler(const SamplerDesc& SamplerDesc, ISam
);
}
+void RenderDeviceD3D12Impl::CreateFence(const FenceDesc& Desc, IFence** ppFence)
+{
+ CreateDeviceObject( "Fence", Desc, ppFence,
+ [&]()
+ {
+ FenceD3D12Impl* pFenceD3D12( NEW_RC_OBJ(m_FenceAllocator, "FenceD3D12Impl instance", FenceD3D12Impl)
+ (this, Desc) );
+ pFenceD3D12->QueryInterface( IID_Fence, reinterpret_cast<IObject**>(ppFence) );
+ OnCreateDeviceObject( pFenceD3D12 );
+ }
+ );
+}
+
DescriptorHeapAllocation RenderDeviceD3D12Impl :: AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count /*= 1*/)
{
VERIFY(Type >= D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV && Type < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES, "Invalid heap type");