Scalar Operations#
It is easy to accidentally vectorise a calculation. Be wary of vectorising scalar operations where the vectorised form costs more cycles for the same output. For example:
highp vec4 v1, v2;
highp float x, y;
// Bad
v2 = (v1 * x) * y; // vector * scalar followed by vector * scalar totals eight scalar muladds
// Good
v2 = v1 * (x * y); // scalar * scalar followed by vector * scalar totals five scalar muladds