[Mesa-dev] [PATCH] st/mesa: disallow mixed formats in a FBO

Julian Adams joolsa at gmail.com
Mon Mar 28 02:37:24 PDT 2011


That's a shame. I use that feature and it works (Gallium says I have
an AMD RS780). As I read the GL_EXT_framebuffer_object it implies the
(internal) format is the same for each rendertarget, the
GL_ARB_framebuffer_object relaxes this. Both specs allow
implementation-dependent additional restrictions though. Could the
Gallium drivers return this as a flag?

On 28 March 2011 01:51, Marek Olšák <maraeo at gmail.com> wrote:
> Some GPUs can't do it (I think most of DX9 ones).
>
> We should later decide how Gallium will expose this feature.
> ---
>  src/mesa/state_tracker/st_cb_fbo.c |   21 ++++++++++++++++++++-
>  1 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
> index 0df0428..e1057b1 100644
> --- a/src/mesa/state_tracker/st_cb_fbo.c
> +++ b/src/mesa/state_tracker/st_cb_fbo.c
> @@ -529,6 +529,7 @@ 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;
>
>    if (depth->Type && stencil->Type && depth->Type != stencil->Type) {
>       fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
> @@ -562,13 +563,31 @@ 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;
>       }
> +
> +      /* Disallow mixed formats. This may be revisited later. */
> +      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;
> +      }
>    }
>  }
>
> --
> 1.7.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>


More information about the mesa-dev mailing list