[Mesa-dev] [PATCH] mesa: fix up some texture error checks
Brian Paul
brianp at vmware.com
Thu Jul 16 14:24:07 PDT 2015
On 07/16/2015 03:15 PM, sroland at vmware.com wrote:
> From: Roland Scheidegger <sroland at vmware.com>
>
> In particular, we were incorrectly accepting s3tc (and lots of others)
> for CompressedTexSubImage3D (but not CompressedTexImage3D) calls with 3d
> targets. At this time, the only allowed formats for these calls are the
> bptc ones, since none of the specific extensions allow it (astc hdr would).
> Also, fix up a bug in _mesa_target_can_be_compressed - 3d target needs to
> be allowed for bptc formats.
> ---
> src/mesa/main/teximage.c | 41 ++++++++++++++++++++---------------------
> src/mesa/main/texstorage.c | 1 +
> 2 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 3d85615..4389082 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1793,8 +1793,6 @@ GLboolean
> _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
> GLenum intFormat)
> {
> - (void) intFormat; /* not used yet */
> -
> switch (target) {
> case GL_TEXTURE_2D:
> case GL_PROXY_TEXTURE_2D:
> @@ -1814,6 +1812,16 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
> case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
> case GL_TEXTURE_CUBE_MAP_ARRAY:
> return ctx->Extensions.ARB_texture_cube_map_array;
> + case GL_TEXTURE_3D:
> + switch (intFormat) {
> + case GL_COMPRESSED_RGBA_BPTC_UNORM:
> + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
> + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
> + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
> + return TRUE;
> + default:
> + return FALSE;
> + }
> default:
> return GL_FALSE;
> }
> @@ -4575,32 +4583,23 @@ compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
> * one of the EAC, ETC2, or RGTC formats and either border is
> * non-zero, or the effective target for the texture is not
> * TEXTURE_2D_ARRAY."
> + * Instead of listing all these, just list those which are allowed,
> + * which is (at this time) only bptc. Otherwise we'd say s3tc (and more)
> + * are valid here, which they are not, but of course not mentioned by
> + * core spec.
> */
> if (target != GL_TEXTURE_2D_ARRAY) {
> bool invalidformat;
> switch (format) {
> /* These came from _mesa_is_compressed_format in glformats.c. */
> - /* EAC formats */
> - case GL_COMPRESSED_RGBA8_ETC2_EAC:
> - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
> - case GL_COMPRESSED_R11_EAC:
> - case GL_COMPRESSED_RG11_EAC:
> - case GL_COMPRESSED_SIGNED_R11_EAC:
> - case GL_COMPRESSED_SIGNED_RG11_EAC:
> - /* ETC2 formats */
> - case GL_COMPRESSED_RGB8_ETC2:
> - case GL_COMPRESSED_SRGB8_ETC2:
> - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
> - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
> - /* RGTC formats */
> - case GL_COMPRESSED_RED_RGTC1:
> - case GL_COMPRESSED_SIGNED_RED_RGTC1:
> - case GL_COMPRESSED_RG_RGTC2:
> - case GL_COMPRESSED_SIGNED_RG_RGTC2:
> - invalidformat = true;
> + case GL_COMPRESSED_RGBA_BPTC_UNORM:
> + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
> + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
> + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
> + invalidformat = false;
> break;
> default:
> - invalidformat = false;
> + invalidformat = true;
> }
> if (invalidformat) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
> index 53cb2c0..aa8fa3e 100644
> --- a/src/mesa/main/texstorage.c
> +++ b/src/mesa/main/texstorage.c
> @@ -309,6 +309,7 @@ tex_storage_error_check(struct gl_context *ctx,
> GL_INVALID_ENUM : GL_INVALID_OPERATION,
> "glTex%sStorage%dD(internalformat = %s)", suffix, dims,
> _mesa_lookup_enum_by_nr(internalformat));
> + return GL_TRUE;
> }
>
> /* levels check */
>
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list