freedreno: Rename the UBWC layer size field and store it as bytes.
[mesa.git] / src / freedreno / fdl / freedreno_layout.h
index c17120a8ac686818d98eb8ce9d70c61e3d92cc9b..7230d337a484a741453f05e65d1b393f1e4180ea 100644 (file)
 #ifndef FREEDRENO_LAYOUT_H_
 #define FREEDRENO_LAYOUT_H_
 
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "util/u_debug.h"
+#include "util/u_math.h"
+#include "util/format/u_format.h"
+
 /* Shared freedreno mipmap layout helper
  *
  * It does *not* attempt to track surface transitions, in particular
@@ -68,6 +75,8 @@
  * texture.
  */
 
+#define FDL_MAX_MIP_LEVELS 14
+
 struct fdl_slice {
        uint32_t offset;         /* offset of first layer in slice */
        uint32_t pitch;
@@ -80,8 +89,10 @@ struct fdl_slice {
  * to derive this.
  */
 struct fdl_layout {
-       struct fdl_slice slices[MAX_MIP_LEVELS];
+       struct fdl_slice slices[FDL_MAX_MIP_LEVELS];
+       struct fdl_slice ubwc_slices[FDL_MAX_MIP_LEVELS];
        uint32_t layer_size;
+       uint32_t ubwc_layer_size; /* in bytes */
        bool layer_first : 1;    /* see above description */
 
        /* Note that for tiled textures, beyond a certain mipmap level (ie.
@@ -98,12 +109,10 @@ struct fdl_layout {
        uint8_t cpp;
 
        uint32_t width0, height0, depth0;
+       uint32_t nr_samples;
+       enum pipe_format format;
 
-       /* UBWC specific fields: */
-       uint32_t offset;         /* offset to start of pixel data */
-       uint32_t ubwc_offset;    /* offset to UBWC meta data */
-       uint32_t ubwc_pitch;
-       uint32_t ubwc_size;
+       uint32_t size; /* Size of the whole image, in bytes. */
 };
 
 static inline uint32_t
@@ -119,9 +128,7 @@ static inline uint32_t
 fdl_surface_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
 {
        const struct fdl_slice *slice = &layout->slices[level];
-       unsigned offset = slice->offset;
-       offset += fdl_layer_stride(layout, level) * layer;
-       return offset + layout->offset;
+       return slice->offset + fdl_layer_stride(layout, level) * layer;
 }
 
 static inline uint32_t
@@ -130,11 +137,11 @@ fdl_ubwc_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
        /* for now this doesn't do anything clever, but when UBWC is enabled
         * for multi layer/level images, it will.
         */
-       if (layout->ubwc_size) {
-               debug_assert(level == 0);
-               debug_assert(layer == 0);
+       if (layout->ubwc_layer_size) {
+               assert(level == 0);
+               assert(layer == 0);
        }
-       return layout->ubwc_offset;
+       return layout->ubwc_slices[0].offset;
 }
 
 static inline bool
@@ -158,7 +165,23 @@ fdl_tile_mode(const struct fdl_layout *layout, int level)
 static inline bool
 fdl_ubwc_enabled(const struct fdl_layout *layout, int level)
 {
-       return layout->ubwc_size && fdl_tile_mode(layout, level);
+       return layout->ubwc_layer_size && fdl_tile_mode(layout, level);
 }
 
+void
+fdl_layout_buffer(struct fdl_layout *layout, uint32_t size);
+
+void
+fdl6_layout(struct fdl_layout *layout,
+               enum pipe_format format, uint32_t nr_samples,
+               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);
+
 #endif /* FREEDRENO_LAYOUT_H_ */