Mesa (master): panfrost: Fix AFBC blits of resources with faked RGTC
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 10 11:51:23 UTC 2020
Module: Mesa
Branch: master
Commit: 44f2de5286c646f9da1fc26af3780e44184aad3c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=44f2de5286c646f9da1fc26af3780e44184aad3c
Author: Icecream95 <ixn at disroot.org>
Date: Mon Nov 2 20:32:18 2020 +1300
panfrost: Fix AFBC blits of resources with faked RGTC
Because u_transfer_helper changes resources back from the real format
to the emulated format after creation, we need to fix the format enum
for resources with fake compression when doing blits to/from AFBC.
Fixes: acb8dcfebdd ("panfrost: Choose AFBC when available")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7400>
---
src/gallium/drivers/panfrost/pan_resource.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 979350d92b7..66970426096 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -728,6 +728,20 @@ pan_alloc_staging(struct panfrost_context *ctx, struct panfrost_resource *rsc,
return pan_resource(pstaging);
}
+static enum pipe_format
+pan_blit_format(enum pipe_format fmt)
+{
+ const struct util_format_description *desc;
+ desc = util_format_description(fmt);
+
+ /* This must be an emulated format (using u_transfer_helper) as if it
+ * was real RGTC we wouldn't have used AFBC and needed a blit. */
+ if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC)
+ fmt = PIPE_FORMAT_R8G8B8A8_UNORM;
+
+ return fmt;
+}
+
static void
pan_blit_from_staging(struct pipe_context *pctx, struct panfrost_transfer *trans)
{
@@ -735,14 +749,14 @@ pan_blit_from_staging(struct pipe_context *pctx, struct panfrost_transfer *trans
struct pipe_blit_info blit = {0};
blit.dst.resource = dst;
- blit.dst.format = dst->format;
+ blit.dst.format = pan_blit_format(dst->format);
blit.dst.level = trans->base.level;
blit.dst.box = trans->base.box;
blit.src.resource = trans->staging.rsrc;
- blit.src.format = trans->staging.rsrc->format;
+ blit.src.format = pan_blit_format(trans->staging.rsrc->format);
blit.src.level = 0;
blit.src.box = trans->staging.box;
- blit.mask = util_format_get_mask(trans->staging.rsrc->format);
+ blit.mask = util_format_get_mask(blit.src.format);
blit.filter = PIPE_TEX_FILTER_NEAREST;
panfrost_blit(pctx, &blit);
@@ -755,14 +769,14 @@ pan_blit_to_staging(struct pipe_context *pctx, struct panfrost_transfer *trans)
struct pipe_blit_info blit = {0};
blit.src.resource = src;
- blit.src.format = src->format;
+ blit.src.format = pan_blit_format(src->format);
blit.src.level = trans->base.level;
blit.src.box = trans->base.box;
blit.dst.resource = trans->staging.rsrc;
- blit.dst.format = trans->staging.rsrc->format;
+ blit.dst.format = pan_blit_format(trans->staging.rsrc->format);
blit.dst.level = 0;
blit.dst.box = trans->staging.box;
- blit.mask = util_format_get_mask(trans->staging.rsrc->format);
+ blit.mask = util_format_get_mask(blit.dst.format);
blit.filter = PIPE_TEX_FILTER_NEAREST;
panfrost_blit(pctx, &blit);
More information about the mesa-commit
mailing list