Mesa (master): mesa st: Report unsupported render-to-texture formats.

Thomas Hellstrom thomash at kemper.freedesktop.org
Thu Jul 30 10:44:36 UTC 2009


Module: Mesa
Branch: master
Commit: f583745519b2b99ca637cdfa6201fd653c848fd6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f583745519b2b99ca637cdfa6201fd653c848fd6

Author: Thomas Hellstrom <thellstrom at vmware.com>
Date:   Thu Jul 30 12:34:02 2009 +0200

mesa st: Report unsupported render-to-texture formats.

If a texture image is bound to a framebuffer for render-to-texture, but
the hardware doesn't support rendering to its internal format,
report the framebuffer as incomplete with FRAMEBUFFER_UNSUPPORTED.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>

---

 src/mesa/state_tracker/st_cb_fbo.c |   53 ++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index ecdb988..a966028 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -446,6 +446,35 @@ st_finish_render_texture(GLcontext *ctx,
 
 
 /**
+ * Validate a renderbuffer attachment for a particular usage.
+ */
+
+static GLboolean
+st_validate_attachment(struct pipe_screen *screen,
+		       const struct gl_renderbuffer_attachment *att,
+		       GLuint usage)
+{
+   const struct st_texture_object *stObj =
+      st_texture_object(att->Texture);
+
+   /**
+    * Only validate texture attachments for now, since
+    * st_renderbuffer_alloc_storage makes sure that
+    * the format is supported.
+    */
+
+   if (att->Type != GL_TEXTURE)
+      return GL_TRUE;
+
+   if (!stObj)
+      return GL_FALSE;
+
+   return screen->is_format_supported(screen, stObj->pt->format,
+				      PIPE_TEXTURE_2D,
+				      usage, 0);
+}
+
+/**
  * Check that the framebuffer configuration is valid in terms of what
  * the driver can support.
  *
@@ -454,13 +483,37 @@ st_finish_render_texture(GLcontext *ctx,
 static void
 st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
 {
+   struct pipe_screen *screen = ctx->st->pipe->screen;
    const struct gl_renderbuffer *depthRb =
       fb->Attachment[BUFFER_DEPTH].Renderbuffer;
    const struct gl_renderbuffer *stencilRb =
       fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+   GLuint i;
 
    if (stencilRb && depthRb && stencilRb != depthRb) {
       fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+      return;
+   }
+
+   if (!st_validate_attachment(screen,
+			       &fb->Attachment[BUFFER_DEPTH],
+			       PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) {
+      fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+      return;
+   }
+   if (!st_validate_attachment(screen,
+			       &fb->Attachment[BUFFER_STENCIL],
+			       PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) {
+      fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+      return;
+   }
+   for (i = 0; i < ctx->Const.MaxColorAttachments; i++) {
+      if (!st_validate_attachment(screen,
+				  &fb->Attachment[BUFFER_COLOR0 + i],
+				  PIPE_TEXTURE_USAGE_RENDER_TARGET)) {
+	 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+	 return;
+      }
    }
 }
 




More information about the mesa-commit mailing list