[Mesa-dev] [PATCH] mesa: Enable ASTC in GLES' [NUM_]COMPRESSED_TEXTURE_FORMATS queries

Nanley Chery nanleychery at gmail.com
Wed Oct 21 15:06:15 PDT 2015


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

In OpenGL ES, the COMPRESSED_TEXTURE_FORMATS query returns the set of
supported specific compressed formats. Since ASTC formats fit within
that category, include them in the set and update the
NUM_COMPRESSED_TEXTURE_FORMATS query as well.

This enables GLES2-based ASTC dEQP tests to run. See the Bugzilla for
more info.

Cc: "11.0" <mesa-stable at lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92193
Reported-by: Tapani Pälli <tapani.palli at intel.com>
Suggested-by: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/mesa/main/texcompress.c | 85 +++++++++++++++++++++++++++++++++------------
 1 file changed, 63 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 84973d3..9d22586 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -243,28 +243,6 @@ _mesa_gl_compressed_format_base_format(GLenum format)
  *        what GL_NUM_COMPRESSED_TEXTURE_FORMATS and
  *        GL_COMPRESSED_TEXTURE_FORMATS return."
  *
- * The KHR_texture_compression_astc_hdr spec says:
- *
- *    "Interactions with OpenGL 4.2
- *
- *        OpenGL 4.2 supports the feature that compressed textures can be
- *        compressed online, by passing the compressed texture format enum as
- *        the internal format when uploading a texture using TexImage1D,
- *        TexImage2D or TexImage3D (see Section 3.9.3, Texture Image
- *        Specification, subsection Encoding of Special Internal Formats).
- *
- *        Due to the complexity of the ASTC compression algorithm, it is not
- *        usually suitable for online use, and therefore ASTC support will be
- *        limited to pre-compressed textures only. Where on-device compression
- *        is required, a domain-specific limited compressor will typically
- *        be used, and this is therefore not suitable for implementation in
- *        the driver.
- *
- *        In particular, the ASTC format specifiers will not be added to
- *        Table 3.14, and thus will not be accepted by the TexImage*D
- *        functions, and will not be returned by the (already deprecated)
- *        COMPRESSED_TEXTURE_FORMATS query."
- *
  * There is no formal spec for GL_ATI_texture_compression_3dc.  Since the
  * formats added by this extension are luminance-alpha formats, it is
  * reasonable to expect them to follow the same rules as
@@ -396,6 +374,69 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
          n += 10;
       }
    }
+
+   /* The KHR_texture_compression_astc_hdr spec says:
+    *
+    *    "Interactions with OpenGL 4.2
+    *
+    *        OpenGL 4.2 supports the feature that compressed textures can be
+    *        compressed online, by passing the compressed texture format enum as
+    *        the internal format when uploading a texture using TexImage1D,
+    *        TexImage2D or TexImage3D (see Section 3.9.3, Texture Image
+    *        Specification, subsection Encoding of Special Internal Formats).
+    *
+    *        Due to the complexity of the ASTC compression algorithm, it is not
+    *        usually suitable for online use, and therefore ASTC support will be
+    *        limited to pre-compressed textures only. Where on-device compression
+    *        is required, a domain-specific limited compressor will typically
+    *        be used, and this is therefore not suitable for implementation in
+    *        the driver.
+    *
+    *        In particular, the ASTC format specifiers will not be added to
+    *        Table 3.14, and thus will not be accepted by the TexImage*D
+    *        functions, and will not be returned by the (already deprecated)
+    *        COMPRESSED_TEXTURE_FORMATS query."
+    *
+    * The ES and the desktop specs diverge here. In OpenGL ES, the COMPRESSED_TEXTURE_FORMATS
+    * query returns the set of supported specific compressed formats.
+    */
+   if (ctx->API == API_OPENGLES2 &&
+       ctx->Extensions.KHR_texture_compression_astc_ldr) {
+      if (formats) {
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x6_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x8_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x10_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_12x10_KHR;
+         formats[n++] = GL_COMPRESSED_RGBA_ASTC_12x12_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
+      }
+      else {
+         n += 28;
+      }
+   }
+
    return n;
 }
 
-- 
2.6.1



More information about the mesa-dev mailing list