freedreno: add debug helper to dump buffers
[mesa.git] / src / gallium / drivers / freedreno / freedreno_resource.c
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)