freedreno/fdl: Add base_align
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 27 Mar 2020 11:00:13 +0000 (12:00 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 31 Mar 2020 08:22:58 +0000 (08:22 +0000)
Tell users what the base address of the image needs to be aligned to.
These values are based on experimentation via passing an offset to
vkBindImageMemory with turnip and seeing if tests still pass. Note that
r8g8 is also special in this regard, however it actually has an
increased alignment (in bytes).

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

src/freedreno/fdl/fd6_layout.c
src/freedreno/fdl/freedreno_layout.h

index 661d757..62700ad 100644 (file)
  * missing 96/128 CPP for 8x MSAA with 32_32_32/32_32_32_32
  */
 static const struct {
+       unsigned basealign;
        unsigned pitchalign;
        unsigned heightalign;
        uint8_t ubwc_blockwidth;
        uint8_t ubwc_blockheight;
 } tile_alignment[] = {
-       [1]  = { 128, 32, 16, 4 },
-       [2]  = { 128, 16, 16, 4 },
-       [3]  = {  64, 32 },
-       [4]  = {  64, 16, 16, 4 },
-       [6]  = {  64, 16 },
-       [8]  = {  64, 16, 8, 4, },
-       [12] = {  64, 16 },
-       [16] = {  64, 16, 4, 4, },
-       [24] = {  64, 16 },
-       [32] = {  64, 16, 4, 2 },
-       [48] = {  64, 16 },
-       [64] = {  64, 16 },
+       [1]  = {  64, 128, 32, 16, 4 },
+       [2]  = { 128, 128, 16, 16, 4 },
+       [3]  = { 256,  64, 32 },
+       [4]  = { 256,  64, 16, 16, 4 },
+       [6]  = { 256,  64, 16 },
+       [8]  = { 256,  64, 16, 8, 4, },
+       [12] = { 256,  64, 16 },
+       [16] = { 256,  64, 16, 4, 4, },
+       [24] = { 256,  64, 16 },
+       [32] = { 256,  64, 16, 4, 2 },
+       [48] = { 256,  64, 16 },
+       [64] = { 256,  64, 16 },
 
        /* special cases for r8g8: */
-       [0]  = {  64, 32, 16, 4 },
+       [0]  = { 256, 64, 32, 16, 4 },
 };
 
 #define RGB_TILE_WIDTH_ALIGNMENT 64
@@ -117,6 +118,12 @@ fdl6_layout(struct fdl_layout *layout,
        debug_assert(ta < ARRAY_SIZE(tile_alignment));
        debug_assert(tile_alignment[ta].pitchalign);
 
+       if (layout->tile_mode) {
+               layout->base_align = tile_alignment[ta].basealign;
+       } else {
+               layout->base_align = 64;
+       }
+
        for (uint32_t level = 0; level < mip_levels; level++) {
                struct fdl_slice *slice = &layout->slices[level];
                struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
index f20a305..e9bc3bd 100644 (file)
@@ -114,6 +114,7 @@ struct fdl_layout {
        enum pipe_format format;
 
        uint32_t size; /* Size of the whole image, in bytes. */
+       uint32_t base_align; /* Alignment of the base address, in bytes. */
 };
 
 static inline uint32_t