[Mesa-dev] [PATCH V2 13/22] mesa: support multisample textures in framebuffer completeness check

Chris Forbes chrisf at ijw.co.nz
Mon Feb 4 21:48:47 PST 2013


- sample count must be the same on all attachments
- fixedsamplepositions must be the same on all attachments
(renderbuffers have fixedsamplepositions=true implicitly; only
multisample textures can choose to have it false)
- stencil-only formats become legal.

V2: - fix wrapping to 80 columns, debug message, fix for state moving
      from texobj to image.
    - stencil texturing tweaks tidied up and folded in here.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/main/fbobject.c | 50 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index d9fd78e..089fa84 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -575,6 +575,7 @@ is_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat)
    switch (baseFormat) {
    case GL_DEPTH_COMPONENT:
    case GL_DEPTH_STENCIL_EXT:
+   case GL_STENCIL_INDEX:
       return GL_TRUE;
    default:
       return GL_FALSE;
@@ -664,8 +665,11 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
              baseFormat == GL_DEPTH_STENCIL_EXT) {
             /* OK */
          }
+         else if (ctx->Extensions.ARB_texture_multisample &&
+               baseFormat == GL_STENCIL_INDEX) {
+            /* OK */
+         }
          else {
-            /* no such thing as stencil-only textures */
             att_incomplete("illegal stencil texture");
             att->Complete = GL_FALSE;
             return;
@@ -745,6 +749,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
    GLenum intFormat = GL_NONE; /* color buffers' internal format */
    GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0;
    GLint numSamples = -1;
+   GLint fixedSampleLocations = -1;
    GLint i;
    GLuint j;
 
@@ -766,6 +771,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
       struct gl_renderbuffer_attachment *att;
       GLenum f;
       gl_format attFormat;
+      struct gl_texture_image *texImg = NULL;
 
       /*
        * XXX for ARB_fbo, only check color buffers that are named by
@@ -805,8 +811,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
       /* get width, height, format of the renderbuffer/texture
        */
       if (att->Type == GL_TEXTURE) {
-         const struct gl_texture_image *texImg =
-            _mesa_get_attachment_teximage(att);
+         texImg = _mesa_get_attachment_teximage(att);
          minWidth = MIN2(minWidth, texImg->Width);
          maxWidth = MAX2(maxWidth, texImg->Width);
          minHeight = MIN2(minHeight, texImg->Height);
@@ -814,12 +819,19 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
          f = texImg->_BaseFormat;
          attFormat = texImg->TexFormat;
          numImages++;
+
          if (!is_format_color_renderable(ctx, attFormat, texImg->InternalFormat) &&
              !is_legal_depth_format(ctx, f)) {
             fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
             fbo_incomplete("texture attachment incomplete", -1);
             return;
          }
+
+         if (numSamples < 0)
+            numSamples = texImg->NumSamples;
+
+         if (fixedSampleLocations < 0)
+            fixedSampleLocations = texImg->FixedSampleLocations;
       }
       else if (att->Type == GL_RENDERBUFFER_EXT) {
          minWidth = MIN2(minWidth, att->Renderbuffer->Width);
@@ -829,21 +841,23 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
          f = att->Renderbuffer->InternalFormat;
          attFormat = att->Renderbuffer->Format;
          numImages++;
+
+         if (numSamples < 0)
+            numSamples = att->Renderbuffer->NumSamples;
+
+         /* RENDERBUFFER has fixedSampleLocations implicitly true */
+         if (fixedSampleLocations < 0)
+            fixedSampleLocations = GL_TRUE;
       }
       else {
          assert(att->Type == GL_NONE);
          continue;
       }
 
-      if (att->Renderbuffer && numSamples < 0) {
-         /* first buffer */
-         numSamples = att->Renderbuffer->NumSamples;
-      }
-
       /* check if integer color */
       fb->_IntegerColor = _mesa_is_format_integer_color(attFormat);
 
-      /* Error-check width, height, format, samples
+      /* Error-check width, height, format, samples, fixedSampleLocations
        */
       if (numImages == 1) {
          /* save format, num samples */
@@ -866,10 +880,22 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
                return;
             }
          }
-         if (att->Renderbuffer &&
-             att->Renderbuffer->NumSamples != numSamples) {
+
+         if ((att->Type == GL_RENDERBUFFER &&
+                  att->Renderbuffer->NumSamples != numSamples) ||
+             (att->Type == GL_TEXTURE &&
+              texImg->NumSamples != numSamples)) {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
+            fbo_incomplete("inconsistent number of samples", i);
+            return;
+         }
+
+         if ((att->Type == GL_RENDERBUFFER &&
+               GL_TRUE != fixedSampleLocations) ||
+             (att->Type == GL_TEXTURE &&
+               texImg->FixedSampleLocations != fixedSampleLocations)) {
             fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
-            fbo_incomplete("inconsistant number of samples", i);
+            fbo_incomplete("inconsistent fixed sample locations", i);
             return;
          }
       }
-- 
1.8.1.2



More information about the mesa-dev mailing list