-
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
Vulkan 1.2.175: Provisional Video Extensions #417
Conversation
There is at least one examples of bitfields in vk.xml VkTransformMatrixKHR. Also bindgen will most likely handle bitfields rust differently than we do. Currently we handwrite those structs. Also what about the naming scheme? What if the next release includes those types in the xml? Will the generated types have the same naming scheme as from bindgen? Do we get a name clash and need to remove vulkan video from bindgen? I am not even sure we should update to the latest spec, I feel like they should fix the xml. I'll open an issue for it. |
Ah great, so they have the possibility to declare these in XML after all.
It's a C header and
If the next release moves everything back to XML we can remove the bindgen part, yes. We might also want to parse the XML and include headers based on what is defined instead of hardcoding those in <type category="include" name="vk_video/vulkan_video_codec_h264std.h">#include "vk_video/vulkan_video_codec_h264std.h"</type>
<type requires="vk_video/vulkan_video_codec_h264std.h" name="StdVideoH264ProfileIdc"/>
<type category="include" name="vk_video/vulkan_video_codec_h264std_decode.h">#include "vk_video/vulkan_video_codec_h264std_decode.h"</type>
<type requires="vk_video/vulkan_video_codec_h264std_decode.h" name="StdVideoDecodeH264PictureInfo"/>
<type requires="vk_video/vulkan_video_codec_h264std_decode.h" name="StdVideoDecodeH264ReferenceInfo"/>
<type requires="vk_video/vulkan_video_codec_h264std_decode.h" name="StdVideoDecodeH264Mvc"/>
I don't want to block future spec updates, and I do feel that Ash - as the most popular Rust Vulkan binding crate - should stay relatively up to date to allow users to experiment with the latest spec without hassle. We can also disable this extension entirely but it seems quite trivial to support it now and we haven't really built and public API like a |
I am not talking about ABI, I am talking about semantic versioning.
Stuff like that. It is possible to simply not require semantic versioning for these things. There is already an issue for it KhronosGroup/Vulkan-Docs#1505 |
Sounds about what we did with |
Sounds reasonable, but lets wait for a reply first. I wish Rust and had an experimental/unstable attribute for this. |
There are no
Yes, all enum variants and struct fields appear to be snake case;
They are prefixed with |
We'll probably split off and merge all the way up to .174 and leave this open for visibility. We can make a move whenever the XML is fixed, the next header release contains something interesting, or someone really needs it (and potentially puts in extra effort to make it workable). |
@MaikKlein Well, we have an answer. Unsurprisingly these header types (data layout) are part of the H.264/5 spec and not specific to Vulkan, and it's very unlikely for them to be mapped out to XML (even though that should theoretically be possible). I feel like cleaning this up (hiding |
Ok there has been another update
This sounds good. If the pregenerated bindgen types are not too much work we can still get them in now. |
Yep, the structs should all be passed by value and could be turned into So we'll need the headers for now, disable vk_video altogether, or hope that at least the |
d3c456c
to
3959f38
Compare
Lets not go out of our ways to make provisional extensions work. (Unless it is an easy change) Lets wait until most of these definitions will be in the xml. I guess we can ignore it for now? |
Yes, let's do that. Let's get the open PRs (+ dependencies) for .171 in, then I'll submit a separate PR updating up till .174 and one that disables generation for the video extensions, so that we can continue pulling in new extensions without being bothered by this. I'll rebase this and keep it somewhat buildable so that folks wishing to play with the Video extensions can do so from Rust. |
c47c0a6
to
8f541b8
Compare
8f96a6a
to
39864d5
Compare
fc696e9
to
0a7f12c
Compare
We're generating C bindings using I've seen this happen on other projects too, and the solution is generally to discard changes to these files if the CI disagrees. It's going to be annoying though given the frequency at which I import and regenerate newer Vulkan headers, having to not forget to revert specific changes to |
c90d260
to
f3a501d
Compare
Some structs turn out to be root structs when their name is not in the `root_structs` set, even when they themselves extend another struct. This was already taken care of for `push_next` which is emitted in this situation, but the trait referenced by `push_next`'s `T` bound is still relying on the `extends` field to not exist in `vk.xml` at all, leading to it not being generated despite `push_next` needing it. Fixes: 215511f ("Implement ExtendXXX for multiple root create infos if there are more than 1")
This is a bit worrying, do you have an example where the padding is different? We would need a tracking issue for it and maybe reach out to the bindgen folks. I can't think of a reason why the padding would be different. |
The problem is with: typedef struct StdVideoH265HrdFlags {
uint32_t nal_hrd_parameters_present_flag : 1;
uint32_t vcl_hrd_parameters_present_flag : 1;
uint32_t sub_pic_hrd_params_present_flag : 1;
uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag : 1;
uint8_t fixed_pic_rate_general_flag; // each bit represents a sublayer, bit 0 - vps_max_sub_layers_minus1
uint8_t fixed_pic_rate_within_cvs_flag; // each bit represents a sublayer, bit 0 - vps_max_sub_layers_minus1
uint8_t low_delay_hrd_flag; // each bit represents a sublayer, bit 0 - vps_max_sub_layers_minus1
} StdVideoH265HrdFlags; On Linux (currently checked in to this PR) the first four bitfields are modeled as a single @@ -2795,6 +2787,7 @@ fn bindgen_test_layout_StdVideoH265SubLayerHrdParameters() {
pub struct StdVideoH265HrdFlags {
pub _bitfield_align_1: [u8; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+ pub __bindgen_padding_0: [u8; 3usize],
pub fixed_pic_rate_general_flag: u8,
pub fixed_pic_rate_within_cvs_flag: u8,
pub low_delay_hrd_flag: u8, (Plus the necessary I don't exactly know the rules bitfields and their overal size in the struct. It feels Windows is more correct, but for all I know there might as well be different rules when targeting Linux or Windows. |
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.
Awesome work, I want to get this in before the next release.
But there is one thing I am a bit uncomfortable with and that is semver with provisional extensions.
I know that there ash hasn't done anything for it in the past, but that was mainly due to me not knowing that they even added provisional extensions to the vk.xml.
We have an experimental
folder, which is "exempt" from semver, but vkvideo here is all over the place. Any thoughts what we can do about it?
We technically could add a cfg/feature flag for all types/functions from provisional extensions. Any idea how much work that would be? #343
Technically the Video extensions aren't all over, except in the autogenerated bindings which are public. The |
But there are quite a few types, bitflags, commands which were generated from the provisional beta extension. Like |
@MaikKlein Having looked into this some, properly guarding provisional API with features requires substantial changes to the generator. Extensions only declare what types/enums/commands they need, but the definitions sit elsewhere without Unfortunately too, extending existing enums with constants happens within the extension and This might mean moving every extension-specific type out from |
Yeah that is what I thought :( I think we can still get it in and make a release, we just have be careful about breaking changes and properly update our versioning in ash. We really need to prioritize the new generator. I'll have another look later today, but don't think I have any other concerns. |
Breaking changes are allowed on most-significant version changes. In our case the minor version field is most-significant because we're still on Would be cool to have a look at the new generator and refactor some of the changes made to the old one into there. What's the status now? Any substantial changes to be made first, or local changes in-progress? |
@MaikKlein Gave this another look in GodBolt: https://godbolt.org/z/bev9eEzdv. The structs really have different layout on Clang/GCC versus MSVC, and that's apparently allowed. This should probably be "fixed" (just use the smallest integer type) in Vulkan headers, or Ash needs per-target and per-platform bindgen output. Not to mention all the trouble we'll be causing with cross compilations though at least |
I think we should definitely raise an issue with the Vulkan folks before implementing unusual hacks. By the C standard it is only allowed to use Additionally, the layout could be somehow explicitly defined as with e.g. Also note that there is a RFC adding support for bit fields, but I don't expect it to land in the near future: rust-lang/rfcs#3113 |
It doesn't seem unusual to have per-target and/or per-platform bindgen files, especially if the target platform defines different layout rules for the same struct. However, I wonder if the Video TSG is aware of this discrepancy - will raise an issue - EDIT: KhronosGroup/Vulkan-Docs#1571.
Not sure that'd help. This struct is in a header file and compilers won't be able to read this documentation.
I wonder if, as a temporary solution, bindgen could also treat this per-platform discrepancy with some |
Certainly not the perfect solution. But if there are no alternatives (for now) it is the only one, fair.
Meant that à la "If a compiler produces code that diverges from that pattern, applications must employ another method to set values according to the correct bit pattern.". But yeah, don't know if something like that could also be applied to the Vulkan Video types. Let's wait and see what the Khronos issue tells us. |
That could work, unfortunately |
Yes! This would be by far the best solution, i'd be great if that went through :) |
Looks like we're getting padding bits instead: KhronosGroup/Vulkan-Docs#1571 (comment) |
Huh okay, probably the least amount of effort on their side, i'm fine with it ¯_(ツ)_/¯ |
Depends on #431 (which depends on #429)
Introducing Vulkan 1.2.175 with raw bindings for the new provisional Vulkan Video Extension. No "safe" bindings are included yet; those can be written if someone ends up needing these, or after the API is stabilized. For now it'll allow users to experiment around with the "raw" (raw pointer) API and unblock future updates.
The
Vulkan-Headers
declaration consist in part of C headers, presumably due to lack of bitfield support in structs invk.xml
. Fortunately bindings can be generated effortlessly withbindgen
.TODO:
Vulkan-Headers
repo. We'll check in pregenerated bindings just like how thegenerator
output is checked in today;pNext
. This extension introduces nested trait extensions. We have the usual:VkVideoProfileKHR
extends existing root structs noExtendsVkVideoProfileKHR
trait is generated for it. However,VkVideoDecodeH264ProfileEXT
includespNext
and will - due tostructextends="VkVideoProfileKHR"
- only implementExtendsVkVideoProfileKHR
which doesn't exist. For now all traits are emitted to solve this build error, but it does not allowVkVideoDecodeH264ProfileEXT
to be put inVkVideoProfileKHRBuilder::push_next
. Nor does it allow any of the "parent" structs forVkVideoProfileKHR
to be put inVkVideoDecodeH264ProfileEXT
either unless they implementExtendsVkVideoProfileKHR
.