-
Notifications
You must be signed in to change notification settings - Fork 477
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
Clarification on vkGetDeviceProcAddr behavior for non-device functions #655
Comments
The spec says:
The footnote directly under Table 2 describing vkGetDeviceProcAddr also says, referring to all function pointers returned by vkGetDeviceProcAddr:
Thus even if you get a function pointer back for a command that dispatches on VkInstance or VkPhysicalDevice, you couldn't validly call through that pointer. The intent was that vkGetDeviceProcAddr only supports functions of VkDevice or its children, and that function pointers you get from it don't require any dispatch overhead: they jump directly to the code for the "outermost" layer that intercepts the function, or directly into driver code if there are no such layers. This is in contrast with vkGetInstanceProcAddr function pointers, which in many cases must jump through a dispatch table. I agree the spec could be more explicit about this. I'll follow up. |
I was thinking the intention for it was to return |
Sorry, yeah, it should return NULL there. I was just using that as evidence that it was only supposed to support device-level commands. The point was that if it supported instance-level commands, the function pointers you'd get back for them would be unusable -- which was unlikely to be the intent :). |
@critsec Yeah, I get that. I was making similar point at the layers repo original Issue. The biggest ambiguity is if it should return |
@Novum By "unusable" we mean ✨"undefined behavior"✨. |
This should be fixed in the 1.0.69 spec update. |
Do I misunderstand something:
Taken from: |
@Zingam Seems correct. What about that document? You can get instance and device level commands with |
I would like to point out that @krOoze's comment was from April 27, 2018, while on March 5, 2018, two months before his comment, Mesa developers had to guess which commands are instance or device level:
https://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg186199.html |
On @critsec's comment:
Currently searching for an official list of children or a graph of parent-child relationships of Vulkan objects to confirm Mesa developers' guess... |
"VkDevice objects are parents of many object types (all that take a VkDevice as a parameter to their creation)." |
"The returned function pointer must only be called with a dispatchable object (the first parameter) that is instance or a child of instance, e.g. VkInstance, VkPhysicalDevice, VkDevice, VkQueue, or VkCommandBuffer." You can indirectly derive from this VkDevice, VkQueue and VkCommandBuffer (tho 'e.g.' may mean it's incomplete). |
"Device-Level Object "For example", again, may mean the list is incomplete, but good enough as a confirm for now. |
That's unfortunate, but it was clear beyond any doubt in 1.0.69 (19 Feb 2018):
And it was strongly suggestive before, and as you quote they arrived to the correct conclusion.
There's simple rule to this. The parent is always the object you retrieved (i.e. via Besides it is in the
Yea, it is brittle. Someone adding object later may forget to add it to that list at that unexpected place, so "e.g." to be safe. But at this point that is a complete list of dispatchable handle children. |
That's a good rule, thanks! :) I wouldn't mind if it ended up somewhere in the spec... |
@procedural Yea, the Object chapter could be improved. |
I would like some clarification on the spec for vkGetDeviceProcAddr. There are some ambiguities, which came up in a bug I originally filed for the loader (KhronosGroup/Vulkan-LoaderAndValidationLayers#2323).
During development of a Vulkan ICD for Wine, I encountered shipping games (Doom / Wolfenstein II), which utilize vkGetDeviceProcAddr to load ALL their function pointers including instance function pointers.
I was surprised the loader allowed this and after testing found it indeed works. In the loader related ticket we concluded that the spec of vkGetDeviceProcAddr isn't entirely clear. vkGetDeviceProcAddr is supposed to work for 'core Vulkan commands', it isn't clear whether that just mean device commands or all instance + device commands. Then there is the side note, which states that the returned function pointers should only be used by device or children of device. This area needs more clarification. What is the intended behaviour?
On the other hand as I demonstrated there are major shipping games relying on potentially unintended behaviour.
The text was updated successfully, but these errors were encountered: