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:
@@ -1579,8 +1579,21 @@ public:
|
||||
|
||||
virtual ir_variable *variable_referenced() const;
|
||||
|
||||
/**
|
||||
* Determine the number of operands used by an expression
|
||||
*/
|
||||
void init_num_operands()
|
||||
{
|
||||
if (operation == ir_quadop_vector) {
|
||||
num_operands = this->type->vector_elements;
|
||||
} else {
|
||||
num_operands = get_num_operands(operation);
|
||||
}
|
||||
}
|
||||
|
||||
ir_expression_operation operation;
|
||||
ir_rvalue *operands[4];
|
||||
uint8_t num_operands;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user