<div dir="ltr">This patch is a followup on this: <a href="http://lists.freedesktop.org/archives/mesa-dev/2015-June/087055.html">http://lists.freedesktop.org/archives/mesa-dev/2015-June/087055.html</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 4:54 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<br>
In agreement with the ASTC spec, this makes calls to TexImage*D unsuccessful.<br>
Implied by the spec, Generate[Texture]Mipmap and [Copy]TexSubImage*D calls<br>
must be unsuccessful as well.<br>
<br>
v2. actually force attempts to compress online to fail.<br>
</span>v3. indentation (Matt).<br>
<div><div class="h5"><br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
src/mesa/main/genmipmap.c | 1 +<br>
src/mesa/main/glformats.c | 41 +++++++++++++++++++++++++++++++++++++++++<br>
src/mesa/main/glformats.h | 3 +++<br>
src/mesa/main/texcompress.c | 22 ++++++++++++++++++++++<br>
src/mesa/main/teximage.c | 15 ++++++++++++---<br>
5 files changed, 79 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c<br>
index c18f9d5..4ec8385 100644<br>
--- a/src/mesa/main/genmipmap.c<br>
+++ b/src/mesa/main/genmipmap.c<br>
@@ -111,6 +111,7 @@ _mesa_generate_texture_mipmap(struct gl_context *ctx,<br>
<br>
if (_mesa_is_enum_format_integer(srcImage->InternalFormat) ||<br>
_mesa_is_depthstencil_format(srcImage->InternalFormat) ||<br>
+ _mesa_is_astc_format(srcImage->InternalFormat) ||<br>
_mesa_is_stencil_format(srcImage->InternalFormat)) {<br>
_mesa_unlock_texture(ctx, texObj);<br>
_mesa_error(ctx, GL_INVALID_OPERATION,<br>
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c<br>
index c3fd734..2240fa9 100644<br>
--- a/src/mesa/main/glformats.c<br>
+++ b/src/mesa/main/glformats.c<br>
@@ -820,6 +820,47 @@ _mesa_is_enum_format_signed_int(GLenum format)<br>
}<br>
}<br>
<br>
+/**<br>
+ * Test if the given format is an ASTC format.<br>
+ */<br>
+GLboolean<br>
+_mesa_is_astc_format(GLenum internalFormat)<br>
+{<br>
+ switch (internalFormat) {<br>
+ case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:<br>
+ case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:<br>
+ case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:<br>
+ return true;<br>
+ default:<br>
+ return false;<br>
+ }<br>
+}<br>
+<br>
<br>
/**<br>
* Test if the given format is an integer (non-normalized) format.<br>
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h<br>
index 419955a..aec905d 100644<br>
--- a/src/mesa/main/glformats.h<br>
+++ b/src/mesa/main/glformats.h<br>
@@ -57,6 +57,9 @@ extern GLint<br>
_mesa_bytes_per_vertex_attrib(GLint comps, GLenum type);<br>
<br>
extern GLboolean<br>
+_mesa_is_astc_format(GLenum internalFormat);<br>
+<br>
+extern GLboolean<br>
_mesa_is_type_unsigned(GLenum type);<br>
<br>
extern GLboolean<br>
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c<br>
index 0fd1a36..1654fc6 100644<br>
--- a/src/mesa/main/texcompress.c<br>
+++ b/src/mesa/main/texcompress.c<br>
@@ -229,6 +229,28 @@ _mesa_gl_compressed_format_base_format(GLenum format)<br>
* what GL_NUM_COMPRESSED_TEXTURE_FORMATS and<br>
* GL_COMPRESSED_TEXTURE_FORMATS return."<br>
*<br>
+ * The KHR_texture_compression_astc_hdr spec says:<br>
+ *<br>
+ * "Interactions with OpenGL 4.2<br>
+ *<br>
+ * OpenGL 4.2 supports the feature that compressed textures can be<br>
+ * compressed online, by passing the compressed texture format enum as<br>
+ * the internal format when uploading a texture using TexImage1D,<br>
+ * TexImage2D or TexImage3D (see Section 3.9.3, Texture Image<br>
+ * Specification, subsection Encoding of Special Internal Formats).<br>
+ *<br>
+ * Due to the complexity of the ASTC compression algorithm, it is not<br>
+ * usually suitable for online use, and therefore ASTC support will be<br>
+ * limited to pre-compressed textures only. Where on-device compression<br>
+ * is required, a domain-specific limited compressor will typically<br>
+ * be used, and this is therefore not suitable for implementation in<br>
+ * the driver.<br>
+ *<br>
+ * In particular, the ASTC format specifiers will not be added to<br>
+ * Table 3.14, and thus will not be accepted by the TexImage*D<br>
+ * functions, and will not be returned by the (already deprecated)<br>
+ * COMPRESSED_TEXTURE_FORMATS query."<br>
+ *<br>
* There is no formal spec for GL_ATI_texture_compression_3dc. Since the<br>
* formats added by this extension are luminance-alpha formats, it is<br>
* reasonable to expect them to follow the same rules as<br>
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c<br>
</div></div>index fc69387..3e9a7b9 100644<br>
<span class="im HOEnZb">--- a/src/mesa/main/teximage.c<br>
+++ b/src/mesa/main/teximage.c<br>
@@ -1784,6 +1784,15 @@ compressedteximage_only_format(const struct gl_context *ctx, GLenum format)<br>
}<br>
}<br>
<br>
+/**<br>
+ * Return true if the format doesn't support online compression.<br>
+ */<br>
</span><span class="im HOEnZb">+static bool<br>
+_mesa_format_no_online_compression(const struct gl_context *ctx, GLenum format)<br>
+{<br>
+ return _mesa_is_astc_format(format) ||<br>
+ compressedteximage_only_format(ctx, format);<br>
</span><div class="HOEnZb"><div class="h5">+}<br>
<br>
/**<br>
* Helper function to determine whether a target and specific compression<br>
@@ -2289,7 +2298,7 @@ texture_error_check( struct gl_context *ctx,<br>
"glTexImage%dD(target can't be compressed)", dimensions);<br>
return GL_TRUE;<br>
}<br>
- if (compressedteximage_only_format(ctx, internalFormat)) {<br>
+ if (_mesa_format_no_online_compression(ctx, internalFormat)) {<br>
_mesa_error(ctx, GL_INVALID_OPERATION,<br>
"glTexImage%dD(no compression for format)", dimensions);<br>
return GL_TRUE;<br>
@@ -2561,7 +2570,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
}<br>
<br>
if (_mesa_is_format_compressed(texImage->TexFormat)) {<br>
- if (compressedteximage_only_format(ctx, texImage->InternalFormat)) {<br>
+ if (_mesa_format_no_online_compression(ctx, texImage->InternalFormat)) {<br>
_mesa_error(ctx, GL_INVALID_OPERATION,<br>
"%s(no compression for format)", callerName);<br>
return GL_TRUE;<br>
@@ -2899,7 +2908,7 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
}<br>
<br>
if (_mesa_is_format_compressed(texImage->TexFormat)) {<br>
- if (compressedteximage_only_format(ctx, texImage->InternalFormat)) {<br>
+ if (_mesa_format_no_online_compression(ctx, texImage->InternalFormat)) {<br>
_mesa_error(ctx, GL_INVALID_OPERATION,<br>
"%s(no compression for format)", caller);<br>
return GL_TRUE;<br>
--<br>
2.4.2<br>
<br>
</div></div></blockquote></div><br></div>