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_1D_array( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d )
int test_read_image_1D_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_1D_array( cl_context context, cl_command_queue queue, image_
// Construct testing sources
if(!gTestMipmaps)
{
image = create_image_1d_array( context, (cl_mem_flags)(CL_MEM_READ_ONLY), imageInfo->format, imageInfo->width, imageInfo->arraySize, 0, 0, NULL, &error );
image = create_image_1d_array(context, flags, imageInfo->format,
imageInfo->width, imageInfo->arraySize, 0,
0, NULL, &error);
if( image == NULL )
{
log_error( "ERROR: Unable to create 1D image array of size %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->arraySize, IGetErrorString( error ) );
@@ -50,7 +54,8 @@ int test_read_image_1D_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 1D image of width %d and array size %d (pitch %d ) (%s)",(int)imageInfo->num_mip_levels, (int)imageInfo->width, (int)imageInfo->arraySize, (int)imageInfo->rowPitch, IGetErrorString( error ) );
@@ -164,7 +169,9 @@ int test_read_image_1D_array( cl_context context, cl_command_queue queue, image_
return 0;
}
int test_read_image_set_1D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format )
int test_read_image_set_1D_array(cl_device_id device, cl_context context,
cl_command_queue queue,
cl_image_format *format, cl_mem_flags flags)
{
size_t maxWidth, maxArraySize;
cl_ulong maxAllocSize, memSize;
@@ -201,7 +208,8 @@ int test_read_image_set_1D_array( cl_device_id device, cl_context context, cl_co
if( gDebugTrace )
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize );
int ret = test_read_image_1D_array( context, queue, &imageInfo, seed );
int ret = test_read_image_1D_array(context, queue, &imageInfo,
seed, flags);
if( ret )
return -1;
}
@@ -228,7 +236,8 @@ int test_read_image_set_1D_array( cl_device_id device, cl_context context, cl_co
log_info("Testing %d x %d\n", (int)imageInfo.width, (int)imageInfo.arraySize);
if( gDebugTrace )
log_info( " at max size %d,%d\n", (int)maxWidth, (int)maxArraySize );
if( test_read_image_1D_array( context, queue, &imageInfo, seed ) )
if (test_read_image_1D_array(context, queue, &imageInfo, seed,
flags))
return -1;
}
}
@@ -266,7 +275,8 @@ int test_read_image_set_1D_array( cl_device_id device, cl_context context, cl_co
if( gDebugTrace )
log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxArraySize );
int ret = test_read_image_1D_array( context, queue, &imageInfo, seed );
int ret = test_read_image_1D_array(context, queue, &imageInfo, seed,
flags);
if( ret )
return -1;
}