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

Escape subnormal values #1953

Merged
merged 1 commit into from
May 30, 2024
Merged
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
10 changes: 7 additions & 3 deletions test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,13 +1125,15 @@ cl_ulong get_image_size_mb(image_descriptor const *imageInfo)
uint64_t gRoundingStartValue = 0;


void escape_inf_nan_values(char *data, size_t allocSize)
void escape_inf_nan_subnormal_values(char *data, size_t allocSize)
{
// filter values with 8 not-quite-highest bits
unsigned int *intPtr = (unsigned int *)data;
for (size_t i = 0; i<allocSize>> 2; i++)
{
if ((intPtr[i] & 0x7F800000) == 0x7F800000) intPtr[i] ^= 0x40000000;
else if ((intPtr[i] & 0x7F800000) == 0)
intPtr[i] ^= 0x40000000;
}

// Ditto with half floats (16-bit numbers with the 5 not-quite-highest bits
Expand All @@ -1140,6 +1142,8 @@ void escape_inf_nan_values(char *data, size_t allocSize)
for (size_t i = 0; i<allocSize>> 1; i++)
{
if ((shortPtr[i] & 0x7C00) == 0x7C00) shortPtr[i] ^= 0x4000;
else if ((shortPtr[i] & 0x7C00) == 0)
shortPtr[i] ^= 0x4000;
}
}

Expand Down Expand Up @@ -1218,7 +1222,7 @@ char *generate_random_image_data(image_descriptor *imageInfo,

// Note: inf or nan float values would cause problems, although we don't
// know this will actually be a float, so we just know what to look for
escape_inf_nan_values(data, allocSize);
escape_inf_nan_subnormal_values(data, allocSize);
return data;
}

Expand All @@ -1230,7 +1234,7 @@ char *generate_random_image_data(image_descriptor *imageInfo,

// Note: inf or nan float values would cause problems, although we don't
// know this will actually be a float, so we just know what to look for
escape_inf_nan_values(data, allocSize);
escape_inf_nan_subnormal_values(data, allocSize);

if (/*!gTestMipmaps*/ imageInfo->num_mip_levels < 2)
{
Expand Down
Loading