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( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d )
int test_read_image_1D(cl_context context, cl_command_queue queue,
image_descriptor *imageInfo, MTdata d,
cl_mem_flags flags)
{
int error;
@@ -34,12 +36,14 @@ int test_read_image_1D( cl_context context, cl_command_queue queue, image_descri
// Construct testing sources
if(!gTestMipmaps)
{
image = create_image_1d( context, (cl_mem_flags)(CL_MEM_READ_ONLY), imageInfo->format, imageInfo->width, 0, NULL, NULL, &error );
if( image == NULL )
{
log_error( "ERROR: Unable to create 1D image of size %d (%s)", (int)imageInfo->width, IGetErrorString( error ) );
return -1;
}
image = create_image_1d(context, flags, imageInfo->format,
imageInfo->width, 0, NULL, NULL, &error);
if (image == NULL)
{
log_error("ERROR: Unable to create 1D image of size %d (%s)",
(int)imageInfo->width, IGetErrorString(error));
return -1;
}
}
else
{
@@ -48,7 +52,8 @@ int test_read_image_1D( cl_context context, cl_command_queue queue, image_descri
image_desc.image_width = imageInfo->width;
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 size %d x %d (pitch %d ) (%s)",(int)imageInfo->num_mip_levels, (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->rowPitch, IGetErrorString( error ) );
@@ -158,7 +163,9 @@ int test_read_image_1D( cl_context context, cl_command_queue queue, image_descri
return 0;
}
int test_read_image_set_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format )
int test_read_image_set_1D(cl_device_id device, cl_context context,
cl_command_queue queue, cl_image_format *format,
cl_mem_flags flags)
{
size_t maxWidth;
cl_ulong maxAllocSize, memSize;
@@ -192,7 +199,8 @@ int test_read_image_set_1D( cl_device_id device, cl_context context, cl_command_
if( gDebugTrace )
log_info( " at size %d\n", (int)imageInfo.width );
int ret = test_read_image_1D( context, queue, &imageInfo, seed );
int ret =
test_read_image_1D(context, queue, &imageInfo, seed, flags);
if( ret )
return -1;
}
@@ -216,7 +224,7 @@ int test_read_image_set_1D( cl_device_id device, cl_context context, cl_command_
log_info("Testing %d\n", (int)imageInfo.width);
if( gDebugTrace )
log_info( " at max size %d\n", (int)maxWidth );
if( test_read_image_1D( context, queue, &imageInfo, seed ) )
if (test_read_image_1D(context, queue, &imageInfo, seed, flags))
return -1;
}
}
@@ -252,7 +260,8 @@ int test_read_image_set_1D( cl_device_id device, cl_context context, cl_command_
if( gDebugTrace )
log_info( " at size %d (row pitch %d) out of %d\n", (int)imageInfo.width, (int)imageInfo.rowPitch, (int)maxWidth );
int ret = test_read_image_1D( context, queue, &imageInfo, seed );
int ret =
test_read_image_1D(context, queue, &imageInfo, seed, flags);
if( ret )
return -1;
}