broadcom/common: add some common v71 helpers
authorAlejandro Piñeiro <apinheiro@igalia.com>
Wed, 17 Nov 2021 13:40:47 +0000 (14:40 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 13 Oct 2023 22:37:41 +0000 (22:37 +0000)
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25450>

src/broadcom/common/v3d_util.c
src/broadcom/common/v3d_util.h

index 57872a9..26f5c6b 100644 (file)
@@ -170,3 +170,30 @@ v3d_hw_prim_type(enum mesa_prim prim_type)
       unreachable("Unsupported primitive type");
    }
 }
+
+uint32_t
+v3d_internal_bpp_words(uint32_t internal_bpp)
+{
+        switch (internal_bpp) {
+        case 0 /* V3D_INTERNAL_BPP_32 */:
+                return 1;
+        case 1 /* V3D_INTERNAL_BPP_64 */:
+                return 2;
+        case 2 /* V3D_INTERNAL_BPP_128 */:
+                return 4;
+        default:
+                unreachable("Unsupported internal BPP");
+        }
+}
+
+uint32_t
+v3d_compute_rt_row_row_stride_128_bits(uint32_t tile_width,
+                                       uint32_t bpp)
+{
+        /* stride in multiples of 128 bits, and covers 2 rows. This is the
+         * reason we divide by 2 instead of 4, as we divide number of 32-bit
+         * words per row by 2.
+         */
+
+        return (tile_width * bpp) / 2;
+}
index a15e474..f619706 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef V3D_UTIL_H
 #define V3D_UTIL_H
 
+#include "util/macros.h"
 #include "common/v3d_device_info.h"
 #include "compiler/shader_enums.h"
 #include "util/format/u_formats.h"
@@ -47,4 +48,30 @@ v3d_translate_pipe_swizzle(enum pipe_swizzle swizzle);
 uint32_t
 v3d_hw_prim_type(enum mesa_prim prim_type);
 
+uint32_t
+v3d_internal_bpp_words(uint32_t internal_bpp);
+
+/* Some configuration packets want the size on log2, but starting at 0 for
+ * size 8.
+ */
+static inline uint8_t
+log2_tile_size(uint32_t size)
+{
+        switch(size) {
+        case 8:
+                return 0;
+        case 16:
+                return 1;
+        case 32:
+                return 2;
+        case 64:
+                return 3;
+        default:
+                unreachable("Unsupported tile width/height");
+        }
+}
+
+uint32_t
+v3d_compute_rt_row_row_stride_128_bits(uint32_t tile_width,
+                                       uint32_t bpp);
 #endif