Add explicit return type to funcpointer definitions in Vulkan XML#2577
Add explicit return type to funcpointer definitions in Vulkan XML#2577mematthias wants to merge 1 commit intoKhronosGroup:mainfrom
Conversation
|
@oddhack Since this draft was assigned but no comments have been made yet, is there anything I should adjust or add? |
|
I do not want to use the requires tag for this as it's a semantically different use (and collides with one existing use). One option is to just add a <type> tag to the base return type which is what the <command> tag already does. We'd have to check if that affects any downstream consumers of the XML but that seems preferable to me and avoids redundancy, which is always a concern for us. Adding a new attribute as you suggest is also workable. Sorry for delay responding. |
|
That sounds good to me - using a That said, introducing a dedicated As an additional suggestion, we could represent function pointers in a structure similar to how commands are currently defined. <type category="funcpointer">
<proto><type>VkBool32</type> <name>PFN_vkDebugUtilsMessengerCallbackEXT</name></proto>
<param><type>VkDebugUtilsMessageSeverityFlagBitsEXT</type> <name>messageSeverity</name></param>
<param><type>VkDebugUtilsMessageTypeFlagsEXT</type> <name>messageTypes</name></param>
<param depends="true">const <type>VkDebugUtilsMessengerCallbackDataEXT</type>* <name>pCallbackData</name></param>
<param><type>void</type>* <name>pUserData</name></param>
</type>One small question regarding the current use of the
Either of these would describe the purpose more clearly than reusing Additionally, separating this purpose from the existing |
|
After experimenting, I found the <proto>const <type>void</type>* (*<name>PFN_...</name>)</proto> |
|
This has largely been addressed in a separate internal MR, so I am going to close it. Regarding the parenthesization of the prototype, that's handled inside the generator code in the same way as the function pointer declarations emitted for any other vk* command. Unlike vk* commands, funcpointer declarations only emit the pointer and not the corresponding prototype, since that does not exist. |
Proposal: Explicit return types for funcpointers
Currently, it is not possible to fully analyze function pointer signatures in the Vulkan XML in a purely static way.
While the function arguments and the function name are accessible, the return type is not.
This makes it difficult to parse function pointers reliably in generators and analysis tools.
Additionally, the missing return type makes it very hard to construct a proper topological order of type dependencies, since the dependency chain cannot be resolved statically.
Suggested change
The
requiresattribute of the<type>element could be used to store the return type explicitly.At the moment, the
requiresattribute is only used for redundant information that can already be derived from the function arguments.Using it consistently for return types instead would remove this redundancy and make the return type available in a static, machine-readable way.
For example:
With this change, the return type, arguments, and function name can all be determined statically and unambiguously.
It would also make it possible to construct a correct topological ordering of all types.
Alternative option
If using
requiresfor return types is considered semantically unclear, a dedicatedreturnsattribute could be introduced to make the intent explicit (at the cost of a schema extension).Summary
requiresto specify the return type explicitlyreturnsattribute for stronger semantic clarity