Skip to content

LiteFX::Rendering::Backends::DirectX12ShaderModule::shaderLocalDescriptor

For ray-tracing shader modules returns the binding point for the descriptor that receives shader-local data.

Synopsis

Declared in <litefx/backends/dx12.hpp>

[[dllimport, dllexport]] virtual Optional<DescriptorBindingPoint> const& shaderLocalDescriptor() const noexcept override;

Description

Ray-tracing shaders, especially hit and intersection shaders may rely on local per-invocation data to handle ray intersections. One prominent example of such data is a custom index that identifies the geometry within the instance that has been hit, which can then be used to index into bindless arrays to acquire additional data, such as material properties or texture maps. This data is placed alongside the shader binding table created from a ShaderRecordCollection and passed to the shader when it is invoked. However, when building the IPipelineLayout for a ray-tracing pipeline, the device needs to know which descriptors bind globally and which descriptor binds locally. This information currently cannot be reliably acquired by shader reflection and must thus be specified on a per-module basis.

Note that it is only possible for one descriptor to bind to local data. However, this descriptor can bind a constant/uniform buffer that contains multiple variables. Whilst it is possible to bind buffer references (using IDeviceMemory::virtualAddress), support for it is differs depending on the shader language. To keep shaders portable, it is recommended to use descriptor indexing to bind buffers and textures and only pass constant values into local descriptor bindings.

For shader modules of types other than ray-tracing, this setting is ignored.

Return Value

Returns the binding point for the descriptor that receives shader-local data.

See Also

ShaderRecord