Skip to content

Commit

Permalink
Fix bug in mipmap comparison
Browse files Browse the repository at this point in the history
The destination image for mipmap copies
is incorrect, use the width of the mip-level
instead of mip-level 0.

Deletes redundant scanline comparison.
  • Loading branch information
joshqti committed Aug 1, 2024
1 parent 284f757 commit c24c601
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
51 changes: 35 additions & 16 deletions test_conformance/images/clCopyImage/test_copy_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down
17 changes: 7 additions & 10 deletions test_conformance/images/clFillImage/test_fill_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c24c601

Please sign in to comment.