Commit 83dbe61e authored by Marek Olšák's avatar Marek Olšák

st/dri: implement the driconf option force_s3tc_enable properly

Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent f27f3a4b
......@@ -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;
}
......
......@@ -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;
};
/**
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment