summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_parser_extras.cpp
diff options
context:
space:
mode:
authorEduardo Lima Mitev <[email protected]>2017-03-05 20:28:42 +0100
committerNeil Roberts <[email protected]>2017-10-30 18:10:39 +0100
commitf5fe99ac85e15b705612bd9e7599cc974c2a121b (patch)
treeb139f026c3dbc034d1b7422b2cfc60f622238847 /src/compiler/glsl/glsl_parser_extras.cpp
parent4c62a270a99d443316e29020377465a90a6968c0 (diff)
glsl: Use the utility function to copy symbols between symbol tables
This effectively factorizes a couple of similar routines. v2 (Neil Roberts): Non-trivial rebase on master Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Eduardo Lima Mitev <[email protected]> Signed-off-by: Neil Roberts <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glsl_parser_extras.cpp')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 97c7b4d7820..822301a5842 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1968,6 +1968,7 @@ do_late_parsing_checks(struct _mesa_glsl_parse_state *state)
static void
opt_shader_and_create_symbol_table(struct gl_context *ctx,
+ struct glsl_symbol_table *source_symbols,
struct gl_shader *shader)
{
assert(shader->CompileStatus != compile_failure &&
@@ -2025,22 +2026,8 @@ opt_shader_and_create_symbol_table(struct gl_context *ctx,
* 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, source_symbols,
+ shader->symbols);
}
void
@@ -2077,7 +2064,9 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
return;
if (shader->CompileStatus == compiled_no_opts) {
- opt_shader_and_create_symbol_table(ctx, shader);
+ opt_shader_and_create_symbol_table(ctx,
+ NULL, /* source_symbols */
+ shader);
shader->CompileStatus = compile_success;
return;
}
@@ -2138,7 +2127,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
lower_subroutine(shader->ir, state);
if (!ctx->Cache || force_recompile)
- opt_shader_and_create_symbol_table(ctx, shader);
+ opt_shader_and_create_symbol_table(ctx, state->symbols, shader);
else {
reparent_ir(shader->ir, shader->ir);
shader->CompileStatus = compiled_no_opts;