summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-03-31 20:15:17 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-03-31 20:15:17 +0100
commit69895725cfe9d4dc917ff6e643af9e6e3a6e093f (patch)
tree2c7f8cfad70a7d6063650e9dfe8f3e2b98359588 /progs
parent3200e708582f75b3566a85228de9a698edbfb022 (diff)
util: Add callback to fetch a single pixel.
Diffstat (limited to 'progs')
-rw-r--r--progs/gallium/unit/u_format_test.c34
1 files changed, 34 insertions, 0 deletions
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
@@ -34,6 +34,37 @@
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;