-
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
Some _device_ extensions are loading (and failing) _instance_ functions via get_device_proc_addr()
#727
Comments
For backporting this to |
I have mixed feelings about proliferating tons of loader structs, but I think it's specifically needed here as you might want to call these before you have a device at all. |
I guess we could accept |
Yup. I was initially thinking about cheating our way out of this by having a I think I'll start by generating into separate |
I just cobbled together the generator code in ed2e5e2 (again, assuming
We have high-level wrappers for seven of these (marked 🧹), three of which (marked 💥) are loading via I'll go ahead and finalize the manual code changes and make a PR for this, then we can decide how to progress - and how to backport this to Footnotes |
I'd be pretty happy to get that stuff out, personally! Judging by the lack of clamor I don't think any existing major users urgently need the fix here. |
Definitely! Hope we won't get the same push-back on "ash releasing yet another breaking change" (which is just a year and a week or two ago now), though this release comes with trivial yet cumbersome changes. However, I did keep the backports branch alive and up-to-date, even made some specific fixes. and to "solve" this issue I'd simply deprecate Will perhaps make a 37.3 release after all and start working towards |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
…ctions This is a minimal, semver-compatible backport of #734 to the `0.37-stable` branch, warning Ash users of the problem outlined below while the issue is properly being solved in the next breaking Ash release (by separating `Instance` and `Device` functions in the generator to avert this problem entirely while also always providing optimal `Device`-specific functions for extension wrappers that are currently already loading _everything_ via `Instance` to forgo the problem). As discovered and detailed in #727 a few extension wrappers were loading and calling `Instance` functions via `Device` and `get_device_proc_addr()` which is [defined] to only return non-`NULL` function pointers for `Device` functions. Those wrapper functions will always call into Ash's panicking NULL-stub functions as the desired `Instance` function could not be loaded. Deprecate the `new()` functions for extension wrappers that were doing this, while pointing the reader to `new_from_instance()` and explaining in the docs what function will always `panic!()` when the struct was loaded using `new()` instead. This function always takes a raw `vk::Device` directly to fill `handle` (rather than `ash::Device` to retrieve `handle()` from), allowing users to pass `vk::Device::null()` when they do intend to load this extension wrapper just for calling the `Instance` function. [defined]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceProcAddr.html#_description
…ctions This is a minimal, semver-compatible backport of #734 to the `0.37-stable` branch, warning Ash users of the problem outlined below while the issue is properly being solved in the next breaking Ash release (by separating `Instance` and `Device` functions in the generator to avert this problem entirely while also always providing optimal `Device`-specific functions for extension wrappers that are currently already loading _everything_ via `Instance` to forgo the problem). As discovered and detailed in #727 a few extension wrappers were loading and calling `Instance` functions via `Device` and `get_device_proc_addr()` which is [defined] to only return non-`NULL` function pointers for `Device` functions. Those wrapper functions will always call into Ash's panicking NULL-stub functions as the desired `Instance` function could not be loaded. Deprecate the `new()` functions for extension wrappers that were doing this, while pointing the reader to `new_from_instance()` and explaining in the docs what function will always `panic!()` when the struct was loaded using `new()` instead. This function always takes a raw `vk::Device` directly to fill `handle` (rather than `ash::Device` to retrieve `handle()` from), allowing users to pass `vk::Device::null()` when they do intend to load this extension wrapper just for calling the `Instance` function. [defined]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceProcAddr.html#_description
…ctions This is a minimal, semver-compatible backport of #734 to the `0.37-stable` branch, warning Ash users of the problem outlined below while the issue is properly being solved in the next breaking Ash release (by separating `Instance` and `Device` functions in the generator to avert this problem entirely while also always providing optimal `Device`-specific functions for extension wrappers that are currently already loading _everything_ via `Instance` to forgo the problem). As discovered and detailed in #727 a few extension wrappers were loading and calling `Instance` functions via `Device` and `get_device_proc_addr()` which is [defined] to only return non-`NULL` function pointers for `Device` functions. Those wrapper functions will always call into Ash's panicking NULL-stub functions as the desired `Instance` function could not be loaded. Deprecate the `new()` functions for extension wrappers that were doing this, while pointing the reader to `new_from_instance()` and explaining in the docs what function will always `panic!()` when the struct was loaded using `new()` instead. This function always takes a raw `vk::Device` directly to fill `handle` (rather than `ash::Device` to retrieve `handle()` from), allowing users to pass `vk::Device::null()` when they do intend to load this extension wrapper just for calling the `Instance` function. [defined]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceProcAddr.html#_description
…`Instance` functions (#754) extensions: Provide `new_from_instance()` fallback for `Instance` functions This is a minimal, semver-compatible backport of #734 to the `0.37-stable` branch, warning Ash users of the problem outlined below while the issue is properly being solved in the next breaking Ash release (by separating `Instance` and `Device` functions in the generator to avert this problem entirely while also always providing optimal `Device`-specific functions for extension wrappers that are currently already loading _everything_ via `Instance` to forgo the problem). As discovered and detailed in #727 a few extension wrappers were loading and calling `Instance` functions via `Device` and `get_device_proc_addr()` which is [defined] to only return non-`NULL` function pointers for `Device` functions. Those wrapper functions will always call into Ash's panicking NULL-stub functions as the desired `Instance` function could not be loaded. Deprecate the `new()` functions for extension wrappers that were doing this, while pointing the reader to `new_from_instance()` and explaining in the docs what function will always `panic!()` when the struct was loaded using `new()` instead. This function always takes a raw `vk::Device` directly to fill `handle` (rather than `ash::Device` to retrieve `handle()` from), allowing users to pass `vk::Device::null()` when they do intend to load this extension wrapper just for calling the `Instance` function. [defined]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceProcAddr.html#_description
A related feature request: I am wondering if it's also possible to introduce e.g. If we don't have enough bandwidth working on that, will the upstream push back a PR that implements these 2 interfaces? Thanks. |
@06393993 such a compatibility fix was already merged and published to |
Thanks for the reply. I know the fix which adds a
Therefore, the feature request is about raw function pointer structs like |
@06393993 Feel free to contribute a wrapper for missing extensions, request it, or wait until our new generator is capable of emitting sensible extension wrappers automatically. Likewise for layers, I'll be adding a helper library to For now you can achieve a similar thing as #754 by calling the However, that PR will only appear in the upcoming breaking release because this |
Found a couple extensions that are erroneously loading all functions through
get_device_proc_addr()
despite containing some instance-level functions (i.e. not taking a device or device child as first argument, see alsofn function_type()
in the generator for fishing this out in a crude way), which cannot be loaded. Concretely found these extensions (by looking for explicitPhysicalDevice
argument, and later validated using the generator):VK_KHR_device_group
: extensions/khr: Add VK_KHR_device_group #631VK_EXT_full_screen_exclusive
: Add VK_EXT_full_screen_exclusive extension #399VK_KHR_swapchain
(newget_physical_device_present_rectangles
): extensions/khr: Implement additionalSwapchain
functions since Vulkan 1.1 #629Quick solution
Unfortunately the fix (a pattern which we apply more rigorously in other extensions) implies a slower path for device-level functions which now imply an extra dispatch table per device, "injected" by the ICD. Worse, it's a breaking change so it might be about time to start thinking about
ash 0.38
.Long-term correctness
As for the fix itself, I've said it before and I'll use this issue to track it: I'd rather have the generator distinguish instance-level and device-level extension functions, either in the loader or via separate
*Fn
structs entirely (anything to force us to load both in a separate way). @oddhack what's the desired way to figure this out if a function operates on device (or childs thereof)? I'm not confident this hardcoded list of"VkDevice" | "VkCommandBuffer" | "VkQueue"
for the first-parameter-type will hold, does it need an extra attribute invk.xml
?ash/generator/src/lib.rs
Lines 561 to 566 in a9fbc71
Random weirdness
VK_KHR_device_group_creation
, added in #630, has a function namedfn device()
that returnsvk::Instance
😅The text was updated successfully, but these errors were encountered: