mesa: add GL_AMD_compressed_ATC_texture support
authorJonathan Marek <jonathan@marek.ca>
Tue, 5 Feb 2019 16:36:59 +0000 (11:36 -0500)
committerRob Clark <robdclark@gmail.com>
Tue, 23 Apr 2019 17:11:56 +0000 (17:11 +0000)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
12 files changed:
src/mapi/glapi/gen/es_EXT.xml
src/mesa/main/extensions_table.h
src/mesa/main/format_info.py
src/mesa/main/formats.c
src/mesa/main/formats.csv
src/mesa/main/formats.h
src/mesa/main/glformats.c
src/mesa/main/glheader.h
src/mesa/main/mtypes.h
src/mesa/main/texcompress.c
src/mesa/main/teximage.c
src/mesa/swrast/s_texfetch.c

index 917fed62f98cd1130c26ed4c27540b294e54cd22..5fa518d7a097e8ca4a0d71655fb20d41215b029c 100644 (file)
     <enum name="HALF_FLOAT_OES"                           value="0x8D61"/>
 </category>
 
+<category name="GL_AMD_compressed_ATC_texture" number="40">
+    <enum name="ATC_RGB_AMD"                              value="0x8C92"/>
+    <enum name="ATC_RGBA_EXPLICIT_ALPHA_AMD"              value="0x8C93"/>
+    <enum name="ATC_RGBA_INTERPOLATED_ALPHA_AMD"          value="0x87EE"/>
+</category>
+
 <!-- 41. GL_EXT_texture_filter_anisotropic -->
 
 <category name="GL_EXT_texture_type_2_10_10_10_REV" number="42">
index 3077068dd80a26846d6b065ca61e6f72b06da396..ec6f8a81353c979da373c8d172c1eb89ff4e26e6 100644 (file)
@@ -8,6 +8,7 @@
 
 EXT(3DFX_texture_compression_FXT1           , TDFX_texture_compression_FXT1          , GLL, GLC,  x ,  x , 1999)
 
+EXT(AMD_compressed_ATC_texture              , AMD_compressed_ATC_texture             ,  x ,  x , ES1, ES2, 2008)
 EXT(AMD_conservative_depth                  , ARB_conservative_depth                 , GLL, GLC,  x ,  x , 2009)
 EXT(AMD_depth_clamp_separate                , AMD_depth_clamp_separate               , GLL, GLC,  x ,  x , 2009)
 EXT(AMD_draw_buffers_blend                  , ARB_draw_buffers_blend                 , GLL, GLC,  x ,  x , 2009)
index 00e27b3fba5b79379469ef576619a94a7db9364d..94017bfae0f55d5711df2fc239b5317b9a87d0c6 100644 (file)
@@ -126,6 +126,8 @@ def get_channel_bits(fmat, chan_name):
       elif fmat.layout == 'astc':
          bits = 16 if 'RGBA' in fmat.name else 8
          return bits if fmat.has_channel(chan_name) else 0
+      elif fmat.layout == 'atc':
+         return 8 if fmat.has_channel(chan_name) else 0
       else:
          assert False
    else:
index cf2d2bc555a127caf688383722642d88a62d8b6e..b47bed97d20dfe07df68cedd988bd08a912d6f80 100644 (file)
@@ -712,11 +712,14 @@ _mesa_get_uncompressed_format(mesa_format format)
    case MESA_FORMAT_ETC1_RGB8:
    case MESA_FORMAT_ETC2_RGB8:
    case MESA_FORMAT_ETC2_SRGB8:
+   case MESA_FORMAT_ATC_RGB:
       return MESA_FORMAT_BGR_UNORM8;
    case MESA_FORMAT_ETC2_RGBA8_EAC:
    case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
    case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
    case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+   case MESA_FORMAT_ATC_RGBA_EXPLICIT:
+   case MESA_FORMAT_ATC_RGBA_INTERPOLATED:
       return MESA_FORMAT_A8B8G8R8_UNORM;
    case MESA_FORMAT_ETC2_R11_EAC:
    case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
index cb821fec62f075895cc4ec75dd4c16076e6f0654..90d9bf07ece6279e6b8cd239ed5575683f5ed321 100644 (file)
@@ -372,3 +372,8 @@ MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x5       , astc  , 5, 5, 5, x128,     ,     ,
 MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5x5       , astc  , 6, 5, 5, x128,     ,     ,     , xyzw, srgb
 MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x5       , astc  , 6, 6, 5, x128,     ,     ,     , xyzw, srgb
 MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6       , astc  , 6, 6, 6, x128,     ,     ,     , xyzw, srgb
+
+# ATC compressed formats
+MESA_FORMAT_ATC_RGB                       ,  atc  , 4, 4, 1, x64 ,     ,     ,     , xyz1, rgb
+MESA_FORMAT_ATC_RGBA_EXPLICIT             ,  atc  , 4, 4, 1, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ATC_RGBA_INTERPOLATED         ,  atc  , 4, 4, 1, x128,     ,     ,     , xyzw, rgb
index 15c561225d6a1f567db8e777a6b0729d535c0750..08039067a6c4fe18d528d2231060445b6dfd5a5d 100644 (file)
@@ -71,6 +71,7 @@ enum mesa_format_layout {
    MESA_FORMAT_LAYOUT_ETC2,
    MESA_FORMAT_LAYOUT_BPTC,
    MESA_FORMAT_LAYOUT_ASTC,
+   MESA_FORMAT_LAYOUT_ATC,
    MESA_FORMAT_LAYOUT_OTHER,
 };
 
@@ -657,6 +658,12 @@ typedef enum
    MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5x5,
    MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x5,
    MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6,
+
+   /* ATC compressed formats */
+   MESA_FORMAT_ATC_RGB,
+   MESA_FORMAT_ATC_RGBA_EXPLICIT,
+   MESA_FORMAT_ATC_RGBA_INTERPOLATED,
+
    MESA_FORMAT_COUNT
 } mesa_format;
 
index ea72cab5b3ed95fc4189a8902bb29294904b354f..bd08784880315062e87840dec026255c64d9be32 100644 (file)
@@ -1142,6 +1142,9 @@ _mesa_is_color_format(GLenum format)
       case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
       case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
       case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+      case GL_ATC_RGB_AMD:
+      case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
+      case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
       /* generic integer formats */
       case GL_RED_INTEGER_EXT:
       case GL_GREEN_INTEGER_EXT:
@@ -1393,6 +1396,8 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)
              _mesa_has_EXT_texture_compression_bptc(ctx);
    case MESA_FORMAT_LAYOUT_ASTC:
       return _mesa_has_KHR_texture_compression_astc_ldr(ctx);
+   case MESA_FORMAT_LAYOUT_ATC:
+      return _mesa_has_AMD_compressed_ATC_texture(ctx);
    default:
       return GL_FALSE;
    }
index 5764b83ffbbdbad67f8b77ce9c52ffa898ff2ada..a3294d89d185f92cd7d2bcb5224b49c70873d01d 100644 (file)
@@ -142,6 +142,12 @@ typedef int GLclampx;
 #define GL_SR8_EXT                                              0x8FBD
 #endif
 
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_ATC_RGB_AMD                                          0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
+#endif
+
 /**
  * Internal token to represent a GLSL shader program (a collection of
  * one or more shaders that get linked together).  Note that GLSL
index 297d3be8098a53e91b8dac439f0c57984f694f52..6efd97584179e5f875875b1ef2ec579235c06271 100644 (file)
@@ -4308,6 +4308,7 @@ struct gl_extensions
    GLboolean OES_texture_view;
    GLboolean OES_viewport_array;
    /* vendor extensions */
+   GLboolean AMD_compressed_ATC_texture;
    GLboolean AMD_framebuffer_multisample_advanced;
    GLboolean AMD_depth_clamp_separate;
    GLboolean AMD_performance_monitor;
index 2406cc5cf7ef168b39c87b2bcbf4ee548a77250e..48d794ddfd2c4e11787bf4637666631608f4ae5b 100644 (file)
@@ -106,6 +106,7 @@ _mesa_gl_compressed_format_base_format(GLenum format)
    case GL_PALETTE4_R5_G6_B5_OES:
    case GL_PALETTE8_RGB8_OES:
    case GL_PALETTE8_R5_G6_B5_OES:
+   case GL_ATC_RGB_AMD:
       return GL_RGB;
 
    case GL_COMPRESSED_RGBA:
@@ -131,6 +132,8 @@ _mesa_gl_compressed_format_base_format(GLenum format)
    case GL_PALETTE4_RGB5_A1_OES:
    case GL_PALETTE8_RGBA8_OES:
    case GL_PALETTE8_RGBA4_OES:
+   case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
+   case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
       return GL_RGBA;
 
    case GL_COMPRESSED_ALPHA:
@@ -455,6 +458,20 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
       formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES;
    }
 
+   /* The GL_AMD_compressed_ATC_texture spec says:
+    *
+    *     "New State
+    *
+    *         The queries for NUM_COMPRESSED_TEXTURE_FORMATS and
+    *         COMPRESSED_TEXTURE_FORMATS include ATC_RGB_AMD,
+    *         ATC_RGBA_EXPLICIT_ALPHA_AMD, and ATC_RGBA_INTERPOLATED_ALPHA_AMD."
+    */
+   if (_mesa_has_AMD_compressed_ATC_texture(ctx)) {
+      formats[n++] = GL_ATC_RGB_AMD;
+      formats[n++] = GL_ATC_RGBA_EXPLICIT_ALPHA_AMD;
+      formats[n++] = GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD;
+   }
+
    assert(n <= ARRAY_SIZE(discard_formats));
 
    return n;
@@ -643,6 +660,13 @@ _mesa_glenum_to_compressed_format(GLenum format)
    case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES:
       return MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6;
 
+   case GL_ATC_RGB_AMD:
+      return MESA_FORMAT_ATC_RGB;
+   case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
+      return MESA_FORMAT_ATC_RGBA_EXPLICIT;
+   case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
+      return MESA_FORMAT_ATC_RGBA_INTERPOLATED;
+
    default:
       return MESA_FORMAT_NONE;
    }
@@ -831,6 +855,14 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx,
       return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES;
    case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6:
       return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES;
+
+   case MESA_FORMAT_ATC_RGB:
+      return GL_ATC_RGB_AMD;
+   case MESA_FORMAT_ATC_RGBA_EXPLICIT:
+      return GL_ATC_RGBA_EXPLICIT_ALPHA_AMD;
+   case MESA_FORMAT_ATC_RGBA_INTERPOLATED:
+      return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD;
+
    default:
       _mesa_problem(ctx, "Unexpected mesa texture format in"
                     " _mesa_compressed_format_to_glenum()");
index a43915e18d98754335cb4d786e62c31773aec8ad..1efdd7dd902421d4e5b902dc174149c4b73490b9 100644 (file)
@@ -176,7 +176,7 @@ oes_float_internal_format(const struct gl_context *ctx,
 /**
  * Install gl_texture_image in a gl_texture_object according to the target
  * and level parameters.
- * 
+ *
  * \param tObj texture object.
  * \param target texture target.
  * \param level image level.
@@ -1366,6 +1366,9 @@ compressedteximage_only_format(GLenum format)
    case GL_PALETTE8_R5_G6_B5_OES:
    case GL_PALETTE8_RGBA4_OES:
    case GL_PALETTE8_RGB5_A1_OES:
+   case GL_ATC_RGB_AMD:
+   case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
+   case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
       return true;
    default:
       return false;
index e8f4eb598a534f4c851abdc9a9cc40d4bc320974..ed8df7bab64c9b73c229153e67f238af3062c14e 100644 (file)
@@ -464,7 +464,11 @@ texfetch_funcs[] =
    FETCH_NULL(SRGB8_ALPHA8_ASTC_5x5x5),
    FETCH_NULL(SRGB8_ALPHA8_ASTC_6x5x5),
    FETCH_NULL(SRGB8_ALPHA8_ASTC_6x6x5),
-   FETCH_NULL(SRGB8_ALPHA8_ASTC_6x6x6)
+   FETCH_NULL(SRGB8_ALPHA8_ASTC_6x6x6),
+
+   FETCH_NULL(ATC_RGB),
+   FETCH_NULL(ATC_RGBA_EXPLICIT),
+   FETCH_NULL(ATC_RGBA_INTERPOLATED)
 };