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:
parent
23da5dbc8c
commit
ae53f73bae
2 changed files with 24 additions and 18 deletions
|
@ -7276,6 +7276,11 @@ impl<'a> FramebufferCreateInfo<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
|
pub fn attachment_count(mut self, attachment_count: u32) -> Self {
|
||||||
|
self.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.attachment_count = attachments.len() as _;
|
self.attachment_count = attachments.len() as _;
|
||||||
self.p_attachments = attachments.as_ptr();
|
self.p_attachments = attachments.as_ptr();
|
||||||
|
|
|
@ -1786,33 +1786,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)]));
|
||||||
|
@ -1831,12 +1829,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]
|
||||||
|
|
Loading…
Add table
Reference in a new issue