mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-26 15:30:40 +02:00
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 <kenneth@whitecape.org>
Signed-off-by: Eduardo Lima Mitev <elima@igalia.com>
Signed-off-by: Neil Roberts <nroberts@igalia.com>
(cherry picked from commit f5fe99ac85)
This commit is contained in:
parent
ebb7ccb306
commit
f34c7ba4e1
2 changed files with 10 additions and 31 deletions
|
|
@ -1979,6 +1979,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 &&
|
||||
|
|
@ -2036,22 +2037,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
|
||||
|
|
@ -2088,7 +2075,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;
|
||||
}
|
||||
|
|
@ -2149,7 +2138,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;
|
||||
|
|
|
|||
|
|
@ -1261,21 +1261,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);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2293,7 +2283,7 @@ link_intrastage_shaders(void *mem_ctx,
|
|||
|
||||
link_bindless_layout_qualifiers(prog, 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).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue