From 96133938ea7d26c4b44f38a2d3a389222e2a84bb Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 30 Oct 2023 11:52:07 +0100 Subject: [PATCH] Enable `descriptor_count()` setter on `ash::vk::WriteDescriptorSet` This parameter is not only used for the length of `pImageInfo`, `pBufferInfo` or `pTexelBufferView`, but also matching the value of `dataSize` when `VkWriteDescriptorSetInlineUniformBlock` is appended in `pNext`, or the value of `accelerationStructureCount` when `VkWriteDescriptorSetAccelerationStructureKHR` is in `pNext`. Having the count setter directly avaialble makes builder code more natural, instead of having to use a `mut` variable and manually assign `.descriptor_count = xx.len();` afterwards. https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkWriteDescriptorSet.html --- Changelog.md | 1 + ash/src/vk/definitions.rs | 5 +++++ generator/src/lib.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Changelog.md b/Changelog.md index b0654193e..2a9fe580f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_NV_low_latency2` device extension (#802) - Added `VK_EXT_hdr_metadata` device extension (#804) - Added `VK_NV_cuda_kernel_launch` device extension (#805) +- Added `descriptor_count()` setter on `ash::vk::WriteDescriptorSet` (#809) ### Changed diff --git a/ash/src/vk/definitions.rs b/ash/src/vk/definitions.rs index 6646a5292..d9f9dc5bb 100644 --- a/ash/src/vk/definitions.rs +++ b/ash/src/vk/definitions.rs @@ -1835,6 +1835,11 @@ impl<'a> WriteDescriptorSet<'a> { self } #[inline] + pub fn descriptor_count(mut self, descriptor_count: u32) -> Self { + self.descriptor_count = descriptor_count; + self + } + #[inline] pub fn descriptor_type(mut self, descriptor_type: DescriptorType) -> Self { self.descriptor_type = descriptor_type; self diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 3cc8ad857..5eb3bfbe7 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1893,6 +1893,9 @@ fn derive_setters( ("VkDescriptorSetLayoutBinding", "descriptorCount"), // No ImageView attachments when VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT is set ("VkFramebufferCreateInfo", "attachmentCount"), + // descriptorCount also describes descriptor length in pNext extension structures + // https://github.com/ash-rs/ash/issues/806 + ("VkWriteDescriptorSet", "descriptorCount"), ]; let skip_members = members .iter()