diff --git a/test_common/harness/imageHelpers.cpp b/test_common/harness/imageHelpers.cpp index 2211924d20..e13404b9a5 100644 --- a/test_common/harness/imageHelpers.cpp +++ b/test_common/harness/imageHelpers.cpp @@ -1128,13 +1128,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> 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 @@ -1143,6 +1145,8 @@ void escape_inf_nan_values(char *data, size_t allocSize) for (size_t i = 0; i> 1; i++) { if ((shortPtr[i] & 0x7C00) == 0x7C00) shortPtr[i] ^= 0x4000; + else if ((shortPtr[i] & 0x7C00) == 0) + shortPtr[i] ^= 0x4000; } } @@ -1221,7 +1225,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; } @@ -1233,7 +1237,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) {