Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix snorm #2033

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,28 @@ 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
if ((aPixel != bPixel) && ((aPixel | bPixel) != 0x81))
Comment on lines +490 to +491
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit too clever, since as-written it will pass the test if aPixel is 0x81 and bPixel is 0, for example.

Maybe it'd be better to just pick one of the -1.0 representations instead, something like:

Suggested change
// -1.0 is defined as 0x80 and 0x81
if ((aPixel != bPixel) && ((aPixel | bPixel) != 0x81))
// -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
if ((aPixel != bPixel) && ((aPixel | bPixel) != 0x8001))
Comment on lines +501 to +502
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, and apply whatever fix we make for CL_SNORM_INT8 to CL_SNORM_INT16 here.

{
return column;
}
}
break;

default:
if (memcmp(aPtr, bPtr, pixel_size) != 0) return column;
break;
Expand Down
Loading