This effectively factorizes a couple of similar routines. --- src/compiler/glsl/glsl_parser_extras.cpp | 18 ++---------------- src/compiler/glsl/linker.cpp | 16 +++------------- 2 files changed, 5 insertions(+), 29 deletions(-)
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index b11ea044c34..66212720af1 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -2087,22 +2087,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, * We don't have to worry about types or interface-types here because those * are fly-weights that are looked up by glsl_type. */ - foreach_in_list (ir_instruction, ir, shader->ir) { - switch (ir->ir_type) { - case ir_type_function: - shader->symbols->add_function((ir_function *) ir); - break; - case ir_type_variable: { - ir_variable *const var = (ir_variable *) ir; - - if (var->data.mode != ir_var_temporary) - shader->symbols->add_variable(var); - break; - } - default: - break; - } - } + _mesa_glsl_copy_symbols_from_table(shader->ir, state->symbols, + shader->symbols); _mesa_glsl_initialize_derived_variables(ctx, shader); diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 3eddbe24d09..b1212139c48 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1225,21 +1225,11 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog, * Populates a shaders symbol table with all global declarations */ static void -populate_symbol_table(gl_linked_shader *sh) +populate_symbol_table(gl_linked_shader *sh, glsl_symbol_table *symbols) { sh->symbols = new(sh) glsl_symbol_table; - foreach_in_list(ir_instruction, inst, sh->ir) { - ir_variable *var; - ir_function *func; - - if ((func = inst->as_function()) != NULL) { - sh->symbols->add_function(func); - } else if ((var = inst->as_variable()) != NULL) { - if (var->data.mode != ir_var_temporary) - sh->symbols->add_variable(var); - } - } + _mesa_glsl_copy_symbols_from_table(sh->ir, symbols, sh->symbols); } @@ -2214,7 +2204,7 @@ link_intrastage_shaders(void *mem_ctx, link_xfb_stride_layout_qualifiers(ctx, prog, linked, shader_list, num_shaders); - populate_symbol_table(linked); + populate_symbol_table(linked, shader_list[0]->symbols); /* The pointer to the main function in the final linked shader (i.e., the * copy of the original shader that contained the main function). -- 2.11.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev