Use the right flags when creating images (#328) (#1015)

Test was querying for supported images with CL_MEM_WRITE_ONLY flag, but
always used CL_MEM_READ_ONLY to create images.

Fixes issue #328

Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
Signed-off-by: James Morrissey <james.morrissey@arm.com>

Co-authored-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
james-morrissey-arm
2021-01-07 12:26:44 +00:00
committed by GitHub
parent 18c54be0a4
commit 24e6a9125c
6 changed files with 115 additions and 51 deletions

View File

@@ -15,7 +15,9 @@
//
#include "../testBase.h"
int test_read_image_2D_array( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d )
int test_read_image_2D_array(cl_context context, cl_command_queue queue,
image_descriptor *imageInfo, MTdata d,
cl_mem_flags flags)
{
int error;
@@ -35,7 +37,9 @@ int test_read_image_2D_array( cl_context context, cl_command_queue queue, image_
// Construct testing sources
if(!gTestMipmaps)
{
image = create_image_2d_array( context, (cl_mem_flags)(CL_MEM_READ_ONLY), imageInfo->format, imageInfo->width, imageInfo->height, imageInfo->arraySize, 0, 0, NULL, &error );
image = create_image_2d_array(context, flags, imageInfo->format,
imageInfo->width, imageInfo->height,
imageInfo->arraySize, 0, 0, NULL, &error);
if( image == NULL )
{
log_error( "ERROR: Unable to create 2D image array of size %d x %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize, IGetErrorString( error ) );
@@ -51,7 +55,8 @@ int test_read_image_2D_array( cl_context context, cl_command_queue queue, image_
image_desc.image_array_size = imageInfo->arraySize;
image_desc.num_mip_levels = imageInfo->num_mip_levels;
image = clCreateImage( context, CL_MEM_READ_ONLY, imageInfo->format, &image_desc, NULL, &error);
image = clCreateImage(context, flags, imageInfo->format, &image_desc,
NULL, &error);
if( error != CL_SUCCESS )
{
log_error( "ERROR: Unable to create %d level mipmapped 3D image of size %d x %d x %d (pitch %d, %d ) (%s)",(int)imageInfo->num_mip_levels, (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth, (int)imageInfo->rowPitch, (int)imageInfo->slicePitch, IGetErrorString( error ) );
@@ -142,7 +147,9 @@ int test_read_image_2D_array( cl_context context, cl_command_queue queue, image_
return 0;
}
int test_read_image_set_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format )
int test_read_image_set_2D_array(cl_device_id device, cl_context context,
cl_command_queue queue,
cl_image_format *format, cl_mem_flags flags)
{
size_t maxWidth, maxHeight, maxArraySize;
cl_ulong maxAllocSize, memSize;
@@ -181,7 +188,8 @@ int test_read_image_set_2D_array( cl_device_id device, cl_context context, cl_co
if( gDebugTrace )
log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize );
int ret = test_read_image_2D_array( context, queue, &imageInfo, seed );
int ret = test_read_image_2D_array(context, queue,
&imageInfo, seed, flags);
if( ret )
return -1;
}
@@ -209,7 +217,8 @@ int test_read_image_set_2D_array( cl_device_id device, cl_context context, cl_co
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed);
log_info("Testing %d x %d x %d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize);
if( test_read_image_2D_array( context, queue, &imageInfo, seed ) )
if (test_read_image_2D_array(context, queue, &imageInfo, seed,
flags))
return -1;
}
}
@@ -253,7 +262,8 @@ int test_read_image_set_2D_array( cl_device_id device, cl_context context, cl_co
if( gDebugTrace )
log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxArraySize );
int ret = test_read_image_2D_array( context, queue, &imageInfo, seed );
int ret = test_read_image_2D_array(context, queue, &imageInfo, seed,
flags);
if( ret )
return -1;
}