re-add MSAA support
authorAlan Hourihane <alanh@tungstengraphics.com>
Fri, 19 Sep 2008 12:55:34 +0000 (13:55 +0100)
committerAlan Hourihane <alanh@tungstengraphics.com>
Fri, 19 Sep 2008 12:58:45 +0000 (13:58 +0100)
src/mesa/drivers/dri/common/utils.c
src/mesa/drivers/dri/common/utils.h

index 431c26a19d8bcfd7b5c12f478b312cac39c32ea9..14cb68fa253a5ee5e0bbf611224dae2fae88f399 100644 (file)
@@ -524,15 +524,12 @@ GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
  * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32, 
  * \c GL_4HALF_16_16_16_16, etc.  We can cross that bridge when we come to it.
  */
-
-/* XXX: need to re-add msaa support after gallium-0.1 merge
- */
-
 __DRIconfig **
 driCreateConfigs(GLenum fb_format, GLenum fb_type,
                 const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
                 unsigned num_depth_stencil_bits,
-                const GLenum * db_modes, unsigned num_db_modes)
+                const GLenum * db_modes, unsigned num_db_modes,
+                const u_int8_t * msaa_samples, unsigned num_msaa_modes)
 {
    static const u_int8_t bits_table[4][4] = {
      /* R  G  B  A */
@@ -592,9 +589,7 @@ driCreateConfigs(GLenum fb_format, GLenum fb_type,
    int index;
    __DRIconfig **configs, **c;
    __GLcontextModes *modes;
-   unsigned i;
-   unsigned j;
-   unsigned k;
+   unsigned i, j, k, h;
    unsigned num_modes;
    unsigned num_accum_bits = 2;
 
@@ -675,66 +670,74 @@ driCreateConfigs(GLenum fb_format, GLenum fb_type,
     c = configs;
     for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
        for ( i = 0 ; i < num_db_modes ; i++ ) {
-           for ( j = 0 ; j < num_accum_bits ; j++ ) {
-               *c = _mesa_malloc (sizeof **c);
-               modes = &(*c)->modes;
-               c++;
-
-               memset(modes, 0, sizeof *modes);
-               modes->redBits   = bits[0];
-               modes->greenBits = bits[1];
-               modes->blueBits  = bits[2];
-               modes->alphaBits = bits[3];
-               modes->redMask   = masks[0];
-               modes->greenMask = masks[1];
-               modes->blueMask  = masks[2];
-               modes->alphaMask = masks[3];
-               modes->rgbBits   = modes->redBits + modes->greenBits
-                   + modes->blueBits + modes->alphaBits;
-
-               modes->accumRedBits   = 16 * j;
-               modes->accumGreenBits = 16 * j;
-               modes->accumBlueBits  = 16 * j;
-               modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
-               modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
-
-               modes->stencilBits = stencil_bits[k];
-               modes->depthBits = depth_bits[k];
-
-               modes->transparentPixel = GLX_NONE;
-               modes->transparentRed = GLX_DONT_CARE;
-               modes->transparentGreen = GLX_DONT_CARE;
-               modes->transparentBlue = GLX_DONT_CARE;
-               modes->transparentAlpha = GLX_DONT_CARE;
-               modes->transparentIndex = GLX_DONT_CARE;
-               modes->visualType = GLX_DONT_CARE;
-               modes->renderType = GLX_RGBA_BIT;
-               modes->drawableType = GLX_WINDOW_BIT;
-               modes->rgbMode = GL_TRUE;
-
-               if ( db_modes[i] == GLX_NONE ) {
-                   modes->doubleBufferMode = GL_FALSE;
-               }
-               else {
-                   modes->doubleBufferMode = GL_TRUE;
-                   modes->swapMethod = db_modes[i];
-               }
-
-               modes->haveAccumBuffer = ((modes->accumRedBits +
+           for ( h = 0 ; h < num_msaa_modes; h++ ) {
+               for ( j = 0 ; j < num_accum_bits ; j++ ) {
+                   *c = _mesa_malloc (sizeof **c);
+                   modes = &(*c)->modes;
+                   c++;
+
+                   memset(modes, 0, sizeof *modes);
+                   modes->redBits   = bits[0];
+                   modes->greenBits = bits[1];
+                   modes->blueBits  = bits[2];
+                   modes->alphaBits = bits[3];
+                   modes->redMask   = masks[0];
+                   modes->greenMask = masks[1];
+                   modes->blueMask  = masks[2];
+                   modes->alphaMask = masks[3];
+                   modes->rgbBits   = modes->redBits + modes->greenBits
+                       + modes->blueBits + modes->alphaBits;
+
+                   modes->accumRedBits   = 16 * j;
+                   modes->accumGreenBits = 16 * j;
+                   modes->accumBlueBits  = 16 * j;
+                   modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
+                   modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
+
+                   modes->stencilBits = stencil_bits[k];
+                   modes->depthBits = depth_bits[k];
+
+                   modes->transparentPixel = GLX_NONE;
+                   modes->transparentRed = GLX_DONT_CARE;
+                   modes->transparentGreen = GLX_DONT_CARE;
+                   modes->transparentBlue = GLX_DONT_CARE;
+                   modes->transparentAlpha = GLX_DONT_CARE;
+                   modes->transparentIndex = GLX_DONT_CARE;
+                   modes->visualType = GLX_DONT_CARE;
+                   modes->renderType = GLX_RGBA_BIT;
+                   modes->drawableType = GLX_WINDOW_BIT;
+                   modes->rgbMode = GL_TRUE;
+
+                   if ( db_modes[i] == GLX_NONE ) {
+                       modes->doubleBufferMode = GL_FALSE;
+                   }
+                   else {
+                       modes->doubleBufferMode = GL_TRUE;
+                       modes->swapMethod = db_modes[i];
+                   }
+
+                   modes->samples = msaa_samples[h];
+                   modes->sampleBuffers = modes->samples ? 1 : 0;
+
+
+                   modes->haveAccumBuffer = ((modes->accumRedBits +
                                           modes->accumGreenBits +
                                           modes->accumBlueBits +
                                           modes->accumAlphaBits) > 0);
-               modes->haveDepthBuffer = (modes->depthBits > 0);
-               modes->haveStencilBuffer = (modes->stencilBits > 0);
-
-               modes->bindToTextureRgb = GL_TRUE;
-               modes->bindToTextureRgba = GL_TRUE;
-               modes->bindToMipmapTexture = GL_FALSE;
-               modes->bindToTextureTargets = modes->rgbMode ?
-                   __DRI_ATTRIB_TEXTURE_1D_BIT |
-                   __DRI_ATTRIB_TEXTURE_2D_BIT |
-                   __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT :
-                   0;
+                   modes->haveDepthBuffer = (modes->depthBits > 0);
+                   modes->haveStencilBuffer = (modes->stencilBits > 0);
+
+                   modes->bindToTextureRgb = GL_TRUE;
+                   modes->bindToTextureRgba = GL_TRUE;
+                   modes->bindToMipmapTexture = GL_FALSE;
+                   modes->bindToTextureTargets = modes->rgbMode ?
+                       __DRI_ATTRIB_TEXTURE_1D_BIT |
+                       __DRI_ATTRIB_TEXTURE_2D_BIT |
+                       __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT :
+                       0;
+
+                   modes = modes->next;
+               }
            }
        }
     }
index 9ac3b51447d05fdbd7a6923db89e25f5431887e3..32a420060db34ce529ee7cbcf52fc59a78978b94 100644 (file)
@@ -129,9 +129,10 @@ struct __DRIconfigRec {
 
 extern __DRIconfig **
 driCreateConfigs(GLenum fb_format, GLenum fb_type,
-                const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
+                const uint8_t * depth_bits, const uint8_t * stencil_bits,
                 unsigned num_depth_stencil_bits,
-                const GLenum * db_modes, unsigned num_db_modes);
+                const GLenum * db_modes, unsigned num_db_modes,
+                const uint8_t * msaa_samples, unsigned num_msaa_modes);
 
 const __DRIconfig **driConcatConfigs(__DRIconfig **a, __DRIconfig **b);