mesa: plug in fallback function for ctx->Driver.ValidateFramebuffer()
authorBrian Paul <brianp@vmware.com>
Tue, 25 Jan 2011 02:38:52 +0000 (19:38 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 25 Jan 2011 02:38:52 +0000 (19:38 -0700)
The software renderer doesn't support GL_ALPHA, GL_LUMINANCE, etc
so we should report GL_FRAMEBUFFER_UNSUPPORTED during FBO validation.

src/mesa/drivers/common/driverfuncs.c
src/mesa/main/fbobject.c
src/mesa/main/fbobject.h
src/mesa/main/renderbuffer.c

index 3c6ecb83f0aa18cbc1f7dd78da0160e8a2a19784..5389a500111aa40939ad2fa5445ca6a3855970f7 100644 (file)
@@ -184,6 +184,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->RenderTexture = _mesa_render_texture;
    driver->FinishRenderTexture = _mesa_finish_render_texture;
    driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+   driver->ValidateFramebuffer = _mesa_validate_framebuffer;
 
    driver->BlitFramebuffer = _swrast_BlitFramebuffer;
 
index ff9dcc9ca6621143af1fdcabfebe1b7bf84f99a4..17b768dc84794d8a44e46374fb9d2bf2cab87acd 100644 (file)
@@ -372,6 +372,35 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
 }
 
 
+/**
+ * Fallback for ctx->Driver.ValidateFramebuffer()
+ * Check if the renderbuffer's formats are supported by the software
+ * renderer.
+ * Drivers should probably override this.
+ */
+void
+_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+   gl_buffer_index buf;
+   for (buf = 0; buf < BUFFER_COUNT; buf++) {
+      const struct gl_renderbuffer *rb = fb->Attachment[buf].Renderbuffer;
+      if (rb) {
+         switch (rb->_BaseFormat) {
+         case GL_ALPHA:
+         case GL_LUMINANCE_ALPHA:
+         case GL_LUMINANCE:
+         case GL_INTENSITY:
+            fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED;
+            return;
+         default:
+            /* render buffer format is supported by software rendering */
+            ;
+         }
+      }
+   }
+}
+
+
 /**
  * For debug only.
  */
index 8763f99c4a7312b3cef5b2db97aaf35f8e18a3ff..ba74a95b74c85f6ff9e83a58cec5899092818a09 100644 (file)
@@ -68,6 +68,9 @@ extern void
 _mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
                                GLenum attachment, struct gl_renderbuffer *rb);
 
+extern void
+_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
+
 extern void
 _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb);
 
index 23c662bab7fe1b02140b7cf691993cd51cf48895..67ee589d77665def695658dc2c1be90b7feec5a9 100644 (file)
@@ -1086,7 +1086,7 @@ _mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *
       pixelSize = sizeof(GLuint);
       break;
    default:
-      _mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage");
+      /* unsupported format */
       return GL_FALSE;
    }