mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-20 06:29:02 +00:00
Remove duplicate format functions (#738)
This moves the filter_formats and get_format_list functions to a common file. These functions were roughly the same, with an optional filtering in some tests for testing mipmaps. Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
#include "../common.h"
|
||||
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
@@ -39,116 +40,6 @@ extern int test_read_image_set_1D_array( cl_device_id device, cl_context context
|
||||
extern 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 );
|
||||
|
||||
static const char *str_1d_image = "1D";
|
||||
static const char *str_2d_image = "2D";
|
||||
static const char *str_3d_image = "3D";
|
||||
static const char *str_1d_image_array = "1D array";
|
||||
static const char *str_2d_image_array = "2D array";
|
||||
|
||||
static const char *convert_image_type_to_string(cl_mem_object_type imageType)
|
||||
{
|
||||
const char *p;
|
||||
switch (imageType)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
p = str_1d_image;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
p = str_2d_image;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
p = str_3d_image;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
p = str_1d_image_array;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
p = str_2d_image_array;
|
||||
break;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
int filter_formats( cl_image_format *formatList, bool *filterFlags, unsigned int formatCount, cl_channel_type *channelDataTypesToFilter )
|
||||
{
|
||||
int numSupported = 0;
|
||||
for( unsigned int j = 0; j < formatCount; j++ )
|
||||
{
|
||||
// If this format has been previously filtered, remove the filter
|
||||
if( filterFlags[ j ] )
|
||||
filterFlags[ j ] = false;
|
||||
|
||||
// skip mipmap tests for CL_DEPTH formats (re# Khronos Bug 13762)
|
||||
if(gTestMipmaps && (formatList[ j ].image_channel_order == CL_DEPTH))
|
||||
{
|
||||
log_info("Skip mipmap tests for CL_DEPTH format\n");
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Have we already discarded the channel type via the command line?
|
||||
if( gChannelTypeToUse != (cl_channel_type)-1 && gChannelTypeToUse != formatList[ j ].image_channel_data_type )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Have we already discarded the channel order via the command line?
|
||||
if( gChannelOrderToUse != (cl_channel_order)-1 && gChannelOrderToUse != formatList[ j ].image_channel_order )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is given format standard channel order and type given by spec. We don't want to test it if this is vendor extension
|
||||
if( !IsChannelOrderSupported( formatList[ j ].image_channel_order ) || !IsChannelTypeSupported( formatList[ j ].image_channel_data_type ) )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !channelDataTypesToFilter )
|
||||
{
|
||||
numSupported++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the format supported?
|
||||
int i;
|
||||
for( i = 0; channelDataTypesToFilter[ i ] != (cl_channel_type)-1; i++ )
|
||||
{
|
||||
if( formatList[ j ].image_channel_data_type == channelDataTypesToFilter[ i ] )
|
||||
{
|
||||
numSupported++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( channelDataTypesToFilter[ i ] == (cl_channel_type)-1 )
|
||||
{
|
||||
// Format is NOT supported, so mark it as such
|
||||
filterFlags[ j ] = true;
|
||||
}
|
||||
}
|
||||
return numSupported;
|
||||
}
|
||||
|
||||
int get_format_list( cl_context context, cl_mem_object_type imageType, cl_image_format * &outFormatList, unsigned int &outFormatCount, cl_mem_flags flags )
|
||||
{
|
||||
int error;
|
||||
|
||||
cl_image_format tempList[ 128 ];
|
||||
error = clGetSupportedImageFormats( context, flags,
|
||||
imageType, 128, tempList, &outFormatCount );
|
||||
test_error( error, "Unable to get count of supported image formats" );
|
||||
|
||||
outFormatList = new cl_image_format[ outFormatCount ];
|
||||
error = clGetSupportedImageFormats( context, flags,
|
||||
imageType, outFormatCount, outFormatList, NULL );
|
||||
test_error( error, "Unable to get list of supported image formats" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_read_image_type( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool floatCoords,
|
||||
image_sampler_data *imageSampler, ExplicitType outputType, cl_mem_object_type imageType )
|
||||
{
|
||||
@@ -416,7 +307,9 @@ int test_image_set( cl_device_id device, cl_context context, cl_command_queue qu
|
||||
#endif
|
||||
CL_UNORM_INT8, CL_SNORM_INT8,
|
||||
CL_UNORM_INT16, CL_SNORM_INT16, CL_FLOAT, CL_HALF_FLOAT, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, floatFormats ) == 0 )
|
||||
if (filter_formats(formatList, filterFlags, numFormats, floatFormats,
|
||||
gTestMipmaps)
|
||||
== 0)
|
||||
{
|
||||
log_info( "No formats supported for float type\n" );
|
||||
}
|
||||
@@ -434,7 +327,9 @@ int test_image_set( cl_device_id device, cl_context context, cl_command_queue qu
|
||||
if( gTypesToTest & kTestInt )
|
||||
{
|
||||
cl_channel_type intFormats[] = { CL_SIGNED_INT8, CL_SIGNED_INT16, CL_SIGNED_INT32, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, intFormats ) == 0 )
|
||||
if (filter_formats(formatList, filterFlags, numFormats, intFormats,
|
||||
gTestMipmaps)
|
||||
== 0)
|
||||
{
|
||||
log_info( "No formats supported for integer type\n" );
|
||||
}
|
||||
@@ -451,7 +346,9 @@ int test_image_set( cl_device_id device, cl_context context, cl_command_queue qu
|
||||
if( gTypesToTest & kTestUInt )
|
||||
{
|
||||
cl_channel_type uintFormats[] = { CL_UNSIGNED_INT8, CL_UNSIGNED_INT16, CL_UNSIGNED_INT32, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, uintFormats ) == 0 )
|
||||
if (filter_formats(formatList, filterFlags, numFormats, uintFormats,
|
||||
gTestMipmaps)
|
||||
== 0)
|
||||
{
|
||||
log_info( "No formats supported for unsigned int type\n" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user