mesa: if AllocStorage doesn't choose a format, report FRAMEBUFFER_UNSUPPORTED
authorMarek Olšák <maraeo@gmail.com>
Fri, 15 Jun 2012 15:21:05 +0000 (17:21 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 16 Jun 2012 12:20:26 +0000 (14:20 +0200)
This allows drivers not to do any allocation in AllocStorage if the storage
cannot be allocated because of an unsupported internalformat + samples combo.

The little ugliness is that AllocStorage is expected to return TRUE in this
case.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/fbobject.c

index 777783eb7eee012912c2b0feae2371e56363c6cb..cfaea62bbad604084d8dfa532242f77462fc61eb 100644 (file)
@@ -805,6 +805,15 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
             return;
          }
       }
+
+      /* Check that the format is valid. (MESA_FORMAT_NONE means unsupported)
+       */
+      if (att->Type == GL_RENDERBUFFER &&
+          att->Renderbuffer->Format == MESA_FORMAT_NONE) {
+         fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED;
+         fbo_incomplete("unsupported renderbuffer format", i);
+         return;
+      }
    }
 
 #if FEATURE_GL
@@ -1394,7 +1403,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
    ASSERT(rb->AllocStorage);
    if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
       /* No error - check/set fields now */
-      assert(rb->Format != MESA_FORMAT_NONE);
+      /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */
       assert(rb->Width == (GLuint) width);
       assert(rb->Height == (GLuint) height);
       rb->InternalFormat = internalFormat;