stackgl/gl-shader-core — pull request #11 by mikolalysenko (2014-11-16 16:19:47+00:00)
Title: Cache shaders

This new version of gl-shader-core caches shaders and attribute locations making it faster to assign values to attributes.

It also fixes a bug which existed previously where the location of some attributes could get screwed up during rebinding.

Compatibility-wise, this would be a major version bump since the reference to the underlying shader and program objects are dropped.

Another major change is that dispose() no longer releases the shader. This is necessary in order for the caching to have some meaningful benefit. I think for shaders this is ultimately a worthwhile tradeoff as:

1. Applications tend to allocate a few shaders which persist through the lifetime of the whole app (so dispose is rarely ever called)
2. Shaders use an insignificant amount of memory on the GPU compared to textures or vertex buffers
3. Shader compilation/linking is expensive