summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-08-19 15:02:00 +0000
committerazhirnov <zh1dron@gmail.com>2020-08-19 15:02:00 +0000
commit0703251a71c8cea898358abb9ecb7460c8655718 (patch)
tree7f429c6e9871790fc9491c31bac0c1ca90e96873 /Graphics/GraphicsEngineD3D11
parentformatting (diff)
parentUpdated description of indirect draw/dispatch commands to specify the argumen... (diff)
downloadDiligentCore-0703251a71c8cea898358abb9ecb7460c8655718.tar.gz
DiligentCore-0703251a71c8cea898358abb9ecb7460c8655718.zip
Merge branch 'master' into mesh_shader
# Conflicts: # Graphics/GraphicsEngine/include/PipelineStateBase.hpp # Graphics/GraphicsEngine/interface/PipelineState.h # Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp # Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/CMakeLists.txt4
-rw-r--r--Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp17
-rw-r--r--Graphics/GraphicsEngineD3D11/include/FramebufferD3D11Impl.hpp54
-rw-r--r--Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp8
-rw-r--r--Graphics/GraphicsEngineD3D11/include/RenderPassD3D11Impl.hpp54
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp165
-rw-r--r--Graphics/GraphicsEngineD3D11/src/FramebufferD3D11Impl.cpp47
-rw-r--r--Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp28
-rw-r--r--Graphics/GraphicsEngineD3D11/src/RenderPassD3D11Impl.cpp47
9 files changed, 417 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineD3D11/CMakeLists.txt b/Graphics/GraphicsEngineD3D11/CMakeLists.txt
index 9ec7e370..ba6aeb46 100644
--- a/Graphics/GraphicsEngineD3D11/CMakeLists.txt
+++ b/Graphics/GraphicsEngineD3D11/CMakeLists.txt
@@ -14,9 +14,11 @@ set(INCLUDE
include/EngineD3D11Defines.h
include/pch.h
include/FenceD3D11Impl.hpp
+ include/FramebufferD3D11Impl.hpp
include/PipelineStateD3D11Impl.hpp
include/QueryD3D11Impl.hpp
include/RenderDeviceD3D11Impl.hpp
+ include/RenderPassD3D11Impl.hpp
include/SamplerD3D11Impl.hpp
include/ShaderD3D11Impl.hpp
include/ShaderResourceBindingD3D11Impl.hpp
@@ -58,10 +60,12 @@ set(SRC
src/DeviceContextD3D11Impl.cpp
src/EngineFactoryD3D11.cpp
src/FenceD3D11Impl.cpp
+ src/FramebufferD3D11Impl.cpp
src/GUIDDef.cpp
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/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp
index 5230b833..635f7603 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.
@@ -122,6 +124,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.
@@ -298,6 +309,8 @@ private:
/// Prepares for an indexed draw command
__forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType);
+ /// Ends current subpass
+ void EndSubpass();
template <bool TransitionResources,
bool CommitResources>
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<IFramebuffer, RenderDeviceD3D11Impl>
+{
+public:
+ using TFramebufferBase = FramebufferBase<IFramebuffer, RenderDeviceD3D11Impl>;
+
+ 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 0daef6b3..f041806c 100644
--- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp
@@ -81,6 +81,14 @@ 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 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/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<IRenderPass, RenderDeviceD3D11Impl>
+{
+public:
+ using TRenderPassBase = RenderPassBase<IRenderPass, RenderDeviceD3D11Impl>;
+
+ RenderPassD3D11Impl(IReferenceCounters* pRefCounters,
+ RenderDeviceD3D11Impl* pDevice,
+ const RenderPassDesc& Desc);
+ ~RenderPassD3D11Impl();
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
index 78814200..9e72ce71 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<TextureBaseD3D11>(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<TextureBaseD3D11>(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.");
}
@@ -627,6 +628,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<true, false>(pPipelineState, pShaderResourceBinding, false);
}
@@ -965,6 +972,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();
}
@@ -1429,7 +1441,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)
@@ -1581,6 +1593,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)
@@ -1627,6 +1647,139 @@ 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<TextureBaseD3D11>(pSrcView->GetTexture());
+ auto* pDstTexD3D11 = ValidatedCast<TextureBaseD3D11>(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)
+{
+ TDeviceContextBase::BeginRenderPass(Attribs);
+ // 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];
+ if (pTexView == nullptr)
+ continue;
+ if (RPDesc.pAttachments[att].LoadOp == ATTACHMENT_LOAD_OP_CLEAR)
+ {
+ auto* pViewD3D11 = ValidatedCast<TextureViewD3D11Impl>(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<ID3D11DepthStencilView*>(pViewD3D11->GetD3D11View());
+ m_pd3d11DeviceContext->ClearDepthStencilView(pd3d11DSV, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, ClearValue.DepthStencil.Depth, ClearValue.DepthStencil.Stencil);
+ }
+ else
+ {
+ auto* pd3d11RTV = static_cast<ID3D11RenderTargetView*>(pViewD3D11->GetD3D11View());
+ m_pd3d11DeviceContext->ClearRenderTargetView(pd3d11RTV, ClearValue.Color);
+ }
+ }
+ }
+}
+
+void DeviceContextD3D11Impl::NextSubpass()
+{
+ EndSubpass();
+
+ VERIFY_EXPR(m_pActiveRenderPass);
+ const auto& RPDesc = m_pActiveRenderPass->GetDesc();
+ VERIFY_EXPR(m_SubpassIndex + 1 < RPDesc.SubpassCount);
+ 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
+ // 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<TextureBaseD3D11>(pTexView->GetTexture());
+ UnbindResourceView(m_CommittedD3D11SRVs, m_CommittedD3D11SRVResources, m_NumCommittedSRVs, pTexD3D11->GetD3D11Texture(), SetSRVMethods);
+ }
+ }
+ }
+ };
+
+ for (Uint32 rt = 0; rt < NextSubpass.RenderTargetAttachmentCount; ++rt)
+ {
+ UnbindAttachmentFromInput(NextSubpass.pRenderTargetAttachments[rt]);
+ if (NextSubpass.pResolveAttachments != nullptr)
+ {
+ UnbindAttachmentFromInput(NextSubpass.pResolveAttachments[rt]);
+ }
+ }
+
+ if (NextSubpass.pDepthStencilAttachment != nullptr)
+ {
+ UnbindAttachmentFromInput(*NextSubpass.pDepthStencilAttachment);
+ }
+
+ TDeviceContextBase::NextSubpass();
+
+ CommitRenderTargets();
+}
+
+void DeviceContextD3D11Impl::EndRenderPass()
+{
+ EndSubpass();
+ TDeviceContextBase::EndRenderPass();
+}
+
+
template <typename TD3D11ResourceType, typename TSetD3D11ResMethodType>
void SetD3D11ResourcesHelper(ID3D11DeviceContext* pDeviceCtx,
TSetD3D11ResMethodType SetD3D11ResMethod,
@@ -1712,6 +1865,8 @@ void DeviceContextD3D11Impl::ReleaseCommittedShaderResources()
void DeviceContextD3D11Impl::FinishCommandList(ICommandList** ppCommandList)
{
+ VERIFY(m_pActiveRenderPass == nullptr, "Finishing command list inside an active render pass.");
+
CComPtr<ID3D11CommandList> pd3d11CmdList;
m_pd3d11DeviceContext->FinishCommandList(
FALSE, // A Boolean flag that determines whether the runtime saves deferred context state before it
@@ -1954,6 +2109,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];
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 4647ba13..c8c26d80 100644
--- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
@@ -40,6 +40,8 @@
#include "ShaderResourceBindingD3D11Impl.hpp"
#include "FenceD3D11Impl.hpp"
#include "QueryD3D11Impl.hpp"
+#include "RenderPassD3D11Impl.hpp"
+#include "FramebufferD3D11Impl.hpp"
#include "EngineMemory.h"
namespace Diligent
@@ -97,7 +99,9 @@ RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCo
sizeof(PipelineStateD3D11Impl),
sizeof(ShaderResourceBindingD3D11Impl),
sizeof(FenceD3D11Impl),
- sizeof(QueryD3D11Impl)
+ sizeof(QueryD3D11Impl),
+ sizeof(RenderPassD3D11Impl),
+ sizeof(FramebufferD3D11Impl)
}
},
m_EngineAttribs{EngineAttribs},
@@ -372,6 +376,28 @@ 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->QueryInterface(IID_RenderPass, reinterpret_cast<IObject**>(ppRenderPass));
+ OnCreateDeviceObject(pRenderPassD3D11);
+ });
+}
+
+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<IObject**>(ppFramebuffer));
+ OnCreateDeviceObject(pFramebufferD3D11);
+ });
+}
+
void RenderDeviceD3D11Impl::IdleGPU()
{
if (auto pImmediateCtx = m_wpImmediateContext.Lock())
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