#include <ShaderResourceGroup.h>
Inherits AZ::Data::InstanceData.
Public Member Functions | |
AZ_INSTANCE_DATA (ShaderResourceGroup, "{88B52D0C-9CBF-4B4D-B9E2-180BA602E1EA}") | |
AZ_CLASS_ALLOCATOR (ShaderResourceGroup, AZ::SystemAllocator) | |
void | Compile () |
Queues a request that the underlying hardware shader resource group be compiled. | |
bool | IsQueuedForCompile () const |
Returns whether the group is currently queued for compilation. | |
RHI::ShaderInputBufferIndex | FindShaderInputBufferIndex (const Name &name) const |
Finds the shader input index from the shader input name for each type of resource. | |
RHI::ShaderInputImageIndex | FindShaderInputImageIndex (const Name &name) const |
RHI::ShaderInputSamplerIndex | FindShaderInputSamplerIndex (const Name &name) const |
RHI::ShaderInputConstantIndex | FindShaderInputConstantIndex (const Name &name) const |
RHI::ShaderInputBufferUnboundedArrayIndex | FindShaderInputBufferUnboundedArrayIndex (const Name &name) const |
RHI::ShaderInputImageUnboundedArrayIndex | FindShaderInputImageUnboundedArrayIndex (const Name &name) const |
const RHI::ShaderResourceGroupLayout * | GetLayout () const |
Returns the RHI shader resource group layout. | |
RHI::ShaderResourceGroup * | GetRHIShaderResourceGroup () |
Returns the underlying RHI shader resource group. | |
bool | SetShaderVariantKeyFallbackValue (const ShaderVariantKey &shaderKey) |
Sets the ShaderVariantKey value as constant data. Returns false if this SRG is not designated as fallback. | |
bool | HasShaderVariantKeyFallbackEntry () const |
Returns true if the ShaderResourceGroup has been designated as a ShaderVariantKey fallback. | |
bool | SetImage (RHI::ShaderInputNameIndex &inputIndex, const Data::Instance< Image > &image, uint32_t arrayIndex=0) |
Sets one RPI image for the given shader input index. | |
bool | SetImage (RHI::ShaderInputImageIndex inputIndex, const Data::Instance< Image > &image, uint32_t arrayIndex=0) |
bool | SetImageArray (RHI::ShaderInputNameIndex &inputIndex, AZStd::span< const Data::Instance< Image > > images, uint32_t arrayIndex=0) |
Sets multiple RPI images for the given shader input index. | |
bool | SetImageArray (RHI::ShaderInputImageIndex inputIndex, AZStd::span< const Data::Instance< Image > > images, uint32_t arrayIndex=0) |
const Data::Instance< Image > & | GetImage (RHI::ShaderInputNameIndex &inputIndex, uint32_t arrayIndex=0) const |
Returns a single RPI image associated with the image shader input index and array offset. | |
const Data::Instance< Image > & | GetImage (RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex=0) const |
AZStd::span< const Data::Instance< Image > > | GetImageArray (RHI::ShaderInputNameIndex &inputIndex) const |
Returns a span of RPI images associated with the image shader input index. | |
AZStd::span< const Data::Instance< Image > > | GetImageArray (RHI::ShaderInputImageIndex inputIndex) const |
bool | SetBuffer (RHI::ShaderInputNameIndex &inputIndex, const Data::Instance< Buffer > &buffer, uint32_t arrayIndex=0) |
Sets one RPI buffer for the given shader input index. | |
bool | SetBuffer (RHI::ShaderInputBufferIndex inputIndex, const Data::Instance< Buffer > &buffer, uint32_t arrayIndex=0) |
bool | SetBufferArray (RHI::ShaderInputNameIndex &inputIndex, AZStd::span< const Data::Instance< Buffer > > buffers, uint32_t arrayIndex=0) |
Sets multiple RPI buffers for the given shader input index. | |
bool | SetBufferArray (RHI::ShaderInputBufferIndex inputIndex, AZStd::span< const Data::Instance< Buffer > > buffers, uint32_t arrayIndex=0) |
const Data::Instance< Buffer > & | GetBuffer (RHI::ShaderInputNameIndex &inputIndex, uint32_t arrayIndex=0) const |
Returns a single RPI buffer associated with the buffer shader input index and array offset. | |
const Data::Instance< Buffer > & | GetBuffer (RHI::ShaderInputBufferIndex inputIndex, uint32_t arrayIndex=0) const |
AZStd::span< const Data::Instance< Buffer > > | GetBufferArray (RHI::ShaderInputNameIndex &inputIndex) const |
Returns a span of RPI buffers associated with the buffer shader input index. | |
AZStd::span< const Data::Instance< Buffer > > | GetBufferArray (RHI::ShaderInputBufferIndex inputIndex) const |
void | ResetViews () |
Reset image and buffer views so that it won't hold references for any RHI resources. | |
bool | SetImageView (RHI::ShaderInputNameIndex &inputIndex, const RHI::ImageView *imageView, uint32_t arrayIndex=0) |
Sets one image view for the given shader input index. | |
bool | SetImageView (RHI::ShaderInputImageIndex inputIndex, const RHI::ImageView *imageView, uint32_t arrayIndex=0) |
bool | SetImageViewArray (RHI::ShaderInputNameIndex &inputIndex, AZStd::span< const RHI::ImageView *const > imageViews, uint32_t arrayIndex=0) |
Sets an array of image view for the given shader input index. | |
bool | SetImageViewArray (RHI::ShaderInputImageIndex inputIndex, AZStd::span< const RHI::ImageView *const > imageViews, uint32_t arrayIndex=0) |
bool | SetImageViewUnboundedArray (RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span< const RHI::ImageView *const > imageViews) |
Sets an unbounded array of image views for the given shader input index. | |
void | SetBindlessViews (RHI::ShaderInputBufferIndex indirectResourceBufferIndex, const RHI::BufferView *indirectResourceBuffer, AZStd::span< const RHI::ImageView *const > imageViews, uint32_t *outIndices, AZStd::span< bool > isViewReadOnly, uint32_t arrayIndex=0) |
Update the indirect buffer view with the indices of all the image views which reside in the global gpu heap. | |
const RHI::ConstPtr< RHI::ImageView > & | GetImageView (RHI::ShaderInputNameIndex &inputIndex, uint32_t arrayIndex=0) const |
Returns a single image view associated with the image shader input index and array offset. | |
const RHI::ConstPtr< RHI::ImageView > & | GetImageView (RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex=0) const |
AZStd::span< const RHI::ConstPtr< RHI::ImageView > > | GetImageViewArray (RHI::ShaderInputNameIndex &inputIndex) const |
Returns a span of image views associated with the given image shader input index. | |
AZStd::span< const RHI::ConstPtr< RHI::ImageView > > | GetImageViewArray (RHI::ShaderInputImageIndex inputIndex) const |
bool | SetBufferView (RHI::ShaderInputNameIndex &inputIndex, const RHI::BufferView *bufferView, uint32_t arrayIndex=0) |
Sets one buffer view for the given shader input index. | |
bool | SetBufferView (RHI::ShaderInputBufferIndex inputIndex, const RHI::BufferView *bufferView, uint32_t arrayIndex=0) |
bool | SetBufferViewArray (RHI::ShaderInputNameIndex &inputIndex, AZStd::span< const RHI::BufferView *const > bufferViews, uint32_t arrayIndex=0) |
Sets an array of buffer view for the given shader input index. | |
bool | SetBufferViewArray (RHI::ShaderInputBufferIndex inputIndex, AZStd::span< const RHI::BufferView *const > bufferViews, uint32_t arrayIndex=0) |
bool | SetBufferViewUnboundedArray (RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span< const RHI::BufferView *const > bufferViews) |
Sets an unbounded array of buffer views for the given shader input index. | |
void | SetBindlessViews (RHI::ShaderInputBufferIndex indirectResourceBufferIndex, const RHI::BufferView *indirectResourceBuffer, AZStd::span< const RHI::BufferView *const > bufferViews, uint32_t *outIndices, AZStd::span< bool > isViewReadOnly, uint32_t arrayIndex=0) |
Update the indirect buffer view with the indices of all the buffer views which reside in the global gpu heap. | |
const RHI::ConstPtr< RHI::BufferView > & | GetBufferView (RHI::ShaderInputNameIndex &inputIndex, uint32_t arrayIndex=0) const |
Returns a single buffer view associated with the buffer shader input index and array offset. | |
const RHI::ConstPtr< RHI::BufferView > & | GetBufferView (RHI::ShaderInputBufferIndex inputIndex, uint32_t arrayIndex=0) const |
AZStd::span< const RHI::ConstPtr< RHI::BufferView > > | GetBufferViewArray (RHI::ShaderInputNameIndex &inputIndex) const |
Returns a span of buffer views associated with the given buffer shader input index. | |
AZStd::span< const RHI::ConstPtr< RHI::BufferView > > | GetBufferViewArray (RHI::ShaderInputBufferIndex inputIndex) const |
bool | SetSampler (RHI::ShaderInputNameIndex &inputIndex, const RHI::SamplerState &sampler, uint32_t arrayIndex=0) |
Sets one sampler for the given shader input index, using the bindingIndex as the key. | |
bool | SetSampler (RHI::ShaderInputSamplerIndex inputIndex, const RHI::SamplerState &sampler, uint32_t arrayIndex=0) |
bool | SetSamplerArray (RHI::ShaderInputNameIndex &inputIndex, AZStd::span< const RHI::SamplerState > samplers, uint32_t arrayIndex=0) |
Sets an array of samplers for the given shader input index. | |
bool | SetSamplerArray (RHI::ShaderInputSamplerIndex inputIndex, AZStd::span< const RHI::SamplerState > samplers, uint32_t arrayIndex=0) |
const RHI::SamplerState & | GetSampler (RHI::ShaderInputNameIndex &inputIndex, uint32_t arrayIndex) const |
Returns a single sampler associated with the sampler shader input index and array offset. | |
const RHI::SamplerState & | GetSampler (RHI::ShaderInputSamplerIndex inputIndex, uint32_t arrayIndex) const |
AZStd::span< const RHI::SamplerState > | GetSamplerArray (RHI::ShaderInputNameIndex &inputIndex) const |
Returns a span of samplers associated with the sampler shader input index. | |
AZStd::span< const RHI::SamplerState > | GetSamplerArray (RHI::ShaderInputSamplerIndex inputIndex) const |
bool | SetConstantRaw (RHI::ShaderInputNameIndex &inputIndex, const void *bytes, uint32_t byteCount) |
Assigns constant data for the given constant shader input index. | |
bool | SetConstantRaw (RHI::ShaderInputConstantIndex inputIndex, const void *bytes, uint32_t byteCount) |
bool | SetConstantRaw (RHI::ShaderInputNameIndex &inputIndex, const void *bytes, uint32_t byteOffset, uint32_t byteCount) |
bool | SetConstantRaw (RHI::ShaderInputConstantIndex inputIndex, const void *bytes, uint32_t byteOffset, uint32_t byteCount) |
template<typename T > | |
bool | SetConstant (RHI::ShaderInputNameIndex &inputIndex, const T &value) |
Assigns a value of type T to the constant shader input. | |
template<typename T > | |
bool | SetConstant (RHI::ShaderInputConstantIndex inputIndex, const T &value) |
template<typename T > | |
bool | SetConstantMatrixRows (RHI::ShaderInputNameIndex &inputIndex, const T &value, uint32_t rowCount) |
Assigns the specified number of rows from a Matrix. | |
template<typename T > | |
bool | SetConstantMatrixRows (RHI::ShaderInputConstantIndex inputIndex, const T &value, uint32_t rowCount) |
template<typename T > | |
bool | SetConstant (RHI::ShaderInputNameIndex &inputIndex, const T &value, uint32_t arrayIndex) |
Assigns a value of type T to the constant shader input, at an array offset. | |
template<typename T > | |
bool | SetConstant (RHI::ShaderInputConstantIndex inputIndex, const T &value, uint32_t arrayIndex) |
template<typename T > | |
bool | SetConstantArray (RHI::ShaderInputNameIndex &inputIndex, AZStd::span< const T > values) |
Assigns a span of type T to the constant shader input. | |
template<typename T > | |
bool | SetConstantArray (RHI::ShaderInputConstantIndex inputIndex, AZStd::span< const T > values) |
template<typename T , size_t N> | |
bool | SetConstantArray (RHI::ShaderInputNameIndex &inputIndex, const AZStd::array< T, N > &values) |
Assigns an array of type T to the constant shader input. | |
template<typename T , size_t N> | |
bool | SetConstantArray (RHI::ShaderInputConstantIndex inputIndex, const AZStd::array< T, N > &values) |
template<typename T > | |
bool | ApplyDataMappingArray (const AZStd::vector< T > &mappings) |
Assigns an array of shader data mappings of type T. | |
bool | ApplyDataMappings (const RHI::ShaderDataMappings &mappings) |
Assigns a group of shader data mapping arrays. | |
template<typename T > | |
AZStd::span< const T > | GetConstantArray (RHI::ShaderInputNameIndex &inputIndex) const |
template<typename T > | |
AZStd::span< const T > | GetConstantArray (RHI::ShaderInputConstantIndex inputIndex) const |
template<typename T > | |
T | GetConstant (RHI::ShaderInputNameIndex &inputIndex) const |
template<typename T > | |
T | GetConstant (RHI::ShaderInputConstantIndex inputIndex) const |
template<typename T > | |
T | GetConstant (RHI::ShaderInputNameIndex &inputIndex, uint32_t arrayIndex) const |
template<typename T > | |
T | GetConstant (RHI::ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const |
AZStd::span< const uint8_t > | GetConstantRaw (RHI::ShaderInputNameIndex &inputIndex) const |
Returns constant data for the given shader input index as a span of bytes. | |
AZStd::span< const uint8_t > | GetConstantRaw (RHI::ShaderInputConstantIndex inputIndex) const |
Static Public Member Functions | |
static Data::Instance< ShaderResourceGroup > | Create (const Data::Asset< ShaderAsset > &shaderAsset, const AZ::Name &srgName) |
static Data::Instance< ShaderResourceGroup > | Create (const Data::Asset< ShaderAsset > &shaderAsset, const SupervariantIndex &supervariantIndex, const AZ::Name &srgName) |
Friends | |
class | ShaderSystem |
class | ShaderResourceGroupPool |
This class is an RPI extension to the RHI shader resource group class. It provides support for instantiation from an asset, as well as assignment of RPI resource types.
This class supports assignment of both RPI and RHI types. If an RPI resource is bound at a specific location, the class will hold both the RPI and RHI references. On the other hand, if an RHI resource is bound, any previously held RPI resource is cleared. Therefore, it's possible that querying for an RPI resource will return null while querying the same location for an RHI resource will return a valid entry.
If RHI validation is enabled, the class will perform error checking. If a setter method fails an error is emitted and the call returns false without performing the requested operation. Likewise, if a getter method fails, an error is emitted and an empty value or empty array is returned. If validation is disabled, the operation is always performed.
|
static |
Instantiates a unique shader resource group instance using its paired asset but with a random InstanceId. This version uses the system-wide supervariant (if available) specified by the ShaderSystem or the Default supervariant.
|
static |
Instantiates a unique shader resource group instance using its paired asset but with a random InstanceId. This version uses the supervariant specified by the caller.
T AZ::RPI::ShaderResourceGroup::GetConstant | ( | RHI::ShaderInputNameIndex & | inputIndex | ) | const |
Returns the constant data as type 'T' returned by value. The size of the constant region must match the size of T exactly. Otherwise, an empty instance is returned.
T AZ::RPI::ShaderResourceGroup::GetConstant | ( | RHI::ShaderInputNameIndex & | inputIndex, |
uint32_t | arrayIndex | ||
) | const |
Treats the constant input as an array of type T, returning the element by value at the specified array index. The size of the constant region must equally partition into an array of type T. Otherwise, an empty instance is returned.
AZStd::span< const T > AZ::RPI::ShaderResourceGroup::GetConstantArray | ( | RHI::ShaderInputNameIndex & | inputIndex | ) | const |
Returns constant data for the given shader input index as a template type. The stride of T must match the size of the constant input region. The number of elements in the returned array is the number of evenly divisible elements. If the strides do not match, an empty array is returned.
const RHI::ShaderResourceGroupLayout * AZ::RPI::ShaderResourceGroup::GetLayout | ( | ) | const |
Returns the RHI shader resource group layout.
Returns the parent shader shader asset where the SRG layout data came from. const Data::Asset<ShaderAsset>& GetAsset() const;