radeon: Only get DRI2 front buffer information for glXBindTexImageEXT.
authorMichel Dänzer <daenzer@vmware.com>
Sat, 5 Dec 2009 16:20:03 +0000 (17:20 +0100)
committerMichel Dänzer <michel@daenzer.net>
Sat, 5 Dec 2009 16:54:23 +0000 (17:54 +0100)
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/radeon/radeon_common.c
src/mesa/drivers/dri/radeon/radeon_common_context.c
src/mesa/drivers/dri/radeon/radeon_common_context.h

index e6f2c0c1a7b874cf6cb936b0cac7bb1e0af0e150..9eaf390b4601bdeadfb88595a30d8970bd93096f 100644 (file)
@@ -409,18 +409,7 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
            return;
        }
 
-       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];
        if (rb->bo == NULL) {
                /* Failed to BO for the buffer */
index 184287aa44cab5ceb0339120d688edbee85f1ae8..c81e80e820ebac6d440c6a4653d67839492a58c8 100644 (file)
@@ -840,7 +840,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);
       }
        }
 
@@ -857,7 +857,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 */
@@ -908,9 +908,9 @@ void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei he
                if (radeon->is_front_buffer_rendering) {
                        ctx->Driver.Flush(ctx);
                }
-               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);
        }
 
        old_viewport = ctx->Driver.Viewport;
index 71f70d724b9458b9af7675b4997c626783ef0af0..5c68bf5df6c3eb7c6108ab999948400490b7221d 100644 (file)
@@ -499,7 +499,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;
@@ -525,7 +526,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]) {
@@ -533,23 +534,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,
@@ -562,12 +565,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,
@@ -735,9 +740,9 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
        readfb = driReadPriv->driverPrivate;
 
        if (driContextPriv->driScreenPriv->dri2.enabled) {
-               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,
                        &(radeon_get_renderbuffer(&drfb->base, BUFFER_BACK_LEFT)->base));
                _mesa_reference_renderbuffer(&radeon->state.depth.rb,
index ad953ddbb5afa8fc0c6c1b921c2b38d598b6f091..49a9ec561061e384f7a8f2ddcb82b2327348d679 100644 (file)
@@ -589,7 +589,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);