Ensure is_extension_available is used where possible (#722)

(Patch2)
A number of tests have got their own code for checking the presence of
extensions. This change replaces that code with is_extension_available
function.

Contributes to #627

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>

Change-Id: I17e007e5ad009e522c5006c42537bf1170550a6f
This commit is contained in:
ellnor01
2020-04-03 10:49:53 +01:00
committed by GitHub
parent cd3b552094
commit 93e76a8a4a
10 changed files with 76 additions and 262 deletions

View File

@@ -439,22 +439,7 @@ int supportsHalf(cl_context context, bool* supports_half)
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, numDev * sizeof(cl_device_id), devices, NULL);
test_error(error, "clGetContextInfo for CL_CONTEXT_DEVICES failed");
// Get the extensions string for the device
error = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, 0, NULL, &size);
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS size failed");
char *extensions = new char[size+1];
if (extensions == 0) {
log_error("Failed to allocate memory for extensions string.\n");
return -1;
}
memset( extensions, CHAR_MIN, sizeof(char)*(size+1) );
error = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, sizeof(char)*size, extensions, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS failed");
*supports_half = strstr(extensions, "cl_khr_fp16");
delete [] extensions;
*supports_half = is_extension_available(devices[0], "cl_khr_fp16");
delete [] devices;
return error;
@@ -473,22 +458,7 @@ int supportsMsaa(cl_context context, bool* supports_msaa)
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, numDev * sizeof(cl_device_id), devices, NULL);
test_error(error, "clGetContextInfo for CL_CONTEXT_DEVICES failed");
// Get the extensions string for the device
error = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, 0, NULL, &size);
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS size failed");
char *extensions = new char[size+1];
if (extensions == 0) {
log_error("Failed to allocate memory for extensions string.\n");
return -1;
}
memset( extensions, CHAR_MIN, sizeof(char)*(size+1) );
error = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, sizeof(char)*size, extensions, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS failed");
*supports_msaa = strstr(extensions, "cl_khr_gl_msaa_sharing");
delete [] extensions;
*supports_msaa = is_extension_available(devices[0], "cl_khr_gl_msaa_sharing");
delete [] devices;
return error;
@@ -507,22 +477,7 @@ int supportsDepth(cl_context context, bool* supports_depth)
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, numDev * sizeof(cl_device_id), devices, NULL);
test_error(error, "clGetContextInfo for CL_CONTEXT_DEVICES failed");
// Get the extensions string for the device
error = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, 0, NULL, &size);
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS size failed");
char *extensions = new char[size+1];
if (extensions == 0) {
log_error("Failed to allocate memory for extensions string.\n");
return -1;
}
memset( extensions, CHAR_MIN, sizeof(char)*(size+1) );
error = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, sizeof(char)*size, extensions, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS failed");
*supports_depth = strstr(extensions, "cl_khr_gl_depth_images");
delete [] extensions;
*supports_depth = is_extension_available(devices[0], "cl_khr_gl_depth_images");
delete [] devices;
return error;