mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
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:
committed by
GitHub
parent
4ce3d8968a
commit
33846e6673
@@ -381,6 +381,10 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
for (VulkanExternalSemaphoreHandleType semaphoreHandleType :
|
||||
supportedExternalSemaphores)
|
||||
{
|
||||
check_external_semaphore_handle_type(
|
||||
device, getCLSemaphoreTypeFromVulkanType(semaphoreHandleType),
|
||||
CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR);
|
||||
|
||||
VulkanSemaphore vkVk2Clsemaphore(*vkDevice, semaphoreHandleType);
|
||||
VulkanSemaphore vkCl2Vksemaphore(*vkDevice, semaphoreHandleType);
|
||||
cl_semaphore_khr clCl2Vksemaphore;
|
||||
@@ -396,6 +400,7 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
|
||||
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
|
||||
};
|
||||
|
||||
switch (semaphoreHandleType)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -404,8 +409,6 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
" Opaque NT handles are only supported on Windows\n");
|
||||
handle1 = vkVk2Clsemaphore.getHandle(semaphoreHandleType);
|
||||
handle2 = vkCl2Vksemaphore.getHandle(semaphoreHandleType);
|
||||
errNum = check_external_semaphore_handle_type(
|
||||
device, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR);
|
||||
sema_props1.push_back(
|
||||
(cl_semaphore_properties_khr)
|
||||
CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR);
|
||||
@@ -420,8 +423,6 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
"Windows\n");
|
||||
handle1 = vkVk2Clsemaphore.getHandle(semaphoreHandleType);
|
||||
handle2 = vkCl2Vksemaphore.getHandle(semaphoreHandleType);
|
||||
errNum = check_external_semaphore_handle_type(
|
||||
device, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR);
|
||||
sema_props1.push_back(
|
||||
(cl_semaphore_properties_khr)
|
||||
CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR);
|
||||
@@ -435,8 +436,6 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD:
|
||||
fd1 = (int)vkVk2Clsemaphore.getHandle(semaphoreHandleType);
|
||||
fd2 = (int)vkCl2Vksemaphore.getHandle(semaphoreHandleType);
|
||||
errNum = check_external_semaphore_handle_type(
|
||||
device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR);
|
||||
sema_props1.push_back(
|
||||
(cl_semaphore_properties_khr)
|
||||
CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR);
|
||||
@@ -449,8 +448,6 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD:
|
||||
fd1 = -1;
|
||||
fd2 = -1;
|
||||
errNum = check_external_semaphore_handle_type(
|
||||
device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR);
|
||||
sema_props1.push_back((cl_semaphore_properties_khr)
|
||||
CL_SEMAPHORE_HANDLE_SYNC_FD_KHR);
|
||||
sema_props1.push_back((cl_semaphore_properties_khr)fd1);
|
||||
@@ -466,7 +463,7 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
|
||||
if (CL_SUCCESS != errNum)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Unsupported external sempahore handle type\n ");
|
||||
"Unsupported external semaphore handle type\n ");
|
||||
}
|
||||
sema_props1.push_back((cl_semaphore_properties_khr)
|
||||
CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR);
|
||||
|
||||
@@ -98,8 +98,8 @@ int run_test_with_two_queue(
|
||||
cl_mem error_1 = nullptr;
|
||||
cl_kernel update_buffer_kernel = nullptr;
|
||||
cl_kernel kernel_cq = nullptr;
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore = nullptr;
|
||||
const char *program_source_const = kernel_text_numbuffer_2;
|
||||
size_t program_source_length = strlen(program_source_const);
|
||||
cl_program program = clCreateProgramWithSource(
|
||||
@@ -147,12 +147,11 @@ int run_test_with_two_queue(
|
||||
}
|
||||
else
|
||||
{
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore, vkVk2CLSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore, vkCl2VkSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, true);
|
||||
clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
}
|
||||
|
||||
const uint32_t maxIter = innerIterations;
|
||||
@@ -442,8 +441,8 @@ int run_test_with_one_queue(
|
||||
uint8_t *error_2 = nullptr;
|
||||
cl_mem error_1 = nullptr;
|
||||
cl_kernel update_buffer_kernel;
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore = nullptr;
|
||||
int err = CL_SUCCESS;
|
||||
|
||||
const std::vector<VulkanExternalMemoryHandleType>
|
||||
@@ -482,12 +481,11 @@ int run_test_with_one_queue(
|
||||
}
|
||||
else
|
||||
{
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore, vkVk2CLSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore, vkCl2VkSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, true);
|
||||
clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
}
|
||||
|
||||
const uint32_t maxIter = innerIterations;
|
||||
@@ -747,8 +745,8 @@ int run_test_with_multi_import_same_ctx(
|
||||
cl_mem error_1 = nullptr;
|
||||
int numImports = numBuffers;
|
||||
cl_kernel update_buffer_kernel;
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore = nullptr;
|
||||
int err = CL_SUCCESS;
|
||||
int calc_max_iter;
|
||||
|
||||
@@ -787,12 +785,11 @@ int run_test_with_multi_import_same_ctx(
|
||||
}
|
||||
else
|
||||
{
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore, vkVk2CLSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore, vkCl2VkSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, true);
|
||||
clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
}
|
||||
|
||||
const uint32_t maxIter = innerIterations;
|
||||
@@ -1084,10 +1081,10 @@ int run_test_with_multi_import_diff_ctx(
|
||||
int numImports = numBuffers;
|
||||
cl_kernel update_buffer_kernel1[MAX_IMPORTS];
|
||||
cl_kernel update_buffer_kernel2[MAX_IMPORTS];
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore2 = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore2 = NULL;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore = nullptr;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore2 = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore2 = nullptr;
|
||||
int err = CL_SUCCESS;
|
||||
int calc_max_iter;
|
||||
bool withOffset;
|
||||
@@ -1128,19 +1125,19 @@ int run_test_with_multi_import_diff_ctx(
|
||||
}
|
||||
else
|
||||
{
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore, vkVk2CLSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore, vkCl2VkSemaphore,
|
||||
context, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore2, vkVk2CLSemaphore,
|
||||
context2, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore2, vkCl2VkSemaphore,
|
||||
context2, vkExternalSemaphoreHandleType,
|
||||
deviceId, false);
|
||||
clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
clVk2CLExternalSemaphore2 = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context2, vkExternalSemaphoreHandleType,
|
||||
deviceId);
|
||||
|
||||
clCl2VkExternalSemaphore2 = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context2, vkExternalSemaphoreHandleType,
|
||||
deviceId);
|
||||
}
|
||||
|
||||
const uint32_t maxIter = innerIterations;
|
||||
|
||||
@@ -254,13 +254,14 @@ int run_test_with_two_queue(
|
||||
|
||||
VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType);
|
||||
VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType);
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore = nullptr;
|
||||
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore, vkCl2VkSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceId, true);
|
||||
clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory2;
|
||||
@@ -873,13 +874,14 @@ int run_test_with_one_queue(
|
||||
|
||||
VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType);
|
||||
VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType);
|
||||
clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
|
||||
clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
|
||||
clExternalImportableSemaphore *clVk2CLExternalSemaphore = nullptr;
|
||||
clExternalExportableSemaphore *clCl2VkExternalSemaphore = nullptr;
|
||||
|
||||
CREATE_OPENCL_SEMAPHORE(clVk2CLExternalSemaphore, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceId, false);
|
||||
CREATE_OPENCL_SEMAPHORE(clCl2VkExternalSemaphore, vkCl2VkSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceId, true);
|
||||
clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory2;
|
||||
|
||||
Reference in New Issue
Block a user