freedreno/a6xx: Fix UBWC mipmapping height alignment.
authorEric Anholt <eric@anholt.net>
Wed, 6 May 2020 21:50:34 +0000 (14:50 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 13 May 2020 19:18:16 +0000 (19:18 +0000)
After fixing the power of two sizing, pitches worked, but 1-pixel high and
unaligned height miplevels were off.

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

src/freedreno/fdl/fd6_layout.c
src/freedreno/fdl/fd6_layout_test.c

index 7b544fb7c6fd672e97bdd370bf36f74bf7e0a89c..137ba42650ee5c8a4522e8be50535e7b1e33a76d 100644 (file)
@@ -133,17 +133,22 @@ fdl6_layout(struct fdl_layout *layout,
 
        uint32_t ubwc_width0 = width0;
        uint32_t ubwc_height0 = height0;
+       uint32_t ubwc_tile_height_alignment = RGB_TILE_HEIGHT_ALIGNMENT;
        if (mip_levels > 1) {
                /* With mipmapping enabled, UBWC layout is power-of-two sized,
-                * specified in log2 width/height in the descriptors.
+                * specified in log2 width/height in the descriptors.  The height
+                * alignment is 64 for mipmapping, but for buffer sharing (always
+                * single level) other participants expect 16.
                 */
                ubwc_width0 = util_next_power_of_two(width0);
                ubwc_height0 = util_next_power_of_two(height0);
+               ubwc_tile_height_alignment = 64;
        }
        ubwc_width0 = align(DIV_ROUND_UP(ubwc_width0, ta->ubwc_blockwidth),
                        RGB_TILE_WIDTH_ALIGNMENT);
-       ubwc_height0 = align(DIV_ROUND_UP(ubwc_height0, ta->ubwc_blockheight),
-                       RGB_TILE_HEIGHT_ALIGNMENT);
+       ubwc_height0 = align(DIV_ROUND_UP(ubwc_height0,
+                                       ta->ubwc_blockheight),
+                       ubwc_tile_height_alignment);
 
        for (uint32_t level = 0; level < mip_levels; level++) {
                uint32_t depth = u_minify(depth0, level);
@@ -207,7 +212,7 @@ fdl6_layout(struct fdl_layout *layout,
                        uint32_t meta_pitch = align(u_minify(ubwc_width0, level),
                                        RGB_TILE_WIDTH_ALIGNMENT);
                        uint32_t meta_height = align(u_minify(ubwc_height0, level),
-                                       RGB_TILE_HEIGHT_ALIGNMENT);
+                                       ubwc_tile_height_alignment);
 
                        ubwc_slice->size0 = align(meta_pitch * meta_height, UBWC_PLANE_SIZE_ALIGNMENT);
                        ubwc_slice->pitch = meta_pitch;
index eac84b910550d8d9723391ab857519a61939fec4..46814b22f1e762b7a5fd2b8478e9c94274767660 100644 (file)
@@ -395,7 +395,6 @@ static const struct testcase testcases[] = {
        /* Pitch fixed in this commit, but offsets broken.  Will be fixed in
         * following commits.
         */
-#if 0
        {
                .format = PIPE_FORMAT_R8G8B8A8_UNORM,
                .layout = {
@@ -432,7 +431,6 @@ static const struct testcase testcases[] = {
                        },
                },
        },
-#endif
        /* UBWC: Height comes from POT-aligned level 0. */
        {
                .format = PIPE_FORMAT_R8G8B8A8_UNORM,
@@ -468,6 +466,134 @@ static const struct testcase testcases[] = {
                        },
                },
        },
+
+       /* UBWC: Get at minimum height of a level across cpps */
+       {
+               .format = PIPE_FORMAT_R16_UINT,
+               .layout = {
+                       .tile_mode = TILE6_3,
+                       .ubwc = true,
+                       .width0 = 16384, .height0 = 1,
+                       .slices = {
+                               { .offset = 0, .pitch = 32768 },
+                               { .offset = 524288, .pitch = 16384 },
+                               { .offset = 786432, .pitch = 8192 },
+                               { .offset = 917504, .pitch = 4096 },
+                               { .offset = 983040, .pitch = 2048 },
+                               { .offset = 1015808, .pitch = 1024 },
+                               { .offset = 1032192, .pitch = 512 },
+                               { .offset = 1040384, .pitch = 256 },
+                               { .offset = 1044480, .pitch = 256 },
+                               { .offset = 1048576, .pitch = 256 },
+                               { .offset = 1052672, .pitch = 256 },
+                               { .offset = 1056768, .pitch = 256 },
+                               { .offset = 1060864, .pitch = 256 },
+                               { .offset = 1064960, .pitch = 256 },
+                               { .offset = 1069056, .pitch = 256 },
+                       },
+                       .ubwc_slices = {
+                               { .offset = 0, .pitch = 1024 },
+                               { .offset = 65536, .pitch = 512 },
+                               { .offset = 98304, .pitch = 256 },
+                               { .offset = 114688, .pitch = 128 },
+                               { .offset = 122880, .pitch = 64 },
+                               { .offset = 126976, .pitch = 64 },
+                               { .offset = 131072, .pitch = 64 },
+                               { .offset = 135168, .pitch = 64 },
+                               { .offset = 139264, .pitch = 64 },
+                               { .offset = 143360, .pitch = 64 },
+                               { .offset = 147456, .pitch = 64 },
+                               { .offset = 151552, .pitch = 64 },
+                               { .offset = 155648, .pitch = 64 },
+                               { .offset = 159744, .pitch = 64 },
+                               { .offset = 163840, .pitch = 64 },
+                       },
+               },
+       },
+       {
+               .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+               .layout = {
+                       .tile_mode = TILE6_3,
+                       .ubwc = true,
+                       .width0 = 16384, .height0 = 1,
+                       .slices = {
+                               { .offset = 0, .pitch = 65536 },
+                               { .offset = 1048576, .pitch = 32768 },
+                               { .offset = 1572864, .pitch = 16384 },
+                               { .offset = 1835008, .pitch = 8192 },
+                               { .offset = 1966080, .pitch = 4096 },
+                               { .offset = 2031616, .pitch = 2048 },
+                               { .offset = 2064384, .pitch = 1024 },
+                               { .offset = 2080768, .pitch = 512 },
+                               { .offset = 2088960, .pitch = 256 },
+                               { .offset = 2093056, .pitch = 256 },
+                               { .offset = 2097152, .pitch = 256 },
+                               { .offset = 2101248, .pitch = 256 },
+                               { .offset = 2105344, .pitch = 256 },
+                               { .offset = 2109440, .pitch = 256 },
+                               { .offset = 2113536, .pitch = 256 },
+                       },
+                       .ubwc_slices = {
+                               { .offset = 0, .pitch = 1024 },
+                               { .offset = 65536, .pitch = 512 },
+                               { .offset = 98304, .pitch = 256 },
+                               { .offset = 114688, .pitch = 128 },
+                               { .offset = 122880, .pitch = 64 },
+                               { .offset = 126976, .pitch = 64 },
+                               { .offset = 131072, .pitch = 64 },
+                               { .offset = 135168, .pitch = 64 },
+                               { .offset = 139264, .pitch = 64 },
+                               { .offset = 143360, .pitch = 64 },
+                               { .offset = 147456, .pitch = 64 },
+                               { .offset = 151552, .pitch = 64 },
+                               { .offset = 155648, .pitch = 64 },
+                               { .offset = 159744, .pitch = 64 },
+                               { .offset = 163840, .pitch = 64 },
+                       },
+               },
+       },
+       {
+               .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
+               .layout = {
+                       .tile_mode = TILE6_3,
+                       .ubwc = true,
+                       .width0 = 16384, .height0 = 1,
+                       .slices = {
+                               { .offset = 0, .pitch = 262144 },
+                               { .offset = 4194304, .pitch = 131072 },
+                               { .offset = 6291456, .pitch = 65536 },
+                               { .offset = 7340032, .pitch = 32768 },
+                               { .offset = 7864320, .pitch = 16384 },
+                               { .offset = 8126464, .pitch = 8192 },
+                               { .offset = 8257536, .pitch = 4096 },
+                               { .offset = 8323072, .pitch = 2048 },
+                               { .offset = 8355840, .pitch = 1024 },
+                               { .offset = 8372224, .pitch = 1024 },
+                               { .offset = 8388608, .pitch = 1024 },
+                               { .offset = 8404992, .pitch = 1024 },
+                               { .offset = 8421376, .pitch = 1024 },
+                               { .offset = 8437760, .pitch = 1024 },
+                               { .offset = 8454144, .pitch = 1024 },
+                       },
+                       .ubwc_slices = {
+                               { .offset = 0, .pitch = 4096 },
+                               { .offset = 262144, .pitch = 2048 },
+                               { .offset = 393216, .pitch = 1024 },
+                               { .offset = 458752, .pitch = 512 },
+                               { .offset = 491520, .pitch = 256 },
+                               { .offset = 507904, .pitch = 128 },
+                               { .offset = 516096, .pitch = 64 },
+                               { .offset = 520192, .pitch = 64 },
+                               { .offset = 524288, .pitch = 64 },
+                               { .offset = 528384, .pitch = 64 },
+                               { .offset = 532480, .pitch = 64 },
+                               { .offset = 536576, .pitch = 64 },
+                               { .offset = 540672, .pitch = 64 },
+                               { .offset = 544768, .pitch = 64 },
+                               { .offset = 548864, .pitch = 64 },
+                       },
+               },
+       },
 };
 
 static bool test_layout(const struct testcase *testcase)