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_find_builtin_function_by_name(name)) {
+ if (_mesa_glsl_has_builtin_function(name)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state,
"A shader cannot redefine or overload built-in "
#include "program/prog_instruction.h"
#include <math.h>
#include "builtin_functions.h"
+#include "util/hash_table.h"
#define M_PIf ((float) M_PI)
#define M_PI_2f ((float) M_PI_2)
_mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
const char *name, exec_list *actual_parameters)
{
- ir_function_signature * s;
+ ir_function_signature *s;
mtx_lock(&builtins_lock);
s = builtins.find(state, name, actual_parameters);
mtx_unlock(&builtins_lock);
- return s;
+
+ if (s == NULL)
+ return NULL;
+
+ struct hash_table *ht =
+ _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+ void *mem_ctx = state;
+ ir_function *f = s->function()->clone(mem_ctx, ht);
+ _mesa_hash_table_destroy(ht, NULL);
+
+ return f->matching_signature(state, actual_parameters, true);
}
-ir_function *
-_mesa_glsl_find_builtin_function_by_name(const char *name)
+bool
+_mesa_glsl_has_builtin_function(const char *name)
{
ir_function *f;
mtx_lock(&builtins_lock);
f = builtins.shader->symbols->get_function(name);
mtx_unlock(&builtins_lock);
- return f;
+
+ return f != NULL;
}
gl_shader *
_mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
const char *name, exec_list *actual_parameters);
-extern ir_function *
-_mesa_glsl_find_builtin_function_by_name(const char *name);
+extern bool
+_mesa_glsl_has_builtin_function(const char *name);
extern gl_shader *
_mesa_glsl_get_builtin_function_shader(void);