xeolabs/scenejs — Issue #139: Configurable state sort order for draw list
Author: xeolabs
Created: 2011-10-21 01:40:42+00:00
State: open

Rendering the draw list involves traversing it while issuing calls on WebGL to bind the nodes' programs and load its states (VBOs, textures, matrices and uniforms etc).

To minimise rebindings during each iteration, the draw list is sorted prior to rendering, ordering first on program, then on texture, followed by VBO.

Program is the major sort order because rebinding of those neccessitates rebind or reload of all other resource types. Texture was made the the next sort order because it was found to be more expensive then VBO binding.

Sorting on (program, texture, VBO) is great when using texture atlases, however when using lots of VBO sharing it makes sense to sort on (program, VBO, texture).

Solution may be to configure this on SceneJS, ie

````
SceneJS.setConfigs({
stateSort: ["program", "vbo", "texture"]
});
````