During compilation, we'll use this to determine built-in availability.
The plan is to have a single shader containing every built-in in every
version of the language, but filter out the ones that aren't actually
available to the shader being compiled.
At link time, we don't actually need this filtering capability: we've
already imported prototypes for every built-in that the shader actually
calls, and they're flagged as is_builtin(). The linker doesn't import
any additional prototypes, so it won't pull in any unavailable
built-ins. When resolving prototypes to function definitions, the
linker ensures the values of is_builtin() match, which means that a
shader can't trick the linker into importing the body of an unavailable
built-in by defining a suspiciously similar prototype.
In other words, during linking, we can just pass in NULL. It will work
out fine.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
if (f != NULL) {
/* Look for a match in the local shader. If exact, we're done. */
bool is_exact = false;
- sig = local_sig = f->matching_signature(actual_parameters, &is_exact);
+ sig = local_sig = f->matching_signature(state, actual_parameters,
+ &is_exact);
if (is_exact)
goto done;
bool is_exact = false;
ir_function_signature *builtin_sig =
- builtin->matching_signature(actual_parameters, &is_exact);
+ builtin->matching_signature(state, actual_parameters, &is_exact);
if (builtin_sig == NULL)
continue;
*/
f = state->symbols->get_function(name);
if (f != NULL && (state->es_shader || f->has_user_signature())) {
- sig = f->exact_matching_signature(&hir_parameters);
+ sig = f->exact_matching_signature(state, &hir_parameters);
if (sig != NULL) {
const char *badvar = sig->qualifiers_match(&hir_parameters);
if (badvar != NULL) {
* Find a signature that matches a set of actual parameters, taking implicit
* conversions into account. Also flags whether the match was exact.
*/
- ir_function_signature *matching_signature(const exec_list *actual_param,
+ ir_function_signature *matching_signature(_mesa_glsl_parse_state *state,
+ const exec_list *actual_param,
bool *match_is_exact);
/**
* Find a signature that matches a set of actual parameters, taking implicit
* conversions into account.
*/
- ir_function_signature *matching_signature(const exec_list *actual_param);
+ ir_function_signature *matching_signature(_mesa_glsl_parse_state *state,
+ const exec_list *actual_param);
/**
* Find a signature that exactly matches a set of actual parameters without
* any implicit type conversions.
*/
- ir_function_signature *exact_matching_signature(const exec_list *actual_ps);
+ ir_function_signature *exact_matching_signature(_mesa_glsl_parse_state *state,
+ const exec_list *actual_ps);
/**
* Name of the function.
ir_function_signature *
-ir_function::matching_signature(const exec_list *actual_parameters)
+ir_function::matching_signature(_mesa_glsl_parse_state *state,
+ const exec_list *actual_parameters)
{
bool is_exact;
- return matching_signature(actual_parameters, &is_exact);
+ return matching_signature(state, actual_parameters, &is_exact);
}
ir_function_signature *
-ir_function::matching_signature(const exec_list *actual_parameters,
+ir_function::matching_signature(_mesa_glsl_parse_state *state,
+ const exec_list *actual_parameters,
bool *is_exact)
{
ir_function_signature *match = NULL;
}
ir_function_signature *
-ir_function::exact_matching_signature(const exec_list *actual_parameters)
+ir_function::exact_matching_signature(_mesa_glsl_parse_state *state,
+ const exec_list *actual_parameters)
{
foreach_iter(exec_list_iterator, iter, signatures) {
ir_function_signature *const sig =
hir_parameters.push_tail(var);
}
- ir_function_signature *sig = f->exact_matching_signature(&hir_parameters);
+ ir_function_signature *sig =
+ f->exact_matching_signature(state, &hir_parameters);
if (sig == NULL && skip_body) {
/* If scanning for prototypes, generate a new signature. */
/* ir_reader doesn't know what languages support a given built-in, so
return NULL;
}
- ir_function_signature *callee = f->matching_signature(¶meters);
+ ir_function_signature *callee = f->matching_signature(state, ¶meters);
if (callee == NULL) {
ir_read_error(expr, "couldn't find matching signature for function "
"%s", name->value());
}
ir_function_signature *linked_sig =
- f->exact_matching_signature(&callee->parameters);
+ f->exact_matching_signature(NULL, &callee->parameters);
if ((linked_sig == NULL)
|| ((linked_sig != NULL)
&& (linked_sig->is_builtin() != ir->use_builtin))) {
if (f == NULL)
continue;
- ir_function_signature *sig = f->matching_signature(actual_parameters);
+ ir_function_signature *sig =
+ f->matching_signature(NULL, actual_parameters);
if ((sig == NULL) || !sig->is_defined)
continue;
* 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(&void_parameters);
+ ir_function_signature *sig = f->matching_signature(NULL, &void_parameters);
if ((sig != NULL) && sig->is_defined) {
return sig;
}
continue;
ir_function_signature *other_sig =
- other->exact_matching_signature(& sig->parameters);
+ other->exact_matching_signature(NULL, &sig->parameters);
if ((other_sig != NULL) && other_sig->is_defined
&& !other_sig->is_builtin()) {
ir_function *main_func = shader->symbols->get_function("main");
exec_list void_parameters;
ir_function_signature *main_func_sig
- = main_func->matching_signature(&void_parameters);
+ = main_func->matching_signature(NULL, &void_parameters);
exec_list new_instructions;
lower_packed_varyings_visitor visitor(mem_ctx, location_base,
locations_used, mode,
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(&empty);
+ sig = ir->matching_signature(NULL, &empty);
assert(sig);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(&empty);
+ sig = ir->matching_signature(NULL, &empty);
assert(sig);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(&empty);
+ sig = ir->matching_signature(NULL, &empty);
assert(sig);
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(&empty);
+ sig = ir->matching_signature(NULL, &empty);
assert(sig);