#include "glsl_symbol_table.h"
#include "ir.h"
#include "program.h"
-#include "hash_table.h"
+#include "program/hash_table.h"
#include "linker.h"
#include "ir_optimization.h"
* FINISHME: modify the shader, and linking with the second
* FINISHME: will fail.
*/
- existing->constant_value = var->constant_value->clone(NULL);
+ existing->constant_value =
+ var->constant_value->clone(talloc_parent(existing), NULL);
}
} else
variables.add_variable(var->name, var);
* should be added.
*/
void
-remap_variables(ir_instruction *inst, glsl_symbol_table *symbols,
- exec_list *instructions, hash_table *temps)
+remap_variables(ir_instruction *inst, struct gl_shader *target,
+ hash_table *temps)
{
class remap_visitor : public ir_hierarchical_visitor {
public:
- remap_visitor(glsl_symbol_table *symbols, exec_list *instructions,
+ remap_visitor(struct gl_shader *target,
hash_table *temps)
{
- this->symbols = symbols;
- this->instructions = instructions;
+ this->target = target;
+ this->symbols = target->symbols;
+ this->instructions = target->ir;
this->temps = temps;
}
if (existing != NULL)
ir->var = existing;
else {
- ir_variable *copy = ir->var->clone(NULL);
+ ir_variable *copy = ir->var->clone(this->target, NULL);
this->symbols->add_variable(copy->name, copy);
this->instructions->push_head(copy);
}
private:
+ struct gl_shader *target;
glsl_symbol_table *symbols;
exec_list *instructions;
hash_table *temps;
};
- remap_visitor v(symbols, instructions, temps);
+ remap_visitor v(target, temps);
inst->accept(&v);
}
|| ((var != NULL) && (var->mode == ir_var_temporary)));
if (make_copies) {
- inst = inst->clone(NULL);
+ inst = inst->clone(target, NULL);
if (var != NULL)
hash_table_insert(temps, inst, var);
else
- remap_variables(inst, target->symbols, target->ir, temps);
+ remap_variables(inst, target, temps);
} else {
inst->remove();
}
gl_shader *const linked = _mesa_new_shader(NULL, 0, main->Type);
linked->ir = new(linked) exec_list;
- clone_ir_list(linked->ir, main->ir);
+ clone_ir_list(linked, linked->ir, main->ir);
populate_symbol_table(linked);
continue;
const unsigned vec4_slots = (var->component_slots() + 3) / 4;
- assert(vec4_slots != 0);
+ if (vec4_slots == 0) {
+ /* If we've got a sampler or an aggregate of them, the size can
+ * end up zero. Don't allocate any space.
+ */
+ continue;
+ }
uniform_node *n = (uniform_node *) hash_table_find(ht, var->name);
if (n == NULL) {
* by the following stage.
*/
if (var->location == -1) {
- var->shader_out = false;
var->mode = ir_var_auto;
}
}
/* An 'in' variable is only really a shader input if its
* value is written by the previous stage.
*/
- var->shader_in = false;
var->mode = ir_var_auto;
}
}
do_mat_op_to_vec(ir);
do_mod_to_fract(ir);
do_div_to_mul_rcp(ir);
+ do_explog_to_explog2(ir);
do {
progress = false;
progress = do_function_inlining(ir) || progress;
+ progress = do_dead_functions(ir) || progress;
+ progress = do_structure_splitting(ir) || progress;
progress = do_if_simplification(ir) || progress;
progress = do_copy_propagation(ir) || progress;
progress = do_dead_code_local(ir) || progress;
progress = do_dead_code(ir) || progress;
progress = do_tree_grafting(ir) || progress;
- progress = do_constant_variable_unlinked(ir) || progress;
+ progress = do_constant_propagation(ir) || progress;
+ progress = do_constant_variable(ir) || progress;
progress = do_constant_folding(ir) || progress;
+ progress = do_algebraic(ir) || progress;
progress = do_if_return(ir) || progress;
#if 0
if (ctx->Shader.EmitNoIfs)