[Mesa-dev] [PATCH] mesa/gles: adjust internal format in glTexSubImage2D error checks

Tapani Pälli tapani.palli at intel.com
Tue Nov 21 07:27:17 UTC 2017


Forgot to add:

Cc: "17.3" <mesa-stable at lists.freedesktop.org>

On 11/21/2017 08:35 AM, Tapani Pälli wrote:
> When floating point textures are created on OpenGL ES 2.0, driver
> is free to choose used internal format. Mesa makes this decision in
> adjust_for_oes_float_texture. Error checking for glTexImage2D properly
> checks that sized formats are not used. We use same error checking
> path for glTexSubImage2D (since there is lot of overlap), however since
> those checks include internalFormat checks, we need to pass original
> internalFormat passed by the client. Patch adds oes_float_internal_format
> that does reverse adjust_for_oes_float_texture to get that format.
> 
> Fixes following test failure:
>     ES2-CTS.gtf.GL2ExtensionTests.texture_float.texture_float
> 
> (when running test with MESA_GLES_VERSION_OVERRIDE=2.0)
> 
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103227
> ---
>   src/mesa/main/teximage.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 55 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 4ec6148bf4..d7643a52df 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -122,6 +122,56 @@ adjust_for_oes_float_texture(const struct gl_context *ctx,
>      return format;
>   }
>   
> +/**
> + * Returns a corresponding base format for a given internal floating point
> + * format as specifed by OES_texture_float.
> + */
> +static GLenum
> +oes_float_internal_format(const struct gl_context *ctx,
> +                          GLenum format, GLenum type)
> +{
> +   switch (type) {
> +   case GL_FLOAT:
> +      if (ctx->Extensions.OES_texture_float) {
> +         switch (format) {
> +         case GL_RGBA32F:
> +            return GL_RGBA;
> +         case GL_RGB32F:
> +            return GL_RGB;
> +         case GL_ALPHA32F_ARB:
> +            return GL_ALPHA;
> +         case GL_LUMINANCE32F_ARB:
> +            return GL_LUMINANCE;
> +         case GL_LUMINANCE_ALPHA32F_ARB:
> +            return GL_LUMINANCE_ALPHA;
> +         default:
> +            break;
> +         }
> +      }
> +      break;
> +
> +   case GL_HALF_FLOAT_OES:
> +      if (ctx->Extensions.OES_texture_half_float) {
> +         switch (format) {
> +         case GL_RGBA16F:
> +            return GL_RGBA;
> +         case GL_RGB16F:
> +            return GL_RGB;
> +         case GL_ALPHA16F_ARB:
> +            return GL_ALPHA;
> +         case GL_LUMINANCE16F_ARB:
> +            return GL_LUMINANCE;
> +         case GL_LUMINANCE_ALPHA16F_ARB:
> +            return GL_LUMINANCE_ALPHA;
> +         default:
> +            break;
> +         }
> +      }
> +      break;
> +   }
> +   return format;
> +}
> +
>   
>   /**
>    * Install gl_texture_image in a gl_texture_object according to the target
> @@ -2155,6 +2205,10 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
>         return GL_TRUE;
>      }
>   
> +   GLenum internalFormat = _mesa_is_gles(ctx) ?
> +      oes_float_internal_format(ctx, texImage->InternalFormat, type) :
> +      texImage->InternalFormat;
> +
>      /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
>       * combinations of format, internalFormat, and type that can be used.
>       * Formats and types that require additional extensions (e.g., GL_FLOAT
> @@ -2162,7 +2216,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
>       */
>      if (_mesa_is_gles(ctx) &&
>          texture_format_error_check_gles(ctx, format, type,
> -                                       texImage->InternalFormat,
> +                                       internalFormat,
>                                          dimensions, callerName)) {
>         return GL_TRUE;
>      }
> 


More information about the mesa-dev mailing list