[Mesa-dev] [PATCH 01/12] r600g: implement fast MSAA color clear for integer textures

Marek Olšák maraeo at gmail.com
Sun Jun 30 18:53:42 PDT 2013


this also fixes the fast clear with multiple colorbuffers and each having
a different format
---
 src/gallium/drivers/r600/r600_blit.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 1cdd1c8..3b8a28b 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -416,17 +416,22 @@ static boolean is_simple_msaa_resolve(const struct pipe_blit_info *info)
 static void r600_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
 			      unsigned offset, unsigned size, unsigned char value);
 
-static void evergreen_set_clear_color(struct pipe_context *ctx,
-				      struct pipe_surface *cbuf,
+static void evergreen_set_clear_color(struct pipe_surface *cbuf,
 				      const union pipe_color_union *color)
 {
-	struct r600_context *rctx = (struct r600_context *)ctx;
-	struct pipe_framebuffer_state *fb = &rctx->framebuffer.state;
 	unsigned *clear_value = ((struct r600_texture *)cbuf->texture)->color_clear_value;
 	union util_color uc;
 
 	memset(&uc, 0, sizeof(uc));
-	util_pack_color(color->f, fb->cbufs[0]->format, &uc);
+
+	if (util_format_is_pure_uint(cbuf->format)) {
+		util_format_write_4ui(cbuf->format, color->ui, 0, &uc, 0, 0, 0, 1, 1);
+	} else if (util_format_is_pure_sint(cbuf->format)) {
+		util_format_write_4i(cbuf->format, color->i, 0, &uc, 0, 0, 0, 1, 1);
+	} else {
+		util_pack_color(color->f, cbuf->format, &uc);
+	}
+
 	memcpy(clear_value, &uc, 2 * sizeof(uint32_t));
 }
 
@@ -448,10 +453,8 @@ static bool can_fast_clear_color(struct pipe_context *ctx)
 			return false;
 		}
 
-		/* cannot pack color for pure integer formats */
 		/* 128-bit formats are unuspported */
-		if (util_format_is_pure_integer(fb->cbufs[i]->format) ||
-		    util_format_get_blocksizebits(fb->cbufs[i]->format) > 64) {
+		if (util_format_get_blocksizebits(fb->cbufs[i]->format) > 64) {
 			return false;
 		}
 
@@ -479,7 +482,7 @@ static void r600_clear(struct pipe_context *ctx, unsigned buffers,
 		for (i = 0; i < fb->nr_cbufs; i++) {
 			struct r600_texture *tex = (struct r600_texture *)fb->cbufs[i]->texture;
 
-			evergreen_set_clear_color(ctx, fb->cbufs[i], color);
+			evergreen_set_clear_color(fb->cbufs[i], color);
 			r600_clear_buffer(ctx, fb->cbufs[i]->texture,
 					tex->cmask_offset, tex->cmask_size, 0);
 			tex->dirty_level_mask |= 1 << fb->cbufs[i]->u.tex.level;
-- 
1.8.1.2



More information about the mesa-dev mailing list