From f583745519b2b99ca637cdfa6201fd653c848fd6 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 30 Jul 2009 12:34:02 +0200 Subject: 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 --- src/mesa/state_tracker/st_cb_fbo.c | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index ecdb988033..a96602878e 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -445,6 +445,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; + } } } -- cgit v1.2.3