Module: Mesa
Branch: main
Commit: a921a69010102c6e35267066dc8a50461cae46fd
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a921a69010102c6e35267066dc8a50461cae46fd

Author: Pavel Asyutchenko <[email protected]>
Date:   Tue Nov 28 21:44:53 2023 +0100

mesa/main: allow S3TC for 3D textures

This is allowed by D3D, RADV, ANV and Nvidia GL drivers
at least, so it should work on any hardware with S3TC.

Confirmed to work in OpenXRay on radeonsi.

Signed-off-by: Pavel Asyutchenko <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26389>

---

 src/mesa/main/teximage.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 7318a3d4a59..9d4b386613b 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1577,6 +1577,21 @@ _mesa_target_can_be_compressed(const struct gl_context 
*ctx, GLenum target,
       case MESA_FORMAT_LAYOUT_BPTC:
          target_can_be_compresed = 
ctx->Extensions.ARB_texture_compression_bptc;
          break;
+      case MESA_FORMAT_LAYOUT_S3TC:
+         /* From the EXT_texture_compression_s3tc spec:
+          *
+          *      In extended OpenGL ES 3.0.2 these new tokens are also 
accepted by the
+          *      <internalformat> parameter of TexImage3D, 
CompressedTexImage3D,
+          *      TexStorage2D, TexStorage3D and the <format> parameter of
+          *      CompressedTexSubImage3D.
+          *
+          * The spec does not clarify whether the same applies to newer 
desktop GL versions
+          * (where 3D textures were introduced), check compatibility ext to be 
safe.
+          */
+         target_can_be_compresed =
+            ctx->Extensions.EXT_texture_compression_s3tc &&
+            (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility);
+         break;
       case MESA_FORMAT_LAYOUT_ASTC:
          target_can_be_compresed =
             ctx->Extensions.KHR_texture_compression_astc_hdr ||
@@ -5532,6 +5547,11 @@ compressed_subtexture_target_check(struct gl_context 
*ctx, GLenum target,
          case MESA_FORMAT_LAYOUT_BPTC:
             /* valid format */
             break;
+         case MESA_FORMAT_LAYOUT_S3TC:
+            targetOK =
+               ctx->Extensions.EXT_texture_compression_s3tc &&
+               (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility);
+            break;
          case MESA_FORMAT_LAYOUT_ASTC:
             targetOK =
                ctx->Extensions.KHR_texture_compression_astc_hdr ||

Reply via email to