diff --git a/src/gallium/drivers/panfrost/driinfo_panfrost.h b/src/gallium/drivers/panfrost/driinfo_panfrost.h index c6147d3da4b..58723993916 100644 --- a/src/gallium/drivers/panfrost/driinfo_panfrost.h +++ b/src/gallium/drivers/panfrost/driinfo_panfrost.h @@ -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 diff --git a/src/gallium/drivers/panfrost/pan_device.h b/src/gallium/drivers/panfrost/pan_device.h index f1641673e9d..949b7689886 100644 --- a/src/gallium/drivers/panfrost/pan_device.h +++ b/src/gallium/drivers/panfrost/pan_device.h @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 53a2e8a17f1..792bec7c625 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index a97e8045864..2b037fe9114 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -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",