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::RHI::ConstantsLayout Class Reference

#include <ConstantsLayout.h>

Inherits AZStd::intrusive_base.

Public Member Functions

 AZ_TYPE_INFO (ConstantsLayout, "{66EDAC32-7730-4F05-AF9D-B3CB0F5D90E0}")
 
 AZ_CLASS_ALLOCATOR (ConstantsLayout, AZ::SystemAllocator)
 
void AddShaderInput (const ShaderInputConstantDescriptor &descriptor)
 Adds a shader input to the constants layout.
 
void Clear ()
 Clears the layout to an empty state. The layout must be finalized prior to usage.
 
bool IsFinalized () const
 
bool Finalize ()
 
HashValue64 GetHash () const
 Returns the hash of the layout.
 
ShaderInputConstantIndex FindShaderInputIndex (const Name &name) const
 
Interval GetInterval (ShaderInputConstantIndex inputIndex) const
 The interval of a constant is its byte [min, max) into the constants data.
 
const ShaderInputConstantDescriptorGetShaderInput (ShaderInputConstantIndex inputIndex) const
 
AZStd::span< const ShaderInputConstantDescriptorGetShaderInputList () const
 
uint32_t GetDataSize () const
 Returns the total size in bytes used by the constants.
 
bool ValidateAccess (ShaderInputConstantIndex inputIndex) const
 
void DebugPrintNames (AZStd::span< const ShaderInputConstantIndex > constantList) const
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static RHI::Ptr< ConstantsLayoutCreate ()
 

Friends

template<typename , typename >
struct AnyTypeInfoConcept
 
template<typename , bool , bool >
struct Serialize::InstanceFactory
 

Detailed Description

ConstantsLayout defines a the layout of a set of constant shader inputs. Each constant input spans a range of bytes in an byte array. The array could represent a constant buffer or an inline structure depending on where the constants are being use.

To use the class, assign shader inputs using AddShaderInput, and call Finalize to complete construction of the layout. This class is intended to be built using an offline shader compiler, and serialized to / from disk.

Member Function Documentation

◆ DebugPrintNames()

void AZ::RHI::ConstantsLayout::DebugPrintNames ( AZStd::span< const ShaderInputConstantIndex constantList) const

Prints to the console the shader input names specified by input list of indices Will ignore any indices outside of the inputs array bounds

◆ Finalize()

bool AZ::RHI::ConstantsLayout::Finalize ( )

Finalizes the layout for access. Must be called prior to usage or serialization. It is not permitted to mutate the layout once Finalize is called. Clear must be called first. If the call fails, the layout is cleared back to an empty state and false is returned. Otherwise, true is returned and the layout is considered finalized.

◆ FindShaderInputIndex()

ShaderInputConstantIndex AZ::RHI::ConstantsLayout::FindShaderInputIndex ( const Name &  name) const

Resolves a shader input name to an index. To maximize performance, the name to index resolve should be done as an initialization step and the indices cached.

◆ GetShaderInput()

const ShaderInputConstantDescriptor & AZ::RHI::ConstantsLayout::GetShaderInput ( ShaderInputConstantIndex  inputIndex) const

Returns the shader input associated with the requested index. It is not permitted to call this method with a null index. An assert will fire otherwise.

◆ GetShaderInputList()

AZStd::span< const ShaderInputConstantDescriptor > AZ::RHI::ConstantsLayout::GetShaderInputList ( ) const

Returns the full lists of shader input added to the layout. Inputs maintain their original order with respect to AddShaderInput.

◆ ValidateAccess()

bool AZ::RHI::ConstantsLayout::ValidateAccess ( ShaderInputConstantIndex  inputIndex) const

Validates that the inputIndex is valid. Emits an assert and returns false on failure; returns true on success. If validation is disabled, true is always returned.


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