intel: Also get the DRI2 front buffer when doing front buffer reading.
authorEric Anholt <eric@anholt.net>
Sat, 20 Jun 2009 05:12:52 +0000 (22:12 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 20 Jun 2009 05:18:16 +0000 (22:18 -0700)
src/mesa/drivers/dri/i965/Makefile
src/mesa/drivers/dri/intel/intel_buffers.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_context.h

index 9712c3872543b2897c2e8c5840cb31f649d9dbc0..00a42111da09430f78715f7eab28e9905d6227a8 100644 (file)
@@ -23,6 +23,7 @@ DRIVER_SOURCES = \
        intel_pixel_bitmap.c \
        intel_pixel_copy.c \
        intel_pixel_draw.c \
+       intel_pixel_read.c \
        intel_state.c \
        intel_swapbuffers.c \
        intel_tex.c \
index df5c3fc1766f40cbb3487fea397db96bb1b79d0a..e7357e78c539256da3c2816f4b0efb98e0bebd07 100644 (file)
@@ -345,6 +345,23 @@ intelDrawBuffer(GLcontext * ctx, GLenum mode)
 static void
 intelReadBuffer(GLcontext * ctx, GLenum mode)
 {
+   if ((ctx->DrawBuffer != NULL) && (ctx->DrawBuffer->Name == 0)) {
+      struct intel_context *const intel = intel_context(ctx);
+      const GLboolean was_front_buffer_reading =
+       intel->is_front_buffer_reading;
+
+      intel->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
+       || (mode == GL_FRONT);
+
+      /* If we weren't front-buffer reading before but we are now, make sure
+       * that the front-buffer has actually been allocated.
+       */
+      if (!was_front_buffer_reading && intel->is_front_buffer_reading) {
+        intel_update_renderbuffers(intel->driContext,
+                                   intel->driContext->driDrawablePriv);
+      }
+   }
+
    if (ctx->ReadBuffer == ctx->DrawBuffer) {
       /* This will update FBO completeness status.
        * A framebuffer will be incomplete if the GL_READ_BUFFER setting
index 4138764604999af4c86d0a86633d8b2687cb85f6..32ce0e207b6ab3f1ca17b313cc53763378788a08 100644 (file)
@@ -218,7 +218,9 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
       struct intel_renderbuffer *stencil_rb;
 
       i = 0;
-      if ((intel->is_front_buffer_rendering || !intel_fb->color_rb[1])
+      if ((intel->is_front_buffer_rendering ||
+          intel->is_front_buffer_reading ||
+          !intel_fb->color_rb[1])
           && intel_fb->color_rb[0]) {
         attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
         attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[0]);
index 7d3c80bb21cce1385eb0238c987c2f7f4c21b6f8..36f33b6f31ec9efa4a22ba8542c7527fa24d0fc3 100644 (file)
@@ -304,6 +304,14 @@ struct intel_context
     * 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;
 
    GLboolean use_texture_tiling;
    GLboolean use_early_z;