[Mesa-dev] [PATCH V3 11/19] mesa: support multisample textures in framebuffer completeness check

Chris Forbes chrisf at ijw.co.nz
Fri Feb 8 01:19:08 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)

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.

V3: - Removed silly stencil hacks entirely; the extension doesn't
      actually make stencil-only textures legal at all.
    - Moved sample count / fixed sample locations checks into
      existing attachment-type-specific blocks, as suggested by Eric

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
[V2] Reviewed-by: Paul Berry <stereotype441 at gmail.com>
---
 src/mesa/main/fbobject.c | 60 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index d9fd78e..46663dd 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -664,8 +664,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 +748,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 +770,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 +810,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 +818,29 @@ _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;
+         else if (numSamples != texImg->NumSamples) {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
+            fbo_incomplete("inconsistent sample count", -1);
+            return;
+         }
+
+         if (fixedSampleLocations < 0)
+            fixedSampleLocations = texImg->FixedSampleLocations;
+         else if (fixedSampleLocations != texImg->FixedSampleLocations) {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
+            fbo_incomplete("inconsistent fixed sample locations", -1);
+            return;
+         }
       }
       else if (att->Type == GL_RENDERBUFFER_EXT) {
          minWidth = MIN2(minWidth, att->Renderbuffer->Width);
@@ -829,24 +850,35 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
          f = att->Renderbuffer->InternalFormat;
          attFormat = att->Renderbuffer->Format;
          numImages++;
+
+         if (numSamples < 0)
+            numSamples = att->Renderbuffer->NumSamples;
+         else if (numSamples != att->Renderbuffer->NumSamples) {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
+            fbo_incomplete("inconsistent sample count", -1);
+            return;
+         }
+
+         /* RENDERBUFFER has fixedSampleLocations implicitly true */
+         if (fixedSampleLocations < 0)
+            fixedSampleLocations = GL_TRUE;
+         else if (fixedSampleLocations != GL_TRUE) {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
+            fbo_incomplete("inconsistent fixed sample locations", -1);
+            return;
+         }
       }
       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 */
       if (numImages == 1) {
-         /* save format, num samples */
+         /* save format */
          if (i >= 0) {
             intFormat = f;
          }
@@ -866,12 +898,6 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
                return;
             }
          }
-         if (att->Renderbuffer &&
-             att->Renderbuffer->NumSamples != numSamples) {
-            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
-            fbo_incomplete("inconsistant number of samples", i);
-            return;
-         }
       }
 
       /* Check that the format is valid. (MESA_FORMAT_NONE means unsupported)
-- 
1.8.1.2



More information about the mesa-dev mailing list