Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RPI::ShaderVariantTreeAsset Class Referencefinal

#include <ShaderVariantTreeAsset.h>

Inherits AZ::Data::AssetData.

Public Member Functions

 AZ_RTTI (ShaderVariantTreeAsset, "{EBF48506-F8BB-4B37-8FAC-F132BF83E42D}", Data::AssetData)
 
 AZ_DISABLE_COPY_MOVE (ShaderVariantTreeAsset)
 
size_t GetNodeCount () const
 Returns the total number of nodes.
 
ShaderVariantSearchResult FindVariantStableId (const ShaderOptionGroupLayout *shaderOptionGroupLayout, const ShaderVariantId &shaderVariantId) const
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static Data::AssetId GetShaderVariantTreeAssetIdFromShaderAssetId (const Data::AssetId &shaderAssetId)
 

Static Public Attributes

static constexpr const char * Extension = "azshadervarianttree"
 
static constexpr const char * DisplayName = "ShaderVariantTree"
 
static constexpr const char * Group = "Shader"
 
static constexpr AZ::u32 ProductSubID = 0
 
static constexpr char CommonSubFolder [] = "ShaderVariants"
 See comments in ValidateShaderVariantListLocation() inside ShaderVariantAssetBuilder.cpp.
 
static constexpr char CommonSubFolderLowerCase [] = "shadervariants"
 

Friends

class ShaderVariantTreeAssetHandler
 
class ShaderVariantTreeAssetCreator
 
struct ShaderVariantTreeNode
 

Detailed Description

The shader variant tree is a data structure to perform lookups of shader variants that have the best runtime performance on the GPU. The tree supports the lookup of a best-fit shader variant, given a specific shader variant key. The best-fit variant should have the best runtime performance on the GPU, as it has less dynamic branches.

The algorithm does the following:

  • Find a list of all matches for the specified shader variant ID.
  • Select the best variant from that list.

The variant searched using the tree has a key that matches the requested key, but some values can be undefined. For example, requesting a key equal to "00101" could return a variant with ID "0?10?", in which ? stands for undefined values. The undefined values must be provided to the fallback constant buffer. (See Shader::FindFallbackShaderResourceGroupAsset).

Member Function Documentation

◆ FindVariantStableId()

ShaderVariantSearchResult AZ::RPI::ShaderVariantTreeAsset::FindVariantStableId ( const ShaderOptionGroupLayout shaderOptionGroupLayout,
const ShaderVariantId shaderVariantId 
) const

Finds and returns the shader variant index associated with the specified ID. The search involves two general steps:

  • Search the tree to find all possible matches for the specified shader variant ID.
  • Search the best match from those results.

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