[Mesa-dev] [PATCH v2 2/2]] mesa/teximage: accept ASTC formats for 3D texture specification

Nanley Chery nanleychery at gmail.com
Thu Jul 30 10:33:44 PDT 2015


From: Nanley Chery <nanley.g.chery at intel.com>

The ASTC spec was revised as follows:

   Revision 2, April 28, 2015 - added CompressedTex{Sub,}Image3D to
   commands accepting ASTC format tokens in the New Tokens section [...].

Support only exists in the HDR submode:

   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 only, this column is checked for all ASTC
   formats.

LDR-only systems should generate an INVALID_OPERATION error when
attempting to call CompressedTexImage3D with the TEXTURE_3D target.

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---

The original patch was missing the GL error modification for LDR-only systems.

 src/mesa/main/teximage.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 949eef0..3a4db63 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1819,6 +1819,35 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
       case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
       case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
          return ctx->Extensions.ARB_texture_compression_bptc;
+      case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
+      case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+         return ctx->Extensions.KHR_texture_compression_astc_hdr;
       default:
          return GL_FALSE;
       }
@@ -2296,6 +2325,16 @@ texture_error_check( struct gl_context *ctx,
    return GL_FALSE;
 }
 
+static inline bool
+is_astc_format(const struct gl_context *ctx, GLenum internalFormat)
+{
+      return ctx->Extensions.KHR_texture_compression_astc_ldr &&
+             ((internalFormat >= GL_COMPRESSED_RGBA_ASTC_4x4_KHR &&
+               internalFormat <= GL_COMPRESSED_RGBA_ASTC_12x12_KHR) ||
+              (internalFormat >= GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR &&
+               internalFormat <= GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR));
+}
+
 
 /**
  * Error checking for glCompressedTexImage[123]D().
@@ -2324,7 +2363,16 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
        *     CompressedTexImage3D will generate an INVALID_OPERATION error if
        *     target is not TEXTURE_2D_ARRAY."
        */
-      error = _mesa_is_desktop_gl(ctx) ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
+      /* From the KHR_texture_compression_astc_hdr spec:
+       *
+       *     'An INVALID_OPERATION error is generated by CompressedTexImage3D
+       *      if <internalformat> is TEXTURE_CUBE_MAP_ARRAY and the
+       *      "Cube Map Array" column of table 8.19 is *not* checked, or if
+       *      <internalformat> is TEXTURE_3D and the "3D Tex." column of table
+       *      8.19 is *not* checked'
+       */
+      error = _mesa_is_desktop_gl(ctx) && !is_astc_format(ctx, internalFormat) ?
+              GL_INVALID_ENUM : GL_INVALID_OPERATION;
       goto error;
    }
 
-- 
2.4.2



More information about the mesa-dev mailing list