llvmpipe: Cover more formats in unit test.

This commit is contained in:
José Fonseca 2010-05-08 13:18:14 +01:00
parent 36e28d42b3
commit 852f735236
1 changed files with 35 additions and 26 deletions

View File

@ -125,7 +125,7 @@ test_format(unsigned verbose, FILE *fp,
fetch_ptr_t fetch_ptr; fetch_ptr_t fetch_ptr;
float unpacked[4]; float unpacked[4];
boolean success; boolean success;
unsigned i; unsigned i, j, k;
fetch = add_fetch_rgba_test(lp_build_module, desc); fetch = add_fetch_rgba_test(lp_build_module, desc);
@ -151,29 +151,37 @@ test_format(unsigned verbose, FILE *fp,
fetch_ptr = (fetch_ptr_t) LLVMGetPointerToGlobal(lp_build_engine, fetch); fetch_ptr = (fetch_ptr_t) LLVMGetPointerToGlobal(lp_build_engine, fetch);
memset(unpacked, 0, sizeof unpacked); for (i = 0; i < desc->block.height; ++i) {
for (j = 0; j < desc->block.width; ++j) {
fetch_ptr(unpacked, test->packed, 0, 0); memset(unpacked, 0, sizeof unpacked);
success = TRUE; fetch_ptr(unpacked, test->packed, j, i);
for(i = 0; i < 4; ++i)
if (fabs((float)test->unpacked[0][0][i] - unpacked[i]) > FLT_EPSILON)
success = FALSE;
if (!success) { success = TRUE;
printf("FAILED\n"); for(k = 0; k < 4; ++k)
printf(" Packed: %02x %02x %02x %02x\n", if (fabs((float)test->unpacked[i][j][k] - unpacked[k]) > FLT_EPSILON)
test->packed[0], test->packed[1], test->packed[2], test->packed[3]); success = FALSE;
printf(" Unpacked: %f %f %f %f obtained\n",
unpacked[0], unpacked[1], unpacked[2], unpacked[3]); if (!success) {
printf(" %f %f %f %f expected\n", printf("FAILED\n");
test->unpacked[0][0][0], printf(" Packed: %02x %02x %02x %02x\n",
test->unpacked[0][0][1], test->packed[0], test->packed[1], test->packed[2], test->packed[3]);
test->unpacked[0][0][2], printf(" Unpacked (%u,%u): %f %f %f %f obtained\n",
test->unpacked[0][0][3]); j, i,
LLVMDumpValue(fetch); unpacked[0], unpacked[1], unpacked[2], unpacked[3]);
printf(" %f %f %f %f expected\n",
test->unpacked[i][j][0],
test->unpacked[i][j][1],
test->unpacked[i][j][2],
test->unpacked[i][j][3]);
}
}
} }
if (!success)
LLVMDumpValue(fetch);
LLVMFreeMachineCodeForFunction(lp_build_engine, fetch); LLVMFreeMachineCodeForFunction(lp_build_engine, fetch);
LLVMDeleteFunction(fetch); LLVMDeleteFunction(fetch);
@ -193,20 +201,23 @@ test_one(unsigned verbose, FILE *fp,
const struct util_format_description *format_desc) const struct util_format_description *format_desc)
{ {
unsigned i; unsigned i;
bool first = TRUE;
bool success = TRUE; bool success = TRUE;
printf("Testing %s ...\n",
format_desc->name);
for (i = 0; i < util_format_nr_test_cases; ++i) { for (i = 0; i < util_format_nr_test_cases; ++i) {
const struct util_format_test_case *test = &util_format_test_cases[i]; const struct util_format_test_case *test = &util_format_test_cases[i];
if (test->format == format_desc->format) { if (test->format == format_desc->format) {
if (first) {
printf("Testing %s ...\n",
format_desc->name);
first = FALSE;
}
if (!test_format(verbose, fp, format_desc, test)) { if (!test_format(verbose, fp, format_desc, test)) {
success = FALSE; success = FALSE;
} }
} }
} }
@ -232,9 +243,7 @@ test_all(unsigned verbose, FILE *fp)
* TODO: test more * TODO: test more
*/ */
if (format_desc->block.width != 1 || if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
format_desc->block.height != 1 ||
format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
continue; continue;
} }