diff options
| author | azhirnov <zh1dron@gmail.com> | 2020-11-25 15:58:54 +0000 |
|---|---|---|
| committer | azhirnov <zh1dron@gmail.com> | 2020-11-25 15:58:54 +0000 |
| commit | 05d6e525008853f21af92c29d5d943a7ebda8e27 (patch) | |
| tree | 8c37e704b4f14d9d2edf7cda61dd0493b36bf2d4 /Graphics/GraphicsEngine | |
| parent | Removed SWAP_CHAIN_USAGE_UNORDERED_ACCESS, fixed shader group checks (diff) | |
| parent | Updated volk submodule (diff) | |
| download | DiligentCore-05d6e525008853f21af92c29d5d943a7ebda8e27.tar.gz DiligentCore-05d6e525008853f21af92c29d5d943a7ebda8e27.zip | |
Merge branch 'master' into ray_tracing_2
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/DeviceContextBase.hpp | 49 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/BlendState.h | 3 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/GraphicsTypes.h | 19 |
3 files changed, 60 insertions, 11 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index 9735bce2..14a2d0eb 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -370,6 +370,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() @@ -660,6 +662,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar m_FramebufferWidth = 0; m_FramebufferHeight = 0; m_FramebufferSlices = 0; + m_FramebufferSamples = 0; if (NumRenderTargets != m_NumBoundRenderTargets) { @@ -683,11 +686,12 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar // 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 { @@ -699,6 +703,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar 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 } } @@ -724,11 +730,12 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar // 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 { @@ -740,6 +747,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar 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 } } @@ -751,7 +760,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar } - 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; } @@ -767,6 +776,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) @@ -776,6 +787,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"); + } } } @@ -786,6 +804,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); @@ -794,6 +819,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; } @@ -969,6 +995,7 @@ void DeviceContextBase<BaseInterface, ImplementationTraits>::ResetRenderTargets( m_FramebufferWidth = 0; m_FramebufferHeight = 0; m_FramebufferSlices = 0; + m_FramebufferSamples = 0; m_pBoundDepthStencil.Release(); diff --git a/Graphics/GraphicsEngine/interface/BlendState.h b/Graphics/GraphicsEngine/interface/BlendState.h index 2dd843ec..50feb22c 100644 --- a/Graphics/GraphicsEngine/interface/BlendState.h +++ b/Graphics/GraphicsEngine/interface/BlendState.h @@ -171,6 +171,9 @@ DILIGENT_TYPED_ENUM(BLEND_OPERATION, Int8) /// writable components of the render target DILIGENT_TYPED_ENUM(COLOR_MASK, Int8) { + /// Do not store any components. + COLOR_MASK_NONE = 0, + /// Allow data to be stored in the red component. COLOR_MASK_RED = 1, diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 736f7b3c..3ec5ee3f 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -2267,6 +2267,25 @@ struct EngineMtlCreateInfo DILIGENT_DERIVE(EngineCreateInfo) /// resource manager and then suballocate from this chunk in a lock-free /// fashion. DynamicHeapPageSize defines the size of this chunk. Uint32 DynamicHeapPageSize DEFAULT_INITIALIZER(4 << 20); + + + /// Indicates if device contexts should automatically manage autorelease pools. + + /// Metal API creates a lot of autoreleased objects. By default, the engine + /// will catch all these objects by pushing autorelease pools where necessary. + /// When UseAutoreleasePoolsInContexts is set to false, the engine will not use + /// autorelease pools in device contexts and the application will be responsible + /// for ensuring that all context commands are issued from within an autorelease + /// pool to avoid memory leaks. + /// + /// \note Autorelease pool is pushed by the first command of the device context + /// that needs it and popped by IDeviceContext::FinishFrame(). + /// The method must always be called from the same thread that + /// issued the context commands. + /// + /// Creating device objects will not leak memory even when + /// UseAutoreleasePoolsInContexts is set to false. + bool UseAutoreleasePoolsInContexts DEFAULT_INITIALIZER(true); }; typedef struct EngineMtlCreateInfo EngineMtlCreateInfo; |
