summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/tests
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-05-23 05:33:34 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-05-23 05:33:34 +0000
commit9886815a25d84be79f51e65ebd8e458bb5d26ca8 (patch)
treea65edf018dd992543337433f7303fb29a6c8e8cf /lib/mesa/src/gallium/tests
parente2a3acb64af2657b1181806818eacad061103c23 (diff)
Merge Mesa 19.0.5
Diffstat (limited to 'lib/mesa/src/gallium/tests')
-rw-r--r--lib/mesa/src/gallium/tests/trivial/compute.c2
-rw-r--r--lib/mesa/src/gallium/tests/unit/u_format_test.c65
2 files changed, 66 insertions, 1 deletions
diff --git a/lib/mesa/src/gallium/tests/trivial/compute.c b/lib/mesa/src/gallium/tests/trivial/compute.c
index afe5d3e9f..20e5a4f14 100644
--- a/lib/mesa/src/gallium/tests/trivial/compute.c
+++ b/lib/mesa/src/gallium/tests/trivial/compute.c
@@ -240,7 +240,7 @@ static void check_tex(struct context *ctx, int slot,
util_format_get_nblocksy(tex->format, tex->height0));
struct pipe_transfer *xfer;
char *map;
- int x, y, i;
+ int x = 0, y, i;
int err = 0;
if (!check)
diff --git a/lib/mesa/src/gallium/tests/unit/u_format_test.c b/lib/mesa/src/gallium/tests/unit/u_format_test.c
index 437cc94b7..640214dfc 100644
--- a/lib/mesa/src/gallium/tests/unit/u_format_test.c
+++ b/lib/mesa/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;