glsl-optimizer
glsl-optimizer copied to clipboard
Do mat_op_to_vec optimizations
do_mat_op_to_vec could be called after constant folding. The kind of optimizations this does:
Original code: vec3 N = normalize((sys_WorldMatrix * vec4( vec3( 1.0, 0.0, 0.0 ), 0 )).xyz); Current: tmpvar_1 = normalize((sys_WorldMatrix * vec4(1.0, 0.0, 0.0, 0.0)).xyz); With mat_op_to_vec: tmpvar_1 = normalize(sys_WorldMatrix[0].xyz);
However just running that turns all matrix ops into vectors, which both looks long and (potentially?) has some downsides.
Find a way to only do the mat_op_to_vec when less than "all" results are used?