From 33bc042e9c863bf9835aa409d6822f6e0553900d Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 2 May 2023 10:44:15 +0200 Subject: [PATCH] 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 --- Changelog.md | 10 +++++++--- ash/src/vk/definitions.rs | 5 +++++ generator/src/lib.rs | 37 +++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Changelog.md b/Changelog.md index 20228b2c6..8fda52738 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,5 @@ # Changelog + 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/), @@ -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_EXT_shader_object` device extension (#732) - Added missing `Device::get_device_queue2()` wrapper (#736) +- Exposed `FramebufferCreateInfoBuilder::attachment_count()` builder for `vk::FramebufferCreateFlags::IMAGELESS` (#747) ## [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 OSX build errors of the examples - ## Before 0.30.0 ### 0.29.0 + - -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 - 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. + ### 0.28.0 + - Switched to a new [changelog](https://keepachangelog.com/en/1.0.0/) format - Fixed a build issue on ARM. - -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. - Builder now uses bool instead of Bool32. + ### 0.25.0 - Adds support for Vulkan 1.1 @@ -353,8 +358,8 @@ flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER_BIT, - Various bug fixes - ### 0.18.0 + - Fixes arm build => uses libc everywhere. Remove `AlignByteSlice`. ### 0.17.0 @@ -368,7 +373,6 @@ flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER_BIT, - `ash::util::Align` is a helper struct that can write to aligned memory. - [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.1]: https://github.com/MaikKlein/ash/releases/tag/0.37.1 diff --git a/ash/src/vk/definitions.rs b/ash/src/vk/definitions.rs index 849ec8552..fdaa463e3 100644 --- a/ash/src/vk/definitions.rs +++ b/ash/src/vk/definitions.rs @@ -10284,6 +10284,11 @@ impl<'a> FramebufferCreateInfoBuilder<'a> { self } #[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 { self.inner.attachment_count = attachments.len() as _; self.inner.p_attachments = attachments.as_ptr(); diff --git a/generator/src/lib.rs b/generator/src/lib.rs index cda2cbbe1..188c92faf 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1793,33 +1793,31 @@ pub fn derive_setters( // Must either have both, or none: assert_eq!(next_field.is_some(), structure_type_field.is_some()); - let nofilter_count_members = [ - ("VkPipelineViewportStateCreateInfo", "pViewports"), - ("VkPipelineViewportStateCreateInfo", "pScissors"), - ("VkDescriptorSetLayoutBinding", "pImmutableSamplers"), + let allowed_count_members = [ + // pViewports is allowed to be empty if the viewport state is empty + ("VkPipelineViewportStateCreateInfo", "viewportCount"), + // 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 = members + let filter_members = members .iter() .filter_map(|(field, _)| { - let field_name = field.name.as_ref().unwrap(); - // Associated _count members if field.array.is_some() { - if let Some(ref array_size) = field.size { - if !nofilter_count_members.contains(&(&struct_.name, field_name)) { - return Some((*array_size).clone()); + if let Some(array_size) = &field.size { + if !allowed_count_members.contains(&(&struct_.name, array_size)) { + return Some(array_size); } } } - // VkShaderModuleCreateInfo requires a custom setter - if field_name == "codeSize" { - return Some(field_name.clone()); - } - None }) - .collect(); + .collect::>(); let setters = members.iter().filter_map(|(field, 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); if let Some(name) = field.name.as_ref() { - // Filter - if filter_members.iter().any(|n| *n == *name) { + if filter_members.contains(&name) { return None; } // Unique cases + if struct_.name == "VkShaderModuleCreateInfo" && name == "codeSize" { + return None; + } + if struct_.name == "VkShaderModuleCreateInfo" && name == "pCode" { return Some(quote!{ #[inline]