RWByteAddressBuffer.LoadAligned
Description
Load a value with type T from the buffer at the specified location with a known alignment.
Signature
T RWByteAddressBuffer.LoadAligned<T>( uint location, uint alignment); T RWByteAddressBuffer.LoadAligned<T>(uint location);
Generic Parameters
T
The type of the value to load from the buffer.
Parameters
location : uint
The input address in bytes, which must be a multiple of alignment.
alignment : uint
The known alignment of location in bytes; a compile-time constant.
Return value
The value loaded from the buffer.
Remarks
alignment selects the widest power-of-two-width access it permits: a single wide load when it covers the whole T, otherwise the widest aligned chunks with per-component loads for any remainder. The rule applies to each vector within T: a struct is loaded field by field, a 3-component vector is always split because no power-of-two alignment is a multiple of its size, and a partially covered bool vector is loaded per component. For example, LoadAligned<float4>(location, 8) lowers as follows:
- HLSL with a Shader Model 5.0 or earlier profile: four uint loads, each converted with asfloat.
- HLSL with a Shader Model 5.1 or later profile, SPIR-V, GLSL, CUDA and C++: two float2 loads.
- Metal, WGSL and LLVM-based CPU targets: four per-component loads, for any valid alignment.
Availability and Requirements
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cpp
Available in all stages.
cuda
Available in all stages.
metal
Available in all stages.
wgsl
Available in all stages.
spirv
Available in all stages.
llvm
Available in all stages.