aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno/fdl
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2020-04-14 14:35:05 -0700
committerMarge Bot <[email protected]>2020-04-23 16:37:50 +0000
commitbd76a24fd130bb5a45fea72a3041104ccfb4a8d1 (patch)
tree929aa5456cccf666ac9401733115844cd4ecaaed /src/freedreno/fdl
parent6a6e71524dc8d6795c7d6188538c8496f2f4c025 (diff)
freedreno: Introduce a "cpp_shift" value for cpp divs/muls.
This only converts part of the driver to use it, leaving the rest to the following commit (which inspired this one). Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4558>
Diffstat (limited to 'src/freedreno/fdl')
-rw-r--r--src/freedreno/fdl/fd6_layout.c2
-rw-r--r--src/freedreno/fdl/freedreno_layout.c1
-rw-r--r--src/freedreno/fdl/freedreno_layout.h13
3 files changed, 16 insertions, 0 deletions
diff --git a/src/freedreno/fdl/fd6_layout.c b/src/freedreno/fdl/fd6_layout.c
index 3d4efb1d0a8..0f8f14dfc2d 100644
--- a/src/freedreno/fdl/fd6_layout.c
+++ b/src/freedreno/fdl/fd6_layout.c
@@ -93,6 +93,8 @@ fdl6_layout(struct fdl_layout *layout,
layout->cpp = util_format_get_blocksize(format);
layout->cpp *= nr_samples;
+ layout->cpp_shift = ffs(layout->cpp) - 1;
+
layout->format = format;
layout->nr_samples = nr_samples;
layout->layer_first = !is_3d;
diff --git a/src/freedreno/fdl/freedreno_layout.c b/src/freedreno/fdl/freedreno_layout.c
index 57f6388b69a..0c50608ff15 100644
--- a/src/freedreno/fdl/freedreno_layout.c
+++ b/src/freedreno/fdl/freedreno_layout.c
@@ -36,6 +36,7 @@ fdl_layout_buffer(struct fdl_layout *layout, uint32_t size)
layout->height0 = 1;
layout->depth0 = 1;
layout->cpp = 1;
+ layout->cpp_shift = 0;
layout->size = size;
layout->format = PIPE_FORMAT_R8_UINT;
layout->nr_samples = 1;
diff --git a/src/freedreno/fdl/freedreno_layout.h b/src/freedreno/fdl/freedreno_layout.h
index e9bc3bdb371..aa46859a2c3 100644
--- a/src/freedreno/fdl/freedreno_layout.h
+++ b/src/freedreno/fdl/freedreno_layout.h
@@ -109,6 +109,12 @@ struct fdl_layout {
*/
uint8_t cpp;
+ /**
+ * Left shift necessary to multiply by cpp. Invalid for NPOT cpp, please
+ * use fdl_cpp_shift() to sanity check you aren't hitting that case.
+ */
+ uint8_t cpp_shift;
+
uint32_t width0, height0, depth0;
uint32_t nr_samples;
enum pipe_format format;
@@ -118,6 +124,13 @@ struct fdl_layout {
};
static inline uint32_t
+fdl_cpp_shift(const struct fdl_layout *layout)
+{
+ assert(util_is_power_of_two_or_zero(layout->cpp));
+ return layout->cpp_shift;
+}
+
+static inline uint32_t
fdl_layer_stride(const struct fdl_layout *layout, unsigned level)
{
if (layout->layer_first)