Vulkan-Loader
Vulkan-Loader copied to clipboard
Is it legal to get "vkGetDeviceProcAddr" from "vkGetDeviceProcAddr"?
In common cases, we get function entry point vkGetDeviceProcAddr by calling myLayer.vkGetInstanceProcAddr( "vkGetDeviceProcAddr").
However, I met some cases that user calls myLayer.vkGetDeviceProcAddr("vkGetDeviceProcAddr") . Regardless of whether it makes sense to do so, I am more concerned about whether this behavior is defined in the spec of Vulkan loader. I have seen layers that returns vkGetDeviceProcAddr of itself, and I have also seen layers returns nothing.
Yes, it is legal. vkGetDeviceProcAddr can query device functions, of which it is one. https://docs.vulkan.org/spec/latest/chapters/initialization.html#initialization-functionpointers has a table defining the vkGetDeviceProcAddr behavior - and because vkGetDeviceProcAddr is a device function, it is defined to be supported by that table.
Whether it does the right thing currently is a different matter. One issue is a layer calling vkGetDeviceProcAddr = myLayer.vkGetDeviceProcAddr("vkGetDeviceProcAddr") and replacing the one provided by the loader with it - which is wrong and a bug I've seen before.
From the loader layer documentation there doesn't appear to be any specifics about this situation, which typically means the vulkan spec is the 'rule to follow'. Adding some details about querying vkGetDeviceProcAddr in a layer could be added, since it is a possible thing to do but must be done with care.
Thanks for replying, I hope experts could add this situation into the loader/layer documentation, it's somehow important to layer programmers.
One issue is a layer calling vkGetDeviceProcAddr = myLayer.vkGetDeviceProcAddr("vkGetDeviceProcAddr") and replacing the one provided by the loader with it - which is wrong and a bug I've seen before.
Well, I think as long as the "next layer" returns the same local "vkGetDeviceProcAddr", there should not be bug. This is required by the loader-layer spec as well.