[Mesa-dev] [PATCH 2/4] mesa: Don't call driver RenderTexture for really broken textures

Jordan Justen jljusten at gmail.com
Sun Jul 28 15:24:55 PDT 2013


On Sun, Jul 28, 2013 at 12:56 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> This fixes the segfault in the '0x0 texture' subtest of piglit's
> fbo-incomplete test.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: mesa-stable at lists.freedesktop.org
> ---
>  src/mesa/main/fbobject.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index a55b56c..f10af41 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -343,6 +343,22 @@ _mesa_remove_attachment(struct gl_context *ctx,
>  }
>
>  /**
> + * Verify a couple error conditions that will lead to an incomplete FBO and
> + * may cause problems for the driver's RenderTexture path.
> + */
> +static bool
> +driver_RenderTexture_is_safe(const struct gl_renderbuffer_attachment *att)
> +{
> +   const struct gl_texture_image *const texImage =
> +      att->Texture->Image[att->CubeMapFace][att->TextureLevel];
> +
> +   if (texImage->Width == 0 || texImage->Height == 0 || texImage->Depth == 0)
> +      return false;
> +
> +   return true;
> +}
> +
> +/**
>   * Create a renderbuffer which will be set up by the driver to wrap the
>   * texture image slice.
>   *
> @@ -391,7 +407,8 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
>     rb->NumSamples = texImage->NumSamples;
>     rb->TexImage = texImage;
>
> -   ctx->Driver.RenderTexture(ctx, fb, att);
> +   if (driver_RenderTexture_is_safe(att))
> +      ctx->Driver.RenderTexture(ctx, fb, att);

Should !driver_RenderTexture_is_safe generate an error?

Or will not having called ctx->Driver.RenderTexture lead to the error
at a later point?

-Jordan

>  }
>
>  /**
> @@ -1891,7 +1908,8 @@ check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
>
>     for (i = 0; i < BUFFER_COUNT; i++) {
>        struct gl_renderbuffer_attachment *att = fb->Attachment + i;
> -      if (att->Texture && att->Renderbuffer->TexImage) {
> +      if (att->Texture && att->Renderbuffer->TexImage
> +          && driver_RenderTexture_is_safe(att)) {
>           ctx->Driver.RenderTexture(ctx, fb, att);
>        }
>     }
> --
> 1.8.1.4
>
> _______________________________________________
> 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