From 3d14e720574ea933b172affdafd53c74a9381e9c Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Mon, 5 Feb 2018 17:00:11 +0100 Subject: [PATCH] mesa: enable ASTC format for CompressedTexSubImage3D MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If extensions GL_KHR_texture_compression_astc_hdr or GL_KHR_texture_compression_astc_sliced_3d are implemented then ASTC format are supported in CompressedTex*Îmage3D. Fixes KHR-GLES2.texture_3d.* with this format. CC: Eric Anholt Reviewed-by: Eric Anholt Signed-off-by: Juan A. Suarez Romero --- src/mesa/main/teximage.c | 41 ++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index cc329e6410e..928e50d472d 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4647,10 +4647,12 @@ out: */ static GLboolean compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, - GLint dims, GLenum format, bool dsa, + GLint dims, GLenum intFormat, bool dsa, const char *caller) { GLboolean targetOK; + mesa_format format; + enum mesa_format_layout layout; if (dsa && target == GL_TEXTURE_RECTANGLE) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller, @@ -4711,21 +4713,44 @@ compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, * 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. + * + * Also, from GL_KHR_texture_compression_astc_{hdr,ldr}: + * + * "Add a second new column "3D Tex." which is empty for all non-ASTC + * formats. If only the LDR profile is supported by the implementation, + * this column is also empty for all ASTC formats. If both the LDR and HDR + * profiles are supported, this column is checked for all ASTC formats." + * + * "An INVALID_OPERATION error is generated by CompressedTexSubImage3D if + * is one of the formats in table 8.19 and is not + * TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, or TEXTURE_3D. + * + * An INVALID_OPERATION error is generated by CompressedTexSubImage3D if + * is TEXTURE_CUBE_MAP_ARRAY and the "Cube Map Array" column of + * table 8.19 is *not* checked, or if is TEXTURE_3D and the "3D + * Tex." column of table 8.19 is *not* checked" + * + * And from GL_KHR_texture_compression_astc_sliced_3d: + * + * "Modify the "3D Tex." column to be checked for all ASTC formats." */ - switch (format) { - /* These are the only 3D compression formats supported at this time */ - 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: + format = _mesa_glenum_to_compressed_format(intFormat); + layout = _mesa_get_format_layout(format); + switch (layout) { + case MESA_FORMAT_LAYOUT_BPTC: /* valid format */ break; + case MESA_FORMAT_LAYOUT_ASTC: + targetOK = + ctx->Extensions.KHR_texture_compression_astc_hdr || + ctx->Extensions.KHR_texture_compression_astc_sliced_3d; + break; default: /* invalid format */ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s for format %s)", caller, _mesa_enum_to_string(target), - _mesa_enum_to_string(format)); + _mesa_enum_to_string(intFormat)); return GL_TRUE; } break; -- 2.30.2