Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable descriptor_count() setter on ash::vk::WriteDescriptorSet #809

Merged

Conversation

MarijnS95
Copy link
Collaborator

Fixes #806

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

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
@Ralith
Copy link
Collaborator

Ralith commented Oct 30, 2023

There's always FRU syntax, but yeah.

@MarijnS95
Copy link
Collaborator Author

Sure, but it feels as hidden away as the mut variant, while in this case there are multiple obvious uses where this member needs to be used in isolation.

Combined FRU syntax isn't too nice to read in my opinion:

let write_descriptor_set = vk::WriteDescriptorSet {
    descriptor_count: as.acceleration_structure_count,
    ..Default::default()
}
.dst_set(...)
.dst_binding(0)
.descriptor_type(vk::DescriptorType::ACCELERATION_STRUCTURE_KHR)
.push_next(&mut as);

Unless one moves all member assignments (PODs) into FRU, except .push_next() which requires casting and should update the lifetime.

@MarijnS95 MarijnS95 merged commit 335251d into master Oct 31, 2023
22 checks passed
@MarijnS95 MarijnS95 deleted the write-descriptor-set-expose-descriptor_count-setter branch October 31, 2023 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Descriptor count for INLINE_UNIFORM_BLOCK WriteDescriptorSet
2 participants