diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-08-01 03:51:27 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-08-02 19:21:41 +0000 |
| commit | 910f9f8c26b5d9db1dfa0437030d10951486ee3c (patch) | |
| tree | 84d8d53ad67ea7a3e1c4128726dbebe785619f87 /Graphics/GraphicsEngine | |
| parent | PipelineStateVkImpl: creating implicit IRenderPass object instead of Vulkan r... (diff) | |
| download | DiligentCore-910f9f8c26b5d9db1dfa0437030d10951486ee3c.tar.gz DiligentCore-910f9f8c26b5d9db1dfa0437030d10951486ee3c.zip | |
Added pRenderPass and SubpassIndex members to GraphicsPipelineDesc struct
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/PipelineStateBase.hpp | 70 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/APIInfo.h | 2 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/PipelineState.h | 44 |
3 files changed, 87 insertions, 29 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp index dbb974b2..109b6ce4 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp @@ -69,6 +69,8 @@ public: TDeviceObjectBase{pRefCounters, pDevice, PSODesc, bIsDeviceInternal}, m_NumShaders{0} { + ValidateDesc(); + const auto& SrcLayout = PSODesc.ResourceLayout; size_t StringPoolSize = 0; if (SrcLayout.Variables != nullptr) @@ -187,6 +189,8 @@ public: DEV_CHECK_ERR(m_NumShaders > 0, "There must be at least one shader in the Pipeline State"); + m_pRenderPass = PSODesc.GraphicsPipeline.pRenderPass; + for (Uint32 rt = GraphicsPipeline.NumRenderTargets; rt < _countof(GraphicsPipeline.RTVFormats); ++rt) { auto RTVFmt = GraphicsPipeline.RTVFormats[rt]; @@ -395,13 +399,52 @@ protected: size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout private: +#define LOG_PSO_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Description of ", (this->m_Desc.IsComputePipeline ? "compute" : "graphics"), " PSO '", this->m_Desc.Name, "' is invalid: ", ##__VA_ARGS__) + + void ValidateDesc() const + { + if (this->m_Desc.IsComputePipeline) + { + if (this->m_Desc.GraphicsPipeline.pRenderPass != nullptr) + { + LOG_PSO_ERROR_AND_THROW("GraphicsPipeline.pRenderPass must be null"); + } + } + else + { + const auto& GraphicsPipeline = this->m_Desc.GraphicsPipeline; + if (GraphicsPipeline.pRenderPass != nullptr) + { + if (GraphicsPipeline.NumRenderTargets != 0) + LOG_PSO_ERROR_AND_THROW("NumRenderTargets must be 0 when explicit render pass is used"); + if (GraphicsPipeline.DSVFormat != TEX_FORMAT_UNKNOWN) + LOG_PSO_ERROR_AND_THROW("DSVFormat must be TEX_FORMAT_UNKNOWN when explicit render pass is used"); + + for (Uint32 rt = 0; rt < MAX_RENDER_TARGETS; ++rt) + { + if (GraphicsPipeline.RTVFormats[rt] != TEX_FORMAT_UNKNOWN) + LOG_PSO_ERROR_AND_THROW("RTVFormats[", rt, "] must be TEX_FORMAT_UNKNOWN when explicit render pass is used"); + } + + const auto& RPDesc = GraphicsPipeline.pRenderPass->GetDesc(); + if (GraphicsPipeline.SubpassIndex >= RPDesc.SubpassCount) + LOG_PSO_ERROR_AND_THROW("Subpass index (", Uint32{GraphicsPipeline.SubpassIndex}, ") exceeds the number of subpasses (", Uint32{RPDesc.SubpassCount}, ") in render pass '", RPDesc.Name, "'"); + } + else + { + if (GraphicsPipeline.SubpassIndex != 0) + LOG_PSO_ERROR_AND_THROW("Subpass index (", Uint32{GraphicsPipeline.SubpassIndex}, ") must be 0 when explicit render pass is not used"); + } + } + } + void CheckRasterizerStateDesc() const { const auto& RSDesc = this->m_Desc.GraphicsPipeline.RasterizerDesc; if (RSDesc.FillMode == FILL_MODE_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: RasterizerDesc.FillMode must not be FILL_MODE_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("RasterizerDesc.FillMode must not be FILL_MODE_UNDEFINED"); if (RSDesc.CullMode == CULL_MODE_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: RasterizerDesc.CullMode must not be CULL_MODE_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("RasterizerDesc.CullMode must not be CULL_MODE_UNDEFINED"); } void CheckAndCorrectDepthStencilDesc() @@ -410,7 +453,7 @@ private: if (DSSDesc.DepthFunc == COMPARISON_FUNC_UNKNOWN) { if (DSSDesc.DepthEnable) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: DepthStencilDesc.DepthFunc must not be COMPARISON_FUNC_UNKNOWN when depth is enabled"); + LOG_PSO_ERROR_AND_THROW("DepthStencilDesc.DepthFunc must not be COMPARISON_FUNC_UNKNOWN when depth is enabled"); else DSSDesc.DepthFunc = DepthStencilStateDesc{}.DepthFunc; } @@ -420,13 +463,13 @@ private: if (DSSDesc.StencilEnable) { if (OpDesc.StencilFailOp == STENCIL_OP_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: DepthStencilDesc.", FaceName, ".StencilFailOp must not be STENCIL_OP_UNDEFINED when stencil is enabled"); + LOG_PSO_ERROR_AND_THROW("DepthStencilDesc.", FaceName, ".StencilFailOp must not be STENCIL_OP_UNDEFINED when stencil is enabled"); if (OpDesc.StencilDepthFailOp == STENCIL_OP_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: DepthStencilDesc.", FaceName, ".StencilDepthFailOp must not be STENCIL_OP_UNDEFINED when stencil is enabled"); + LOG_PSO_ERROR_AND_THROW("DepthStencilDesc.", FaceName, ".StencilDepthFailOp must not be STENCIL_OP_UNDEFINED when stencil is enabled"); if (OpDesc.StencilPassOp == STENCIL_OP_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: DepthStencilDesc.", FaceName, ".StencilPassOp must not be STENCIL_OP_UNDEFINED when stencil is enabled"); + LOG_PSO_ERROR_AND_THROW("DepthStencilDesc.", FaceName, ".StencilPassOp must not be STENCIL_OP_UNDEFINED when stencil is enabled"); if (OpDesc.StencilFunc == COMPARISON_FUNC_UNKNOWN) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: DepthStencilDesc.", FaceName, ".StencilFunc must not be COMPARISON_FUNC_UNKNOWN when stencil is enabled"); + LOG_PSO_ERROR_AND_THROW("DepthStencilDesc.", FaceName, ".StencilFunc must not be COMPARISON_FUNC_UNKNOWN when stencil is enabled"); } else { @@ -457,18 +500,18 @@ private: if (BlendEnable) { if (RTDesc.SrcBlend == BLEND_FACTOR_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: BlendDesc.RenderTargets[", rt, "].SrcBlend must not be BLEND_FACTOR_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("BlendDesc.RenderTargets[", rt, "].SrcBlend must not be BLEND_FACTOR_UNDEFINED"); if (RTDesc.DestBlend == BLEND_FACTOR_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: BlendDesc.RenderTargets[", rt, "].DestBlend must not be BLEND_FACTOR_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("BlendDesc.RenderTargets[", rt, "].DestBlend must not be BLEND_FACTOR_UNDEFINED"); if (RTDesc.BlendOp == BLEND_OPERATION_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: BlendDesc.RenderTargets[", rt, "].BlendOp must not be BLEND_OPERATION_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("BlendDesc.RenderTargets[", rt, "].BlendOp must not be BLEND_OPERATION_UNDEFINED"); if (RTDesc.SrcBlendAlpha == BLEND_FACTOR_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: BlendDesc.RenderTargets[", rt, "].SrcBlendAlpha must not be BLEND_FACTOR_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("BlendDesc.RenderTargets[", rt, "].SrcBlendAlpha must not be BLEND_FACTOR_UNDEFINED"); if (RTDesc.DestBlendAlpha == BLEND_FACTOR_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: BlendDesc.RenderTargets[", rt, "].DestBlendAlpha must not be BLEND_FACTOR_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("BlendDesc.RenderTargets[", rt, "].DestBlendAlpha must not be BLEND_FACTOR_UNDEFINED"); if (RTDesc.BlendOpAlpha == BLEND_OPERATION_UNDEFINED) - LOG_ERROR_AND_THROW("Description of graphics PSO '", this->m_Desc.Name, "' is invalid: BlendDesc.RenderTargets[", rt, "].BlendOpAlpha must not be BLEND_OPERATION_UNDEFINED"); + LOG_PSO_ERROR_AND_THROW("BlendDesc.RenderTargets[", rt, "].BlendOpAlpha must not be BLEND_OPERATION_UNDEFINED"); } else { @@ -491,6 +534,7 @@ private: RTDesc.LogicOp = RenderTargetBlendDesc{}.LogicOp; } } +#undef LOG_PSO_ERROR_AND_THROW }; } // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index c355b315..59d3bd30 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -30,7 +30,7 @@ /// \file /// Diligent API information -#define DILIGENT_API_VERSION 240064 +#define DILIGENT_API_VERSION 240065 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 4079a66a..3de6f02d 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -151,24 +151,24 @@ typedef struct PipelineResourceLayoutDesc PipelineResourceLayoutDesc; /// This structure describes the graphics pipeline state and is part of the PipelineStateDesc structure. struct GraphicsPipelineDesc { - /// Vertex shader to be used with the pipeline + /// Vertex shader to be used with the pipeline. IShader* pVS DEFAULT_INITIALIZER(nullptr); - /// Pixel shader to be used with the pipeline + /// Pixel shader to be used with the pipeline. IShader* pPS DEFAULT_INITIALIZER(nullptr); - /// Domain shader to be used with the pipeline + /// Domain shader to be used with the pipeline. IShader* pDS DEFAULT_INITIALIZER(nullptr); - /// Hull shader to be used with the pipeline + /// Hull shader to be used with the pipeline. IShader* pHS DEFAULT_INITIALIZER(nullptr); - /// Geometry shader to be used with the pipeline + /// Geometry shader to be used with the pipeline. IShader* pGS DEFAULT_INITIALIZER(nullptr); //D3D12_STREAM_OUTPUT_DESC StreamOutput; - /// Blend state description + /// Blend state description. BlendStateDesc BlendDesc; /// 32-bit sample mask that determines which samples get updated @@ -177,34 +177,48 @@ struct GraphicsPipelineDesc /// depend on whether an application uses multisample render targets. Uint32 SampleMask DEFAULT_INITIALIZER(0xFFFFFFFF); - /// Rasterizer state description + /// Rasterizer state description. RasterizerStateDesc RasterizerDesc; - /// Depth-stencil state description + /// Depth-stencil state description. DepthStencilStateDesc DepthStencilDesc; - /// Input layout + /// Input layout. InputLayoutDesc InputLayout; //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue; - /// Primitive topology type + /// Primitive topology type. PRIMITIVE_TOPOLOGY PrimitiveTopology DEFAULT_INITIALIZER(PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); - /// Number of viewports used by this pipeline + /// The number of viewports used by this pipeline Uint8 NumViewports DEFAULT_INITIALIZER(1); - /// Number of render targets in the RTVFormats member + /// The number of render targets in the RTVFormats array. + /// Must be 0 when pRenderPass is not null. Uint8 NumRenderTargets DEFAULT_INITIALIZER(0); - /// Render target formats + /// When pRenderPass is not null, the subpass + /// index within the render pass. + /// When pRenderPass is null, this member must be 0. + Uint8 SubpassIndex DEFAULT_INITIALIZER(0); + + /// Render target formats. + /// All formats must be TEX_FORMAT_UNKNOWN when pRenderPass is not null. TEXTURE_FORMAT RTVFormats[8] DEFAULT_INITIALIZER({}); - /// Depth-stencil format + /// Depth-stencil format. + /// Must be TEX_FORMAT_UNKNOWN when pRenderPass is not null. TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); - /// Multisampling parameters + /// Multisampling parameters. SampleDesc SmplDesc; + /// Pointer to the render pass object. + + /// When non-null render pass is specified, NumRenderTargets must be 0, + /// and all RTV formats as well as DSV format must be TEX_FORMAT_UNKNOWN. + IRenderPass* pRenderPass DEFAULT_INITIALIZER(nullptr); + /// Node mask. Uint32 NodeMask DEFAULT_INITIALIZER(0); |
