+ * Binds (and creates) VAO
+ *
+ * VAO is fixed per program so it has to be created only once assuming
+ * that VertexInputState has been set correctly for the pipeline.
+ *
+ */
+ void BindProgramVAO(GLES::ProgramImpl* program, const VertexInputState& vertexInputState)
+ {
+ auto& gl = *mController.GetGL();
+ auto iter = mProgramVAOMap.find(program);
+ if(iter != mProgramVAOMap.end())
+ {
+ if(mProgramVAOCurrentState != iter->second)
+ {
+ mProgramVAOCurrentState = iter->second;
+ gl.BindVertexArray(iter->second);
+ }
+ return;
+ }
+
+ uint32_t vao;
+ gl.GenVertexArrays(1, &vao);
+ gl.BindVertexArray(vao);
+ mProgramVAOMap[program] = vao;
+ for(const auto& attr : vertexInputState.attributes)
+ {
+ gl.EnableVertexAttribArray(attr.location);
+ }
+
+ mProgramVAOCurrentState = vao;
+ }
+
+ /**