Mesa (master): etnaviv: blt: blit with the original format when possible

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jun 30 01:59:25 UTC 2019


Module: Mesa
Branch: master
Commit: 89381191a96891a61a1f98102780669990b9f626
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=89381191a96891a61a1f98102780669990b9f626

Author: Jonathan Marek <jonathan at marek.ca>
Date:   Thu Jun 20 11:53:05 2019 -0400

etnaviv: blt: blit with the original format when possible

This fixes BGR565 blit: currently BGRA444 is used for the blit, but with
swizzles from the original BGR565 format, so the 4 alpha bits are set to 1.
We can't just use the swizzle from the 'compatible' format, since there are
cases where BGR<->RGB swap needs to happen.

We can avoid all this trouble by using the original formats and only
falling back to the 'compatible' format when we need to.

Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>

---

 src/gallium/drivers/etnaviv/etnaviv_blt.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_blt.c b/src/gallium/drivers/etnaviv/etnaviv_blt.c
index 1f13bbc31cd..42d1a4462d1 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_blt.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_blt.c
@@ -391,12 +391,16 @@ etna_try_blt_blit(struct pipe_context *pctx,
 
    /* TODO: 1 byte per pixel formats aren't handled by etna_compatible_rs_format nor
     * translate_rs_format.
-    * Also this should be smarter about format conversions; etna_compatible_rs_format
-    * assumes all 2-byte pixel format are laid out as 4444, all 4-byte pixel formats
-    * are 8888.
     */
-   unsigned src_format = etna_compatible_rs_format(blit_info->src.format);
-   unsigned dst_format = etna_compatible_rs_format(blit_info->dst.format);
+   unsigned src_format = blit_info->src.format;
+   unsigned dst_format = blit_info->dst.format;
+
+   /* for a copy with same dst/src format, we can use a different format */
+   if (translate_blt_format(src_format) == ETNA_NO_MATCH &&
+       src_format == dst_format) {
+      src_format = dst_format = etna_compatible_rs_format(src_format);
+   }
+
    if (translate_blt_format(src_format) == ETNA_NO_MATCH ||
        translate_blt_format(dst_format) == ETNA_NO_MATCH ||
        blit_info->scissor_enable ||
@@ -449,7 +453,7 @@ etna_try_blt_blit(struct pipe_context *pctx,
       op.src.tiling = src->layout;
       op.src.cache_mode = TS_CACHE_MODE_128; /* TODO: cache modes */
       const struct util_format_description *src_format_desc =
-         util_format_description(blit_info->src.format);
+         util_format_description(src_format);
       for (unsigned x=0; x<4; ++x)
          op.src.swizzle[x] = src_format_desc->swizzle[x];
 
@@ -474,7 +478,7 @@ etna_try_blt_blit(struct pipe_context *pctx,
       op.dest.tiling = dst->layout;
       op.dest.cache_mode = TS_CACHE_MODE_128; /* TODO cache modes */
       const struct util_format_description *dst_format_desc =
-         util_format_description(blit_info->dst.format);
+         util_format_description(dst_format);
       for (unsigned x=0; x<4; ++x)
          op.dest.swizzle[x] = dst_format_desc->swizzle[x];
 




More information about the mesa-commit mailing list