glsl: add variable mode check to build_stageref