Skip to content

Commit

Permalink
Expose FramebufferCreateInfo::attachment_count builder for `IMAGELE…
Browse files Browse the repository at this point in the history
…SS` (#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
  • Loading branch information
MarijnS95 committed May 2, 2023
1 parent 0cd90ef commit 33bc042
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
10 changes: 7 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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/),
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions ash/src/vk/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
37 changes: 19 additions & 18 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = 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::<Vec<_>>();

let setters = members.iter().filter_map(|(field, deprecated)| {
let deprecated = deprecated.as_ref().map(|d| quote!(#d #[allow(deprecated)]));
Expand All @@ -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]
Expand Down

0 comments on commit 33bc042

Please sign in to comment.