[Mesa-dev] [RFC PATCH] i965/msaa: Disable unsupported formats.

Paul Berry stereotype441 at gmail.com
Fri Jun 15 11:12:16 PDT 2012


Due to hardware limitations, MSAA is unsupported on Gen6 for formats
containing >64 bits of data per pixel.  From the Sandy Bridge PRM,
vol4 part1, p72 ("Surface Format"):

    If Number of Multisamples is set to a value other than
    MULTISAMPLECOUNT_1, this field cannot be set to the following
    formats:
    - any format with greater than 64 bits per element
    - any compressed texture format (BC*)
    - any YCRCB* format

Gen7 has a similar, but less stringent limitation: formats with >64
bits of data per pixel only support 4x MSAA.

This patch causes the unsupported formats to report
GL_FRAMEBUFFER_UNSUPPORTED.

Fixes piglit "multisample-formats" tests on Gen6.
---

It is not 100% clear to me whether this approach is compliant with the
spec.  On the one hand, the spec requires formats RGBA32F, RGBA32I,
and RGBA32UI to be color-renderable.  On the other hand, the spec
allows for the implementation to report GL_FRAMEBUFFER_UNSUPPORTED if
the set of attached images violates "an implementation-dependent set
of restrictions", which seems to leave a lot of leeway.

If we decide that it's not ok to report GL_FRAMEBUFFER_UNSUPPORTED for
MSAA buffers using these formats, then we'll have to figure out some
other way to work around the hardware's lack of support for MSAA on
these formats, and I haven't thought of a good way to do that.  The
alternatives I've considered (substitute another buffer format, or
substitute a non-multisampled renderbuffer) are definitely
non-spec-compliant, and also fraught with implementation difficulties.

So for the moment my inclination is to go through with this patch as
is, and if we later discover that it causes trouble for a client
application, we can consider other options.  I'm curious to hear what
others think.

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 4718337..d09fe6d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -576,6 +576,19 @@ brw_render_target_supported(struct intel_context *intel,
 	rb->_BaseFormat != GL_RED) && _mesa_is_format_integer_color(format))
       return false;
 
+   /* Under some conditions, MSAA is not supported for formats whose width is
+    * more than 64 bits.
+    */
+   if (rb->NumSamples > 0 && _mesa_get_format_bytes(format) > 8) {
+      /* Gen6: MSAA on >64 bit formats is unsupported. */
+      if (intel->gen <= 6)
+         return false;
+
+      /* Gen7: 8x MSAA on >64 bit formats is unsupported. */
+      if (rb->NumSamples >= 8)
+         return false;
+   }
+
    return brw->format_supported_as_render_target[format];
 }
 
-- 
1.7.7.6



More information about the mesa-dev mailing list