Fix potential critical section bug when reloading shaders.

Reference needs to be inside critical section, before doing the SetShader call.