Skip to content

Commit 741c5b0

Browse files
committed
Rebind GL uniforms only when the shader binding or uniforms change.
1 parent 3e133b9 commit 741c5b0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cocos2d/CCNoARC.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,15 @@ -(void)transitionRenderer:(CCRenderer *)renderer FromState:(CCRenderState *)prev
200200
}
201201

202202
// Bind the shader.
203-
if(previous == nil || _shader != previous->_shader){
203+
BOOL bindShader = (previous == nil || _shader != previous->_shader);
204+
if(bindShader){
204205
CCGL_DEBUG_INSERT_EVENT_MARKER("Shader");
205206

206207
glUseProgram(_shader->_program);
207208
}
208209

209210
// Set the shader's uniform state.
210-
if(previous == nil || _shaderUniforms != previous->_shaderUniforms){
211+
if(bindShader || _shaderUniforms != previous->_shaderUniforms){
211212
CCGL_DEBUG_INSERT_EVENT_MARKER("Uniforms");
212213

213214
NSDictionary *globalShaderUniforms = renderer->_globalShaderUniforms;

0 commit comments

Comments
 (0)