Mesa (master): radeon: Only get DRI2 front buffer information for glXBindTexImageEXT.

Michel Dänzer daenzer at kemper.freedesktop.org
Sun Aug 30 10:54:31 UTC 2009


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

Author: Michel Dänzer <daenzer at vmware.com>
Date:   Sun Aug 30 12:37:14 2009 +0200

radeon: Only get DRI2 front buffer information for glXBindTexImageEXT.

---

 src/mesa/drivers/dri/r300/r300_texstate.c          |   13 +----
 src/mesa/drivers/dri/radeon/radeon_common.c        |    8 ++--
 .../drivers/dri/radeon/radeon_common_context.c     |   57 +++++++++++---------
 .../drivers/dri/radeon/radeon_common_context.h     |    3 +-
 4 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c
index e6c489c..c09c796 100644
--- a/src/mesa/drivers/dri/r300/r300_texstate.c
+++ b/src/mesa/drivers/dri/r300/r300_texstate.c
@@ -408,18 +408,7 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
     	}
 
 	if (!rfb->color_rb[0] || !rfb->color_rb[0]->bo) {
-		radeon_update_renderbuffers(pDRICtx, dPriv);
-		/* back & depth buffer are useless free them right away */
-		rb = (void*)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer;
-		if (rb && rb->bo) {
-			radeon_bo_unref(rb->bo);
-			rb->bo = NULL;
-		}
-		rb = (void*)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer;
-		if (rb && rb->bo) {
-			radeon_bo_unref(rb->bo);
-			rb->bo = NULL;
-		}
+		radeon_update_renderbuffers(pDRICtx, dPriv, GL_TRUE);
 	}
 
 	rb = rfb->color_rb[0];
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index 6b8a86d..27dcddf 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -892,7 +892,7 @@ void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
        */
 		if (!was_front_buffer_rendering && radeon->is_front_buffer_rendering) {
 			radeon_update_renderbuffers(radeon->dri.context,
-				radeon->dri.context->driDrawablePriv);
+				radeon->dri.context->driDrawablePriv, GL_FALSE);
       }
 	}
 
@@ -909,7 +909,7 @@ void radeonReadBuffer( GLcontext *ctx, GLenum mode )
 
 		if (!was_front_buffer_reading && rmesa->is_front_buffer_reading) {
 			radeon_update_renderbuffers(rmesa->dri.context,
-						    rmesa->dri.context->driReadablePriv);
+						    rmesa->dri.context->driReadablePriv, GL_FALSE);
 	 	}
 	}
 	/* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
@@ -964,9 +964,9 @@ void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei he
 		}
 
 		if (!radeon->meta.internal_viewport_call && !radeon_fb->keep_buffers) {
-			radeon_update_renderbuffers(driContext, driContext->driDrawablePriv);
+			radeon_update_renderbuffers(driContext, driContext->driDrawablePriv, GL_FALSE);
 			if (driContext->driDrawablePriv != driContext->driReadablePriv)
-				radeon_update_renderbuffers(driContext, driContext->driReadablePriv);
+				radeon_update_renderbuffers(driContext, driContext->driReadablePriv, 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 10bde8c..76f0ad0 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -515,7 +515,8 @@ radeon_bits_per_pixel(const struct radeon_renderbuffer *rb)
 }
 
 void
-radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
+			    GLboolean front_only)
 {
 	unsigned int attachments[10];
 	__DRIbuffer *buffers = NULL;
@@ -541,7 +542,7 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 		struct radeon_renderbuffer *stencil_rb;
 
 		i = 0;
-		if ((radeon->is_front_buffer_rendering ||
+		if ((front_only || radeon->is_front_buffer_rendering ||
 		     radeon->is_front_buffer_reading ||
 		     !draw->color_rb[1])
 		    && draw->color_rb[0]) {
@@ -549,23 +550,25 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 			attachments[i++] = radeon_bits_per_pixel(draw->color_rb[0]);
 		}
 
-		if (draw->color_rb[1]) {
-			attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-			attachments[i++] = radeon_bits_per_pixel(draw->color_rb[1]);
-		}
+		if (!front_only) {
+			if (draw->color_rb[1]) {
+				attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+				attachments[i++] = radeon_bits_per_pixel(draw->color_rb[1]);
+			}
 
-		depth_rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
-		stencil_rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
-
-		if ((depth_rb != NULL) && (stencil_rb != NULL)) {
-			attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
-			attachments[i++] = radeon_bits_per_pixel(depth_rb);
-		} else if (depth_rb != NULL) {
-			attachments[i++] = __DRI_BUFFER_DEPTH;
-			attachments[i++] = radeon_bits_per_pixel(depth_rb);
-		} else if (stencil_rb != NULL) {
-			attachments[i++] = __DRI_BUFFER_STENCIL;
-			attachments[i++] = radeon_bits_per_pixel(stencil_rb);
+			depth_rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+			stencil_rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+
+			if ((depth_rb != NULL) && (stencil_rb != NULL)) {
+				attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
+				attachments[i++] = radeon_bits_per_pixel(depth_rb);
+			} else if (depth_rb != NULL) {
+				attachments[i++] = __DRI_BUFFER_DEPTH;
+				attachments[i++] = radeon_bits_per_pixel(depth_rb);
+			} else if (stencil_rb != NULL) {
+				attachments[i++] = __DRI_BUFFER_STENCIL;
+				attachments[i++] = radeon_bits_per_pixel(stencil_rb);
+			}
 		}
 
 		buffers = (*screen->dri2.loader->getBuffersWithFormat)(drawable,
@@ -578,12 +581,14 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 		i = 0;
 		if (draw->color_rb[0])
 			attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-		if (draw->color_rb[1])
-			attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-		if (radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH))
-			attachments[i++] = __DRI_BUFFER_DEPTH;
-		if (radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL))
-			attachments[i++] = __DRI_BUFFER_STENCIL;
+		if (!front_only) {
+			if (draw->color_rb[1])
+				attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+			if (radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH))
+				attachments[i++] = __DRI_BUFFER_DEPTH;
+			if (radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL))
+				attachments[i++] = __DRI_BUFFER_STENCIL;
+		}
 
 		buffers = (*screen->dri2.loader->getBuffers)(drawable,
 								 &drawable->w,
@@ -754,9 +759,9 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
 
 	if (driContextPriv->driScreenPriv->dri2.enabled) {
 		if (0 || !drfb->keep_buffers) {
-			radeon_update_renderbuffers(driContextPriv, driDrawPriv);
+			radeon_update_renderbuffers(driContextPriv, driDrawPriv, GL_FALSE);
 			if (driDrawPriv != driReadPriv)
-				radeon_update_renderbuffers(driContextPriv, driReadPriv);
+				radeon_update_renderbuffers(driContextPriv, driReadPriv, GL_FALSE);
                 }
 
 		_mesa_reference_renderbuffer(&radeon->state.color.rb,
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h
index 3821952..bfd0ffa 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -617,7 +617,8 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
 
 void radeonCleanupContext(radeonContextPtr radeon);
 GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
-void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable);
+void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
+				 GLboolean front_only);
 GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
 			    __DRIdrawablePrivate * driDrawPriv,
 			    __DRIdrawablePrivate * driReadPriv);




More information about the mesa-commit mailing list