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_3D( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d )
int test_read_image_3D(cl_context context, cl_command_queue queue,
image_descriptor *imageInfo, MTdata d,
cl_mem_flags flags)
{
int error;
@@ -34,7 +36,9 @@ int test_read_image_3D( cl_context context, cl_command_queue queue, image_descri
// Construct testing sources
if(!gTestMipmaps)
{
image = create_image_3d( context, (cl_mem_flags)(CL_MEM_READ_ONLY), imageInfo->format, imageInfo->width, imageInfo->height, imageInfo->depth, 0, 0, NULL, &error );
image = create_image_3d(context, flags, imageInfo->format,
imageInfo->width, imageInfo->height,
imageInfo->depth, 0, 0, NULL, &error);
if( image == NULL )
{
log_error( "ERROR: Unable to create 2D image of size %d x %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth, IGetErrorString( error ) );
@@ -50,7 +54,8 @@ int test_read_image_3D( cl_context context, cl_command_queue queue, image_descri
image_desc.image_depth = imageInfo->depth;
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 ) );
@@ -147,7 +152,9 @@ int test_read_image_3D( cl_context context, cl_command_queue queue, image_descri
return 0;
}
int test_read_image_set_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format )
int test_read_image_set_3D(cl_device_id device, cl_context context,
cl_command_queue queue, cl_image_format *format,
cl_mem_flags flags)
{
size_t maxWidth, maxHeight, maxDepth;
cl_ulong maxAllocSize, memSize;
@@ -186,7 +193,8 @@ int test_read_image_set_3D( cl_device_id device, cl_context context, cl_command_
if( gDebugTrace )
log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth );
int ret = test_read_image_3D( context, queue, &imageInfo, seed );
int ret = test_read_image_3D(context, queue, &imageInfo,
seed, flags);
if( ret )
return -1;
}
@@ -214,8 +222,8 @@ int test_read_image_set_3D( cl_device_id device, cl_context context, cl_command_
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, imageInfo.depth), seed);
log_info("Testing %d x %d x %d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth);
if( test_read_image_3D( context, queue, &imageInfo, seed ) )
return -1;
if (test_read_image_3D(context, queue, &imageInfo, seed, flags))
return -1;
}
}
else
@@ -257,7 +265,8 @@ int test_read_image_set_3D( cl_device_id device, cl_context context, cl_command_
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.depth, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxDepth );
int ret = test_read_image_3D( context, queue, &imageInfo, seed );
int ret =
test_read_image_3D(context, queue, &imageInfo, seed, flags);
if( ret )
return -1;
}