From 5e379acd31449fddc54554881e31caaf8aa07c38 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 24 Nov 2022 21:30:33 -0500 Subject: [PATCH] asahi: Enable framebuffer compression At 4K, glmark2 -bdesktop from 60fps to 86fps. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 37 ++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index f798efd..58bccc0 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -370,8 +370,41 @@ agx_twiddled_allowed(const struct agx_resource *pres) static bool agx_compression_allowed(const struct agx_resource *pres) { - /* At this point in the series, compression isn't fully plumbed in */ - return false; + /* Allow disabling compression for debugging */ + if (agx_device(pres->base.screen)->debug & AGX_DBG_NOCOMPRESS) + return false; + + /* Limited to renderable */ + if (pres->base.bind & ~(PIPE_BIND_SAMPLER_VIEW | + PIPE_BIND_RENDER_TARGET | + PIPE_BIND_DEPTH_STENCIL | + PIPE_BIND_SHARED | + PIPE_BIND_SCANOUT)) + return false; + + /* We use the PBE for compression via staging blits, so we can only compress + * renderable formats. As framebuffer compression, other formats don't make a + * ton of sense to compress anyway. + */ + if (!agx_pixel_format[pres->base.format].renderable) + return false; + + /* Lossy-compressed texture formats cannot be compressed */ + assert(!util_format_is_compressed(pres->base.format) && + "block-compressed formats are not renderable"); + + /* TODO: Compression of arrays/cubes currently fails because it would require + * arrayed linear staging resources, which the hardware doesn't support. This + * could be worked around with more sophisticated blit code. + */ + if (pres->base.target != PIPE_TEXTURE_2D && pres->base.target != PIPE_TEXTURE_RECT) + return false; + + /* Small textures cannot (should not?) be compressed */ + if (pres->base.width0 < 16 || pres->base.height0 < 16) + return false; + + return true; } static uint64_t -- 2.7.4