i965/gen7+: Ensure that front/back buffers are fast-clear resolved.
authorPaul Berry <stereotype441@gmail.com>
Tue, 7 May 2013 22:38:45 +0000 (15:38 -0700)
committerPaul Berry <stereotype441@gmail.com>
Wed, 12 Jun 2013 18:10:07 +0000 (11:10 -0700)
We already had code in intel_downsample_for_dri2_flush() for
downsampling front and back buffers when multisampling was in use.
This patch extends that function to perform fast color clear resolves
when necessary.

To account for the additional functionality, the function is renamed
to simply intel_resolve_for_dri2_flush().

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_context.h
src/mesa/drivers/dri/intel/intel_screen.c

index 09b33b142ed23aeb8238e524f21d93d01cd94770..f669ae04ac8cd33bb32662a0ec8deec3dc5e76f3 100644 (file)
@@ -95,12 +95,12 @@ intelGetString(struct gl_context * ctx, GLenum name)
 }
 
 void
-intel_downsample_for_dri2_flush(struct intel_context *intel,
-                                __DRIdrawable *drawable)
+intel_resolve_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.
+      /* MSAA and fast color clear are not supported, so don't waste time
+       * checking whether a resolve is needed.
        */
       return;
    }
@@ -120,7 +120,10 @@ intel_downsample_for_dri2_flush(struct intel_context *intel,
       rb = intel_get_renderbuffer(fb, buffers[i]);
       if (rb == NULL || rb->mt == NULL)
          continue;
-      intel_miptree_downsample(intel, rb->mt);
+      if (rb->mt->num_samples <= 1)
+         intel_miptree_resolve_color(intel, rb->mt);
+      else
+         intel_miptree_downsample(intel, rb->mt);
    }
 }
 
@@ -137,14 +140,14 @@ intel_flush_front(struct gl_context *ctx)
           driDrawable &&
           driDrawable->loaderPrivate) {
 
-         /* Downsample before flushing FAKE_FRONT_LEFT to FRONT_LEFT.
+         /* Resolve before flushing FAKE_FRONT_LEFT to FRONT_LEFT.
           *
-          * This potentially downsamples both front and back buffer. It
-          * is unnecessary to downsample the back, but harms nothing except
+          * This potentially resolves both front and back buffer. It
+          * is unnecessary to resolve the back, but harms nothing except
           * performance. And no one cares about front-buffer render
           * performance.
           */
-         intel_downsample_for_dri2_flush(intel, driDrawable);
+         intel_resolve_for_dri2_flush(intel, driDrawable);
 
          screen->dri2.loader->flushFrontBuffer(driDrawable,
                                                driDrawable->loaderPrivate);
index 5420e76b70943c7b63b19543b3d06305985c5297..552b9cfed169bfbd174b03780070c2e68b0a52d6 100644 (file)
@@ -615,8 +615,8 @@ void intel_update_renderbuffers(__DRIcontext *context,
 void intel_prepare_render(struct intel_context *intel);
 
 void
-intel_downsample_for_dri2_flush(struct intel_context *intel,
-                                __DRIdrawable *drawable);
+intel_resolve_for_dri2_flush(struct intel_context *intel,
+                             __DRIdrawable *drawable);
 
 void i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
                                  uint32_t buffer_id);
index 325304d266d92b77e98568b4806289ae94a491d3..b4758f9381724d467f1fff6559373bbd97c7d290 100644 (file)
@@ -170,7 +170,7 @@ intelDRI2Flush(__DRIdrawable *drawable)
    if (intel->gen < 4)
       INTEL_FIREVERTICES(intel);
 
-   intel_downsample_for_dri2_flush(intel, drawable);
+   intel_resolve_for_dri2_flush(intel, drawable);
    intel->need_throttle = true;
 
    if (intel->batch.used)