Open 3D Engine Atom Gem API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
AZ::RPI::ShaderAsset Class Referencefinal

Inherits AssetData, Handler, and Handler.

Public Member Functions

 AZ_RTTI (ShaderAsset, "{823395A3-D570-49F4-99A9-D820CD1DEF98}", Data::AssetData)
 
 AZ_DISABLE_COPY_MOVE (ShaderAsset)
 
const Name & GetName () const
 Returns the name of the shader.
 
RHI::PipelineStateType GetPipelineStateType () const
 Returns the pipeline state type generated by variants of this shader.
 
const Name & GetDrawListName () const
 
AZStd::sys_time_t GetBuildTimestamp () const
 
const ShaderOptionGroupLayoutGetShaderOptionGroupLayout () const
 Returns the shader option group layout.
 
SupervariantIndex GetSupervariantIndex (const AZ::Name &supervariantName) const
 
Data::Asset< ShaderVariantAssetGetVariant (const ShaderVariantId &shaderVariantId, SupervariantIndex supervariantIndex)
 
Data::Asset< ShaderVariantAssetGetVariant (const ShaderVariantId &shaderVariantId)
 
ShaderVariantSearchResult FindVariantStableId (const ShaderVariantId &shaderVariantId)
 
Data::Asset< ShaderVariantAssetGetVariant (ShaderVariantStableId shaderVariantStableId, SupervariantIndex supervariantIndex) const
 
Data::Asset< ShaderVariantAssetGetVariant (ShaderVariantStableId shaderVariantStableId) const
 
Data::Asset< ShaderVariantAssetGetRootVariant (SupervariantIndex supervariantIndex) const
 
Data::Asset< ShaderVariantAssetGetRootVariant () const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & FindShaderResourceGroupLayout (const Name &shaderResourceGroupName, SupervariantIndex supervariantIndex) const
 Finds and returns the shader resource group asset with the requested name. Returns an empty handle if no matching group was found.
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & FindShaderResourceGroupLayout (const Name &shaderResourceGroupName) const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & FindShaderResourceGroupLayout (uint32_t bindingSlot, SupervariantIndex supervariantIndex) const
 Finds and returns the shader resource group layout associated with the requested binding slot. Returns an empty handle if no matching srg was found.
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & FindShaderResourceGroupLayout (uint32_t bindingSlot) const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & FindFallbackShaderResourceGroupLayout (SupervariantIndex supervariantIndex) const
 Finds and returns the shader resource group layout designated as a ShaderVariantKey fallback.
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & FindFallbackShaderResourceGroupLayout () const
 
AZStd::span< const RHI::Ptr< RHI::ShaderResourceGroupLayout > > GetShaderResourceGroupLayouts (SupervariantIndex supervariantIndex) const
 Returns the set of shader resource group layouts owned by a given supervariant.
 
AZStd::span< const RHI::Ptr< RHI::ShaderResourceGroupLayout > > GetShaderResourceGroupLayouts () const
 
const RHI::PipelineLayoutDescriptorGetPipelineLayoutDescriptor (SupervariantIndex supervariantIndex) const
 Returns the pipeline layout descriptor shared by all variants in the asset.
 
const RHI::PipelineLayoutDescriptorGetPipelineLayoutDescriptor () const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetDrawSrgLayout (SupervariantIndex supervariantIndex) const
 Returns the shader resource group asset that has per-draw frequency, which is added to every draw packet.
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetDrawSrgLayout () const
 
const ShaderInputContractGetInputContract (SupervariantIndex supervariantIndex) const
 Returns the ShaderInputContract which describes which inputs the shader requires.
 
const ShaderInputContractGetInputContract () const
 
const ShaderOutputContractGetOutputContract (SupervariantIndex supervariantIndex) const
 Returns the ShaderOuputContract which describes which outputs the shader requires.
 
const ShaderOutputContractGetOutputContract () const
 
const RHI::RenderStatesGetRenderStates (SupervariantIndex supervariantIndex) const
 Returns the render states for the draw pipeline. Only used for draw pipelines.
 
const RHI::RenderStatesGetRenderStates () const
 
AZStd::optional< RHI::ShaderStageAttributeArguments > GetAttribute (const RHI::ShaderStage &shaderStage, const Name &attributeName, SupervariantIndex supervariantIndex) const
 Returns a list of arguments for the specified attribute, or nullopt_t if the attribute is not found. The list can be empty which is still valid.
 
AZStd::optional< RHI::ShaderStageAttributeArguments > GetAttribute (const RHI::ShaderStage &shaderStage, const Name &attributeName) const
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static uint32_t MakeProductAssetSubId (uint32_t rhiApiUniqueIndex, uint32_t supervariantIndex, uint32_t subProductType)
 
static SupervariantIndex GetSupervariantIndexFromProductAssetSubId (uint32_t assetProducSubId)
 
static SupervariantIndex GetSupervariantIndexFromAssetId (const Data::AssetId &assetId)
 

Static Public Attributes

static constexpr char DisplayName [] = "Shader"
 
static constexpr char Extension [] = "azshader"
 
static constexpr char Group [] = "Shader"
 
static const ShaderVariantStableId RootShaderVariantStableId
 The default shader variant (i.e. the one without any options set).
 

Friends

class ShaderAssetCreator
 
class ShaderAssetHandler
 
class ShaderAssetTester
 
class Shader
 

Member Function Documentation

◆ FindVariantStableId()

ShaderVariantSearchResult AZ::RPI::ShaderAsset::FindVariantStableId ( const ShaderVariantId shaderVariantId)

Finds the best matching shader variant and returns its StableId. This function first loads and caches the ShaderVariantTreeAsset (if not done before). If the ShaderVariantTreeAsset is not found (either the AssetProcessor has not generated it yet, or it simply doesn't exist), then it returns a search result that identifies the root variant. This function is thread safe.

◆ GetBuildTimestamp()

AZStd::sys_time_t AZ::RPI::ShaderAsset::GetBuildTimestamp ( ) const

Return the timestamp when the shader asset was built. This is used to synchronize versions of the ShaderAsset and ShaderVariantTreeAsset, especially during hot-reload.

◆ GetDrawListName()

const Name& AZ::RPI::ShaderAsset::GetDrawListName ( ) const

Returns the draw list tag name. To get the corresponding DrawListTag use DrawListTagRegistry's FindTag() or AcquireTag() (see RHISystemInterface::GetDrawListTagRegistry()). The DrawListTag is also available in the Shader that corresponds to this ShaderAsset.

◆ GetSupervariantIndex()

SupervariantIndex AZ::RPI::ShaderAsset::GetSupervariantIndex ( const AZ::Name &  supervariantName) const

Returns the supervariant index from the specified name. Note that this will append the system supervariant name from RPI::ShaderSystem when searching.

◆ GetVariant() [1/2]

Data::Asset<ShaderVariantAsset> AZ::RPI::ShaderAsset::GetVariant ( const ShaderVariantId shaderVariantId,
SupervariantIndex  supervariantIndex 
)

This function should be your one stop shop to get a ShaderVariantAsset. Finds and returns the best matching ShaderVariantAsset given a ShaderVariantId. If the ShaderVariantAsset is not fully loaded and ready at the moment, this function will QueueLoad the ShaderVariantTreeAsset and subsequently will QueueLoad the ShaderVariantAsset. The called will be notified via the ShaderVariantFinderNotificationBus when the ShaderVariantAsset is loaded and ready. In the mean time, if the required variant is not available this function returns the Root Variant.

◆ GetVariant() [2/2]

Data::Asset<ShaderVariantAsset> AZ::RPI::ShaderAsset::GetVariant ( ShaderVariantStableId  shaderVariantStableId,
SupervariantIndex  supervariantIndex 
) const

Returns the variant asset associated with the provided StableId. The user should call FindVariantStableId() first to get a ShaderVariantStableId from a ShaderVariantId, Or better yet, call GetVariant(ShaderVariantId) for maximum convenience. If the requested variant is not found, the root variant will be returned AND the requested variant will be queued for loading. Next time around if the variant has been loaded this function will return it. Alternatively the caller can register with the ShaderVariantFinderNotificationBus to get the asset as soon as is available. This function is thread safe.


The documentation for this class was generated from the following file: