glsl: convert reusable lower_precision util code into helper functions