mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Use std::vector for format lists in images suite (#1105)
* Use std::vector for format lists in images suite Avoids memory deallocation issues and generally simplifies the code. * Fixup formatting with git-clang-format
This commit is contained in:
@@ -1562,8 +1562,11 @@ int test_read_image_2D( cl_context context, cl_command_queue queue, cl_kernel ke
|
||||
return numTries != MAX_TRIES || numClamped != MAX_CLAMPED;
|
||||
}
|
||||
|
||||
int test_read_image_set_2D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType )
|
||||
int test_read_image_set_2D(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler, bool floatCoords,
|
||||
ExplicitType outputType)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -24,34 +24,34 @@ extern int gtestTypesToRun;
|
||||
|
||||
extern int test_read_image_set_1D(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
cl_image_format *format,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType);
|
||||
extern int test_read_image_set_2D(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
cl_image_format *format,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType);
|
||||
extern int test_read_image_set_3D(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
cl_image_format *format,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType);
|
||||
extern int test_read_image_set_1D_array(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
cl_image_format *format,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords,
|
||||
ExplicitType outputType);
|
||||
extern int test_read_image_set_2D_array(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
cl_image_format *format,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords,
|
||||
ExplicitType outputType);
|
||||
|
||||
int test_read_image_type(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, cl_image_format *format,
|
||||
cl_command_queue queue, const cl_image_format *format,
|
||||
bool floatCoords, image_sampler_data *imageSampler,
|
||||
ExplicitType outputType, cl_mem_object_type imageType)
|
||||
{
|
||||
@@ -164,8 +164,9 @@ int test_read_image_type(cl_device_id device, cl_context context,
|
||||
}
|
||||
|
||||
int test_read_image_formats(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, cl_image_format *formatList,
|
||||
bool *filterFlags, unsigned int numFormats,
|
||||
cl_command_queue queue,
|
||||
const std::vector<cl_image_format> &formatList,
|
||||
const std::vector<bool> &filterFlags,
|
||||
image_sampler_data *imageSampler,
|
||||
ExplicitType outputType,
|
||||
cl_mem_object_type imageType)
|
||||
@@ -212,11 +213,11 @@ int test_read_image_formats(cl_device_id device, cl_context context,
|
||||
: "integer",
|
||||
get_explicit_type_name(outputType));
|
||||
|
||||
for (unsigned int i = 0; i < numFormats; i++)
|
||||
for (unsigned int i = 0; i < formatList.size(); i++)
|
||||
{
|
||||
if (filterFlags[i]) continue;
|
||||
|
||||
cl_image_format &imageFormat = formatList[i];
|
||||
const cl_image_format &imageFormat = formatList[i];
|
||||
|
||||
ret |=
|
||||
test_read_image_type(device, context, queue, &imageFormat,
|
||||
@@ -290,11 +291,6 @@ int test_image_set(cl_device_id device, cl_context context,
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the list of supported image formats for integer reads
|
||||
cl_image_format *formatList;
|
||||
bool *filterFlags;
|
||||
unsigned int numFormats;
|
||||
|
||||
// This flag is only for querying the list of supported formats
|
||||
// The flag for creating image will be set explicitly in test functions
|
||||
cl_mem_flags flags;
|
||||
@@ -326,19 +322,9 @@ int test_image_set(cl_device_id device, cl_context context,
|
||||
}
|
||||
}
|
||||
|
||||
if (get_format_list(context, imageType, formatList, numFormats, flags))
|
||||
return -1;
|
||||
BufferOwningPtr<cl_image_format> formatListBuf(formatList);
|
||||
|
||||
|
||||
filterFlags = new bool[numFormats];
|
||||
if (filterFlags == NULL)
|
||||
{
|
||||
log_error("ERROR: Out of memory allocating filter flags list!\n");
|
||||
return -1;
|
||||
}
|
||||
BufferOwningPtr<bool> filterFlagsBuf(filterFlags);
|
||||
memset(filterFlags, 0, sizeof(bool) * numFormats);
|
||||
// Grab the list of supported image formats for integer reads
|
||||
std::vector<cl_image_format> formatList;
|
||||
if (get_format_list(context, imageType, formatList, flags)) return -1;
|
||||
|
||||
// First time through, we'll go ahead and print the formats supported,
|
||||
// regardless of type
|
||||
@@ -348,7 +334,7 @@ int test_image_set(cl_device_id device, cl_context context,
|
||||
{
|
||||
log_info("---- Supported %s %s formats for this device ---- \n",
|
||||
convert_image_type_to_string(imageType), flagNames);
|
||||
for (unsigned int f = 0; f < numFormats; f++)
|
||||
for (unsigned int f = 0; f < formatList.size(); f++)
|
||||
{
|
||||
if (IsChannelOrderSupported(formatList[f].image_channel_order)
|
||||
&& IsChannelTypeSupported(
|
||||
@@ -369,8 +355,9 @@ int test_image_set(cl_device_id device, cl_context context,
|
||||
{
|
||||
if (gTypesToTest & test.type)
|
||||
{
|
||||
if (filter_formats(formatList, filterFlags, numFormats,
|
||||
test.channelTypes, gTestMipmaps)
|
||||
std::vector<bool> filterFlags(formatList.size(), false);
|
||||
if (filter_formats(formatList, filterFlags, test.channelTypes,
|
||||
gTestMipmaps)
|
||||
== 0)
|
||||
{
|
||||
log_info("No formats supported for %s type\n", test.name);
|
||||
@@ -379,7 +366,7 @@ int test_image_set(cl_device_id device, cl_context context,
|
||||
{
|
||||
imageSampler.filter_mode = CL_FILTER_NEAREST;
|
||||
ret += formatTestFn(device, context, queue, formatList,
|
||||
filterFlags, numFormats, &imageSampler,
|
||||
filterFlags, &imageSampler,
|
||||
test.explicitType, imageType);
|
||||
|
||||
// Linear filtering is only supported with floats
|
||||
@@ -387,7 +374,7 @@ int test_image_set(cl_device_id device, cl_context context,
|
||||
{
|
||||
imageSampler.filter_mode = CL_FILTER_LINEAR;
|
||||
ret += formatTestFn(device, context, queue, formatList,
|
||||
filterFlags, numFormats, &imageSampler,
|
||||
filterFlags, &imageSampler,
|
||||
test.explicitType, imageType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,8 +985,11 @@ int test_read_image_1D( cl_context context, cl_command_queue queue, cl_kernel ke
|
||||
return numTries != MAX_TRIES || numClamped != MAX_CLAMPED;
|
||||
}
|
||||
|
||||
int test_read_image_set_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType )
|
||||
int test_read_image_set_1D(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler, bool floatCoords,
|
||||
ExplicitType outputType)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -1094,8 +1094,11 @@ int test_read_image_1D_array( cl_context context, cl_command_queue queue, cl_ker
|
||||
return numTries != MAX_TRIES || numClamped != MAX_CLAMPED;
|
||||
}
|
||||
|
||||
int test_read_image_set_1D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType )
|
||||
int test_read_image_set_1D_array(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -1301,8 +1301,11 @@ int test_read_image_2D_array( cl_context context, cl_command_queue queue, cl_ker
|
||||
return numTries != MAX_TRIES || numClamped != MAX_CLAMPED;
|
||||
}
|
||||
|
||||
int test_read_image_set_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType )
|
||||
int test_read_image_set_2D_array(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -1158,8 +1158,11 @@ int test_read_image_3D( cl_context context, cl_command_queue queue, cl_kernel ke
|
||||
return numTries != MAX_TRIES || numClamped != MAX_CLAMPED;
|
||||
}
|
||||
|
||||
int test_read_image_set_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, image_sampler_data *imageSampler,
|
||||
bool floatCoords, ExplicitType outputType )
|
||||
int test_read_image_set_3D(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
image_sampler_data *imageSampler, bool floatCoords,
|
||||
ExplicitType outputType)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -521,7 +521,10 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que
|
||||
return totalErrors;
|
||||
}
|
||||
|
||||
int test_write_image_1D_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d )
|
||||
int test_write_image_1D_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -542,7 +542,10 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma
|
||||
}
|
||||
|
||||
|
||||
int test_write_image_1D_array_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d )
|
||||
int test_write_image_1D_array_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -568,7 +568,10 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma
|
||||
}
|
||||
|
||||
|
||||
int test_write_image_2D_array_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d )
|
||||
int test_write_image_2D_array_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -576,7 +576,10 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que
|
||||
}
|
||||
|
||||
|
||||
int test_write_image_3D_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d )
|
||||
int test_write_image_3D_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
|
||||
@@ -23,10 +23,24 @@ extern bool gTestImage2DFromBuffer;
|
||||
extern cl_mem_flags gMemFlagsToUse;
|
||||
extern int gtestTypesToRun;
|
||||
|
||||
extern int test_write_image_1D_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d );
|
||||
extern int test_write_image_3D_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d );
|
||||
extern int test_write_image_1D_array_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d );
|
||||
extern int test_write_image_2D_array_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d );
|
||||
extern int test_write_image_1D_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d);
|
||||
extern int test_write_image_3D_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d);
|
||||
extern int test_write_image_1D_array_set(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d);
|
||||
extern int test_write_image_2D_array_set(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d);
|
||||
|
||||
extern bool validate_float_write_results( float *expected, float *actual, image_descriptor *imageInfo );
|
||||
extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor *imageInfo );
|
||||
@@ -595,7 +609,9 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue
|
||||
}
|
||||
|
||||
|
||||
int test_write_image_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType inputType, MTdata d )
|
||||
int test_write_image_set(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, const cl_image_format *format,
|
||||
ExplicitType inputType, MTdata d)
|
||||
{
|
||||
char programSrc[10240];
|
||||
const char *ptr;
|
||||
@@ -797,8 +813,13 @@ int test_write_image_set( cl_device_id device, cl_context context, cl_command_qu
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_write_image_formats( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *formatList, bool *filterFlags, unsigned int numFormats,
|
||||
image_sampler_data *imageSampler, ExplicitType inputType, cl_mem_object_type imageType )
|
||||
int test_write_image_formats(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue,
|
||||
const std::vector<cl_image_format> &formatList,
|
||||
const std::vector<bool> &filterFlags,
|
||||
image_sampler_data *imageSampler,
|
||||
ExplicitType inputType,
|
||||
cl_mem_object_type imageType)
|
||||
{
|
||||
if( imageSampler->filter_mode == CL_FILTER_LINEAR )
|
||||
// No need to run for linear filters
|
||||
@@ -811,9 +832,9 @@ int test_write_image_formats( cl_device_id device, cl_context context, cl_comman
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
for( unsigned int i = 0; i < numFormats; i++ )
|
||||
for (unsigned int i = 0; i < formatList.size(); i++)
|
||||
{
|
||||
cl_image_format &imageFormat = formatList[ i ];
|
||||
const cl_image_format &imageFormat = formatList[i];
|
||||
|
||||
if( filterFlags[ i ] )
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user