diff options
author | Kenneth Graunke <[email protected]> | 2014-07-24 14:05:40 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-08-04 15:47:06 -0700 |
commit | 21129d4de300f1a934d02e30347c465520afef9e (patch) | |
tree | 499101703099b43852ce4119507131f9fd95550b /src | |
parent | f82f2fb3dc770902f1657ab1c22e6004faa3afab (diff) |
glsl: Make it possible to ignore built-ins when matching signatures.
Historically, we've implemented the rules for overriding built-in
functions by creating multiple ir_functions and relying on the symbol
table to hide the one containing built-in functions. That works, but
has a few drawbacks, so the next patch will change it.
Instead, we'll have a single ir_function for a particular name, which
will contain both built-in and user-defined signatures. Passing an
extra parameter to matching_signature makes it easy to ignore built-ins
when they're supposed to be hidden.
I didn't add the parameter to exact_matching_signature since it wasn't
necessary.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ast_function.cpp | 15 | ||||
-rw-r--r-- | src/glsl/builtin_functions.cpp | 3 | ||||
-rw-r--r-- | src/glsl/ir.h | 4 | ||||
-rw-r--r-- | src/glsl/ir_function.cpp | 10 | ||||
-rw-r--r-- | src/glsl/ir_reader.cpp | 3 | ||||
-rw-r--r-- | src/glsl/link_functions.cpp | 2 | ||||
-rw-r--r-- | src/glsl/linker.cpp | 3 | ||||
-rw-r--r-- | src/glsl/lower_packed_varyings.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 |
12 files changed, 30 insertions, 20 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 4981fe17458..39c7beeb22a 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -450,20 +450,21 @@ match_function_by_name(const char *name, 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. */ diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index e01742c4d05..185fe98b33d 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -706,7 +706,8 @@ builtin_builder::find(_mesa_glsl_parse_state *state, 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; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 49f74face65..31c354556e4 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -979,6 +979,7 @@ public: */ ir_function_signature *matching_signature(_mesa_glsl_parse_state *state, const exec_list *actual_param, + bool allow_builtins, bool *match_is_exact); /** @@ -986,7 +987,8 @@ public: * 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 diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index 7d6c2f45133..98bec45ceec 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -281,15 +281,18 @@ choose_best_inexact_overload(_mesa_glsl_parse_state *state, 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; @@ -308,7 +311,8 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state, */ 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)) { diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index e3566e1d696..ae00e793496 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -677,7 +677,8 @@ ir_reader::read_call(s_expression *expr) 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()); diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 2ce9609b55d..f86aec689b1 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -307,7 +307,7 @@ find_matching_signature(const char *name, const exec_list *actual_parameters, 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)) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index d588bc63ec4..0096fb023dc 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1129,7 +1129,8 @@ get_main_function_signature(gl_shader *sh) * 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; } diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp index c72b80a32fd..78014831566 100644 --- a/src/glsl/lower_packed_varyings.cpp +++ b/src/glsl/lower_packed_varyings.cpp @@ -655,7 +655,7 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used, 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); diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 3b03eef77cd..752e5a413ec 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2511,7 +2511,7 @@ fs_visitor::visit(ir_function *ir) const ir_function_signature *sig; exec_list empty; - sig = ir->matching_signature(NULL, &empty); + sig = ir->matching_signature(NULL, &empty, false); assert(sig); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index e16e93cc27a..23d1daec315 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1068,7 +1068,7 @@ vec4_visitor::visit(ir_function *ir) const ir_function_signature *sig; exec_list empty; - sig = ir->matching_signature(NULL, &empty); + sig = ir->matching_signature(NULL, &empty, false); assert(sig); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 2a82e9d9ddc..b088160d3c3 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -793,7 +793,7 @@ ir_to_mesa_visitor::visit(ir_function *ir) const ir_function_signature *sig; exec_list empty; - sig = ir->matching_signature(NULL, &empty); + sig = ir->matching_signature(NULL, &empty, false); assert(sig); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 293bc5c1b7d..a165d6a5c1f 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1192,7 +1192,7 @@ glsl_to_tgsi_visitor::visit(ir_function *ir) const ir_function_signature *sig; exec_list empty; - sig = ir->matching_signature(NULL, &empty); + sig = ir->matching_signature(NULL, &empty, false); assert(sig); |