glsl: add helper for counting varyings