diff options
author | Timothy Arceri <[email protected]> | 2017-08-09 13:34:02 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-08-11 10:43:12 +1000 |
commit | e2e2c5abd279df1b3aa99c52b81c9cb48fea35fb (patch) | |
tree | 814dcc8cf5c292ebaead53f75580c93b7f95f1ce /src/mesa | |
parent | 5563872dbfbf733ed56e1b367bc8944ca59b1c3e (diff) |
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 <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ac12b59d075..db7f11c6bf2 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1004,7 +1004,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) return; } - for (operand = 0; operand < ir->get_num_operands(); operand++) { + for (operand = 0; operand < ir->num_operands; operand++) { this->result.file = PROGRAM_UNDEFINED; ir->operands[operand]->accept(this); if (this->result.file == PROGRAM_UNDEFINED) { @@ -1736,7 +1736,7 @@ ir_to_mesa_visitor::process_move_condition(ir_rvalue *ir) bool switch_order = false; ir_expression *const expr = ir->as_expression(); - if ((expr != NULL) && (expr->get_num_operands() == 2)) { + if ((expr != NULL) && (expr->num_operands == 2)) { bool zero_on_left = false; if (expr->operands[0]->is_zero()) { diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9bc745c7916..aaa5cddcf3e 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1575,7 +1575,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) if (ir->operation == ir_quadop_vector) assert(!"ir_quadop_vector should have been lowered"); - for (unsigned int operand = 0; operand < ir->get_num_operands(); operand++) { + for (unsigned int operand = 0; operand < ir->num_operands; operand++) { this->result.file = PROGRAM_UNDEFINED; ir->operands[operand]->accept(this); if (this->result.file == PROGRAM_UNDEFINED) { @@ -2990,7 +2990,7 @@ glsl_to_tgsi_visitor::process_move_condition(ir_rvalue *ir) ir_expression *const expr = ir->as_expression(); if (native_integers) { - if ((expr != NULL) && (expr->get_num_operands() == 2)) { + if ((expr != NULL) && (expr->num_operands == 2)) { enum glsl_base_type type = expr->operands[0]->type->base_type; if (type == GLSL_TYPE_INT || type == GLSL_TYPE_UINT || type == GLSL_TYPE_BOOL) { @@ -3019,7 +3019,7 @@ glsl_to_tgsi_visitor::process_move_condition(ir_rvalue *ir) return switch_order; } - if ((expr != NULL) && (expr->get_num_operands() == 2)) { + if ((expr != NULL) && (expr->num_operands == 2)) { bool zero_on_left = false; if (expr->operands[0]->is_zero()) { |