ac/nir: call glsl_get_sampler_dim() only once where possible