panfrost: Move panfrost_is_yuv() to pan_format.h

This way we can do the test outside pan_texture.c.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Constantine Shablya <constantine.shablya@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26698>
This commit is contained in:
Boris Brezillon
2023-12-05 18:53:26 +01:00
committed by Marge Bot
parent fba7f38fda
commit 897733c55d
2 changed files with 22 additions and 25 deletions
+10
View File
@@ -189,6 +189,16 @@ struct pan_decomposed_swizzle
#endif
static inline bool panfrost_format_is_yuv(enum pipe_format f)
{
enum util_format_layout layout = util_format_description(f)->layout;
/* Mesa's subsampled RGB formats are considered YUV formats on Mali */
return layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED ||
layout == UTIL_FORMAT_LAYOUT_PLANAR2 ||
layout == UTIL_FORMAT_LAYOUT_PLANAR3;
}
#ifdef PAN_ARCH
static inline const struct panfrost_format *
GENX(panfrost_format_from_pipe_format)(enum pipe_format f)
+12 -25
View File
@@ -165,15 +165,6 @@ panfrost_texture_num_elements(unsigned first_level, unsigned last_level,
return levels * layers * faces * MAX2(nr_samples, 1);
}
static bool
panfrost_is_yuv(enum util_format_layout layout)
{
/* Mesa's subsampled RGB formats are considered YUV formats on Mali */
return layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED ||
layout == UTIL_FORMAT_LAYOUT_PLANAR2 ||
layout == UTIL_FORMAT_LAYOUT_PLANAR3;
}
/* Conservative estimate of the size of the texture payload a priori.
* Average case, size equal to the actual size. Worst case, off by 2x (if
* a manual stride is not needed on a linear texture). Returned value
@@ -186,17 +177,13 @@ GENX(panfrost_estimate_texture_payload_size)(const struct pan_image_view *iview)
size_t element_size;
#if PAN_ARCH >= 9
enum util_format_layout layout =
util_format_description(iview->format)->layout;
element_size = pan_size(PLANE);
/* 2-plane and 3-plane YUV use two plane descriptors. */
if (panfrost_is_yuv(layout) && iview->planes[1] != NULL)
if (panfrost_format_is_yuv(iview->format) && iview->planes[1] != NULL)
element_size *= 2;
#elif PAN_ARCH == 7
enum util_format_layout layout =
util_format_description(iview->format)->layout;
if (panfrost_is_yuv(layout))
if (panfrost_format_is_yuv(iview->format))
element_size = pan_size(MULTIPLANAR_SURFACE);
else
element_size = pan_size(SURFACE_WITH_STRIDE);
@@ -397,7 +384,7 @@ panfrost_clump_format(enum pipe_format format)
assert(!util_format_is_compressed(format));
/* YUV-sampling has special cases */
if (panfrost_is_yuv(util_format_description(format)->layout)) {
if (panfrost_format_is_yuv(format)) {
switch (format) {
case PIPE_FORMAT_R8G8_R8B8_UNORM:
case PIPE_FORMAT_G8R8_B8R8_UNORM:
@@ -476,7 +463,7 @@ panfrost_emit_plane(const struct pan_image_layout *layout,
if (is_3_planar_yuv) {
cfg.two_plane_yuv_chroma.secondary_pointer = plane2_ptr;
} else if (!panfrost_is_yuv(desc->layout)) {
} else if (!panfrost_format_is_yuv(layout->format)) {
cfg.slice_stride = layout->nr_samples
? surface_stride
: panfrost_get_layer_stride(layout, level);
@@ -583,7 +570,7 @@ panfrost_emit_surface(const struct pan_image_view *iview, unsigned level,
}
#if PAN_ARCH >= 9
if (panfrost_is_yuv(desc->layout)) {
if (panfrost_format_is_yuv(format)) {
for (int i = 0; i < MAX_IMAGE_PLANES; i++) {
/* 3-plane YUV is submitted using two PLANE descriptors, where the
* second one is of type CHROMA_2P */
@@ -609,7 +596,7 @@ panfrost_emit_surface(const struct pan_image_view *iview, unsigned level,
#if PAN_ARCH <= 7
#if PAN_ARCH == 7
if (panfrost_is_yuv(desc->layout)) {
if (panfrost_format_is_yuv(format)) {
panfrost_emit_multiplanar_surface(plane_ptrs, row_strides, payload);
return;
}
@@ -688,9 +675,6 @@ GENX(panfrost_new_texture)(const struct panfrost_device *dev,
uint32_t mali_format = GENX(panfrost_format_from_pipe_format)(format)->hw;
unsigned char swizzle[4];
ASSERTED const struct util_format_description *desc =
util_format_description(format);
if (PAN_ARCH >= 7 && util_format_is_depth_or_stencil(format)) {
/* v7+ doesn't have an _RRRR component order, combine the
* user swizzle with a .XXXX swizzle to emulate that.
@@ -703,7 +687,7 @@ GENX(panfrost_new_texture)(const struct panfrost_device *dev,
};
util_format_compose_swizzles(replicate_x, iview->swizzle, swizzle);
} else if (PAN_ARCH == 7 && !panfrost_is_yuv(desc->layout)) {
} else if (PAN_ARCH == 7 && !panfrost_format_is_yuv(format)) {
#if PAN_ARCH == 7
/* v7 (only) restricts component orders when AFBC is in use.
* Rather than restrict AFBC, we use an allowed component order
@@ -725,7 +709,10 @@ GENX(panfrost_new_texture)(const struct panfrost_device *dev,
}
if ((dev->debug & PAN_DBG_YUV) && PAN_ARCH == 7 &&
panfrost_is_yuv(desc->layout)) {
panfrost_format_is_yuv(format)) {
const struct util_format_description *desc =
util_format_description(format);
if (desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
swizzle[2] = PIPE_SWIZZLE_1;
} else if (desc->layout == UTIL_FORMAT_LAYOUT_PLANAR2) {
@@ -745,7 +732,7 @@ GENX(panfrost_new_texture)(const struct panfrost_device *dev,
}
/* Multiplanar YUV textures require 2 surface descriptors. */
if (panfrost_is_yuv(desc->layout) && PAN_ARCH >= 9 &&
if (panfrost_format_is_yuv(iview->format) && PAN_ARCH >= 9 &&
pan_image_view_get_plane(iview, 1) != NULL)
array_size *= 2;