diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 97e37e49f4d..a141b8789ed 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -144,7 +144,7 @@ deprecated_texture(const _mesa_glsl_parse_state *state)
static bool
deprecated_texture_derivatives_only(const _mesa_glsl_parse_state *state)
{
- return deprecated_texture(state) && derivatives_only(state);
+ return (deprecated_texture(state) && derivatives_only(state)) || state->allow_vertex_texture_bias;
}
static bool
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 8795b0ac6b2..c5435f9f296 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -317,6 +317,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
sizeof(this->atomic_counter_offsets));
this->allow_extension_directive_midshader =
ctx->Const.AllowGLSLExtensionDirectiveMidShader;
+ this->alias_shader_extension =
+ ctx->Const.AliasShaderExtension;
+ this->allow_vertex_texture_bias =
+ ctx->Const.AllowVertexTextureBias;
this->allow_glsl_120_subset_in_110 =
ctx->Const.AllowGLSL120SubsetIn110;
this->allow_builtin_variable_redeclaration =
@@ -814,17 +818,51 @@ void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state,
state->*(this->warn_flag) = (behavior == extension_warn);
}
+/**
+ * Check alias_shader_extension for any aliased shader extensions
+ */
+static const char *find_extension_alias(_mesa_glsl_parse_state *state, const char *name)
+{
+ char *exts, *field, *ext_alias = NULL;
+
+ /* Copy alias_shader_extension because strtok() is destructive. */
+ exts = strdup(state->alias_shader_extension);
+ if (exts) {
+ for (field = strtok(exts, ","); field != NULL; field = strtok(NULL, ",")) {
+ if(strncmp(name, field, strlen(name)) == 0) {
+ field = strstr(field, ":");
+ if(field) {
+ ext_alias = strdup(field + 1);
+ }
+ break;
+ }
+ }
+
+ free(exts);
+ }
+ return ext_alias;
+}
+
/**
* Find an extension by name in _mesa_glsl_supported_extensions. If
* the name is not found, return NULL.
*/
-static const _mesa_glsl_extension *find_extension(const char *name)
+static const _mesa_glsl_extension *find_extension(_mesa_glsl_parse_state *state, const char *name)
{
+ const char *ext_alias = NULL;
+ if (state->alias_shader_extension) {
+ ext_alias = find_extension_alias(state, name);
+ name = ext_alias ? ext_alias : name;
+ }
+
for (unsigned i = 0; i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) {
if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) {
+ free((void *)ext_alias);
return &_mesa_glsl_supported_extensions[i];
}
}
+
+ free((void *)ext_alias);
return NULL;
}
@@ -879,7 +917,7 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
}
}
} else {
- const _mesa_glsl_extension *extension = find_extension(name);
+ const _mesa_glsl_extension *extension = find_extension(state, name);
if (extension &&
(extension->compatible_with_state(state, api, gl_version) ||
(state->consts->AllowGLSLCompatShaders &&
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index 8e69cfcf67c..3d956a97004 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -961,6 +961,8 @@ struct _mesa_glsl_parse_state {
bool layer_viewport_relative;
bool allow_extension_directive_midshader;
+ char *alias_shader_extension;
+ bool allow_vertex_texture_bias;
bool allow_glsl_120_subset_in_110;
bool allow_builtin_variable_redeclaration;
bool ignore_write_to_readonly_var;
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index c4f34c6ea5f..f764916b630 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -21,6 +21,8 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED(false)
DRI_CONF_DISABLE_ARB_GPU_SHADER5(false)
DRI_CONF_DISABLE_UNIFORM_ARRAY_RESIZE(false)
+ DRI_CONF_ALIAS_SHADER_EXTENSION()
+ DRI_CONF_ALLOW_VERTEX_TEXTURE_BIAS(false)
DRI_CONF_FORCE_GLSL_VERSION(0)
DRI_CONF_ALLOW_EXTRA_PP_TOKENS(false)
DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER(false)
diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c
index 7280cfb6e18..165de18b131 100644
--- a/src/gallium/auxiliary/util/u_driconf.c
+++ b/src/gallium/auxiliary/util/u_driconf.c
@@ -42,6 +42,8 @@ u_driconf_fill_st_options(struct st_config_options *options,
query_bool_option(disable_arb_gpu_shader5);
query_bool_option(disable_glsl_line_continuations);
query_bool_option(disable_uniform_array_resize);
+ query_string_option(alias_shader_extension);
+ query_bool_option(allow_vertex_texture_bias);
query_bool_option(force_compat_shaders);
query_bool_option(force_glsl_extensions_warn);
query_int_option(force_glsl_version);
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h
index bef0a8d7cd1..712cbe9e47e 100644
--- a/src/gallium/include/frontend/api.h
+++ b/src/gallium/include/frontend/api.h
@@ -171,6 +171,8 @@ struct st_config_options
bool disable_glsl_line_continuations;
bool disable_arb_gpu_shader5;
bool disable_uniform_array_resize;
+ char *alias_shader_extension;
+ bool allow_vertex_texture_bias;
bool force_compat_shaders;
bool force_glsl_extensions_warn;
unsigned force_glsl_version;
diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h
index 0245a06707c..b80f69b1e11 100644
--- a/src/mesa/main/consts_exts.h
+++ b/src/mesa/main/consts_exts.h
@@ -798,6 +798,16 @@ struct gl_constants
*/
bool DisableUniformArrayResize;
+ /**
+ * Alias extension e.g. GL_ATI_shader_texture_lod to GL_ARB_shader_texture_lod.
+ */
+ char *AliasShaderExtension;
+
+ /**
+ * Allow fs-only bias argument in vertex shaders.
+ */
+ GLboolean AllowVertexTextureBias;
+
/**
* Align varyings to POT in a slot
*
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index c19f3084ad0..8cc079ec47a 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1468,6 +1468,11 @@ void st_init_extensions(struct pipe_screen *screen,
if (options->disable_uniform_array_resize)
consts->DisableUniformArrayResize = 1;
+ consts->AliasShaderExtension = options->alias_shader_extension;
+
+ if (options->allow_vertex_texture_bias)
+ consts->AllowVertexTextureBias = GL_TRUE;
+
if (options->allow_glsl_extension_directive_midshader)
consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE;
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index 37b34af6f1b..fc033542de1 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -161,6 +161,12 @@ TODO: document the other workarounds.
+
+
+
+
+
+
diff --git a/src/util/driconf.h b/src/util/driconf.h
index c6409ec3f69..b9132f00e49 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -168,6 +168,13 @@
DRI_CONF_OPT_B(disable_uniform_array_resize, def, \
"Disable the glsl optimisation that resizes uniform arrays")
+#define DRI_CONF_ALIAS_SHADER_EXTENSION() \
+ DRI_CONF_OPT_S_NODEF(alias_shader_extension, "Allow alias for shader extensions")
+
+#define DRI_CONF_ALLOW_VERTEX_TEXTURE_BIAS(def) \
+ DRI_CONF_OPT_B(allow_vertex_texture_bias, def, \
+ "Allow GL2 vertex shaders to have access to texture2D/textureCube with bias variants")
+
#define DRI_CONF_FORCE_GLSL_VERSION(def) \
DRI_CONF_OPT_I(force_glsl_version, def, 0, 999, \
"Force a default GLSL version for shaders that lack an explicit #version line")