diff --git a/chapters/descriptor_heap.adoc b/chapters/descriptor_heap.adoc index 8f81c43..326552b 100644 --- a/chapters/descriptor_heap.adoc +++ b/chapters/descriptor_heap.adoc @@ -485,10 +485,21 @@ image::{images}descriptor_heap_stride_alignment.svg[descriptor_heap_stride_align === Indirect Buffer alignment -Some mappings (such as `VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_EXT`) have an "indirect" Uniform or Storage buffer used. Access into these buffer need to be aligned with either `minUniformBufferOffsetAlignment` or `minStorageBufferOffsetAlignment`. +Some mappings have an "indirect" Uniform buffer used. + +At first, you might think these access need to be aligned to `minUniformBufferOffsetAlignment`, but since these are being accessed as "indirect buffers" and not a "descriptor" they follow scalar alignment rules. + +- `VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_EXT`/`VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_ARRAY_EXT` will load a `uint32_t` offset. Needs to be aligned to 4 bytes. +- `VK_DESCRIPTOR_MAPPING_SOURCE_INDIRECT_ADDRESS_EXT` will load a `VkDeviceAddress` to the final descriptor. Needs to be aligned to 8 bytes. + +Using the following diagram: image::{images}descriptor_heap_indirect_alignment.svg[descriptor_heap_indirect_alignment.svg] +both `0x4000` and `0x4008` are aligned to 8 bytes which is valid. If it was `0x4004` that would be invalid. + +The final address (`0x8000` and `0x8040`) need to be aligned to `minUniformBufferOffsetAlignment` as it accesses that memory as an Uniform Buffer Descriptor. + == Combined Image Samplers The `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER` is a special descriptor and deserves it's own mention if you are planning to use it with `VK_EXT_descriptor_heap`. diff --git a/chapters/images/descriptor_heap_indirect_alignment.svg b/chapters/images/descriptor_heap_indirect_alignment.svg index a4e23a5..c144829 100644 --- a/chapters/images/descriptor_heap_indirect_alignment.svg +++ b/chapters/images/descriptor_heap_indirect_alignment.svg @@ -1,4 +1,4 @@ -
0x4000
0
8
16
0x4024
Valid
0x4000 is aligned to 0x40
0x4000
0x4040
0x4020
minUniformBufferOffsetAlignment = 0x40 (64)

source = VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_EXT
sourceData.indirectIndex.pushOffset = 0x0;
sourceData.indirectIndex.pushOffset = 0x8;
0x4000
0
8
16
0x4024
invalid
0x4024 is not aligned to 0x40
VkBuffer
(Uniform Buffer)
0x4000
0x4040
0x4020
Push Data
\ No newline at end of file +
0x4000
0
8
16
0x4008

0x4000
0x4020
0x4010
minUniformBufferOffsetAlignment = 0x40 (64)

source = VK_DESCRIPTOR_MAPPING_SOURCE_INDIRECT_ADDRESS_EXT
sourceData.indirectAddress.pushOffset = 0x0;
sourceData.indirectAddress.pushOffset = 0x8;
0x4000
0
8
16
0x4008
VkBuffer
(Uniform Buffer)
Push Data
0x8000
0x8040
0x0000
0x0000
UBO Data
\ No newline at end of file