glsl: fix crashes on out of bound matrix access using constant index