<div dir="ltr">Sorry about the incorrect threading on these v2's.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 14, 2015 at 11:17 AM, 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>
Instead of case statements, use _mesa_get_format_layout() to<br>
determine if a GL format is part of a family of compressed formats.<br>
<br>
</span>v2. restrict LATC formats to API_OPENGL_COMPAT (Ilia).<br>
    rename the variable mFormat to m_format.<br>
<span class=""><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/glformats.c | 119 ++++++++++++++++------------------------------<br>
 1 file changed, 40 insertions(+), 79 deletions(-)<br>
<br>
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c<br>
</span>index c1d3c7d..99c6a8f 100644<br>
<span class="">--- a/src/mesa/main/glformats.c<br>
+++ b/src/mesa/main/glformats.c<br>
@@ -28,6 +28,7 @@<br>
 #include "context.h"<br>
 #include "glformats.h"<br>
 #include "formats.h"<br>
+#include "texcompress.h"<br>
 #include "enums.h"<br>
<br>
 enum {<br>
</span>@@ -1271,95 +1272,22 @@ _mesa_is_depth_or_stencil_format(GLenum format)<br>
<span class=""> GLboolean<br>
 _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)<br>
 {<br>
</span>+   mesa_format m_format = _mesa_glenum_to_compressed_format(format);<br>
<div><div class="h5">+<br>
+   /* Some formats in this switch have an equivalent mesa_format_layout<br>
+    * to the compressed formats in the layout switch below and thus<br>
+    * must be handled first.<br>
+    */<br>
    switch (format) {<br>
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:<br>
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:<br>
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:<br>
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:<br>
-      /* Assume that the ANGLE flag will always be set if the EXT flag is set.<br>
-       */<br>
-      return ctx->Extensions.ANGLE_texture_compression_dxt;<br>
    case GL_RGB_S3TC:<br>
    case GL_RGB4_S3TC:<br>
    case GL_RGBA_S3TC:<br>
    case GL_RGBA4_S3TC:<br>
       return _mesa_is_desktop_gl(ctx) &&<br>
          ctx->Extensions.ANGLE_texture_compression_dxt;<br>
-   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:<br>
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:<br>
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:<br>
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:<br>
-      return _mesa_is_desktop_gl(ctx)<br>
-         && ctx->Extensions.EXT_texture_sRGB<br>
-         && ctx->Extensions.EXT_texture_compression_s3tc;<br>
-   case GL_COMPRESSED_RGB_FXT1_3DFX:<br>
-   case GL_COMPRESSED_RGBA_FXT1_3DFX:<br>
-      return _mesa_is_desktop_gl(ctx)<br>
-         && ctx->Extensions.TDFX_texture_compression_FXT1;<br>
-   case GL_COMPRESSED_RED_RGTC1:<br>
-   case GL_COMPRESSED_SIGNED_RED_RGTC1:<br>
-   case GL_COMPRESSED_RG_RGTC2:<br>
-   case GL_COMPRESSED_SIGNED_RG_RGTC2:<br>
-      return _mesa_is_desktop_gl(ctx)<br>
-         && ctx->Extensions.ARB_texture_compression_rgtc;<br>
-   case GL_COMPRESSED_LUMINANCE_LATC1_EXT:<br>
-   case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:<br>
-   case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:<br>
-   case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:<br>
</div></div>-      return ctx->API == API_OPENGL_COMPAT<br>
<span class="">-         && ctx->Extensions.EXT_texture_compression_latc;<br>
    case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:<br>
</span>       return ctx->API == API_OPENGL_COMPAT<br>
<div><div class="h5">          && ctx->Extensions.ATI_texture_compression_3dc;<br>
-   case GL_ETC1_RGB8_OES:<br>
-      return _mesa_is_gles(ctx)<br>
-         && ctx->Extensions.OES_compressed_ETC1_RGB8_texture;<br>
-   case GL_COMPRESSED_RGB8_ETC2:<br>
-   case GL_COMPRESSED_SRGB8_ETC2:<br>
-   case GL_COMPRESSED_RGBA8_ETC2_EAC:<br>
-   case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:<br>
-   case GL_COMPRESSED_R11_EAC:<br>
-   case GL_COMPRESSED_RG11_EAC:<br>
-   case GL_COMPRESSED_SIGNED_R11_EAC:<br>
-   case GL_COMPRESSED_SIGNED_RG11_EAC:<br>
-   case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:<br>
-   case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:<br>
-      return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility;<br>
-   case GL_COMPRESSED_RGBA_BPTC_UNORM:<br>
-   case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:<br>
-   case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:<br>
-   case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:<br>
-      return _mesa_is_desktop_gl(ctx) &&<br>
-         ctx->Extensions.ARB_texture_compression_bptc;<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 ctx->Extensions.KHR_texture_compression_astc_ldr;<br>
    case GL_PALETTE4_RGB8_OES:<br>
    case GL_PALETTE4_RGBA8_OES:<br>
    case GL_PALETTE4_R5_G6_B5_OES:<br>
</div></div>@@ -1371,6 +1299,39 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)<br>
<span class="">    case GL_PALETTE8_RGBA4_OES:<br>
    case GL_PALETTE8_RGB5_A1_OES:<br>
       return ctx->API == API_OPENGLES;<br>
+   }<br>
+<br>
</span>+   switch (_mesa_get_format_layout(m_format)) {<br>
+   case MESA_FORMAT_LAYOUT_S3TC:<br>
+      if (_mesa_get_format_color_encoding(m_format) == GL_LINEAR) {<br>
<span class="">+         /* Assume that the ANGLE flag will always be set if the<br>
+          * EXT flag is set.<br>
+          */<br>
+         return ctx->Extensions.ANGLE_texture_compression_dxt;<br>
+      } else {<br>
+         return _mesa_is_desktop_gl(ctx)<br>
+            && ctx->Extensions.EXT_texture_sRGB<br>
+            && ctx->Extensions.EXT_texture_compression_s3tc;<br>
+      }<br>
+   case MESA_FORMAT_LAYOUT_FXT1:<br>
+      return _mesa_is_desktop_gl(ctx)<br>
+         && ctx->Extensions.TDFX_texture_compression_FXT1;<br>
+   case MESA_FORMAT_LAYOUT_RGTC:<br>
+      return _mesa_is_desktop_gl(ctx)<br>
+         && ctx->Extensions.ARB_texture_compression_rgtc;<br>
+   case MESA_FORMAT_LAYOUT_LATC:<br>
</span>+      return ctx->API == API_OPENGL_COMPAT<br>
<span class="">+         && ctx->Extensions.EXT_texture_compression_latc;<br>
+   case MESA_FORMAT_LAYOUT_ETC1:<br>
+      return _mesa_is_gles(ctx)<br>
+         && ctx->Extensions.OES_compressed_ETC1_RGB8_texture;<br>
+   case MESA_FORMAT_LAYOUT_ETC2:<br>
+      return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility;<br>
+   case MESA_FORMAT_LAYOUT_BPTC:<br>
+      return _mesa_is_desktop_gl(ctx) &&<br>
+         ctx->Extensions.ARB_texture_compression_bptc;<br>
+   case MESA_FORMAT_LAYOUT_ASTC:<br>
+      return ctx->Extensions.KHR_texture_compression_astc_ldr;<br>
    default:<br>
       return GL_FALSE;<br>
    }<br>
--<br>
</span>2.5.1<br>
<br>
</blockquote></div><br></div>