freedreno: add debug helper to dump buffers
[mesa.git] / src / gallium / drivers / freedreno / freedreno_resource.h
index f71cd6a86172a39c6220abbdaf7f4db40e7996ce..a88f6cd45addfe652bb69522b695137f84f3d066 100644 (file)
 #include "freedreno_util.h"
 #include "freedreno/fdl/freedreno_layout.h"
 
+enum fd_lrz_direction {
+       FD_LRZ_UNKNOWN,
+       /* Depth func less/less-than: */
+       FD_LRZ_LESS,
+       /* Depth func greater/greater-than: */
+       FD_LRZ_GREATER,
+};
+
 struct fd_resource {
        struct pipe_resource base;
        struct fd_bo *bo;
@@ -86,12 +94,18 @@ struct fd_resource {
         * fdl_layout
         */
        bool lrz_valid : 1;
+       enum fd_lrz_direction lrz_direction : 2;
        uint16_t lrz_width;  // for lrz clear, does this differ from lrz_pitch?
        uint16_t lrz_height;
        uint16_t lrz_pitch;
        struct fd_bo *lrz;
 };
 
+struct fd_memory_object {
+       struct pipe_memory_object b;
+       struct fd_bo *bo;
+};
+
 static inline struct fd_resource *
 fd_resource(struct pipe_resource *ptex)
 {
@@ -104,6 +118,12 @@ fd_resource_const(const struct pipe_resource *ptex)
        return (const struct fd_resource *)ptex;
 }
 
+static inline struct fd_memory_object *
+fd_memory_object (struct pipe_memory_object *pmemobj)
+{
+       return (struct fd_memory_object *)pmemobj;
+}
+
 static inline bool
 pending(struct fd_resource *rsc, bool write)
 {
@@ -188,6 +208,16 @@ fd_resource_layer_stride(struct fd_resource *rsc, unsigned level)
        return fdl_layer_stride(&rsc->layout, level);
 }
 
+/* get pitch (in bytes) for specified mipmap level */
+static inline uint32_t
+fd_resource_pitch(struct fd_resource *rsc, unsigned level)
+{
+       if (is_a2xx(fd_screen(rsc->base.screen)))
+               return fdl2_pitch(&rsc->layout, level);
+
+       return fdl_pitch(&rsc->layout, level);
+}
+
 /* get offset for specified mipmap level and texture/array layer */
 static inline uint32_t
 fd_resource_offset(struct fd_resource *rsc, unsigned level, unsigned layer)
@@ -242,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);