intel: Downsample on DRI2 flush
authorChad Versace <chad.versace@linux.intel.com>
Thu, 12 Jul 2012 20:01:26 +0000 (13:01 -0700)
committerChad Versace <chad.versace@linux.intel.com>
Tue, 7 Aug 2012 16:30:33 +0000 (09:30 -0700)
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
src/mesa/drivers/dri/intel/intel_screen.c

index 9aca4639d25290b1c82e26da88a95ff4db427ea5..a3c0140542ef6370dc01e96d100b141cd0fb34c4 100644 (file)
@@ -149,6 +149,36 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
    intelSetTexBuffer2,
 };
 
+static void
+intel_downsample_for_dri2_flush(struct intel_context *intel,
+                                __DRIdrawable *drawable)
+{
+   if (intel->gen < 6) {
+      /* MSAA is not supported, so don't waste time checking for
+       * a multisample buffer.
+       */
+      return;
+   }
+
+   struct gl_framebuffer *fb = drawable->driverPrivate;
+   struct intel_renderbuffer *rb;
+
+   /* Usually, only the back buffer will need to be downsampled. However,
+    * the front buffer will also need it if the user has rendered into it.
+    */
+   static const gl_buffer_index buffers[2] = {
+         BUFFER_BACK_LEFT,
+         BUFFER_FRONT_LEFT,
+   };
+
+   for (int i = 0; i < 2; ++i) {
+      rb = intel_get_renderbuffer(fb, buffers[i]);
+      if (rb == NULL || rb->mt == NULL)
+         continue;
+      intel_miptree_downsample(intel, rb->mt);
+   }
+}
+
 static void
 intelDRI2Flush(__DRIdrawable *drawable)
 {
@@ -160,6 +190,7 @@ intelDRI2Flush(__DRIdrawable *drawable)
    if (intel->gen < 4)
       INTEL_FIREVERTICES(intel);
 
+   intel_downsample_for_dri2_flush(intel, drawable);
    intel->need_throttle = true;
 
    if (intel->batch.used)