diff --git a/test_common/harness/imageHelpers.cpp b/test_common/harness/imageHelpers.cpp index d1754653..314709f8 100644 --- a/test_common/harness/imageHelpers.cpp +++ b/test_common/harness/imageHelpers.cpp @@ -479,6 +479,47 @@ void print_first_pixel_difference_error(size_t where, const char *sourcePixel, } } +size_t compare_scanlines(const image_descriptor *imageInfo, const char *aPtr, + const char *bPtr) +{ + size_t pixel_size = get_pixel_size(imageInfo->format); + size_t column; + + for (column = 0; column < imageInfo->width; column++) + { + switch (imageInfo->format->image_channel_data_type) + { + // If the data type is 101010, then ignore bits 31 and 32 when + // comparing the row + case CL_UNORM_INT_101010: { + cl_uint aPixel = *(cl_uint *)aPtr; + cl_uint bPixel = *(cl_uint *)bPtr; + if ((aPixel & 0x3fffffff) != (bPixel & 0x3fffffff)) + return column; + } + break; + + // If the data type is 555, ignore bit 15 when comparing the row + case CL_UNORM_SHORT_555: { + cl_ushort aPixel = *(cl_ushort *)aPtr; + cl_ushort bPixel = *(cl_ushort *)bPtr; + if ((aPixel & 0x7fff) != (bPixel & 0x7fff)) return column; + } + break; + + default: + if (memcmp(aPtr, bPtr, pixel_size) != 0) return column; + break; + } + + aPtr += pixel_size; + bPtr += pixel_size; + } + + // If we didn't find a difference, return the width of the image + return column; +} + int random_log_in_range(int minV, int maxV, MTdata d) { double v = log2(((double)genrand_int32(d) / (double)0xffffffff) + 1); diff --git a/test_common/harness/imageHelpers.h b/test_common/harness/imageHelpers.h index 848ec655..e728a939 100644 --- a/test_common/harness/imageHelpers.h +++ b/test_common/harness/imageHelpers.h @@ -139,6 +139,9 @@ void print_first_pixel_difference_error(size_t where, const char *sourcePixel, image_descriptor *imageInfo, size_t y, size_t thirdDim); +size_t compare_scanlines(const image_descriptor *imageInfo, const char *aPtr, + const char *bPtr); + void get_max_sizes(size_t *numberOfSizes, const int maxNumberOfSizes, size_t sizes[][3], size_t maxWidth, size_t maxHeight, size_t maxDepth, size_t maxArraySize, diff --git a/test_conformance/images/clCopyImage/test_copy_generic.cpp b/test_conformance/images/clCopyImage/test_copy_generic.cpp index 026916e8..bd935e7f 100644 --- a/test_conformance/images/clCopyImage/test_copy_generic.cpp +++ b/test_conformance/images/clCopyImage/test_copy_generic.cpp @@ -547,18 +547,19 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d { if( memcmp( sourcePtr, destPtr, scanlineSize ) != 0 ) { - // Find the first missing pixel + // Find the first differing pixel size_t pixel_size = get_pixel_size( dstImageInfo->format ); - size_t where = 0; - for( where = 0; where < dstImageInfo->width; where++ ) - if( memcmp( sourcePtr + pixel_size * where, destPtr + pixel_size * where, pixel_size) ) - break; + size_t where = + compare_scanlines(dstImageInfo, sourcePtr, destPtr); - print_first_pixel_difference_error( - where, sourcePtr + pixel_size * where, - destPtr + pixel_size * where, dstImageInfo, y, - dstImageInfo->depth); - return -1; + if (where < dstImageInfo->width) + { + print_first_pixel_difference_error( + where, sourcePtr + pixel_size * where, + destPtr + pixel_size * where, dstImageInfo, y, + dstImageInfo->depth); + return -1; + } } sourcePtr += rowPitch; if((dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY || dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D)) diff --git a/test_conformance/images/clFillImage/test_fill_generic.cpp b/test_conformance/images/clFillImage/test_fill_generic.cpp index 59bf24ad..6cd6beb0 100644 --- a/test_conformance/images/clFillImage/test_fill_generic.cpp +++ b/test_conformance/images/clFillImage/test_fill_generic.cpp @@ -468,27 +468,19 @@ int test_fill_image_generic( cl_context context, cl_command_queue queue, image_d { for ( size_t y = 0; y < secondDim; y++ ) { - // If the data type is 101010 ignore bits 31 and 32 when comparing the row - if (imageInfo->format->image_channel_data_type == CL_UNORM_INT_101010) { - for (size_t w=0;w!=scanlineSize/4;++w) { - ((cl_uint*)sourcePtr)[w] &= 0x3FFFFFFF; - ((cl_uint*)destPtr)[w] &= 0x3FFFFFFF; - } - } - if (memcmp( sourcePtr, destPtr, scanlineSize ) != 0) { - // Find the first missing pixel + // Find the first differing pixel size_t pixel_size = get_pixel_size( imageInfo->format ); - size_t where = 0; - for ( where = 0; where < imageInfo->width; where++ ) - if ( memcmp( sourcePtr + pixel_size * where, destPtr + pixel_size * where, pixel_size) ) - break; + size_t where = compare_scanlines(imageInfo, sourcePtr, destPtr); - print_first_pixel_difference_error( - where, sourcePtr + pixel_size * where, - destPtr + pixel_size * where, imageInfo, y, thirdDim); - return -1; + if (where < imageInfo->width) + { + print_first_pixel_difference_error( + where, sourcePtr + pixel_size * where, + destPtr + pixel_size * where, imageInfo, y, thirdDim); + return -1; + } } total_matched += scanlineSize;