Expose FramebufferCreateInfo::attachment_count builder for IMAGELESS (#747)

* Expose `FramebufferCreateInfo::attachment_count` builder for `IMAGELESS`

Don't omit the `attachment_count()` builder method, because it is valid
to set the number of attachments without providing attachments in the
`IMAGELESS` case.

Also change the generator array lookup to use the name of the count
field that is allowed to have a builder method, rather than the name of
the field that would use this as `len` field and hence cause it to be
skipped.

* Clean up clones
This commit is contained in:
Marijn Suijten 2023-05-02 10:44:15 +02:00
parent 0cd90ef75d
commit 33bc042e9c
No known key found for this signature in database
GPG key ID: 78B516122FCACECE
3 changed files with 31 additions and 21 deletions

View file

@ -1,4 +1,5 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@ -12,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_KHR_performance_query` device extension (#726) - Added `VK_KHR_performance_query` device extension (#726)
- Added `VK_EXT_shader_object` device extension (#732) - Added `VK_EXT_shader_object` device extension (#732)
- Added missing `Device::get_device_queue2()` wrapper (#736) - Added missing `Device::get_device_queue2()` wrapper (#736)
- Exposed `FramebufferCreateInfoBuilder::attachment_count()` builder for `vk::FramebufferCreateFlags::IMAGELESS` (#747)
## [0.37.2] - 2022-01-11 ## [0.37.2] - 2022-01-11
@ -289,15 +291,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix XCB types - Fix XCB types
- Fix OSX build errors of the examples - Fix OSX build errors of the examples
## Before 0.30.0 ## Before 0.30.0
### 0.29.0 ### 0.29.0
- -Breaking-: Removed Display impl for flags. The Debug impl now reports flags by name. - -Breaking-: Removed Display impl for flags. The Debug impl now reports flags by name.
- Functions now have a doc comment that links to the Vulkan spec - Functions now have a doc comment that links to the Vulkan spec
- Entry has a new method called `try_enumerate_instance_version` which can be used in a 1.0 context. - Entry has a new method called `try_enumerate_instance_version` which can be used in a 1.0 context.
- The generator now uses `BTreeMap` for better diffs. - The generator now uses `BTreeMap` for better diffs.
### 0.28.0 ### 0.28.0
- Switched to a new [changelog](https://keepachangelog.com/en/1.0.0/) format - Switched to a new [changelog](https://keepachangelog.com/en/1.0.0/) format
- Fixed a build issue on ARM. - Fixed a build issue on ARM.
- -Breaking- Arrays are now passed by reference. - -Breaking- Arrays are now passed by reference.
@ -322,6 +326,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Expose function pointers for easier interop with external libraries. - Expose function pointers for easier interop with external libraries.
- Builder now uses bool instead of Bool32. - Builder now uses bool instead of Bool32.
### 0.25.0 ### 0.25.0
- Adds support for Vulkan 1.1 - Adds support for Vulkan 1.1
@ -353,8 +358,8 @@ flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER_BIT,
- Various bug fixes - Various bug fixes
### 0.18.0 ### 0.18.0
- Fixes arm build => uses libc everywhere. Remove `AlignByteSlice`. - Fixes arm build => uses libc everywhere. Remove `AlignByteSlice`.
### 0.17.0 ### 0.17.0
@ -368,7 +373,6 @@ flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER_BIT,
- `ash::util::Align` is a helper struct that - `ash::util::Align` is a helper struct that
can write to aligned memory. can write to aligned memory.
[Unreleased]: https://github.com/MaikKlein/ash/compare/0.37.2...HEAD [Unreleased]: https://github.com/MaikKlein/ash/compare/0.37.2...HEAD
[0.37.2]: https://github.com/MaikKlein/ash/releases/tag/0.37.2 [0.37.2]: https://github.com/MaikKlein/ash/releases/tag/0.37.2
[0.37.1]: https://github.com/MaikKlein/ash/releases/tag/0.37.1 [0.37.1]: https://github.com/MaikKlein/ash/releases/tag/0.37.1

View file

@ -10284,6 +10284,11 @@ impl<'a> FramebufferCreateInfoBuilder<'a> {
self self
} }
#[inline] #[inline]
pub fn attachment_count(mut self, attachment_count: u32) -> Self {
self.inner.attachment_count = attachment_count;
self
}
#[inline]
pub fn attachments(mut self, attachments: &'a [ImageView]) -> Self { pub fn attachments(mut self, attachments: &'a [ImageView]) -> Self {
self.inner.attachment_count = attachments.len() as _; self.inner.attachment_count = attachments.len() as _;
self.inner.p_attachments = attachments.as_ptr(); self.inner.p_attachments = attachments.as_ptr();

View file

@ -1793,33 +1793,31 @@ pub fn derive_setters(
// Must either have both, or none: // Must either have both, or none:
assert_eq!(next_field.is_some(), structure_type_field.is_some()); assert_eq!(next_field.is_some(), structure_type_field.is_some());
let nofilter_count_members = [ let allowed_count_members = [
("VkPipelineViewportStateCreateInfo", "pViewports"), // pViewports is allowed to be empty if the viewport state is empty
("VkPipelineViewportStateCreateInfo", "pScissors"), ("VkPipelineViewportStateCreateInfo", "viewportCount"),
("VkDescriptorSetLayoutBinding", "pImmutableSamplers"), // Must match viewportCount
("VkPipelineViewportStateCreateInfo", "scissorCount"),
// descriptorCount is settable regardless of having pImmutableSamplers
("VkDescriptorSetLayoutBinding", "descriptorCount"),
// No ImageView attachments when VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT is set
("VkFramebufferCreateInfo", "attachmentCount"),
]; ];
let filter_members: Vec<String> = members let filter_members = members
.iter() .iter()
.filter_map(|(field, _)| { .filter_map(|(field, _)| {
let field_name = field.name.as_ref().unwrap();
// Associated _count members // Associated _count members
if field.array.is_some() { if field.array.is_some() {
if let Some(ref array_size) = field.size { if let Some(array_size) = &field.size {
if !nofilter_count_members.contains(&(&struct_.name, field_name)) { if !allowed_count_members.contains(&(&struct_.name, array_size)) {
return Some((*array_size).clone()); return Some(array_size);
} }
} }
} }
// VkShaderModuleCreateInfo requires a custom setter
if field_name == "codeSize" {
return Some(field_name.clone());
}
None None
}) })
.collect(); .collect::<Vec<_>>();
let setters = members.iter().filter_map(|(field, deprecated)| { let setters = members.iter().filter_map(|(field, deprecated)| {
let deprecated = deprecated.as_ref().map(|d| quote!(#d #[allow(deprecated)])); let deprecated = deprecated.as_ref().map(|d| quote!(#d #[allow(deprecated)]));
@ -1838,12 +1836,15 @@ pub fn derive_setters(
let mut param_ident_short = format_ident!("{}", param_ident_short); let mut param_ident_short = format_ident!("{}", param_ident_short);
if let Some(name) = field.name.as_ref() { if let Some(name) = field.name.as_ref() {
// Filter if filter_members.contains(&name) {
if filter_members.iter().any(|n| *n == *name) {
return None; return None;
} }
// Unique cases // Unique cases
if struct_.name == "VkShaderModuleCreateInfo" && name == "codeSize" {
return None;
}
if struct_.name == "VkShaderModuleCreateInfo" && name == "pCode" { if struct_.name == "VkShaderModuleCreateInfo" && name == "pCode" {
return Some(quote!{ return Some(quote!{
#[inline] #[inline]