panfrost: Force strict import rules for AFBC(YUV)

AFBC(YUV) has been introduced after the stricter import rules. Let's
make them strict by default now, so we don't encourage exporters to pass
funky WSI pitch values.

We add a driconf option to allow relaxing this strictness on a per-app
basis.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35762>
This commit is contained in:
Boris Brezillon
2025-06-26 09:51:49 +02:00
parent ec05d4b1fa
commit 53e4f4149b
4 changed files with 24 additions and 1 deletions
@@ -15,4 +15,5 @@ DRI_CONF_SECTION_MISCELLANEOUS
DRI_CONF_PAN_COMPUTE_CORE_MASK(~0ull)
DRI_CONF_PAN_FRAGMENT_CORE_MASK(~0ull)
DRI_CONF_OPT_B(pan_allow_128bit_rts_v4, false, "Allow using 128 bit render-targets on V4")
DRI_CONF_OPT_B(pan_relax_afbc_yuv_imports, false, "Use relaxed import rules for AFBC(YUV)")
DRI_CONF_SECTION_END
@@ -119,6 +119,7 @@ struct panfrost_device {
const struct pan_model *model;
bool has_afbc;
bool has_afrc;
bool relaxed_afbc_yuv_imports;
/* Table of formats, indexed by a PIPE format */
const struct pan_format *formats;
+19 -1
View File
@@ -289,6 +289,24 @@ panfrost_resource_new_label(struct panfrost_resource *rsrc,
return new_label;
}
static bool
strict_import(struct panfrost_device *dev, uint64_t mod,
enum pipe_format format)
{
if (dev->debug & PAN_DBG_STRICT_IMPORT)
return true;
/* AFBC(YUV) has been introduced after the stricter import rules, let's
* make them strict by default. */
if (drm_is_afbc(mod) && pan_format_is_yuv(format) && !dev->relaxed_afbc_yuv_imports)
return true;
/* Linear and u-tiled imports have always been strict. The only ones that
* were lax are AFBC, AFRC and MTK_TILED. Make sure we encourage new
* modifiers to enforce strict rules by default. */
return !(drm_is_afbc(mod) || drm_is_afrc(mod) || drm_is_mtk_tiled(mod));
}
static struct pipe_resource *
panfrost_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *templat,
@@ -320,7 +338,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
struct pan_image_layout_constraints explicit_layout = {
.offset_B = whandle->offset,
.wsi_row_pitch_B = whandle->stride,
.strict = dev->debug & PAN_DBG_STRICT_IMPORT,
.strict = strict_import(dev, mod, templat->format),
};
rsc->modifier = mod;
@@ -984,6 +984,9 @@ panfrost_create_screen(int fd, const struct pipe_screen_config *config,
if (dev->debug & PAN_DBG_NO_AFBC)
dev->has_afbc = false;
dev->relaxed_afbc_yuv_imports =
driQueryOptionb(config->options, "pan_relax_afbc_yuv_imports");
/* Bail early on unsupported hardware */
if (dev->model == NULL) {
debug_printf("panfrost: Unsupported model %X",