freedreno: add debug helper to dump buffers
authorRob Clark <robdclark@chromium.org>
Fri, 21 Aug 2020 19:50:34 +0000 (12:50 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Aug 2020 20:15:23 +0000 (20:15 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6434>

src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_resource.h

index 45bff983bdcbbdd8eaea1245585df05ed4c29eff..ed7daaaf63a84f1583c5d52050f7ad7f0061bfe9 100644 (file)
@@ -34,6 +34,8 @@
 #include "util/set.h"
 #include "util/u_drm.h"
 
+#include "decode/util.h"
+
 #include "freedreno_resource.h"
 #include "freedreno_batch_cache.h"
 #include "freedreno_blitter.h"
@@ -392,6 +394,17 @@ fd_resource_uncompress(struct fd_context *ctx, struct fd_resource *rsc)
        debug_assert(success);
 }
 
+/**
+ * Debug helper to hexdump a resource.
+ */
+void
+fd_resource_dump(struct fd_resource *rsc, const char *name)
+{
+       fd_bo_cpu_prep(rsc->bo, NULL, DRM_FREEDRENO_PREP_READ);
+       printf("%s: \n", name);
+       dump_hex(fd_bo_map(rsc->bo), fd_bo_size(rsc->bo));
+}
+
 static struct fd_resource *
 fd_alloc_staging(struct fd_context *ctx, struct fd_resource *rsc,
                unsigned level, const struct pipe_box *box)
index f2382d75be222b0c8e02058a883337dc879bfb03..a88f6cd45addfe652bb69522b695137f84f3d066 100644 (file)
@@ -272,6 +272,7 @@ void fd_resource_context_init(struct pipe_context *pctx);
 uint32_t fd_setup_slices(struct fd_resource *rsc);
 void fd_resource_resize(struct pipe_resource *prsc, uint32_t sz);
 void fd_resource_uncompress(struct fd_context *ctx, struct fd_resource *rsc);
+void fd_resource_dump(struct fd_resource *rsc, const char *name);
 
 bool fd_render_condition_check(struct pipe_context *pctx);