From 38ad2d5cb659074ad9b4bde16bcbf71481719b94 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 26 Jan 2020 13:44:37 -0800 Subject: Renamed .h -> .hpp in GraphicsEngine, GraphicsEngineD3DBase, GraphicsEningeD3D11, and GraphicsEningeD3D12 projects --- Graphics/GraphicsEngineD3D11/CMakeLists.txt | 42 +- .../GraphicsEngineD3D11/include/BufferD3D11Impl.h | 97 ----- .../include/BufferD3D11Impl.hpp | 97 +++++ .../include/BufferViewD3D11Impl.h | 68 ---- .../include/BufferViewD3D11Impl.hpp | 68 ++++ .../include/CommandListD3D11Impl.h | 59 --- .../include/CommandListD3D11Impl.hpp | 59 +++ .../include/DeviceContextD3D11Impl.h | 438 --------------------- .../include/DeviceContextD3D11Impl.hpp | 438 +++++++++++++++++++++ .../include/DisjointQueryPool.h | 102 ----- .../include/DisjointQueryPool.hpp | 102 +++++ .../GraphicsEngineD3D11/include/FenceD3D11Impl.h | 89 ----- .../GraphicsEngineD3D11/include/FenceD3D11Impl.hpp | 89 +++++ .../include/PipelineStateD3D11Impl.h | 158 -------- .../include/PipelineStateD3D11Impl.hpp | 158 ++++++++ .../GraphicsEngineD3D11/include/QueryD3D11Impl.h | 85 ---- .../GraphicsEngineD3D11/include/QueryD3D11Impl.hpp | 85 ++++ .../include/RenderDeviceD3D11Impl.h | 108 ----- .../include/RenderDeviceD3D11Impl.hpp | 108 +++++ .../GraphicsEngineD3D11/include/SamplerD3D11Impl.h | 64 --- .../include/SamplerD3D11Impl.hpp | 64 +++ .../GraphicsEngineD3D11/include/ShaderD3D11Impl.h | 99 ----- .../include/ShaderD3D11Impl.hpp | 99 +++++ .../include/ShaderResourceBindingD3D11Impl.h | 108 ----- .../include/ShaderResourceBindingD3D11Impl.hpp | 108 +++++ .../include/ShaderResourceCacheD3D11.h | 334 ---------------- .../include/ShaderResourceCacheD3D11.hpp | 334 ++++++++++++++++ .../include/ShaderResourceLayoutD3D11.h | 415 ------------------- .../include/ShaderResourceLayoutD3D11.hpp | 415 +++++++++++++++++++ .../include/ShaderResourcesD3D11.h | 142 ------- .../include/ShaderResourcesD3D11.hpp | 142 +++++++ .../include/SwapChainD3D11Impl.h | 80 ---- .../include/SwapChainD3D11Impl.hpp | 80 ++++ .../GraphicsEngineD3D11/include/Texture1D_D3D11.h | 64 --- .../include/Texture1D_D3D11.hpp | 64 +++ .../GraphicsEngineD3D11/include/Texture2D_D3D11.h | 64 --- .../include/Texture2D_D3D11.hpp | 64 +++ .../GraphicsEngineD3D11/include/Texture3D_D3D11.h | 64 --- .../include/Texture3D_D3D11.hpp | 64 +++ .../GraphicsEngineD3D11/include/TextureBaseD3D11.h | 98 ----- .../include/TextureBaseD3D11.hpp | 98 +++++ .../include/TextureViewD3D11Impl.h | 69 ---- .../include/TextureViewD3D11Impl.hpp | 69 ++++ Graphics/GraphicsEngineD3D11/include/pch.h | 4 +- .../GraphicsEngineD3D11/src/BufferD3D11Impl.cpp | 8 +- .../src/BufferViewD3D11Impl.cpp | 2 +- .../src/CommandListD3D11Impl.cpp | 2 +- .../src/D3D11TypeConversions.cpp | 4 +- .../src/DeviceContextD3D11Impl.cpp | 28 +- .../GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp | 8 +- .../GraphicsEngineD3D11/src/FenceD3D11Impl.cpp | 2 +- .../src/PipelineStateD3D11Impl.cpp | 8 +- .../GraphicsEngineD3D11/src/QueryD3D11Impl.cpp | 4 +- .../src/RenderDeviceD3D11Impl.cpp | 26 +- .../GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp | 4 +- .../GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp | 4 +- .../src/ShaderResourceBindingD3D11Impl.cpp | 8 +- .../src/ShaderResourceCacheD3D11.cpp | 10 +- .../src/ShaderResourceLayoutD3D11.cpp | 16 +- .../src/ShaderResourcesD3D11.cpp | 8 +- .../GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp | 6 +- .../GraphicsEngineD3D11/src/Texture1D_D3D11.cpp | 4 +- .../GraphicsEngineD3D11/src/Texture2D_D3D11.cpp | 4 +- .../GraphicsEngineD3D11/src/Texture3D_D3D11.cpp | 4 +- .../GraphicsEngineD3D11/src/TextureBaseD3D11.cpp | 8 +- .../src/TextureViewD3D11Impl.cpp | 4 +- 66 files changed, 2914 insertions(+), 2914 deletions(-) delete mode 100644 Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.hpp delete mode 100755 Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h create mode 100644 Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.hpp delete mode 100755 Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp delete mode 100755 Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h create mode 100644 Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.hpp delete mode 100644 Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h create mode 100644 Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.hpp (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/CMakeLists.txt b/Graphics/GraphicsEngineD3D11/CMakeLists.txt index ab544ad1..614f6264 100644 --- a/Graphics/GraphicsEngineD3D11/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3D11/CMakeLists.txt @@ -4,32 +4,32 @@ project(Diligent-GraphicsEngineD3D11 CXX) set(INCLUDE - include/BufferD3D11Impl.h - include/BufferViewD3D11Impl.h - include/CommandListD3D11Impl.h + include/BufferD3D11Impl.hpp + include/BufferViewD3D11Impl.hpp + include/CommandListD3D11Impl.hpp include/D3D11TypeConversions.h include/D3D11TypeDefinitions.h - include/DeviceContextD3D11Impl.h - include/DisjointQueryPool.h + include/DeviceContextD3D11Impl.hpp + include/DisjointQueryPool.hpp include/EngineD3D11Defines.h include/pch.h - include/FenceD3D11Impl.h - include/PipelineStateD3D11Impl.h - include/QueryD3D11Impl.h - include/RenderDeviceD3D11Impl.h - include/SamplerD3D11Impl.h - include/ShaderD3D11Impl.h - include/ShaderResourceBindingD3D11Impl.h - include/ShaderResourceCacheD3D11.h - include/ShaderResourceLayoutD3D11.h - include/ShaderResourcesD3D11.h - include/SwapChainD3D11Impl.h + include/FenceD3D11Impl.hpp + include/PipelineStateD3D11Impl.hpp + include/QueryD3D11Impl.hpp + include/RenderDeviceD3D11Impl.hpp + include/SamplerD3D11Impl.hpp + include/ShaderD3D11Impl.hpp + include/ShaderResourceBindingD3D11Impl.hpp + include/ShaderResourceCacheD3D11.hpp + include/ShaderResourceLayoutD3D11.hpp + include/ShaderResourcesD3D11.hpp + include/SwapChainD3D11Impl.hpp include/targetver.h - include/Texture1D_D3D11.h - include/Texture2D_D3D11.h - include/Texture3D_D3D11.h - include/TextureBaseD3D11.h - include/TextureViewD3D11Impl.h + include/Texture1D_D3D11.hpp + include/Texture2D_D3D11.hpp + include/Texture3D_D3D11.hpp + include/TextureBaseD3D11.hpp + include/TextureViewD3D11Impl.hpp ) set(INTERFACE diff --git a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h deleted file mode 100644 index 77c74f45..00000000 --- a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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::BufferD3D11Impl class - -#include "BufferD3D11.h" -#include "RenderDeviceD3D11.h" -#include "BufferBase.h" -#include "BufferViewD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Buffer object implementation in Direct3D11 backend. -class BufferD3D11Impl final : public BufferBase -{ -public: - using TBufferBase = BufferBase; - - BufferD3D11Impl(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& BuffViewObjMemAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const BufferDesc& BuffDesc, - const BufferData* pBuffData = nullptr); - - BufferD3D11Impl(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& BuffViewObjMemAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const BufferDesc& BuffDesc, - RESOURCE_STATE InitialState, - ID3D11Buffer* pd3d11Buffer); - - ~BufferD3D11Impl(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of IBufferD3D11::GetD3D11Buffer(). - virtual ID3D11Buffer* GetD3D11Buffer() override final { return m_pd3d11Buffer; } - - /// Implementation of IBuffer::GetNativeHandle(). - virtual void* GetNativeHandle() override final { return GetD3D11Buffer(); } - - void AddState(RESOURCE_STATE State) - { - m_State = static_cast(m_State & ~static_cast(RESOURCE_STATE_UNDEFINED)); - m_State = static_cast(m_State | State); - } - - void ClearState(RESOURCE_STATE State) - { - VERIFY_EXPR(IsInKnownState()); - m_State = static_cast(m_State & ~static_cast(State)); - if (m_State == RESOURCE_STATE_UNKNOWN) - m_State = RESOURCE_STATE_UNDEFINED; - } - -private: - virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, IBufferView** ppView, bool bIsDefaultView) override; - - void CreateUAV(struct BufferViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV); - void CreateSRV(struct BufferViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV); - - friend class DeviceContextD3D11Impl; - CComPtr m_pd3d11Buffer; ///< D3D11 buffer object -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp new file mode 100644 index 00000000..1deb3f91 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp @@ -0,0 +1,97 @@ +/* + * 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::BufferD3D11Impl class + +#include "BufferD3D11.h" +#include "RenderDeviceD3D11.h" +#include "BufferBase.hpp" +#include "BufferViewD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Buffer object implementation in Direct3D11 backend. +class BufferD3D11Impl final : public BufferBase +{ +public: + using TBufferBase = BufferBase; + + BufferD3D11Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const BufferDesc& BuffDesc, + const BufferData* pBuffData = nullptr); + + BufferD3D11Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const BufferDesc& BuffDesc, + RESOURCE_STATE InitialState, + ID3D11Buffer* pd3d11Buffer); + + ~BufferD3D11Impl(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of IBufferD3D11::GetD3D11Buffer(). + virtual ID3D11Buffer* GetD3D11Buffer() override final { return m_pd3d11Buffer; } + + /// Implementation of IBuffer::GetNativeHandle(). + virtual void* GetNativeHandle() override final { return GetD3D11Buffer(); } + + void AddState(RESOURCE_STATE State) + { + m_State = static_cast(m_State & ~static_cast(RESOURCE_STATE_UNDEFINED)); + m_State = static_cast(m_State | State); + } + + void ClearState(RESOURCE_STATE State) + { + VERIFY_EXPR(IsInKnownState()); + m_State = static_cast(m_State & ~static_cast(State)); + if (m_State == RESOURCE_STATE_UNKNOWN) + m_State = RESOURCE_STATE_UNDEFINED; + } + +private: + virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, IBufferView** ppView, bool bIsDefaultView) override; + + void CreateUAV(struct BufferViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV); + void CreateSRV(struct BufferViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV); + + friend class DeviceContextD3D11Impl; + CComPtr m_pd3d11Buffer; ///< D3D11 buffer object +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h deleted file mode 100644 index a44eae3a..00000000 --- a/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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::BufferViewD3D11Impl class - -#include "BufferViewD3D11.h" -#include "RenderDeviceD3D11.h" -#include "BufferViewBase.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Buffer view implementation in Direct3D11 backend. -class BufferViewD3D11Impl final : public BufferViewBase -{ -public: - using TBufferViewBase = BufferViewBase; - - BufferViewD3D11Impl(IReferenceCounters* pRefCounters, - RenderDeviceD3D11Impl* pDevice, - const BufferViewDesc& ViewDesc, - class IBuffer* pBuffer, - ID3D11View* pD3D11View, - bool bIsDefaultView); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) final; - - /// Implementation of IBufferViewD3D11::GetD3D11View(). - virtual ID3D11View* GetD3D11View() override final - { - return m_pD3D11View; - } - -protected: - CComPtr m_pD3D11View; /// +{ +public: + using TBufferViewBase = BufferViewBase; + + BufferViewD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const BufferViewDesc& ViewDesc, + class IBuffer* pBuffer, + ID3D11View* pD3D11View, + bool bIsDefaultView); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) final; + + /// Implementation of IBufferViewD3D11::GetD3D11View(). + virtual ID3D11View* GetD3D11View() override final + { + return m_pD3D11View; + } + +protected: + CComPtr m_pD3D11View; /// -{ -public: - using TCommandListBase = CommandListBase; - - CommandListD3D11Impl(IReferenceCounters* pRefCounters, - RenderDeviceD3D11Impl* pDevice, - ID3D11CommandList* pd3d11CommandList); - ~CommandListD3D11Impl(); - - ID3D11CommandList* GetD3D11CommandList() { return m_pd3d11CommandList; } - -private: - CComPtr m_pd3d11CommandList; ///< D3D11 CommandList object -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.hpp new file mode 100644 index 00000000..031e8339 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.hpp @@ -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. + */ + +#pragma once + +/// \file +/// Declaration of Diligent::CommandListD3D11Impl class + +#include "RenderDeviceD3D11.h" +#include "CommandListBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Command list implementation in Direct3D11 backend. +class CommandListD3D11Impl final : public CommandListBase +{ +public: + using TCommandListBase = CommandListBase; + + CommandListD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + ID3D11CommandList* pd3d11CommandList); + ~CommandListD3D11Impl(); + + ID3D11CommandList* GetD3D11CommandList() { return m_pd3d11CommandList; } + +private: + CComPtr m_pd3d11CommandList; ///< D3D11 CommandList object +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h deleted file mode 100755 index 162a1285..00000000 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ /dev/null @@ -1,438 +0,0 @@ -/* - * 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::DeviceContextD3D11Impl class - -#include "DeviceContextD3D11.h" -#include "DeviceContextBase.h" -#include "ShaderD3D11Impl.h" -#include "BufferD3D11Impl.h" -#include "TextureBaseD3D11.h" -#include "PipelineStateD3D11Impl.h" -#include "QueryD3D11Impl.h" -#include "DisjointQueryPool.h" - -#ifdef _DEBUG -# define VERIFY_CONTEXT_BINDINGS -#endif - -namespace Diligent -{ - -class RenderDeviceD3D11Impl; - -struct DeviceContextD3D11ImplTraits -{ - using BufferType = BufferD3D11Impl; - using TextureType = TextureBaseD3D11; - using PipelineStateType = PipelineStateD3D11Impl; - using DeviceType = RenderDeviceD3D11Impl; - using QueryType = QueryD3D11Impl; -}; - -/// Device context implementation in Direct3D11 backend. -class DeviceContextD3D11Impl final : public DeviceContextBase -{ -public: - using TDeviceContextBase = DeviceContextBase; - - DeviceContextD3D11Impl(IReferenceCounters* pRefCounters, - IMemoryAllocator& Allocator, - RenderDeviceD3D11Impl* pDevice, - ID3D11DeviceContext* pd3d11DeviceContext, - const struct EngineD3D11CreateInfo& EngineAttribs, - bool bIsDeferred); - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of IDeviceContext::SetPipelineState() in Direct3D11 backend. - virtual void SetPipelineState(IPipelineState* pPipelineState) override final; - - /// Implementation of IDeviceContext::TransitionShaderResources() in Direct3D11 backend. - virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) override final; - - /// Implementation of IDeviceContext::CommitShaderResources() in Direct3D11 backend. - virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::SetStencilRef() in Direct3D11 backend. - virtual void SetStencilRef(Uint32 StencilRef) override final; - - /// Implementation of IDeviceContext::SetBlendFactors() in Direct3D11 backend. - virtual void SetBlendFactors(const float* pBlendFactors = nullptr) override final; - - /// Implementation of IDeviceContext::SetVertexBuffers() in Direct3D11 backend. - virtual void SetVertexBuffers(Uint32 StartSlot, - Uint32 NumBuffersSet, - IBuffer** ppBuffers, - Uint32* pOffsets, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, - SET_VERTEX_BUFFERS_FLAGS Flags) override final; - - /// Implementation of IDeviceContext::InvalidateState() in Direct3D11 backend. - virtual void InvalidateState() override final; - - /// Implementation of IDeviceContext::SetIndexBuffer() in Direct3D11 backend. - virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::SetViewports() in Direct3D11 backend. - virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight) override final; - - /// Implementation of IDeviceContext::SetScissorRects() in Direct3D11 backend. - virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight) override final; - - /// Implementation of IDeviceContext::SetRenderTargets() in Direct3D11 backend. - virtual void SetRenderTargets(Uint32 NumRenderTargets, - ITextureView* ppRenderTargets[], - ITextureView* pDepthStencil, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::Draw() in Direct3D11 backend. - virtual void Draw(const DrawAttribs& Attribs) override final; - /// Implementation of IDeviceContext::DrawIndexed() in Direct3D11 backend. - virtual void DrawIndexed(const DrawIndexedAttribs& Attribs) override final; - /// Implementation of IDeviceContext::DrawIndirect() in Direct3D11 backend. - virtual void DrawIndirect(const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final; - /// Implementation of IDeviceContext::DrawIndexedIndirect() in Direct3D11 backend. - virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final; - - /// Implementation of IDeviceContext::DispatchCompute() in Direct3D11 backend. - virtual void DispatchCompute(const DispatchComputeAttribs& Attribs) override final; - /// Implementation of IDeviceContext::DispatchComputeIndirect() in Direct3D11 backend. - virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final; - - /// Implementation of IDeviceContext::ClearDepthStencil() in Direct3D11 backend. - virtual void ClearDepthStencil(ITextureView* pView, - CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, - float fDepth, - Uint8 Stencil, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::ClearRenderTarget() in Direct3D11 backend. - virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::UpdateBuffer() in Direct3D11 backend. - virtual void UpdateBuffer(IBuffer* pBuffer, - Uint32 Offset, - Uint32 Size, - const void* pData, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::CopyBuffer() in Direct3D11 backend. - virtual void CopyBuffer(IBuffer* pSrcBuffer, - Uint32 SrcOffset, - RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, - IBuffer* pDstBuffer, - Uint32 DstOffset, - Uint32 Size, - RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override final; - - /// Implementation of IDeviceContext::MapBuffer() in Direct3D11 backend. - virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) override final; - - /// Implementation of IDeviceContext::UnmapBuffer() in Direct3D11 backend. - virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) override final; - - /// Implementation of IDeviceContext::UpdateTexture() in Direct3D11 backend. - virtual void UpdateTexture(ITexture* pTexture, - Uint32 MipLevel, - Uint32 Slice, - const Box& DstBox, - const TextureSubResData& SubresData, - RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; - - /// Implementation of IDeviceContext::CopyTexture() in Direct3D11 backend. - virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) override final; - - /// Implementation of IDeviceContext::MapTextureSubresource() in Direct3D11 backend. - virtual void MapTextureSubresource(ITexture* pTexture, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - MAP_FLAGS MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData) override final; - - /// Implementation of IDeviceContext::UnmapTextureSubresource() in Direct3D11 backend. - virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) override final; - - /// Implementation of IDeviceContext::GenerateMips() in Direct3D11 backend. - virtual void GenerateMips(ITextureView* pTextureView) override final; - - /// Implementation of IDeviceContext::FinishFrame() in Direct3D11 backend. - virtual void FinishFrame() override final; - - /// Implementation of IDeviceContext::TransitionResourceStates() in Direct3D11 backend. - virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) override final; - - /// Implementation of IDeviceContext::ResolveTextureSubresource() in Direct3D11 backend. - virtual void ResolveTextureSubresource(ITexture* pSrcTexture, - ITexture* pDstTexture, - const ResolveTextureSubresourceAttribs& ResolveAttribs) override final; - - /// Implementation of IDeviceContext::FinishCommandList() in Direct3D11 backend. - void FinishCommandList(class ICommandList** ppCommandList) override final; - - /// Implementation of IDeviceContext::ExecuteCommandList() in Direct3D11 backend. - virtual void ExecuteCommandList(class ICommandList* pCommandList) override final; - - /// Implementation of IDeviceContext::SignalFence() in Direct3D11 backend. - virtual void SignalFence(IFence* pFence, Uint64 Value) override final; - - /// Implementation of IDeviceContext::WaitForFence() in Direct3D11 backend. - virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext) override final; - - /// Implementation of IDeviceContext::WaitForIdle() in Direct3D11 backend. - virtual void WaitForIdle() override final; - - /// Implementation of IDeviceContext::BeginQuery() in Direct3D11 backend. - virtual void BeginQuery(IQuery* pQuery) override final; - - /// Implementation of IDeviceContext::EndQuery() in Direct3D11 backend. - virtual void EndQuery(IQuery* pQuery) override final; - - /// Implementation of IDeviceContext::Flush() in Direct3D11 backend. - virtual void Flush() override final; - - /// Implementation of IDeviceContextD3D11::GetD3D11DeviceContext(). - virtual ID3D11DeviceContext* GetD3D11DeviceContext() override final { return m_pd3d11DeviceContext; } - - void CommitRenderTargets(); - - /// Clears committed shader resource cache. This function - /// is called once per frame (before present) to release all - /// outstanding objects that are only kept alive by references - /// in the cache. The function does not release cached vertex and - /// index buffers, input layout, depth-stencil, rasterizer, and blend - /// states. - void ReleaseCommittedShaderResources(); - - /// Unbinds all render targets. Used when resizing the swap chain. - virtual void ResetRenderTargets() override final; - - /// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute) - static constexpr int NumShaderTypes = 6; - -private: - /// Commits d3d11 index buffer to d3d11 device context. - void CommitD3D11IndexBuffer(VALUE_TYPE IndexType); - - /// Commits d3d11 vertex buffers to d3d11 device context. - void CommitD3D11VertexBuffers(class PipelineStateD3D11Impl* pPipelineStateD3D11); - - /// Helper template function used to facilitate resource unbinding - template - void UnbindResourceView(TD3D11ResourceViewType CommittedD3D11ViewsArr[][NumSlots], - ID3D11Resource* CommittedD3D11ResourcesArr[][NumSlots], - Uint8 NumCommittedResourcesArr[], - ID3D11Resource* pd3d11ResToUndind, - TSetD3D11View SetD3D11ViewMethods[]); - - /// Unbinds a texture from shader resource view slots. - /// \note The function only unbinds the texture from d3d11 device - /// context. All shader bindings are retained. - void UnbindTextureFromInput(TextureBaseD3D11* pTexture, ID3D11Resource* pd3d11Resource); - - /// Unbinds a buffer from input (shader resource views slots, index - /// and vertex buffer slots). - /// \note The function only unbinds the buffer from d3d11 device - /// context. All shader bindings are retained. - void UnbindBufferFromInput(BufferD3D11Impl* pBuffer, ID3D11Resource* pd3d11Buffer); - - /// Unbinds a resource from UAV slots. - /// \note The function only unbinds the resource from d3d11 device - /// context. All shader bindings are retained. - void UnbindResourceFromUAV(IDeviceObject* pResource, ID3D11Resource* pd3d11Resource); - - /// Unbinds a texture from render target slots. - void UnbindTextureFromRenderTarget(TextureBaseD3D11* pResource); - - /// Unbinds a texture from depth-stencil. - void UnbindTextureFromDepthStencil(TextureBaseD3D11* pTexD3D11); - - /// Prepares for a draw command - __forceinline void PrepareForDraw(DRAW_FLAGS Flags); - - /// Prepares for an indexed draw command - __forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType); - - - template - void TransitionAndCommitShaderResources(IPipelineState* pPSO, IShaderResourceBinding* pShaderResourceBinding, bool VerifyStates); - - void ClearStateCache(); - - CComPtr m_pd3d11DeviceContext; ///< D3D11 device context - - // clang-format off - - /// An array of D3D11 constant buffers committed to D3D11 device context, - /// for each shader type. The context addref's all bound resources, so we do - /// not need to keep strong references. - ID3D11Buffer* m_CommittedD3D11CBs [NumShaderTypes][D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] = {}; - - /// An array of D3D11 shader resource views committed to D3D11 device context, - /// for each shader type. The context addref's all bound resources, so we do - /// not need to keep strong references. - ID3D11ShaderResourceView* m_CommittedD3D11SRVs [NumShaderTypes][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {}; - - /// An array of D3D11 samplers committed to D3D11 device context, - /// for each shader type. The context addref's all bound resources, so we do - /// not need to keep strong references. - ID3D11SamplerState* m_CommittedD3D11Samplers[NumShaderTypes][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT] = {}; - - /// An array of D3D11 UAVs committed to D3D11 device context, - /// for each shader type. The context addref's all bound resources, so we do - /// not need to keep strong references. - ID3D11UnorderedAccessView* m_CommittedD3D11UAVs [NumShaderTypes][D3D11_PS_CS_UAV_REGISTER_COUNT] = {}; - - /// An array of D3D11 resources commited as SRV to D3D11 device context, - /// for each shader type. The context addref's all bound resources, so we do - /// not need to keep strong references. - ID3D11Resource* m_CommittedD3D11SRVResources [NumShaderTypes][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {}; - - /// An array of D3D11 resources commited as UAV to D3D11 device context, - /// for each shader type. The context addref's all bound resources, so we do - /// not need to keep strong references. - ID3D11Resource* m_CommittedD3D11UAVResources [NumShaderTypes][D3D11_PS_CS_UAV_REGISTER_COUNT] = {}; - - Uint8 m_NumCommittedCBs [NumShaderTypes] = {}; - Uint8 m_NumCommittedSRVs [NumShaderTypes] = {}; - Uint8 m_NumCommittedSamplers[NumShaderTypes] = {}; - Uint8 m_NumCommittedUAVs [NumShaderTypes] = {}; - - // clang-format on - - /// An array of D3D11 vertex buffers committed to D3D device context. - /// There is no need to keep strong references because D3D11 device context - /// already does. Buffers cannot be destroyed while bound to the context. - /// We only mirror all bindings. - ID3D11Buffer* m_CommittedD3D11VertexBuffers[MAX_BUFFER_SLOTS] = {}; - /// An array of strides of committed vertex buffers - UINT m_CommittedD3D11VBStrides[MAX_BUFFER_SLOTS] = {}; - /// An array of offsets of committed vertex buffers - UINT m_CommittedD3D11VBOffsets[MAX_BUFFER_SLOTS] = {}; - /// Number committed vertex buffers - UINT m_NumCommittedD3D11VBs = 0; - /// Flag indicating if currently committed D3D11 vertex buffers are up to date - bool m_bCommittedD3D11VBsUpToDate = false; - - /// D3D11 input layout committed to device context. - /// The context keeps the layout alive, so there is no need - /// to keep strong reference. - ID3D11InputLayout* m_CommittedD3D11InputLayout = nullptr; - - /// Strong reference to D3D11 buffer committed as index buffer - /// to D3D device context. - CComPtr m_CommittedD3D11IndexBuffer; - /// Format of the committed D3D11 index buffer - VALUE_TYPE m_CommittedIBFormat = VT_UNDEFINED; - /// Offset of the committed D3D11 index buffer - Uint32 m_CommittedD3D11IndexDataStartOffset = 0; - /// Flag indicating if currently committed D3D11 index buffer is up to date - bool m_bCommittedD3D11IBUpToDate = false; - - D3D11_PRIMITIVE_TOPOLOGY m_CommittedD3D11PrimTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; - PRIMITIVE_TOPOLOGY m_CommittedPrimitiveTopology = PRIMITIVE_TOPOLOGY_UNDEFINED; - - /// Strong references to committed D3D11 shaders - CComPtr m_CommittedD3DShaders[NumShaderTypes]; - - const Uint32 m_DebugFlags; - - FixedBlockMemoryAllocator m_CmdListAllocator; - - DisjointQueryPool m_DisjointQueryPool; - std::shared_ptr m_ActiveDisjointQuery; - -#ifdef VERIFY_CONTEXT_BINDINGS - - /// Helper template function used to facilitate context verification - template - void dbgVerifyCommittedResources(TD3D11ResourceType CommittedD3D11ResourcesArr[][MaxResources], - Uint8 NumCommittedResourcesArr[], - TGetD3D11ResourcesType GetD3D11ResMethods[], - const Char* ResourceName, - SHADER_TYPE ShaderType); - - /// Helper template function used to facilitate validation of SRV and UAV consistency with D3D11 resources - template - void dbgVerifyViewConsistency(TD3D11ViewType CommittedD3D11ViewArr[][MaxResources], - ID3D11Resource* CommittedD3D11ResourcesArr[][MaxResources], - Uint8 NumCommittedResourcesArr[], - const Char* ResourceName, - SHADER_TYPE ShaderType); - - /// Debug function that verifies that SRVs cached in m_CommittedD3D11SRVs - /// array comply with resources actually committed to D3D11 device context - void dbgVerifyCommittedSRVs(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); - - /// Debug function that verifies that UAVs cached in m_CommittedD3D11UAVs - /// array comply with resources actually committed to D3D11 device context - void dbgVerifyCommittedUAVs(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); - - /// Debug function that verifies that samplers cached in m_CommittedD3D11Samplers - /// array comply with resources actually committed to D3D11 device context - void dbgVerifyCommittedSamplers(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); - - /// Debug function that verifies that constant buffers cached in m_CommittedD3D11CBs - /// array comply with buffers actually committed to D3D11 device context - void dbgVerifyCommittedCBs(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); - - /// Debug function that verifies that index buffer cached in - /// m_CommittedD3D11IndexBuffer is the buffer actually committed to D3D11 - /// device context - void dbgVerifyCommittedIndexBuffer(); - - /// Debug function that verifies that vertex buffers cached in - /// m_CommittedD3D11VertexBuffers are the buffers actually committed to D3D11 - /// device context - void dbgVerifyCommittedVertexBuffers(); - - /// Debug function that verifies that shaders cached in - /// m_CommittedD3DShaders are the shaders actually committed to D3D11 - /// device context - void dbgVerifyCommittedShaders(); - -#else -# define dbgVerifyRenderTargetFormats(...) -# define dbgVerifyCommittedSRVs(...) -# define dbgVerifyCommittedUAVs(...) -# define dbgVerifyCommittedSamplers(...) -# define dbgVerifyCommittedCBs(...) -# define dbgVerifyCommittedIndexBuffer(...) -# define dbgVerifyCommittedVertexBuffers(...) -# define dbgVerifyCommittedShaders(...) -#endif // VERIFY_CONTEXT_BINDINGS -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp new file mode 100644 index 00000000..f1105509 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -0,0 +1,438 @@ +/* + * 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::DeviceContextD3D11Impl class + +#include "DeviceContextD3D11.h" +#include "DeviceContextBase.hpp" +#include "ShaderD3D11Impl.hpp" +#include "BufferD3D11Impl.hpp" +#include "TextureBaseD3D11.hpp" +#include "PipelineStateD3D11Impl.hpp" +#include "QueryD3D11Impl.hpp" +#include "DisjointQueryPool.hpp" + +#ifdef _DEBUG +# define VERIFY_CONTEXT_BINDINGS +#endif + +namespace Diligent +{ + +class RenderDeviceD3D11Impl; + +struct DeviceContextD3D11ImplTraits +{ + using BufferType = BufferD3D11Impl; + using TextureType = TextureBaseD3D11; + using PipelineStateType = PipelineStateD3D11Impl; + using DeviceType = RenderDeviceD3D11Impl; + using QueryType = QueryD3D11Impl; +}; + +/// Device context implementation in Direct3D11 backend. +class DeviceContextD3D11Impl final : public DeviceContextBase +{ +public: + using TDeviceContextBase = DeviceContextBase; + + DeviceContextD3D11Impl(IReferenceCounters* pRefCounters, + IMemoryAllocator& Allocator, + RenderDeviceD3D11Impl* pDevice, + ID3D11DeviceContext* pd3d11DeviceContext, + const struct EngineD3D11CreateInfo& EngineAttribs, + bool bIsDeferred); + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of IDeviceContext::SetPipelineState() in Direct3D11 backend. + virtual void SetPipelineState(IPipelineState* pPipelineState) override final; + + /// Implementation of IDeviceContext::TransitionShaderResources() in Direct3D11 backend. + virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) override final; + + /// Implementation of IDeviceContext::CommitShaderResources() in Direct3D11 backend. + virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::SetStencilRef() in Direct3D11 backend. + virtual void SetStencilRef(Uint32 StencilRef) override final; + + /// Implementation of IDeviceContext::SetBlendFactors() in Direct3D11 backend. + virtual void SetBlendFactors(const float* pBlendFactors = nullptr) override final; + + /// Implementation of IDeviceContext::SetVertexBuffers() in Direct3D11 backend. + virtual void SetVertexBuffers(Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, + SET_VERTEX_BUFFERS_FLAGS Flags) override final; + + /// Implementation of IDeviceContext::InvalidateState() in Direct3D11 backend. + virtual void InvalidateState() override final; + + /// Implementation of IDeviceContext::SetIndexBuffer() in Direct3D11 backend. + virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::SetViewports() in Direct3D11 backend. + virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight) override final; + + /// Implementation of IDeviceContext::SetScissorRects() in Direct3D11 backend. + virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight) override final; + + /// Implementation of IDeviceContext::SetRenderTargets() in Direct3D11 backend. + virtual void SetRenderTargets(Uint32 NumRenderTargets, + ITextureView* ppRenderTargets[], + ITextureView* pDepthStencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::Draw() in Direct3D11 backend. + virtual void Draw(const DrawAttribs& Attribs) override final; + /// Implementation of IDeviceContext::DrawIndexed() in Direct3D11 backend. + virtual void DrawIndexed(const DrawIndexedAttribs& Attribs) override final; + /// Implementation of IDeviceContext::DrawIndirect() in Direct3D11 backend. + virtual void DrawIndirect(const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final; + /// Implementation of IDeviceContext::DrawIndexedIndirect() in Direct3D11 backend. + virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final; + + /// Implementation of IDeviceContext::DispatchCompute() in Direct3D11 backend. + virtual void DispatchCompute(const DispatchComputeAttribs& Attribs) override final; + /// Implementation of IDeviceContext::DispatchComputeIndirect() in Direct3D11 backend. + virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final; + + /// Implementation of IDeviceContext::ClearDepthStencil() in Direct3D11 backend. + virtual void ClearDepthStencil(ITextureView* pView, + CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, + float fDepth, + Uint8 Stencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::ClearRenderTarget() in Direct3D11 backend. + virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::UpdateBuffer() in Direct3D11 backend. + virtual void UpdateBuffer(IBuffer* pBuffer, + Uint32 Offset, + Uint32 Size, + const void* pData, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::CopyBuffer() in Direct3D11 backend. + virtual void CopyBuffer(IBuffer* pSrcBuffer, + Uint32 SrcOffset, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + IBuffer* pDstBuffer, + Uint32 DstOffset, + Uint32 Size, + RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override final; + + /// Implementation of IDeviceContext::MapBuffer() in Direct3D11 backend. + virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) override final; + + /// Implementation of IDeviceContext::UnmapBuffer() in Direct3D11 backend. + virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) override final; + + /// Implementation of IDeviceContext::UpdateTexture() in Direct3D11 backend. + virtual void UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + + /// Implementation of IDeviceContext::CopyTexture() in Direct3D11 backend. + virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) override final; + + /// Implementation of IDeviceContext::MapTextureSubresource() in Direct3D11 backend. + virtual void MapTextureSubresource(ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + MAP_FLAGS MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData) override final; + + /// Implementation of IDeviceContext::UnmapTextureSubresource() in Direct3D11 backend. + virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) override final; + + /// Implementation of IDeviceContext::GenerateMips() in Direct3D11 backend. + virtual void GenerateMips(ITextureView* pTextureView) override final; + + /// Implementation of IDeviceContext::FinishFrame() in Direct3D11 backend. + virtual void FinishFrame() override final; + + /// Implementation of IDeviceContext::TransitionResourceStates() in Direct3D11 backend. + virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) override final; + + /// Implementation of IDeviceContext::ResolveTextureSubresource() in Direct3D11 backend. + virtual void ResolveTextureSubresource(ITexture* pSrcTexture, + ITexture* pDstTexture, + const ResolveTextureSubresourceAttribs& ResolveAttribs) override final; + + /// Implementation of IDeviceContext::FinishCommandList() in Direct3D11 backend. + void FinishCommandList(class ICommandList** ppCommandList) override final; + + /// Implementation of IDeviceContext::ExecuteCommandList() in Direct3D11 backend. + virtual void ExecuteCommandList(class ICommandList* pCommandList) override final; + + /// Implementation of IDeviceContext::SignalFence() in Direct3D11 backend. + virtual void SignalFence(IFence* pFence, Uint64 Value) override final; + + /// Implementation of IDeviceContext::WaitForFence() in Direct3D11 backend. + virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext) override final; + + /// Implementation of IDeviceContext::WaitForIdle() in Direct3D11 backend. + virtual void WaitForIdle() override final; + + /// Implementation of IDeviceContext::BeginQuery() in Direct3D11 backend. + virtual void BeginQuery(IQuery* pQuery) override final; + + /// Implementation of IDeviceContext::EndQuery() in Direct3D11 backend. + virtual void EndQuery(IQuery* pQuery) override final; + + /// Implementation of IDeviceContext::Flush() in Direct3D11 backend. + virtual void Flush() override final; + + /// Implementation of IDeviceContextD3D11::GetD3D11DeviceContext(). + virtual ID3D11DeviceContext* GetD3D11DeviceContext() override final { return m_pd3d11DeviceContext; } + + void CommitRenderTargets(); + + /// Clears committed shader resource cache. This function + /// is called once per frame (before present) to release all + /// outstanding objects that are only kept alive by references + /// in the cache. The function does not release cached vertex and + /// index buffers, input layout, depth-stencil, rasterizer, and blend + /// states. + void ReleaseCommittedShaderResources(); + + /// Unbinds all render targets. Used when resizing the swap chain. + virtual void ResetRenderTargets() override final; + + /// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute) + static constexpr int NumShaderTypes = 6; + +private: + /// Commits d3d11 index buffer to d3d11 device context. + void CommitD3D11IndexBuffer(VALUE_TYPE IndexType); + + /// Commits d3d11 vertex buffers to d3d11 device context. + void CommitD3D11VertexBuffers(class PipelineStateD3D11Impl* pPipelineStateD3D11); + + /// Helper template function used to facilitate resource unbinding + template + void UnbindResourceView(TD3D11ResourceViewType CommittedD3D11ViewsArr[][NumSlots], + ID3D11Resource* CommittedD3D11ResourcesArr[][NumSlots], + Uint8 NumCommittedResourcesArr[], + ID3D11Resource* pd3d11ResToUndind, + TSetD3D11View SetD3D11ViewMethods[]); + + /// Unbinds a texture from shader resource view slots. + /// \note The function only unbinds the texture from d3d11 device + /// context. All shader bindings are retained. + void UnbindTextureFromInput(TextureBaseD3D11* pTexture, ID3D11Resource* pd3d11Resource); + + /// Unbinds a buffer from input (shader resource views slots, index + /// and vertex buffer slots). + /// \note The function only unbinds the buffer from d3d11 device + /// context. All shader bindings are retained. + void UnbindBufferFromInput(BufferD3D11Impl* pBuffer, ID3D11Resource* pd3d11Buffer); + + /// Unbinds a resource from UAV slots. + /// \note The function only unbinds the resource from d3d11 device + /// context. All shader bindings are retained. + void UnbindResourceFromUAV(IDeviceObject* pResource, ID3D11Resource* pd3d11Resource); + + /// Unbinds a texture from render target slots. + void UnbindTextureFromRenderTarget(TextureBaseD3D11* pResource); + + /// Unbinds a texture from depth-stencil. + void UnbindTextureFromDepthStencil(TextureBaseD3D11* pTexD3D11); + + /// Prepares for a draw command + __forceinline void PrepareForDraw(DRAW_FLAGS Flags); + + /// Prepares for an indexed draw command + __forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType); + + + template + void TransitionAndCommitShaderResources(IPipelineState* pPSO, IShaderResourceBinding* pShaderResourceBinding, bool VerifyStates); + + void ClearStateCache(); + + CComPtr m_pd3d11DeviceContext; ///< D3D11 device context + + // clang-format off + + /// An array of D3D11 constant buffers committed to D3D11 device context, + /// for each shader type. The context addref's all bound resources, so we do + /// not need to keep strong references. + ID3D11Buffer* m_CommittedD3D11CBs [NumShaderTypes][D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] = {}; + + /// An array of D3D11 shader resource views committed to D3D11 device context, + /// for each shader type. The context addref's all bound resources, so we do + /// not need to keep strong references. + ID3D11ShaderResourceView* m_CommittedD3D11SRVs [NumShaderTypes][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {}; + + /// An array of D3D11 samplers committed to D3D11 device context, + /// for each shader type. The context addref's all bound resources, so we do + /// not need to keep strong references. + ID3D11SamplerState* m_CommittedD3D11Samplers[NumShaderTypes][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT] = {}; + + /// An array of D3D11 UAVs committed to D3D11 device context, + /// for each shader type. The context addref's all bound resources, so we do + /// not need to keep strong references. + ID3D11UnorderedAccessView* m_CommittedD3D11UAVs [NumShaderTypes][D3D11_PS_CS_UAV_REGISTER_COUNT] = {}; + + /// An array of D3D11 resources commited as SRV to D3D11 device context, + /// for each shader type. The context addref's all bound resources, so we do + /// not need to keep strong references. + ID3D11Resource* m_CommittedD3D11SRVResources [NumShaderTypes][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {}; + + /// An array of D3D11 resources commited as UAV to D3D11 device context, + /// for each shader type. The context addref's all bound resources, so we do + /// not need to keep strong references. + ID3D11Resource* m_CommittedD3D11UAVResources [NumShaderTypes][D3D11_PS_CS_UAV_REGISTER_COUNT] = {}; + + Uint8 m_NumCommittedCBs [NumShaderTypes] = {}; + Uint8 m_NumCommittedSRVs [NumShaderTypes] = {}; + Uint8 m_NumCommittedSamplers[NumShaderTypes] = {}; + Uint8 m_NumCommittedUAVs [NumShaderTypes] = {}; + + // clang-format on + + /// An array of D3D11 vertex buffers committed to D3D device context. + /// There is no need to keep strong references because D3D11 device context + /// already does. Buffers cannot be destroyed while bound to the context. + /// We only mirror all bindings. + ID3D11Buffer* m_CommittedD3D11VertexBuffers[MAX_BUFFER_SLOTS] = {}; + /// An array of strides of committed vertex buffers + UINT m_CommittedD3D11VBStrides[MAX_BUFFER_SLOTS] = {}; + /// An array of offsets of committed vertex buffers + UINT m_CommittedD3D11VBOffsets[MAX_BUFFER_SLOTS] = {}; + /// Number committed vertex buffers + UINT m_NumCommittedD3D11VBs = 0; + /// Flag indicating if currently committed D3D11 vertex buffers are up to date + bool m_bCommittedD3D11VBsUpToDate = false; + + /// D3D11 input layout committed to device context. + /// The context keeps the layout alive, so there is no need + /// to keep strong reference. + ID3D11InputLayout* m_CommittedD3D11InputLayout = nullptr; + + /// Strong reference to D3D11 buffer committed as index buffer + /// to D3D device context. + CComPtr m_CommittedD3D11IndexBuffer; + /// Format of the committed D3D11 index buffer + VALUE_TYPE m_CommittedIBFormat = VT_UNDEFINED; + /// Offset of the committed D3D11 index buffer + Uint32 m_CommittedD3D11IndexDataStartOffset = 0; + /// Flag indicating if currently committed D3D11 index buffer is up to date + bool m_bCommittedD3D11IBUpToDate = false; + + D3D11_PRIMITIVE_TOPOLOGY m_CommittedD3D11PrimTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; + PRIMITIVE_TOPOLOGY m_CommittedPrimitiveTopology = PRIMITIVE_TOPOLOGY_UNDEFINED; + + /// Strong references to committed D3D11 shaders + CComPtr m_CommittedD3DShaders[NumShaderTypes]; + + const Uint32 m_DebugFlags; + + FixedBlockMemoryAllocator m_CmdListAllocator; + + DisjointQueryPool m_DisjointQueryPool; + std::shared_ptr m_ActiveDisjointQuery; + +#ifdef VERIFY_CONTEXT_BINDINGS + + /// Helper template function used to facilitate context verification + template + void dbgVerifyCommittedResources(TD3D11ResourceType CommittedD3D11ResourcesArr[][MaxResources], + Uint8 NumCommittedResourcesArr[], + TGetD3D11ResourcesType GetD3D11ResMethods[], + const Char* ResourceName, + SHADER_TYPE ShaderType); + + /// Helper template function used to facilitate validation of SRV and UAV consistency with D3D11 resources + template + void dbgVerifyViewConsistency(TD3D11ViewType CommittedD3D11ViewArr[][MaxResources], + ID3D11Resource* CommittedD3D11ResourcesArr[][MaxResources], + Uint8 NumCommittedResourcesArr[], + const Char* ResourceName, + SHADER_TYPE ShaderType); + + /// Debug function that verifies that SRVs cached in m_CommittedD3D11SRVs + /// array comply with resources actually committed to D3D11 device context + void dbgVerifyCommittedSRVs(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); + + /// Debug function that verifies that UAVs cached in m_CommittedD3D11UAVs + /// array comply with resources actually committed to D3D11 device context + void dbgVerifyCommittedUAVs(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); + + /// Debug function that verifies that samplers cached in m_CommittedD3D11Samplers + /// array comply with resources actually committed to D3D11 device context + void dbgVerifyCommittedSamplers(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); + + /// Debug function that verifies that constant buffers cached in m_CommittedD3D11CBs + /// array comply with buffers actually committed to D3D11 device context + void dbgVerifyCommittedCBs(SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN); + + /// Debug function that verifies that index buffer cached in + /// m_CommittedD3D11IndexBuffer is the buffer actually committed to D3D11 + /// device context + void dbgVerifyCommittedIndexBuffer(); + + /// Debug function that verifies that vertex buffers cached in + /// m_CommittedD3D11VertexBuffers are the buffers actually committed to D3D11 + /// device context + void dbgVerifyCommittedVertexBuffers(); + + /// Debug function that verifies that shaders cached in + /// m_CommittedD3DShaders are the shaders actually committed to D3D11 + /// device context + void dbgVerifyCommittedShaders(); + +#else +# define dbgVerifyRenderTargetFormats(...) +# define dbgVerifyCommittedSRVs(...) +# define dbgVerifyCommittedUAVs(...) +# define dbgVerifyCommittedSamplers(...) +# define dbgVerifyCommittedCBs(...) +# define dbgVerifyCommittedIndexBuffer(...) +# define dbgVerifyCommittedVertexBuffers(...) +# define dbgVerifyCommittedShaders(...) +#endif // VERIFY_CONTEXT_BINDINGS +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h b/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h deleted file mode 100644 index c9d259ab..00000000 --- a/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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::DisjointQueryPool class - -#include - -namespace Diligent -{ - -class DisjointQueryPool final -{ -public: - struct DisjointQueryWrapper - { - DisjointQueryPool& Pool; - CComPtr pd3d11Query; - bool IsEnded = false; - - DisjointQueryWrapper(DisjointQueryPool& _Pool, - CComPtr&& _pd3d11Query) : - Pool(_Pool), - pd3d11Query(std::move(_pd3d11Query)) - { - } - - ~DisjointQueryWrapper() - { - Pool.m_AvailableQueries.emplace_back(std::move(pd3d11Query)); - } - - DisjointQueryWrapper(DisjointQueryWrapper&&) = default; - - DisjointQueryWrapper(const DisjointQueryWrapper&) = delete; - DisjointQueryWrapper& operator=(const DisjointQueryWrapper&) = delete; - DisjointQueryWrapper& operator=(DisjointQueryWrapper&&) = delete; - }; - - std::shared_ptr GetDisjointQuery(ID3D11Device* pd3d11Device) - { - CComPtr pd3d11Query; - if (!m_AvailableQueries.empty()) - { - pd3d11Query = std::move(m_AvailableQueries.back()); - m_AvailableQueries.pop_back(); - } - else - { - pd3d11Query = CreateQuery(pd3d11Device); - } - return std::shared_ptr{new DisjointQueryWrapper{*this, std::move(pd3d11Query)}}; - } - - ~DisjointQueryPool() - { - LOG_INFO_MESSAGE("Disjoint query pool: created ", m_NumQueriesCreated, (m_NumQueriesCreated == 1 ? " query" : " queries")); - } - -private: - CComPtr CreateQuery(ID3D11Device* pd3d11Device) - { - D3D11_QUERY_DESC QueryDesc = {D3D11_QUERY_TIMESTAMP_DISJOINT, 0}; - - CComPtr pd3d11Query; - pd3d11Device->CreateQuery(&QueryDesc, &pd3d11Query); - DEV_CHECK_ERR(pd3d11Query, "Failed to create D3D11 disjoint query"); - ++m_NumQueriesCreated; - return pd3d11Query; - } - std::vector> m_AvailableQueries; - - Uint32 m_NumQueriesCreated = 0; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.hpp b/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.hpp new file mode 100644 index 00000000..c9d259ab --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.hpp @@ -0,0 +1,102 @@ +/* + * 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::DisjointQueryPool class + +#include + +namespace Diligent +{ + +class DisjointQueryPool final +{ +public: + struct DisjointQueryWrapper + { + DisjointQueryPool& Pool; + CComPtr pd3d11Query; + bool IsEnded = false; + + DisjointQueryWrapper(DisjointQueryPool& _Pool, + CComPtr&& _pd3d11Query) : + Pool(_Pool), + pd3d11Query(std::move(_pd3d11Query)) + { + } + + ~DisjointQueryWrapper() + { + Pool.m_AvailableQueries.emplace_back(std::move(pd3d11Query)); + } + + DisjointQueryWrapper(DisjointQueryWrapper&&) = default; + + DisjointQueryWrapper(const DisjointQueryWrapper&) = delete; + DisjointQueryWrapper& operator=(const DisjointQueryWrapper&) = delete; + DisjointQueryWrapper& operator=(DisjointQueryWrapper&&) = delete; + }; + + std::shared_ptr GetDisjointQuery(ID3D11Device* pd3d11Device) + { + CComPtr pd3d11Query; + if (!m_AvailableQueries.empty()) + { + pd3d11Query = std::move(m_AvailableQueries.back()); + m_AvailableQueries.pop_back(); + } + else + { + pd3d11Query = CreateQuery(pd3d11Device); + } + return std::shared_ptr{new DisjointQueryWrapper{*this, std::move(pd3d11Query)}}; + } + + ~DisjointQueryPool() + { + LOG_INFO_MESSAGE("Disjoint query pool: created ", m_NumQueriesCreated, (m_NumQueriesCreated == 1 ? " query" : " queries")); + } + +private: + CComPtr CreateQuery(ID3D11Device* pd3d11Device) + { + D3D11_QUERY_DESC QueryDesc = {D3D11_QUERY_TIMESTAMP_DISJOINT, 0}; + + CComPtr pd3d11Query; + pd3d11Device->CreateQuery(&QueryDesc, &pd3d11Query); + DEV_CHECK_ERR(pd3d11Query, "Failed to create D3D11 disjoint query"); + ++m_NumQueriesCreated; + return pd3d11Query; + } + std::vector> m_AvailableQueries; + + Uint32 m_NumQueriesCreated = 0; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h deleted file mode 100644 index e4f923de..00000000 --- a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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::FenceD3D11Impl class - -#include -#include "FenceD3D11.h" -#include "RenderDeviceD3D11.h" -#include "FenceBase.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Fence implementation in Direct3D11 backend. -class FenceD3D11Impl final : public FenceBase -{ -public: - using TFenceBase = FenceBase; - - FenceD3D11Impl(IReferenceCounters* pRefCounters, - RenderDeviceD3D11Impl* pDevice, - const FenceDesc& Desc); - ~FenceD3D11Impl(); - - IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_FenceD3D11, TFenceBase); - - /// Implementation of IFence::GetCompletedValue() in Direct3D11 backend. - virtual Uint64 GetCompletedValue() override final; - - /// Implementation of IFence::Reset() in Direct3D11 backend. - virtual void Reset(Uint64 Value) override final; - - void AddPendingQuery(CComPtr pCtx, CComPtr pQuery, Uint64 Value) - { - m_PendingQueries.emplace_back(std::move(pCtx), std::move(pQuery), Value); - } - - void Wait(Uint64 Value, bool FlushCommands); - -private: - struct PendingFenceData - { - CComPtr pd3d11Ctx; - CComPtr pd3d11Query; - Uint64 Value; - - PendingFenceData(CComPtr pCtx, CComPtr pQuery, Uint64 _Value) : - // clang-format off - pd3d11Ctx {std::move(pCtx)}, - pd3d11Query{std::move(pQuery)}, - Value {_Value} - // clang-format on - {} - }; - std::deque m_PendingQueries; - volatile Uint64 m_LastCompletedFenceValue = 0; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp new file mode 100644 index 00000000..3b08400a --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.hpp @@ -0,0 +1,89 @@ +/* + * 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::FenceD3D11Impl class + +#include +#include "FenceD3D11.h" +#include "RenderDeviceD3D11.h" +#include "FenceBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Fence implementation in Direct3D11 backend. +class FenceD3D11Impl final : public FenceBase +{ +public: + using TFenceBase = FenceBase; + + FenceD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const FenceDesc& Desc); + ~FenceD3D11Impl(); + + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_FenceD3D11, TFenceBase); + + /// Implementation of IFence::GetCompletedValue() in Direct3D11 backend. + virtual Uint64 GetCompletedValue() override final; + + /// Implementation of IFence::Reset() in Direct3D11 backend. + virtual void Reset(Uint64 Value) override final; + + void AddPendingQuery(CComPtr pCtx, CComPtr pQuery, Uint64 Value) + { + m_PendingQueries.emplace_back(std::move(pCtx), std::move(pQuery), Value); + } + + void Wait(Uint64 Value, bool FlushCommands); + +private: + struct PendingFenceData + { + CComPtr pd3d11Ctx; + CComPtr pd3d11Query; + Uint64 Value; + + PendingFenceData(CComPtr pCtx, CComPtr pQuery, Uint64 _Value) : + // clang-format off + pd3d11Ctx {std::move(pCtx)}, + pd3d11Query{std::move(pQuery)}, + Value {_Value} + // clang-format on + {} + }; + std::deque m_PendingQueries; + volatile Uint64 m_LastCompletedFenceValue = 0; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h deleted file mode 100644 index 0a2c9805..00000000 --- a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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::PipelineStateD3D11Impl class - -#include "PipelineStateD3D11.h" -#include "RenderDeviceD3D11.h" -#include "PipelineStateBase.h" -#include "ShaderD3D11Impl.h" -#include "SRBMemoryAllocator.hpp" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Pipeline state object implementation in Direct3D11 backend. -class PipelineStateD3D11Impl final : public PipelineStateBase -{ -public: - using TPipelineStateBase = PipelineStateBase; - - PipelineStateD3D11Impl(IReferenceCounters* pRefCounters, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const PipelineStateDesc& PipelineDesc); - ~PipelineStateD3D11Impl(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of IPipelineState::BindStaticResources() in Direct3D11 backend. - virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags) override final; - - /// Implementation of IPipelineState::GetStaticVariableCount() in Direct3D11 backend. - virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const override final; - - /// Implementation of IPipelineState::GetStaticVariableByName() in Direct3D11 backend. - virtual IShaderResourceVariable* GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) override final; - - /// Implementation of IPipelineState::GetStaticVariableByIndex() in Direct3D11 backend. - virtual IShaderResourceVariable* GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final; - - /// Implementation of IPipelineState::CreateShaderResourceBinding() in Direct3D11 backend. - virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources) override final; - - /// Implementation of IPipelineState::IsCompatibleWith() in Direct3D11 backend. - virtual bool IsCompatibleWith(const IPipelineState* pPSO) const override final; - - - /// Implementation of IPipelineStateD3D11::GetD3D11BlendState() method. - virtual ID3D11BlendState* GetD3D11BlendState() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11RasterizerState() method. - virtual ID3D11RasterizerState* GetD3D11RasterizerState() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11DepthStencilState() method. - virtual ID3D11DepthStencilState* GetD3D11DepthStencilState() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11InputLayout() method. - virtual ID3D11InputLayout* GetD3D11InputLayout() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11VertexShader() method. - virtual ID3D11VertexShader* GetD3D11VertexShader() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11PixelShader() method. - virtual ID3D11PixelShader* GetD3D11PixelShader() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11GeometryShader() method. - virtual ID3D11GeometryShader* GetD3D11GeometryShader() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11DomainShader() method. - virtual ID3D11DomainShader* GetD3D11DomainShader() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11HullShader() method. - virtual ID3D11HullShader* GetD3D11HullShader() override final; - - /// Implementation of IPipelineStateD3D11::GetD3D11ComputeShader() method. - virtual ID3D11ComputeShader* GetD3D11ComputeShader() override final; - - - SRBMemoryAllocator& GetSRBMemoryAllocator() - { - return m_SRBMemAllocator; - } - - const ShaderResourceLayoutD3D11& GetStaticResourceLayout(Uint32 s) const - { - VERIFY_EXPR(s < m_NumShaders); - return m_pStaticResourceLayouts[s]; - } - - ShaderResourceCacheD3D11& GetStaticResourceCache(Uint32 s) - { - VERIFY_EXPR(s < m_NumShaders); - return m_pStaticResourceCaches[s]; - } - - void SetStaticSamplers(ShaderResourceCacheD3D11& ResourceCache, Uint32 ShaderInd) const; - -private: - CComPtr m_pd3d11BlendState; - CComPtr m_pd3d11RasterizerState; - CComPtr m_pd3d11DepthStencilState; - CComPtr m_pd3d11InputLayout; - - // The caches are indexed by the shader order in the PSO, not shader index - ShaderResourceCacheD3D11* m_pStaticResourceCaches = nullptr; - ShaderResourceLayoutD3D11* m_pStaticResourceLayouts = nullptr; - - // SRB memory allocator must be defined before the default shader res binding - SRBMemoryAllocator m_SRBMemAllocator; - - Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1}; - - Uint16 m_StaticSamplerOffsets[MAX_SHADERS_IN_PIPELINE + 1] = {}; - struct StaticSamplerInfo - { - const D3DShaderResourceAttribs& Attribs; - RefCntAutoPtr pSampler; - StaticSamplerInfo(const D3DShaderResourceAttribs& _Attribs, - RefCntAutoPtr _pSampler) : - // clang-format off - Attribs {_Attribs}, - pSampler {std::move(_pSampler)} - // clang-format on - {} - }; - std::vector> m_StaticSamplers; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp new file mode 100644 index 00000000..59c7b0e8 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp @@ -0,0 +1,158 @@ +/* + * 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::PipelineStateD3D11Impl class + +#include "PipelineStateD3D11.h" +#include "RenderDeviceD3D11.h" +#include "PipelineStateBase.hpp" +#include "ShaderD3D11Impl.hpp" +#include "SRBMemoryAllocator.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Pipeline state object implementation in Direct3D11 backend. +class PipelineStateD3D11Impl final : public PipelineStateBase +{ +public: + using TPipelineStateBase = PipelineStateBase; + + PipelineStateD3D11Impl(IReferenceCounters* pRefCounters, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const PipelineStateDesc& PipelineDesc); + ~PipelineStateD3D11Impl(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of IPipelineState::BindStaticResources() in Direct3D11 backend. + virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags) override final; + + /// Implementation of IPipelineState::GetStaticVariableCount() in Direct3D11 backend. + virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const override final; + + /// Implementation of IPipelineState::GetStaticVariableByName() in Direct3D11 backend. + virtual IShaderResourceVariable* GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) override final; + + /// Implementation of IPipelineState::GetStaticVariableByIndex() in Direct3D11 backend. + virtual IShaderResourceVariable* GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final; + + /// Implementation of IPipelineState::CreateShaderResourceBinding() in Direct3D11 backend. + virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources) override final; + + /// Implementation of IPipelineState::IsCompatibleWith() in Direct3D11 backend. + virtual bool IsCompatibleWith(const IPipelineState* pPSO) const override final; + + + /// Implementation of IPipelineStateD3D11::GetD3D11BlendState() method. + virtual ID3D11BlendState* GetD3D11BlendState() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11RasterizerState() method. + virtual ID3D11RasterizerState* GetD3D11RasterizerState() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11DepthStencilState() method. + virtual ID3D11DepthStencilState* GetD3D11DepthStencilState() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11InputLayout() method. + virtual ID3D11InputLayout* GetD3D11InputLayout() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11VertexShader() method. + virtual ID3D11VertexShader* GetD3D11VertexShader() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11PixelShader() method. + virtual ID3D11PixelShader* GetD3D11PixelShader() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11GeometryShader() method. + virtual ID3D11GeometryShader* GetD3D11GeometryShader() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11DomainShader() method. + virtual ID3D11DomainShader* GetD3D11DomainShader() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11HullShader() method. + virtual ID3D11HullShader* GetD3D11HullShader() override final; + + /// Implementation of IPipelineStateD3D11::GetD3D11ComputeShader() method. + virtual ID3D11ComputeShader* GetD3D11ComputeShader() override final; + + + SRBMemoryAllocator& GetSRBMemoryAllocator() + { + return m_SRBMemAllocator; + } + + const ShaderResourceLayoutD3D11& GetStaticResourceLayout(Uint32 s) const + { + VERIFY_EXPR(s < m_NumShaders); + return m_pStaticResourceLayouts[s]; + } + + ShaderResourceCacheD3D11& GetStaticResourceCache(Uint32 s) + { + VERIFY_EXPR(s < m_NumShaders); + return m_pStaticResourceCaches[s]; + } + + void SetStaticSamplers(ShaderResourceCacheD3D11& ResourceCache, Uint32 ShaderInd) const; + +private: + CComPtr m_pd3d11BlendState; + CComPtr m_pd3d11RasterizerState; + CComPtr m_pd3d11DepthStencilState; + CComPtr m_pd3d11InputLayout; + + // The caches are indexed by the shader order in the PSO, not shader index + ShaderResourceCacheD3D11* m_pStaticResourceCaches = nullptr; + ShaderResourceLayoutD3D11* m_pStaticResourceLayouts = nullptr; + + // SRB memory allocator must be defined before the default shader res binding + SRBMemoryAllocator m_SRBMemAllocator; + + Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1}; + + Uint16 m_StaticSamplerOffsets[MAX_SHADERS_IN_PIPELINE + 1] = {}; + struct StaticSamplerInfo + { + const D3DShaderResourceAttribs& Attribs; + RefCntAutoPtr pSampler; + StaticSamplerInfo(const D3DShaderResourceAttribs& _Attribs, + RefCntAutoPtr _pSampler) : + // clang-format off + Attribs {_Attribs}, + pSampler {std::move(_pSampler)} + // clang-format on + {} + }; + std::vector> m_StaticSamplers; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.h deleted file mode 100644 index c8611ec0..00000000 --- a/Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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::QueryD3D11Impl class - -#include - -#include "QueryD3D11.h" -#include "QueryBase.h" -#include "RenderDeviceD3D11Impl.h" -#include "DisjointQueryPool.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Query implementation in Direct3D11 backend. -class QueryD3D11Impl final : public QueryBase -{ -public: - using TQueryBase = QueryBase; - - QueryD3D11Impl(IReferenceCounters* pRefCounters, - RenderDeviceD3D11Impl* pDevice, - const QueryDesc& Desc); - ~QueryD3D11Impl(); - - IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_QueryD3D11, TQueryBase); - - /// Implementation of IQuery::GetData(). - virtual bool GetData(void* pData, Uint32 DataSize, bool AutoInvalidate) override final; - - /// Implementation of IQuery::Invalidate(). - virtual void Invalidate() override final - { - m_DisjointQuery.reset(); - TQueryBase::Invalidate(); - } - - /// Implementation of IQueryD3D11::GetD3D11Query(). - virtual ID3D11Query* GetD3D11Query() override final - { - return m_pd3d11Query; - } - - void SetDisjointQuery(std::shared_ptr DisjointQuery) - { - m_DisjointQuery = DisjointQuery; - } - -private: - CComPtr m_pd3d11Query; - - std::shared_ptr m_DisjointQuery; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.hpp new file mode 100644 index 00000000..c95ddcd9 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/QueryD3D11Impl.hpp @@ -0,0 +1,85 @@ +/* + * 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::QueryD3D11Impl class + +#include + +#include "QueryD3D11.h" +#include "QueryBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" +#include "DisjointQueryPool.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Query implementation in Direct3D11 backend. +class QueryD3D11Impl final : public QueryBase +{ +public: + using TQueryBase = QueryBase; + + QueryD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const QueryDesc& Desc); + ~QueryD3D11Impl(); + + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_QueryD3D11, TQueryBase); + + /// Implementation of IQuery::GetData(). + virtual bool GetData(void* pData, Uint32 DataSize, bool AutoInvalidate) override final; + + /// Implementation of IQuery::Invalidate(). + virtual void Invalidate() override final + { + m_DisjointQuery.reset(); + TQueryBase::Invalidate(); + } + + /// Implementation of IQueryD3D11::GetD3D11Query(). + virtual ID3D11Query* GetD3D11Query() override final + { + return m_pd3d11Query; + } + + void SetDisjointQuery(std::shared_ptr DisjointQuery) + { + m_DisjointQuery = DisjointQuery; + } + +private: + CComPtr m_pd3d11Query; + + std::shared_ptr m_DisjointQuery; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h deleted file mode 100644 index 17285244..00000000 --- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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::RenderDeviceD3D11Impl class - -#include "RenderDeviceD3D11.h" -#include "RenderDeviceD3DBase.h" -#include "DeviceContextD3D11.h" - -namespace Diligent -{ - -/// Render device implementation in Direct3D11 backend. -class RenderDeviceD3D11Impl final : public RenderDeviceD3DBase -{ -public: - using TRenderDeviceBase = RenderDeviceD3DBase; - - RenderDeviceD3D11Impl(IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, - IEngineFactory* pEngineFactory, - const EngineD3D11CreateInfo& EngineAttribs, - ID3D11Device* pd3d11Device, - Uint32 NumDeferredContexts); - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of IRenderDevice::CreateBuffer() in Direct3D11 backend. - virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer) override final; - - /// Implementation of IRenderDevice::CreateShader() in Direct3D11 backend. - virtual void CreateShader(const ShaderCreateInfo& ShaderCI, IShader** ppShader) override final; - - /// Implementation of IRenderDevice::CreateTexture() in Direct3D11 backend. - virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture) override final; - - /// Implementation of IRenderDevice::CreateSampler() in Direct3D11 backend. - virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler) override final; - - /// Implementation of IRenderDevice::CreatePipelineState() in Direct3D11 backend. - virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState** ppPipelineState) override final; - - /// Implementation of IRenderDevice::CreateFence() in Direct3D11 backend. - virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence) override final; - - /// Implementation of IRenderDevice::CreateQuery() in Direct3D11 backend. - virtual void CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) override final; - - /// Implementation of IRenderDeviceD3D11::GetD3D11Device() in Direct3D11 backend. - ID3D11Device* GetD3D11Device() override final { return m_pd3d11Device; } - - /// Implementation of IRenderDeviceD3D11::CreateBufferFromD3DResource() in Direct3D11 backend. - virtual void CreateBufferFromD3DResource(ID3D11Buffer* pd3d11Buffer, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer** ppBuffer) override final; - - /// Implementation of IRenderDeviceD3D11::CreateTextureFromD3DResource() for 1D textures in Direct3D11 backend. - virtual void CreateTextureFromD3DResource(ID3D11Texture1D* pd3d11Texture, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; - - /// Implementation of IRenderDeviceD3D11::CreateTextureFromD3DResource() for 2D textures in Direct3D11 backend. - virtual void CreateTextureFromD3DResource(ID3D11Texture2D* pd3d11Texture, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; - - /// Implementation of IRenderDeviceD3D11::CreateTextureFromD3DResource() for 3D textures in Direct3D11 backend. - virtual void CreateTextureFromD3DResource(ID3D11Texture3D* pd3d11Texture, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; - - /// Implementation of IRenderDevice::ReleaseStaleResources() in Direct3D11 backend. - virtual void ReleaseStaleResources(bool ForceRelease = false) override final {} - - /// Implementation of IRenderDevice::IdleGPU() in Direct3D11 backend. - virtual void IdleGPU() override final; - - size_t GetCommandQueueCount() const { return 1; } - Uint64 GetCommandQueueMask() const { return Uint64{1}; } - -private: - virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) override final; - - EngineD3D11CreateInfo m_EngineAttribs; - - /// D3D11 device - CComPtr m_pd3d11Device; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp new file mode 100644 index 00000000..2c23841c --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp @@ -0,0 +1,108 @@ +/* + * 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::RenderDeviceD3D11Impl class + +#include "RenderDeviceD3D11.h" +#include "RenderDeviceD3DBase.hpp" +#include "DeviceContextD3D11.h" + +namespace Diligent +{ + +/// Render device implementation in Direct3D11 backend. +class RenderDeviceD3D11Impl final : public RenderDeviceD3DBase +{ +public: + using TRenderDeviceBase = RenderDeviceD3DBase; + + RenderDeviceD3D11Impl(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, + const EngineD3D11CreateInfo& EngineAttribs, + ID3D11Device* pd3d11Device, + Uint32 NumDeferredContexts); + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of IRenderDevice::CreateBuffer() in Direct3D11 backend. + virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer) override final; + + /// Implementation of IRenderDevice::CreateShader() in Direct3D11 backend. + virtual void CreateShader(const ShaderCreateInfo& ShaderCI, IShader** ppShader) override final; + + /// Implementation of IRenderDevice::CreateTexture() in Direct3D11 backend. + virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture) override final; + + /// Implementation of IRenderDevice::CreateSampler() in Direct3D11 backend. + virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler) override final; + + /// Implementation of IRenderDevice::CreatePipelineState() in Direct3D11 backend. + virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState** ppPipelineState) override final; + + /// Implementation of IRenderDevice::CreateFence() in Direct3D11 backend. + virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence) override final; + + /// Implementation of IRenderDevice::CreateQuery() in Direct3D11 backend. + virtual void CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) override final; + + /// Implementation of IRenderDeviceD3D11::GetD3D11Device() in Direct3D11 backend. + ID3D11Device* GetD3D11Device() override final { return m_pd3d11Device; } + + /// Implementation of IRenderDeviceD3D11::CreateBufferFromD3DResource() in Direct3D11 backend. + virtual void CreateBufferFromD3DResource(ID3D11Buffer* pd3d11Buffer, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer** ppBuffer) override final; + + /// Implementation of IRenderDeviceD3D11::CreateTextureFromD3DResource() for 1D textures in Direct3D11 backend. + virtual void CreateTextureFromD3DResource(ID3D11Texture1D* pd3d11Texture, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; + + /// Implementation of IRenderDeviceD3D11::CreateTextureFromD3DResource() for 2D textures in Direct3D11 backend. + virtual void CreateTextureFromD3DResource(ID3D11Texture2D* pd3d11Texture, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; + + /// Implementation of IRenderDeviceD3D11::CreateTextureFromD3DResource() for 3D textures in Direct3D11 backend. + virtual void CreateTextureFromD3DResource(ID3D11Texture3D* pd3d11Texture, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; + + /// Implementation of IRenderDevice::ReleaseStaleResources() in Direct3D11 backend. + virtual void ReleaseStaleResources(bool ForceRelease = false) override final {} + + /// Implementation of IRenderDevice::IdleGPU() in Direct3D11 backend. + virtual void IdleGPU() override final; + + size_t GetCommandQueueCount() const { return 1; } + Uint64 GetCommandQueueMask() const { return Uint64{1}; } + +private: + virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) override final; + + EngineD3D11CreateInfo m_EngineAttribs; + + /// D3D11 device + CComPtr m_pd3d11Device; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h deleted file mode 100644 index 6d5d8936..00000000 --- a/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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::SamplerD3D11Impl class - -#include "SamplerD3D11.h" -#include "RenderDeviceD3D11.h" -#include "SamplerBase.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Sampler implementation in Direct3D11 backend. -class SamplerD3D11Impl final : public SamplerBase -{ -public: - using TSamplerBase = SamplerBase; - - SamplerD3D11Impl(IReferenceCounters* pRefCounters, - class RenderDeviceD3D11Impl* pRenderDeviceD3D11, - const SamplerDesc& SamplerDesc); - ~SamplerD3D11Impl(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of ISamplerD3D11::ISamplerD3D11() method. - virtual ID3D11SamplerState* GetD3D11SamplerState() override final { return m_pd3dSampler; } - -private: - /// D3D11 sampler - CComPtr m_pd3dSampler; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.hpp new file mode 100644 index 00000000..6ad866f0 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.hpp @@ -0,0 +1,64 @@ +/* + * 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::SamplerD3D11Impl class + +#include "SamplerD3D11.h" +#include "RenderDeviceD3D11.h" +#include "SamplerBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Sampler implementation in Direct3D11 backend. +class SamplerD3D11Impl final : public SamplerBase +{ +public: + using TSamplerBase = SamplerBase; + + SamplerD3D11Impl(IReferenceCounters* pRefCounters, + class RenderDeviceD3D11Impl* pRenderDeviceD3D11, + const SamplerDesc& SamplerDesc); + ~SamplerD3D11Impl(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of ISamplerD3D11::ISamplerD3D11() method. + virtual ID3D11SamplerState* GetD3D11SamplerState() override final { return m_pd3dSampler; } + +private: + /// D3D11 sampler + CComPtr m_pd3dSampler; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h deleted file mode 100644 index aaaae904..00000000 --- a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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::ShaderD3D11Impl class - -#include "ShaderD3D11.h" -#include "RenderDeviceD3D11.h" -#include "ShaderBase.h" -#include "ShaderD3DBase.h" -#include "ShaderResourceLayoutD3D11.h" -#include "ShaderResourceCacheD3D11.h" -#include "EngineD3D11Defines.h" -#include "ShaderResourcesD3D11.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; -class ResourceMapping; - -/// Shader implementation in Direct3D11 backend. -class ShaderD3D11Impl final : public ShaderBase, public ShaderD3DBase -{ -public: - using TShaderBase = ShaderBase; - - ShaderD3D11Impl(IReferenceCounters* pRefCounters, - class RenderDeviceD3D11Impl* pRenderDeviceD3D11, - const ShaderCreateInfo& ShaderCI); - ~ShaderD3D11Impl(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of IShader::GetResourceCount() in Direct3D11 backend. - virtual Uint32 GetResourceCount() const override final - { - return m_pShaderResources->GetTotalResources(); - } - - /// Implementation of IShader::GetResource() in Direct3D11 backend. - virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final - { - ResourceDesc = GetHLSLResource(Index); - } - - /// Implementation of IShaderD3D::GetHLSLResource() method. - virtual HLSLShaderResourceDesc GetHLSLResource(Uint32 Index) const override final - { - return m_pShaderResources->GetHLSLShaderResourceDesc(Index); - } - - /// Implementation of IShaderD3D11::GetD3D11Shader() method. - virtual ID3D11DeviceChild* GetD3D11Shader() override final - { - return m_pShader; - } - - ID3DBlob* GetBytecode() { return m_pShaderByteCode; } - - const std::shared_ptr& GetD3D11Resources() const { return m_pShaderResources; } - -private: - /// D3D11 shader - CComPtr m_pShader; - - // ShaderResources class instance must be referenced through the shared pointer, because - // it is referenced by ShaderResourceLayoutD3D11 class instances - std::shared_ptr m_pShaderResources; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.hpp new file mode 100644 index 00000000..214bedca --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.hpp @@ -0,0 +1,99 @@ +/* + * 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::ShaderD3D11Impl class + +#include "ShaderD3D11.h" +#include "RenderDeviceD3D11.h" +#include "ShaderBase.hpp" +#include "ShaderD3DBase.hpp" +#include "ShaderResourceLayoutD3D11.hpp" +#include "ShaderResourceCacheD3D11.hpp" +#include "EngineD3D11Defines.h" +#include "ShaderResourcesD3D11.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; +class ResourceMapping; + +/// Shader implementation in Direct3D11 backend. +class ShaderD3D11Impl final : public ShaderBase, public ShaderD3DBase +{ +public: + using TShaderBase = ShaderBase; + + ShaderD3D11Impl(IReferenceCounters* pRefCounters, + class RenderDeviceD3D11Impl* pRenderDeviceD3D11, + const ShaderCreateInfo& ShaderCI); + ~ShaderD3D11Impl(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of IShader::GetResourceCount() in Direct3D11 backend. + virtual Uint32 GetResourceCount() const override final + { + return m_pShaderResources->GetTotalResources(); + } + + /// Implementation of IShader::GetResource() in Direct3D11 backend. + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final + { + ResourceDesc = GetHLSLResource(Index); + } + + /// Implementation of IShaderD3D::GetHLSLResource() method. + virtual HLSLShaderResourceDesc GetHLSLResource(Uint32 Index) const override final + { + return m_pShaderResources->GetHLSLShaderResourceDesc(Index); + } + + /// Implementation of IShaderD3D11::GetD3D11Shader() method. + virtual ID3D11DeviceChild* GetD3D11Shader() override final + { + return m_pShader; + } + + ID3DBlob* GetBytecode() { return m_pShaderByteCode; } + + const std::shared_ptr& GetD3D11Resources() const { return m_pShaderResources; } + +private: + /// D3D11 shader + CComPtr m_pShader; + + // ShaderResources class instance must be referenced through the shared pointer, because + // it is referenced by ShaderResourceLayoutD3D11 class instances + std::shared_ptr m_pShaderResources; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.h deleted file mode 100755 index bc14042d..00000000 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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::ShaderResourceBindingD3D11Impl class - -#include "ShaderResourceBindingD3D11.h" -#include "RenderDeviceD3D11.h" -#include "ShaderResourceBindingBase.h" -#include "ShaderResourceCacheD3D11.h" -#include "ShaderResourceLayoutD3D11.h" -#include "STDAllocator.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Implementation of shader resource binding object in Direct3D11 backend. -class ShaderResourceBindingD3D11Impl final : public ShaderResourceBindingBase -{ -public: - using TBase = ShaderResourceBindingBase; - - ShaderResourceBindingD3D11Impl(IReferenceCounters* pRefCounters, - class PipelineStateD3D11Impl* pPSO, - bool IsInternal); - ~ShaderResourceBindingD3D11Impl(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of IShaderResourceBinding::BindResources() in Direct3D11 backend. - virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) override final; - - /// Implementation of IShaderResourceBinding::GetVariableByName() in Direct3D11 backend. - virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name) override final; - - /// Implementation of IShaderResourceBinding::GetVariableCount() in Direct3D11 backend. - virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const override final; - - /// Implementation of IShaderResourceBinding::GetVariableByIndex() in Direct3D11 backend. - virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final; - - /// Implementation of IShaderResourceBinding::InitializeStaticResources() in Direct3D11 backend. - virtual void InitializeStaticResources(const IPipelineState* pPipelineState) override final; - - ShaderResourceCacheD3D11& GetResourceCache(Uint32 Ind) - { - VERIFY_EXPR(Ind < m_NumActiveShaders); - return m_pBoundResourceCaches[Ind]; - } - - ShaderResourceLayoutD3D11& GetResourceLayout(Uint32 Ind) - { - VERIFY_EXPR(Ind < m_NumActiveShaders); - return m_pResourceLayouts[Ind]; - } - - inline bool IsStaticResourcesBound() { return m_bIsStaticResourcesBound; } - - Uint32 GetNumActiveShaders() - { - return static_cast(m_NumActiveShaders); - } - - Int32 GetActiveShaderTypeIndex(Uint32 s) { return m_ShaderTypeIndex[s]; } - -private: - // The caches are indexed by the shader order in the PSO, not shader index - ShaderResourceCacheD3D11* m_pBoundResourceCaches = nullptr; - ShaderResourceLayoutD3D11* m_pResourceLayouts = nullptr; - - Int8 m_ShaderTypeIndex[6] = {}; - - // Resource layout index in m_ResourceLayouts[] array for every shader stage - Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1}; - Uint8 m_NumActiveShaders = 0; - - bool m_bIsStaticResourcesBound = false; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp new file mode 100644 index 00000000..55a6ca2d --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp @@ -0,0 +1,108 @@ +/* + * 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::ShaderResourceBindingD3D11Impl class + +#include "ShaderResourceBindingD3D11.h" +#include "RenderDeviceD3D11.h" +#include "ShaderResourceBindingBase.hpp" +#include "ShaderResourceCacheD3D11.hpp" +#include "ShaderResourceLayoutD3D11.hpp" +#include "STDAllocator.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of shader resource binding object in Direct3D11 backend. +class ShaderResourceBindingD3D11Impl final : public ShaderResourceBindingBase +{ +public: + using TBase = ShaderResourceBindingBase; + + ShaderResourceBindingD3D11Impl(IReferenceCounters* pRefCounters, + class PipelineStateD3D11Impl* pPSO, + bool IsInternal); + ~ShaderResourceBindingD3D11Impl(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of IShaderResourceBinding::BindResources() in Direct3D11 backend. + virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) override final; + + /// Implementation of IShaderResourceBinding::GetVariableByName() in Direct3D11 backend. + virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name) override final; + + /// Implementation of IShaderResourceBinding::GetVariableCount() in Direct3D11 backend. + virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const override final; + + /// Implementation of IShaderResourceBinding::GetVariableByIndex() in Direct3D11 backend. + virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final; + + /// Implementation of IShaderResourceBinding::InitializeStaticResources() in Direct3D11 backend. + virtual void InitializeStaticResources(const IPipelineState* pPipelineState) override final; + + ShaderResourceCacheD3D11& GetResourceCache(Uint32 Ind) + { + VERIFY_EXPR(Ind < m_NumActiveShaders); + return m_pBoundResourceCaches[Ind]; + } + + ShaderResourceLayoutD3D11& GetResourceLayout(Uint32 Ind) + { + VERIFY_EXPR(Ind < m_NumActiveShaders); + return m_pResourceLayouts[Ind]; + } + + inline bool IsStaticResourcesBound() { return m_bIsStaticResourcesBound; } + + Uint32 GetNumActiveShaders() + { + return static_cast(m_NumActiveShaders); + } + + Int32 GetActiveShaderTypeIndex(Uint32 s) { return m_ShaderTypeIndex[s]; } + +private: + // The caches are indexed by the shader order in the PSO, not shader index + ShaderResourceCacheD3D11* m_pBoundResourceCaches = nullptr; + ShaderResourceLayoutD3D11* m_pResourceLayouts = nullptr; + + Int8 m_ShaderTypeIndex[6] = {}; + + // Resource layout index in m_ResourceLayouts[] array for every shader stage + Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1}; + Uint8 m_NumActiveShaders = 0; + + bool m_bIsStaticResourcesBound = false; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h deleted file mode 100755 index 2623b5c3..00000000 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h +++ /dev/null @@ -1,334 +0,0 @@ -/* - * 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::ShaderResourceCacheD3D11 class - -#include "TextureBaseD3D11.h" -#include "BufferD3D11Impl.h" -#include "SamplerD3D11Impl.h" - -namespace Diligent -{ - -/// The class implements a cache that holds resources bound to a specific shader stage -// All resources are stored in the continuous memory using the following layout: -// -// | CachedCB | ID3D11Buffer* || CachedResource | ID3D11ShaderResourceView* || CachedSampler | ID3D11SamplerState* || CachedResource | ID3D11UnorderedAccessView*|| -// |---------------------------------------------------||--------------------------|---------------------------||------------------------------|-----------------------------||-------------------------|---------------------------|| -// | 0 | 1 | ... | CBCount-1 | 0 | 1 | ...| CBCount-1 || 0 | 1 | ... | SRVCount-1 | 0 | 1 | ... | SRVCount-1 || 0 | 1 | ... | SamplerCount-1 | 0 | 1 | ...| SamplerCount-1 ||0 | 1 | ... | UAVCount-1 | 0 | 1 | ... | UAVCount-1 || -// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// -// http://diligentgraphics.com/diligent-engine/architecture/d3d11/shader-resource-cache/ -class ShaderResourceCacheD3D11 -{ -public: - ShaderResourceCacheD3D11() - {} - - ~ShaderResourceCacheD3D11(); - - // clang-format off - ShaderResourceCacheD3D11 (const ShaderResourceCacheD3D11&) = delete; - ShaderResourceCacheD3D11& operator = (const ShaderResourceCacheD3D11&) = delete; - ShaderResourceCacheD3D11 (ShaderResourceCacheD3D11&&) = delete; - ShaderResourceCacheD3D11& operator = (ShaderResourceCacheD3D11&&) = delete; - // clang-format on - - /// Describes a resource associated with a cached constant buffer - struct CachedCB - { - /// Strong reference to the buffer - RefCntAutoPtr pBuff; - - __forceinline void Set(RefCntAutoPtr&& _pBuff) - { - pBuff = std::move(_pBuff); - } - }; - - /// Describes a resource associated with a cached sampler - struct CachedSampler - { - /// Strong reference to the sampler - RefCntAutoPtr pSampler; - - __forceinline void Set(SamplerD3D11Impl* pSam) - { - pSampler = pSam; - } - }; - - /// Describes a resource associated with a cached SRV or a UAV - struct CachedResource - { - /// Wee keep strong reference to the view instead of the reference - /// to the texture or buffer because this is more efficient from - /// performance point of view: this avoids one pair of - /// AddStrongRef()/ReleaseStrongRef(). The view holds strong reference - /// to the texture or the buffer, so it makes no difference. - RefCntAutoPtr pView; - - TextureBaseD3D11* pTexture = nullptr; - BufferD3D11Impl* pBuffer = nullptr; - - // There is no need to keep strong reference to D3D11 resource as - // it is already kept by either pTexture or pBuffer - ID3D11Resource* pd3d11Resource = nullptr; - - CachedResource() noexcept {} - - __forceinline void Set(RefCntAutoPtr&& pTexView) - { - pBuffer = nullptr; - // Avoid unnecessary virtual function calls - pTexture = pTexView ? ValidatedCast(pTexView->TextureViewD3D11Impl::GetTexture()) : nullptr; - pView.Attach(pTexView.Detach()); - pd3d11Resource = pTexture ? pTexture->TextureBaseD3D11::GetD3D11Texture() : nullptr; - } - - __forceinline void Set(RefCntAutoPtr&& pBufView) - { - pTexture = nullptr; - // Avoid unnecessary virtual function calls - pBuffer = pBufView ? ValidatedCast(pBufView->BufferViewD3D11Impl::GetBuffer()) : nullptr; - pView.Attach(pBufView.Detach()); - pd3d11Resource = pBuffer ? pBuffer->BufferD3D11Impl::GetD3D11Buffer() : nullptr; - } - }; - - static size_t GetRequriedMemorySize(const class ShaderResourcesD3D11& Resources); - - void Initialize(const class ShaderResourcesD3D11& Resources, class IMemoryAllocator& MemAllocator); - void Initialize(Uint32 CBCount, Uint32 SRVCount, Uint32 SamplerCount, Uint32 UAVCount, class IMemoryAllocator& MemAllocator); - void Destroy(class IMemoryAllocator& MemAllocator); - - - __forceinline void SetCB(Uint32 Slot, RefCntAutoPtr&& pBuffD3D11Impl) - { - auto* pd3d11Buff = pBuffD3D11Impl ? pBuffD3D11Impl->BufferD3D11Impl::GetD3D11Buffer() : nullptr; - SetD3D11ResourceInternal(Slot, GetCBCount(), &ShaderResourceCacheD3D11::GetCBArrays, std::move(pBuffD3D11Impl), pd3d11Buff); - } - - __forceinline void SetTexSRV(Uint32 Slot, RefCntAutoPtr&& pTexView) - { - auto* pd3d11SRV = pTexView ? static_cast(pTexView->TextureViewD3D11Impl::GetD3D11View()) : nullptr; - SetD3D11ResourceInternal(Slot, GetSRVCount(), &ShaderResourceCacheD3D11::GetSRVArrays, std::move(pTexView), pd3d11SRV); - } - - __forceinline void SetBufSRV(Uint32 Slot, RefCntAutoPtr&& pBuffView) - { - auto* pd3d11SRV = pBuffView ? static_cast(pBuffView->BufferViewD3D11Impl::GetD3D11View()) : nullptr; - SetD3D11ResourceInternal(Slot, GetSRVCount(), &ShaderResourceCacheD3D11::GetSRVArrays, std::move(pBuffView), pd3d11SRV); - } - - __forceinline void SetTexUAV(Uint32 Slot, RefCntAutoPtr&& pTexView) - { - auto* pd3d11UAV = pTexView ? static_cast(pTexView->TextureViewD3D11Impl::GetD3D11View()) : nullptr; - SetD3D11ResourceInternal(Slot, GetUAVCount(), &ShaderResourceCacheD3D11::GetUAVArrays, std::move(pTexView), pd3d11UAV); - } - - __forceinline void SetBufUAV(Uint32 Slot, RefCntAutoPtr&& pBuffView) - { - auto* pd3d11UAV = pBuffView ? static_cast(pBuffView->BufferViewD3D11Impl::GetD3D11View()) : nullptr; - SetD3D11ResourceInternal(Slot, GetUAVCount(), &ShaderResourceCacheD3D11::GetUAVArrays, std::move(pBuffView), pd3d11UAV); - } - - __forceinline void SetSampler(Uint32 Slot, SamplerD3D11Impl* pSampler) - { - auto* pd3d11Sampler = pSampler ? pSampler->SamplerD3D11Impl::GetD3D11SamplerState() : nullptr; - SetD3D11ResourceInternal(Slot, GetSamplerCount(), &ShaderResourceCacheD3D11::GetSamplerArrays, pSampler, pd3d11Sampler); - } - - - - __forceinline CachedCB& GetCB(Uint32 Slot) - { - VERIFY(Slot < GetCBCount(), "CB slot is out of range"); - ShaderResourceCacheD3D11::CachedCB* CBs; - ID3D11Buffer** pd3d11CBs; - GetCBArrays(CBs, pd3d11CBs); - return CBs[Slot]; - } - - __forceinline CachedResource& GetSRV(Uint32 Slot) - { - VERIFY(Slot < GetSRVCount(), "SRV slot is out of range"); - ShaderResourceCacheD3D11::CachedResource* SRVResources; - ID3D11ShaderResourceView** pd3d11SRVs; - GetSRVArrays(SRVResources, pd3d11SRVs); - return SRVResources[Slot]; - } - - __forceinline CachedResource& GetUAV(Uint32 Slot) - { - VERIFY(Slot < GetUAVCount(), "UAV slot is out of range"); - ShaderResourceCacheD3D11::CachedResource* UAVResources; - ID3D11UnorderedAccessView** pd3d11UAVs; - GetUAVArrays(UAVResources, pd3d11UAVs); - return UAVResources[Slot]; - } - - __forceinline CachedSampler& GetSampler(Uint32 Slot) - { - VERIFY(Slot < GetSamplerCount(), "Sampler slot is out of range"); - ShaderResourceCacheD3D11::CachedSampler* Samplers; - ID3D11SamplerState** pd3d11Samplers; - GetSamplerArrays(Samplers, pd3d11Samplers); - return Samplers[Slot]; - } - - - __forceinline bool IsCBBound(Uint32 Slot) const - { - CachedCB* CBs = nullptr; - ID3D11Buffer** d3d11CBs = nullptr; - const_cast(this)->GetCBArrays(CBs, d3d11CBs); - if (Slot < GetCBCount() && d3d11CBs[Slot] != nullptr) - { - VERIFY(CBs[Slot].pBuff != nullptr, "No relevant buffer resource"); - return true; - } - return false; - } - - __forceinline bool IsSRVBound(Uint32 Slot, bool dbgIsTextureView) const - { - CachedResource* SRVResources = nullptr; - ID3D11ShaderResourceView** d3d11SRVs = nullptr; - const_cast(this)->GetSRVArrays(SRVResources, d3d11SRVs); - if (Slot < GetSRVCount() && d3d11SRVs[Slot] != nullptr) - { - VERIFY((dbgIsTextureView && SRVResources[Slot].pTexture != nullptr) || (!dbgIsTextureView && SRVResources[Slot].pBuffer != nullptr), - "No relevant resource"); - return true; - } - return false; - } - - __forceinline bool IsUAVBound(Uint32 Slot, bool dbgIsTextureView) const - { - CachedResource* UAVResources = nullptr; - ID3D11UnorderedAccessView** d3d11UAVs = nullptr; - const_cast(this)->GetUAVArrays(UAVResources, d3d11UAVs); - if (Slot < GetUAVCount() && d3d11UAVs[Slot] != nullptr) - { - VERIFY((dbgIsTextureView && UAVResources[Slot].pTexture != nullptr) || (!dbgIsTextureView && UAVResources[Slot].pBuffer != nullptr), - "No relevant resource"); - return true; - } - return false; - } - - __forceinline bool IsSamplerBound(Uint32 Slot) const - { - CachedSampler* Samplers = nullptr; - ID3D11SamplerState** d3d11Samplers = nullptr; - const_cast(this)->GetSamplerArrays(Samplers, d3d11Samplers); - if (Slot < GetSamplerCount() && d3d11Samplers[Slot] != nullptr) - { - VERIFY(Samplers[Slot].pSampler != nullptr, "No relevant sampler"); - return true; - } - return false; - } - - void dbgVerifyCacheConsistency(); - - // clang-format off - __forceinline Uint32 GetCBCount() const { return (m_SRVOffset - m_CBOffset) / (sizeof(CachedCB) + sizeof(ID3D11Buffer*)); } - __forceinline Uint32 GetSRVCount() const { return (m_SamplerOffset - m_SRVOffset) / (sizeof(CachedResource) + sizeof(ID3D11ShaderResourceView*)); } - __forceinline Uint32 GetSamplerCount() const { return (m_UAVOffset - m_SamplerOffset) / (sizeof(CachedSampler) + sizeof(ID3D11SamplerState*)); } - __forceinline Uint32 GetUAVCount() const { return (m_MemoryEndOffset - m_UAVOffset) / (sizeof(CachedResource) + sizeof(ID3D11UnorderedAccessView*)); } - // clang-format on - - __forceinline void GetCBArrays(CachedCB*& CBs, ID3D11Buffer**& pd3d11CBs) - { - CBs = reinterpret_cast(m_pResourceData + m_CBOffset); - pd3d11CBs = reinterpret_cast(CBs + GetCBCount()); - } - - __forceinline void GetSRVArrays(CachedResource*& SRVResources, ID3D11ShaderResourceView**& d3d11SRVs) - { - SRVResources = reinterpret_cast(m_pResourceData + m_SRVOffset); - d3d11SRVs = reinterpret_cast(SRVResources + GetSRVCount()); - } - - __forceinline void GetSamplerArrays(CachedSampler*& Samplers, ID3D11SamplerState**& pd3d11Samplers) - { - Samplers = reinterpret_cast(m_pResourceData + m_SamplerOffset); - pd3d11Samplers = reinterpret_cast(Samplers + GetSamplerCount()); - } - - __forceinline void GetUAVArrays(CachedResource*& UAVResources, ID3D11UnorderedAccessView**& pd3d11UAVs) - { - UAVResources = reinterpret_cast(m_pResourceData + m_UAVOffset); - pd3d11UAVs = reinterpret_cast(UAVResources + GetUAVCount()); - } - - __forceinline bool IsInitialized() const - { - return m_MemoryEndOffset != InvalidResourceOffset; - } - -private: - template - __forceinline void SetD3D11ResourceInternal(Uint32 Slot, Uint32 Size, TGetResourceArraysFunc GetArrays, TSrcResourceType&& pResource, TD3D11ResourceType* pd3d11Resource) - { - VERIFY(Slot < Size, "Resource cache is not big enough"); - VERIFY(pResource != nullptr && pd3d11Resource != nullptr || pResource == nullptr && pd3d11Resource == nullptr, - "Resource and D3D11 resource must be set/unset atomically"); - TCachedResourceType* Resources; - TD3D11ResourceType** d3d11ResArr; - (this->*GetArrays)(Resources, d3d11ResArr); - Resources[Slot].Set(std::forward(pResource)); - d3d11ResArr[Slot] = pd3d11Resource; - } - - static constexpr const Uint16 InvalidResourceOffset = 0xFFFF; - // Resource limits in D3D11: - // Max CB count: 14 - // Max SRV count: 128 - // Max Sampler count: 16 - // Max UAV count: 8 - static constexpr const Uint16 m_CBOffset = 0; - Uint16 m_SRVOffset = InvalidResourceOffset; - Uint16 m_SamplerOffset = InvalidResourceOffset; - Uint16 m_UAVOffset = InvalidResourceOffset; - Uint16 m_MemoryEndOffset = InvalidResourceOffset; - - Uint8* m_pResourceData = nullptr; - -#ifdef _DEBUG - IMemoryAllocator* m_pdbgMemoryAllocator = nullptr; -#endif -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp new file mode 100644 index 00000000..ef18f9f0 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp @@ -0,0 +1,334 @@ +/* + * 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::ShaderResourceCacheD3D11 class + +#include "TextureBaseD3D11.hpp" +#include "BufferD3D11Impl.hpp" +#include "SamplerD3D11Impl.hpp" + +namespace Diligent +{ + +/// The class implements a cache that holds resources bound to a specific shader stage +// All resources are stored in the continuous memory using the following layout: +// +// | CachedCB | ID3D11Buffer* || CachedResource | ID3D11ShaderResourceView* || CachedSampler | ID3D11SamplerState* || CachedResource | ID3D11UnorderedAccessView*|| +// |---------------------------------------------------||--------------------------|---------------------------||------------------------------|-----------------------------||-------------------------|---------------------------|| +// | 0 | 1 | ... | CBCount-1 | 0 | 1 | ...| CBCount-1 || 0 | 1 | ... | SRVCount-1 | 0 | 1 | ... | SRVCount-1 || 0 | 1 | ... | SamplerCount-1 | 0 | 1 | ...| SamplerCount-1 ||0 | 1 | ... | UAVCount-1 | 0 | 1 | ... | UAVCount-1 || +// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// +// http://diligentgraphics.com/diligent-engine/architecture/d3d11/shader-resource-cache/ +class ShaderResourceCacheD3D11 +{ +public: + ShaderResourceCacheD3D11() + {} + + ~ShaderResourceCacheD3D11(); + + // clang-format off + ShaderResourceCacheD3D11 (const ShaderResourceCacheD3D11&) = delete; + ShaderResourceCacheD3D11& operator = (const ShaderResourceCacheD3D11&) = delete; + ShaderResourceCacheD3D11 (ShaderResourceCacheD3D11&&) = delete; + ShaderResourceCacheD3D11& operator = (ShaderResourceCacheD3D11&&) = delete; + // clang-format on + + /// Describes a resource associated with a cached constant buffer + struct CachedCB + { + /// Strong reference to the buffer + RefCntAutoPtr pBuff; + + __forceinline void Set(RefCntAutoPtr&& _pBuff) + { + pBuff = std::move(_pBuff); + } + }; + + /// Describes a resource associated with a cached sampler + struct CachedSampler + { + /// Strong reference to the sampler + RefCntAutoPtr pSampler; + + __forceinline void Set(SamplerD3D11Impl* pSam) + { + pSampler = pSam; + } + }; + + /// Describes a resource associated with a cached SRV or a UAV + struct CachedResource + { + /// Wee keep strong reference to the view instead of the reference + /// to the texture or buffer because this is more efficient from + /// performance point of view: this avoids one pair of + /// AddStrongRef()/ReleaseStrongRef(). The view holds strong reference + /// to the texture or the buffer, so it makes no difference. + RefCntAutoPtr pView; + + TextureBaseD3D11* pTexture = nullptr; + BufferD3D11Impl* pBuffer = nullptr; + + // There is no need to keep strong reference to D3D11 resource as + // it is already kept by either pTexture or pBuffer + ID3D11Resource* pd3d11Resource = nullptr; + + CachedResource() noexcept {} + + __forceinline void Set(RefCntAutoPtr&& pTexView) + { + pBuffer = nullptr; + // Avoid unnecessary virtual function calls + pTexture = pTexView ? ValidatedCast(pTexView->TextureViewD3D11Impl::GetTexture()) : nullptr; + pView.Attach(pTexView.Detach()); + pd3d11Resource = pTexture ? pTexture->TextureBaseD3D11::GetD3D11Texture() : nullptr; + } + + __forceinline void Set(RefCntAutoPtr&& pBufView) + { + pTexture = nullptr; + // Avoid unnecessary virtual function calls + pBuffer = pBufView ? ValidatedCast(pBufView->BufferViewD3D11Impl::GetBuffer()) : nullptr; + pView.Attach(pBufView.Detach()); + pd3d11Resource = pBuffer ? pBuffer->BufferD3D11Impl::GetD3D11Buffer() : nullptr; + } + }; + + static size_t GetRequriedMemorySize(const class ShaderResourcesD3D11& Resources); + + void Initialize(const class ShaderResourcesD3D11& Resources, class IMemoryAllocator& MemAllocator); + void Initialize(Uint32 CBCount, Uint32 SRVCount, Uint32 SamplerCount, Uint32 UAVCount, class IMemoryAllocator& MemAllocator); + void Destroy(class IMemoryAllocator& MemAllocator); + + + __forceinline void SetCB(Uint32 Slot, RefCntAutoPtr&& pBuffD3D11Impl) + { + auto* pd3d11Buff = pBuffD3D11Impl ? pBuffD3D11Impl->BufferD3D11Impl::GetD3D11Buffer() : nullptr; + SetD3D11ResourceInternal(Slot, GetCBCount(), &ShaderResourceCacheD3D11::GetCBArrays, std::move(pBuffD3D11Impl), pd3d11Buff); + } + + __forceinline void SetTexSRV(Uint32 Slot, RefCntAutoPtr&& pTexView) + { + auto* pd3d11SRV = pTexView ? static_cast(pTexView->TextureViewD3D11Impl::GetD3D11View()) : nullptr; + SetD3D11ResourceInternal(Slot, GetSRVCount(), &ShaderResourceCacheD3D11::GetSRVArrays, std::move(pTexView), pd3d11SRV); + } + + __forceinline void SetBufSRV(Uint32 Slot, RefCntAutoPtr&& pBuffView) + { + auto* pd3d11SRV = pBuffView ? static_cast(pBuffView->BufferViewD3D11Impl::GetD3D11View()) : nullptr; + SetD3D11ResourceInternal(Slot, GetSRVCount(), &ShaderResourceCacheD3D11::GetSRVArrays, std::move(pBuffView), pd3d11SRV); + } + + __forceinline void SetTexUAV(Uint32 Slot, RefCntAutoPtr&& pTexView) + { + auto* pd3d11UAV = pTexView ? static_cast(pTexView->TextureViewD3D11Impl::GetD3D11View()) : nullptr; + SetD3D11ResourceInternal(Slot, GetUAVCount(), &ShaderResourceCacheD3D11::GetUAVArrays, std::move(pTexView), pd3d11UAV); + } + + __forceinline void SetBufUAV(Uint32 Slot, RefCntAutoPtr&& pBuffView) + { + auto* pd3d11UAV = pBuffView ? static_cast(pBuffView->BufferViewD3D11Impl::GetD3D11View()) : nullptr; + SetD3D11ResourceInternal(Slot, GetUAVCount(), &ShaderResourceCacheD3D11::GetUAVArrays, std::move(pBuffView), pd3d11UAV); + } + + __forceinline void SetSampler(Uint32 Slot, SamplerD3D11Impl* pSampler) + { + auto* pd3d11Sampler = pSampler ? pSampler->SamplerD3D11Impl::GetD3D11SamplerState() : nullptr; + SetD3D11ResourceInternal(Slot, GetSamplerCount(), &ShaderResourceCacheD3D11::GetSamplerArrays, pSampler, pd3d11Sampler); + } + + + + __forceinline CachedCB& GetCB(Uint32 Slot) + { + VERIFY(Slot < GetCBCount(), "CB slot is out of range"); + ShaderResourceCacheD3D11::CachedCB* CBs; + ID3D11Buffer** pd3d11CBs; + GetCBArrays(CBs, pd3d11CBs); + return CBs[Slot]; + } + + __forceinline CachedResource& GetSRV(Uint32 Slot) + { + VERIFY(Slot < GetSRVCount(), "SRV slot is out of range"); + ShaderResourceCacheD3D11::CachedResource* SRVResources; + ID3D11ShaderResourceView** pd3d11SRVs; + GetSRVArrays(SRVResources, pd3d11SRVs); + return SRVResources[Slot]; + } + + __forceinline CachedResource& GetUAV(Uint32 Slot) + { + VERIFY(Slot < GetUAVCount(), "UAV slot is out of range"); + ShaderResourceCacheD3D11::CachedResource* UAVResources; + ID3D11UnorderedAccessView** pd3d11UAVs; + GetUAVArrays(UAVResources, pd3d11UAVs); + return UAVResources[Slot]; + } + + __forceinline CachedSampler& GetSampler(Uint32 Slot) + { + VERIFY(Slot < GetSamplerCount(), "Sampler slot is out of range"); + ShaderResourceCacheD3D11::CachedSampler* Samplers; + ID3D11SamplerState** pd3d11Samplers; + GetSamplerArrays(Samplers, pd3d11Samplers); + return Samplers[Slot]; + } + + + __forceinline bool IsCBBound(Uint32 Slot) const + { + CachedCB* CBs = nullptr; + ID3D11Buffer** d3d11CBs = nullptr; + const_cast(this)->GetCBArrays(CBs, d3d11CBs); + if (Slot < GetCBCount() && d3d11CBs[Slot] != nullptr) + { + VERIFY(CBs[Slot].pBuff != nullptr, "No relevant buffer resource"); + return true; + } + return false; + } + + __forceinline bool IsSRVBound(Uint32 Slot, bool dbgIsTextureView) const + { + CachedResource* SRVResources = nullptr; + ID3D11ShaderResourceView** d3d11SRVs = nullptr; + const_cast(this)->GetSRVArrays(SRVResources, d3d11SRVs); + if (Slot < GetSRVCount() && d3d11SRVs[Slot] != nullptr) + { + VERIFY((dbgIsTextureView && SRVResources[Slot].pTexture != nullptr) || (!dbgIsTextureView && SRVResources[Slot].pBuffer != nullptr), + "No relevant resource"); + return true; + } + return false; + } + + __forceinline bool IsUAVBound(Uint32 Slot, bool dbgIsTextureView) const + { + CachedResource* UAVResources = nullptr; + ID3D11UnorderedAccessView** d3d11UAVs = nullptr; + const_cast(this)->GetUAVArrays(UAVResources, d3d11UAVs); + if (Slot < GetUAVCount() && d3d11UAVs[Slot] != nullptr) + { + VERIFY((dbgIsTextureView && UAVResources[Slot].pTexture != nullptr) || (!dbgIsTextureView && UAVResources[Slot].pBuffer != nullptr), + "No relevant resource"); + return true; + } + return false; + } + + __forceinline bool IsSamplerBound(Uint32 Slot) const + { + CachedSampler* Samplers = nullptr; + ID3D11SamplerState** d3d11Samplers = nullptr; + const_cast(this)->GetSamplerArrays(Samplers, d3d11Samplers); + if (Slot < GetSamplerCount() && d3d11Samplers[Slot] != nullptr) + { + VERIFY(Samplers[Slot].pSampler != nullptr, "No relevant sampler"); + return true; + } + return false; + } + + void dbgVerifyCacheConsistency(); + + // clang-format off + __forceinline Uint32 GetCBCount() const { return (m_SRVOffset - m_CBOffset) / (sizeof(CachedCB) + sizeof(ID3D11Buffer*)); } + __forceinline Uint32 GetSRVCount() const { return (m_SamplerOffset - m_SRVOffset) / (sizeof(CachedResource) + sizeof(ID3D11ShaderResourceView*)); } + __forceinline Uint32 GetSamplerCount() const { return (m_UAVOffset - m_SamplerOffset) / (sizeof(CachedSampler) + sizeof(ID3D11SamplerState*)); } + __forceinline Uint32 GetUAVCount() const { return (m_MemoryEndOffset - m_UAVOffset) / (sizeof(CachedResource) + sizeof(ID3D11UnorderedAccessView*)); } + // clang-format on + + __forceinline void GetCBArrays(CachedCB*& CBs, ID3D11Buffer**& pd3d11CBs) + { + CBs = reinterpret_cast(m_pResourceData + m_CBOffset); + pd3d11CBs = reinterpret_cast(CBs + GetCBCount()); + } + + __forceinline void GetSRVArrays(CachedResource*& SRVResources, ID3D11ShaderResourceView**& d3d11SRVs) + { + SRVResources = reinterpret_cast(m_pResourceData + m_SRVOffset); + d3d11SRVs = reinterpret_cast(SRVResources + GetSRVCount()); + } + + __forceinline void GetSamplerArrays(CachedSampler*& Samplers, ID3D11SamplerState**& pd3d11Samplers) + { + Samplers = reinterpret_cast(m_pResourceData + m_SamplerOffset); + pd3d11Samplers = reinterpret_cast(Samplers + GetSamplerCount()); + } + + __forceinline void GetUAVArrays(CachedResource*& UAVResources, ID3D11UnorderedAccessView**& pd3d11UAVs) + { + UAVResources = reinterpret_cast(m_pResourceData + m_UAVOffset); + pd3d11UAVs = reinterpret_cast(UAVResources + GetUAVCount()); + } + + __forceinline bool IsInitialized() const + { + return m_MemoryEndOffset != InvalidResourceOffset; + } + +private: + template + __forceinline void SetD3D11ResourceInternal(Uint32 Slot, Uint32 Size, TGetResourceArraysFunc GetArrays, TSrcResourceType&& pResource, TD3D11ResourceType* pd3d11Resource) + { + VERIFY(Slot < Size, "Resource cache is not big enough"); + VERIFY(pResource != nullptr && pd3d11Resource != nullptr || pResource == nullptr && pd3d11Resource == nullptr, + "Resource and D3D11 resource must be set/unset atomically"); + TCachedResourceType* Resources; + TD3D11ResourceType** d3d11ResArr; + (this->*GetArrays)(Resources, d3d11ResArr); + Resources[Slot].Set(std::forward(pResource)); + d3d11ResArr[Slot] = pd3d11Resource; + } + + static constexpr const Uint16 InvalidResourceOffset = 0xFFFF; + // Resource limits in D3D11: + // Max CB count: 14 + // Max SRV count: 128 + // Max Sampler count: 16 + // Max UAV count: 8 + static constexpr const Uint16 m_CBOffset = 0; + Uint16 m_SRVOffset = InvalidResourceOffset; + Uint16 m_SamplerOffset = InvalidResourceOffset; + Uint16 m_UAVOffset = InvalidResourceOffset; + Uint16 m_MemoryEndOffset = InvalidResourceOffset; + + Uint8* m_pResourceData = nullptr; + +#ifdef _DEBUG + IMemoryAllocator* m_pdbgMemoryAllocator = nullptr; +#endif +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h deleted file mode 100644 index 3c42624e..00000000 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h +++ /dev/null @@ -1,415 +0,0 @@ -/* - * 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::ShaderResourceLayoutD3D11 class - -#include "ShaderResources.h" -#include "ShaderBase.h" -#include "ShaderResourceCacheD3D11.h" -#include "EngineD3D11Defines.h" -#include "STDAllocator.h" -#include "ShaderVariableD3DBase.h" -#include "ShaderResourcesD3D11.h" - -namespace Diligent -{ - -class IMemoryAllocator; - -/// Diligent::ShaderResourceLayoutD3D11 class -/// http://diligentgraphics.com/diligent-engine/architecture/d3d11/shader-resource-layout/ -// sizeof(ShaderResourceLayoutD3D11) == 64 (x64) -class ShaderResourceLayoutD3D11 -{ -public: - ShaderResourceLayoutD3D11(IObject& Owner, - std::shared_ptr pSrcResources, - const PipelineResourceLayoutDesc& ResourceLayout, - const SHADER_RESOURCE_VARIABLE_TYPE* VarTypes, - Uint32 NumVarTypes, - ShaderResourceCacheD3D11& ResourceCache, - IMemoryAllocator& ResCacheDataAllocator, - IMemoryAllocator& ResLayoutDataAllocator); - ~ShaderResourceLayoutD3D11(); - - // clang-format off - // No copies, only moves are allowed - ShaderResourceLayoutD3D11 (const ShaderResourceLayoutD3D11&) = delete; - ShaderResourceLayoutD3D11& operator = (const ShaderResourceLayoutD3D11&) = delete; - ShaderResourceLayoutD3D11 ( ShaderResourceLayoutD3D11&&) = default; - ShaderResourceLayoutD3D11& operator = ( ShaderResourceLayoutD3D11&&) = delete; - // clang-format on - - static size_t GetRequiredMemorySize(const ShaderResourcesD3D11& SrcResources, - const PipelineResourceLayoutDesc& ResourceLayout, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes); - - void CopyResources(ShaderResourceCacheD3D11& DstCache) const; - - using ShaderVariableD3D11Base = ShaderVariableD3DBase; - - struct ConstBuffBindInfo final : ShaderVariableD3D11Base - { - ConstBuffBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, - ShaderResourceLayoutD3D11& ParentResLayout, - SHADER_RESOURCE_VARIABLE_TYPE VariableType) : - ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} - {} - // Non-virtual function - __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } - - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final - { - VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); - for (Uint32 elem = 0; elem < NumElements; ++elem) - BindResource(ppObjects[elem], FirstElement + elem); - } - - virtual bool IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsCBBound(m_Attribs.BindPoint + ArrayIndex); - } - }; - - struct TexSRVBindInfo final : ShaderVariableD3D11Base - { - TexSRVBindInfo(const D3DShaderResourceAttribs& _TextureAttribs, - Uint32 _SamplerIndex, - ShaderResourceLayoutD3D11& ParentResLayout, - SHADER_RESOURCE_VARIABLE_TYPE VariableType) : - ShaderVariableD3D11Base{ParentResLayout, _TextureAttribs, VariableType}, - SamplerIndex{_SamplerIndex} - {} - - // Non-virtual function - __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } - - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final - { - VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); - for (Uint32 elem = 0; elem < NumElements; ++elem) - BindResource(ppObjects[elem], FirstElement + elem); - } - - virtual bool IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, true); - } - - - bool ValidSamplerAssigned() const { return SamplerIndex != InvalidSamplerIndex; } - - static constexpr Uint32 InvalidSamplerIndex = static_cast(-1); - const Uint32 SamplerIndex; - }; - - struct TexUAVBindInfo final : ShaderVariableD3D11Base - { - TexUAVBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, - ShaderResourceLayoutD3D11& ParentResLayout, - SHADER_RESOURCE_VARIABLE_TYPE VariableType) : - ShaderVariableD3D11Base(ParentResLayout, ResourceAttribs, VariableType) - {} - - // Provide non-virtual function - __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } - - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final - { - VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); - for (Uint32 elem = 0; elem < NumElements; ++elem) - BindResource(ppObjects[elem], FirstElement + elem); - } - - __forceinline virtual bool IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, true); - } - }; - - struct BuffUAVBindInfo final : ShaderVariableD3D11Base - { - BuffUAVBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, - ShaderResourceLayoutD3D11& ParentResLayout, - SHADER_RESOURCE_VARIABLE_TYPE VariableType) : - ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} - {} - - // Non-virtual function - __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } - - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final - { - VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); - for (Uint32 elem = 0; elem < NumElements; ++elem) - BindResource(ppObjects[elem], FirstElement + elem); - } - - virtual bool IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, false); - } - }; - - struct BuffSRVBindInfo final : ShaderVariableD3D11Base - { - BuffSRVBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, - ShaderResourceLayoutD3D11& ParentResLayout, - SHADER_RESOURCE_VARIABLE_TYPE VariableType) : - ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} - {} - - // Non-virtual function - __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } - - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final - { - VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); - for (Uint32 elem = 0; elem < NumElements; ++elem) - BindResource(ppObjects[elem], FirstElement + elem); - } - - virtual bool IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, false); - } - }; - - struct SamplerBindInfo final : ShaderVariableD3D11Base - { - SamplerBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, - ShaderResourceLayoutD3D11& ParentResLayout, - SHADER_RESOURCE_VARIABLE_TYPE VariableType) : - ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} - {} - - // Non-virtual function - __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } - - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final - { - VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); - for (Uint32 elem = 0; elem < NumElements; ++elem) - BindResource(ppObjects[elem], FirstElement + elem); - } - - virtual bool IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsSamplerBound(m_Attribs.BindPoint + ArrayIndex); - } - }; - - // dbgResourceCache is only used for sanity check and as a remainder that the resource cache must be alive - // while Layout is alive - void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags, const ShaderResourceCacheD3D11& dbgResourceCache); - -#ifdef DEVELOPMENT - bool dvpVerifyBindings() const; -#endif - - IShaderResourceVariable* GetShaderVariable(const Char* Name); - IShaderResourceVariable* GetShaderVariable(Uint32 Index); - __forceinline SHADER_TYPE GetShaderType() const { return m_pResources->GetShaderType(); } - - IObject& GetOwner() { return m_Owner; } - - Uint32 GetVariableIndex(const ShaderVariableD3D11Base& Variable) const; - Uint32 GetTotalResourceCount() const - { - auto ResourceCount = GetNumCBs() + GetNumTexSRVs() + GetNumTexUAVs() + GetNumBufUAVs() + GetNumBufSRVs(); - // Do not expose sampler variables when using combined texture samplers - if (!m_pResources->IsUsingCombinedTextureSamplers()) - ResourceCount += GetNumSamplers(); - return ResourceCount; - } - - // clang-format off - Uint32 GetNumCBs() const { return (m_TexSRVsOffset - 0 ) / sizeof(ConstBuffBindInfo);} - Uint32 GetNumTexSRVs() const { return (m_TexUAVsOffset - m_TexSRVsOffset ) / sizeof(TexSRVBindInfo); } - Uint32 GetNumTexUAVs() const { return (m_BuffSRVsOffset - m_TexUAVsOffset ) / sizeof(TexUAVBindInfo) ; } - Uint32 GetNumBufSRVs() const { return (m_BuffUAVsOffset - m_BuffSRVsOffset) / sizeof(BuffSRVBindInfo); } - Uint32 GetNumBufUAVs() const { return (m_SamplerOffset - m_BuffUAVsOffset) / sizeof(BuffUAVBindInfo); } - Uint32 GetNumSamplers() const { return (m_MemorySize - m_SamplerOffset ) / sizeof(SamplerBindInfo); } - - template Uint32 GetNumResources()const; - template<> Uint32 GetNumResources() const { return GetNumCBs(); } - template<> Uint32 GetNumResources () const { return GetNumTexSRVs(); } - template<> Uint32 GetNumResources () const { return GetNumTexUAVs(); } - template<> Uint32 GetNumResources () const { return GetNumBufSRVs(); } - template<> Uint32 GetNumResources () const { return GetNumBufUAVs(); } - template<> Uint32 GetNumResources () const { return GetNumSamplers(); } - // clang-format on - - const Char* GetShaderName() const - { - return m_pResources->GetShaderName(); - } - -private: - // clang-format off - -/* 0 */ IObject& m_Owner; -/* 8 */ std::shared_ptr m_pResources; - - // No need to use shared pointer, as the resource cache is either part of the same - // ShaderD3D11Impl object, or ShaderResourceBindingD3D11Impl object -/*24*/ ShaderResourceCacheD3D11& m_ResourceCache; - -/*32*/ std::unique_ptr > m_ResourceBuffer; - - // Offsets in bytes - using OffsetType = Uint16; -/*48*/ OffsetType m_TexSRVsOffset = 0; -/*50*/ OffsetType m_TexUAVsOffset = 0; -/*52*/ OffsetType m_BuffSRVsOffset = 0; -/*54*/ OffsetType m_BuffUAVsOffset = 0; -/*56*/ OffsetType m_SamplerOffset = 0; -/*58*/ OffsetType m_MemorySize = 0; -/*60 - 64*/ -/*64*/ // End of data - - - template OffsetType GetResourceOffset()const; - template<> OffsetType GetResourceOffset() const { return 0; } - template<> OffsetType GetResourceOffset () const { return m_TexSRVsOffset; } - template<> OffsetType GetResourceOffset () const { return m_TexUAVsOffset; } - template<> OffsetType GetResourceOffset () const { return m_BuffSRVsOffset; } - template<> OffsetType GetResourceOffset () const { return m_BuffUAVsOffset; } - template<> OffsetType GetResourceOffset () const { return m_SamplerOffset; } - - // clang-format on - - template - ResourceType& GetResource(Uint32 ResIndex) - { - VERIFY(ResIndex < GetNumResources(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources() - 1, ")"); - auto Offset = GetResourceOffset(); - return reinterpret_cast(reinterpret_cast(m_ResourceBuffer.get()) + Offset)[ResIndex]; - } - - template - const ResourceType& GetConstResource(Uint32 ResIndex) const - { - VERIFY(ResIndex < GetNumResources(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources() - 1, ")"); - auto Offset = GetResourceOffset(); - return reinterpret_cast(reinterpret_cast(m_ResourceBuffer.get()) + Offset)[ResIndex]; - } - - template - IShaderResourceVariable* GetResourceByName(const Char* Name); - - template - void HandleResources(THandleCB HandleCB, - THandleTexSRV HandleTexSRV, - THandleTexUAV HandleTexUAV, - THandleBufSRV HandleBufSRV, - THandleBufUAV HandleBufUAV, - THandleSampler HandleSampler) - { - for (Uint32 cb = 0; cb < GetNumResources(); ++cb) - HandleCB(GetResource(cb)); - - for (Uint32 t = 0; t < GetNumResources(); ++t) - HandleTexSRV(GetResource(t)); - - for (Uint32 u = 0; u < GetNumResources(); ++u) - HandleTexUAV(GetResource(u)); - - for (Uint32 s = 0; s < GetNumResources(); ++s) - HandleBufSRV(GetResource(s)); - - for (Uint32 u = 0; u < GetNumResources(); ++u) - HandleBufUAV(GetResource(u)); - - for (Uint32 s = 0; s < GetNumResources(); ++s) - HandleSampler(GetResource(s)); - } - - template - void HandleConstResources(THandleCB HandleCB, - THandleTexSRV HandleTexSRV, - THandleTexUAV HandleTexUAV, - THandleBufSRV HandleBufSRV, - THandleBufUAV HandleBufUAV, - THandleSampler HandleSampler) const - { - for (Uint32 cb = 0; cb < GetNumResources(); ++cb) - HandleCB(GetConstResource(cb)); - - for (Uint32 t = 0; t < GetNumResources(); ++t) - HandleTexSRV(GetConstResource(t)); - - for (Uint32 u = 0; u < GetNumResources(); ++u) - HandleTexUAV(GetConstResource(u)); - - for (Uint32 s = 0; s < GetNumResources(); ++s) - HandleBufSRV(GetConstResource(s)); - - for (Uint32 u = 0; u < GetNumResources(); ++u) - HandleBufUAV(GetConstResource(u)); - - for (Uint32 s = 0; s < GetNumResources(); ++s) - HandleSampler(GetConstResource(s)); - } - - friend class ShaderVariableIndexLocator; - friend class ShaderVariableLocator; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.hpp new file mode 100644 index 00000000..9b58ea3c --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.hpp @@ -0,0 +1,415 @@ +/* + * 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::ShaderResourceLayoutD3D11 class + +#include "ShaderResources.hpp" +#include "ShaderBase.hpp" +#include "ShaderResourceCacheD3D11.hpp" +#include "EngineD3D11Defines.h" +#include "STDAllocator.h" +#include "ShaderVariableD3DBase.hpp" +#include "ShaderResourcesD3D11.hpp" + +namespace Diligent +{ + +class IMemoryAllocator; + +/// Diligent::ShaderResourceLayoutD3D11 class +/// http://diligentgraphics.com/diligent-engine/architecture/d3d11/shader-resource-layout/ +// sizeof(ShaderResourceLayoutD3D11) == 64 (x64) +class ShaderResourceLayoutD3D11 +{ +public: + ShaderResourceLayoutD3D11(IObject& Owner, + std::shared_ptr pSrcResources, + const PipelineResourceLayoutDesc& ResourceLayout, + const SHADER_RESOURCE_VARIABLE_TYPE* VarTypes, + Uint32 NumVarTypes, + ShaderResourceCacheD3D11& ResourceCache, + IMemoryAllocator& ResCacheDataAllocator, + IMemoryAllocator& ResLayoutDataAllocator); + ~ShaderResourceLayoutD3D11(); + + // clang-format off + // No copies, only moves are allowed + ShaderResourceLayoutD3D11 (const ShaderResourceLayoutD3D11&) = delete; + ShaderResourceLayoutD3D11& operator = (const ShaderResourceLayoutD3D11&) = delete; + ShaderResourceLayoutD3D11 ( ShaderResourceLayoutD3D11&&) = default; + ShaderResourceLayoutD3D11& operator = ( ShaderResourceLayoutD3D11&&) = delete; + // clang-format on + + static size_t GetRequiredMemorySize(const ShaderResourcesD3D11& SrcResources, + const PipelineResourceLayoutDesc& ResourceLayout, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes); + + void CopyResources(ShaderResourceCacheD3D11& DstCache) const; + + using ShaderVariableD3D11Base = ShaderVariableD3DBase; + + struct ConstBuffBindInfo final : ShaderVariableD3D11Base + { + ConstBuffBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, + ShaderResourceLayoutD3D11& ParentResLayout, + SHADER_RESOURCE_VARIABLE_TYPE VariableType) : + ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} + {} + // Non-virtual function + __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); + + virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } + + virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final + { + VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); + for (Uint32 elem = 0; elem < NumElements; ++elem) + BindResource(ppObjects[elem], FirstElement + elem); + } + + virtual bool IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsCBBound(m_Attribs.BindPoint + ArrayIndex); + } + }; + + struct TexSRVBindInfo final : ShaderVariableD3D11Base + { + TexSRVBindInfo(const D3DShaderResourceAttribs& _TextureAttribs, + Uint32 _SamplerIndex, + ShaderResourceLayoutD3D11& ParentResLayout, + SHADER_RESOURCE_VARIABLE_TYPE VariableType) : + ShaderVariableD3D11Base{ParentResLayout, _TextureAttribs, VariableType}, + SamplerIndex{_SamplerIndex} + {} + + // Non-virtual function + __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); + + virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } + + virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final + { + VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); + for (Uint32 elem = 0; elem < NumElements; ++elem) + BindResource(ppObjects[elem], FirstElement + elem); + } + + virtual bool IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, true); + } + + + bool ValidSamplerAssigned() const { return SamplerIndex != InvalidSamplerIndex; } + + static constexpr Uint32 InvalidSamplerIndex = static_cast(-1); + const Uint32 SamplerIndex; + }; + + struct TexUAVBindInfo final : ShaderVariableD3D11Base + { + TexUAVBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, + ShaderResourceLayoutD3D11& ParentResLayout, + SHADER_RESOURCE_VARIABLE_TYPE VariableType) : + ShaderVariableD3D11Base(ParentResLayout, ResourceAttribs, VariableType) + {} + + // Provide non-virtual function + __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); + + virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } + + virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final + { + VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); + for (Uint32 elem = 0; elem < NumElements; ++elem) + BindResource(ppObjects[elem], FirstElement + elem); + } + + __forceinline virtual bool IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, true); + } + }; + + struct BuffUAVBindInfo final : ShaderVariableD3D11Base + { + BuffUAVBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, + ShaderResourceLayoutD3D11& ParentResLayout, + SHADER_RESOURCE_VARIABLE_TYPE VariableType) : + ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} + {} + + // Non-virtual function + __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); + + virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } + + virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final + { + VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); + for (Uint32 elem = 0; elem < NumElements; ++elem) + BindResource(ppObjects[elem], FirstElement + elem); + } + + virtual bool IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, false); + } + }; + + struct BuffSRVBindInfo final : ShaderVariableD3D11Base + { + BuffSRVBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, + ShaderResourceLayoutD3D11& ParentResLayout, + SHADER_RESOURCE_VARIABLE_TYPE VariableType) : + ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} + {} + + // Non-virtual function + __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); + + virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } + + virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final + { + VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); + for (Uint32 elem = 0; elem < NumElements; ++elem) + BindResource(ppObjects[elem], FirstElement + elem); + } + + virtual bool IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, false); + } + }; + + struct SamplerBindInfo final : ShaderVariableD3D11Base + { + SamplerBindInfo(const D3DShaderResourceAttribs& ResourceAttribs, + ShaderResourceLayoutD3D11& ParentResLayout, + SHADER_RESOURCE_VARIABLE_TYPE VariableType) : + ShaderVariableD3D11Base{ParentResLayout, ResourceAttribs, VariableType} + {} + + // Non-virtual function + __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); + + virtual void Set(IDeviceObject* pObject) override final { BindResource(pObject, 0); } + + virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final + { + VerifyAndCorrectSetArrayArguments(m_Attribs.Name, m_Attribs.BindCount, FirstElement, NumElements); + for (Uint32 elem = 0; elem < NumElements; ++elem) + BindResource(ppObjects[elem], FirstElement + elem); + } + + virtual bool IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsSamplerBound(m_Attribs.BindPoint + ArrayIndex); + } + }; + + // dbgResourceCache is only used for sanity check and as a remainder that the resource cache must be alive + // while Layout is alive + void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags, const ShaderResourceCacheD3D11& dbgResourceCache); + +#ifdef DEVELOPMENT + bool dvpVerifyBindings() const; +#endif + + IShaderResourceVariable* GetShaderVariable(const Char* Name); + IShaderResourceVariable* GetShaderVariable(Uint32 Index); + __forceinline SHADER_TYPE GetShaderType() const { return m_pResources->GetShaderType(); } + + IObject& GetOwner() { return m_Owner; } + + Uint32 GetVariableIndex(const ShaderVariableD3D11Base& Variable) const; + Uint32 GetTotalResourceCount() const + { + auto ResourceCount = GetNumCBs() + GetNumTexSRVs() + GetNumTexUAVs() + GetNumBufUAVs() + GetNumBufSRVs(); + // Do not expose sampler variables when using combined texture samplers + if (!m_pResources->IsUsingCombinedTextureSamplers()) + ResourceCount += GetNumSamplers(); + return ResourceCount; + } + + // clang-format off + Uint32 GetNumCBs() const { return (m_TexSRVsOffset - 0 ) / sizeof(ConstBuffBindInfo);} + Uint32 GetNumTexSRVs() const { return (m_TexUAVsOffset - m_TexSRVsOffset ) / sizeof(TexSRVBindInfo); } + Uint32 GetNumTexUAVs() const { return (m_BuffSRVsOffset - m_TexUAVsOffset ) / sizeof(TexUAVBindInfo) ; } + Uint32 GetNumBufSRVs() const { return (m_BuffUAVsOffset - m_BuffSRVsOffset) / sizeof(BuffSRVBindInfo); } + Uint32 GetNumBufUAVs() const { return (m_SamplerOffset - m_BuffUAVsOffset) / sizeof(BuffUAVBindInfo); } + Uint32 GetNumSamplers() const { return (m_MemorySize - m_SamplerOffset ) / sizeof(SamplerBindInfo); } + + template Uint32 GetNumResources()const; + template<> Uint32 GetNumResources() const { return GetNumCBs(); } + template<> Uint32 GetNumResources () const { return GetNumTexSRVs(); } + template<> Uint32 GetNumResources () const { return GetNumTexUAVs(); } + template<> Uint32 GetNumResources () const { return GetNumBufSRVs(); } + template<> Uint32 GetNumResources () const { return GetNumBufUAVs(); } + template<> Uint32 GetNumResources () const { return GetNumSamplers(); } + // clang-format on + + const Char* GetShaderName() const + { + return m_pResources->GetShaderName(); + } + +private: + // clang-format off + +/* 0 */ IObject& m_Owner; +/* 8 */ std::shared_ptr m_pResources; + + // No need to use shared pointer, as the resource cache is either part of the same + // ShaderD3D11Impl object, or ShaderResourceBindingD3D11Impl object +/*24*/ ShaderResourceCacheD3D11& m_ResourceCache; + +/*32*/ std::unique_ptr > m_ResourceBuffer; + + // Offsets in bytes + using OffsetType = Uint16; +/*48*/ OffsetType m_TexSRVsOffset = 0; +/*50*/ OffsetType m_TexUAVsOffset = 0; +/*52*/ OffsetType m_BuffSRVsOffset = 0; +/*54*/ OffsetType m_BuffUAVsOffset = 0; +/*56*/ OffsetType m_SamplerOffset = 0; +/*58*/ OffsetType m_MemorySize = 0; +/*60 - 64*/ +/*64*/ // End of data + + + template OffsetType GetResourceOffset()const; + template<> OffsetType GetResourceOffset() const { return 0; } + template<> OffsetType GetResourceOffset () const { return m_TexSRVsOffset; } + template<> OffsetType GetResourceOffset () const { return m_TexUAVsOffset; } + template<> OffsetType GetResourceOffset () const { return m_BuffSRVsOffset; } + template<> OffsetType GetResourceOffset () const { return m_BuffUAVsOffset; } + template<> OffsetType GetResourceOffset () const { return m_SamplerOffset; } + + // clang-format on + + template + ResourceType& GetResource(Uint32 ResIndex) + { + VERIFY(ResIndex < GetNumResources(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources() - 1, ")"); + auto Offset = GetResourceOffset(); + return reinterpret_cast(reinterpret_cast(m_ResourceBuffer.get()) + Offset)[ResIndex]; + } + + template + const ResourceType& GetConstResource(Uint32 ResIndex) const + { + VERIFY(ResIndex < GetNumResources(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources() - 1, ")"); + auto Offset = GetResourceOffset(); + return reinterpret_cast(reinterpret_cast(m_ResourceBuffer.get()) + Offset)[ResIndex]; + } + + template + IShaderResourceVariable* GetResourceByName(const Char* Name); + + template + void HandleResources(THandleCB HandleCB, + THandleTexSRV HandleTexSRV, + THandleTexUAV HandleTexUAV, + THandleBufSRV HandleBufSRV, + THandleBufUAV HandleBufUAV, + THandleSampler HandleSampler) + { + for (Uint32 cb = 0; cb < GetNumResources(); ++cb) + HandleCB(GetResource(cb)); + + for (Uint32 t = 0; t < GetNumResources(); ++t) + HandleTexSRV(GetResource(t)); + + for (Uint32 u = 0; u < GetNumResources(); ++u) + HandleTexUAV(GetResource(u)); + + for (Uint32 s = 0; s < GetNumResources(); ++s) + HandleBufSRV(GetResource(s)); + + for (Uint32 u = 0; u < GetNumResources(); ++u) + HandleBufUAV(GetResource(u)); + + for (Uint32 s = 0; s < GetNumResources(); ++s) + HandleSampler(GetResource(s)); + } + + template + void HandleConstResources(THandleCB HandleCB, + THandleTexSRV HandleTexSRV, + THandleTexUAV HandleTexUAV, + THandleBufSRV HandleBufSRV, + THandleBufUAV HandleBufUAV, + THandleSampler HandleSampler) const + { + for (Uint32 cb = 0; cb < GetNumResources(); ++cb) + HandleCB(GetConstResource(cb)); + + for (Uint32 t = 0; t < GetNumResources(); ++t) + HandleTexSRV(GetConstResource(t)); + + for (Uint32 u = 0; u < GetNumResources(); ++u) + HandleTexUAV(GetConstResource(u)); + + for (Uint32 s = 0; s < GetNumResources(); ++s) + HandleBufSRV(GetConstResource(s)); + + for (Uint32 u = 0; u < GetNumResources(); ++u) + HandleBufUAV(GetConstResource(u)); + + for (Uint32 s = 0; s < GetNumResources(); ++s) + HandleSampler(GetConstResource(s)); + } + + friend class ShaderVariableIndexLocator; + friend class ShaderVariableLocator; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h deleted file mode 100644 index 5e3ac600..00000000 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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::ShaderResourcesD3D11 class - - -// ShaderResourcesD3D11 are created by ShaderD3D11Impl instances. They are then referenced by ShaderResourceLayoutD3D11 objects, which are in turn -// created by instances of ShaderResourceBindingsD3D11Impl and PipelineStateD3D11Impl -// -// _________________ -// | | -// | ShaderD3D11Impl | -// |_________________| -// | -// |shared_ptr -// ________V_____________ _____________________________________________________________________ -// | | unique_ptr | | | | | | | -// | ShaderResourcesD3D11 |--------------->| CBs | TexSRVs | TexUAVs | BufSRVs | BufUAVs | Samplers | -// |______________________| |________|___________|___________|___________|___________|____________| -// A A A A A A A -// | \ \ \ \ \ \ -// |shared_ptr Ref Ref Ref Ref Ref Ref -// ________|__________________ ____\_________\__________\__________\___________\_______ ___\______ -// | | unique_ptr | | | | | | | -// | ShaderResourceLayoutD3D11 |--------------->| CBs | TexSRVs | TexUAVs | BufSRVs | BufUAVs | Samplers | -// |___________________________| |________|___________|___________|___________|___________|__________| -// | A -// |_________________SamplerIndex_________________| -// -// -// One ShaderResourcesD3D11 instance can be referenced by multiple objects -// -// -// _______ ________________________________ -// | | | | -// ----| ShaderResourceLayoutD3D11 |<-----| ShaderResourceBindingD3D11Impl | -// | |___________________________| |________________________________| -// | -// | -// _________________ ______________________ | _______ ________________________________ -// | | shared_ptr | | shared_ptr| | | | | -// | ShaderD3D11Impl |--------------->| ShaderResourcesD3D11 |<---------------| ShaderResourceLayoutD3D11 |<-----| ShaderResourceBindingD3D11Impl | -// |_________________| |______________________| | |___________________________| |________________________________| -// A | -// | | -// __________ | | _______ ________________________________ -// | | shared_ptr | | | | | | -// | ShaderResourceLayoutD3D11 |------------------- ----| ShaderResourceLayoutD3D11 |<-----| ShaderResourceBindingD3D11Impl | -// |___________________________| |___________________________| |________________________________| -// A -// ___________|______________ -// | | -// | PipelineStateD3D11Impl | -// |__________________________| -// - -#include - -#include "ShaderResources.h" - -namespace Diligent -{ - -/// Diligent::ShaderResourcesD3D11 class -class ShaderResourcesD3D11 : public ShaderResources -{ -public: - // Loads shader resources from the compiled shader bytecode - ShaderResourcesD3D11(class RenderDeviceD3D11Impl* pDeviceD3D11Impl, - ID3DBlob* pShaderBytecode, - const ShaderDesc& ShdrDesc, - const char* CombinedSamplerSuffix); - ~ShaderResourcesD3D11(); - - // clang-format off - ShaderResourcesD3D11 (const ShaderResourcesD3D11&) = delete; - ShaderResourcesD3D11 ( ShaderResourcesD3D11&&) = delete; - ShaderResourcesD3D11& operator = (const ShaderResourcesD3D11&) = delete; - ShaderResourcesD3D11& operator = ( ShaderResourcesD3D11&&) = delete; - - __forceinline Int32 GetMaxCBBindPoint() const { return m_MaxCBBindPoint; } - __forceinline Int32 GetMaxSRVBindPoint() const { return m_MaxSRVBindPoint; } - __forceinline Int32 GetMaxSamplerBindPoint()const { return m_MaxSamplerBindPoint; } - __forceinline Int32 GetMaxUAVBindPoint() const { return m_MaxUAVBindPoint; } - // clang-format on - -#ifdef DEVELOPMENT - void dvpVerifyCommittedResources(ID3D11Buffer* CommittedD3D11CBs[], - ID3D11ShaderResourceView* CommittedD3D11SRVs[], - ID3D11Resource* CommittedD3D11SRVResources[], - ID3D11SamplerState* CommittedD3D11Samplers[], - ID3D11UnorderedAccessView* CommittedD3D11UAVs[], - ID3D11Resource* CommittedD3D11UAVResources[], - class ShaderResourceCacheD3D11& ResourceCache) const; -#endif - - -private: - using MaxBindPointType = Int8; - - // clang-format off - MaxBindPointType m_MaxCBBindPoint = -1; // Max == 13 - MaxBindPointType m_MaxSRVBindPoint = -1; // Max == 127 - MaxBindPointType m_MaxSamplerBindPoint = -1; // Max == 15 - MaxBindPointType m_MaxUAVBindPoint = -1; // Max == 7 - - static constexpr UINT MaxAllowedBindPoint = std::numeric_limits::max(); - static_assert(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max CB slot" ); - static_assert(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max SRV slot"); - static_assert(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max Sampler slot"); - static_assert(D3D11_PS_CS_UAV_REGISTER_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max UAV slot"); - // clang-format on -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.hpp new file mode 100644 index 00000000..6fe91203 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.hpp @@ -0,0 +1,142 @@ +/* + * 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::ShaderResourcesD3D11 class + + +// ShaderResourcesD3D11 are created by ShaderD3D11Impl instances. They are then referenced by ShaderResourceLayoutD3D11 objects, which are in turn +// created by instances of ShaderResourceBindingsD3D11Impl and PipelineStateD3D11Impl +// +// _________________ +// | | +// | ShaderD3D11Impl | +// |_________________| +// | +// |shared_ptr +// ________V_____________ _____________________________________________________________________ +// | | unique_ptr | | | | | | | +// | ShaderResourcesD3D11 |--------------->| CBs | TexSRVs | TexUAVs | BufSRVs | BufUAVs | Samplers | +// |______________________| |________|___________|___________|___________|___________|____________| +// A A A A A A A +// | \ \ \ \ \ \ +// |shared_ptr Ref Ref Ref Ref Ref Ref +// ________|__________________ ____\_________\__________\__________\___________\_______ ___\______ +// | | unique_ptr | | | | | | | +// | ShaderResourceLayoutD3D11 |--------------->| CBs | TexSRVs | TexUAVs | BufSRVs | BufUAVs | Samplers | +// |___________________________| |________|___________|___________|___________|___________|__________| +// | A +// |_________________SamplerIndex_________________| +// +// +// One ShaderResourcesD3D11 instance can be referenced by multiple objects +// +// +// _______ ________________________________ +// | | | | +// ----| ShaderResourceLayoutD3D11 |<-----| ShaderResourceBindingD3D11Impl | +// | |___________________________| |________________________________| +// | +// | +// _________________ ______________________ | _______ ________________________________ +// | | shared_ptr | | shared_ptr| | | | | +// | ShaderD3D11Impl |--------------->| ShaderResourcesD3D11 |<---------------| ShaderResourceLayoutD3D11 |<-----| ShaderResourceBindingD3D11Impl | +// |_________________| |______________________| | |___________________________| |________________________________| +// A | +// | | +// __________ | | _______ ________________________________ +// | | shared_ptr | | | | | | +// | ShaderResourceLayoutD3D11 |------------------- ----| ShaderResourceLayoutD3D11 |<-----| ShaderResourceBindingD3D11Impl | +// |___________________________| |___________________________| |________________________________| +// A +// ___________|______________ +// | | +// | PipelineStateD3D11Impl | +// |__________________________| +// + +#include + +#include "ShaderResources.hpp" + +namespace Diligent +{ + +/// Diligent::ShaderResourcesD3D11 class +class ShaderResourcesD3D11 : public ShaderResources +{ +public: + // Loads shader resources from the compiled shader bytecode + ShaderResourcesD3D11(class RenderDeviceD3D11Impl* pDeviceD3D11Impl, + ID3DBlob* pShaderBytecode, + const ShaderDesc& ShdrDesc, + const char* CombinedSamplerSuffix); + ~ShaderResourcesD3D11(); + + // clang-format off + ShaderResourcesD3D11 (const ShaderResourcesD3D11&) = delete; + ShaderResourcesD3D11 ( ShaderResourcesD3D11&&) = delete; + ShaderResourcesD3D11& operator = (const ShaderResourcesD3D11&) = delete; + ShaderResourcesD3D11& operator = ( ShaderResourcesD3D11&&) = delete; + + __forceinline Int32 GetMaxCBBindPoint() const { return m_MaxCBBindPoint; } + __forceinline Int32 GetMaxSRVBindPoint() const { return m_MaxSRVBindPoint; } + __forceinline Int32 GetMaxSamplerBindPoint()const { return m_MaxSamplerBindPoint; } + __forceinline Int32 GetMaxUAVBindPoint() const { return m_MaxUAVBindPoint; } + // clang-format on + +#ifdef DEVELOPMENT + void dvpVerifyCommittedResources(ID3D11Buffer* CommittedD3D11CBs[], + ID3D11ShaderResourceView* CommittedD3D11SRVs[], + ID3D11Resource* CommittedD3D11SRVResources[], + ID3D11SamplerState* CommittedD3D11Samplers[], + ID3D11UnorderedAccessView* CommittedD3D11UAVs[], + ID3D11Resource* CommittedD3D11UAVResources[], + class ShaderResourceCacheD3D11& ResourceCache) const; +#endif + + +private: + using MaxBindPointType = Int8; + + // clang-format off + MaxBindPointType m_MaxCBBindPoint = -1; // Max == 13 + MaxBindPointType m_MaxSRVBindPoint = -1; // Max == 127 + MaxBindPointType m_MaxSamplerBindPoint = -1; // Max == 15 + MaxBindPointType m_MaxUAVBindPoint = -1; // Max == 7 + + static constexpr UINT MaxAllowedBindPoint = std::numeric_limits::max(); + static_assert(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max CB slot" ); + static_assert(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max SRV slot"); + static_assert(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max Sampler slot"); + static_assert(D3D11_PS_CS_UAV_REGISTER_COUNT-1 <= MaxAllowedBindPoint, "Not enough bits to represent max UAV slot"); + // clang-format on +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.h deleted file mode 100644 index 3997f1c7..00000000 --- a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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::SwapChainD3D11Impl class - -#include "SwapChainD3D11.h" -#include "SwapChainD3DBase.h" - -namespace Diligent -{ - -class IMemoryAllocator; - -/// Swap chain implementation in Direct3D11 backend. -class SwapChainD3D11Impl final : public SwapChainD3DBase -{ -public: - using TSwapChainBase = SwapChainD3DBase; - - SwapChainD3D11Impl(IReferenceCounters* pRefCounters, - const SwapChainDesc& SCDesc, - const FullScreenModeDesc& FSDesc, - class RenderDeviceD3D11Impl* pRenderDeviceD3D11, - class DeviceContextD3D11Impl* pDeviceContextD3D11, - void* pNativeWndHandle); - ~SwapChainD3D11Impl(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of ISwapChain::Present() in Direct3D11 backend. - virtual void Present(Uint32 SyncInterval) override final; - - /// Implementation of ISwapChain::Resize() in Direct3D11 backend. - virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) override final; - - /// Implementation of ISwapChainD3D11::GetDXGISwapChain() in Direct3D11 backend. - virtual IDXGISwapChain* GetDXGISwapChain() override final { return m_pSwapChain; } - - /// Implementation of ISwapChainD3D11::GetCurrentBackBufferRTV() in Direct3D11 backend. - virtual ITextureViewD3D11* GetCurrentBackBufferRTV() override final { return m_pRenderTargetView; } - - /// Implementation of ISwapChainD3D11::GetDepthBufferDSV() in Direct3D11 backend. - virtual ITextureViewD3D11* GetDepthBufferDSV() override final { return m_pDepthStencilView; } - -private: - virtual void UpdateSwapChain(bool CreateNew) override final; - void CreateRTVandDSV(); - - RefCntAutoPtr m_pRenderTargetView; - RefCntAutoPtr m_pDepthStencilView; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp new file mode 100644 index 00000000..f40b4b9b --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp @@ -0,0 +1,80 @@ +/* + * 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::SwapChainD3D11Impl class + +#include "SwapChainD3D11.h" +#include "SwapChainD3DBase.hpp" + +namespace Diligent +{ + +class IMemoryAllocator; + +/// Swap chain implementation in Direct3D11 backend. +class SwapChainD3D11Impl final : public SwapChainD3DBase +{ +public: + using TSwapChainBase = SwapChainD3DBase; + + SwapChainD3D11Impl(IReferenceCounters* pRefCounters, + const SwapChainDesc& SCDesc, + const FullScreenModeDesc& FSDesc, + class RenderDeviceD3D11Impl* pRenderDeviceD3D11, + class DeviceContextD3D11Impl* pDeviceContextD3D11, + void* pNativeWndHandle); + ~SwapChainD3D11Impl(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of ISwapChain::Present() in Direct3D11 backend. + virtual void Present(Uint32 SyncInterval) override final; + + /// Implementation of ISwapChain::Resize() in Direct3D11 backend. + virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) override final; + + /// Implementation of ISwapChainD3D11::GetDXGISwapChain() in Direct3D11 backend. + virtual IDXGISwapChain* GetDXGISwapChain() override final { return m_pSwapChain; } + + /// Implementation of ISwapChainD3D11::GetCurrentBackBufferRTV() in Direct3D11 backend. + virtual ITextureViewD3D11* GetCurrentBackBufferRTV() override final { return m_pRenderTargetView; } + + /// Implementation of ISwapChainD3D11::GetDepthBufferDSV() in Direct3D11 backend. + virtual ITextureViewD3D11* GetDepthBufferDSV() override final { return m_pDepthStencilView; } + +private: + virtual void UpdateSwapChain(bool CreateNew) override final; + void CreateRTVandDSV(); + + RefCntAutoPtr m_pRenderTargetView; + RefCntAutoPtr m_pDepthStencilView; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h b/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h deleted file mode 100644 index 0be21f90..00000000 --- a/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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::Texture1D_D3D11 class - -#include "TextureBaseD3D11.h" - -namespace Diligent -{ - -/// Implementation of a 1D texture in Direct3D11 backend. -class Texture1D_D3D11 final : public TextureBaseD3D11 -{ -public: - Texture1D_D3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const TextureDesc& TexDesc, - const TextureData* pInitData = nullptr); - - Texture1D_D3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - RESOURCE_STATE InitialState, - ID3D11Texture1D* pd3d11Texture); - ~Texture1D_D3D11(); - -protected: - // clang-format off - virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) override final; - virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) override final; - virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) override final; - virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) override final; - // clang-format on -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.hpp b/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.hpp new file mode 100644 index 00000000..7ffcb7ba --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.hpp @@ -0,0 +1,64 @@ +/* + * 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::Texture1D_D3D11 class + +#include "TextureBaseD3D11.hpp" + +namespace Diligent +{ + +/// Implementation of a 1D texture in Direct3D11 backend. +class Texture1D_D3D11 final : public TextureBaseD3D11 +{ +public: + Texture1D_D3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr); + + Texture1D_D3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + RESOURCE_STATE InitialState, + ID3D11Texture1D* pd3d11Texture); + ~Texture1D_D3D11(); + +protected: + // clang-format off + virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) override final; + virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) override final; + virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) override final; + virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) override final; + // clang-format on +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h b/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h deleted file mode 100644 index 6c8d41f0..00000000 --- a/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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::Texture2D_D3D11 class - -#include "TextureBaseD3D11.h" - -namespace Diligent -{ - -/// Implementation of a 2D texture in Direct3D11 backend. -class Texture2D_D3D11 final : public TextureBaseD3D11 -{ -public: - Texture2D_D3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const TextureDesc& TexDesc, - const TextureData* pInitData = nullptr); - - Texture2D_D3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - RESOURCE_STATE InitialState, - ID3D11Texture2D* pd3d11Texture); - ~Texture2D_D3D11(); - -protected: - // clang-format off - virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) override final; - virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) override final; - virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) override final; - virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) override final; - // clang-format on -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.hpp b/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.hpp new file mode 100644 index 00000000..5df66c0c --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.hpp @@ -0,0 +1,64 @@ +/* + * 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::Texture2D_D3D11 class + +#include "TextureBaseD3D11.hpp" + +namespace Diligent +{ + +/// Implementation of a 2D texture in Direct3D11 backend. +class Texture2D_D3D11 final : public TextureBaseD3D11 +{ +public: + Texture2D_D3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr); + + Texture2D_D3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + RESOURCE_STATE InitialState, + ID3D11Texture2D* pd3d11Texture); + ~Texture2D_D3D11(); + +protected: + // clang-format off + virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) override final; + virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) override final; + virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) override final; + virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) override final; + // clang-format on +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h b/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h deleted file mode 100644 index 9ae638a1..00000000 --- a/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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::Texture3D_D3D11 class - -#include "TextureBaseD3D11.h" - -namespace Diligent -{ - -/// Implementation of a 3D texture in Direct3D11 backend. -class Texture3D_D3D11 final : public TextureBaseD3D11 -{ -public: - Texture3D_D3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const TextureDesc& TexDesc, - const TextureData* pInitData = nullptr); - - Texture3D_D3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - RESOURCE_STATE InitialState, - ID3D11Texture3D* pd3d11Texture); - ~Texture3D_D3D11(); - -protected: - // clang-format off - virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) override final; - virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) override final; - virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) override final; - virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) override final; - // clang-format on -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.hpp b/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.hpp new file mode 100644 index 00000000..b7e1710f --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.hpp @@ -0,0 +1,64 @@ +/* + * 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::Texture3D_D3D11 class + +#include "TextureBaseD3D11.hpp" + +namespace Diligent +{ + +/// Implementation of a 3D texture in Direct3D11 backend. +class Texture3D_D3D11 final : public TextureBaseD3D11 +{ +public: + Texture3D_D3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr); + + Texture3D_D3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + RESOURCE_STATE InitialState, + ID3D11Texture3D* pd3d11Texture); + ~Texture3D_D3D11(); + +protected: + // clang-format off + virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) override final; + virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) override final; + virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) override final; + virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) override final; + // clang-format on +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h deleted file mode 100644 index ece4e088..00000000 --- a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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::TextureBaseD3D11 class - -#include "TextureD3D11.h" -#include "RenderDeviceD3D11.h" -#include "TextureBase.h" -#include "TextureViewD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Base implementation of a texture object in Direct3D11 backend. -class TextureBaseD3D11 : public TextureBase -{ -public: - using TTextureBase = TextureBase; - using ViewImplType = TextureViewD3D11Impl; - - TextureBaseD3D11(IReferenceCounters* pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D11Impl* pDeviceD3D11, - const TextureDesc& TexDesc, - const TextureData* pInitData = nullptr); - ~TextureBaseD3D11(); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of ITextureD3D11::GetD3D11Texture(). - virtual ID3D11Resource* GetD3D11Texture() override final { return m_pd3d11Texture; } - - /// Implementation of ITexture::GetNativeHandle(). - virtual void* GetNativeHandle() override final { return GetD3D11Texture(); } - - void AddState(RESOURCE_STATE State) - { - m_State = static_cast(m_State & ~static_cast(RESOURCE_STATE_UNDEFINED)); - m_State = static_cast(m_State | State); - } - - void ClearState(RESOURCE_STATE State) - { - VERIFY_EXPR(IsInKnownState()); - m_State = static_cast(m_State & ~static_cast(State)); - if (m_State == RESOURCE_STATE_UNKNOWN) - m_State = RESOURCE_STATE_UNDEFINED; - } - -protected: - void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) override final; - void PrepareD3D11InitData(const TextureData* pInitData, - Uint32 NumSubresources, - std::vector>& D3D11InitData); - - // clang-format off - virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) = 0; - virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) = 0; - virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) = 0; - virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) = 0; - // clang-format on - - friend class RenderDeviceD3D11Impl; - /// D3D11 texture - CComPtr m_pd3d11Texture; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.hpp new file mode 100644 index 00000000..c954f844 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.hpp @@ -0,0 +1,98 @@ +/* + * 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::TextureBaseD3D11 class + +#include "TextureD3D11.h" +#include "RenderDeviceD3D11.h" +#include "TextureBase.hpp" +#include "TextureViewD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Base implementation of a texture object in Direct3D11 backend. +class TextureBaseD3D11 : public TextureBase +{ +public: + using TTextureBase = TextureBase; + using ViewImplType = TextureViewD3D11Impl; + + TextureBaseD3D11(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D11Impl* pDeviceD3D11, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr); + ~TextureBaseD3D11(); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of ITextureD3D11::GetD3D11Texture(). + virtual ID3D11Resource* GetD3D11Texture() override final { return m_pd3d11Texture; } + + /// Implementation of ITexture::GetNativeHandle(). + virtual void* GetNativeHandle() override final { return GetD3D11Texture(); } + + void AddState(RESOURCE_STATE State) + { + m_State = static_cast(m_State & ~static_cast(RESOURCE_STATE_UNDEFINED)); + m_State = static_cast(m_State | State); + } + + void ClearState(RESOURCE_STATE State) + { + VERIFY_EXPR(IsInKnownState()); + m_State = static_cast(m_State & ~static_cast(State)); + if (m_State == RESOURCE_STATE_UNKNOWN) + m_State = RESOURCE_STATE_UNDEFINED; + } + +protected: + void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) override final; + void PrepareD3D11InitData(const TextureData* pInitData, + Uint32 NumSubresources, + std::vector>& D3D11InitData); + + // clang-format off + virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) = 0; + virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) = 0; + virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) = 0; + virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) = 0; + // clang-format on + + friend class RenderDeviceD3D11Impl; + /// D3D11 texture + CComPtr m_pd3d11Texture; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h deleted file mode 100644 index 0b104597..00000000 --- a/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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::TextureViewD3D11Impl class - -#include "TextureViewD3D11.h" -#include "RenderDeviceD3D11.h" -#include "TextureViewBase.h" -#include "RenderDeviceD3D11Impl.h" - -namespace Diligent -{ - -class FixedBlockMemoryAllocator; - -/// Texture view implementation in Direct3D11 backend. -class TextureViewD3D11Impl final : public TextureViewBase -{ -public: - using TTextureViewBase = TextureViewBase; - - TextureViewD3D11Impl(IReferenceCounters* pRefCounters, - RenderDeviceD3D11Impl* pDevice, - const TextureViewDesc& ViewDesc, - class ITexture* pTexture, - ID3D11View* pD3D11View, - bool bIsDefaultView); - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; - - /// Implementation of ITextureViewD3D11::GetD3D11View(). - virtual ID3D11View* GetD3D11View() override final - { - return m_pD3D11View; - } - -private: - /// D3D11 view - CComPtr m_pD3D11View; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.hpp new file mode 100644 index 00000000..20c2afbf --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.hpp @@ -0,0 +1,69 @@ +/* + * 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::TextureViewD3D11Impl class + +#include "TextureViewD3D11.h" +#include "RenderDeviceD3D11.h" +#include "TextureViewBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Texture view implementation in Direct3D11 backend. +class TextureViewD3D11Impl final : public TextureViewBase +{ +public: + using TTextureViewBase = TextureViewBase; + + TextureViewD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const TextureViewDesc& ViewDesc, + class ITexture* pTexture, + ID3D11View* pD3D11View, + bool bIsDefaultView); + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final; + + /// Implementation of ITextureViewD3D11::GetD3D11View(). + virtual ID3D11View* GetD3D11View() override final + { + return m_pD3D11View; + } + +private: + /// D3D11 view + CComPtr m_pD3D11View; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/pch.h b/Graphics/GraphicsEngineD3D11/include/pch.h index bbc00ae1..ea2eab2f 100644 --- a/Graphics/GraphicsEngineD3D11/include/pch.h +++ b/Graphics/GraphicsEngineD3D11/include/pch.h @@ -74,8 +74,8 @@ #include "Errors.h" #include "RefCntAutoPtr.h" #include "DebugUtilities.h" -#include "D3DErrors.h" -#include "RenderDeviceBase.h" +#include "D3DErrors.hpp" +#include "RenderDeviceBase.hpp" #include "D3D11TypeConversions.h" #include "ValidatedCast.h" #include diff --git a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp index 02235237..2d2d10b5 100644 --- a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp @@ -28,11 +28,11 @@ #include "pch.h" #include -#include "BufferD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" +#include "BufferD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" #include "D3D11TypeConversions.h" -#include "BufferViewD3D11Impl.h" +#include "BufferViewD3D11Impl.hpp" #include "GraphicsAccessories.hpp" #include "EngineMemory.h" diff --git a/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp index ff78e3dc..e02bd8ff 100644 --- a/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp @@ -26,7 +26,7 @@ */ #include "pch.h" -#include "BufferViewD3D11Impl.h" +#include "BufferViewD3D11Impl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp index 27981375..39eb87bd 100644 --- a/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp @@ -28,7 +28,7 @@ #include "pch.h" #include -#include "CommandListD3D11Impl.h" +#include "CommandListD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/D3D11TypeConversions.cpp b/Graphics/GraphicsEngineD3D11/src/D3D11TypeConversions.cpp index 59a937b5..0d76db58 100644 --- a/Graphics/GraphicsEngineD3D11/src/D3D11TypeConversions.cpp +++ b/Graphics/GraphicsEngineD3D11/src/D3D11TypeConversions.cpp @@ -29,8 +29,8 @@ #include "D3D11TypeConversions.h" #include "D3D11TypeDefinitions.h" -#include "D3DTypeConversionImpl.h" -#include "D3DViewDescConversionImpl.h" +#include "D3DTypeConversionImpl.hpp" +#include "D3DViewDescConversionImpl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 78f08bf4..0c19756c 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -26,22 +26,22 @@ */ #include "pch.h" -#include "DeviceContextD3D11Impl.h" -#include "BufferD3D11Impl.h" -#include "ShaderD3D11Impl.h" -#include "Texture1D_D3D11.h" -#include "Texture2D_D3D11.h" -#include "Texture3D_D3D11.h" -#include "SamplerD3D11Impl.h" +#include "DeviceContextD3D11Impl.hpp" +#include "BufferD3D11Impl.hpp" +#include "ShaderD3D11Impl.hpp" +#include "Texture1D_D3D11.hpp" +#include "Texture2D_D3D11.hpp" +#include "Texture3D_D3D11.hpp" +#include "SamplerD3D11Impl.hpp" #include "D3D11TypeConversions.h" -#include "TextureViewD3D11Impl.h" -#include "PipelineStateD3D11Impl.h" -#include "ShaderResourceBindingD3D11Impl.h" +#include "TextureViewD3D11Impl.hpp" +#include "PipelineStateD3D11Impl.hpp" +#include "ShaderResourceBindingD3D11Impl.hpp" #include "EngineD3D11Defines.h" -#include "CommandListD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" -#include "FenceD3D11Impl.h" -#include "QueryD3D11Impl.h" +#include "CommandListD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" +#include "FenceD3D11Impl.hpp" +#include "QueryD3D11Impl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp index 623dde46..252697bd 100644 --- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp @@ -30,12 +30,12 @@ #include "pch.h" #include "EngineFactoryD3D11.h" -#include "RenderDeviceD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" -#include "SwapChainD3D11Impl.h" +#include "RenderDeviceD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" +#include "SwapChainD3D11Impl.hpp" #include "D3D11TypeConversions.h" #include "EngineMemory.h" -#include "EngineFactoryD3DBase.h" +#include "EngineFactoryD3DBase.hpp" #include #include diff --git a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp index 9a651121..3cb1b91e 100644 --- a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp @@ -28,7 +28,7 @@ #include "pch.h" #include -#include "FenceD3D11Impl.h" +#include "FenceD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp index 7cc5313d..02f0dac8 100644 --- a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp @@ -27,11 +27,11 @@ #include "pch.h" #include -#include "PipelineStateD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" -#include "ShaderResourceBindingD3D11Impl.h" +#include "PipelineStateD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" +#include "ShaderResourceBindingD3D11Impl.hpp" #include "EngineMemory.h" -#include "ShaderD3D11Impl.h" +#include "ShaderD3D11Impl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp index 751810de..bf70dfc1 100644 --- a/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp @@ -27,8 +27,8 @@ #include "pch.h" -#include "QueryD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" +#include "QueryD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index b7e7a0bc..bcd9bec6 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -26,20 +26,20 @@ */ #include "pch.h" -#include "RenderDeviceD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" -#include "BufferD3D11Impl.h" -#include "ShaderD3D11Impl.h" -#include "Texture1D_D3D11.h" -#include "Texture2D_D3D11.h" -#include "Texture3D_D3D11.h" -#include "SamplerD3D11Impl.h" +#include "RenderDeviceD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" +#include "BufferD3D11Impl.hpp" +#include "ShaderD3D11Impl.hpp" +#include "Texture1D_D3D11.hpp" +#include "Texture2D_D3D11.hpp" +#include "Texture3D_D3D11.hpp" +#include "SamplerD3D11Impl.hpp" #include "D3D11TypeConversions.h" -#include "TextureViewD3D11Impl.h" -#include "PipelineStateD3D11Impl.h" -#include "ShaderResourceBindingD3D11Impl.h" -#include "FenceD3D11Impl.h" -#include "QueryD3D11Impl.h" +#include "TextureViewD3D11Impl.hpp" +#include "PipelineStateD3D11Impl.hpp" +#include "ShaderResourceBindingD3D11Impl.hpp" +#include "FenceD3D11Impl.hpp" +#include "QueryD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp index c5166c27..6d23f951 100644 --- a/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp @@ -26,8 +26,8 @@ */ #include "pch.h" -#include "SamplerD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" +#include "SamplerD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" #include "D3D11TypeConversions.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp index 8cf31521..b5b0194f 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp @@ -27,8 +27,8 @@ #include "pch.h" -#include "ShaderD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" +#include "ShaderD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" #include "ResourceMapping.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp index 96acdd01..7af06af3 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp @@ -26,10 +26,10 @@ */ #include "pch.h" -#include "ShaderResourceBindingD3D11Impl.h" -#include "PipelineStateD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" +#include "ShaderResourceBindingD3D11Impl.hpp" +#include "PipelineStateD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp index a98653eb..2286d65e 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp @@ -27,11 +27,11 @@ #include "pch.h" -#include "ShaderResourceCacheD3D11.h" -#include "ShaderResourceLayoutD3D11.h" -#include "TextureBaseD3D11.h" -#include "BufferD3D11Impl.h" -#include "SamplerD3D11Impl.h" +#include "ShaderResourceCacheD3D11.hpp" +#include "ShaderResourceLayoutD3D11.hpp" +#include "TextureBaseD3D11.hpp" +#include "BufferD3D11Impl.hpp" +#include "SamplerD3D11Impl.hpp" #include "MemoryAllocator.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp index c13f6fd8..741b5692 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp @@ -29,15 +29,15 @@ #include -#include "ShaderResourceLayoutD3D11.h" -#include "ShaderResourceCacheD3D11.h" -#include "BufferD3D11Impl.h" -#include "BufferViewD3D11Impl.h" -#include "TextureBaseD3D11.h" +#include "ShaderResourceLayoutD3D11.hpp" +#include "ShaderResourceCacheD3D11.hpp" +#include "BufferD3D11Impl.hpp" +#include "BufferViewD3D11Impl.hpp" +#include "TextureBaseD3D11.hpp" #include "TextureViewD3D11.h" -#include "SamplerD3D11Impl.h" -#include "ShaderD3D11Impl.h" -#include "ShaderResourceVariableBase.h" +#include "SamplerD3D11Impl.hpp" +#include "ShaderD3D11Impl.hpp" +#include "ShaderResourceVariableBase.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp index 6ca61897..e39830aa 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp @@ -28,10 +28,10 @@ #include "pch.h" #include -#include "ShaderResourcesD3D11.h" -#include "ShaderBase.h" -#include "ShaderResourceCacheD3D11.h" -#include "RenderDeviceD3D11Impl.h" +#include "ShaderResourcesD3D11.hpp" +#include "ShaderBase.hpp" +#include "ShaderResourceCacheD3D11.hpp" +#include "RenderDeviceD3D11Impl.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp index 537064e5..0beb5eb8 100644 --- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp @@ -26,9 +26,9 @@ */ #include "pch.h" -#include "SwapChainD3D11Impl.h" -#include "RenderDeviceD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" +#include "SwapChainD3D11Impl.hpp" +#include "RenderDeviceD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" #include namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp b/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp index 7f7b63cc..89104a55 100644 --- a/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp @@ -26,8 +26,8 @@ */ #include "pch.h" -#include "Texture1D_D3D11.h" -#include "RenderDeviceD3D11Impl.h" +#include "Texture1D_D3D11.hpp" +#include "RenderDeviceD3D11Impl.hpp" #include "D3D11TypeConversions.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp b/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp index 2deb84cc..cc36b713 100644 --- a/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp @@ -26,8 +26,8 @@ */ #include "pch.h" -#include "Texture2D_D3D11.h" -#include "RenderDeviceD3D11Impl.h" +#include "Texture2D_D3D11.hpp" +#include "RenderDeviceD3D11Impl.hpp" #include "D3D11TypeConversions.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp b/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp index 37ad78a9..322043e8 100644 --- a/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp @@ -26,8 +26,8 @@ */ #include "pch.h" -#include "Texture3D_D3D11.h" -#include "RenderDeviceD3D11Impl.h" +#include "Texture3D_D3D11.hpp" +#include "RenderDeviceD3D11Impl.hpp" #include "D3D11TypeConversions.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp index add54b6b..39918856 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp @@ -26,11 +26,11 @@ */ #include "pch.h" -#include "TextureBaseD3D11.h" -#include "RenderDeviceD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" +#include "TextureBaseD3D11.hpp" +#include "RenderDeviceD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" #include "D3D11TypeConversions.h" -#include "TextureViewD3D11Impl.h" +#include "TextureViewD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp index 6dc63f6a..f6c2d982 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp @@ -26,8 +26,8 @@ */ #include "pch.h" -#include "TextureViewD3D11Impl.h" -#include "DeviceContextD3D11Impl.h" +#include "TextureViewD3D11Impl.hpp" +#include "DeviceContextD3D11Impl.hpp" namespace Diligent { -- cgit v1.2.3