diff options
| author | azhirnov <zh1dron@gmail.com> | 2020-08-11 19:48:23 +0000 |
|---|---|---|
| committer | azhirnov <zh1dron@gmail.com> | 2020-08-11 19:49:36 +0000 |
| commit | dc9a4e784c8bb97fbb16a01624c7b8f0544977a4 (patch) | |
| tree | b4a07f6e2029ca9d20999acfd940ea8e2556cb9d /Graphics/GraphicsEngine | |
| parent | Bash function for format validation in submodules (#155) (diff) | |
| download | DiligentCore-dc9a4e784c8bb97fbb16a01624c7b8f0544977a4.tar.gz DiligentCore-dc9a4e784c8bb97fbb16a01624c7b8f0544977a4.zip | |
Added mesh shader
added mesh shader support to DX12 and Vulkan, added DXIL compiler for Shader Model 6.x
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/DeviceContextBase.hpp | 90 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/include/PipelineStateBase.hpp | 42 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/include/ShaderBase.hpp | 18 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/DeviceCaps.h | 3 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/DeviceContext.h | 85 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/GraphicsTypes.h | 2 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/PipelineState.h | 36 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/Shader.h | 17 |
8 files changed, 252 insertions, 41 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index b4c271fa..d547ca6f 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -229,8 +229,10 @@ protected: // clang-format off bool DvpVerifyDrawArguments (const DrawAttribs& Attribs)const; bool DvpVerifyDrawIndexedArguments (const DrawIndexedAttribs& Attribs)const; + bool DvpVerifyDrawMeshArguments (const DrawMeshAttribs& Attribs)const; bool DvpVerifyDrawIndirectArguments (const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const; bool DvpVerifyDrawIndexedIndirectArguments(const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const; + bool DvpVerifyDrawMeshIndirectArguments (const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const; bool DvpVerifyDispatchArguments (const DispatchComputeAttribs& Attribs)const; bool DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const; @@ -242,8 +244,10 @@ protected: #else bool DvpVerifyDrawArguments (const DrawAttribs& Attribs)const {return true;} bool DvpVerifyDrawIndexedArguments (const DrawIndexedAttribs& Attribs)const {return true;} + bool DvpVerifyDrawMeshArguments (const DrawMeshAttribs& Attribs)const {return true;} bool DvpVerifyDrawIndirectArguments (const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;} bool DvpVerifyDrawIndexedIndirectArguments(const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;} + bool DvpVerifyDrawMeshIndirectArguments (const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;} bool DvpVerifyDispatchArguments (const DispatchComputeAttribs& Attribs)const {return true;} bool DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;} @@ -1175,7 +1179,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: return false; } - if (m_pPipelineState->GetDesc().IsComputePipeline) + if (m_pPipelineState->GetDesc().PipelineType != GRAPHICS_PIPELINE) { LOG_ERROR_MESSAGE("Draw command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a compute pipeline."); return false; @@ -1201,8 +1205,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: no pipeline state is bound."); return false; } - - if (m_pPipelineState->GetDesc().IsComputePipeline) + + if (m_pPipelineState->GetDesc().PipelineType != GRAPHICS_PIPELINE) { LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a compute pipeline."); @@ -1232,6 +1236,34 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: template <typename BaseInterface, typename ImplementationTraits> inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: + DvpVerifyDrawMeshArguments(const DrawMeshAttribs& Attribs)const +{ + if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) + return true; + + if (!m_pPipelineState) + { + LOG_ERROR_MESSAGE("DrawMesh command arguments are invalid: no pipeline state is bound."); + return false; + } + + if (m_pPipelineState->GetDesc().PipelineType != MESH_PIPELINE) + { + LOG_ERROR_MESSAGE("DrawMesh command arguments are invalid: pipeline state '", + m_pPipelineState->GetDesc().Name, "' is a compute pipeline."); + return false; + } + + if (Attribs.ThreadGroupCount == 0) + { + LOG_WARNING_MESSAGE("DrawMesh command arguments are invalid: number of groups to dispatch is zero."); + } + + return true; +} + +template <typename BaseInterface, typename ImplementationTraits> +inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: DvpVerifyDrawIndirectArguments(const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) @@ -1242,8 +1274,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: LOG_ERROR_MESSAGE("DrawIndirect command arguments are invalid: no pipeline state is bound."); return false; } - - if (m_pPipelineState->GetDesc().IsComputePipeline) + + if (m_pPipelineState->GetDesc().PipelineType != GRAPHICS_PIPELINE) { LOG_ERROR_MESSAGE("DrawIndirect command arguments are invalid: pipeline state '", @@ -1281,8 +1313,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: no pipeline state is bound."); return false; } - - if (m_pPipelineState->GetDesc().IsComputePipeline) + + if (m_pPipelineState->GetDesc().PipelineType != GRAPHICS_PIPELINE) { LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a compute pipeline."); @@ -1321,6 +1353,44 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: } template <typename BaseInterface, typename ImplementationTraits> +inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: + DvpVerifyDrawMeshIndirectArguments(const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const +{ + if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) + return true; + + if (!m_pPipelineState) + { + LOG_ERROR_MESSAGE("DrawMeshIndirect command arguments are invalid: no pipeline state is bound."); + return false; + } + + if (m_pPipelineState->GetDesc().PipelineType != MESH_PIPELINE) + { + LOG_ERROR_MESSAGE("DrawMeshIndirect command arguments are invalid: pipeline state '", + m_pPipelineState->GetDesc().Name, "' is a compute pipeline."); + return false; + } + + if (pAttribsBuffer != nullptr) + { + if ((pAttribsBuffer->GetDesc().BindFlags & BIND_INDIRECT_DRAW_ARGS) == 0) + { + LOG_ERROR_MESSAGE("DrawMeshIndirect command arguments are invalid: indirect draw arguments buffer '", + pAttribsBuffer->GetDesc().Name, "' was not created with BIND_INDIRECT_DRAW_ARGS flag."); + return false; + } + } + else + { + LOG_ERROR_MESSAGE("DrawMeshIndirect command arguments are invalid: indirect draw arguments buffer is null."); + return false; + } + + return true; +} + +template <typename BaseInterface, typename ImplementationTraits> inline void DeviceContextBase<BaseInterface, ImplementationTraits>:: DvpVerifyRenderTargets() const { @@ -1384,7 +1454,7 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: return false; } - if (!m_pPipelineState->GetDesc().IsComputePipeline) + if (m_pPipelineState->GetDesc().PipelineType != COMPUTE_PIPELINE) { LOG_ERROR_MESSAGE("DispatchCompute command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a graphics pipeline."); @@ -1412,8 +1482,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>:: LOG_ERROR_MESSAGE("DispatchComputeIndirect command arguments are invalid: no pipeline state is bound."); return false; } - - if (!m_pPipelineState->GetDesc().IsComputePipeline) + + if (m_pPipelineState->GetDesc().PipelineType != COMPUTE_PIPELINE) { LOG_ERROR_MESSAGE("DispatchComputeIndirect command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a graphics pipeline."); diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp index 6d70f4da..37d4e7cd 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp @@ -83,7 +83,7 @@ public: StringPoolSize += strlen(SrcLayout.StaticSamplers[i].SamplerOrTextureName) + 1; } - if (!PSODesc.IsComputePipeline) + if (PSODesc.IsAnyGraphicsPipeline()) { CheckAndCorrectBlendStateDesc(); CheckRasterizerStateDesc(); @@ -142,7 +142,7 @@ public: } - if (this->m_Desc.IsComputePipeline) + if (this->m_Desc.IsComputePipeline()) { const auto& ComputePipeline = PSODesc.ComputePipeline; if (ComputePipeline.pCS == nullptr) @@ -171,20 +171,40 @@ public: VALIDATE_SHADER_TYPE(GraphicsPipeline.pGS, SHADER_TYPE_GEOMETRY, "geometry") VALIDATE_SHADER_TYPE(GraphicsPipeline.pHS, SHADER_TYPE_HULL, "hull") VALIDATE_SHADER_TYPE(GraphicsPipeline.pDS, SHADER_TYPE_DOMAIN, "domain") + VALIDATE_SHADER_TYPE(GraphicsPipeline.pAS, SHADER_TYPE_AMPLIFICATION, "amplification") + VALIDATE_SHADER_TYPE(GraphicsPipeline.pMS, SHADER_TYPE_MESH, "mesh") #undef VALIDATE_SHADER_TYPE - m_pVS = GraphicsPipeline.pVS; - m_pPS = GraphicsPipeline.pPS; - m_pGS = GraphicsPipeline.pGS; - m_pDS = GraphicsPipeline.pDS; - m_pHS = GraphicsPipeline.pHS; + if (PSODesc.PipelineType == GRAPHICS_PIPELINE) + { + CHECK_THROW(GraphicsPipeline.pVS, "Vertex shader must be defined"); + CHECK_THROW(!GraphicsPipeline.pAS && !GraphicsPipeline.pMS, "Mesh shaders are not supported in graphics pipeline"); + m_pVS = GraphicsPipeline.pVS; + m_pPS = GraphicsPipeline.pPS; + m_pGS = GraphicsPipeline.pGS; + m_pDS = GraphicsPipeline.pDS; + m_pHS = GraphicsPipeline.pHS; + } + else + if (PSODesc.PipelineType == MESH_PIPELINE) + { + CHECK_THROW(GraphicsPipeline.pMS, "Mesh shader must be defined"); + CHECK_THROW(!GraphicsPipeline.pVS && !GraphicsPipeline.pGS && !GraphicsPipeline.pDS && !GraphicsPipeline.pHS, + "Vertex, geometry and tessellation shaders are not supported in mesh pipeline"); + DEV_CHECK_ERR(GraphicsPipeline.InputLayout.NumElements == 0, "Input layout ignored in mesh shader"); + m_pAS = GraphicsPipeline.pAS; + m_pMS = GraphicsPipeline.pMS; + m_pPS = GraphicsPipeline.pPS; + } if (GraphicsPipeline.pVS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pVS; if (GraphicsPipeline.pPS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pPS; if (GraphicsPipeline.pGS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pGS; if (GraphicsPipeline.pHS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pHS; if (GraphicsPipeline.pDS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pDS; - + if (GraphicsPipeline.pAS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pAS; + if (GraphicsPipeline.pMS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pMS; + DEV_CHECK_ERR(m_NumShaders > 0, "There must be at least one shader in the Pipeline State"); for (Uint32 rt = GraphicsPipeline.NumRenderTargets; rt < _countof(GraphicsPipeline.RTVFormats); ++rt) @@ -388,9 +408,11 @@ protected: RefCntAutoPtr<IShader> m_pDS; ///< Strong reference to the domain shader RefCntAutoPtr<IShader> m_pHS; ///< Strong reference to the hull shader RefCntAutoPtr<IShader> m_pCS; ///< Strong reference to the compute shader + RefCntAutoPtr<IShader> m_pAS; ///< Strong reference to the amplification shader + RefCntAutoPtr<IShader> m_pMS; ///< Strong reference to the mesh shader - IShader* m_ppShaders[5] = {}; ///< Array of pointers to the shaders used by this PSO - size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout + IShader* m_ppShaders[MAX_SHADERS_IN_PIPELINE] = {}; ///< Array of pointers to the shaders used by this PSO + size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout private: void CheckRasterizerStateDesc() const diff --git a/Graphics/GraphicsEngine/include/ShaderBase.hpp b/Graphics/GraphicsEngine/include/ShaderBase.hpp index 9874206a..5462c7a4 100644 --- a/Graphics/GraphicsEngine/include/ShaderBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderBase.hpp @@ -57,13 +57,15 @@ inline Int32 GetShaderTypeIndex(SHADER_TYPE Type) switch (Type) { // clang-format off - case SHADER_TYPE_UNKNOWN: VERIFY_EXPR(ShaderIndex == -1); break; - case SHADER_TYPE_VERTEX: VERIFY_EXPR(ShaderIndex == 0); break; - case SHADER_TYPE_PIXEL: VERIFY_EXPR(ShaderIndex == 1); break; - case SHADER_TYPE_GEOMETRY:VERIFY_EXPR(ShaderIndex == 2); break; - case SHADER_TYPE_HULL: VERIFY_EXPR(ShaderIndex == 3); break; - case SHADER_TYPE_DOMAIN: VERIFY_EXPR(ShaderIndex == 4); break; - case SHADER_TYPE_COMPUTE: VERIFY_EXPR(ShaderIndex == 5); break; + case SHADER_TYPE_UNKNOWN: VERIFY_EXPR(ShaderIndex == -1); break; + case SHADER_TYPE_VERTEX: VERIFY_EXPR(ShaderIndex == 0); break; + case SHADER_TYPE_PIXEL: VERIFY_EXPR(ShaderIndex == 1); break; + case SHADER_TYPE_GEOMETRY: VERIFY_EXPR(ShaderIndex == 2); break; + case SHADER_TYPE_HULL: VERIFY_EXPR(ShaderIndex == 3); break; + case SHADER_TYPE_DOMAIN: VERIFY_EXPR(ShaderIndex == 4); break; + case SHADER_TYPE_COMPUTE: VERIFY_EXPR(ShaderIndex == 5); break; + case SHADER_TYPE_AMPLIFICATION: VERIFY_EXPR(ShaderIndex == 6); break; + case SHADER_TYPE_MESH: VERIFY_EXPR(ShaderIndex == 7); break; // clang-format on default: UNEXPECTED("Unexpected shader type (", Type, ")"); break; } @@ -78,6 +80,8 @@ static const int GSInd = GetShaderTypeIndex(SHADER_TYPE_GEOMETRY); static const int HSInd = GetShaderTypeIndex(SHADER_TYPE_HULL); static const int DSInd = GetShaderTypeIndex(SHADER_TYPE_DOMAIN); static const int CSInd = GetShaderTypeIndex(SHADER_TYPE_COMPUTE); +static const int ASInd = GetShaderTypeIndex(SHADER_TYPE_AMPLIFICATION); +static const int MSInd = GetShaderTypeIndex(SHADER_TYPE_MESH); /// Template class implementing base functionality for a shader object diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h index 1f0dc257..77095307 100644 --- a/Graphics/GraphicsEngine/interface/DeviceCaps.h +++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h @@ -164,6 +164,9 @@ struct DeviceFeatures /// Specifies whether all the extended UAV texture formats are available in shader code. Bool TextureUAVExtendedFormats DEFAULT_INITIALIZER(False); + + /// Indicates if device supports mesh and amplification shaders + Bool MeshShaders DEFAULT_INITIALIZER(False); }; typedef struct DeviceFeatures DeviceFeatures; diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 79f8bd39..db1c0175 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -362,6 +362,68 @@ struct DrawIndexedIndirectAttribs }; typedef struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs; +/// Defines the mesh draw command attributes. + +/// This structure is used by IDeviceContext::DrawMesh(). +struct DrawMeshAttribs +{ + ///< Number of dispatched groups + Uint32 ThreadGroupCount DEFAULT_INITIALIZER(1); + + /// Additional flags, see Diligent::DRAW_FLAGS. + DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); + +#if DILIGENT_CPP_INTERFACE + /// Initializes the structure members with default values. + DrawMeshAttribs()noexcept{} + + /// Initializes the structure with user-specified values. + DrawMeshAttribs(Uint32 _ThreadGroupCount, + DRAW_FLAGS _Flags)noexcept : + ThreadGroupCount {_ThreadGroupCount}, + Flags {_Flags} + {} +#endif +}; +typedef struct DrawMeshAttribs DrawMeshAttribs; + +/// Defines the mesh indirect draw command attributes. + +/// This structure is used by IDeviceContext::DrawMeshIndirect(). +struct DrawMeshIndirectAttribs +{ + /// Additional flags, see Diligent::DRAW_FLAGS. + DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); + + /// State transition mode for indirect draw arguments buffer. + RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); + + /// Offset from the beginning of the buffer to the location of draw command attributes. + Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0); + +#if DILIGENT_CPP_INTERFACE + /// Initializes the structure members with default values + + /// Default values: + /// Member | Default value + /// -----------------------------------------|-------------------------------------- + /// Flags | DRAW_FLAG_NONE + /// IndirectAttribsBufferStateTransitionMode | RESOURCE_STATE_TRANSITION_MODE_NONE + /// IndirectDrawArgsOffset | 0 + DrawMeshIndirectAttribs()noexcept{} + + /// Initializes the structure members with user-specified values. + DrawMeshIndirectAttribs(DRAW_FLAGS _Flags, + RESOURCE_STATE_TRANSITION_MODE _IndirectAttribsBufferStateTransitionMode, + Uint32 _IndirectDrawArgsOffset = 0)noexcept : + Flags {_Flags }, + IndirectAttribsBufferStateTransitionMode{_IndirectAttribsBufferStateTransitionMode}, + IndirectDrawArgsOffset {_IndirectDrawArgsOffset } + {} +#endif +}; +typedef struct DrawMeshIndirectAttribs DrawMeshIndirectAttribs; + /// Defines which parts of the depth-stencil buffer to clear. /// These flags are used by IDeviceContext::ClearDepthStencil(). @@ -930,6 +992,29 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject) VIRTUAL void METHOD(DrawIndexedIndirect)(THIS_ const DrawIndexedIndirectAttribs REF Attribs, IBuffer* pAttribsBuffer) PURE; + + + /// Executes an mesh draw command. + + /// \param [in] Attribs - Draw command attributes, see Diligent::DrawMeshAttribs for details. + VIRTUAL void METHOD(DrawMesh)(THIS_ + const DrawMeshAttribs REF Attribs) PURE; + + + /// Executes an mesh indirect draw command. + + /// \param [in] Attribs - Structure describing the command attributes, see Diligent::DrawMeshIndirectAttribs for details. + /// \param [in] pAttribsBuffer - Pointer to the buffer, from which indirect draw attributes will be read. + /// + /// \remarks If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, + /// the method may transition the state of the indirect draw arguments buffer. This is not a thread safe operation, + /// so no other thread is allowed to read or write the state of the buffer. + /// + /// If the application intends to use the same resources in other threads simultaneously, it needs to + /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. + VIRTUAL void METHOD(DrawMeshIndirect)(THIS_ + const DrawMeshIndirectAttribs REF Attribs, + IBuffer* pAttribsBuffer) PURE; /// Executes a dispatch compute command. diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 0d0631b7..b54ac7cb 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -920,7 +920,7 @@ DEFINE_FLAG_ENUM_OPERATORS(MISC_TEXTURE_FLAGS) /// Input primitive topology. -/// This enumeration is used by DrawAttribs structure to define input primitive topology. +/// This enumeration is used by GraphicsPipelineDesc structure to define input primitive topology. DILIGENT_TYPED_ENUM(PRIMITIVE_TOPOLOGY, Uint8) { /// Undefined topology diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 5e99a392..6daa74b6 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -165,6 +165,12 @@ struct GraphicsPipelineDesc /// Geometry shader to be used with the pipeline IShader* pGS DEFAULT_INITIALIZER(nullptr); + /// Amplification shader to be used with the pipeline + IShader* pAS DEFAULT_INITIALIZER(nullptr); + + /// Mesh shader to be used with the pipeline + IShader* pMS DEFAULT_INITIALIZER(nullptr); + //D3D12_STREAM_OUTPUT_DESC StreamOutput; /// Blend state description @@ -182,11 +188,11 @@ struct GraphicsPipelineDesc /// Depth-stencil state description DepthStencilStateDesc DepthStencilDesc; - /// Input layout + /// Input layout, ignored in mesh pipeline InputLayoutDesc InputLayout; //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue; - /// Primitive topology type + /// Primitive topology type, ignored in mesh pipeline PRIMITIVE_TOPOLOGY PrimitiveTopology DEFAULT_INITIALIZER(PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); /// Number of viewports used by this pipeline @@ -223,12 +229,25 @@ struct ComputePipelineDesc }; typedef struct ComputePipelineDesc ComputePipelineDesc; +/// Pipeline type +DILIGENT_TYPED_ENUM(PIPELINE_TYPE, Uint8) +{ + /// Graphics pipeline used in IDeviceContext::Draw(), IDeviceContext::DrawIndexed(), + /// IDeviceContext::DrawIndirect(), IDeviceContext::DrawIndexedIndirect(). + GRAPHICS_PIPELINE, + + /// Compute pipeline used in IDeviceContext::DispatchCompute(), IDeviceContext::DispatchComputeIndirect(). + COMPUTE_PIPELINE, + + // Mesh pipeline used in IDeviceContext::DrawMesh(), IDeviceContext::DrawMeshIndirect(). + MESH_PIPELINE, +}; /// Pipeline state description struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs) - /// Flag indicating if pipeline state is a compute pipeline state - bool IsComputePipeline DEFAULT_INITIALIZER(false); + /// Pipeline type + PIPELINE_TYPE PipelineType DEFAULT_INITIALIZER(GRAPHICS_PIPELINE); /// Shader resource binding allocation granularity @@ -242,11 +261,16 @@ struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Pipeline layout description PipelineResourceLayoutDesc ResourceLayout; - /// Graphics pipeline state description. This memeber is ignored if IsComputePipeline == True + /// Graphics pipeline state description. This memeber is ignored if PipelineType == GRAPHICS_PIPELINE or MESH_PIPELINE GraphicsPipelineDesc GraphicsPipeline; - /// Compute pipeline state description. This memeber is ignored if IsComputePipeline == False + /// Compute pipeline state description. This memeber is ignored if PipelineType == COMPUTE_PIPELINE ComputePipelineDesc ComputePipeline; + +#if DILIGENT_CPP_INTERFACE + bool IsAnyGraphicsPipeline() const { return PipelineType == GRAPHICS_PIPELINE || PipelineType == MESH_PIPELINE; } + bool IsComputePipeline () const { return PipelineType == COMPUTE_PIPELINE; } +#endif }; typedef struct PipelineStateDesc PipelineStateDesc; diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index eacd35f0..867335a9 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -45,13 +45,16 @@ static const INTERFACE_ID IID_Shader = /// Describes the shader type DILIGENT_TYPED_ENUM(SHADER_TYPE, Uint32) { - SHADER_TYPE_UNKNOWN = 0x000, ///< Unknown shader type - SHADER_TYPE_VERTEX = 0x001, ///< Vertex shader - SHADER_TYPE_PIXEL = 0x002, ///< Pixel (fragment) shader - SHADER_TYPE_GEOMETRY = 0x004, ///< Geometry shader - SHADER_TYPE_HULL = 0x008, ///< Hull (tessellation control) shader - SHADER_TYPE_DOMAIN = 0x010, ///< Domain (tessellation evaluation) shader - SHADER_TYPE_COMPUTE = 0x020 ///< Compute shader + SHADER_TYPE_UNKNOWN = 0x000, ///< Unknown shader type + SHADER_TYPE_VERTEX = 0x001, ///< Vertex shader + SHADER_TYPE_PIXEL = 0x002, ///< Pixel (fragment) shader + SHADER_TYPE_GEOMETRY = 0x004, ///< Geometry shader + SHADER_TYPE_HULL = 0x008, ///< Hull (tessellation control) shader + SHADER_TYPE_DOMAIN = 0x010, ///< Domain (tessellation evaluation) shader + SHADER_TYPE_COMPUTE = 0x020, ///< Compute shader + SHADER_TYPE_AMPLIFICATION = 0x040, ///< Amplification (task) shader + SHADER_TYPE_MESH = 0x080, ///< Mesh shader + SHADER_TYPE_LAST }; DEFINE_FLAG_ENUM_OPERATORS(SHADER_TYPE); |
