Mesa (main): freedreno: Don't try staging blit for non-renderable formats
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 19:26:49 UTC 2021
Module: Mesa
Branch: main
Commit: fb8fe017ee1dd716dbe2d1e571f973f0f26f7726
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb8fe017ee1dd716dbe2d1e571f973f0f26f7726
Author: Rob Clark <robdclark at chromium.org>
Date: Sun Jun 13 08:21:52 2021 -0700
freedreno: Don't try staging blit for non-renderable formats
If a format is not supported as a render target, there is no point in
trying a staging blit, as it will end up in a CPU copy fallback.
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11371>
---
src/gallium/drivers/freedreno/freedreno_resource.c | 23 +++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 92b349e36d5..309be6137bf 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -325,6 +325,20 @@ fd_resource_busy(struct pipe_screen *pscreen, struct pipe_resource *prsc,
static void flush_resource(struct fd_context *ctx, struct fd_resource *rsc,
unsigned usage);
+/**
+ * Helper to check if the format is something that we can blit/render
+ * to.. if the format is not renderable, there is no point in trying
+ * to do a staging blit (as it will still end up being a cpu copy)
+ */
+static bool
+is_renderable(struct pipe_resource *prsc)
+{
+ struct pipe_screen *pscreen = prsc->screen;
+ return pscreen->is_format_supported(
+ pscreen, prsc->format, prsc->target, prsc->nr_samples,
+ prsc->nr_storage_samples, PIPE_BIND_RENDER_TARGET);
+}
+
/**
* @rsc: the resource to shadow
* @level: the level to discard (if box != NULL, otherwise ignored)
@@ -361,9 +375,7 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
/* TODO: somehow munge dimensions and format to copy unsupported
* render target format to something that is supported?
*/
- if (!pctx->screen->is_format_supported(
- pctx->screen, prsc->format, prsc->target, prsc->nr_samples,
- prsc->nr_storage_samples, PIPE_BIND_RENDER_TARGET))
+ if (!is_renderable(prsc))
fallback = true;
/* do shadowing back-blits on the cpu for buffers: */
@@ -847,7 +859,7 @@ resource_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc,
needs_flush = busy = false;
ctx->stats.shadow_uploads++;
} else {
- struct fd_resource *staging_rsc;
+ struct fd_resource *staging_rsc = NULL;
if (needs_flush) {
flush_resource(ctx, rsc, usage);
@@ -859,7 +871,8 @@ resource_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc,
* already had rendering flushed for all tiles. So we can
* use a staging buffer to do the upload.
*/
- staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
+ if (is_renderable(prsc))
+ staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
if (staging_rsc) {
trans->staging_prsc = &staging_rsc->b.b;
trans->b.b.stride = fd_resource_pitch(staging_rsc, 0);
More information about the mesa-commit
mailing list