summaryrefslogtreecommitdiffstats
path: root/src/gallium/tests/unit
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-01-23 14:26:53 -0800
committerEric Anholt <[email protected]>2019-01-25 13:06:50 -0800
commit08f4a904b386f3535719dff4c224ea5cfccc92cd (patch)
treefe37c929c2488ac9857036c7ce49f2f11058c49f /src/gallium/tests/unit
parent104c7883e777b3d5caca98ed96afc3c7c409d340 (diff)
gallium: Make sure we return is_unorm/is_snorm for compressed formats.
The util helpers were looking for a non-void channels in a non-mixed format and returning its snorm/unorm state. However, compressed formats don't have non-void channels, so they always returned false. V3D wants to use util_format_is_[su]norm for its border color clamping workarounds, so fix the functions to return the right answer for these. This now means that we ignore .is_mixed. I could retain the is_mixed check, but it doesn't seem like a useful feature -- the only code I could find that might care is freedreno's blit, which has some notes about how things are wonky in this area anyway. Reviewed-by: <Roland Scheidegger [email protected]>
Diffstat (limited to 'src/gallium/tests/unit')
-rw-r--r--src/gallium/tests/unit/u_format_test.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/gallium/tests/unit/u_format_test.c b/src/gallium/tests/unit/u_format_test.c
index 437cc94b757..640214dfc50 100644
--- a/src/gallium/tests/unit/u_format_test.c
+++ b/src/gallium/tests/unit/u_format_test.c
@@ -668,6 +668,47 @@ test_format_pack_s_8uint(const struct util_format_description *format_desc,
}
+/* Touch-test that the unorm/snorm flags are set up right by codegen. */
+static boolean
+test_format_norm_flags(const struct util_format_description *format_desc)
+{
+ boolean success = TRUE;
+
+#define FORMAT_CASE(format, unorm, snorm) \
+ case format: \
+ success = (format_desc->is_unorm == unorm && \
+ format_desc->is_snorm == snorm); \
+ break
+
+ switch (format_desc->format) {
+ FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_UNORM, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_SRGB, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_SNORM, FALSE, TRUE);
+ FORMAT_CASE(PIPE_FORMAT_R32_FLOAT, FALSE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_X8Z24_UNORM, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_S8X24_UINT, FALSE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_DXT1_RGB, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_ETC2_RGB8, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_ETC2_R11_SNORM, FALSE, TRUE);
+ FORMAT_CASE(PIPE_FORMAT_ASTC_4x4, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_BPTC_RGBA_UNORM, TRUE, FALSE);
+ FORMAT_CASE(PIPE_FORMAT_BPTC_RGB_FLOAT, FALSE, FALSE);
+ default:
+ success = !(format_desc->is_unorm && format_desc->is_snorm);
+ break;
+ }
+#undef FORMAT_CASE
+
+ if (!success) {
+ printf("FAILED: %s (unorm %s, snorm %s)\n",
+ format_desc->short_name,
+ format_desc->is_unorm ? "yes" : "no",
+ format_desc->is_snorm ? "yes" : "no");
+ }
+
+ return success;
+}
+
typedef boolean
(*test_func_t)(const struct util_format_description *format_desc,
const struct util_format_test_case *test);
@@ -698,6 +739,22 @@ test_one_func(const struct util_format_description *format_desc,
return success;
}
+static boolean
+test_format_metadata(const struct util_format_description *format_desc,
+ boolean (*func)(const struct util_format_description *format_desc),
+ const char *suffix)
+{
+ boolean success = TRUE;
+
+ printf("Testing util_format_%s_%s ...\n", format_desc->short_name, suffix);
+ fflush(stdout);
+
+ if (!func(format_desc)) {
+ success = FALSE;
+ }
+
+ return success;
+}
static boolean
test_all(void)
@@ -724,6 +781,11 @@ test_all(void)
} \
}
+# define TEST_FORMAT_METADATA(name) \
+ if (!test_format_metadata(format_desc, &test_format_##name, #name)) { \
+ success = FALSE; \
+ } \
+
TEST_ONE_FUNC(fetch_rgba_float);
TEST_ONE_FUNC(pack_rgba_float);
TEST_ONE_FUNC(unpack_rgba_float);
@@ -737,7 +799,10 @@ test_all(void)
TEST_ONE_FUNC(unpack_s_8uint);
TEST_ONE_FUNC(pack_s_8uint);
+ TEST_FORMAT_METADATA(norm_flags);
+
# undef TEST_ONE_FUNC
+# undef TEST_ONE_FORMAT
}
return success;