glsl: calculate number of operands in an expression once

Graphics / Mesa 3D Graphics Library / Mesa - Timothy Arceri [itsqueeze.com] - 10 August 2017 20:43 EDT

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

e2e2c5a glsl: calculate number of operands in an expression once
src/compiler/glsl/glsl_to_nir.cpp | 4 +--
src/compiler/glsl/ir.cpp | 22 +++++++++++++--
src/compiler/glsl/ir.h | 13 +++++++++
src/compiler/glsl/ir_builder_print_visitor.cpp | 8 +++---
src/compiler/glsl/ir_clone.cpp | 2 +-
src/compiler/glsl/ir_constant_expression.cpp | 2 +-
src/compiler/glsl/ir_equals.cpp | 2 +-
src/compiler/glsl/ir_hv_accept.cpp | 2 +-
src/compiler/glsl/ir_print_visitor.cpp | 2 +-
src/compiler/glsl/ir_rvalue_visitor.cpp | 2 +-
src/compiler/glsl/ir_validate.cpp | 8 ++++++
src/compiler/glsl/lower_instructions.cpp | 32 ++++++++++++++++++++++
src/compiler/glsl/lower_int64.cpp | 4 +--
src/compiler/glsl/lower_mat_op_to_vec.cpp | 8 +++---
src/compiler/glsl/lower_ubo_reference.cpp | 2 +-
.../glsl/lower_vec_index_to_cond_assign.cpp | 2 +-
src/compiler/glsl/lower_vector.cpp | 2 +-
src/compiler/glsl/opt_algebraic.cpp | 4 +--
src/compiler/glsl/opt_constant_folding.cpp | 2 +-
src/compiler/glsl/opt_tree_grafting.cpp | 2 +-
src/mesa/program/ir_to_mesa.cpp | 4 +--
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 ++--
22 files changed, 103 insertions(+), 32 deletions(-)

Upstream: cgit.freedesktop.org


  • Share