glsl: calculate number of operands in an expression once

Extra validation is added to ir_validate to make sure this is
always updated to the correct numer of operands, as passes like
lower_instructions modify the instructions directly rather then
generating a new one.

The reduction in time is so small that it is not really
measurable. However callgrind was reporting this function as
being called just under 34 million times while compiling the
Deus Ex shaders (just pre-linking was profiled) with 0.20%
spent in this function.

v2:
 - make num_operands a unit8_t
 - fix unsigned/signed mismatches

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
This commit is contained in:
Timothy Arceri
2017-08-09 13:34:02 +10:00
parent 5563872dbf
commit e2e2c5abd2
22 changed files with 103 additions and 32 deletions

View File

@@ -291,7 +291,7 @@ void ir_print_visitor::visit(ir_expression *ir)
fprintf(f, " %s ", ir_expression_operation_strings[ir->operation]);
for (unsigned i = 0; i < ir->get_num_operands(); i++) {
for (unsigned i = 0; i < ir->num_operands; i++) {
ir->operands[i]->accept(this);
}