summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-07-30 22:29:18 +0200
committerMarek Olšák <[email protected]>2013-07-30 23:31:24 +0200
commit83dbe61ea4308638f1c041d2f550f0f719e36967 (patch)
tree80708f40e9455509a9c24cd6f01e33ed14372ec7
parentf27f3a4b15449e9ba3c0ee4e01b9db753e48e55f (diff)
st/dri: implement the driconf option force_s3tc_enable properly
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/auxiliary/util/u_format_s3tc.c12
-rw-r--r--src/gallium/include/state_tracker/st_api.h1
-rw-r--r--src/gallium/state_trackers/dri/common/dri_context.c2
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.c19
-rw-r--r--src/gallium/state_trackers/osmesa/osmesa.c1
-rw-r--r--src/mesa/state_tracker/st_extensions.c10
6 files changed, 24 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c
index fd628157b60..11b46020bc3 100644
--- a/src/gallium/auxiliary/util/u_format_s3tc.c
+++ b/src/gallium/auxiliary/util/u_format_s3tc.c
@@ -111,7 +111,6 @@ util_format_s3tc_init(void)
util_dl_proc fetch_2d_texel_rgba_dxt3;
util_dl_proc fetch_2d_texel_rgba_dxt5;
util_dl_proc tx_compress_dxtn;
- char *force_s3tc_enable;
if (!first_time)
return;
@@ -122,15 +121,8 @@ util_format_s3tc_init(void)
library = util_dl_open(DXTN_LIBNAME);
if (!library) {
- if ((force_s3tc_enable = getenv("force_s3tc_enable")) &&
- !strcmp(force_s3tc_enable, "true")) {
- debug_printf("couldn't open " DXTN_LIBNAME ", enabling DXTn due to "
- "force_s3tc_enable=true environment variable\n");
- util_format_s3tc_enabled = TRUE;
- } else {
- debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
- "compression/decompression unavailable\n");
- }
+ debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
+ "compression/decompression unavailable\n");
return;
}
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index fd6d04c4a3d..2c178b6951d 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -242,6 +242,7 @@ struct st_config_options
boolean force_glsl_extensions_warn;
boolean disable_glsl_line_continuations;
boolean disable_blend_func_extended;
+ boolean force_s3tc_enable;
};
/**
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index 5794e487158..ab80fc75bd4 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -58,6 +58,8 @@ static void dri_fill_st_options(struct st_config_options *options,
driQueryOptionb(optionCache, "disable_glsl_line_continuations");
options->disable_blend_func_extended =
driQueryOptionb(optionCache, "disable_blend_func_extended");
+ options->force_s3tc_enable =
+ driQueryOptionb(optionCache, "force_s3tc_enable");
}
GLboolean
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c
index c8aed63f1d3..ca17742eb5b 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -41,6 +41,7 @@
#include "state_tracker/drm_driver.h"
#include "util/u_debug.h"
+#include "util/u_format_s3tc.h"
#define MSAA_VISUAL_MAX_SAMPLES 32
@@ -54,7 +55,7 @@ PUBLIC const char __driConfigOptions[] =
DRI_CONF_SECTION_END
DRI_CONF_SECTION_QUALITY
-/* DRI_CONF_FORCE_S3TC_ENABLE("false") */
+ DRI_CONF_FORCE_S3TC_ENABLE("false")
DRI_CONF_PP_CELSHADE(0)
DRI_CONF_PP_NORED(0)
DRI_CONF_PP_NOGREEN(0)
@@ -76,7 +77,7 @@ PUBLIC const char __driConfigOptions[] =
#define false 0
-static const uint __driNConfigOptions = 12;
+static const uint __driNConfigOptions = 13;
static const __DRIconfig **
dri_fill_in_modes(struct dri_screen *screen)
@@ -416,6 +417,20 @@ dri_init_screen_helper(struct dri_screen *screen,
screen->sPriv->myNum,
driver_descriptor.name);
+ /* Handle force_s3tc_enable. */
+ if (!util_format_s3tc_enabled &&
+ driQueryOptionb(&screen->optionCache, "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;
+ }
+
return dri_fill_in_modes(screen);
}
diff --git a/src/gallium/state_trackers/osmesa/osmesa.c b/src/gallium/state_trackers/osmesa/osmesa.c
index 5908316dc81..594372bd725 100644
--- a/src/gallium/state_trackers/osmesa/osmesa.c
+++ b/src/gallium/state_trackers/osmesa/osmesa.c
@@ -545,6 +545,7 @@ OSMesaCreateContextExt(GLenum format, GLint depthBits, GLint stencilBits,
attribs.options.force_glsl_extensions_warn = FALSE;
attribs.options.disable_blend_func_extended = FALSE;
attribs.options.disable_glsl_line_continuations = FALSE;
+ attribs.options.force_s3tc_enable = FALSE;
osmesa_init_st_visual(&attribs.visual,
PIPE_FORMAT_R8G8B8A8_UNORM,
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index b201012f9d2..6bc1284f826 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -289,14 +289,6 @@ void st_init_limits(struct st_context *st)
}
-static GLboolean st_get_s3tc_override(void)
-{
- const char *override = _mesa_getenv("force_s3tc_enable");
- if (override && !strcmp(override, "true"))
- return GL_TRUE;
- return GL_FALSE;
-}
-
/**
* Given a member \c x of struct gl_extensions, return offset of
* \c x in bytes.
@@ -628,7 +620,7 @@ void st_init_extensions(struct st_context *st)
/* Below are the cases which cannot be moved into tables easily. */
- if (!ctx->Mesa_DXTn && !st_get_s3tc_override()) {
+ if (!ctx->Mesa_DXTn && !st->options.force_s3tc_enable) {
ctx->Extensions.EXT_texture_compression_s3tc = GL_FALSE;
ctx->Extensions.ANGLE_texture_compression_dxt = GL_FALSE;
}