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;
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;
*/
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;
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)
{
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];
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);
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];
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);
layout->cpp = util_format_get_blocksize(prsc->format);
layout->cpp *= fd_resource_nr_samples(prsc);
+ layout->cpp_shift = ffs(layout->cpp) - 1;
}
/**