-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix struct generation with constant size arrays #193
Conversation
All instances of HashMap and HashSet have been replaced with BTreeMap and BTreeSet. Repeated generation of vk.rs results in the same output given the same vk.xml and generator. Note that this commit still contains the struct generation bug introduced in PR ash-rs#191. All structs with fixed sized arrays are currently generated as slices.
This is a great thought, but I think it's dramatic overkill; most |
Also, do the last two commits need to be separate? |
Here's one: https://github.com/MaikKlein/ash/pull/193/files#diff-02cf551bd84acec65d3adf3311783cdfR2148 https://github.com/MaikKlein/ash/pull/193/files#diff-02cf551bd84acec65d3adf3311783cdfR2246 I don't really see the For what it's worth, I didn't notice any particular performance difference after the change, but I wasn't timing it either. |
c7bd41a
to
ede9ed6
Compare
They're now squashed. |
You're right that it's not performance-relevant; I'm just not a huge fan of using a less-conventional tool where a conventional one will do fine, as it misleadingly invites the reader to wonder what the unusual requirement is for cases where there is none. |
I am super confused how this is even correct in 0.28. I think #191 didn't actually run the generator and then I just rebased in the changes. I'll give you a proper review during the day. |
@MaikKlein Yeah, that was the conclusion I came to as well. Running the generator is a little scary when you see all of This PR is actually a pre-cursor to the changes that I wanted to add. I ran into issues with being unable to build after re-generating, thus this PR was born to correct that first. Once this is (hopefully) merged, I'll put in a PR for adding doc links to the Khronos man pages for every struct and function. This makes both rustdocs and IDE auto-completion much nicer (IMO). Preview: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using BTreeXXX
for ordering is fine I think. Using a bool to differentiate between ffi and fields is also okay.
My (weak) objection was against using it for cases where ordering is not observed. In the cases where ordering is observed, it is a great solution. |
A valid argument. Kind of hard to see where a |
@Ralith @MaikKlein Updated the generator to use |
bors r+ |
193: Fix struct generation with constant size arrays r=MaikKlein a=aloucks PR #191 introduced a bug into the generator where constant sized array struct fields were generated as slices. This PR adds a flag to `type_tokens` that will revert that behavior while still generating FFI function signatures with pointers instead of fixed sized arrays (e.g. for `set_blend_constants`). In addition, all instances of `HashMap` and `HashSet` have been replaced with `BTreeMap` and `BTreeSet`, which makes the generation of `vk.rs` idempotent for the same `vk.xml` input. This should obviate the need for #130 and make it much easier to see how changes to the generator or `vk.xml` affect the generated output. Co-authored-by: Aaron Loucks <[email protected]>
@aloucks Thanks for the PR, contributions are always appreciated :). |
PR #191 introduced a bug into the generator where constant sized array struct fields were generated as slices. This PR adds a flag to
type_tokens
that will revert that behavior while still generating FFI function signatures with pointers instead of fixed sized arrays (e.g. forset_blend_constants
).In addition, all instances of
HashMap
andHashSet
have been replaced withBTreeMap
andBTreeSet
, which makes the generation ofvk.rs
idempotent for the samevk.xml
input. This should obviate the need for #130 and make it much easier to see how changes to the generator orvk.xml
affect the generated output.