Add "sledgehammer" option for buffer packing/unpacking for bound shader data #3726
Labels
feature/graphics
This item is related to the Atom renderer or graphics.
priority/minor
Lowest priority. Work that may be scheduled
sig/graphics-audio
Categorizes an issue or PR as relevant to SIG graphics-audio.
Is your feature request related to a problem? Please describe.
Resource binding rules are confusing. When all else fails and we don't want to bother ensuring consistent packing between CPU and GPU memory, we can use raw buffer views, accessed as ByteAddressBuffers in HLSL code.
Describe the solution you'd like
Accessing memory in this way requires the SRV to be created with the appropriate flag (D3D12_BUFFER_SRV_FLAG_RAW). After which, the bound slot is denoted as a ByteAddressBuffer (see https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-byteaddressbuffer).
The ByteAddressBuffer lets us load/store arbitrary data at dword-aligned offsets, meaning we can control the packing ourselves up to word granularity. Leveraging this, we can define a consistent packing rule across all APIs/platforms that support BAB semantics. Having this degree of packing control means we can guarantee all RHI backends that have the same support for the load/store code gen.
Additional context
Note that we technically have ByteAddressBuffer::Load and RWByteAddressBuffer::Store from here: microsoft/DirectXShaderCompiler#2176
However, on some GPUs, there may be unfortunate codegen using the templated loads/stores here: microsoft/hlsl-specs#258
The text was updated successfully, but these errors were encountered: