goto done; /* no match */
if (f != NULL) {
+ /* In desktop GL, the presence of a user-defined signature hides any
+ * built-in signatures, so we must ignore them. In contrast, in ES2
+ * user-defined signatures add new overloads, so we must consider them.
+ */
+ bool allow_builtins = state->es_shader || !f->has_user_signature();
+
/* Look for a match in the local shader. If exact, we're done. */
bool is_exact = false;
sig = local_sig = f->matching_signature(state, actual_parameters,
- &is_exact);
+ allow_builtins, &is_exact);
if (is_exact)
goto done;
- if (!state->es_shader && f->has_user_signature()) {
- /* In desktop GL, the presence of a user-defined signature hides any
- * built-in signatures, so we must ignore them. In contrast, in ES2
- * user-defined signatures add new overloads, so we must proceed.
- */
+ if (!allow_builtins)
goto done;
- }
}
/* Local shader has no exact candidates; check the built-ins. */
if (f == NULL)
return NULL;
- ir_function_signature *sig = f->matching_signature(state, actual_parameters);
+ ir_function_signature *sig =
+ f->matching_signature(state, actual_parameters, true);
if (sig == NULL)
return NULL;
*/
ir_function_signature *matching_signature(_mesa_glsl_parse_state *state,
const exec_list *actual_param,
+ bool allow_builtins,
bool *match_is_exact);
/**
* conversions into account.
*/
ir_function_signature *matching_signature(_mesa_glsl_parse_state *state,
- const exec_list *actual_param);
+ const exec_list *actual_param,
+ bool allow_builtins);
/**
* Find a signature that exactly matches a set of actual parameters without
ir_function_signature *
ir_function::matching_signature(_mesa_glsl_parse_state *state,
- const exec_list *actual_parameters)
+ const exec_list *actual_parameters,
+ bool allow_builtins)
{
bool is_exact;
- return matching_signature(state, actual_parameters, &is_exact);
+ return matching_signature(state, actual_parameters, allow_builtins,
+ &is_exact);
}
ir_function_signature *
ir_function::matching_signature(_mesa_glsl_parse_state *state,
const exec_list *actual_parameters,
+ bool allow_builtins,
bool *is_exact)
{
ir_function_signature **inexact_matches = NULL;
*/
foreach_in_list(ir_function_signature, sig, &this->signatures) {
/* Skip over any built-ins that aren't available in this shader. */
- if (sig->is_builtin() && !sig->is_builtin_available(state))
+ if (sig->is_builtin() && (!allow_builtins ||
+ !sig->is_builtin_available(state)))
continue;
switch (parameter_lists_match(state, & sig->parameters, actual_parameters)) {
return NULL;
}
- ir_function_signature *callee = f->matching_signature(state, ¶meters);
+ ir_function_signature *callee =
+ f->matching_signature(state, ¶meters, true);
if (callee == NULL) {
ir_read_error(expr, "couldn't find matching signature for function "
"%s", name->value());
continue;
ir_function_signature *sig =
- f->matching_signature(NULL, actual_parameters);
+ f->matching_signature(NULL, actual_parameters, use_builtin);
if ((sig == NULL) ||
(!sig->is_defined && !sig->is_intrinsic))
* We don't have to check for multiple definitions of main (in multiple
* shaders) because that would have already been caught above.
*/
- ir_function_signature *sig = f->matching_signature(NULL, &void_parameters);
+ ir_function_signature *sig =
+ f->matching_signature(NULL, &void_parameters, false);
if ((sig != NULL) && sig->is_defined) {
return sig;
}
ir_function *main_func = shader->symbols->get_function("main");
exec_list void_parameters;
ir_function_signature *main_func_sig
- = main_func->matching_signature(NULL, &void_parameters);
+ = main_func->matching_signature(NULL, &void_parameters, false);
exec_list new_instructions;
lower_packed_varyings_visitor visitor(mem_ctx, locations_used, mode,
gs_input_vertices, &new_instructions);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(NULL, &empty);
+ sig = ir->matching_signature(NULL, &empty, false);
assert(sig);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(NULL, &empty);
+ sig = ir->matching_signature(NULL, &empty, false);
assert(sig);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(NULL, &empty);
+ sig = ir->matching_signature(NULL, &empty, false);
assert(sig);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(NULL, &empty);
+ sig = ir->matching_signature(NULL, &empty, false);
assert(sig);