-
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
Implement extensions directly on Instance/Device instead? #408
Comments
Yes this is something I have been considering for a while and will most likely change with #344 |
Would it be ok if I made this change manually in a PR for now? Assuming the generator rewrite will take a while. |
That would be nice
This would be my preference, keep it as it is now and just move the trait impls to a normal impl block. |
@MaikKlein @MarijnS95 @Ralith now that the PR has been split and the first one merged, what do you think about the details about this proposal? Some question points are:
Point 2 only matters if you ever decide to copy it, but is that done anywhere? And does it need to be? Point 4 doesn't necessarily mean that extensions should all be added to |
We simply have a You can even If you really want to solve this inside
Unfortunately our codebase does that a lot, because lifetimes (and I guess no-one realised it's currently over 1000 bytes large). We should probably put the device on the heap and |
One thing of relevance is that you are perhaps concerned with every extension struct individually holding on to a redundant device/instance handle? |
I remain a fan of how
I'm skeptical that these are a realistic threat. |
But I do believe that is something for the crate user to specify in their own code. I don't want to expect/unwrap
I'm not sure whether drivers prefer to perform extra loading/work during instance/device creation when the extensions are passed, or when a function is loaded. Neither seem to be slow on any driver that I've tried but given past/open issues Ash is used in quite a few embedded scenarios for which we should provide an as bare-bones setup as possible, IMO. |
Yes, strongly agree. |
Looks like this was addressed in #412, and there's no strong precedent for creating mega-structs containing all extension pfns, loaded from the get-go. |
Currently, Ash has separate structures for each extension, which means each one has to be loaded and kept around by the user. This is a bit awkward if there's many extensions involved, so what if the extension functions were implemented directly on
Instance
andDevice
instead? The user would only have to keep these two structures around for all their use cases.These two objects would initialise the function pointers of all extensions internally when they are created. This is allowed by the spec; the spec dictates that asking for the pointer to an extension function that has not been requested at create time should return a null pointer. Ash itself already does this for the Vulkan core functions, which are all loaded regardless of whether the user created their Instance for that version.
If this is done, I also suggest getting rid of the
DeviceV1_0
trait and others like it, and implementing functions (both core and extension) as inherent methods onInstance
andDevice
. These traits add extra flexibility but I'm not sure if that's actually needed for most people. And if each extension is going to be represented as a trait onInstance
orDevice
, those two types end up with a very long list of trait implementations. You could keep the functions for returning the raw function pointer structs as they are now, or expose each function struct member ofInstance
andDevice
to the user directly; the latter has my preference.The text was updated successfully, but these errors were encountered: