Mesa (master): freedreno/a5xx: Add the outline of a unit test for a5xx layout.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 22 00:30:03 UTC 2020


Module: Mesa
Branch: master
Commit: 9f62566ef6f8e096b9bbff5bc51e74b9fe44f241
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f62566ef6f8e096b9bbff5bc51e74b9fe44f241

Author: Eric Anholt <eric at anholt.net>
Date:   Tue May 19 15:52:11 2020 -0700

freedreno/a5xx: Add the outline of a unit test for a5xx layout.

Includes a few 3D cases from CTS layouts (since I was looking at CTS
failures) which do justify that a5xx's 3D layout workaround is actually
different from a6xx's.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5127>

---

 src/freedreno/fdl/fd5_layout_test.c | 103 ++++++++++++++++++++++++++++++++++++
 src/freedreno/fdl/fd_layout_test.c  |  32 +++++++----
 src/freedreno/fdl/meson.build       |  47 ++++++++--------
 3 files changed, 149 insertions(+), 33 deletions(-)

diff --git a/src/freedreno/fdl/fd5_layout_test.c b/src/freedreno/fdl/fd5_layout_test.c
new file mode 100644
index 00000000000..71ed259e1fc
--- /dev/null
+++ b/src/freedreno/fdl/fd5_layout_test.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2020 Google LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "freedreno_layout.h"
+#include "fd_layout_test.h"
+#include "adreno_common.xml.h"
+#include "util/u_half.h"
+#include "a5xx.xml.h"
+
+#include <stdio.h>
+
+/* Testcases generated from cffdump --script texturator-to-unit-test-5xx.lua
+ * on a Pixel 2
+ */
+static const struct testcase testcases[] = {
+	/* Basic POT, non-UBWC layout test */
+	{
+		.format = PIPE_FORMAT_R9G9B9E5_FLOAT,
+		.layout = {
+			.tile_mode = TILE5_3,
+			.width0 = 32, .height0 = 32,
+			.slices = {
+				{ .offset = 0, .pitch = 256 },
+				{ .offset = 8192, .pitch = 256 },
+				{ .offset = 12288, .pitch = 256 },
+				{ .offset = 14336, .pitch = 256 },
+				{ .offset = 15360, .pitch = 256 },
+				{ .offset = 15872, .pitch = 256 },
+			},
+		},
+	},
+
+	/* Some 3D cases of sizes from the CTS, when I was suspicious of our 3D
+	 * layout.
+	 */
+	{
+		.format = PIPE_FORMAT_R9G9B9E5_FLOAT,
+		.is_3d = true,
+		.layout = {
+			.tile_mode = TILE5_3,
+			.ubwc = false,
+			.width0 = 59, .height0 = 37, .depth0 = 11,
+			.slices = {
+				{ .offset = 0, .pitch = 256 },
+				{ .offset = 135168, .pitch = 256 },
+				{ .offset = 176128, .pitch = 256 },
+				{ .offset = 192512, .pitch = 256 },
+				{ .offset = 200704, .pitch = 256 },
+				{ .offset = 208896, .pitch = 256 },
+			},
+		},
+	},
+	{
+		.format = PIPE_FORMAT_R32G32_FLOAT,
+		.is_3d = true,
+		.layout = {
+			.tile_mode = TILE5_3,
+			.ubwc = false,
+			.width0 = 63, .height0 = 29, .depth0 = 11,
+			.slices = {
+				{ .offset = 0, .pitch = 512 },
+				{ .offset = 180224, .pitch = 512 },
+				{ .offset = 221184, .pitch = 512 },
+				{ .offset = 237568, .pitch = 512 },
+				{ .offset = 245760, .pitch = 512 },
+				{ .offset = 253952, .pitch = 512 },
+			},
+		},
+	},
+};
+
+int
+main(int argc, char **argv)
+{
+	int ret = 0;
+
+	for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
+		if (!fdl_test_layout(&testcases[i], 540))
+			ret = 1;
+	}
+
+	return ret;
+}
diff --git a/src/freedreno/fdl/fd_layout_test.c b/src/freedreno/fdl/fd_layout_test.c
index 43d16c168bf..f0bdecf9258 100644
--- a/src/freedreno/fdl/fd_layout_test.c
+++ b/src/freedreno/fdl/fd_layout_test.c
@@ -43,16 +43,28 @@ bool fdl_test_layout(const struct testcase *testcase, int gpu_id)
 		max_size = u_minify(max_size, 1);
 	}
 
-	assert(gpu_id >= 600);
-	fdl6_layout(&layout,
-			testcase->format,
-			MAX2(testcase->layout.nr_samples, 1),
-			testcase->layout.width0,
-			MAX2(testcase->layout.height0, 1),
-			MAX2(testcase->layout.depth0, 1),
-			mip_levels,
-			MAX2(testcase->array_size, 1),
-			testcase->is_3d);
+	if (gpu_id >= 600) {
+		fdl6_layout(&layout,
+				testcase->format,
+				MAX2(testcase->layout.nr_samples, 1),
+				testcase->layout.width0,
+				MAX2(testcase->layout.height0, 1),
+				MAX2(testcase->layout.depth0, 1),
+				mip_levels,
+				MAX2(testcase->array_size, 1),
+				testcase->is_3d);
+	} else {
+		assert(gpu_id >= 500);
+		fdl5_layout(&layout,
+				testcase->format,
+				MAX2(testcase->layout.nr_samples, 1),
+				testcase->layout.width0,
+				MAX2(testcase->layout.height0, 1),
+				MAX2(testcase->layout.depth0, 1),
+				mip_levels,
+				MAX2(testcase->array_size, 1),
+				testcase->is_3d);
+	}
 
 	/* fdl lays out UBWC data before the color data, while all we have
 	 * recorded in this testcase are the color offsets (other than the UBWC
diff --git a/src/freedreno/fdl/meson.build b/src/freedreno/fdl/meson.build
index d5b93af9b4f..15eff5b2477 100644
--- a/src/freedreno/fdl/meson.build
+++ b/src/freedreno/fdl/meson.build
@@ -32,26 +32,27 @@ libfreedreno_layout = static_library(
   build_by_default : false,
 )
 
-
-test(
-  'fd6_layout',
-  executable(
-    'fd6_layout',
-    [
-      'fd_layout_test.c',
-      'fd6_layout_test.c',
-      freedreno_xml_header_files,
-    ],
-    link_with: libfreedreno_layout,
-    dependencies : idep_mesautil,
-    include_directories: [
-      inc_include,
-      inc_src,
-      inc_mapi,
-      inc_mesa,
-      inc_gallium,
-      inc_gallium_aux,
-      inc_freedreno],
-  ),
-  suite : ['freedreno'],
-)
+foreach major : ['5', '6']
+  test(
+    'fd' + major + '_layout',
+    executable(
+      'fd' + major + '_layout',
+      [
+        'fd_layout_test.c',
+        'fd' + major + '_layout_test.c',
+        freedreno_xml_header_files,
+      ],
+      link_with: libfreedreno_layout,
+      dependencies : idep_mesautil,
+      include_directories: [
+        inc_include,
+        inc_src,
+        inc_mapi,
+        inc_mesa,
+        inc_gallium,
+        inc_gallium_aux,
+        inc_freedreno],
+    ),
+    suite : ['freedreno'],
+  )
+endforeach



More information about the mesa-commit mailing list