New patch here:<br><br>    gallium: add a CAP for mixed colorbuffer format support<br>    <br>    Some GPUs can&#39;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>          &amp;fb-&gt;Attachment[BUFFER_STENCIL];<br>    GLuint i;<br>+   enum pipe_format first_format = PIPE_FORMAT_NONE;<br>+   boolean mixed_formats =<br>+         screen-&gt;get_param(screen, PIPE_CAP_MIXED_COLORBUFFER_FORMATS) != 0;<br>

 <br>    if (depth-&gt;Type &amp;&amp; stencil-&gt;Type &amp;&amp; depth-&gt;Type != stencil-&gt;Type) {<br>       fb-&gt;_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 &lt; ctx-&gt;Const.MaxColorAttachments; i++) {<br>+      struct gl_renderbuffer_attachment *att =<br>+            &amp;fb-&gt;Attachment[BUFFER_COLOR0 + i];<br>+      enum pipe_format format;<br>

+<br>       if (!st_validate_attachment(ctx,<br>                                   screen,<br>-                                 &amp;fb-&gt;Attachment[BUFFER_COLOR0 + i],<br>+                                 att,<br>                                  PIPE_BIND_RENDER_TARGET)) {<br>

         fb-&gt;_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>         return;<br>       }<br>+<br>+      if (!mixed_formats) {<br>+         /* Disallow mixed formats. */<br>+         if (att-&gt;Type != GL_NONE) {<br>+            format = st_renderbuffer(att-&gt;Renderbuffer)-&gt;surface-&gt;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-&gt;_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">&lt;<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a>&gt;</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>
&gt; Some GPUs can&#39;t do it (I think most of DX9 ones).<br>
&gt;<br>
&gt; 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&#39;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&#39;d rather avoid breaking applications that use this feature for an<br>
undefined amount of time.<br>
<div><div></div><div class="h5"><br>
&gt; ---<br>
&gt;  src/mesa/state_tracker/st_cb_fbo.c |   21 ++++++++++++++++++++-<br>
&gt;  1 files changed, 20 insertions(+), 1 deletions(-)<br>
&gt;<br>
&gt; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c<br>
&gt; index 0df0428..e1057b1 100644<br>
&gt; --- a/src/mesa/state_tracker/st_cb_fbo.c<br>
&gt; +++ b/src/mesa/state_tracker/st_cb_fbo.c<br>
&gt; @@ -529,6 +529,7 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)<br>
&gt;     const struct gl_renderbuffer_attachment *stencil =<br>
&gt;           &amp;fb-&gt;Attachment[BUFFER_STENCIL];<br>
&gt;     GLuint i;<br>
&gt; +   enum pipe_format first_format = PIPE_FORMAT_NONE;<br>
&gt;<br>
&gt;     if (depth-&gt;Type &amp;&amp; stencil-&gt;Type &amp;&amp; depth-&gt;Type != stencil-&gt;Type) {<br>
&gt;        fb-&gt;_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
&gt; @@ -562,13 +563,31 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)<br>
&gt;        return;<br>
&gt;     }<br>
&gt;     for (i = 0; i &lt; ctx-&gt;Const.MaxColorAttachments; i++) {<br>
&gt; +      struct gl_renderbuffer_attachment *att =<br>
&gt; +            &amp;fb-&gt;Attachment[BUFFER_COLOR0 + i];<br>
&gt; +      enum pipe_format format;<br>
&gt; +<br>
&gt;        if (!st_validate_attachment(ctx,<br>
&gt;                                    screen,<br>
&gt; -                               &amp;fb-&gt;Attachment[BUFFER_COLOR0 + i],<br>
&gt; +                               att,<br>
&gt;                                 PIPE_BIND_RENDER_TARGET)) {<br>
&gt;        fb-&gt;_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
&gt;        return;<br>
&gt;        }<br>
&gt; +<br>
&gt; +      /* Disallow mixed formats. This may be revisited later. */<br>
&gt; +      if (att-&gt;Type != GL_NONE) {<br>
&gt; +         format = st_renderbuffer(att-&gt;Renderbuffer)-&gt;surface-&gt;format;<br>
&gt; +      } else {<br>
&gt; +         continue;<br>
&gt; +      }<br>
&gt; +<br>
&gt; +      if (first_format == PIPE_FORMAT_NONE) {<br>
&gt; +         first_format = format;<br>
&gt; +      } else if (format != first_format) {<br>
&gt; +         fb-&gt;_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;<br>
&gt; +         return;<br>
&gt; +      }<br>
&gt;     }<br>
&gt;  }<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>