summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-11-21 04:17:45 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-11-21 04:17:45 +0000
commitb455f877b27282b3235a26afdd78207ce48c8615 (patch)
tree1b4304599dea43c5f59cac08020573efaaef969e /Graphics/GraphicsEngine
parentCMake: enabled malloc scribble and malloc guard edges xcode scheme settings (diff)
downloadDiligentCore-b455f877b27282b3235a26afdd78207ce48c8615.tar.gz
DiligentCore-b455f877b27282b3235a26afdd78207ce48c8615.zip
DeviceContextBase: added m_FramebufferSamples member
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.hpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
index 4eebd683..ac56eac9 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
@@ -322,6 +322,8 @@ protected:
Uint32 m_FramebufferHeight = 0;
/// Number of array slices in the currently bound framebuffer
Uint32 m_FramebufferSlices = 0;
+ /// Number of samples in the currently bound framebuffer
+ Uint32 m_FramebufferSamples = 0;
/// Strong references to the bound depth stencil view.
/// Use final texture view implementation type to avoid virtual calls to AddRef()/Release()
@@ -598,6 +600,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
m_FramebufferWidth = 0;
m_FramebufferHeight = 0;
m_FramebufferSlices = 0;
+ m_FramebufferSamples = 0;
if (NumRenderTargets != m_NumBoundRenderTargets)
{
@@ -621,11 +624,12 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
// Use this RTV to set the render target size
if (m_FramebufferWidth == 0)
{
- auto* pTex = pRTView->GetTexture();
- const auto& TexDesc = pTex->GetDesc();
- m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
- m_FramebufferHeight = std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U);
- m_FramebufferSlices = RTVDesc.NumArraySlices;
+ auto* pTex = pRTView->GetTexture();
+ const auto& TexDesc = pTex->GetDesc();
+ m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
+ m_FramebufferHeight = std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U);
+ m_FramebufferSlices = RTVDesc.NumArraySlices;
+ m_FramebufferSamples = TexDesc.SampleCount;
}
else
{
@@ -637,6 +641,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
LOG_ERROR_MESSAGE("Render target height (", std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
if (m_FramebufferSlices != RTVDesc.NumArraySlices)
LOG_ERROR_MESSAGE("Number of slices (", RTVDesc.NumArraySlices, ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the number of slices in previously bound render targets (", m_FramebufferSlices, ")");
+ if (m_FramebufferSamples != TexDesc.SampleCount)
+ LOG_ERROR_MESSAGE("Sample count (", TexDesc.SampleCount, ") of RTV '", RTVDesc.Name, "' is inconsistent with the sample count of previously bound render targets (", m_FramebufferSamples, ")");
#endif
}
}
@@ -662,11 +668,12 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
// Use depth stencil size to set render target size
if (m_FramebufferWidth == 0)
{
- auto* pTex = pDepthStencil->GetTexture();
- const auto& TexDesc = pTex->GetDesc();
- m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
- m_FramebufferHeight = std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U);
- m_FramebufferSlices = DSVDesc.NumArraySlices;
+ auto* pTex = pDepthStencil->GetTexture();
+ const auto& TexDesc = pTex->GetDesc();
+ m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
+ m_FramebufferHeight = std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U);
+ m_FramebufferSlices = DSVDesc.NumArraySlices;
+ m_FramebufferSamples = TexDesc.SampleCount;
}
else
{
@@ -678,6 +685,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
LOG_ERROR_MESSAGE("Depth-stencil target height (", std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
if (m_FramebufferSlices != DSVDesc.NumArraySlices)
LOG_ERROR_MESSAGE("Number of slices (", DSVDesc.NumArraySlices, ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the number of slices in previously bound render targets (", m_FramebufferSlices, ")");
+ if (m_FramebufferSamples != TexDesc.SampleCount)
+ LOG_ERROR_MESSAGE("Sample count (", TexDesc.SampleCount, ") of DSV '", DSVDesc.Name, "' is inconsistent with the sample count of previously bound render targets (", m_FramebufferSamples, ")");
#endif
}
}
@@ -689,7 +698,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
}
- VERIFY_EXPR(m_FramebufferWidth > 0 && m_FramebufferHeight > 0 && m_FramebufferSlices > 0);
+ VERIFY_EXPR(m_FramebufferWidth > 0 && m_FramebufferHeight > 0 && m_FramebufferSlices > 0 && m_FramebufferSamples > 0);
return bBindRenderTargets;
}
@@ -705,6 +714,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetSubpassRe
VERIFY_EXPR(m_SubpassIndex < RPDesc.SubpassCount);
const auto& Subpass = RPDesc.pSubpasses[m_SubpassIndex];
+ m_FramebufferSamples = 0;
+
ITextureView* ppRTVs[MAX_RENDER_TARGETS] = {};
ITextureView* pDSV = nullptr;
for (Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt)
@@ -714,6 +725,13 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetSubpassRe
{
VERIFY_EXPR(RTAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
ppRTVs[rt] = FBDesc.ppAttachments[RTAttachmentRef.AttachmentIndex];
+ if (ppRTVs[rt] != nullptr)
+ {
+ if (m_FramebufferSamples == 0)
+ m_FramebufferSamples = ppRTVs[rt]->GetTexture()->GetDesc().SampleCount;
+ else
+ DEV_CHECK_ERR(m_FramebufferSamples == ppRTVs[rt]->GetTexture()->GetDesc().SampleCount, "Inconsistent sample count");
+ }
}
}
@@ -724,6 +742,13 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetSubpassRe
{
VERIFY_EXPR(DSAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
pDSV = FBDesc.ppAttachments[DSAttachmentRef.AttachmentIndex];
+ if (pDSV != nullptr)
+ {
+ if (m_FramebufferSamples == 0)
+ m_FramebufferSamples = pDSV->GetTexture()->GetDesc().SampleCount;
+ else
+ DEV_CHECK_ERR(m_FramebufferSamples == pDSV->GetTexture()->GetDesc().SampleCount, "Inconsistent sample count");
+ }
}
}
bool BindRenderTargets = SetRenderTargets(Subpass.RenderTargetAttachmentCount, ppRTVs, pDSV);
@@ -732,6 +757,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetSubpassRe
m_FramebufferWidth = FBDesc.Width;
m_FramebufferHeight = FBDesc.Height;
m_FramebufferSlices = FBDesc.NumArraySlices;
+ VERIFY_EXPR(m_FramebufferSamples > 0);
return BindRenderTargets;
}
@@ -905,6 +931,7 @@ void DeviceContextBase<BaseInterface, ImplementationTraits>::ResetRenderTargets(
m_FramebufferWidth = 0;
m_FramebufferHeight = 0;
m_FramebufferSlices = 0;
+ m_FramebufferSamples = 0;
m_pBoundDepthStencil.Release();