diff --git a/test_common/harness/kernelHelpers.cpp b/test_common/harness/kernelHelpers.cpp index 2139821a..3f73638c 100644 --- a/test_common/harness/kernelHelpers.cpp +++ b/test_common/harness/kernelHelpers.cpp @@ -1467,6 +1467,43 @@ int checkFor3DImageSupport( cl_device_id device ) return 0; } +int checkForReadWriteImageSupport(cl_device_id device) +{ + if (checkForImageSupport(device)) + { + return CL_IMAGE_FORMAT_NOT_SUPPORTED; + } + + auto device_cl_version = get_device_cl_version(device); + if (device_cl_version >= Version(3, 0)) + { + // In OpenCL 3.0, Read-Write images are optional. + // Check if they are supported. + cl_uint are_rw_images_supported{}; + test_error( + clGetDeviceInfo(device, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, + sizeof(are_rw_images_supported), + &are_rw_images_supported, nullptr), + "clGetDeviceInfo failed for CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS\n"); + if (0 == are_rw_images_supported) + { + log_info("READ_WRITE_IMAGE tests skipped, not supported.\n"); + return CL_IMAGE_FORMAT_NOT_SUPPORTED; + } + } + // READ_WRITE images are not supported on 1.X devices. + else if (device_cl_version < Version(2, 0)) + { + log_info("READ_WRITE_IMAGE tests skipped, Opencl 2.0+ is requried."); + return CL_IMAGE_FORMAT_NOT_SUPPORTED; + } + // Support for read-write image arguments is required + // for an 2.X device if the device supports images. + + /* So our support is good */ + return 0; +} + size_t get_min_alignment(cl_context context) { static cl_uint align_size = 0; diff --git a/test_common/harness/kernelHelpers.h b/test_common/harness/kernelHelpers.h index c5ff5d0d..d78481e1 100644 --- a/test_common/harness/kernelHelpers.h +++ b/test_common/harness/kernelHelpers.h @@ -141,6 +141,7 @@ extern test_status verifyImageSupport( cl_device_id device ); /* Checks that the given device supports images. Same as verify, but doesn't print an error */ extern int checkForImageSupport( cl_device_id device ); extern int checkFor3DImageSupport( cl_device_id device ); +extern int checkForReadWriteImageSupport(cl_device_id device); /* Checks that a given queue property is supported on the specified device. Returns 1 if supported, 0 if not or an error. */ extern int checkDeviceForQueueSupport( cl_device_id device, cl_command_queue_properties prop ); diff --git a/test_conformance/images/kernel_read_write/main.cpp b/test_conformance/images/kernel_read_write/main.cpp index 51d5c071..98506934 100644 --- a/test_conformance/images/kernel_read_write/main.cpp +++ b/test_conformance/images/kernel_read_write/main.cpp @@ -177,11 +177,10 @@ static int doTest( cl_device_id device, cl_context context, cl_command_queue que } } - if (testTypesToRun & kReadWriteTests) { - if (gDeviceLt20) { - log_info("TEST skipped, Opencl 2.0 + requried for this test"); - return ret; - } + if ((testTypesToRun & kReadWriteTests) + && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; } if( ( testTypesToRun & kReadWriteTests ) && !gTestMipmaps ) diff --git a/test_conformance/images/samplerlessReads/test_iterations.cpp b/test_conformance/images/samplerlessReads/test_iterations.cpp index 857fbc67..c33007f1 100644 --- a/test_conformance/images/samplerlessReads/test_iterations.cpp +++ b/test_conformance/images/samplerlessReads/test_iterations.cpp @@ -201,6 +201,11 @@ int test_read_image_set_2D( cl_device_id device, cl_context context, cl_command_ image_descriptor imageInfo = { 0 }; size_t pixelSize; + if (gTestReadWrite && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; + } + imageInfo.format = format; imageInfo.depth = imageInfo.arraySize = imageInfo.slicePitch = 0; imageInfo.type = CL_MEM_OBJECT_IMAGE2D; diff --git a/test_conformance/images/samplerlessReads/test_loops.cpp b/test_conformance/images/samplerlessReads/test_loops.cpp index e50d5d42..639efa80 100644 --- a/test_conformance/images/samplerlessReads/test_loops.cpp +++ b/test_conformance/images/samplerlessReads/test_loops.cpp @@ -109,9 +109,9 @@ int test_image_set( cl_device_id device, cl_context context, cl_command_queue qu gDeviceLt20 = true; } - if (gDeviceLt20 && gTestReadWrite) { - log_info("TEST skipped, Opencl 2.0 + requried for this test"); - return ret; + if (gTestReadWrite && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; } // This flag is only for querying the list of supported formats diff --git a/test_conformance/images/samplerlessReads/test_read_1D.cpp b/test_conformance/images/samplerlessReads/test_read_1D.cpp index 173bc6f7..f38a2e64 100644 --- a/test_conformance/images/samplerlessReads/test_read_1D.cpp +++ b/test_conformance/images/samplerlessReads/test_read_1D.cpp @@ -196,6 +196,11 @@ int test_read_image_set_1D( cl_device_id device, cl_context context, cl_command_ RandomSeed seed( gRandomSeed ); int error; + if (gTestReadWrite && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; + } + // Get our operating params size_t maxWidth; cl_ulong maxAllocSize, memSize; diff --git a/test_conformance/images/samplerlessReads/test_read_1D_array.cpp b/test_conformance/images/samplerlessReads/test_read_1D_array.cpp index 503a161d..c86250fc 100644 --- a/test_conformance/images/samplerlessReads/test_read_1D_array.cpp +++ b/test_conformance/images/samplerlessReads/test_read_1D_array.cpp @@ -198,6 +198,11 @@ int test_read_image_set_1D_array( cl_device_id device, cl_context context, cl_co image_descriptor imageInfo = { 0 }; size_t pixelSize; + if (gTestReadWrite && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; + } + imageInfo.format = format; imageInfo.height = imageInfo.depth = 0; imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY; diff --git a/test_conformance/images/samplerlessReads/test_read_2D_array.cpp b/test_conformance/images/samplerlessReads/test_read_2D_array.cpp index 22fcffc3..fe221ee5 100644 --- a/test_conformance/images/samplerlessReads/test_read_2D_array.cpp +++ b/test_conformance/images/samplerlessReads/test_read_2D_array.cpp @@ -176,6 +176,11 @@ int test_read_image_set_2D_array( cl_device_id device, cl_context context, cl_co int error; + if (gTestReadWrite && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; + } + clProgramWrapper program; clKernelWrapper kernel; diff --git a/test_conformance/images/samplerlessReads/test_read_3D.cpp b/test_conformance/images/samplerlessReads/test_read_3D.cpp index 142d7225..e06a347c 100644 --- a/test_conformance/images/samplerlessReads/test_read_3D.cpp +++ b/test_conformance/images/samplerlessReads/test_read_3D.cpp @@ -179,6 +179,11 @@ int test_read_image_set_3D( cl_device_id device, cl_context context, cl_command_ int error; + if (gTestReadWrite && checkForReadWriteImageSupport(device)) + { + return TEST_SKIPPED_ITSELF; + } + clProgramWrapper program; clKernelWrapper kernel;