From e7b97899ac92e9dc1390db017bad8e3ee492e047 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 17 Dec 2022 16:28:54 -0500 Subject: [PATCH] asahi: Use writeback when it looks beneficial When playing the My Little Pony theme song at 1080p on T8103, with mpv's GPU compositing but software decoding, CPU usage drops from 200% to 50% due to proper caching of the staging resource. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 689b66fef3b..3607ad3e4e2 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -530,7 +530,19 @@ agx_resource_create_with_modifiers(struct pipe_screen *screen, : (bind & PIPE_BIND_SHADER_IMAGE) ? "Shader image" : "Other resource"; - nresource->bo = agx_bo_create(dev, nresource->layout.size_B, 0, label); + uint32_t create_flags = 0; + + /* Default to write-combine resources, but use writeback if that is expected + * to be beneficial. + */ + if (nresource->base.usage == PIPE_USAGE_STAGING || + (nresource->base.flags & PIPE_RESOURCE_FLAG_MAP_COHERENT)) { + + create_flags |= AGX_BO_WRITEBACK; + } + + nresource->bo = + agx_bo_create(dev, nresource->layout.size_B, create_flags, label); if (!nresource->bo) { FREE(nresource);