-
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
device,instance: Provide load_with()
constructor for get_proc_addr closure
#846
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.
Seems reasonable overall!
9613142
to
9e5c1bf
Compare
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.
LGTM. It's not obvious to me why we couldn't do this for Entry
as well.
I just updated the commit message with the reason, but didn't update the PR description: Alternatively we could use the closure - supposedly implemented as https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetInstanceProcAddr.html
|
Ah, that makes sense. Let's leave it as-is; it's not obvious that |
f2e23c9
to
d23282b
Compare
…closure While working on a GStreamer Vulkan interop example (where GStreamer-Vulkan opens the ICD and creates most objects for us, which need to be imported in an `ash::Instance` and `ash::Device`), it wasn't feasible to construct a `vk::EntryFnV1_0` and `vk::InstanceFnV1_0` with `extern` functions while keeping object data in some global static, especially `vk::InstanceFnV1_0` which contains many more functions that are not consumed by `Instance::load()`. GStreamer provides function loaders directly on its `GstVulkanInstance` and `GstVulkanDevice` which are desired to be used rather than attempting to open the same ICD and loading the same functions by hand. The original `Device::load()` and `Instance::load()` already create a closure internally, which is exactly what we need to expose to have a single callback that can hold the `&gst_vulkan::VulkanInstance/Device` state, and respond to a char-pointer name with a function pointer. Note that this doesn't map very clearly to `Entry`, where the `load()` constructor is named `from_static_fn()` and a closure signature is equally lacking. This is due `Entry` also storing `StaticFn` for various uses, which any constructor with just a closure won't (easily) be able to replicate.
d23282b
to
cc3c504
Compare
While working on a GStreamer Vulkan interop example (where GStreamer-Vulkan opens the ICD and creates most objects for us, which need to be imported in an
ash::Instance
andash::Device
), it wasn't feasible to construct avk::EntryFnV1_0
andvk::InstanceFnV1_0
withextern
functions while keeping object data in some global static, especiallyvk::InstanceFnV1_0
which contains many more functions that are not consumed byInstance::load()
. GStreamer provides function loaders directly on itsGstVulkanInstance
andGstVulkanDevice
which are desired to be used rather than attempting to open the same ICD and loading the same functions by hand.The original
Device::load()
andInstance::load()
already create a closure internally, which is exactly what we need to expose to have a single callback that can hold the&gst_vulkan::VulkanInstance/Device
state, and respond to a char-pointer name with a function pointer.Note that this doesn't map very clearly to
Entry
, where theload()
constructor is namedfrom_static_fn()
and a closure signature is equally lacking.