From 1102e0bccff2f76af4b062d5b22ff2e13fc7f779 Mon Sep 17 00:00:00 2001 From: joshqti <127994991+joshqti@users.noreply.github.com> Date: Tue, 26 Nov 2024 09:24:35 -0800 Subject: [PATCH] Fix snorm (#2033) When comparing scanlines for SNORM images, take into account that -1.0 can be exactly represented in two different ways. --------- Co-authored-by: Ben Ashbaugh --- test_common/harness/imageHelpers.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test_common/harness/imageHelpers.cpp b/test_common/harness/imageHelpers.cpp index a66a8101..b354baeb 100644 --- a/test_common/harness/imageHelpers.cpp +++ b/test_common/harness/imageHelpers.cpp @@ -490,6 +490,32 @@ size_t compare_scanlines(const image_descriptor *imageInfo, const char *aPtr, } break; + case CL_SNORM_INT8: { + cl_uchar aPixel = *(cl_uchar *)aPtr; + cl_uchar bPixel = *(cl_uchar *)bPtr; + // -1.0 is defined as 0x80 and 0x81 + aPixel = (aPixel == 0x80) ? 0x81 : aPixel; + bPixel = (bPixel == 0x80) ? 0x81 : bPixel; + if (aPixel != bPixel) + { + return column; + } + } + break; + + case CL_SNORM_INT16: { + cl_ushort aPixel = *(cl_ushort *)aPtr; + cl_ushort bPixel = *(cl_ushort *)bPtr; + // -1.0 is defined as 0x8000 and 0x8001 + aPixel = (aPixel == 0x8000) ? 0x8001 : aPixel; + bPixel = (bPixel == 0x8000) ? 0x8001 : bPixel; + if (aPixel != bPixel) + { + return column; + } + } + break; + default: if (memcmp(aPtr, bPtr, pixel_size) != 0) return column; break;