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

Parse and provide bitwidth attribute on <enums> element #17

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

MarijnS95
Copy link
Contributor

This attribute specifies - together with a typedef to VkFlags(64) - the size of an enum. VK_KHR_synchronization2 introduces larger
bitflags/bitmasks with more than 32 bits in use. These bitmasks have bitwidth set to 64, while the default for enums is assumed to be 32 bit.


Future tasks

  • Perhaps this option should be an enum for 32- and 64-bit variants, defaulting to 32-bit? That's less expressive though, in case future alterations are added (though very unlikely).
  • Add support for remaining new attributes, so that one of the newer vk.xmls (.172) can be tested in the CI.

If I may ask: Why isn't this crate deserializing to structures directly with Serde, followed by optional conversion and error checking? The manual approach with match_attributes! is pretty verbose. Or was that not possible/not expressive enough back in the day?

MarijnS95 added a commit to Traverse-Research/ash that referenced this pull request Mar 20, 2021
This change prepares for future additions in vk_parse fields ([1]) by
converting over the enum generation path from vkxml.  Most of the
conversion is easy by repurposing the existing `EnumSpec` parsing logic
from extension constants for all enumeration variants, with slight
modifications to not bail when `extends` is not set which is specific to
extension constants.

As an (unintended) added bonus this unification of the `EnumSpec`
codepath allows aliases (for backwards-compatible names) to be generated
as discussed earlier in [2].

[1]: krolli/vk-parse#17
[2]: ash-rs#384 (comment)
MarijnS95 added a commit to Traverse-Research/ash that referenced this pull request Mar 20, 2021
Since Vulkan-Headers v1.2.170 with VK_KHR_synchronization2 there are now
bitmasks/enums using 64-bits instead of the default 32. vk-parse has
been updated [1] to convey this info though the typedefs for these
enumerations could be parsed as well.

[1]: krolli/vk-parse#17
MarijnS95 added a commit to ash-rs/ash that referenced this pull request Apr 16, 2021
This change prepares for future additions in vk_parse fields ([1]) by
converting over the enum generation path from vkxml.  Most of the
conversion is easy by repurposing the existing `EnumSpec` parsing logic
from extension constants for all enumeration variants, with slight
modifications to not bail when `extends` is not set which is specific to
extension constants.

As an (unintended) added bonus this unification of the `EnumSpec`
codepath allows aliases (for backwards-compatible names) to be generated
as discussed earlier in [2].

[1]: krolli/vk-parse#17
[2]: #384 (comment)
MarijnS95 added a commit to ash-rs/ash that referenced this pull request Apr 16, 2021
Since Vulkan-Headers v1.2.170 with VK_KHR_synchronization2 there are now
bitmasks/enums using 64-bits instead of the default 32. vk-parse has
been updated [1] to convey this info though the typedefs for these
enumerations could be parsed as well.

[1]: krolli/vk-parse#17
MarijnS95 added a commit to Traverse-Research/ash that referenced this pull request Apr 17, 2021
This change prepares for future additions in vk_parse fields ([1]) by
converting over the enum generation path from vkxml.  Most of the
conversion is easy by repurposing the existing `EnumSpec` parsing logic
from extension constants for all enumeration variants, with slight
modifications to not bail when `extends` is not set which is specific to
extension constants.

As an (unintended) added bonus this unification of the `EnumSpec`
codepath allows aliases (for backwards-compatible names) to be generated
as discussed earlier in [2].

[1]: krolli/vk-parse#17
[2]: ash-rs#384 (comment)
MaikKlein pushed a commit to ash-rs/ash that referenced this pull request Apr 18, 2021
* generator: Generate enums from vk_parse representation

This change prepares for future additions in vk_parse fields ([1]) by
converting over the enum generation path from vkxml.  Most of the
conversion is easy by repurposing the existing `EnumSpec` parsing logic
from extension constants for all enumeration variants, with slight
modifications to not bail when `extends` is not set which is specific to
extension constants.

As an (unintended) added bonus this unification of the `EnumSpec`
codepath allows aliases (for backwards-compatible names) to be generated
as discussed earlier in [2].

[1]: krolli/vk-parse#17
[2]: #384 (comment)

* generator: Turn "backwards"-mentioning docs into deprecation notices

All constant aliases for misspelled items (missing `_BIT` andsoforth)
contain the text "backwards compatibility" or "Backwards-compatible
alias".

* generator: Drop aliases whose name becomes identical after de-mangling

* generator: Remove aliases from const_debugs

These already have a match against the name they're aliasing, and some
of the aliases are "deprecated" (since they're just typo fixups for
backwards compatibility).
MarijnS95 added a commit to Traverse-Research/ash that referenced this pull request Apr 18, 2021
Since Vulkan-Headers v1.2.170 with VK_KHR_synchronization2 there are now
bitmasks/enums using 64-bits instead of the default 32. vk-parse has
been updated [1] to convey this info though the typedefs for these
enumerations could be parsed as well.

[1]: krolli/vk-parse#17
MarijnS95 added a commit to Traverse-Research/ash that referenced this pull request Apr 18, 2021
Since Vulkan-Headers v1.2.170 with VK_KHR_synchronization2 there are now
bitmasks/enums using 64-bits instead of the default 32. vk-parse has
been updated [1] to convey this info though the typedefs for these
enumerations could be parsed as well.

[1]: krolli/vk-parse#17
@krolli
Copy link
Owner

krolli commented Apr 21, 2021

Why isn't this crate deserializing to structures directly with Serde, followed by optional conversion and error checking? The manual approach with match_attributes! is pretty verbose. Or was that not possible/not expressive enough back in the day?

vk.xml file is weird combination of structured XML and tagged C code. Structured parts could definitely go through serde, but I'm not sure about tagged C code. Currently content of these elements is collected and later parsed (in a very hacky way), but originally this was done together. I think there was some discussion within Khronos about having vk.xml format structured with defined schema, but they chose against it as it made things too rigid and hard to work with. Even if it might be possible to change the parsing code to serde right now, there is no guarantee that they don't introduce something hard to deal with in the future. I prefer to stick with SAX parser since it provides more flexibility and drags in fewer dependencies.

Back to the PR, addition of bitwidth support looks good and I would merge it right away, but commit with cargo.lock seems unrelated and unnecessary. Is there any need for it? I would rather just grab the bitwidth commit.

@MarijnS95
Copy link
Contributor Author

Right, I was explained earlier that serde is not (or does not appear to be) expressive enough to deal with this heavy intermixing of XML elements and text nodes, which pretty much define the whole Vulkan format (it is effectively a header with some heavy XML annotation interspersed).

Back to the PR, addition of bitwidth support looks good and I would merge it right away, but commit with cargo.lock seems unrelated and unnecessary. Is there any need for it? I would rather just grab the bitwidth commit.

As mentioned in #18 outdated crates actually cause issues, so I'd suggest either dropping Cargo.lock or updating it. If this repo works by squash-merging I can move that over to a separate PR.

@krolli
Copy link
Owner

krolli commented Apr 21, 2021

I would like to discuss the Cargo.lock thing a bit more but I don't want to block the fix because of it. If you can move it over to separate PR, I will gladly merge this one.

This attribute specifies - together with a typedef to VkFlags(64) - the
size of an enum. VK_KHR_synchronization2 introduces larger
bitflags/bitmasks with more than 32 bits in use. These bitmasks have
bitwidth set to 64, while the default for enums is assumed to be 32 bit.
@krolli krolli merged commit b536924 into krolli:master Apr 22, 2021
@MarijnS95 MarijnS95 deleted the enums-bitwidth branch April 22, 2021 07:58
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.

2 participants