summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Stach <dev@lynxeye.de>2017-06-04 21:06:31 +0200
committerAndres Gomez <agomez@igalia.com>2017-06-28 20:15:03 +0300
commitf1d6d6bb1b1f774c2c7cdeb0aa43c0d58cc4d807 (patch)
treeb0917a6354fa87a4cf968396d83c971c6ccd4eff
parente8368dbd6b3a30ad40fb9d7990b4c45936d5c959 (diff)
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@lists.freedesktop.org Signed-off-by: Lucas Stach <dev@lynxeye.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> (cherry picked from commit d6aa2ba2b293f78d9c28922ed3af9077100f3480)
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_clear_blit.c13
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_translate.h47
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 c3b755e3da8..c44fa6d7967 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 e8466d63ff1..cbbfdf23d93 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)