Vulkan-Loader icon indicating copy to clipboard operation
Vulkan-Loader copied to clipboard

Is it legal to get "vkGetDeviceProcAddr" from "vkGetDeviceProcAddr"?

Open psionic12 opened this issue 5 months ago • 3 comments

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.

psionic12 avatar Jun 09 '25 12:06 psionic12

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.

charles-lunarg avatar Jun 09 '25 15:06 charles-lunarg

Thanks for replying, I hope experts could add this situation into the loader/layer documentation, it's somehow important to layer programmers.

psionic12 avatar Jun 10 '25 04:06 psionic12

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.

tntljc avatar Jun 10 '25 06:06 tntljc