st/mesa: Add GL_TDFX_texture_compression_FXT1 support
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 27 Nov 2019 10:41:47 +0000 (02:41 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 2 Dec 2019 06:55:21 +0000 (22:55 -0800)
Eric recently added PIPE_FORMAT_FXT1_RGB[A] as part of his format
unification work.  This was really most of the work of implementing
the extension.  We just need to handle it in a couple of places and
expose the extension.

v2: Reject the new formats in llvmpipe_is_format_supported to prevent
    crashes because it doesn't know how to handle the new formats.

Reviewed-by: Marek Olšák <marek.olsak@amd.com> [v1]
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
src/gallium/drivers/llvmpipe/lp_screen.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_format.c
src/util/format/u_format.h

index c036108d318dbe9cc521def33b416e0a8fc6694f..080b0635c64c0ce43b8a67b016f27666a5718b1d 100644 (file)
@@ -665,7 +665,8 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
    }
 
    if (format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC ||
-       format_desc->layout == UTIL_FORMAT_LAYOUT_ATC) {
+       format_desc->layout == UTIL_FORMAT_LAYOUT_ATC ||
+       format_desc->layout == UTIL_FORMAT_LAYOUT_FXT1) {
       /* Software decoding is not hooked up. */
       return false;
    }
index ace19c59b0eb5ef7e1acacc5dd467da451036fa4..df5f16efd629ecddf5890c3e4e951c12e83355ae 100644 (file)
@@ -2046,6 +2046,8 @@ st_GetTexSubImage(struct gl_context * ctx,
       case PIPE_FORMAT_ASTC_12x10:
       case PIPE_FORMAT_ASTC_12x12:
       case PIPE_FORMAT_BPTC_RGBA_UNORM:
+      case PIPE_FORMAT_FXT1_RGB:
+      case PIPE_FORMAT_FXT1_RGBA:
          dst_glformat = GL_RGBA8;
          break;
       case PIPE_FORMAT_RGTC1_SNORM:
index 252e04c07168055544baa27a9b24f8ff28f8bef7..f31ea043ee0d0a0e1dd19607572ea34d8cf6311c 100644 (file)
@@ -877,6 +877,10 @@ void st_init_extensions(struct pipe_screen *screen,
           PIPE_FORMAT_BPTC_RGB_FLOAT,
           PIPE_FORMAT_BPTC_RGB_UFLOAT } },
 
+      { { o(TDFX_texture_compression_FXT1) },
+        { PIPE_FORMAT_FXT1_RGB,
+          PIPE_FORMAT_FXT1_RGBA } },
+
       { { o(KHR_texture_compression_astc_ldr),
           o(KHR_texture_compression_astc_sliced_3d) },
         { PIPE_FORMAT_ASTC_4x4,
index c0e9e25c71d13ee6bd1e8efd34c51590d534cc88..4bbb781932d0de846e3387eaf891e7afa2f073bf 100644 (file)
@@ -332,16 +332,14 @@ static const struct format_mapping format_map[] = {
       { PIPE_FORMAT_DXT5_RGBA, 0 }
    },
 
-#if 0
    {
       { GL_COMPRESSED_RGB_FXT1_3DFX, 0 },
-      { PIPE_FORMAT_RGB_FXT1, 0 }
+      { PIPE_FORMAT_FXT1_RGB, 0 }
    },
    {
       { GL_COMPRESSED_RGBA_FXT1_3DFX, 0 },
-      { PIPE_FORMAT_RGBA_FXT1, 0 }
+      { PIPE_FORMAT_FXT1_RGBA, 0 }
    },
-#endif
 
    /* Depth formats */
    {
index eec7a185f94cb17e2963ab239c6f080d822a9acd..b85bd217b2eebb0f6ea7d752eb13a75aa22781f9 100644 (file)
@@ -495,6 +495,7 @@ util_format_is_compressed(enum pipe_format format)
    case UTIL_FORMAT_LAYOUT_BPTC:
    case UTIL_FORMAT_LAYOUT_ASTC:
    case UTIL_FORMAT_LAYOUT_ATC:
+   case UTIL_FORMAT_LAYOUT_FXT1:
       /* XXX add other formats in the future */
       return TRUE;
    default: