From c24c6012936770dc31065fb0009871ae121686e9 Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Thu, 1 Aug 2024 15:50:31 -0700 Subject: [PATCH] Fix bug in mipmap comparison The destination image for mipmap copies is incorrect, use the width of the mip-level instead of mip-level 0. Deletes redundant scanline comparison. --- .../images/clCopyImage/test_copy_generic.cpp | 51 +++++++++++++------ .../images/clFillImage/test_fill_generic.cpp | 17 +++---- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/test_conformance/images/clCopyImage/test_copy_generic.cpp b/test_conformance/images/clCopyImage/test_copy_generic.cpp index 54a156fed9..720e841393 100644 --- a/test_conformance/images/clCopyImage/test_copy_generic.cpp +++ b/test_conformance/images/clCopyImage/test_copy_generic.cpp @@ -620,6 +620,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d size_t thirdDim = 1; size_t secondDim = 1; + size_t firstDim = dstImageInfo->width; + image_descriptor dstMipLevelImageInfo = { 0 }; switch (dstImageInfo->type) { @@ -665,30 +667,47 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d : 1; break; } + firstDim = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; + + dstMipLevelImageInfo.width = firstDim; + dstMipLevelImageInfo.height = secondDim; + dstMipLevelImageInfo.depth = thirdDim; + dstMipLevelImageInfo.rowPitch = mappedRow; + dstMipLevelImageInfo.slicePitch = mappedSlice; + dstMipLevelImageInfo.num_mip_levels = 0; + dstMipLevelImageInfo.format = dstImageInfo->format; + dstMipLevelImageInfo.type = dstImageInfo->type; } + + // Select the correct destinate image. Mipmapped levels are smaller than + // the full image. + image_descriptor *dstComparisonImageInfo = + gTestMipmaps ? &dstMipLevelImageInfo : dstImageInfo; + for( size_t z = 0; z < thirdDim; z++ ) { for( size_t y = 0; y < secondDim; y++ ) { - if( memcmp( sourcePtr, destPtr, scanlineSize ) != 0 ) + // Find the first differing pixel + size_t where = + compare_scanlines(dstComparisonImageInfo, sourcePtr, destPtr); + if (where < dstComparisonImageInfo->width) { - // Find the first differing pixel - size_t pixel_size = get_pixel_size( dstImageInfo->format ); - size_t where = - compare_scanlines(dstImageInfo, sourcePtr, destPtr); - - if (where < dstImageInfo->width) - { - print_first_pixel_difference_error( - where, sourcePtr + pixel_size * where, - destPtr + pixel_size * where, dstImageInfo, y, - dstImageInfo->depth); - return -1; - } + size_t pixel_size = + get_pixel_size(dstComparisonImageInfo->format); + + print_first_pixel_difference_error( + where, sourcePtr + pixel_size * where, + destPtr + pixel_size * where, dstComparisonImageInfo, y, + dstComparisonImageInfo->depth); + return -1; } sourcePtr += rowPitch; - if((dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY || dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D)) - destPtr += mappedSlice; + if ((dstComparisonImageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY + || dstComparisonImageInfo->type == CL_MEM_OBJECT_IMAGE1D)) + destPtr += mappedSlice; else destPtr += mappedRow; } diff --git a/test_conformance/images/clFillImage/test_fill_generic.cpp b/test_conformance/images/clFillImage/test_fill_generic.cpp index ca9a1bfa3a..440ae15fb3 100644 --- a/test_conformance/images/clFillImage/test_fill_generic.cpp +++ b/test_conformance/images/clFillImage/test_fill_generic.cpp @@ -599,19 +599,16 @@ int test_fill_image_generic( cl_context context, cl_command_queue queue, image_d { for ( size_t y = 0; y < secondDim; y++ ) { - if (memcmp( sourcePtr, destPtr, scanlineSize ) != 0) + size_t where = compare_scanlines(imageInfo, sourcePtr, destPtr); + if (where < imageInfo->width) { // Find the first differing pixel - size_t pixel_size = get_pixel_size( imageInfo->format ); - size_t where = compare_scanlines(imageInfo, sourcePtr, destPtr); + size_t pixel_size = get_pixel_size(imageInfo->format); - if (where < imageInfo->width) - { - print_first_pixel_difference_error( - where, sourcePtr + pixel_size * where, - destPtr + pixel_size * where, imageInfo, y, thirdDim); - return -1; - } + print_first_pixel_difference_error( + where, sourcePtr + pixel_size * where, + destPtr + pixel_size * where, imageInfo, y, thirdDim); + return -1; } total_matched += scanlineSize;