From 25f26997670302b07d48207b28f385f85f6af9bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 28 Mar 2011 02:28:48 +0200 Subject: [PATCH] gallium: add a CAP for mixed colorbuffer format support Some GPUs can't do it (I think most of DX9 ones), so they should have the option not to allow it. --- src/gallium/include/pipe/p_defines.h | 1 + src/mesa/state_tracker/st_cb_fbo.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 4c1879c7c24..431a7fb6695 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -464,6 +464,7 @@ enum pipe_cap { PIPE_CAP_TGSI_INSTANCEID = 43, PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR = 44, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL = 45, + PIPE_CAP_MIXED_COLORBUFFER_FORMATS = 46, }; /* Shader caps not specific to any single stage */ diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 0df04287ae6..7ffee901cdb 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -529,6 +529,9 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) const struct gl_renderbuffer_attachment *stencil = &fb->Attachment[BUFFER_STENCIL]; GLuint i; + enum pipe_format first_format = PIPE_FORMAT_NONE; + boolean mixed_formats = + screen->get_param(screen, PIPE_CAP_MIXED_COLORBUFFER_FORMATS) != 0; if (depth->Type && stencil->Type && depth->Type != stencil->Type) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; @@ -562,13 +565,33 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) return; } for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { + struct gl_renderbuffer_attachment *att = + &fb->Attachment[BUFFER_COLOR0 + i]; + enum pipe_format format; + if (!st_validate_attachment(ctx, screen, - &fb->Attachment[BUFFER_COLOR0 + i], + att, PIPE_BIND_RENDER_TARGET)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } + + if (!mixed_formats) { + /* Disallow mixed formats. */ + if (att->Type != GL_NONE) { + format = st_renderbuffer(att->Renderbuffer)->surface->format; + } else { + continue; + } + + if (first_format == PIPE_FORMAT_NONE) { + first_format = format; + } else if (format != first_format) { + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; + return; + } + } } } -- 2.30.2