ioquake/ioq3 — pull request #37 by inolen (2014-02-01 20:04:28+00:00)
Title: don't regenerate GLSL shaders unless required

To preface this, I realize this change may be completely undesired, but I thought I'd at least present it.

On my Macbook Pro currently shader generation takes ~1.1 seconds on renderer2, and the renderer restarts 3 times when launching directly into a map. So, about ~2.2 seconds of time is wasted generating shaders.

In my actual use case (compiling ioq3 to run on the web), shader generation is even more expensive (~2.5 seconds). So, 5+ seconds of loading a map is wasted generating shaders.

With this change, I've added a a trStatic_t structure that holds onto data unrelated to the hunk, and is only reset when the context is destroyed (perhaps this makes sense to merge this and glState_t, they have the same lifecycle I believe).

I've then moved the shaderProgram_t structures into this new structure, and we early out and avoid rebuilding shaders unless cvars that control the shader generation have changed.

Aside from that, there was a global find and replace to change references from `tr.[shader]` to `trs.[shader]`.