Re: [Mesa-dev] [PATCH 4/4] glsl: Delete linker stuff relating to built-in functions.
On 09/21/2016 10:20 PM, Kenneth Graunke wrote: > Now that we generate built-in functions inline, there's no need to link > against the built-in shader, and no built-in prototypes to consider. > > This lets us delete a bunch of code. Boy howdy. This simplifies things quite a bit. Pending patch 2, this patch is Reviewed-by: Ian Romanick> Signed-off-by: Kenneth Graunke > --- > src/compiler/glsl/link_functions.cpp | 32 +++ > src/compiler/glsl/linker.cpp | 42 > +++- > 2 files changed, 16 insertions(+), 58 deletions(-) > > diff --git a/src/compiler/glsl/link_functions.cpp > b/src/compiler/glsl/link_functions.cpp > index b4aae5e..e4f77be 100644 > --- a/src/compiler/glsl/link_functions.cpp > +++ b/src/compiler/glsl/link_functions.cpp > @@ -32,7 +32,7 @@ > > static ir_function_signature * > find_matching_signature(const char *name, const exec_list *actual_parameters, > -glsl_symbol_table *symbols, bool use_builtin); > +glsl_symbol_table *symbols); > > namespace { > > @@ -74,12 +74,15 @@ public: >assert(callee != NULL); >const char *const name = callee->function_name(); > > + /* We don't actually need to find intrinsics; they're not real */ > + if (callee->is_intrinsic) > + return visit_continue; > + >/* Determine if the requested function signature already exists in the > * final linked shader. If it does, use it as the target of the call. > */ >ir_function_signature *sig = > - find_matching_signature(name, >parameters, linked->symbols, > - ir->use_builtin); > + find_matching_signature(name, >parameters, linked->symbols); >if (sig != NULL) { >ir->callee = sig; >return visit_continue; > @@ -90,8 +93,7 @@ public: > */ >for (unsigned i = 0; i < num_shaders; i++) { > sig = find_matching_signature(name, >actual_parameters, > - shader_list[i]->symbols, > - ir->use_builtin); > + shader_list[i]->symbols); > if (sig) > break; >} > @@ -122,9 +124,7 @@ public: > >ir_function_signature *linked_sig = >f->exact_matching_signature(NULL, >parameters); > - if ((linked_sig == NULL) > - || ((linked_sig != NULL) > - && (linked_sig->is_builtin() != ir->use_builtin))) { > + if (linked_sig == NULL) { >linked_sig = new(linked) ir_function_signature(callee->return_type); >f->add_signature(linked_sig); >} > @@ -314,22 +314,16 @@ private: > */ > ir_function_signature * > find_matching_signature(const char *name, const exec_list *actual_parameters, > -glsl_symbol_table *symbols, bool use_builtin) > +glsl_symbol_table *symbols) > { > ir_function *const f = symbols->get_function(name); > > if (f) { >ir_function_signature *sig = > - f->matching_signature(NULL, actual_parameters, use_builtin); > - > - if (sig && (sig->is_defined || sig->is_intrinsic)) { > - /* If this function expects to bind to a built-in function and the > - * signature that we found isn't a built-in, keep looking. Also > keep > - * looking if we expect a non-built-in but found a built-in. > - */ > - if (use_builtin == sig->is_builtin()) > -return sig; > - } > + f->matching_signature(NULL, actual_parameters, false); > + > + if (sig && (sig->is_defined || sig->is_intrinsic)) > + return sig; > } > > return NULL; > diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp > index 606d006..929a653 100644 > --- a/src/compiler/glsl/linker.cpp > +++ b/src/compiler/glsl/linker.cpp > @@ -2098,14 +2098,13 @@ link_intrastage_shaders(void *mem_ctx, > continue; > > foreach_in_list(ir_function_signature, sig, >signatures) { > -if (!sig->is_defined || sig->is_builtin()) > +if (!sig->is_defined) > continue; > > ir_function_signature *other_sig = > other->exact_matching_signature(NULL, >parameters); > > -if ((other_sig != NULL) && other_sig->is_defined > -&& !other_sig->is_builtin()) { > +if (other_sig != NULL && other_sig->is_defined) { > linker_error(prog, "function `%s' is multiply defined\n", > f->name); > return NULL; > @@ -2171,42 +2170,7 @@ link_intrastage_shaders(void *mem_ctx, > insertion_point, true, linked); > } > > - /* Check if any shader needs built-in functions. */ > - bool need_builtins
[Mesa-dev] [PATCH 4/4] glsl: Delete linker stuff relating to built-in functions.
Now that we generate built-in functions inline, there's no need to link against the built-in shader, and no built-in prototypes to consider. This lets us delete a bunch of code. Signed-off-by: Kenneth Graunke--- src/compiler/glsl/link_functions.cpp | 32 +++ src/compiler/glsl/linker.cpp | 42 +++- 2 files changed, 16 insertions(+), 58 deletions(-) diff --git a/src/compiler/glsl/link_functions.cpp b/src/compiler/glsl/link_functions.cpp index b4aae5e..e4f77be 100644 --- a/src/compiler/glsl/link_functions.cpp +++ b/src/compiler/glsl/link_functions.cpp @@ -32,7 +32,7 @@ static ir_function_signature * find_matching_signature(const char *name, const exec_list *actual_parameters, -glsl_symbol_table *symbols, bool use_builtin); +glsl_symbol_table *symbols); namespace { @@ -74,12 +74,15 @@ public: assert(callee != NULL); const char *const name = callee->function_name(); + /* We don't actually need to find intrinsics; they're not real */ + if (callee->is_intrinsic) + return visit_continue; + /* Determine if the requested function signature already exists in the * final linked shader. If it does, use it as the target of the call. */ ir_function_signature *sig = - find_matching_signature(name, >parameters, linked->symbols, - ir->use_builtin); + find_matching_signature(name, >parameters, linked->symbols); if (sig != NULL) { ir->callee = sig; return visit_continue; @@ -90,8 +93,7 @@ public: */ for (unsigned i = 0; i < num_shaders; i++) { sig = find_matching_signature(name, >actual_parameters, - shader_list[i]->symbols, - ir->use_builtin); + shader_list[i]->symbols); if (sig) break; } @@ -122,9 +124,7 @@ public: ir_function_signature *linked_sig = f->exact_matching_signature(NULL, >parameters); - if ((linked_sig == NULL) - || ((linked_sig != NULL) - && (linked_sig->is_builtin() != ir->use_builtin))) { + if (linked_sig == NULL) { linked_sig = new(linked) ir_function_signature(callee->return_type); f->add_signature(linked_sig); } @@ -314,22 +314,16 @@ private: */ ir_function_signature * find_matching_signature(const char *name, const exec_list *actual_parameters, -glsl_symbol_table *symbols, bool use_builtin) +glsl_symbol_table *symbols) { ir_function *const f = symbols->get_function(name); if (f) { ir_function_signature *sig = - f->matching_signature(NULL, actual_parameters, use_builtin); - - if (sig && (sig->is_defined || sig->is_intrinsic)) { - /* If this function expects to bind to a built-in function and the - * signature that we found isn't a built-in, keep looking. Also keep - * looking if we expect a non-built-in but found a built-in. - */ - if (use_builtin == sig->is_builtin()) -return sig; - } + f->matching_signature(NULL, actual_parameters, false); + + if (sig && (sig->is_defined || sig->is_intrinsic)) + return sig; } return NULL; diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 606d006..929a653 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2098,14 +2098,13 @@ link_intrastage_shaders(void *mem_ctx, continue; foreach_in_list(ir_function_signature, sig, >signatures) { - if (!sig->is_defined || sig->is_builtin()) + if (!sig->is_defined) continue; ir_function_signature *other_sig = other->exact_matching_signature(NULL, >parameters); - if ((other_sig != NULL) && other_sig->is_defined - && !other_sig->is_builtin()) { + if (other_sig != NULL && other_sig->is_defined) { linker_error(prog, "function `%s' is multiply defined\n", f->name); return NULL; @@ -2171,42 +2170,7 @@ link_intrastage_shaders(void *mem_ctx, insertion_point, true, linked); } - /* Check if any shader needs built-in functions. */ - bool need_builtins = false; - for (unsigned i = 0; i < num_shaders; i++) { - if (shader_list[i]->info.uses_builtin_functions) { - need_builtins = true; - break; - } - } - - bool ok; - if (need_builtins) { - /* Make a temporary array one larger than shader_list, which will hold - * the built-in function shader as well. - */ - gl_shader