[Mesa-dev] [PATCH 10/15] gallium: Remove util_format_s3tc_enabled

Matt Turner mattst88 at gmail.com
Mon Oct 2 06:59:51 UTC 2017


---
 src/gallium/auxiliary/util/u_format.c         |  4 --
 src/gallium/auxiliary/util/u_format_s3tc.c    | 54 +--------------------------
 src/gallium/auxiliary/util/u_format_s3tc.h    |  2 -
 src/gallium/drivers/llvmpipe/lp_screen.c      |  4 --
 src/gallium/drivers/llvmpipe/lp_test_format.c |  5 ---
 src/gallium/drivers/r300/r300_screen.c        |  2 +-
 src/gallium/drivers/r300/r300_texture.c       |  4 --
 src/gallium/drivers/r600/r600_state_common.c  |  4 --
 src/gallium/drivers/radeonsi/si_state.c       |  4 --
 src/gallium/drivers/softpipe/sp_screen.c      |  4 --
 src/gallium/drivers/swr/swr_screen.cpp        |  4 --
 src/gallium/drivers/virgl/virgl_screen.c      |  4 +-
 src/gallium/state_trackers/dri/dri_screen.c   | 13 -------
 src/gallium/tests/unit/u_format_test.c        |  5 ---
 14 files changed, 3 insertions(+), 110 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index a6d42a428d..0fc3231654 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -242,10 +242,6 @@ util_format_is_supported(enum pipe_format format, unsigned bind)
       return FALSE;
    }
 
-   if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) {
-      return FALSE;
-   }
-
 #ifndef TEXTURE_FLOAT_ENABLED
    if ((bind & PIPE_BIND_RENDER_TARGET) &&
        format != PIPE_FORMAT_R9G9B9E5_FLOAT &&
diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c
index 8c4f2150be..031255f2b3 100644
--- a/src/gallium/auxiliary/util/u_format_s3tc.c
+++ b/src/gallium/auxiliary/util/u_format_s3tc.c
@@ -28,17 +28,7 @@
 #include "u_format.h"
 #include "u_format_s3tc.h"
 #include "util/format_srgb.h"
-
-
-#if defined(_WIN32) || defined(WIN32)
-#define DXTN_LIBNAME "dxtn.dll"
-#elif defined(__CYGWIN__)
-#define DXTN_LIBNAME "cygtxc_dxtn.dll"
-#elif defined(__APPLE__)
-#define DXTN_LIBNAME "libtxc_dxtn.dylib"
-#else
-#define DXTN_LIBNAME "libtxc_dxtn.so"
-#endif
+#include "../../../mesa/main/texcompress_s3tc_tmp.h"
 
 
 static void
@@ -93,8 +83,6 @@ util_format_dxtn_pack_stub(int src_comps,
 }
 
 
-boolean util_format_s3tc_enabled = FALSE;
-
 util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = util_format_dxt1_rgb_fetch_stub;
 util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = util_format_dxt1_rgba_fetch_stub;
 util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = util_format_dxt3_rgba_fetch_stub;
@@ -107,56 +95,16 @@ void
 util_format_s3tc_init(void)
 {
    static boolean first_time = TRUE;
-   struct util_dl_library *library = NULL;
-   util_dl_proc fetch_2d_texel_rgb_dxt1;
-   util_dl_proc fetch_2d_texel_rgba_dxt1;
-   util_dl_proc fetch_2d_texel_rgba_dxt3;
-   util_dl_proc fetch_2d_texel_rgba_dxt5;
-   util_dl_proc tx_compress_dxtn;
 
    if (!first_time)
       return;
    first_time = FALSE;
 
-   if (util_format_s3tc_enabled)
-      return;
-
-   library = util_dl_open(DXTN_LIBNAME);
-   if (!library) {
-      debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
-                   "compression/decompression unavailable\n");
-      return;
-   }
-
-   fetch_2d_texel_rgb_dxt1 =
-         util_dl_get_proc_address(library, "fetch_2d_texel_rgb_dxt1");
-   fetch_2d_texel_rgba_dxt1 =
-         util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt1");
-   fetch_2d_texel_rgba_dxt3 =
-         util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt3");
-   fetch_2d_texel_rgba_dxt5 =
-         util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt5");
-   tx_compress_dxtn =
-         util_dl_get_proc_address(library, "tx_compress_dxtn");
-
-   if (!util_format_dxt1_rgb_fetch ||
-       !util_format_dxt1_rgba_fetch ||
-       !util_format_dxt3_rgba_fetch ||
-       !util_format_dxt5_rgba_fetch ||
-       !util_format_dxtn_pack) {
-      debug_printf("couldn't reference all symbols in " DXTN_LIBNAME
-                   ", software DXTn compression/decompression "
-                   "unavailable\n");
-      util_dl_close(library);
-      return;
-   }
-
    util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgb_dxt1;
    util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt1;
    util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt3;
    util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt5;
    util_format_dxtn_pack = (util_format_dxtn_pack_t)tx_compress_dxtn;
-   util_format_s3tc_enabled = TRUE;
 }
 
 
diff --git a/src/gallium/auxiliary/util/u_format_s3tc.h b/src/gallium/auxiliary/util/u_format_s3tc.h
index ae20010cdf..42e62bdbb2 100644
--- a/src/gallium/auxiliary/util/u_format_s3tc.h
+++ b/src/gallium/auxiliary/util/u_format_s3tc.h
@@ -58,8 +58,6 @@ typedef void
                             uint8_t *dst,
                             int dst_stride);
 
-extern boolean util_format_s3tc_enabled;
-
 extern util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch;
 extern util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch;
 extern util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch;
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 53171162a5..7b694b5755 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -532,10 +532,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
        format != PIPE_FORMAT_ETC1_RGB8)
       return FALSE;
 
-   if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-      return util_format_s3tc_enabled;
-   }
-
    /*
     * Everything can be supported by u_format
     * (those without fetch_rgba_float might be not but shouldn't hit that)
diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index 9b16162131..fd79087287 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_format.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -383,11 +383,6 @@ test_all(unsigned verbose, FILE *fp)
       if (util_format_is_pure_integer(format))
 	 continue;
 
-      if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC &&
-          !util_format_s3tc_enabled) {
-         continue;
-      }
-
       /* only have util fetch func for etc1 */
       if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
           format != PIPE_FORMAT_ETC1_RGB8) {
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 0c3e097535..6d6b5fb74a 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -127,7 +127,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
 
         /* r300 cannot do swizzling of compressed textures. Supported otherwise. */
         case PIPE_CAP_TEXTURE_SWIZZLE:
-            return util_format_s3tc_enabled ? r300screen->caps.dxtc_swizzle : 1;
+            return r300screen->caps.dxtc_swizzle;
 
         /* We don't support color clamping on r500, so that we can use color
          * intepolators for generic varyings. */
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 8873c54ebc..0658205f87 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -250,10 +250,6 @@ uint32_t r300_translate_texformat(enum pipe_format format,
 
     /* S3TC formats. */
     if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-        if (!util_format_s3tc_enabled) {
-            return ~0; /* Unsupported. */
-        }
-
         switch (format) {
             case PIPE_FORMAT_DXT1_RGB:
             case PIPE_FORMAT_DXT1_RGBA:
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 7e2b34bf79..0e8c5d666e 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -2405,10 +2405,6 @@ uint32_t r600_translate_texformat(struct pipe_screen *screen,
 	}
 
 	if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-		if (!util_format_s3tc_enabled) {
-			goto out_unknown;
-		}
-
 		switch (format) {
 		case PIPE_FORMAT_DXT1_RGB:
 		case PIPE_FORMAT_DXT1_RGBA:
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index e82ca6a694..f0e2083000 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1697,10 +1697,6 @@ static uint32_t si_translate_texformat(struct pipe_screen *screen,
 		if (!enable_compressed_formats)
 			goto out_unknown;
 
-		if (!util_format_s3tc_enabled) {
-			goto out_unknown;
-		}
-
 		switch (format) {
 		case PIPE_FORMAT_DXT1_RGB:
 		case PIPE_FORMAT_DXT1_RGBA:
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 7e9d9e6592..50eefe65af 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -460,10 +460,6 @@ softpipe_is_format_supported( struct pipe_screen *screen,
     * All other operations (sampling, transfer, etc).
     */
 
-   if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-      return util_format_s3tc_enabled;
-   }
-
    /*
     * Everything else should be supported by u_format.
     */
diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
index ee7782d648..3ae56f52d5 100644
--- a/src/gallium/drivers/swr/swr_screen.cpp
+++ b/src/gallium/drivers/swr/swr_screen.cpp
@@ -147,10 +147,6 @@ swr_is_format_supported(struct pipe_screen *_screen,
       return FALSE;
    }
 
-   if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-      return util_format_s3tc_enabled;
-   }
-
    return TRUE;
 }
 
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index 935ce2f9b0..f2636aac38 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -486,9 +486,7 @@ virgl_is_format_supported( struct pipe_screen *screen,
     */
 
    if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-      if (util_format_s3tc_enabled)
-         goto out_lookup;
-      return FALSE;
+      goto out_lookup;
    }
    if (format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC) {
       goto out_lookup;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 1d9f441223..803264a58f 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -505,19 +505,6 @@ dri_init_screen_helper(struct dri_screen *screen,
    else
       screen->target = PIPE_TEXTURE_RECT;
 
-   /* Handle force_s3tc_enable. */
-   if (!util_format_s3tc_enabled && screen->options.force_s3tc_enable) {
-      /* Ensure libtxc_dxtn has been loaded if available.
-       * Forcing S3TC on before calling this would prevent loading
-       * the library.
-       * This is just a precaution, the driver should have called it
-       * already.
-       */
-      util_format_s3tc_init();
-
-      util_format_s3tc_enabled = TRUE;
-   }
-
    dri_postprocessing_init(screen);
 
    screen->st_api->query_versions(screen->st_api, &screen->base,
diff --git a/src/gallium/tests/unit/u_format_test.c b/src/gallium/tests/unit/u_format_test.c
index 69d6c7dd3a..2152b227f6 100644
--- a/src/gallium/tests/unit/u_format_test.c
+++ b/src/gallium/tests/unit/u_format_test.c
@@ -722,11 +722,6 @@ test_all(void)
       assert(format_desc->block.height <= UTIL_FORMAT_MAX_UNPACKED_HEIGHT);
       assert(format_desc->block.width  <= UTIL_FORMAT_MAX_UNPACKED_WIDTH);
 
-      if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC &&
-          !util_format_s3tc_enabled) {
-         continue;
-      }
-
 #     define TEST_ONE_FUNC(name) \
       if (format_desc->name) { \
          if (!test_one_func(format_desc, &test_format_##name, #name)) { \
-- 
2.13.6



More information about the mesa-dev mailing list