mesa: Enable ASTC in GLES' [NUM_]COMPRESSED_TEXTURE_FORMATS queries
authorNanley Chery <nanley.g.chery@intel.com>
Wed, 14 Oct 2015 21:32:43 +0000 (14:32 -0700)
committerNanley Chery <nanley.g.chery@intel.com>
Thu, 29 Oct 2015 22:40:37 +0000 (15:40 -0700)
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.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92193
Reported-by: Tapani Pälli <tapani.palli@intel.com>
Suggested-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/texcompress.c

index 7fcaa424583953e4c2a8fa0ae549a020458bc296..a8ac19e40d7db0069f285b0876f8bef5d5d91ab5 100644 (file)
@@ -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
@@ -397,6 +375,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;
 }