freedreno: Move the layout debug under FD_MESA_DEBUG=layout.
authorEric Anholt <eric@anholt.net>
Thu, 12 Dec 2019 21:48:31 +0000 (13:48 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 4 Feb 2020 23:18:00 +0000 (23:18 +0000)
I keep wanting to turn this on while debugging layout stuff, and I
suspect krh and robclark could use it too.

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

src/freedreno/fdl/fd6_layout.c
src/freedreno/fdl/freedreno_layout.c
src/freedreno/fdl/freedreno_layout.h
src/gallium/drivers/freedreno/a5xx/fd5_resource.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/freedreno_util.h

index 966a3e4bbc423c1cc11f8ab26e9b4e76e10ff55f..6f0a91afcb9d60087ecbefe731976c84d0ffe313 100644 (file)
@@ -78,6 +78,8 @@ fdl6_layout(struct fdl_layout *layout,
 
        layout->cpp = util_format_get_blocksize(format);
        layout->cpp *= nr_samples;
+       layout->format = format;
+       layout->nr_samples = nr_samples;
 
        const struct util_format_description *format_desc =
                util_format_description(format);
@@ -222,28 +224,6 @@ fdl6_layout(struct fdl_layout *layout,
                        layout->slices[level].offset += layout->ubwc_size * array_size;
                layout->size += layout->ubwc_size * array_size;
        }
-
-       if (false) {
-               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];
-                       uint32_t tile_mode = (ubwc ?
-                                       layout->tile_mode : fdl_tile_mode(layout, level));
-
-                       fprintf(stderr, "%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, aligned_height=%3u, offset=0x%x,0x%x tiling=%d\n",
-                                       util_format_name(format),
-                                       u_minify(layout->width0, level),
-                                       u_minify(layout->height0, level),
-                                       u_minify(layout->depth0, level),
-                                       layout->cpp, nr_samples,
-                                       level,
-                                       slice->pitch * layout->cpp,
-                                       slice->size0, ubwc_slice->size0,
-                                       slice->size0 / (slice->pitch * layout->cpp),
-                                       slice->offset, ubwc_slice->offset,
-                                       tile_mode);
-               }
-       }
 }
 
 void
index 6f604333560e136b0f7717f93590b697abcd763a..345b33deb83a7fb97be5c0a815d558e962f744ea 100644 (file)
@@ -37,4 +37,30 @@ fdl_layout_buffer(struct fdl_layout *layout, uint32_t size)
        layout->depth0 = 1;
        layout->cpp = 1;
        layout->size = size;
+       layout->format = PIPE_FORMAT_R8_UINT;
+       layout->nr_samples = 1;
+}
+
+void
+fdl_dump_layout(struct fdl_layout *layout)
+{
+       for (uint32_t level = 0; level < layout->slices[level].size0; level++) {
+               struct fdl_slice *slice = &layout->slices[level];
+               struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
+               uint32_t tile_mode = (layout->ubwc_size ?
+                               layout->tile_mode : fdl_tile_mode(layout, level));
+
+               fprintf(stderr, "%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, aligned_height=%3u, offset=0x%x,0x%x tiling=%d\n",
+                               util_format_name(layout->format),
+                               u_minify(layout->width0, level),
+                               u_minify(layout->height0, level),
+                               u_minify(layout->depth0, level),
+                               layout->cpp, layout->nr_samples,
+                               level,
+                               slice->pitch * layout->cpp,
+                               slice->size0, ubwc_slice->size0,
+                               slice->size0 / (slice->pitch * layout->cpp),
+                               slice->offset, ubwc_slice->offset,
+                               tile_mode);
+       }
 }
index 54f7d3720d39a890a237179ea56609e20667fe16..e7dbc057df7daddfe9cb939d40e2f0805a9464e3 100644 (file)
@@ -108,6 +108,8 @@ struct fdl_layout {
        uint8_t cpp;
 
        uint32_t width0, height0, depth0;
+       uint32_t nr_samples;
+       enum pipe_format format;
 
        uint32_t size; /* Size of the whole image, in bytes. */
 
@@ -176,6 +178,9 @@ fdl6_layout(struct fdl_layout *layout,
                uint32_t width0, uint32_t height0, uint32_t depth0,
                uint32_t mip_levels, uint32_t array_size, bool is_3d, bool ubwc);
 
+void
+fdl_dump_layout(struct fdl_layout *layout);
+
 void
 fdl6_get_ubwc_blockwidth(struct fdl_layout *layout,
                uint32_t *blockwidth, uint32_t *blockheight);
index 0d356286eb55badd8ac3b6c8888f75c386b9848d..3fe730a99c84f0c9e2bdaeca13f63a15cae850ac 100644 (file)
@@ -108,15 +108,6 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
                else
                        slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
 
-#if 0
-               debug_printf("%s: %ux%ux%u@%u: %2u: stride=%4u, size=%7u, aligned_height=%3u\n",
-                               util_format_name(prsc->format),
-                               prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp,
-                               level, slice->pitch * rsc->layout.cpp,
-                               slice->size0 * depth * layers_in_level,
-                               aligned_height);
-#endif
-
                size += slice->size0 * depth * layers_in_level;
 
                width = u_minify(width, 1);
index 2e15bbadea11d0f020f9ab94b9fc4403c2b22477..4eced1fb1fbe3738c6ca52d081e7cce27f8f97dd 100644 (file)
@@ -1003,6 +1003,9 @@ fd_resource_create_with_modifiers(struct pipe_screen *pscreen,
                size = rsc->layout.layer_size * prsc->array_size;
        }
 
+       if (fd_mesa_debug & FD_DBG_LAYOUT)
+               fdl_dump_layout(&rsc->layout);
+
        realloc_bo(rsc, size);
        if (!rsc->bo)
                goto fail;
index 5c0feb9e0f6059e0fe62a09d26a83f58a34bfc06..3c0ed69a9cb13a0ad48bd49ca31f9092fbb14708 100644 (file)
@@ -91,6 +91,7 @@ static const struct debug_named_value debug_options[] = {
                {"noubwc",    FD_DBG_NOUBWC, "Disable UBWC for all internal buffers"},
                {"nolrz",     FD_DBG_NOLRZ,  "Disable LRZ (a6xx)"},
                {"notile",    FD_DBG_NOTILE, "Disable tiling for all internal buffers"},
+               {"layout",    FD_DBG_LAYOUT, "Dump resource layouts"},
                DEBUG_NAMED_VALUE_END
 };
 
index 33b38472d69d51920febdf1601c6d7daedbc563a..a83056d89d0faf87a05a7b2a20fdba2c39da32f3 100644 (file)
@@ -88,6 +88,8 @@ enum fd_debug_flag {
        FD_DBG_NOUBWC       = BITFIELD_BIT(23),
        FD_DBG_NOLRZ        = BITFIELD_BIT(24),
        FD_DBG_NOTILE       = BITFIELD_BIT(25),
+       FD_DBG_LAYOUT       = BITFIELD_BIT(26),
+
 };
 
 extern int fd_mesa_debug;