Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::IPipelineState Struct Referenceabstract

Pipeline state interface. More...

#include <PipelineState.h>

Inheritance diagram for Diligent::IPipelineState:
Diligent::IDeviceObject Diligent.IObject Diligent::IPipelineStateD3D11 Diligent::IPipelineStateD3D12 Diligent::IPipelineStateGL Diligent::IPipelineStateMtl Diligent::IPipelineStateVk Diligent::IPipelineStateWebGPU Diligent::ISerializedPipelineState

Public Member Functions

virtual const PipelineStateDesc &DILIGENT_CALL_TYPE GetDesc () const override=0
 Returns the pipeline description used to create the object.
 
virtual const GraphicsPipelineDesc &DILIGENT_CALL_TYPE GetGraphicsPipelineDesc () const =0
 Returns the graphics pipeline description used to create the object.
 
virtual const RayTracingPipelineDesc &DILIGENT_CALL_TYPE GetRayTracingPipelineDesc () const =0
 Returns the ray tracing pipeline description used to create the object.
 
virtual const TilePipelineDesc &DILIGENT_CALL_TYPE GetTilePipelineDesc () const =0
 Returns the tile pipeline description used to create the object.
 
virtual void DILIGENT_CALL_TYPE BindStaticResources (SHADER_TYPE ShaderStages, IResourceMapping *pResourceMapping, BIND_SHADER_RESOURCES_FLAGS Flags)=0
 Binds resources for all shaders in the pipeline state.
 
virtual Uint32 DILIGENT_CALL_TYPE GetStaticVariableCount (SHADER_TYPE ShaderType) const =0
 Returns the number of static shader resource variables.
 
virtual IShaderResourceVariable *DILIGENT_CALL_TYPE GetStaticVariableByName (SHADER_TYPE ShaderType, const Char *Name)=0
 Returns static shader resource variable.
 
virtual IShaderResourceVariable *DILIGENT_CALL_TYPE GetStaticVariableByIndex (SHADER_TYPE ShaderType, Uint32 Index)=0
 Returns static shader resource variable by its index.
 
virtual void DILIGENT_CALL_TYPE CreateShaderResourceBinding (IShaderResourceBinding **ppShaderResourceBinding, Bool InitStaticResources=false)=0
 Creates a shader resource binding object.
 
virtual void DILIGENT_CALL_TYPE InitializeStaticSRBResources (struct IShaderResourceBinding *pShaderResourceBinding) const =0
 Initializes static resources in the shader binding object.
 
virtual void DILIGENT_CALL_TYPE CopyStaticResources (IPipelineState *pDstPipeline) const =0
 Copies static resource bindings to the destination pipeline.
 
virtual bool DILIGENT_CALL_TYPE IsCompatibleWith (const struct IPipelineState *pPSO) const =0
 Checks if this pipeline state object is compatible with another PSO.
 
virtual Uint32 DILIGENT_CALL_TYPE GetResourceSignatureCount () const =0
 Returns the number of pipeline resource signatures used by this pipeline.
 
virtual IPipelineResourceSignature *DILIGENT_CALL_TYPE GetResourceSignature (Uint32 Index) const =0
 Returns pipeline resource signature at the give index.
 
virtual PIPELINE_STATE_STATUS DILIGENT_CALL_TYPE GetStatus (bool WaitForCompletion=false)=0
 Returns the pipeline state status, see Diligent::PIPELINE_STATE_STATUS.
 
- Public Member Functions inherited from Diligent::IDeviceObject
virtual Int32 DILIGENT_CALL_TYPE GetUniqueID () const =0
 Returns unique identifier assigned to an object.
 
virtual void DILIGENT_CALL_TYPE SetUserData (IObject *pUserData)=0
 Stores a pointer to the user-provided data object.
 
virtual IObject *DILIGENT_CALL_TYPE GetUserData () const =0
 Returns a pointer to the user data object previously set with SetUserData() method.
 
- Public Member Functions inherited from Diligent.IObject
virtual void DILIGENT_CALL_TYPE QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface)=0
 Queries the specific interface.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE AddRef ()=0
 Increments the number of strong references by 1.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Release ()=0
 
virtual IReferenceCounters *DILIGENT_CALL_TYPE GetReferenceCounters () const =0
 

Detailed Description

Pipeline state interface.

Member Function Documentation

◆ BindStaticResources()

virtual void DILIGENT_CALL_TYPE Diligent::IPipelineState::BindStaticResources ( SHADER_TYPE ShaderStages,
IResourceMapping * pResourceMapping,
BIND_SHADER_RESOURCES_FLAGS Flags )
pure virtual

Binds resources for all shaders in the pipeline state.

Parameters
[in]ShaderStages- Flags that specify shader stages, for which resources will be bound. Any combination of Diligent::SHADER_TYPE may be used.
[in]pResourceMapping- Pointer to the resource mapping interface.
[in]Flags- Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS.

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::BindStaticResources() method.

◆ CopyStaticResources()

virtual void DILIGENT_CALL_TYPE Diligent::IPipelineState::CopyStaticResources ( IPipelineState * pDstPipeline) const
pure virtual

Copies static resource bindings to the destination pipeline.

Parameters
[in]pDstPipeline- Destination pipeline state.
Note
Destination pipeline state must be compatible with this pipeline.

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::CopyStaticResources() method.

◆ CreateShaderResourceBinding()

virtual void DILIGENT_CALL_TYPE Diligent::IPipelineState::CreateShaderResourceBinding ( IShaderResourceBinding ** ppShaderResourceBinding,
Bool InitStaticResources = false )
pure virtual

Creates a shader resource binding object.

Parameters
[out]ppShaderResourceBinding- Memory location where pointer to the new shader resource binding object is written.
[in]InitStaticResources- If set to true, the method will initialize static resources in the created object, which has the exact same effect as calling IPipelineState::InitializeStaticSRBResources().

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::CreateShaderResourceBinding() method.

◆ GetGraphicsPipelineDesc()

virtual const GraphicsPipelineDesc &DILIGENT_CALL_TYPE Diligent::IPipelineState::GetGraphicsPipelineDesc ( ) const
pure virtual

Returns the graphics pipeline description used to create the object.

This method must only be called for a graphics or mesh pipeline.

◆ GetRayTracingPipelineDesc()

virtual const RayTracingPipelineDesc &DILIGENT_CALL_TYPE Diligent::IPipelineState::GetRayTracingPipelineDesc ( ) const
pure virtual

Returns the ray tracing pipeline description used to create the object.

This method must only be called for a ray tracing pipeline.

◆ GetResourceSignature()

virtual IPipelineResourceSignature *DILIGENT_CALL_TYPE Diligent::IPipelineState::GetResourceSignature ( Uint32 Index) const
pure virtual

Returns pipeline resource signature at the give index.

Parameters
[in]Index- Index of the resource signature, same as BindingIndex in PipelineResourceSignatureDesc.
Returns
A pointer to the pipeline resource signature interface.

◆ GetResourceSignatureCount()

virtual Uint32 DILIGENT_CALL_TYPE Diligent::IPipelineState::GetResourceSignatureCount ( ) const
pure virtual

Returns the number of pipeline resource signatures used by this pipeline.

After the PSO is created, pipeline resource signatures are arranged by their binding indices. The value returned by this function is given by the maximum signature binding index plus one, and thus may not be equal to PipelineStateCreateInfo::ResourceSignaturesCount.

◆ GetStaticVariableByIndex()

virtual IShaderResourceVariable *DILIGENT_CALL_TYPE Diligent::IPipelineState::GetStaticVariableByIndex ( SHADER_TYPE ShaderType,
Uint32 Index )
pure virtual

Returns static shader resource variable by its index.

Parameters
[in]ShaderType- The type of the shader to look up the variable. Must be one of Diligent::SHADER_TYPE.
[in]Index- Shader variable index. The index must be between 0 and the total number of variables returned by GetStaticVariableCount().

Only static shader resource variables can be accessed through this method. Mutable and dynamic variables are accessed through Shader Resource Binding object.

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::GetStaticVariableByIndex() method.

◆ GetStaticVariableByName()

virtual IShaderResourceVariable *DILIGENT_CALL_TYPE Diligent::IPipelineState::GetStaticVariableByName ( SHADER_TYPE ShaderType,
const Char * Name )
pure virtual

Returns static shader resource variable.

If the variable is not found, returns nullptr.

Parameters
[in]ShaderType- The type of the shader to look up the variable. Must be one of Diligent::SHADER_TYPE.
[in]Name- Name of the variable.

The method does not increment the reference counter of the returned interface.

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::GetStaticVariableByName() method.

◆ GetStaticVariableCount()

virtual Uint32 DILIGENT_CALL_TYPE Diligent::IPipelineState::GetStaticVariableCount ( SHADER_TYPE ShaderType) const
pure virtual

Returns the number of static shader resource variables.

Parameters
[in]ShaderType- Type of the shader.

Only static variables (that can be accessed directly through the PSO) are counted. Mutable and dynamic variables are accessed through Shader Resource Binding object.

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::GetStaticVariableCount() method.

◆ GetStatus()

virtual PIPELINE_STATE_STATUS DILIGENT_CALL_TYPE Diligent::IPipelineState::GetStatus ( bool WaitForCompletion = false)
pure virtual

Returns the pipeline state status, see Diligent::PIPELINE_STATE_STATUS.

Parameters
[in]WaitForCompletion- If true, the method will wait until the pipeline state is compiled. If false, the method will return the pipeline state status without waiting. This parameter is ignored if the pipeline state was compiled synchronously.
Returns
The pipeline state status.

◆ GetTilePipelineDesc()

virtual const TilePipelineDesc &DILIGENT_CALL_TYPE Diligent::IPipelineState::GetTilePipelineDesc ( ) const
pure virtual

Returns the tile pipeline description used to create the object.

This method must only be called for a tile pipeline.

◆ InitializeStaticSRBResources()

virtual void DILIGENT_CALL_TYPE Diligent::IPipelineState::InitializeStaticSRBResources ( struct IShaderResourceBinding * pShaderResourceBinding) const
pure virtual

Initializes static resources in the shader binding object.

If static shader resources were not initialized when the SRB was created, this method must be called to initialize them before the SRB can be used. The method should be called after all static variables have been initialized in the PSO.

Parameters
[in]pShaderResourceBinding- Shader resource binding object to initialize. The pipeline state must be compatible with the shader resource binding object.
Note
If static resources have already been initialized in the SRB and the method is called again, it will have no effect and a warning message will be displayed.

This method is only allowed for pipelines that use implicit resource signature (e.g. shader resources are defined through ResourceLayout member of the pipeline desc). For pipelines that use explicit resource signatures, use IPipelineResourceSignature::InitializeStaticSRBResources() method.

◆ IsCompatibleWith()

virtual bool DILIGENT_CALL_TYPE Diligent::IPipelineState::IsCompatibleWith ( const struct IPipelineState * pPSO) const
pure virtual

Checks if this pipeline state object is compatible with another PSO.

If two pipeline state objects are compatible, they can use shader resource binding objects interchangeably, i.e. SRBs created by one PSO can be committed when another PSO is bound.

Parameters
[in]pPSO- Pointer to the pipeline state object to check compatibility with.
Returns
true if this PSO is compatible with pPSO. false otherwise.

The function only checks that shader resource layouts are compatible, but does not check if resource types match. For instance, if a pixel shader in one PSO uses a texture at slot 0, and a pixel shader in another PSO uses texture array at slot 0, the pipelines will be compatible. However, if you try to use SRB object from the first pipeline to commit resources for the second pipeline, a runtime error will occur.
The function only checks compatibility of shader resource layouts. It does not take into account vertex shader input layout, number of outputs, etc.

Technical details

PSOs may be partially compatible when some, but not all pipeline resource signatures are compatible. In Vulkan backend, switching PSOs that are partially compatible may increase performance as shader resource bindings (that map to descriptor sets) from compatible signatures may be preserved. In Direct3D12 backend, only switching between fully compatible PSOs preserves shader resource bindings, while switching partially compatible PSOs still requires re-binding all resource bindings from all signatures. In other backends the behavior is emulated. Usually, the bindings from the first N compatible resource signatures may be preserved.