[D3D12]Bindless Resources Notes
keywords: Direct3D 12, D3D12, Vulkan, Bindless, Texture and Buffer, DescriptorSet, Descriptor Set Layout, Descriptor Indexing
Summary
Advantages
Difference between array textures (slot-based) and bindless textures:
Array textures are generally restricted by the fact that all textures in the array are required to use the same format and dimensions. Bindless textures are independent in size and format, but can still be accessed directly from the shader and don't require a CPU-side bind call to enable them for the shader.
Quoted from: How are bindless resources different from slot-based resources
The bindless descriptors advantages:
Bindless designs make the cpu side work a lot faster due to the CPU having to do much less work, and the GPU can also go faster due to better utilization as each drawcall is “bigger”. The less drawcalls you use to render your scene, the better, as modern GPUs are really big and have a big ramp up/ramp down time.
Quoted from GPU Driven Rendering Overview
Optimization
Quoted from Intel® Processor Graphics Xᵉ-LP API Developer and Optimization Guide:
Modern Graphics APIs give you more control over resource binding, such as with DirectX Root Signatures and Vulkan* Pipeline Layout. Using these requires particular attention to maximize performance. When designing an application strategy for resource binding, employ the following guidance:
- Minimize the number of root signature slots or descriptor sets to only what will be used by a shader.
- Try to find a balance between root signature or descriptor set reuse across shaders.
- For multiple constant buffers that do not change between draws, consider packing all constant buffer views into one descriptor table.
- For multiple Unordered Access Views (UAVs) and Shader Resource Views (SRVs) that do not span a consecutive range of registers and do not change between draws, it is best to pack them into a descriptor table.
- Minimize descriptor heap changes. Changing descriptor heaps severely stalls the graphics pipeline. Ideally, all resources will have views appropriated out of one descriptor heap.
- Avoid generic root signature definitions where unnecessary descriptors are defined and not leveraged. Instead, optimize root signature definitions to the minimal set of descriptor tables needed.
- Vulkan: When creating a Descriptor Set, using the BindAfterFlag bit beware that Xe-LP only supports 1M Descriptors. Only Create needed descriptors (when porting from DX12, remember that
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV
maps to 7 Vulkan types [VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
,*_STORAGE_IMAGE
,*_UNIFORM_TEXEL_BUFFER
,*_STORAGE_TEXEL_BUFFER
,*_UNIFORM_BUFFER
,*_STORAGE_BUFFER
])
- Vulkan: When creating a Descriptor Set, using the BindAfterFlag bit beware that Xe-LP only supports 1M Descriptors. Only Create needed descriptors (when porting from DX12, remember that
- Favor root constants over root descriptors, and favor root descriptors over descriptor tables when working with constants.
- Make use of root/push constants to enable fast access to constant buffer data (they are pre-loaded into registers).
- Root/push constants are great to use on frequently changing constant buffer data.
- Use root/push constants for cases where the constants are changing at a high frequency.
- If certain Root Signature slots are less frequently used (not referenced by a PSO), put those at the end of the root signature to reduce GRF usage
- Be sure to use hints that allow the driver to perform constant-based optimizations, such as
D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC
. - For placed resources, initialize with a clear, copy, or discard before rendering to the resource. This helps enable proper compression by putting the placed resource into a valid state.
- When creating resource heaps, resources that need to be accessed by the GPU should be placed in heaps that are declared as resident in GPU memory, preferably exclusively. This has a significant impact on discrete GPU performance.
- Use queries to identify scenarios when GPU local memory gets oversubscribed and adjust resource location to accommodate this.
Presentations
Exploration of Bindless Rendering in Vulkan, DirectX 12, and OpenGL [2021-04-21]
https://www.youtube.com/watch?v=SVm0HanVTRw
D3D12
Documents
Bindless Descriptors
https://wickedengine.net/2021/04/06/bindless-descriptors/
Binding Bindlessly
https://alextardif.com/Bindless.html
Bindless Texturing for Deferred Rendering and Decals
https://therealmjp.github.io/posts/bindless-texturing-for-deferred-rendering-and-decals/
https://github.com/TheRealMJP/DeferredTexturing
Vulkan
Documents
Managing bindless descriptors in Vulkan
https://dev.to/gasim/implementing-bindless-design-in-vulkan-34no
New game changing Vulkan extensions for mobile: Descriptor Indexing
Vulkan Pills 1: Bindless Textures
https://jorenjoestar.github.io/post/vulkan_bindless_texture/
Bindless descriptor sets
https://vincent-p.github.io/posts/vulkan_bindless_descriptors/
Descriptorless Rendering in Vulkan
https://msiglreith.gitbook.io/blog/descriptorless-rendering-in-vulkan
Presentations
Setting up a bindless rendering pipeline
Resources & Descriptors | “Use Buffers and Images in Vulkan Shaders”
https://www.youtube.com/watch?v=5VBVWCg7riQ
One moment of patience may ward off great disaster. One moment of impatience may ruin a whole life. -Chinese Proverbs