-
Notifications
You must be signed in to change notification settings - Fork 187
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
Impl trait functions directly on EntryCustom/Instance/Device #412
Conversation
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.
Sorry for the late reply.
Moving the core traits into methods seems good, I am not so sure about moving the extensions into core as well. Basically this tries to load every extensions when creating a instance/device. It is also a pretty big breaking change as now all the extension structs are gone + the extension functions have a vendor extension in their name.
I am going to request a few reviews to get more opinions.
I'm in favor of dropping the traits; I've never derived any benefit from them, it's just another thing to import, and empirically a recurring source of confusion for new users. I'm ambivalent about folding the extensions in as well. It's a bit more convenient, but also a bit more error-prone. For extensions that I don't require (e.g. debug stuff) I quite like having an |
Dropping the traits is fine by me - we're only using Moving the extensions in there should definitely be done in a separate PR, if only for cleaner history and easier review/revertability - and it's a significant breaking change that should be considered carefully while allowing "normal" PRs (introducing new features) to be released first. |
That is not fully true IIRC. Some functions from extensions might require other extensions to be enabled. So it is possible for some extension function pointers to not load. |
Right that's true, we can't have a single |
Can you give a specific example of an extension that is valid without another extension loaded, but which defines additional functions only if it's present? |
Did I misinterpret MaikKlein's reply in #408 (comment)? I thought that was giving me the go-ahead for this PR as a whole. Anyway, I reduced this PR to only the removal of the traits. Should I implement the suggestion I originally made, to create a |
cc9b224
to
9758695
Compare
9758695
to
22be6ee
Compare
…n-instance-device
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.
Did I misinterpret MaikKlein's reply in #408 (comment)? I thought that was giving me the go-ahead for this PR as a whole.
Sorry I should have been clearer.
Thank you for this PR, a much needed simplification <3. @MarijnS95 can you have a quick peek?
@MaikKlein I'll queue this up for tomorrow-morning, together with some other PRs. Will also check how it fares on our existing usecases. |
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.
Apologies, it took some time (a full work-week, to be precise) to get to this.
Overall this is a net-win for our codebase. All we had to do was remove the trait imports and bounds, it's actually great we're now acknowledging that all (core) function pointers were stored in ash::Device
anyway, and there wasn't any extra compile/runtime checking to ensure that the (mandatory) functions could be loaded in the first place.
All in all the only thing that disappears with this PR is static visibility in what core functions are actually used by a code-base. That might be a big deal. @MaikKlein Do you perhaps remember why traits were used in the first place?
@Rua You should probably remove Fixes #408
as this only removes trait bounds but does not take care of the main issue described there: unconditionally dumping all extension function pointers in ash::Device
.
…n-instance-device
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.
@Rua I do think that you need to maintain the 1.2 - 1.1 - 1.0 ordering in device.rs
like you did in instance.rs
. That way the diffstat is more bearable, and the resulting diff is much easier to read and git blame
is still useful.
Also, conflict resolution with master
seems to have gone wrong, we replaced all redundant type names with Self
and fortunately enabled the clippy::use_self
warning for the entire extensions
module.
Ok, done. |
@Rua |
Thanks! Given that all maintainers agreed this is the way forward, and the changes look clean/small enough (now after reordering the functions again), I've just merged this to unblock some other PRs 🥳 |
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
Looking at this again, it seems However, there's quite a bit of duplicated code as well and can easily get away with both problems by returning a pointer to the static |
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412
* lib: Provide entrypoint through Ash loader w.o. implementing Entry Ash recently [dropped all traits](1) to simplify `ash::Device` usage, but this also disallows ash-molten from overriding the `EntryV1_0` trait to provide a static entrypoint intead. Fortunately ash-molten can simply pass a library loading closure that returns the static address of `vkGetInstanceProcAddr` to `EntryCustom::new_custom`, getting rid of the copied `fn create_instance` implementation at the same time. [1]: ash-rs/ash#412 * cargo: Disable unneeded `libloading` feature in Ash The entry-point is statically linked from `MoltenVK` and does not need any dlopen nor dlsym functionality. * Fix some typos
This seems to have been forgotten in #412.
This seems to have been forgotten in #412.
This seems to have been forgotten in #412.
Depends on #400.
A possible improvement to the code structure could be to create a
core
module to sit alongsideextensions
, containingcore/v1_0.rs
,core/v1_1.rs
andcore/v1_2.rs
. This would better match the way extension code is currently structured. I think it could also be good to re-export Vulkan types from each of these.