我正在为Android构建一个游戏,在尝试优化我打开gl的调用后,我在跟踪器上发现了一个奇怪的问题。 游戏运行完美,大部分时间都低于16 fps,但在某些帧中每帧超过20 21毫秒,所以我注意到这几乎每个glUniform1f,glUniform3fv,glUniform1i调用:
java.lang.RuntimeException: No such property: PROGRAM_STATE/PROGRAMS/${program}/ACTIVE_UNIFORMS/14/UNIFORM_VALUE
Error applying transformations for glUniform3fv(location = 3, count = 1, v = [0.0, 100.0, 0.0])
on frames> 16毫秒此调用需要更多时间来执行。
以下是绘制调用的示例:
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, this.MyGLTexture);
GLES20.glUseProgram(this.Params.Programm);
GLES20.glUniform1i(this.Params.uTextureLoc, 0);
GLES20.glUniformMatrix4fv(this.Params.uMMatrixHandle, 1, false,this.MMatrixClip, 0);
Matrix.multiplyMM(this.MMatrix, 0, GamePlayRenderer.MVPMatrix, 0,this.MMatrix, 0);
GLES20.glUniformMatrix4fv(this.Params.uMVPMatrixHandle, 1, false,this.MMatrix, 0);
GLES20.glUniform1f(this.Params.uAlphaFactor,this.alphaFactor);
GLES20.glUniform1f(this.Params.Fader,fader);
GLES20.glUniform3fv(this.Params.uEyePos,1,cameraPos,0);
GLES20.glUniform3fv(this.Params.uLightPos,1,lightPos,0);
GLES20.glUniform3fv(this.Params.uMatAmbient,this.MatAmbient.length/3,this.MatAmbient,0);
GLES20.glUniform3fv(this.Params.uMatDifusse,this.MatDifusse.length/3,this.MatDifusse,0);
GLES20.glUniform3fv(this.Params.uMatSpecular,this.MatSpecular.length/3,this.MatSpecular,0);
GLES20.glUniform3fv(this.Params.uMatAlpha,this.MatAlpha.length/3,this.MatAlpha,0);
GLES20.glEnableVertexAttribArray(this.Params.aPosHandle);
GLES20.glEnableVertexAttribArray(this.Params.aTextHandle);
GLES20.glEnableVertexAttribArray(this.Params.aNorHandle);
GLES20.glEnableVertexAttribArray(this.Params.aMatIdHandle);
GLES20.glVertexAttribPointer(this.Params.aPosHandle, 3, GLES20.GL_FLOAT, false, 40, 0);
GLES20.glVertexAttribPointer(this.Params.aTextHandle, 2, GLES20.GL_FLOAT, false, 40, 12);
GLES20.glVertexAttribPointer(this.Params.aNorHandle, 3, GLES20.GL_FLOAT, false, 40, 20);
GLES20.glVertexAttribPointer(this.Params.aMatIdHandle, 2, GLES20.GL_FLOAT, false, 40, 32);
GLES20.glDrawArrays(GLES20.GL_TRIANGLES,this.ObjectStart,this.ObjectCount);