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

Update Vulkan-Headers to 1.2.162 with stable ray-tracing spec #341

Merged
merged 8 commits into from
Dec 13, 2020

Conversation

MarijnS95
Copy link
Collaborator

@MarijnS95 MarijnS95 commented Nov 23, 2020

Depends on #339
Fixes #277

Update to the first stable ray-tracing spec released this morning in KhronosGroup/Vulkan-Headers@d230818. VK_KHR_ray_tracing is now separated in VK_KHR_ray_tracing_pipeline, VK_KHR_ray_query and VK_KHR_acceleration_structure. Safe extensions wrappers have been updated to account for this.

The only interesting change in the generator is dealing with constant-sized arrays, used in VkAccelerationStructureVersionInfoKHR:

<member len="2*ename:VK_UUID_SIZE" altlen="2*VK_UUID_SIZE">const <type>uint8_t</type>* <name>pVersionData</name></member>

Comment on lines 1786 to 1802
let (slice_param_ty_tokens, set_size_stmt) = if array_size.contains("ename:") {
// Should contain the same minus `ename:`-prefixed identifiers
let array_size = field.c_size.as_ref().unwrap();
let c_size = convert_c_expression(array_size);

(
quote!(&'a #mutable_ref [#slice_type; #c_size]),
quote!(),
)
} else {
let array_size_ident = Ident::from(array_size.to_snake_case().as_str());
(
quote!(&'a #mutable_ref [#slice_type]),
quote!(self.inner.#array_size_ident = #param_ident_short.len() as _;),
)
};
Copy link
Collaborator Author

@MarijnS95 MarijnS95 Nov 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like hacking in this static size in vkxml::ArrayType::Dynamic, but this field is weird: it's definitely a pointer according to the *, p prefix and the header:
KhronosGroup/Vulkan-Headers@d230818#diff-e222ae95c2b0d5082b94d6086fb1c24da18ee31384c1a39840df3b9152023ee6R11550, but the size of the data it points to is statically known. Perhaps we need a third state for this in vkxml::Field?

Otherwise I'd have implemented it something like this: a9b79a3

EDIT: Turns out the field was always there, but the problem never showed up because the setter code for dynamic arrays only runs if the name starts with p or pp. This was fixed in these headers, but I've also fixed in #339 by running this code on every reference (field.reference.is_none()). Perhaps the spec should turn this into a pointer to a fixed-size array of uint8_t[16] though.

Copy link
Collaborator Author

@MarijnS95 MarijnS95 Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spent some more time on this over the weekend (have an itch for perfecting "irrelevant" bits of code), and with there being no proper way to represent this const uint8_t (* versionData)[2 * VK_UUID_SIZE] in vk.xml it seems easiest to override the array type to static straight after parsing the file, or adding the "static len expression" heuristic to vk-parse instead.

That'd look about like this: master...Traverse-Research:simplify

  • vkxml really needs to add Eq, Clone (and Copy) to their types, but the repo hasn't been touched since 2017...
  • The heuristic is wrong, and should be moved to vk-parse as this nested for is beyond unacceptable;
  • Finally, data_void is now a proper *const [u8; 2 * UUID_SIZE] instead of *const u8 in the struct 😬

Copy link
Member

@MaikKlein MaikKlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think we need a raytracing example in the ash repro now that it is official. Not needed for this PR, I'll open an issue for it.

Comment on lines +109 to +113
let max_primitive_counts = max_primitive_counts
.iter()
.map(|cnt| *cnt as *const _)
.collect::<Vec<_>>();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is slightly unfortunate. I think this could actually be safe to transmute, but safe code for now is totally fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that'd be better, one now has to be aware that cnt is &&u32 to make the pointer cast work.

@MaikKlein MaikKlein merged commit 05747b2 into ash-rs:master Dec 13, 2020
@MarijnS95 MarijnS95 deleted the v11 branch December 13, 2020 18:52
MarijnS95 added a commit to Traverse-Research/ash that referenced this pull request Feb 27, 2021
This handle is already held onto when creating the safe wrapper object,
but is inconsistently required again in some but not all functions.
Remove it from every function and use the internal handle instead.

Closes: ash-rs#377
Fixes: 05747b2 ("Update Vulkan-Headers to 1.2.162 with stable ray-tracing spec (ash-rs#341)")
MaikKlein pushed a commit that referenced this pull request Feb 28, 2021
#378)

This handle is already held onto when creating the safe wrapper object,
but is inconsistently required again in some but not all functions.
Remove it from every function and use the internal handle instead.

Closes: #377
Fixes: 05747b2 ("Update Vulkan-Headers to 1.2.162 with stable ray-tracing spec (#341)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for the new VK_KHR_ray_tracing extension
3 participants