From bea8baee72618de7fb36f1ec810ae41b194b1979 Mon Sep 17 00:00:00 2001 From: spencer-lunarg Date: Thu, 9 Jul 2026 15:57:04 -0400 Subject: [PATCH] heaps: Add NullDescriptor section --- chapters/descriptor_heap.adoc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/chapters/descriptor_heap.adoc b/chapters/descriptor_heap.adoc index 900f48d..bba04f6 100644 --- a/chapters/descriptor_heap.adoc +++ b/chapters/descriptor_heap.adoc @@ -538,6 +538,39 @@ both `0x4000` and `0x4008` are aligned to 8 bytes which is valid. If it was `0x4 The final address (`0x8000` and `0x8040`) need to be aligned to `minUniformBufferOffsetAlignment` as it accesses that memory as an Uniform Buffer Descriptor. +== Null Descriptors + +The link:https://docs.vulkan.org/spec/latest/chapters/features.html#features-nullDescriptor[nullDescriptor] feature is a form of xref:{chapters}/robustness.adoc[robustness] that allows descriptors to be both null and valid. If you write a null descriptor the writes are discarded. If you read from a null descriptor it will return a defined value (mainly zero). + +[NOTE] +==== +There is no null descriptor for samplers. +==== + +To get a null descriptor simply set `VkResourceDescriptorDataEXT` to null when calling `vkWriteResourceDescriptorsEXT` + +[source,c++] +---- +// Example getting a UBO null descriptor +uint8_t host_data[256]; +VkHostAddressRangeEXT host_range; +host_range.address = host_data; +host_range.size = bufferDescriptorSize; // VkPhysicalDeviceDescriptorHeapPropertiesEXT + +VkResourceDescriptorInfoEXT desc_info; +desc_info.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; +desc_info.data.pAddressRange = nullptr; + +vkWriteResourceDescriptorsEXT(device, 1, &desc_info, &host_range); +---- + +From here you can put the `host_data` instead your descriptor heap. + +[NOTE] +==== +On some hardware, the null descriptor is just all zeros, but this is **not** always true and making such assumption can lead to trouble. +==== + == 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`.