Is it worth caching glsl uniform location in code?

后端 未结 1 1514
一整个雨季
一整个雨季 2021-01-18 01:58

I would like to have ability to set uniforms via their actual names in the shader

myProgram.uniform3fv(\"uniformVector\", 0.0f, 0.1f, 1.0f);
<
相关标签:
1条回答
  • 2021-01-18 02:47

    The OpenGL specification defines functionality, not performance. So there's no way to know how any particular OpenGL implementation will store the list of active uniforms or how fast glGetUniformLocation will be, relative to std::map performance.

    So really, it's up to you. If you want consistent, known performance, do it yourself. If you want to take a chance on the vagaries of the OpenGL implementation, then query it whenever you want. Personally, I'd say ditch names and go with locations. That way you get maximum performance.

    0 讨论(0)
提交回复
热议问题