On 08/23/2015 09:09 AM, Jordan Justen wrote: > Also rename to _mesa_get_main_function_signature. > > We will call it near the end of compilation to insert some code into > main for initializing some compute shader global variables. > > Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> > --- > src/glsl/builtin_functions.cpp | 28 ++++++++++++++++++++++++++++ > src/glsl/ir.h | 3 +++ > src/glsl/linker.cpp | 31 ++----------------------------- > src/glsl/linker.h | 3 --- > src/glsl/lower_vertex_id.cpp | 2 +- > 5 files changed, 34 insertions(+), 33 deletions(-) > > diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp > index 1bc3de4..bb8bc50 100644 > --- a/src/glsl/builtin_functions.cpp > +++ b/src/glsl/builtin_functions.cpp > @@ -5061,4 +5061,32 @@ _mesa_glsl_get_builtin_function_shader() > return builtins.shader; > } > > + > +/** > + * Get the function signature for main from a shader > + */ > +ir_function_signature * > +_mesa_get_main_function_signature(gl_shader *sh) > +{ > + ir_function *const f = sh->symbols->get_function("main"); > + if (f != NULL) { > + exec_list void_parameters; > + > + /* Look for the 'void main()' signature and ensure that it's defined. > + * This keeps the linker from accidentally pick a shader that just > + * contains a prototype for main. > + * > + * 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, false); > + if ((sig != NULL) && sig->is_defined) { > + return sig;
A tab slipped here, use spaces instead like rest of file. Other than that, patch looks good. Reviewed-by: Eduardo Lima Mitev <el...@igalia.com> > + } > + } > + > + return NULL; > +} > + > /** @} */ > diff --git a/src/glsl/ir.h b/src/glsl/ir.h > index ede8caa..750321e 100644 > --- a/src/glsl/ir.h > +++ b/src/glsl/ir.h > @@ -2529,6 +2529,9 @@ > _mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state, > extern gl_shader * > _mesa_glsl_get_builtin_function_shader(void); > > +extern ir_function_signature * > +_mesa_get_main_function_signature(gl_shader *sh); > + > extern void > _mesa_glsl_release_functions(void); > > diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp > index 47f7d25..cf0f646 100644 > --- a/src/glsl/linker.cpp > +++ b/src/glsl/linker.cpp > @@ -1341,33 +1341,6 @@ move_non_declarations(exec_list *instructions, > exec_node *last, > return last; > } > > -/** > - * Get the function signature for main from a shader > - */ > -ir_function_signature * > -link_get_main_function_signature(gl_shader *sh) > -{ > - ir_function *const f = sh->symbols->get_function("main"); > - if (f != NULL) { > - exec_list void_parameters; > - > - /* Look for the 'void main()' signature and ensure that it's defined. > - * This keeps the linker from accidentally pick a shader that just > - * contains a prototype for main. > - * > - * 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, false); > - if ((sig != NULL) && sig->is_defined) { > - return sig; > - } > - } > - > - return NULL; > -} > - > > /** > * This class is only used in link_intrastage_shaders() below but declaring > @@ -2040,7 +2013,7 @@ link_intrastage_shaders(void *mem_ctx, > */ > gl_shader *main = NULL; > for (unsigned i = 0; i < num_shaders; i++) { > - if (link_get_main_function_signature(shader_list[i]) != NULL) { > + if (_mesa_get_main_function_signature(shader_list[i]) != NULL) { > main = shader_list[i]; > break; > } > @@ -2072,7 +2045,7 @@ link_intrastage_shaders(void *mem_ctx, > * copy of the original shader that contained the main function). > */ > ir_function_signature *const main_sig = > - link_get_main_function_signature(linked); > + _mesa_get_main_function_signature(linked); > > /* Move any instructions other than variable declarations or function > * declarations into main. > diff --git a/src/glsl/linker.h b/src/glsl/linker.h > index ce3dc32..0999878 100644 > --- a/src/glsl/linker.h > +++ b/src/glsl/linker.h > @@ -26,9 +26,6 @@ > #ifndef GLSL_LINKER_H > #define GLSL_LINKER_H > > -ir_function_signature * > -link_get_main_function_signature(gl_shader *sh); > - > extern bool > link_function_calls(gl_shader_program *prog, gl_shader *main, > gl_shader **shader_list, unsigned num_shaders); > diff --git a/src/glsl/lower_vertex_id.cpp b/src/glsl/lower_vertex_id.cpp > index fc90bc8..3da7a2f 100644 > --- a/src/glsl/lower_vertex_id.cpp > +++ b/src/glsl/lower_vertex_id.cpp > @@ -130,7 +130,7 @@ lower_vertex_id(gl_shader *shader) > return false; > > ir_function_signature *const main_sig = > - link_get_main_function_signature(shader); > + _mesa_get_main_function_signature(shader); > if (main_sig == NULL) { > assert(main_sig != NULL); > return false; > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev