Cache shader program uniform state to avoid redundant uniform1i calls

uniform1i calls are one of the worst performance bottlenecks of the
engine when running on devices with a lower-powered CPU but a relatively
high-performance GPU. Don't set the uniforms redundantly to gain up to
10% extra performance.

The optimization is targeted especially for the usage pattern seen on for
example biodigitalhuman.com, where there can be lots of draw calls with
exactly the same parameters in succession.
Cache material uniform state to avoid redundant uniform* calls

Continuation of the previous patch to reduce CPU overhead from setting
uniforms further.
Merge pull request #304 from NVIDIA/uniform1i-optimization

Uniform1i optimization