[Mesa-dev] [PATCH 02/18] gallium/radeon: use rectangles for 1D and 2D texture blits

Marek Olšák maraeo at gmail.com
Thu Aug 17 18:31:23 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeon/r600_pipe_common.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index dc54b5e..4cc64c7 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -209,40 +209,35 @@ void r600_draw_rectangle(struct blitter_context *blitter,
 			 enum blitter_attrib_type type,
 			 const union pipe_color_union *attrib)
 {
 	struct r600_common_context *rctx =
 		(struct r600_common_context*)util_blitter_get_pipe(blitter);
 	struct pipe_viewport_state viewport;
 	struct pipe_resource *buf = NULL;
 	unsigned offset = 0;
 	float *vb;
 
-	if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) {
-		util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, type, attrib);
-		return;
-	}
-
 	/* Some operations (like color resolve on r6xx) don't work
 	 * with the conventional primitive types.
 	 * One that works is PT_RECTLIST, which we use here. */
 
 	/* setup viewport */
 	viewport.scale[0] = 1.0f;
 	viewport.scale[1] = 1.0f;
 	viewport.scale[2] = 1.0f;
 	viewport.translate[0] = 0.0f;
 	viewport.translate[1] = 0.0f;
 	viewport.translate[2] = 0.0f;
 	rctx->b.set_viewport_states(&rctx->b, 0, 1, &viewport);
 
 	/* Upload vertices. The hw rectangle has only 3 vertices,
-	 * I guess the 4th one is derived from the first 3.
+	 * The 4th one is derived from the first 3.
 	 * The vertex specification should match u_blitter's vertex element state. */
 	u_upload_alloc(rctx->b.stream_uploader, 0, sizeof(float) * 24,
 		       rctx->screen->info.tcc_cache_line_size,
                        &offset, &buf, (void**)&vb);
 	if (!buf)
 		return;
 
 	vb[0] = x1;
 	vb[1] = y1;
 	vb[2] = depth;
@@ -251,24 +246,35 @@ void r600_draw_rectangle(struct blitter_context *blitter,
 	vb[8] = x1;
 	vb[9] = y2;
 	vb[10] = depth;
 	vb[11] = 1;
 
 	vb[16] = x2;
 	vb[17] = y1;
 	vb[18] = depth;
 	vb[19] = 1;
 
-	if (attrib) {
+	switch (type) {
+	case UTIL_BLITTER_ATTRIB_COLOR:
 		memcpy(vb+4, attrib->f, sizeof(float)*4);
 		memcpy(vb+12, attrib->f, sizeof(float)*4);
 		memcpy(vb+20, attrib->f, sizeof(float)*4);
+		break;
+	case UTIL_BLITTER_ATTRIB_TEXCOORD:
+		vb[4] = attrib->f[0]; /* x1 */
+		vb[5] = attrib->f[1]; /* y1 */
+		vb[12] = attrib->f[0]; /* x1 */
+		vb[13] = attrib->f[3]; /* y2 */
+		vb[20] = attrib->f[2]; /* x2 */
+		vb[21] = attrib->f[1]; /* y1 */
+		break;
+	default:; /* Nothing to do. */
 	}
 
 	/* draw */
 	util_draw_vertex_buffer(&rctx->b, NULL, buf, blitter->vb_slot, offset,
 				R600_PRIM_RECTANGLE_LIST, 3, 2);
 	pipe_resource_reference(&buf, NULL);
 }
 
 static void r600_dma_emit_wait_idle(struct r600_common_context *rctx)
 {
-- 
2.7.4



More information about the mesa-dev mailing list