Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions chapters/descriptor_heap.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ The results are: `x == vec4(4)` and `y == vec4(5)`

The formula is `offset = heapOffset + (pushIndex * heapIndexStride) + (shaderIndex * heapArrayStride)`

The `pushOffset = 8` sets `pushIndex` to `0x10`
The `pushOffset = 8` sets `pushIndex` to `2`

----
u_buffers[0] offset = 0x20 + (0x10 * 2) + (0 * 0x10)
u_buffers[1] offset = 0x20 + (0x10 * 2) + (1 * 0x10)
u_buffers[0] offset = 0x20 + (2 * 0x10) + (0 * 0x10)
u_buffers[1] offset = 0x20 + (2 * 0x10) + (1 * 0x10)
----

==== VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_EXT
Expand Down Expand Up @@ -356,6 +356,44 @@ Only Uniform Buffers, Storage Buffers, and Acceleration Structures are allowed f
todo - Add Ray Tracing section
====

=== VkDescriptorMappingSourceEXT bindingCount alias

When setting `VkDescriptorSetAndBindingMappingEXT`, there are `firstBinding` and `bindingCount` fields.

The idea is that with a single mapping, you can apply the offsets for multiple bindings within a descriptor set.

For example, imagine the following shader:

[source,glsl]
----
layout(binding = 1) uniform sampler2D a[4];
layout(binding = 3) uniform sampler2D b;
layout(binding = 4) uniform sampler2D c;
----

If the mapping is configured as follows:

[source,c++]
----
VkDescriptorSetAndBindingMappingEXT mapping;
mapping.firstBinding = 1;
mapping.bindingCount = 4; // Covers bindings 1, 2, 3, and 4
mapping.source = VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_CONSTANT_OFFSET_EXT;
mapping.sourceData.heapOffset = 0;
mapping.sourceData.heapArrayStride = 0x10;
----

Each binding can be viewed as an index into the mapping. The respective offsets for each descriptor are calculated as follows:

- `a[0]` = `0x00`
- `a[1]` = `0x10`
- `a[2]` = `0x20`
- `a[3]` = `0x30`
- `b` = `0x20`
- `c` = `0x30`

Note that both `a[2]` and `b` share the same descriptor offset here. This overlapping behavior is completely by design!

== Untyped shader model

The above usage of `VkShaderDescriptorSetAndBindingMappingInfoEXT` was designed to allow backwards compatibility.
Expand Down
2 changes: 1 addition & 1 deletion chapters/images/descriptor_heap_push_index.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading