ail: Test mipmapped_z behaviour
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Fri, 3 Feb 2023 23:47:53 +0000 (18:47 -0500)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Feb 2023 07:04:49 +0000 (07:04 +0000)
The mipmapped_z = true case is checked against Metal, the false case is smoke
testing the old behaviour (which is still used for 2D arrays).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21114>

src/asahi/layout/tests/test-layout.cpp

index 44b16c9..9285cda 100644 (file)
@@ -92,3 +92,40 @@ TEST(Miptree, SomeMipLevels)
 
    EXPECT_EQ(layout.size_B, 0x555680);
 }
+
+TEST(Miptree, SmallPartialMiptree2DArray)
+{
+   struct ail_layout layout = {
+      .width_px = 32,
+      .height_px = 16,
+      .depth_px = 64,
+      .sample_count_sa = 1,
+      .levels = 4,
+      .tiling = AIL_TILING_TWIDDLED,
+      .format = PIPE_FORMAT_R32_FLOAT,
+   };
+
+   ail_make_miptree(&layout);
+
+   EXPECT_EQ(layout.layer_stride_B, 0xc00);
+   EXPECT_EQ(layout.size_B, 0x30000);
+}
+
+TEST(Miptree, SmallPartialMiptree3D)
+{
+   struct ail_layout layout = {
+      .width_px = 32,
+      .height_px = 16,
+      .depth_px = 64,
+      .sample_count_sa = 1,
+      .levels = 4,
+      .mipmapped_z = true,
+      .tiling = AIL_TILING_TWIDDLED,
+      .format = PIPE_FORMAT_R32_FLOAT,
+   };
+
+   ail_make_miptree(&layout);
+
+   EXPECT_EQ(layout.layer_stride_B, 0xc80);
+   EXPECT_EQ(layout.size_B, 0x32000);
+}