[Mesa-dev] [PATCH 1/2] mesa: Fix texture target validation for glFramebufferTexture()

Jordan Justen jljusten at gmail.com
Wed Nov 20 00:40:43 PST 2013


Whoops, this was on my todo list. Sorry I missed getting it fixed. :(

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

On Tue, Nov 19, 2013 at 11:02 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> Previously we were using the code path for validating
> glFramebufferTextureLayer().  But glFramebufferTexture() allows
> additional texture types.
>
> Fixes piglit tests:
> - spec/!OpenGL 3.2/layered-rendering/gl-layer-cube-map
> - spec/!OpenGL 3.2/layered-rendering/framebuffertexture
>
> Cc: "10.0" <mesa-stable at lists.freedesktop.org>
> ---
>  src/mesa/main/fbobject.c | 50 ++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 9dd7161..2feb4c3 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -2334,16 +2334,46 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
>        texObj = _mesa_lookup_texture(ctx, texture);
>        if (texObj != NULL) {
>           if (textarget == 0) {
> -            /* If textarget == 0 it means we're being called by
> -             * glFramebufferTextureLayer() and textarget is not used.
> -             * The only legal texture types for that function are 3D and
> -             * 1D/2D arrays textures.
> -             */
> -            err = (texObj->Target != GL_TEXTURE_3D) &&
> -                (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
> -                (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
> -                (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
> -                (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
> +            if (layered) {
> +               /* We're being called by glFramebufferTexture() and textarget
> +                * is not used.
> +                */
> +               switch (texObj->Target) {
> +               case GL_TEXTURE_3D:
> +               case GL_TEXTURE_1D_ARRAY_EXT:
> +               case GL_TEXTURE_2D_ARRAY_EXT:
> +               case GL_TEXTURE_CUBE_MAP:
> +               case GL_TEXTURE_CUBE_MAP_ARRAY:
> +               case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> +                  err = false;
> +                  break;
> +               case GL_TEXTURE_1D:
> +               case GL_TEXTURE_2D:
> +               case GL_TEXTURE_RECTANGLE:
> +               case GL_TEXTURE_2D_MULTISAMPLE:
> +                  /* These texture types are valid to pass to
> +                   * glFramebufferTexture(), but since they aren't layered, it
> +                   * is equivalent to calling glFramebufferTexture{1D,2D}().
> +                   */
> +                  err = false;
> +                  layered = false;
> +                  textarget = texObj->Target;
> +                  break;
> +               default:
> +                  err = true;
> +                  break;
> +               }
> +            } else {
> +               /* We're being called by glFramebufferTextureLayer() and
> +                * textarget is not used.  The only legal texture types for
> +                * that function are 3D and 1D/2D arrays textures.
> +                */
> +               err = (texObj->Target != GL_TEXTURE_3D) &&
> +                  (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
> +                  (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
> +                  (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
> +                  (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
> +            }
>           }
>           else {
>              /* Make sure textarget is consistent with the texture's type */
> --
> 1.8.4.2
>
> _______________________________________________
> 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