i965/blorp: allow all buffer formats provided src and dst match.
authorPaul Berry <stereotype441@gmail.com>
Wed, 6 Jun 2012 18:17:32 +0000 (11:17 -0700)
committerPaul Berry <stereotype441@gmail.com>
Thu, 7 Jun 2012 18:03:15 +0000 (11:03 -0700)
Previously, blits using the "blorp" mechanism only worked for 8-bit
RGBA color buffers, 24-bit depth buffers, and 8 bit stencil buffers.
This was not enough, because the blorp mechanism must be used for
blitting whenever MSAA is in use.  This patch allows all formats to be
used, provided the source and destination formats match.

So far I have confirmed that the following formats work properly with
MSAA:
- GL_RGB
- GL_RGBA
- GL_ALPHA
- GL_ALPHA4
- GL_ALPHA8
- GL_R3_G3_B2
- GL_RGB4
- GL_RGB5
- GL_RGB8
- GL_RGB10
- GL_RGB12
- GL_RGB16
- GL_RGBA2
- GL_RGBA4
- GL_RGB5_A1
- GL_RGBA8
- GL_RGB10_A2
- GL_RGBA12
- GL_RGBA16

Fixes piglit tests "EXT_framebuffer_multisample/formats {2,4}" on
Sandy Bridge and Ivy Bridge.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_blorp_blit.cpp

index 180468b20a669f6c20f509da6f108bbdb42dd0d0..4de2d7a561a715fb732bed07442ee115145371e5 100644 (file)
@@ -151,19 +151,6 @@ try_blorp_blit(struct intel_context *intel,
    if (!src_mt) return false;
    if (buffer_bit == GL_STENCIL_BUFFER_BIT && src_mt->stencil_mt)
       src_mt = src_mt->stencil_mt;
-   switch (src_mt->format) {
-   case MESA_FORMAT_ARGB8888:
-   case MESA_FORMAT_X8_Z24:
-   case MESA_FORMAT_S8:
-      break; /* Supported */
-   default:
-      /* Unsupported format.
-       *
-       * TODO: need to support all formats that are allowed as multisample
-       * render targets.
-       */
-      return false;
-   }
 
    /* Validate destination */
    if (!dst_rb) return false;
@@ -172,19 +159,14 @@ try_blorp_blit(struct intel_context *intel,
    if (!dst_mt) return false;
    if (buffer_bit == GL_STENCIL_BUFFER_BIT && dst_mt->stencil_mt)
       dst_mt = dst_mt->stencil_mt;
-   switch (dst_mt->format) {
-   case MESA_FORMAT_ARGB8888:
-   case MESA_FORMAT_X8_Z24:
-   case MESA_FORMAT_S8:
-      break; /* Supported */
-   default:
-      /* Unsupported format.
-       *
-       * TODO: need to support all formats that are allowed as multisample
-       * render targets.
-       */
+
+   /* Blorp blits can't translate from one format to another.  For that we'll
+    * have to fall back to the meta-op blit.  Note: the meta-op blit doesn't
+    * support multisampled blits, but fortunately this is ok because
+    * multisampled blits require identical source and destination formats.
+    */
+   if (src_mt->format != dst_mt->format)
       return false;
-   }
 
    /* Account for the fact that in the system framebuffer, the origin is at
     * the lower left.