+ /* To ensure it's 16-byte aligned */
+ memcpy(packed, test->packed, sizeof packed);
+
+ for (i = 0; i < desc->block.height; ++i) {
+ for (j = 0; j < desc->block.width; ++j) {
+ boolean match = TRUE;
+
+ memset(unpacked, 0, sizeof unpacked);
+
+ fetch_ptr(unpacked, packed, j, i, use_cache ? cache_ptr : NULL);
+
+ for(k = 0; k < 4; ++k) {
+ if (util_double_inf_sign(test->unpacked[i][j][k]) != util_inf_sign(unpacked[k])) {
+ match = FALSE;
+ }
+
+ if (util_is_double_nan(test->unpacked[i][j][k]) != util_is_nan(unpacked[k])) {
+ match = FALSE;
+ }
+
+ if (!util_is_double_inf_or_nan(test->unpacked[i][j][k]) &&
+ fabs((float)test->unpacked[i][j][k] - unpacked[k]) > FLT_EPSILON) {
+ match = FALSE;
+ }
+ }
+
+ /* Ignore errors in S3TC for now */
+ if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
+ match = TRUE;
+ }
+
+ if (!match) {
+ printf("FAILED\n");
+ printf(" Packed: %02x %02x %02x %02x\n",
+ test->packed[0], test->packed[1], test->packed[2], test->packed[3]);
+ printf(" Unpacked (%u,%u): %.9g %.9g %.9g %.9g obtained\n",
+ j, i,
+ unpacked[0], unpacked[1], unpacked[2], unpacked[3]);
+ printf(" %.9g %.9g %.9g %.9g expected\n",
+ test->unpacked[i][j][0],
+ test->unpacked[i][j][1],
+ test->unpacked[i][j][2],
+ test->unpacked[i][j][3]);
+ fflush(stdout);
+ success = FALSE;
+ }
+ }
+ }
+ }
+ }