summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2017-07-03 17:08:12 -0400
committerAndres Gomez <[email protected]>2017-07-12 19:32:08 +0300
commit2711a13a4fca238d0647558905f98e7f1170b67d (patch)
tree04c7c2a8e75954c4ab15a680f5fec9bab15509a7
parent9b4970b0354ae8fc9fdd64d18a46551ab0727d0c (diff)
glsl: check if any of the named builtins are available first
_mesa_glsl_has_builtin_function is used to determine whether any variant of a builtin are available, for the purpose of enforcing the GLSL ES 3.00+ rule that overloads or overrides of builtins are disallowed. However the builtin_builder contains information on all builtins, irrespective of parse state, or versions, or extension enablement. As a result we would say that a builtin existed even if it was not actually available. To resolve this, first check if at least one signature is available for a builtin before returning true. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101666 Signed-off-by: Ilia Mirkin <[email protected]> Cc: [email protected] Reviewed-by: Timothy Arceri <[email protected]> Acked-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> (cherry picked from commit 880f21f55d579fe2183255d031c23343da30f69e) [Andres Gomez: resolve trivial conflicts] Signed-off-by: Andres Gomez <[email protected]>
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp2
-rw-r--r--src/compiler/glsl/builtin_functions.cpp13
-rw-r--r--src/compiler/glsl/builtin_functions.h3
3 files changed, 14 insertions, 4 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 9ea37f4cf62..a9c0d0569da 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -5661,7 +5661,7 @@ ast_function::hir(exec_list *instructions,
if (state->es_shader && state->language_version >= 300) {
/* Local shader has no exact candidates; check the built-ins. */
_mesa_glsl_initialize_builtin_functions();
- if (_mesa_glsl_has_builtin_function(name)) {
+ if (_mesa_glsl_has_builtin_function(state, name)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state,
"A shader cannot redefine or overload built-in "
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 5d62d9f8ee9..92e7ea0da02 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -6121,14 +6121,23 @@ _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
}
bool
-_mesa_glsl_has_builtin_function(const char *name)
+_mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name)
{
ir_function *f;
+ bool ret = false;
mtx_lock(&builtins_lock);
f = builtins.shader->symbols->get_function(name);
+ if (f != NULL) {
+ foreach_in_list(ir_function_signature, sig, &f->signatures) {
+ if (sig->is_builtin_available(state)) {
+ ret = true;
+ break;
+ }
+ }
+ }
mtx_unlock(&builtins_lock);
- return f != NULL;
+ return ret;
}
gl_shader *
diff --git a/src/compiler/glsl/builtin_functions.h b/src/compiler/glsl/builtin_functions.h
index 14a52b94027..2053c82b745 100644
--- a/src/compiler/glsl/builtin_functions.h
+++ b/src/compiler/glsl/builtin_functions.h
@@ -32,7 +32,8 @@ _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
const char *name, exec_list *actual_parameters);
extern bool
-_mesa_glsl_has_builtin_function(const char *name);
+_mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state,
+ const char *name);
extern gl_shader *
_mesa_glsl_get_builtin_function_shader(void);