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>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -117,6 +123,13 @@ struct fdl_layout {
|
||||
uint32_t base_align; /* Alignment of the base address, in bytes. */
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user