freedreno/fdl: Separate the list of a6xx testcases from the the test code.
authorEric Anholt <eric@anholt.net>
Tue, 19 May 2020 22:45:05 +0000 (15:45 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 22 May 2020 00:09:42 +0000 (17:09 -0700)
I'll be reusing the test code for a5xx.

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

src/freedreno/fdl/fd6_layout_test.c
src/freedreno/fdl/fd_layout_test.c [new file with mode: 0644]
src/freedreno/fdl/fd_layout_test.h [new file with mode: 0644]
src/freedreno/fdl/meson.build

index 46814b22f1e762b7a5fd2b8478e9c94274767660..c5b693a931d47215dab2d7d4c53093c3205737be 100644 (file)
  */
 
 #include "freedreno_layout.h"
+#include "fd_layout_test.h"
 #include "adreno_common.xml.h"
 #include "a6xx.xml.h"
 
 #include <stdio.h>
 
-struct testcase {
-       enum pipe_format format;
-
-       int array_size; /* Size for array textures, or 0 otherwise. */
-       bool is_3d;
-
-    /* Partially filled layout of input parameters and expected results. */
-       struct fdl_layout layout;
-};
-
 static const struct testcase testcases[] = {
        /* A straightforward first testcase, linear, with an obvious format. */
        {
@@ -596,95 +587,13 @@ static const struct testcase testcases[] = {
        },
 };
 
-static bool test_layout(const struct testcase *testcase)
-{
-       struct fdl_layout layout = {
-               .ubwc = testcase->layout.ubwc,
-               .tile_mode = testcase->layout.tile_mode,
-       };
-       bool ok = true;
-
-       int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);
-       int mip_levels = 1;
-       while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {
-               mip_levels++;
-               max_size = u_minify(max_size, 1);
-       }
-
-       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);
-
-       /* 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
-        * buffer sharing test).  Shift the fdl layout down so we can compare
-        * color offsets.
-        */
-       if (layout.ubwc && !testcase->layout.slices[0].offset) {
-               for (int l = 1; l < mip_levels; l++)
-                       layout.slices[l].offset -= layout.slices[0].offset;
-               layout.slices[0].offset = 0;
-       }
-
-       for (int l = 0; l < mip_levels; l++) {
-               if (layout.slices[l].offset != testcase->layout.slices[l].offset) {
-                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
-                                       util_format_short_name(testcase->format),
-                                       layout.width0, layout.height0, layout.depth0,
-                                       layout.nr_samples, l,
-                                       layout.slices[l].offset,
-                                       testcase->layout.slices[l].offset);
-                       ok = false;
-               }
-               if (layout.slices[l].pitch != testcase->layout.slices[l].pitch) {
-                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
-                                       util_format_short_name(testcase->format),
-                                       layout.width0, layout.height0, layout.depth0,
-                                       layout.nr_samples, l,
-                                       layout.slices[l].pitch,
-                                       testcase->layout.slices[l].pitch);
-                       ok = false;
-               }
-
-               if (layout.ubwc_slices[l].offset != testcase->layout.ubwc_slices[l].offset) {
-                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
-                                       util_format_short_name(testcase->format),
-                                       layout.width0, layout.height0, layout.depth0,
-                                       layout.nr_samples, l,
-                                       layout.ubwc_slices[l].offset,
-                                       testcase->layout.ubwc_slices[l].offset);
-                       ok = false;
-               }
-               if (layout.ubwc_slices[l].pitch != testcase->layout.ubwc_slices[l].pitch) {
-                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
-                                       util_format_short_name(testcase->format),
-                                       layout.width0, layout.height0, layout.depth0,
-                                       layout.nr_samples, l,
-                                       layout.ubwc_slices[l].pitch,
-                                       testcase->layout.ubwc_slices[l].pitch);
-                       ok = false;
-               }
-       }
-
-       if (!ok)
-               fprintf(stderr, "\n");
-
-       return ok;
-}
-
 int
 main(int argc, char **argv)
 {
        int ret = 0;
 
        for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
-               if (!test_layout(&testcases[i]))
+               if (!fdl_test_layout(&testcases[i], 630))
                        ret = 1;
        }
 
diff --git a/src/freedreno/fdl/fd_layout_test.c b/src/freedreno/fdl/fd_layout_test.c
new file mode 100644 (file)
index 0000000..43d16c1
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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 "a6xx.xml.h"
+
+#include <stdio.h>
+
+bool fdl_test_layout(const struct testcase *testcase, int gpu_id)
+{
+       struct fdl_layout layout = {
+               .ubwc = testcase->layout.ubwc,
+               .tile_mode = testcase->layout.tile_mode,
+       };
+       bool ok = true;
+
+       int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);
+       int mip_levels = 1;
+       while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {
+               mip_levels++;
+               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);
+
+       /* 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
+        * buffer sharing test).  Shift the fdl layout down so we can compare
+        * color offsets.
+        */
+       if (layout.ubwc && !testcase->layout.slices[0].offset) {
+               for (int l = 1; l < mip_levels; l++)
+                       layout.slices[l].offset -= layout.slices[0].offset;
+               layout.slices[0].offset = 0;
+       }
+
+       for (int l = 0; l < mip_levels; l++) {
+               if (layout.slices[l].offset != testcase->layout.slices[l].offset) {
+                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
+                                       util_format_short_name(testcase->format),
+                                       layout.width0, layout.height0, layout.depth0,
+                                       layout.nr_samples, l,
+                                       layout.slices[l].offset,
+                                       testcase->layout.slices[l].offset);
+                       ok = false;
+               }
+               if (layout.slices[l].pitch != testcase->layout.slices[l].pitch) {
+                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
+                                       util_format_short_name(testcase->format),
+                                       layout.width0, layout.height0, layout.depth0,
+                                       layout.nr_samples, l,
+                                       layout.slices[l].pitch,
+                                       testcase->layout.slices[l].pitch);
+                       ok = false;
+               }
+
+               if (layout.ubwc_slices[l].offset != testcase->layout.ubwc_slices[l].offset) {
+                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
+                                       util_format_short_name(testcase->format),
+                                       layout.width0, layout.height0, layout.depth0,
+                                       layout.nr_samples, l,
+                                       layout.ubwc_slices[l].offset,
+                                       testcase->layout.ubwc_slices[l].offset);
+                       ok = false;
+               }
+               if (layout.ubwc_slices[l].pitch != testcase->layout.ubwc_slices[l].pitch) {
+                       fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
+                                       util_format_short_name(testcase->format),
+                                       layout.width0, layout.height0, layout.depth0,
+                                       layout.nr_samples, l,
+                                       layout.ubwc_slices[l].pitch,
+                                       testcase->layout.ubwc_slices[l].pitch);
+                       ok = false;
+               }
+       }
+
+       if (!ok)
+               fprintf(stderr, "\n");
+
+       return ok;
+}
diff --git a/src/freedreno/fdl/fd_layout_test.h b/src/freedreno/fdl/fd_layout_test.h
new file mode 100644 (file)
index 0000000..0be7a40
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+struct testcase {
+       enum pipe_format format;
+
+       int array_size; /* Size for array textures, or 0 otherwise. */
+       bool is_3d;
+
+    /* Partially filled layout of input parameters and expected results. */
+       struct fdl_layout layout;
+};
+
+bool fdl_test_layout(const struct testcase *testcase, int gpu_id);
index 6ed83b50172d66813007b9a6405a40d0036c2319..d5b93af9b4f387fcb7d55bf984519e9c9aa6beb6 100644 (file)
@@ -38,6 +38,7 @@ test(
   executable(
     'fd6_layout',
     [
+      'fd_layout_test.c',
       'fd6_layout_test.c',
       freedreno_xml_header_files,
     ],