From a78add37a57b51d80ef2fd21a7a0799ba73dd937 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 23 Jul 2020 15:24:54 -0700 Subject: Added Render pass interface stub --- .../GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp | 4 ++++ Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp index 0daef6b3..8f50f8f8 100644 --- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp @@ -81,6 +81,10 @@ public: virtual void DILIGENT_CALL_TYPE CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) override final; + /// Implementation of IRenderDevice::CreateRenderPass() in Direct3D11 backend. + virtual void DILIGENT_CALL_TYPE CreateRenderPass(const RenderPassDesc& Desc, + IRenderPass** ppRenderPass) override final; + /// Implementation of IRenderDeviceD3D11::GetD3D11Device() in Direct3D11 backend. ID3D11Device* DILIGENT_CALL_TYPE GetD3D11Device() override final { return m_pd3d11Device; } diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index e73bec3a..ce0dc402 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -372,6 +372,17 @@ void RenderDeviceD3D11Impl::CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) }); } +void RenderDeviceD3D11Impl::CreateRenderPass(const RenderPassDesc& Desc, IRenderPass** ppRenderPass) +{ + //CreateDeviceObject("RenderPass", Desc, ppRenderPass, + // [&]() // + // { + // RenderPassD3D11Impl* pRenderPassD3D11(NEW_RC_OBJ(m_RenderPassAllocator, "RenderPassD3D11Impl instance", RenderPassD3D11Impl)(this, Desc)); + // pRenderPassD3D11->RenderPassInterface(IID_RenderPass, reinterpret_cast(ppRenderPass)); + // OnCreateDeviceObject(pRenderPassD3D11); + // }); +} + void RenderDeviceD3D11Impl::IdleGPU() { if (auto pImmediateCtx = m_wpImmediateContext.Lock()) -- cgit v1.2.3 From 8a7504ff49c357ad86d547a35bdfd3258bea72df Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 23 Jul 2020 15:58:46 -0700 Subject: Added render pass object implementation stubs in all backends --- Graphics/GraphicsEngineD3D11/CMakeLists.txt | 2 + .../include/RenderPassD3D11Impl.hpp | 54 ++++++++++++++++++++++ .../src/RenderDeviceD3D11Impl.cpp | 18 ++++---- .../src/RenderPassD3D11Impl.cpp | 47 +++++++++++++++++++ 4 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 Graphics/GraphicsEngineD3D11/include/RenderPassD3D11Impl.hpp create mode 100644 Graphics/GraphicsEngineD3D11/src/RenderPassD3D11Impl.cpp (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/CMakeLists.txt b/Graphics/GraphicsEngineD3D11/CMakeLists.txt index 9ec7e370..30a48152 100644 --- a/Graphics/GraphicsEngineD3D11/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3D11/CMakeLists.txt @@ -17,6 +17,7 @@ set(INCLUDE include/PipelineStateD3D11Impl.hpp include/QueryD3D11Impl.hpp include/RenderDeviceD3D11Impl.hpp + include/RenderPassD3D11Impl.hpp include/SamplerD3D11Impl.hpp include/ShaderD3D11Impl.hpp include/ShaderResourceBindingD3D11Impl.hpp @@ -62,6 +63,7 @@ set(SRC src/PipelineStateD3D11Impl.cpp src/QueryD3D11Impl.cpp src/RenderDeviceD3D11Impl.cpp + src/RenderPassD3D11Impl.cpp src/SamplerD3D11Impl.cpp src/ShaderD3D11Impl.cpp src/ShaderResourceBindingD3D11Impl.cpp diff --git a/Graphics/GraphicsEngineD3D11/include/RenderPassD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/RenderPassD3D11Impl.hpp new file mode 100644 index 00000000..d90d67ac --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/RenderPassD3D11Impl.hpp @@ -0,0 +1,54 @@ +/* + * 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::RenderPassD3D11Impl class + +#include "RenderDeviceD3D11.h" +#include "RenderPassBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Render pass implementation in Direct3D11 backend. +class RenderPassD3D11Impl final : public RenderPassBase +{ +public: + using TRenderPassBase = RenderPassBase; + + RenderPassD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const RenderPassDesc& Desc); + ~RenderPassD3D11Impl(); +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index ce0dc402..729eb687 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -40,6 +40,7 @@ #include "ShaderResourceBindingD3D11Impl.hpp" #include "FenceD3D11Impl.hpp" #include "QueryD3D11Impl.hpp" +#include "RenderPassD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent @@ -97,7 +98,8 @@ RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCo sizeof(PipelineStateD3D11Impl), sizeof(ShaderResourceBindingD3D11Impl), sizeof(FenceD3D11Impl), - sizeof(QueryD3D11Impl) + sizeof(QueryD3D11Impl), + sizeof(RenderPassD3D11Impl) } }, m_EngineAttribs{EngineAttribs}, @@ -374,13 +376,13 @@ void RenderDeviceD3D11Impl::CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) void RenderDeviceD3D11Impl::CreateRenderPass(const RenderPassDesc& Desc, IRenderPass** ppRenderPass) { - //CreateDeviceObject("RenderPass", Desc, ppRenderPass, - // [&]() // - // { - // RenderPassD3D11Impl* pRenderPassD3D11(NEW_RC_OBJ(m_RenderPassAllocator, "RenderPassD3D11Impl instance", RenderPassD3D11Impl)(this, Desc)); - // pRenderPassD3D11->RenderPassInterface(IID_RenderPass, reinterpret_cast(ppRenderPass)); - // OnCreateDeviceObject(pRenderPassD3D11); - // }); + CreateDeviceObject("RenderPass", Desc, ppRenderPass, + [&]() // + { + RenderPassD3D11Impl* pRenderPassD3D11(NEW_RC_OBJ(m_RenderPassAllocator, "RenderPassD3D11Impl instance", RenderPassD3D11Impl)(this, Desc)); + pRenderPassD3D11->QueryInterface(IID_RenderPass, reinterpret_cast(ppRenderPass)); + OnCreateDeviceObject(pRenderPassD3D11); + }); } void RenderDeviceD3D11Impl::IdleGPU() diff --git a/Graphics/GraphicsEngineD3D11/src/RenderPassD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderPassD3D11Impl.cpp new file mode 100644 index 00000000..d30fd368 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/src/RenderPassD3D11Impl.cpp @@ -0,0 +1,47 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +#include "RenderPassD3D11Impl.hpp" +#include "EngineMemory.h" + +namespace Diligent +{ + +RenderPassD3D11Impl::RenderPassD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const RenderPassDesc& Desc) : + TRenderPassBase{pRefCounters, pDevice, Desc} +{ +} + +RenderPassD3D11Impl::~RenderPassD3D11Impl() +{ +} + +} // namespace Diligent -- cgit v1.2.3 From 16dd04efc73e4093a991a517f786ebaf03f3f6d1 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 24 Jul 2020 21:18:48 -0700 Subject: Added framebuffer object implementation stubs --- Graphics/GraphicsEngineD3D11/CMakeLists.txt | 2 + .../include/FramebufferD3D11Impl.hpp | 54 ++++++++++++++++++++++ .../include/RenderDeviceD3D11Impl.hpp | 4 ++ .../src/FramebufferD3D11Impl.cpp | 47 +++++++++++++++++++ .../src/RenderDeviceD3D11Impl.cpp | 15 +++++- 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 Graphics/GraphicsEngineD3D11/include/FramebufferD3D11Impl.hpp create mode 100644 Graphics/GraphicsEngineD3D11/src/FramebufferD3D11Impl.cpp (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/CMakeLists.txt b/Graphics/GraphicsEngineD3D11/CMakeLists.txt index 30a48152..ba6aeb46 100644 --- a/Graphics/GraphicsEngineD3D11/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3D11/CMakeLists.txt @@ -14,6 +14,7 @@ set(INCLUDE include/EngineD3D11Defines.h include/pch.h include/FenceD3D11Impl.hpp + include/FramebufferD3D11Impl.hpp include/PipelineStateD3D11Impl.hpp include/QueryD3D11Impl.hpp include/RenderDeviceD3D11Impl.hpp @@ -59,6 +60,7 @@ set(SRC src/DeviceContextD3D11Impl.cpp src/EngineFactoryD3D11.cpp src/FenceD3D11Impl.cpp + src/FramebufferD3D11Impl.cpp src/GUIDDef.cpp src/PipelineStateD3D11Impl.cpp src/QueryD3D11Impl.cpp diff --git a/Graphics/GraphicsEngineD3D11/include/FramebufferD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/FramebufferD3D11Impl.hpp new file mode 100644 index 00000000..5449d4f9 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/include/FramebufferD3D11Impl.hpp @@ -0,0 +1,54 @@ +/* + * 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::FramebufferD3D11Impl class + +#include "RenderDeviceD3D11.h" +#include "FramebufferBase.hpp" +#include "RenderDeviceD3D11Impl.hpp" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Render pass implementation in Direct3D11 backend. +class FramebufferD3D11Impl final : public FramebufferBase +{ +public: + using TFramebufferBase = FramebufferBase; + + FramebufferD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const FramebufferDesc& Desc); + ~FramebufferD3D11Impl(); +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp index 8f50f8f8..f041806c 100644 --- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp @@ -85,6 +85,10 @@ public: virtual void DILIGENT_CALL_TYPE CreateRenderPass(const RenderPassDesc& Desc, IRenderPass** ppRenderPass) override final; + /// Implementation of IRenderDevice::CreateFramebuffer() in Direct3D11 backend. + virtual void DILIGENT_CALL_TYPE CreateFramebuffer(const FramebufferDesc& Desc, + IFramebuffer** ppFramebuffer) override final; + /// Implementation of IRenderDeviceD3D11::GetD3D11Device() in Direct3D11 backend. ID3D11Device* DILIGENT_CALL_TYPE GetD3D11Device() override final { return m_pd3d11Device; } diff --git a/Graphics/GraphicsEngineD3D11/src/FramebufferD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/FramebufferD3D11Impl.cpp new file mode 100644 index 00000000..469dc3c5 --- /dev/null +++ b/Graphics/GraphicsEngineD3D11/src/FramebufferD3D11Impl.cpp @@ -0,0 +1,47 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +#include "FramebufferD3D11Impl.hpp" +#include "EngineMemory.h" + +namespace Diligent +{ + +FramebufferD3D11Impl::FramebufferD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const FramebufferDesc& Desc) : + TFramebufferBase{pRefCounters, pDevice, Desc} +{ +} + +FramebufferD3D11Impl::~FramebufferD3D11Impl() +{ +} + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index 729eb687..d413ac5f 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -41,6 +41,7 @@ #include "FenceD3D11Impl.hpp" #include "QueryD3D11Impl.hpp" #include "RenderPassD3D11Impl.hpp" +#include "FramebufferD3D11Impl.hpp" #include "EngineMemory.h" namespace Diligent @@ -99,7 +100,8 @@ RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCo sizeof(ShaderResourceBindingD3D11Impl), sizeof(FenceD3D11Impl), sizeof(QueryD3D11Impl), - sizeof(RenderPassD3D11Impl) + sizeof(RenderPassD3D11Impl), + sizeof(FramebufferD3D11Impl) } }, m_EngineAttribs{EngineAttribs}, @@ -385,6 +387,17 @@ void RenderDeviceD3D11Impl::CreateRenderPass(const RenderPassDesc& Desc, IRender }); } +void RenderDeviceD3D11Impl::CreateFramebuffer(const FramebufferDesc& Desc, IFramebuffer** ppFramebuffer) +{ + CreateDeviceObject("Framebuffer", Desc, ppFramebuffer, + [&]() // + { + FramebufferD3D11Impl* pFramebufferD3D11(NEW_RC_OBJ(m_FramebufferAllocator, "FramebufferD3D11Impl instance", FramebufferD3D11Impl)(this, Desc)); + pFramebufferD3D11->QueryInterface(IID_Framebuffer, reinterpret_cast(ppFramebuffer)); + OnCreateDeviceObject(pFramebufferD3D11); + }); +} + void RenderDeviceD3D11Impl::IdleGPU() { if (auto pImmediateCtx = m_wpImmediateContext.Lock()) -- cgit v1.2.3 From 8798aa2e94602372a61c362d5c3f288cc07388c9 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 26 Jul 2020 19:16:18 -0700 Subject: Added BeginRenderPass, NextSubpass, and EndRenderPass device context methods --- .../include/DeviceContextD3D11Impl.hpp | 9 +++++++++ .../GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index f8db6f23..a9efa7ff 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -122,6 +122,15 @@ public: ITextureView* pDepthStencil, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final; + /// Implementation of IDeviceContext::BeginRenderPass() in Direct3D11 backend. + virtual void DILIGENT_CALL_TYPE BeginRenderPass(const BeginRenderPassAttribs& Attribs) override final; + + /// Implementation of IDeviceContext::NextSubpass() in Direct3D11 backend. + virtual void DILIGENT_CALL_TYPE NextSubpass() override final; + + /// Implementation of IDeviceContext::EndRenderPass() in Direct3D11 backend. + virtual void DILIGENT_CALL_TYPE EndRenderPass() override final; + /// Implementation of IDeviceContext::Draw() in Direct3D11 backend. virtual void DILIGENT_CALL_TYPE Draw(const DrawAttribs& Attribs) override final; /// Implementation of IDeviceContext::DrawIndexed() in Direct3D11 backend. diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 0ff2227d..48eb6498 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1617,6 +1617,22 @@ void DeviceContextD3D11Impl::SetRenderTargets(Uint32 Num } } +void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attribs) +{ + UNEXPECTED("Method not implemented"); +} + +void DeviceContextD3D11Impl::NextSubpass() +{ + UNEXPECTED("Method not implemented"); +} + +void DeviceContextD3D11Impl::EndRenderPass() +{ + UNEXPECTED("Method not implemented"); +} + + template void SetD3D11ResourcesHelper(ID3D11DeviceContext* pDeviceCtx, TSetD3D11ResMethodType SetD3D11ResMethod, -- cgit v1.2.3 From b875435c82aa5efbea55ee17719c4a57b171a811 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 31 Jul 2020 23:31:05 -0700 Subject: Base implementation of BeginRenderPass/NextSubpass/EndRenderPass methods --- Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp | 6 ++++-- Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index a9efa7ff..7f148d8c 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -37,6 +37,8 @@ #include "TextureBaseD3D11.hpp" #include "PipelineStateD3D11Impl.hpp" #include "QueryD3D11Impl.hpp" +#include "FramebufferD3D11Impl.hpp" +#include "RenderPassD3D11Impl.hpp" #include "DisjointQueryPool.hpp" #ifdef DILIGENT_DEBUG @@ -46,8 +48,6 @@ namespace Diligent { -class RenderDeviceD3D11Impl; - struct DeviceContextD3D11ImplTraits { using BufferType = BufferD3D11Impl; @@ -55,6 +55,8 @@ struct DeviceContextD3D11ImplTraits using PipelineStateType = PipelineStateD3D11Impl; using DeviceType = RenderDeviceD3D11Impl; using QueryType = QueryD3D11Impl; + using FramebufferType = FramebufferD3D11Impl; + using RenderPassType = RenderPassD3D11Impl; }; /// Device context implementation in Direct3D11 backend. diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 48eb6498..339e6f35 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1619,16 +1619,19 @@ void DeviceContextD3D11Impl::SetRenderTargets(Uint32 Num void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attribs) { + TDeviceContextBase::BeginRenderPass(Attribs); UNEXPECTED("Method not implemented"); } void DeviceContextD3D11Impl::NextSubpass() { + TDeviceContextBase::NextSubpass(); UNEXPECTED("Method not implemented"); } void DeviceContextD3D11Impl::EndRenderPass() { + TDeviceContextBase::EndRenderPass(); UNEXPECTED("Method not implemented"); } -- cgit v1.2.3 From 812fc38d1b0957ed96d93e023b7322d65c5d3f5d Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 1 Aug 2020 18:18:48 -0700 Subject: Updated EndRenderPass to optionally update resource states --- Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp | 2 +- Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index 7f148d8c..9df79314 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -131,7 +131,7 @@ public: virtual void DILIGENT_CALL_TYPE NextSubpass() override final; /// Implementation of IDeviceContext::EndRenderPass() in Direct3D11 backend. - virtual void DILIGENT_CALL_TYPE EndRenderPass() override final; + virtual void DILIGENT_CALL_TYPE EndRenderPass(bool UpdateResourceStates) override final; /// Implementation of IDeviceContext::Draw() in Direct3D11 backend. virtual void DILIGENT_CALL_TYPE Draw(const DrawAttribs& Attribs) override final; diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 339e6f35..857ed7c5 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1629,9 +1629,9 @@ void DeviceContextD3D11Impl::NextSubpass() UNEXPECTED("Method not implemented"); } -void DeviceContextD3D11Impl::EndRenderPass() +void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) { - TDeviceContextBase::EndRenderPass(); + TDeviceContextBase::EndRenderPass(UpdateResourceStates); UNEXPECTED("Method not implemented"); } -- cgit v1.2.3 From 3ce2d21558fa0568ab7d332a5c300a661e444f44 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 4 Aug 2020 19:21:19 -0700 Subject: Added more renderpass-related checks --- .../GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 857ed7c5..c6f9d289 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -627,6 +627,12 @@ void DeviceContextD3D11Impl::TransitionShaderResources(IPipelineState* pPipeline { DEV_CHECK_ERR(pPipelineState != nullptr, "Pipeline state must not be null"); DEV_CHECK_ERR(pShaderResourceBinding != nullptr, "Shader resource binding must not be null"); + if (m_pActiveRenderPass) + { + LOG_ERROR_MESSAGE("State transitions are not allowed inside a render pass."); + return; + } + TransitionAndCommitShaderResources(pPipelineState, pShaderResourceBinding, false); } @@ -955,6 +961,11 @@ void DeviceContextD3D11Impl::ClearRenderTarget(ITextureView* pView, const float* void DeviceContextD3D11Impl::Flush() { + if (m_pActiveRenderPass != nullptr) + { + LOG_ERROR_MESSAGE("Flushing device context inside an active render pass."); + } + m_pd3d11DeviceContext->Flush(); } @@ -1721,6 +1732,8 @@ void DeviceContextD3D11Impl::ReleaseCommittedShaderResources() void DeviceContextD3D11Impl::FinishCommandList(ICommandList** ppCommandList) { + VERIFY(m_pActiveRenderPass == nullptr, "Finishing command list inside an active render pass."); + CComPtr pd3d11CmdList; m_pd3d11DeviceContext->FinishCommandList( FALSE, // A Boolean flag that determines whether the runtime saves deferred context state before it @@ -1963,6 +1976,8 @@ void DeviceContextD3D11Impl::InvalidateState() void DeviceContextD3D11Impl::TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) { + VERIFY(m_pActiveRenderPass == nullptr, "State transitions are not allowed inside a render pass"); + for (Uint32 i = 0; i < BarrierCount; ++i) { const auto& Barrier = pResourceBarriers[i]; -- cgit v1.2.3 From a34d7e04dc092e6c1bae4db120edbf5e6fc8c564 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 7 Aug 2020 12:14:43 -0700 Subject: First implementation of render passes in d3d11 --- .../include/DeviceContextD3D11Impl.hpp | 5 ++ .../src/DeviceContextD3D11Impl.cpp | 92 +++++++++++++++++++++- 2 files changed, 94 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index 9df79314..ba5cec2f 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -305,6 +305,11 @@ private: /// Prepares for an indexed draw command __forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType); + /// Prepares for current subpass + void BeginSubpass(); + + /// Ends current subpass + void EndSubpass(); template diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index c6f9d289..7da0b98f 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1582,6 +1582,14 @@ void DeviceContextD3D11Impl::SetRenderTargets(Uint32 Num ITextureView* pDepthStencil, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) { +#ifdef DILIGENT_DEVELOPMENT + if (m_pActiveRenderPass != nullptr) + { + LOG_ERROR_MESSAGE("Calling SetRenderTargets inside active render pass is invalid. End the render pass first"); + return; + } +#endif + if (TDeviceContextBase::SetRenderTargets(NumRenderTargets, ppRenderTargets, pDepthStencil)) { for (Uint32 RT = 0; RT < NumRenderTargets; ++RT) @@ -1628,22 +1636,100 @@ void DeviceContextD3D11Impl::SetRenderTargets(Uint32 Num } } +void DeviceContextD3D11Impl::BeginSubpass() +{ + VERIFY_EXPR(m_pActiveRenderPass); + const auto& RPDesc = m_pActiveRenderPass->GetDesc(); + VERIFY_EXPR(m_SubpassIndex < RPDesc.SubpassCount); + const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + + for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) + { + auto* pTex = ValidatedCast(FBDesc.ppAttachments[att]->GetTexture()); + if (pTex == nullptr) + continue; + + const auto NewState = m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex, att); + const auto PrevState = m_SubpassIndex > 0 ? + m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex - 1, att) : + RPDesc.pAttachments[att].InitialState; + + if (NewState == PrevState) + continue; + + switch (NewState) + { + case RESOURCE_STATE_RENDER_TARGET: + case RESOURCE_STATE_DEPTH_WRITE: + case RESOURCE_STATE_RESOLVE_DEST: + UnbindTextureFromInput(pTex, pTex->GetD3D11Texture()); + break; + + case RESOURCE_STATE_SHADER_RESOURCE: + case RESOURCE_STATE_INPUT_ATTACHMENT: + UnbindTextureFromFramebuffer(pTex, false); + break; + + default: + UNEXPECTED("Unexpected attachment state ", GetResourceStateString(NewState)); + } + } + + CommitRenderTargets(); +} + +void DeviceContextD3D11Impl::EndSubpass() +{ +} + void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attribs) { TDeviceContextBase::BeginRenderPass(Attribs); - UNEXPECTED("Method not implemented"); + BeginSubpass(); + // Set the viewport to match the framebuffer size + SetViewports(1, nullptr, 0, 0); + + const auto& RPDesc = m_pActiveRenderPass->GetDesc(); + const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + + for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) + { + auto* pTexView = FBDesc.ppAttachments[att]; + if (pTexView == nullptr) + continue; + if (RPDesc.pAttachments[att].LoadOp == ATTACHMENT_LOAD_OP_CLEAR) + { + auto* pViewD3D11 = ValidatedCast(pTexView); + const auto FmtAttribs = GetTextureFormatAttribs(pTexView->GetDesc().Format); + VERIFY_EXPR(att < Attribs.ClearValueCount); + const auto& ClearValue = Attribs.pClearValues[att]; + if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH || + FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH_STENCIL) + { + auto* pd3d11DSV = static_cast(pViewD3D11->GetD3D11View()); + m_pd3d11DeviceContext->ClearDepthStencilView(pd3d11DSV, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, ClearValue.DepthStencil.Depth, ClearValue.DepthStencil.Stencil); + } + else + { + auto* pd3d11RTV = static_cast(pViewD3D11->GetD3D11View()); + m_pd3d11DeviceContext->ClearRenderTargetView(pd3d11RTV, ClearValue.Color); + } + } + } } void DeviceContextD3D11Impl::NextSubpass() { + EndSubpass(); TDeviceContextBase::NextSubpass(); - UNEXPECTED("Method not implemented"); + BeginSubpass(); } void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) { + EndSubpass(); TDeviceContextBase::EndRenderPass(UpdateResourceStates); - UNEXPECTED("Method not implemented"); + // Nothing needs to be done } -- cgit v1.2.3 From 9ed0f7e0e27a703c371b089f958f3908ab296948 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 7 Aug 2020 13:01:42 -0700 Subject: Reworked attachment state transitoins handling in D3D11 backend --- .../include/DeviceContextD3D11Impl.hpp | 3 - .../src/DeviceContextD3D11Impl.cpp | 94 ++++++++++++---------- 2 files changed, 50 insertions(+), 47 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index ba5cec2f..27671d52 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -305,9 +305,6 @@ private: /// Prepares for an indexed draw command __forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType); - /// Prepares for current subpass - void BeginSubpass(); - /// Ends current subpass void EndSubpass(); diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 7da0b98f..70887b10 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1636,48 +1636,6 @@ void DeviceContextD3D11Impl::SetRenderTargets(Uint32 Num } } -void DeviceContextD3D11Impl::BeginSubpass() -{ - VERIFY_EXPR(m_pActiveRenderPass); - const auto& RPDesc = m_pActiveRenderPass->GetDesc(); - VERIFY_EXPR(m_SubpassIndex < RPDesc.SubpassCount); - const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); - - for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) - { - auto* pTex = ValidatedCast(FBDesc.ppAttachments[att]->GetTexture()); - if (pTex == nullptr) - continue; - - const auto NewState = m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex, att); - const auto PrevState = m_SubpassIndex > 0 ? - m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex - 1, att) : - RPDesc.pAttachments[att].InitialState; - - if (NewState == PrevState) - continue; - - switch (NewState) - { - case RESOURCE_STATE_RENDER_TARGET: - case RESOURCE_STATE_DEPTH_WRITE: - case RESOURCE_STATE_RESOLVE_DEST: - UnbindTextureFromInput(pTex, pTex->GetD3D11Texture()); - break; - - case RESOURCE_STATE_SHADER_RESOURCE: - case RESOURCE_STATE_INPUT_ATTACHMENT: - UnbindTextureFromFramebuffer(pTex, false); - break; - - default: - UNEXPECTED("Unexpected attachment state ", GetResourceStateString(NewState)); - } - } - - CommitRenderTargets(); -} - void DeviceContextD3D11Impl::EndSubpass() { } @@ -1685,13 +1643,17 @@ void DeviceContextD3D11Impl::EndSubpass() void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attribs) { TDeviceContextBase::BeginRenderPass(Attribs); - BeginSubpass(); + // BeginRenderPass() transitions resources to required states + + CommitRenderTargets(); + // Set the viewport to match the framebuffer size SetViewports(1, nullptr, 0, 0); const auto& RPDesc = m_pActiveRenderPass->GetDesc(); const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + // Clear attachments for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) { auto* pTexView = FBDesc.ppAttachments[att]; @@ -1721,8 +1683,52 @@ void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attri void DeviceContextD3D11Impl::NextSubpass() { EndSubpass(); + + VERIFY_EXPR(m_pActiveRenderPass); + const auto& RPDesc = m_pActiveRenderPass->GetDesc(); + VERIFY_EXPR(m_SubpassIndex + 1 < RPDesc.SubpassCount); + const auto& Subpass = RPDesc.pSubpasses[m_SubpassIndex + 1]; + const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + + // Unbind these attachments that will be used for output by the next subpass. + // There is no need to unbind textures from output as the new subpass atachments + // will be set as render target/depth stencil anyway, so these that can be used for + // input will be unbound. + + auto UnbindAttachmentFromInput = [&](const AttachmentReference& AttachmentRef) // + { + if (AttachmentRef.AttachmentIndex != ATTACHMENT_UNUSED) + { + auto CurrAttachmentState = m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex, AttachmentRef.AttachmentIndex); + if (CurrAttachmentState == RESOURCE_STATE_SHADER_RESOURCE || CurrAttachmentState == RESOURCE_STATE_INPUT_ATTACHMENT) + { + if (auto* pTexView = FBDesc.ppAttachments[AttachmentRef.AttachmentIndex]) + { + auto* pTexD3D11 = ValidatedCast(pTexView->GetTexture()); + if ((pTexD3D11->GetDesc().BindFlags & (BIND_SHADER_RESOURCE | BIND_INPUT_ATTACHMENT)) != 0) + UnbindResourceView(m_CommittedD3D11SRVs, m_CommittedD3D11SRVResources, m_NumCommittedSRVs, pTexD3D11->GetD3D11Texture(), SetSRVMethods); + } + } + } + }; + + for (Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt) + { + UnbindAttachmentFromInput(Subpass.pRenderTargetAttachments[rt]); + if (Subpass.pResolveAttachments != nullptr) + { + UnbindAttachmentFromInput(Subpass.pResolveAttachments[rt]); + } + } + + if (Subpass.pDepthStencilAttachment != nullptr) + { + UnbindAttachmentFromInput(*Subpass.pDepthStencilAttachment); + } + TDeviceContextBase::NextSubpass(); - BeginSubpass(); + + CommitRenderTargets(); } void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) -- cgit v1.2.3 From 05664a1b9e6e528a5b1d40e89cf121bc21739a1a Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 7 Aug 2020 13:41:19 -0700 Subject: Implemented render pass resolve in D3D11 backend, added test --- .../src/DeviceContextD3D11Impl.cpp | 52 +++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 70887b10..ec985a1b 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1638,6 +1638,38 @@ void DeviceContextD3D11Impl::SetRenderTargets(Uint32 Num void DeviceContextD3D11Impl::EndSubpass() { + VERIFY_EXPR(m_pActiveRenderPass); + const auto& RPDesc = m_pActiveRenderPass->GetDesc(); + VERIFY_EXPR(m_SubpassIndex < RPDesc.SubpassCount); + const auto& Subpass = RPDesc.pSubpasses[m_SubpassIndex]; + const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + + if (Subpass.pResolveAttachments != nullptr) + { + for (Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt) + { + const auto& RslvAttachmentRef = Subpass.pResolveAttachments[rt]; + if (RslvAttachmentRef.AttachmentIndex != ATTACHMENT_UNUSED) + { + const auto& RTAttachmentRef = Subpass.pRenderTargetAttachments[rt]; + VERIFY_EXPR(RTAttachmentRef.AttachmentIndex != ATTACHMENT_UNUSED); + auto* pSrcView = FBDesc.ppAttachments[RTAttachmentRef.AttachmentIndex]; + auto* pDstView = FBDesc.ppAttachments[RslvAttachmentRef.AttachmentIndex]; + auto* pSrcTexD3D11 = ValidatedCast(pSrcView->GetTexture()); + auto* pDstTexD3D11 = ValidatedCast(pDstView->GetTexture()); + + const auto& SrcViewDesc = pSrcView->GetDesc(); + const auto& DstViewDesc = pDstView->GetDesc(); + const auto& SrcTexDesc = pSrcTexD3D11->GetDesc(); + const auto& DstTexDesc = pDstTexD3D11->GetDesc(); + + auto DXGIFmt = TexFormatToDXGI_Format(RPDesc.pAttachments[RTAttachmentRef.AttachmentIndex].Format); + auto SrcSubresIndex = D3D11CalcSubresource(SrcViewDesc.MostDetailedMip, SrcViewDesc.FirstArraySlice, SrcTexDesc.MipLevels); + auto DstSubresIndex = D3D11CalcSubresource(DstViewDesc.MostDetailedMip, DstViewDesc.FirstArraySlice, DstTexDesc.MipLevels); + m_pd3d11DeviceContext->ResolveSubresource(pDstTexD3D11->GetD3D11Texture(), DstSubresIndex, pSrcTexD3D11->GetD3D11Texture(), SrcSubresIndex, DXGIFmt); + } + } + } } void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attribs) @@ -1687,8 +1719,8 @@ void DeviceContextD3D11Impl::NextSubpass() VERIFY_EXPR(m_pActiveRenderPass); const auto& RPDesc = m_pActiveRenderPass->GetDesc(); VERIFY_EXPR(m_SubpassIndex + 1 < RPDesc.SubpassCount); - const auto& Subpass = RPDesc.pSubpasses[m_SubpassIndex + 1]; - const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + const auto& NextSubpass = RPDesc.pSubpasses[m_SubpassIndex + 1]; + const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); // Unbind these attachments that will be used for output by the next subpass. // There is no need to unbind textures from output as the new subpass atachments @@ -1705,25 +1737,24 @@ void DeviceContextD3D11Impl::NextSubpass() if (auto* pTexView = FBDesc.ppAttachments[AttachmentRef.AttachmentIndex]) { auto* pTexD3D11 = ValidatedCast(pTexView->GetTexture()); - if ((pTexD3D11->GetDesc().BindFlags & (BIND_SHADER_RESOURCE | BIND_INPUT_ATTACHMENT)) != 0) - UnbindResourceView(m_CommittedD3D11SRVs, m_CommittedD3D11SRVResources, m_NumCommittedSRVs, pTexD3D11->GetD3D11Texture(), SetSRVMethods); + UnbindResourceView(m_CommittedD3D11SRVs, m_CommittedD3D11SRVResources, m_NumCommittedSRVs, pTexD3D11->GetD3D11Texture(), SetSRVMethods); } } } }; - for (Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt) + for (Uint32 rt = 0; rt < NextSubpass.RenderTargetAttachmentCount; ++rt) { - UnbindAttachmentFromInput(Subpass.pRenderTargetAttachments[rt]); - if (Subpass.pResolveAttachments != nullptr) + UnbindAttachmentFromInput(NextSubpass.pRenderTargetAttachments[rt]); + if (NextSubpass.pResolveAttachments != nullptr) { - UnbindAttachmentFromInput(Subpass.pResolveAttachments[rt]); + UnbindAttachmentFromInput(NextSubpass.pResolveAttachments[rt]); } } - if (Subpass.pDepthStencilAttachment != nullptr) + if (NextSubpass.pDepthStencilAttachment != nullptr) { - UnbindAttachmentFromInput(*Subpass.pDepthStencilAttachment); + UnbindAttachmentFromInput(*NextSubpass.pDepthStencilAttachment); } TDeviceContextBase::NextSubpass(); @@ -1735,7 +1766,6 @@ void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) { EndSubpass(); TDeviceContextBase::EndRenderPass(UpdateResourceStates); - // Nothing needs to be done } -- cgit v1.2.3 From aef7f38b073ce6e7fdb00544419b7f3291508017 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 7 Aug 2020 14:56:01 -0700 Subject: D3D11 backend: udpating resource states when calling NextSubpass --- .../include/DeviceContextD3D11Impl.hpp | 2 ++ .../src/DeviceContextD3D11Impl.cpp | 24 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index 27671d52..4df12602 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -390,6 +390,8 @@ private: /// Strong references to committed D3D11 shaders CComPtr m_CommittedD3DShaders[NumShaderTypes]; + RESOURCE_STATE_TRANSITION_MODE m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE; + const Uint32 m_DebugFlags; FixedBlockMemoryAllocator m_CmdListAllocator; diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index ec985a1b..a40aa77a 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1430,7 +1430,7 @@ void DeviceContextD3D11Impl::UnbindTextureFromInput(TextureBaseD3D11* pTexture, if (!pTexture) return; UnbindResourceView(m_CommittedD3D11SRVs, m_CommittedD3D11SRVResources, m_NumCommittedSRVs, pd3d11Resource, SetSRVMethods); - pTexture->ClearState(RESOURCE_STATE_SHADER_RESOURCE); + pTexture->ClearState(RESOURCE_STATE_SHADER_RESOURCE | RESOURCE_STATE_INPUT_ATTACHMENT); } void DeviceContextD3D11Impl::UnbindBufferFromInput(BufferD3D11Impl* pBuffer, ID3D11Resource* pd3d11Buffer) @@ -1677,6 +1677,8 @@ void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attri TDeviceContextBase::BeginRenderPass(Attribs); // BeginRenderPass() transitions resources to required states + m_RenderPassAttachmentsTransitionMode = Attribs.StateTransitionMode; + CommitRenderTargets(); // Set the viewport to match the framebuffer size @@ -1759,6 +1761,25 @@ void DeviceContextD3D11Impl::NextSubpass() TDeviceContextBase::NextSubpass(); + if (m_RenderPassAttachmentsTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION) + { + for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) + { + auto* pTexView = ValidatedCast(FBDesc.ppAttachments[att]); + if (pTexView == nullptr) + continue; + + auto* pTex = ValidatedCast(pTexView->GetTexture()); + if (pTex->IsInKnownState()) + { + auto CurrState = m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex, att); + if ((CurrState & RESOURCE_STATE_INPUT_ATTACHMENT) != 0) + CurrState |= RESOURCE_STATE_SHADER_RESOURCE; + pTex->SetState(CurrState); + } + } + } + CommitRenderTargets(); } @@ -1766,6 +1787,7 @@ void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) { EndSubpass(); TDeviceContextBase::EndRenderPass(UpdateResourceStates); + m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE; } -- cgit v1.2.3 From fd6ecbc3e52569119c4e0ff30236bd23f2757737 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 8 Aug 2020 16:48:40 -0700 Subject: Implemented unified render pass attachment state updates within subpasses and after the render pass ends --- .../include/DeviceContextD3D11Impl.hpp | 4 +-- .../src/DeviceContextD3D11Impl.cpp | 33 ++++------------------ 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index 4df12602..6da56a4f 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -131,7 +131,7 @@ public: virtual void DILIGENT_CALL_TYPE NextSubpass() override final; /// Implementation of IDeviceContext::EndRenderPass() in Direct3D11 backend. - virtual void DILIGENT_CALL_TYPE EndRenderPass(bool UpdateResourceStates) override final; + virtual void DILIGENT_CALL_TYPE EndRenderPass() override final; /// Implementation of IDeviceContext::Draw() in Direct3D11 backend. virtual void DILIGENT_CALL_TYPE Draw(const DrawAttribs& Attribs) override final; @@ -390,8 +390,6 @@ private: /// Strong references to committed D3D11 shaders CComPtr m_CommittedD3DShaders[NumShaderTypes]; - RESOURCE_STATE_TRANSITION_MODE m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE; - const Uint32 m_DebugFlags; FixedBlockMemoryAllocator m_CmdListAllocator; diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index a40aa77a..748723f5 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -261,7 +261,7 @@ void DeviceContextD3D11Impl::TransitionAndCommitShaderResources(IPipelineState* { if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_UNORDERED_ACCESS)) { - if (pTexture->CheckState(RESOURCE_STATE_SHADER_RESOURCE)) + if (pTexture->CheckAnyState(RESOURCE_STATE_SHADER_RESOURCE | RESOURCE_STATE_INPUT_ATTACHMENT)) UnbindTextureFromInput(pTexture, UAVRes.pd3d11Resource); pTexture->SetState(RESOURCE_STATE_UNORDERED_ACCESS); } @@ -482,7 +482,7 @@ void DeviceContextD3D11Impl::TransitionAndCommitShaderResources(IPipelineState* { if (auto* pTexture = ValidatedCast(SRVRes.pTexture)) { - if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_SHADER_RESOURCE)) + if (pTexture->IsInKnownState() && !pTexture->CheckAnyState(RESOURCE_STATE_SHADER_RESOURCE | RESOURCE_STATE_INPUT_ATTACHMENT)) { if (pTexture->CheckState(RESOURCE_STATE_UNORDERED_ACCESS)) { @@ -521,7 +521,8 @@ void DeviceContextD3D11Impl::TransitionAndCommitShaderResources(IPipelineState* VERIFY_EXPR(CommitResources); if (const auto* pTexture = ValidatedCast(SRVRes.pTexture)) { - if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_SHADER_RESOURCE)) + if (pTexture->IsInKnownState() && + !(pTexture->CheckState(RESOURCE_STATE_SHADER_RESOURCE) || m_pActiveRenderPass != nullptr && pTexture->CheckState(RESOURCE_STATE_INPUT_ATTACHMENT))) { LOG_ERROR_MESSAGE("Texture '", pTexture->GetDesc().Name, "' has not been transitioned to Shader Resource state. Call TransitionShaderResources(), use RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode or explicitly transition the texture to required state."); } @@ -1677,8 +1678,6 @@ void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attri TDeviceContextBase::BeginRenderPass(Attribs); // BeginRenderPass() transitions resources to required states - m_RenderPassAttachmentsTransitionMode = Attribs.StateTransitionMode; - CommitRenderTargets(); // Set the viewport to match the framebuffer size @@ -1761,33 +1760,13 @@ void DeviceContextD3D11Impl::NextSubpass() TDeviceContextBase::NextSubpass(); - if (m_RenderPassAttachmentsTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION) - { - for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) - { - auto* pTexView = ValidatedCast(FBDesc.ppAttachments[att]); - if (pTexView == nullptr) - continue; - - auto* pTex = ValidatedCast(pTexView->GetTexture()); - if (pTex->IsInKnownState()) - { - auto CurrState = m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex, att); - if ((CurrState & RESOURCE_STATE_INPUT_ATTACHMENT) != 0) - CurrState |= RESOURCE_STATE_SHADER_RESOURCE; - pTex->SetState(CurrState); - } - } - } - CommitRenderTargets(); } -void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) +void DeviceContextD3D11Impl::EndRenderPass() { EndSubpass(); - TDeviceContextBase::EndRenderPass(UpdateResourceStates); - m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE; + TDeviceContextBase::EndRenderPass(); } -- cgit v1.2.3