From 908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 19 Jul 2018 22:41:05 -0700 Subject: Added fence object stubs + code formatting --- Graphics/GraphicsEngineD3D11/CMakeLists.txt | 3 ++ .../GraphicsEngineD3D11/include/FenceD3D11Impl.h | 60 ++++++++++++++++++++++ .../include/RenderDeviceD3D11Impl.h | 4 +- .../GraphicsEngineD3D11/interface/FenceD3D11.h | 51 ++++++++++++++++++ .../GraphicsEngineD3D11/src/FenceD3D11Impl.cpp | 54 +++++++++++++++++++ .../src/RenderDeviceD3D11Impl.cpp | 17 +++++- 6 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/CMakeLists.txt b/Graphics/GraphicsEngineD3D11/CMakeLists.txt index d8d1759b..79bcb0e2 100644 --- a/Graphics/GraphicsEngineD3D11/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3D11/CMakeLists.txt @@ -13,6 +13,7 @@ set(INCLUDE include/DeviceContextD3D11Impl.h include/EngineD3D11Defines.h include/pch.h + include/FenceD3D11Impl.h include/PipelineStateD3D11Impl.h include/RenderDeviceD3D11Impl.h include/SamplerD3D11Impl.h @@ -35,6 +36,7 @@ set(INTERFACE interface/BufferViewD3D11.h interface/DeviceContextD3D11.h interface/EngineD3D11Attribs.h + interface/FenceD3D11.h interface/PipelineStateD3D11.h interface/RenderDeviceD3D11.h interface/RenderDeviceFactoryD3D11.h @@ -54,6 +56,7 @@ set(SRC src/D3D11DebugUtilities.cpp src/D3D11TypeConversions.cpp src/DeviceContextD3D11Impl.cpp + src/FenceD3D11Impl.cpp src/PipelineStateD3D11Impl.cpp src/RenderDeviceD3D11Impl.cpp src/RenderDeviceFactoryD3D11.cpp diff --git a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h new file mode 100644 index 00000000..44b6a5bf --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.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::FenceD3D11Impl class + +#include "FenceD3D11.h" +#include "RenderDeviceD3D11.h" +#include "FenceBase.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of the Diligent::IFenceD3D11 interface +class FenceD3D11Impl : public FenceBase +{ +public: + using TFenceBase = FenceBase; + + FenceD3D11Impl(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const FenceDesc& Desc); + ~FenceD3D11Impl(); + + virtual Uint64 GetCompletedValue()override final; + + /// Resets the fence to the specified value. + virtual void Reset(Uint64 Value)override final; + + ID3D11Fence* GetD3D11Fence()override final{ return m_pd3d11Fence; } + +private: + CComPtr m_pd3d11Fence; ///< D3D11 Fence object +}; + +} diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h index d92a5b8c..4ab28877 100644 --- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h @@ -55,7 +55,9 @@ public: virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler)override final; - virtual void CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState )override final; + virtual void CreatePipelineState(const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState)override final; + + virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence)override final; ID3D11Device* GetD3D11Device()override final{return m_pd3d11Device;} diff --git a/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h b/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h new file mode 100644 index 00000000..01e690e6 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.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::IFenceD3D11 interface + +#include "../../GraphicsEngine/interface/Fence.h" + +namespace Diligent +{ + +// {45F2BE28-652B-4180-B6E4-E75F83F63CC7} +static constexpr INTERFACE_ID IID_FenceD3D11 = +{ 0x45f2be28, 0x652b, 0x4180, { 0xb6, 0xe4, 0xe7, 0x5f, 0x83, 0xf6, 0x3c, 0xc7 } }; + + +/// Interface to the fence object implemented in D3D11 +class IFenceD3D11 : public IFence +{ +public: + + /// Returns a pointer to the ID3D11Fence interface of the internal Direct3D11 object. + + /// The method does *NOT* call AddRef() on the returned interface, + /// so Release() must not be called. + virtual ID3D11Fence* GetD3D11Fence() = 0; +}; + +} diff --git a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp new file mode 100644 index 00000000..c090b3b8 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.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 + +#include "FenceD3D11Impl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +FenceD3D11Impl :: FenceD3D11Impl(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const FenceDesc& Desc) : + TFenceBase(pRefCounters, pDevice, Desc) +{ +} + +FenceD3D11Impl :: ~FenceD3D11Impl() +{ +} + +Uint64 FenceD3D11Impl :: GetCompletedValue() +{ + return m_pd3d11Fence->GetCompletedValue(); +} + +void FenceD3D11Impl :: Reset(Uint64 Value) +{ + LOG_ERROR("Resetting D3D11 fence is not supported"); +} + +} diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index 222be0c5..27b226e9 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -34,6 +34,7 @@ #include "TextureViewD3D11Impl.h" #include "PipelineStateD3D11Impl.h" #include "ShaderResourceBindingD3D11Impl.h" +#include "FenceD3D11Impl.h" #include "EngineMemory.h" namespace Diligent @@ -56,7 +57,8 @@ RenderDeviceD3D11Impl :: RenderDeviceD3D11Impl(IReferenceCounters* pRefCou sizeof(ShaderD3D11Impl), sizeof(SamplerD3D11Impl), sizeof(PipelineStateD3D11Impl), - sizeof(ShaderResourceBindingD3D11Impl) + sizeof(ShaderResourceBindingD3D11Impl), + sizeof(FenceD3D11Impl) }, m_EngineAttribs(EngineAttribs), m_pd3d11Device(pd3d11Device) @@ -378,4 +380,17 @@ void RenderDeviceD3D11Impl::CreatePipelineState(const PipelineStateDesc& Pipelin ); } +void RenderDeviceD3D11Impl::CreateFence(const FenceDesc& Desc, IFence** ppFence) +{ + CreateDeviceObject( "Fence", Desc, ppFence, + [&]() + { + FenceD3D11Impl* pFenceD3D11( NEW_RC_OBJ(m_FenceAllocator, "FenceD3D11Impl instance", FenceD3D11Impl) + (this, Desc) ); + pFenceD3D11->QueryInterface( IID_Fence, reinterpret_cast(ppFence) ); + OnCreateDeviceObject( pFenceD3D11 ); + } + ); +} + } -- cgit v1.2.3