New patch here:<br><br> gallium: add a CAP for mixed colorbuffer format support<br> <br> Some GPUs can't do it (I think most of DX9 ones), so they should have<br> the option not to allow it.<br><br>diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index 1c1a8f2..0f0ca39 100644<br>--- a/src/gallium/include/pipe/p_defines.h<br>+++ b/src/gallium/include/pipe/p_defines.h<br>@@ -463,7 +463,8 @@ enum pipe_cap {<br> PIPE_CAP_SHADER_STENCIL_EXPORT,<br> PIPE_CAP_TGSI_INSTANCEID,<br>
PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR,<br>- PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL<br>+ PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL,<br>+ PIPE_CAP_MIXED_COLORBUFFER_FORMATS,<br> };<br> <br> /* Shader caps not specific to any single stage */<br>
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c<br>index 0df0428..7ffee90 100644<br>--- a/src/mesa/state_tracker/st_cb_fbo.c<br>+++ b/src/mesa/state_tracker/st_cb_fbo.c<br>@@ -529,6 +529,9 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer<br>
const struct gl_renderbuffer_attachment *stencil =<br> &fb->Attachment[BUFFER_STENCIL];<br> GLuint i;<br>+ enum pipe_format first_format = PIPE_FORMAT_NONE;<br>+ boolean mixed_formats =<br>+ screen->get_param(screen, PIPE_CAP_MIXED_COLORBUFFER_FORMATS) != 0;<br>
<br> if (depth->Type && stencil->Type && depth->Type != stencil->Type) {<br> fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>@@ -562,13 +565,33 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuff<br>
return;<br> }<br> for (i = 0; i < ctx->Const.MaxColorAttachments; i++) {<br>+ struct gl_renderbuffer_attachment *att =<br>+ &fb->Attachment[BUFFER_COLOR0 + i];<br>+ enum pipe_format format;<br>
+<br> if (!st_validate_attachment(ctx,<br> screen,<br>- &fb->Attachment[BUFFER_COLOR0 + i],<br>+ att,<br> PIPE_BIND_RENDER_TARGET)) {<br>
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br> return;<br> }<br>+<br>+ if (!mixed_formats) {<br>+ /* Disallow mixed formats. */<br>+ if (att->Type != GL_NONE) {<br>+ format = st_renderbuffer(att->Renderbuffer)->surface->format;<br>
+ } else {<br>+ continue;<br>+ }<br>+<br>+ if (first_format == PIPE_FORMAT_NONE) {<br>+ first_format = format;<br>+ } else if (format != first_format) {<br>+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
+ return;<br>+ }<br>+ }<br> }<br> }<br><br>Marek<br><br><br><div class="gmail_quote">On Mon, Mar 28, 2011 at 11:27 AM, Christoph Bumiller <span dir="ltr"><<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On 28.03.2011 02:51, Marek Olšák wrote:<br>
> Some GPUs can't do it (I think most of DX9 ones).<br>
><br>
> We should later decide how Gallium will expose this feature.<br>
</div>How about you just add a PIPE_CAP_FRAMEBUFFE_MIXED_FORMATS and<br>
PIPE_CAP_FRAMEBUFFER_MIXED_DIMENSIONS ?<br>
And if those aren't present you only expose GL_EXT_framebuffer_object<br>
and not the ARB version.<br>
<br>
Or alternatively a pipe_context.validate_framebuffer_configuration where<br>
more advanced cards can just return TRUE ?<br>
<br>
I'd rather avoid breaking applications that use this feature for an<br>
undefined amount of time.<br>
<div><div></div><div class="h5"><br>
> ---<br>
> src/mesa/state_tracker/st_cb_fbo.c | 21 ++++++++++++++++++++-<br>
> 1 files changed, 20 insertions(+), 1 deletions(-)<br>
><br>
> diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c<br>
> index 0df0428..e1057b1 100644<br>
> --- a/src/mesa/state_tracker/st_cb_fbo.c<br>
> +++ b/src/mesa/state_tracker/st_cb_fbo.c<br>
> @@ -529,6 +529,7 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)<br>
> const struct gl_renderbuffer_attachment *stencil =<br>
> &fb->Attachment[BUFFER_STENCIL];<br>
> GLuint i;<br>
> + enum pipe_format first_format = PIPE_FORMAT_NONE;<br>
><br>
> if (depth->Type && stencil->Type && depth->Type != stencil->Type) {<br>
> fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
> @@ -562,13 +563,31 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)<br>
> return;<br>
> }<br>
> for (i = 0; i < ctx->Const.MaxColorAttachments; i++) {<br>
> + struct gl_renderbuffer_attachment *att =<br>
> + &fb->Attachment[BUFFER_COLOR0 + i];<br>
> + enum pipe_format format;<br>
> +<br>
> if (!st_validate_attachment(ctx,<br>
> screen,<br>
> - &fb->Attachment[BUFFER_COLOR0 + i],<br>
> + att,<br>
> PIPE_BIND_RENDER_TARGET)) {<br>
> fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
> return;<br>
> }<br>
> +<br>
> + /* Disallow mixed formats. This may be revisited later. */<br>
> + if (att->Type != GL_NONE) {<br>
> + format = st_renderbuffer(att->Renderbuffer)->surface->format;<br>
> + } else {<br>
> + continue;<br>
> + }<br>
> +<br>
> + if (first_format == PIPE_FORMAT_NONE) {<br>
> + first_format = format;<br>
> + } else if (format != first_format) {<br>
> + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
> + return;<br>
> + }<br>
> }<br>
> }<br>
><br>
<br>
</div></div></blockquote></div><br>