Refactor external semaphore scaffolding (#2300)

Remove the `CREATE_OPENCL_SEMAPHORE` macro and use derived class
instantiations of the `clExternalSemaphore` class, rather than base
pointers to derived class objects.

Remove the default argument for `queryParamName` in
`check_external_semaphore_handle_type()`.

Move `check_external_semaphore_handle_type()` checks to constructors of
`clExternalImportableSemaphore` and `clExternalExportableSemaphore`,
rather than manually making the check before creating an external
semaphore.

---------

Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
Co-authored-by: Kévin Petit <kpet@free.fr>
Co-authored-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
gorazd-sumkovski-arm
2025-04-16 04:41:38 +01:00
committed by GitHub
parent 4ce3d8968a
commit 33846e6673
6 changed files with 148 additions and 189 deletions

View File

@@ -28,23 +28,6 @@
#include <optional>
#define CREATE_OPENCL_SEMAPHORE(clSemaphore, vkSemaphore, ctx, handleType, \
devIdx, createExportable) \
if (!(createExportable \
&& (check_external_semaphore_handle_type( \
devIdx, getCLSemaphoreTypeFromVulkanType(handleType), \
CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) \
== CL_SUCCESS))) \
{ \
clSemaphore = new clExternalImportableSemaphore(vkSemaphore, ctx, \
handleType, devIdx); \
} \
else \
{ \
clSemaphore = new clExternalExportableSemaphore(vkSemaphore, ctx, \
handleType, devIdx); \
}
typedef cl_semaphore_khr (*pfnclCreateSemaphoreWithPropertiesKHR)(
cl_context context, cl_semaphore_properties_khr *sema_props,
cl_int *errcode_ret);
@@ -93,11 +76,10 @@ cl_int getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *, size_t,
cl_int check_external_memory_handle_type(
cl_device_id deviceID,
cl_external_memory_handle_type_khr requiredHandleType);
cl_int check_external_semaphore_handle_type(
cl_device_id deviceID,
void check_external_semaphore_handle_type(
cl_device_id device,
cl_external_semaphore_handle_type_khr requiredHandleType,
cl_device_info queryParamName =
CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR);
cl_device_info queryParamName);
cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &width,
size_t &height);