aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_gmem.c8
-rw-r--r--src/gallium/drivers/freedreno/a4xx/fd4_gmem.c2
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_gmem.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c1
7 files changed, 24 insertions, 5 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)
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
index 90c8b8bd49f..ff9f4357368 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
@@ -94,7 +94,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
swap = rsc->layout.tile_mode ? WZYX : fd3_pipe2swap(pformat);
if (bin_w) {
- stride = bin_w * rsc->layout.cpp;
+ stride = bin_w << fdl_cpp_shift(&rsc->layout);
if (bases) {
base = bases[i];
@@ -1009,11 +1009,13 @@ fd3_emit_tile_renderprep(struct fd_batch *batch, const struct fd_tile *tile)
OUT_RING(ring, reg);
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
- OUT_RING(ring, A3XX_RB_DEPTH_PITCH(rsc->layout.cpp * gmem->bin_w));
+ OUT_RING(ring, A3XX_RB_DEPTH_PITCH(gmem->bin_w <<
+ fdl_cpp_shift(&rsc->layout)));
if (rsc->stencil) {
OUT_PKT0(ring, REG_A3XX_RB_STENCIL_INFO, 2);
OUT_RING(ring, A3XX_RB_STENCIL_INFO_STENCIL_BASE(gmem->zsbuf_base[1]));
- OUT_RING(ring, A3XX_RB_STENCIL_PITCH(rsc->stencil->layout.cpp * gmem->bin_w));
+ OUT_RING(ring, A3XX_RB_STENCIL_PITCH(gmem->bin_w <<
+ fdl_cpp_shift(&rsc->stencil->layout)));
}
} else {
OUT_RING(ring, 0x00000000);
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c
index 16e2ac0fbad..5f565e08d65 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c
@@ -97,7 +97,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
psurf->u.tex.first_layer);
if (bin_w) {
- stride = bin_w * rsc->layout.cpp;
+ stride = bin_w << fdl_cpp_shift(&rsc->layout);
if (bases) {
base = bases[i];
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c b/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
index c6564669e46..eb8b5404e86 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
@@ -498,7 +498,7 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base,
buf = BLIT_MRT0;
}
- stride = gmem->bin_w * rsc->layout.cpp;
+ stride = gmem->bin_w << fdl_cpp_shift(&rsc->layout);
size = stride * gmem->bin_h;
OUT_PKT4(ring, REG_A5XX_RB_BLIT_FLAG_DST_LO, 4);
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index e7bf3d9ee9b..7c61fb72911 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -886,6 +886,7 @@ fd_resource_layout_init(struct pipe_resource *prsc)
layout->cpp = util_format_get_blocksize(prsc->format);
layout->cpp *= fd_resource_nr_samples(prsc);
+ layout->cpp_shift = ffs(layout->cpp) - 1;
}
/**