From 2a1217513e1c5d881718c2a7f2afb951e1fe6305 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 22 Jul 2020 12:11:39 -0400 Subject: [PATCH] panfrost: Implement panfrost_query_dmabuf_modifiers v2: Only advertise AFBC if PAN_MESA_DEBUG=afbc is set. This is to avoid sharing AFBC buffers as SCANOUT until corresponding kernel bugfixes are landed. Technically a kernel issue but let's prevent a regression. Signed-off-by: Alyssa Rosenzweig Tested-by: Icecream95 [v1] Part-of: --- src/gallium/drivers/panfrost/pan_screen.c | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index eed910fb3f8..9942ea8e1af 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -59,7 +59,7 @@ static const struct debug_named_value debug_options[] = { {"msgs", PAN_DBG_MSGS, "Print debug messages"}, {"trace", PAN_DBG_TRACE, "Trace the command stream"}, {"deqp", PAN_DBG_DEQP, "Hacks for dEQP"}, - {"afbc", PAN_DBG_AFBC, "Enable non-conformant AFBC impl"}, + {"afbc", PAN_DBG_AFBC, "Enable AFBC buffer sharing"}, {"sync", PAN_DBG_SYNC, "Wait for each job's completion and check for any GPU fault"}, {"precompile", PAN_DBG_PRECOMPILE, "Precompile shaders for shader-db"}, {"nofp16", PAN_DBG_NOFP16, "Disable 16-bit support"}, @@ -485,6 +485,48 @@ panfrost_is_format_supported( struct pipe_screen *screen, return fmt.hw && ((relevant_bind & ~fmt.bind) == 0); } +/* We always support linear and tiled operations, both external and internal. + * We support AFBC for a subset of formats, and colourspace transform for a + * subset of those. */ + +static void +panfrost_query_dmabuf_modifiers(struct pipe_screen *screen, + enum pipe_format format, int max, uint64_t *modifiers, unsigned + int *external_only, int *out_count) +{ + /* Query AFBC status */ + bool afbc = panfrost_format_supports_afbc(format); + bool ytr = panfrost_afbc_can_ytr(format); + + /* Don't advertise AFBC before T760 */ + struct panfrost_device *dev = pan_device(screen); + afbc &= !(dev->quirks & MIDGARD_NO_AFBC); + + /* XXX: AFBC scanout is broken on mainline RK3399 with older kernels */ + afbc &= (dev->debug & PAN_DBG_AFBC); + + unsigned count = 0; + + for (unsigned i = 0; i < PAN_MODIFIER_COUNT; ++i) { + if (drm_is_afbc(pan_best_modifiers[i]) && !afbc) + continue; + + if ((pan_best_modifiers[i] & AFBC_FORMAT_MOD_YTR) && !ytr) + continue; + + count++; + + if (max > (int) count) { + modifiers[count] = pan_best_modifiers[i]; + + if (external_only) + external_only[count] = false; + } + } + + *out_count = count; +} + static int panfrost_get_compute_param(struct pipe_screen *pscreen, enum pipe_shader_ir ir_type, enum pipe_compute_cap param, void *ret) @@ -695,6 +737,7 @@ panfrost_create_screen(int fd, struct renderonly *ro) screen->base.get_paramf = panfrost_get_paramf; screen->base.get_timestamp = panfrost_get_timestamp; screen->base.is_format_supported = panfrost_is_format_supported; + screen->base.query_dmabuf_modifiers = panfrost_query_dmabuf_modifiers; screen->base.context_create = panfrost_create_context; screen->base.get_compiler_options = panfrost_screen_get_compiler_options; screen->base.fence_reference = panfrost_fence_reference; -- 2.30.2