Browse Source

Documented internal shader program state tracking.

pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
733e02b07b
  1. 20
      src/AbstractShaderProgram.h

20
src/AbstractShaderProgram.h

@ -200,6 +200,18 @@ specularTexture->bind(MyShader::SpecularTextureLayer);
mesh.draw(); mesh.draw();
@endcode @endcode
@section AbstractShaderProgram-performance-optimization Performance optimizations
The engine tracks currently used shader program to avoid unnecessary calls to
@fn_gl{UseProgram}.
If extension @extension{ARB,separate_shader_objects} or
@extension{EXT,direct_state_access} is available, uniform setting
functions use DSA functions to avoid unnecessary calls to @fn_gl{UseProgram}.
See setUniform(GLint, GLfloat) documentation for more information.
To achieve least state changes, set all uniforms in one run -- method chaining
comes in handy.
@todo Uniform arrays support @todo Uniform arrays support
*/ */
class MAGNUM_EXPORT AbstractShaderProgram { class MAGNUM_EXPORT AbstractShaderProgram {
@ -381,10 +393,10 @@ class MAGNUM_EXPORT AbstractShaderProgram {
* @param value Value * @param value Value
* *
* If neither @extension{ARB,separate_shader_objects} nor * If neither @extension{ARB,separate_shader_objects} nor
* @extension{EXT,direct_state_access} is available, use() is called * @extension{EXT,direct_state_access} is available, the shader is
* before the operation. * marked for use before the operation.
* @see use(), @fn_gl{Uniform} or `glProgramUniform()` from * @see @fn_gl{UseProgram}, @fn_gl{Uniform} or `glProgramUniform()`
* @extension{ARB,separate_shader_objects}/@extension{EXT,direct_state_access}. * from @extension{ARB,separate_shader_objects}/@extension{EXT,direct_state_access}.
*/ */
inline void setUniform(GLint location, GLfloat value) { inline void setUniform(GLint location, GLfloat value) {
(this->*uniform1fImplementation)(location, value); (this->*uniform1fImplementation)(location, value);

Loading…
Cancel
Save