From 69895725cfe9d4dc917ff6e643af9e6e3a6e093f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 20:15:17 +0100 Subject: util: Add callback to fetch a single pixel. --- progs/gallium/unit/u_format_test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'progs/gallium') diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index e96f0a9d12..ba4e9fab66 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -33,6 +33,37 @@ #include "util/u_format_tests.h" +static boolean +test_format_fetch_float(const struct util_format_description *format_desc, + const struct util_format_test_case *test) +{ + float unpacked[4]; + unsigned i; + boolean success; + + /* + * TODO: test block formats too. + */ + if (format_desc->block.width != 1 && format_desc->block.height != 1) { + return TRUE; + } + + format_desc->fetch_float(unpacked, test->packed, 0, 0); + + success = TRUE; + for (i = 0; i < 4; ++i) + if (test->unpacked[i] != unpacked[i]) + success = FALSE; + + if (!success) { + printf("FAILED: (%f %f %f %f) obtained\n", unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + printf(" (%f %f %f %f) expected\n", test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]); + } + + return success; +} + + static boolean test_format_unpack_float(const struct util_format_description *format_desc, const struct util_format_test_case *test) @@ -225,6 +256,9 @@ test_all(void) { bool success = TRUE; + if (!test_one(&test_format_fetch_float, "fetch_float")) + success = FALSE; + if (!test_one(&test_format_pack_float, "pack_float")) success = FALSE; -- cgit v1.2.3