[Mesa-dev] [PATCH 1/2] mesa: expose EXT_texture_compression_rgtc on GLES

Marek Olšák maraeo at gmail.com
Tue Dec 4 19:57:10 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

The spec was modified to support GLES. Tested by piglit.

v2: rebase

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu> (v1)
---
 docs/relnotes/19.0.0.html        |  1 +
 src/mesa/main/extensions_table.h |  2 +-
 src/mesa/main/glformats.c        | 19 ++++++++++++++-----
 src/mesa/main/texcompress.c      |  9 +++++++++
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/docs/relnotes/19.0.0.html b/docs/relnotes/19.0.0.html
index 1629e0ba52e..4a61420be1a 100644
--- a/docs/relnotes/19.0.0.html
+++ b/docs/relnotes/19.0.0.html
@@ -33,20 +33,21 @@ Compatibility contexts may report a lower version depending on each driver.
 <h2>SHA256 checksums</h2>
 <pre>
 TBD.
 </pre>
 
 
 <h2>New features</h2>
 
 <ul>
 <li>GL_EXT_shader_implicit_conversions on all drivers (ES extension).</li>
+<li>GL_EXT_texture_compression_rgtc on all GL 3.0 drivers (ES extension).</li>
 <li>GL_EXT_texture_view on drivers supporting texture views (ES extension).</li>
 <li>GL_OES_texture_view on drivers supporting texture views (ES extension).</li>
 </ul>
 
 <h2>Bug fixes</h2>
 
 <ul>
 <li>TBD</li>
 </ul>
 
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 8d6d56c640d..a229f3af2b2 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -271,21 +271,21 @@ EXT(EXT_stencil_wrap                        , dummy_true
 EXT(EXT_subtexture                          , dummy_true                             , GLL,  x ,  x ,  x , 1995)
 EXT(EXT_tessellation_point_size             , ARB_tessellation_shader                ,  x ,  x ,  x ,  31, 2013)
 EXT(EXT_tessellation_shader                 , ARB_tessellation_shader                ,  x ,  x ,  x ,  31, 2013)
 EXT(EXT_texture                             , dummy_true                             , GLL,  x ,  x ,  x , 1996)
 EXT(EXT_texture3D                           , dummy_true                             , GLL,  x ,  x ,  x , 1996)
 EXT(EXT_texture_array                       , EXT_texture_array                      , GLL, GLC,  x ,  x , 2006)
 EXT(EXT_texture_border_clamp                , ARB_texture_border_clamp               ,  x ,  x ,  x , ES2, 2014)
 EXT(EXT_texture_buffer                      , OES_texture_buffer                     ,  x ,  x ,  x ,  31, 2014)
 EXT(EXT_texture_compression_dxt1            , ANGLE_texture_compression_dxt          , GLL, GLC, ES1, ES2, 2004)
 EXT(EXT_texture_compression_latc            , EXT_texture_compression_latc           , GLL,  x ,  x ,  x , 2006)
-EXT(EXT_texture_compression_rgtc            , ARB_texture_compression_rgtc           , GLL, GLC,  x ,  x , 2004)
+EXT(EXT_texture_compression_rgtc            , ARB_texture_compression_rgtc           , GLL, GLC,  x ,  30, 2004)
 EXT(EXT_texture_compression_s3tc            , EXT_texture_compression_s3tc           , GLL, GLC,  x , ES2, 2000)
 EXT(EXT_texture_cube_map                    , ARB_texture_cube_map                   , GLL,  x ,  x ,  x , 2001)
 EXT(EXT_texture_cube_map_array              , OES_texture_cube_map_array             ,  x ,  x ,  x ,  31, 2014)
 EXT(EXT_texture_edge_clamp                  , dummy_true                             , GLL,  x ,  x ,  x , 1997)
 EXT(EXT_texture_env_add                     , dummy_true                             , GLL,  x ,  x ,  x , 1999)
 EXT(EXT_texture_env_combine                 , dummy_true                             , GLL,  x ,  x ,  x , 2000)
 EXT(EXT_texture_env_dot3                    , EXT_texture_env_dot3                   , GLL,  x ,  x ,  x , 2000)
 EXT(EXT_texture_filter_anisotropic          , EXT_texture_filter_anisotropic         , GLL, GLC, ES1, ES2, 1999)
 EXT(EXT_texture_format_BGRA8888             , dummy_true                             ,  x ,  x , ES1, ES2, 2005)
 EXT(EXT_texture_integer                     , EXT_texture_integer                    , GLL, GLC,  x ,  x , 2006)
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 7506c238232..77e0d94a71b 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1372,21 +1372,22 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)
    case MESA_FORMAT_LAYOUT_S3TC:
       if (_mesa_get_format_color_encoding(m_format) == GL_LINEAR) {
          return _mesa_has_EXT_texture_compression_s3tc(ctx);
       } else {
          return _mesa_has_EXT_texture_sRGB(ctx) &&
             _mesa_has_EXT_texture_compression_s3tc(ctx);
       }
    case MESA_FORMAT_LAYOUT_FXT1:
       return _mesa_has_3DFX_texture_compression_FXT1(ctx);
    case MESA_FORMAT_LAYOUT_RGTC:
-      return _mesa_has_ARB_texture_compression_rgtc(ctx);
+      return _mesa_has_ARB_texture_compression_rgtc(ctx) ||
+             _mesa_has_EXT_texture_compression_rgtc(ctx);
    case MESA_FORMAT_LAYOUT_LATC:
       return _mesa_has_EXT_texture_compression_latc(ctx);
    case MESA_FORMAT_LAYOUT_ETC1:
       return _mesa_has_OES_compressed_ETC1_RGB8_texture(ctx);
    case MESA_FORMAT_LAYOUT_ETC2:
       return _mesa_is_gles3(ctx) || _mesa_has_ARB_ES3_compatibility(ctx);
    case MESA_FORMAT_LAYOUT_BPTC:
       return _mesa_has_ARB_texture_compression_bptc(ctx);
    case MESA_FORMAT_LAYOUT_ASTC:
       return _mesa_has_KHR_texture_compression_astc_ldr(ctx);
@@ -3117,26 +3118,30 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
       default:
          return GL_INVALID_OPERATION;
       }
       break;
 
    case GL_RG:
       if (!_mesa_has_rg_textures(ctx))
          return GL_INVALID_OPERATION;
       switch (type) {
       case GL_UNSIGNED_BYTE:
-         if (internalFormat != GL_RG8)
+         if (internalFormat != GL_RG8 &&
+             (!_mesa_has_EXT_texture_compression_rgtc(ctx) ||
+              internalFormat != GL_COMPRESSED_RED_GREEN_RGTC2_EXT))
             return GL_INVALID_OPERATION;
          break;
 
       case GL_BYTE:
-         if (internalFormat != GL_RG8_SNORM)
+         if (internalFormat != GL_RG8_SNORM &&
+             (!_mesa_has_EXT_texture_compression_rgtc(ctx) ||
+              internalFormat != GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT))
             return GL_INVALID_OPERATION;
          break;
 
       case GL_UNSIGNED_SHORT:
          if (!_mesa_has_EXT_texture_norm16(ctx) || internalFormat != GL_RG16)
             return GL_INVALID_OPERATION;
          break;
 
       case GL_SHORT:
          if (!_mesa_has_EXT_texture_norm16(ctx) ||
@@ -3220,26 +3225,30 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
       }
       break;
 
    case GL_RED:
       if (!_mesa_has_rg_textures(ctx))
          return GL_INVALID_OPERATION;
       switch (type) {
       case GL_UNSIGNED_BYTE:
          if (internalFormat == GL_R8 ||
              ((internalFormat == GL_SR8_EXT) &&
-              _mesa_has_EXT_texture_sRGB_R8(ctx)))
+              _mesa_has_EXT_texture_sRGB_R8(ctx)) ||
+             (internalFormat == GL_COMPRESSED_RED_RGTC1_EXT &&
+              _mesa_has_EXT_texture_compression_rgtc(ctx)))
             break;
          return GL_INVALID_OPERATION;
 
       case GL_BYTE:
-         if (internalFormat != GL_R8_SNORM)
+         if (internalFormat != GL_R8_SNORM &&
+             (!_mesa_has_EXT_texture_compression_rgtc(ctx) ||
+              internalFormat != GL_COMPRESSED_SIGNED_RED_RGTC1_EXT))
             return GL_INVALID_OPERATION;
          break;
 
       case GL_UNSIGNED_SHORT:
          if (!_mesa_has_EXT_texture_norm16(ctx) || internalFormat != GL_R16)
             return GL_INVALID_OPERATION;
          break;
 
       case GL_SHORT:
          if (!_mesa_has_EXT_texture_norm16(ctx) ||
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 1c128e42c2a..dcdb81ec111 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -320,20 +320,29 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
     *     "New State
     *
     *         The queries for NUM_COMPRESSED_TEXTURE_FORMATS and
     *         COMPRESSED_TEXTURE_FORMATS include ETC1_RGB8_OES."
     */
    if (_mesa_is_gles(ctx)
        && ctx->Extensions.OES_compressed_ETC1_RGB8_texture) {
       formats[n++] = GL_ETC1_RGB8_OES;
    }
 
+   /* Required by EXT_texture_compression_rgtc in GLES. */
+   if (_mesa_is_gles3(ctx) &&
+       _mesa_has_EXT_texture_compression_rgtc(ctx)) {
+      formats[n++] = GL_COMPRESSED_RED_RGTC1_EXT;
+      formats[n++] = GL_COMPRESSED_SIGNED_RED_RGTC1_EXT;
+      formats[n++] = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
+      formats[n++] = GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
+   }
+
    if (ctx->API == API_OPENGLES) {
       formats[n++] = GL_PALETTE4_RGB8_OES;
       formats[n++] = GL_PALETTE4_RGBA8_OES;
       formats[n++] = GL_PALETTE4_R5_G6_B5_OES;
       formats[n++] = GL_PALETTE4_RGBA4_OES;
       formats[n++] = GL_PALETTE4_RGB5_A1_OES;
       formats[n++] = GL_PALETTE8_RGB8_OES;
       formats[n++] = GL_PALETTE8_RGBA8_OES;
       formats[n++] = GL_PALETTE8_R5_G6_B5_OES;
       formats[n++] = GL_PALETTE8_RGBA4_OES;
-- 
2.17.1



More information about the mesa-dev mailing list