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

Expose FramebufferCreateInfo::attachment_count builder for IMAGELESS #747

Merged
merged 2 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
MarijnS95 committed May 1, 2023
commit 26c77869da24acb0c57acd576aaf7f23f714cd05
5 changes: 5 additions & 0 deletions ash/src/vk/definitions.rs
Original file line number Diff line number Diff line change
@@ -7276,6 +7276,11 @@ impl<'a> FramebufferCreateInfo<'a> {
self
}
#[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 {
self.attachment_count = attachments.len() as _;
self.p_attachments = attachments.as_ptr();
15 changes: 10 additions & 5 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1786,10 +1786,15 @@ 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<String> = members
.iter()
@@ -1799,7 +1804,7 @@ pub fn derive_setters(
// 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)) {
if !allowed_count_members.contains(&(&struct_.name, array_size)) {
return Some((*array_size).clone());
}
}