[Mesa-dev] [PATCH 2/3] mesa: expose EXT_texture_compression_bptc in GLES

Marek Olšák maraeo at gmail.com
Thu Nov 29 01:22:19 UTC 2018


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

tested by piglit.
---
 docs/relnotes/19.0.0.html        |  1 +
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/glformats.c        | 13 +++++++++++--
 src/mesa/main/texcompress.c      |  9 +++++++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/docs/relnotes/19.0.0.html b/docs/relnotes/19.0.0.html
index 50cdda6cbc7..d10bd2cf720 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_bptc on all GL 4.0 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 dd7a4d45079..45ee7675ab2 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -269,20 +269,21 @@ EXT(EXT_shadow_funcs                        , ARB_shadow
 EXT(EXT_stencil_two_side                    , EXT_stencil_two_side                   , GLL,  x ,  x ,  x , 2001)
 EXT(EXT_stencil_wrap                        , dummy_true                             , GLL,  x ,  x ,  x , 2002)
 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_bptc            , ARB_texture_compression_bptc           ,  x ,  x ,  x ,  30, 2017)
 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 ,  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)
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index bacaa9519ca..98ae5d93234 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1389,22 +1389,21 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)
       return ctx->Extensions.ARB_texture_compression_rgtc;
    case MESA_FORMAT_LAYOUT_LATC:
       return ctx->API == API_OPENGL_COMPAT
          && ctx->Extensions.EXT_texture_compression_latc;
    case MESA_FORMAT_LAYOUT_ETC1:
       return _mesa_is_gles(ctx)
          && ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
    case MESA_FORMAT_LAYOUT_ETC2:
       return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility;
    case MESA_FORMAT_LAYOUT_BPTC:
-      return _mesa_is_desktop_gl(ctx) &&
-         ctx->Extensions.ARB_texture_compression_bptc;
+      return ctx->Extensions.ARB_texture_compression_bptc;
    case MESA_FORMAT_LAYOUT_ASTC:
       return ctx->Extensions.KHR_texture_compression_astc_ldr;
    default:
       return GL_FALSE;
    }
 }
 
 /**
  * Test if the given format represents an sRGB format.
  * \param format the GL format (can be an internal format)
@@ -2834,20 +2833,25 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
          switch (internalFormat) {
          case GL_RGBA:
          case GL_RGBA8:
          case GL_RGB5_A1:
          case GL_RGBA4:
             break;
          case GL_SRGB8_ALPHA8_EXT:
             if (ctx->Version <= 20)
                return GL_INVALID_OPERATION;
             break;
+         case GL_COMPRESSED_RGBA_BPTC_UNORM:
+         case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
+            if (!ctx->Extensions.ARB_texture_compression_bptc)
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }
          break;
 
       case GL_BYTE:
          if (ctx->Version <= 20 || internalFormat != GL_RGBA8_SNORM)
             return GL_INVALID_OPERATION;
          break;
 
@@ -3038,20 +3042,25 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
          case GL_RGB16F:
          case GL_RGB32F:
          case GL_R11F_G11F_B10F:
          case GL_RGB9_E5:
             if (ctx->Version <= 20)
                return GL_INVALID_OPERATION;
             break;
          case GL_RGB:
             if (ctx->Extensions.OES_texture_float && internalFormat == format)
                break;
+         case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
+         case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
+            if (!ctx->Extensions.ARB_texture_compression_bptc)
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }
          break;
 
       case GL_HALF_FLOAT_OES:
          if (!ctx->Extensions.OES_texture_half_float || internalFormat != format)
             return GL_INVALID_OPERATION;
          break;
 
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index edbee168c88..fb1bb46f1e7 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_bptc in GLES. */
+   if (_mesa_is_gles3(ctx) &&
+       ctx->Extensions.ARB_texture_compression_bptc) {
+      formats[n++] = GL_COMPRESSED_RGBA_BPTC_UNORM;
+      formats[n++] = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
+      formats[n++] = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT;
+      formats[n++] = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT;
+   }
+
    /* Required by EXT_texture_compression_rgtc in GLES. */
    if (_mesa_is_gles3(ctx) &&
        ctx->Extensions.ARB_texture_compression_rgtc) {
       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) {
-- 
2.17.1



More information about the mesa-dev mailing list