Mesa (master): etnaviv: replace translate_clear_color with util_pack_color

Christian Gmeiner austriancoder at kemper.freedesktop.org
Fri Jun 16 13:26:54 UTC 2017


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

Author: Lucas Stach <dev at lynxeye.de>
Date:   Sun Jun  4 21:06:31 2017 +0200

etnaviv: replace translate_clear_color with util_pack_color

This replaces the open coded etnaviv version of the color pack with the
common util_pack_color.

Fixes piglits:
arb_color_buffer_float-clear
fcc-front-buffer-distraction
fbo-clearmipmap

Fixes: c9e8b49b ("etnaviv: gallium driver for Vivante GPUs")
Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Lucas Stach <dev at lynxeye.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>

---

 src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 13 ++++++-
 src/gallium/drivers/etnaviv/etnaviv_translate.h  | 47 ------------------------
 2 files changed, 12 insertions(+), 48 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
index 225073dd66..e4620a3015 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
@@ -100,13 +100,24 @@ etna_rs_gen_clear_surface(struct etna_context *ctx, struct etna_surface *surf,
    });
 }
 
+static inline uint32_t
+pack_rgba(enum pipe_format format, const float *rgba)
+{
+   union util_color uc;
+   util_pack_color(rgba, format, &uc);
+   if (util_format_get_blocksize(format) == 2)
+      return uc.ui[0] << 16 | uc.ui[0];
+   else
+      return uc.ui[0];
+}
+
 static void
 etna_blit_clear_color(struct pipe_context *pctx, struct pipe_surface *dst,
                       const union pipe_color_union *color)
 {
    struct etna_context *ctx = etna_context(pctx);
    struct etna_surface *surf = etna_surface(dst);
-   uint32_t new_clear_value = translate_clear_color(surf->base.format, color);
+   uint32_t new_clear_value = pack_rgba(surf->base.format, color->f);
 
    if (surf->surf.ts_size) { /* TS: use precompiled clear command */
       ctx->framebuffer.TS_COLOR_CLEAR_VALUE = new_clear_value;
diff --git a/src/gallium/drivers/etnaviv/etnaviv_translate.h b/src/gallium/drivers/etnaviv/etnaviv_translate.h
index e8466d63ff..cbbfdf23d9 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_translate.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_translate.h
@@ -405,53 +405,6 @@ etna_layout_multiple(unsigned layout, unsigned pixel_pipes, bool rs_align,
    }
 }
 
-/* return 32-bit clear pattern for color */
-static inline uint32_t
-translate_clear_color(enum pipe_format format,
-                      const union pipe_color_union *color)
-{
-   uint32_t clear_value = 0;
-
-   // XXX util_pack_color
-   switch (format) {
-   case PIPE_FORMAT_B8G8R8A8_UNORM:
-   case PIPE_FORMAT_B8G8R8X8_UNORM:
-   case PIPE_FORMAT_R8G8B8A8_UNORM:
-   case PIPE_FORMAT_R8G8B8X8_UNORM:
-      clear_value = etna_cfloat_to_uintN(color->f[2], 8) |
-                    (etna_cfloat_to_uintN(color->f[1], 8) << 8) |
-                    (etna_cfloat_to_uintN(color->f[0], 8) << 16) |
-                    (etna_cfloat_to_uintN(color->f[3], 8) << 24);
-      break;
-   case PIPE_FORMAT_B4G4R4X4_UNORM:
-   case PIPE_FORMAT_B4G4R4A4_UNORM:
-      clear_value = etna_cfloat_to_uintN(color->f[2], 4) |
-                    (etna_cfloat_to_uintN(color->f[1], 4) << 4) |
-                    (etna_cfloat_to_uintN(color->f[0], 4) << 8) |
-                    (etna_cfloat_to_uintN(color->f[3], 4) << 12);
-      clear_value |= clear_value << 16;
-      break;
-   case PIPE_FORMAT_B5G5R5X1_UNORM:
-   case PIPE_FORMAT_B5G5R5A1_UNORM:
-      clear_value = etna_cfloat_to_uintN(color->f[2], 5) |
-                    (etna_cfloat_to_uintN(color->f[1], 5) << 5) |
-                    (etna_cfloat_to_uintN(color->f[0], 5) << 10) |
-                    (etna_cfloat_to_uintN(color->f[3], 1) << 15);
-      clear_value |= clear_value << 16;
-      break;
-   case PIPE_FORMAT_B5G6R5_UNORM:
-      clear_value = etna_cfloat_to_uintN(color->f[2], 5) |
-                    (etna_cfloat_to_uintN(color->f[1], 6) << 5) |
-                    (etna_cfloat_to_uintN(color->f[0], 5) << 11);
-      clear_value |= clear_value << 16;
-      break;
-   default:
-      DBG("Unhandled pipe format for color clear: %i", format);
-   }
-
-   return clear_value;
-}
-
 static inline uint32_t
 translate_clear_depth_stencil(enum pipe_format format, float depth,
                               unsigned stencil)




More information about the mesa-commit mailing list