Conversation
|
Nice PR, it makes writing a binding generator easier. Maybe functions should be added as OpenCL version/extension |
|
@bashbaug, what do you think about require tags? I can add that in this PR, or a separate one, I'm not sure if that would be extra complexity here... |
Sorry for the very slow reply. I think adding the function pointer types is going to be the more contentious issue, since they aren't described in the spec currently. If we decide to add the function pointer types then I think it would make sense to add the appropriate "require" tags to associate them with the right OpenCL version, but again, that's a big "if". How confident are we that introducing the function pointer types isn't going to cause a compatibility issue? Could we make this change as part of the next OpenCL version? This way an application would only see an issue when moving to headers for the newer version. Or, does this just add complexity with no real benefit? |
Can't C header generator emit the same header after these changes? It can translate functions as typedefs and then use them in command declarations, but it can also write out function prototype for every argument, like it's done currently. The only difference is going to be in spaces, like pointed out in the PR description. |
|
Added function types to Usage of function types per API function: It seems this last commit broke generators, and I might as well try to do as @RocketRide9 described. |
This is admittedly somewhat philosophical, but IMHO the XML file should be a faithful representation of the specification, which should faithfully be described by the headers, so it'd be odd for the three to be out-of-sync. |
|
I took the liberty to create a proposal defining those types in the headers from the specification. |
|
We decided to take a look at adding a form of this to the specification. <comment>The PFN_vk*Function types are used by VkAllocationCallbacks below</comment>
<type category="funcpointer">typedef void (VKAPI_PTR *<name>PFN_vkInternalAllocationNotification</name>)(
<type>void</type>* pUserData,
<type>size_t</type> size,
<type>VkInternalAllocationType</type> allocationType,
<type>VkSystemAllocationScope</type> allocationScope);</type>
<type category="funcpointer">typedef void (VKAPI_PTR *<name>PFN_vkInternalFreeNotification</name>)(
<type>void</type>* pUserData,
<type>size_t</type> size,
<type>VkInternalAllocationType</type> allocationType,
<type>VkSystemAllocationScope</type> allocationScope);</type>
<type category="funcpointer">typedef void* (VKAPI_PTR *<name>PFN_vkReallocationFunction</name>)(
<type>void</type>* pUserData,
<type>void</type>* pOriginal,
<type>size_t</type> size,
<type>size_t</type> alignment,
<type>VkSystemAllocationScope</type> allocationScope);</type>
<type category="funcpointer">typedef void* (VKAPI_PTR *<name>PFN_vkAllocationFunction</name>)(
<type>void</type>* pUserData,
<type>size_t</type> size,
<type>size_t</type> alignment,
<type>VkSystemAllocationScope</type> allocationScope);</type>
<type category="funcpointer">typedef void (VKAPI_PTR *<name>PFN_vkFreeFunction</name>)(
<type>void</type>* pUserData,
<type>void</type>* pMemory);</type> |
I like the fact that you tried to factor the callbacks. Though I think some type safety might be useful when the intent of the callback is different. If we factor the callback, then I think the callback function should be clear in the name, I am very bad at naming things, but here are a few counter proposal to get the ball rolling:
My reasoning for not factoring the different program callbacks is that you would most probably not want to use these interchangeably, since they have different intent. |
|
Agree with almost everything (and assume you meant But for now, I'm not convinced that we need to separate function types with the same parameters. P.S. There is also |
|
In the cases when a callback is used by a core API and an extension API we have an additional wrinkle to consider: if an extension was added to "backport" a feature to a prior version of OpenCL, it would be undesirable for the extension to rely on a function pointer type that is only defined for a newer version of OpenCL. Therefore, we would want the core function pointer type to be defined for all versions of OpenCL, not just when the core API is added. Not the end of the world, but this feels a little weird. We should also prepare for the eventuality where an extension adds a callback and later gets prompted to a core feature. Given these issues, would it be easier to have a specific type for a core API callback vs. an extension API callback? We could also do something like this, which we've done a few times in the past, but it's always felt a little ugly: #if !defined(CL_VERSION_2_1)
/* defined in CL.h for OpenCL 2.1 and newer */
typedef cl_uint cl_kernel_sub_group_info;
#endif /* !defined(CL_VERSION_2_1) */ |
|
Turns out Line 1129 in d1eb455 Though now it creates a few broken files in .\gen\api\funcpointers, seemingly taking only const strings from <type> tags.
|
I definitely think that the callback type for |
|
Added callback for @bashbaug, as I understand, we are now waiting on a decision: Do we want to have generators output inline callbacks as before, or to change the API to a (mostly) compatible one with separately defined callbacks, as in the sister PR KhronosGroup/OpenCL-Headers#294 |
Currently, function pointers definitions are placed inside
<command>and require full-on parsing to properly interpret, because there are no tags to separate parameters and return type.Also, the cl_arm_printf extension requires its own function pointer type, but there is nowhere to define it in XML.
So, I've added
<type category="function">tags. I've also merged function pointer types with the same parameters under a common name. Including cases where original spacing differs:clEnqueueSVMFreeARM:clEnqueueSVMFree: