[Mesa-dev] [PATCH 15/18] radeon: Drop broken front_buffer_reading/drawing optimization

Ian Romanick idr at freedesktop.org
Wed Sep 30 13:58:03 PDT 2015


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/drivers/dri/radeon/radeon_common.c        | 37 ++++++++--------------
 .../drivers/dri/radeon/radeon_common_context.c     | 10 +++---
 .../drivers/dri/radeon/radeon_common_context.h     | 17 ----------
 3 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index 1ba61c8..e786f73 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -324,22 +324,17 @@ void radeonDrawBuffer( struct gl_context *ctx, GLenum mode )
 		fprintf(stderr, "%s %s\n", __func__,
 			_mesa_enum_to_string( mode ));
 
-	if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+	if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) {
 		radeonContextPtr radeon = RADEON_CONTEXT(ctx);
 
-		const GLboolean was_front_buffer_rendering =
-			radeon->is_front_buffer_rendering;
-
-		radeon->is_front_buffer_rendering = (mode == GL_FRONT_LEFT) ||
-                                            (mode == GL_FRONT);
-
-      /* If we weren't front-buffer rendering before but we are now, make sure
-       * that the front-buffer has actually been allocated.
-       */
-		if (!was_front_buffer_rendering && radeon->is_front_buffer_rendering) {
-			radeon_update_renderbuffers(radeon->driContext,
-				radeon->driContext->driDrawablePriv, GL_FALSE);
-      }
+		/* If we might be front-buffer rendering on this buffer for
+		 * the first time, invalidate our DRI drawable so we'll ask
+		 * for new buffers (including the fake front) before we start
+		 * rendering again.
+		 */
+		radeon_update_renderbuffers(radeon->driContext,
+					    radeon->driContext->driDrawablePriv,
+					    GL_FALSE);
 	}
 
 	radeon_draw_buffer(ctx, ctx->DrawBuffer);
@@ -347,16 +342,10 @@ void radeonDrawBuffer( struct gl_context *ctx, GLenum mode )
 
 void radeonReadBuffer( struct gl_context *ctx, GLenum mode )
 {
-	if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+	if (_mesa_is_front_buffer_reading(ctx->ReadBuffer)) {
 		struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
-		const GLboolean was_front_buffer_reading = rmesa->is_front_buffer_reading;
-		rmesa->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
-					|| (mode == GL_FRONT);
-
-		if (!was_front_buffer_reading && rmesa->is_front_buffer_reading) {
-			radeon_update_renderbuffers(rmesa->driContext,
-						    rmesa->driContext->driReadablePriv, GL_FALSE);
-	 	}
+		radeon_update_renderbuffers(rmesa->driContext,
+					    rmesa->driContext->driReadablePriv, GL_FALSE);
 	}
 	/* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
 	if (ctx->ReadBuffer == ctx->DrawBuffer) {
@@ -382,7 +371,7 @@ void radeon_viewport(struct gl_context *ctx)
 	void (*old_viewport)(struct gl_context *ctx);
 
 	if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
-		if (radeon->is_front_buffer_rendering) {
+		if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) {
 			ctx->Driver.Flush(ctx);
 		}
 		radeon_update_renderbuffers(driContext, driContext->driDrawablePriv, GL_FALSE);
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index 4660d98..4d993f7 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -352,7 +352,7 @@ void radeon_prepare_render(radeonContextPtr radeon)
      * that will happen next will probably dirty the front buffer.  So
      * mark it as dirty here.
      */
-    if (radeon->is_front_buffer_rendering)
+    if (_mesa_is_front_buffer_drawing(radeon->glCtx.DrawBuffer))
 	radeon->front_buffer_dirty = GL_TRUE;
 }
 
@@ -389,10 +389,10 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
 		struct radeon_renderbuffer *stencil_rb;
 
 		i = 0;
-		if ((front_only || radeon->is_front_buffer_rendering ||
-		     radeon->is_front_buffer_reading ||
-		     !draw->color_rb[1])
-		    && draw->color_rb[0]) {
+                if ((front_only || _mesa_is_front_buffer_drawing(&draw->base) ||
+                     _mesa_is_front_buffer_reading(&draw->base) ||
+                     !draw->color_rb[1])
+                    && draw->color_rb[0]) {
 			attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
 			attachments[i++] = radeon_bits_per_pixel(draw->color_rb[0]);
 		}
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h
index d142a87..6008a1e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -427,23 +427,6 @@ struct radeon_context {
     */
    GLboolean front_buffer_dirty;
 
-   /**
-    * Track whether front-buffer rendering is currently enabled
-    *
-    * A separate flag is used to track this in order to support MRT more
-    * easily.
-    */
-   GLboolean is_front_buffer_rendering;
-
-   /**
-    * Track whether front-buffer is the current read target.
-    *
-    * This is closely associated with is_front_buffer_rendering, but may
-    * be set separately.  The DRI2 fake front buffer must be referenced
-    * either way.
-    */
-   GLboolean is_front_buffer_reading;
-
    struct {
 	struct radeon_query_object *current;
 	struct radeon_state_atom queryobj;
-- 
2.1.0



More information about the mesa-dev mailing list