Turn off the use of uniform arrays in shaders as some devices don't like them, and the speedup seems to be very small if any.

This commit is contained in:
Henrik Rydgard committed 2013-05-26 14:03:02 +02:00
1 parent 138c3fb835
commit cdef31f9fc
6 files changed
+53 -4

No files matched your search

+19 -1
View File
@@ -105,8 +105,16 @@ LinkedShader::LinkedShader(Shader *vs, Shader *fs)
u_view = glGetUniformLocation(program, "u_view");
u_world = glGetUniformLocation(program, "u_world");
u_texmtx = glGetUniformLocation(program, "u_texmtx");
u_bone = glGetUniformLocation(program, "u_bone");
numBones = gstate.getNumBoneWeights();
#ifdef USE_BONE_ARRAY
u_bone = glGetUniformLocation(program, "u_bone");
#else
for (int i = 0; i < numBones; i++) {
char name[10];
sprintf(name, "u_bone%i", i);
u_bone[i] = glGetUniformLocation(program, name);
}
#endif
// Lighting, texturing
u_ambient = glGetUniformLocation(program, "u_ambient");
@@ -323,6 +331,7 @@ void LinkedShader::updateUniforms() {
}
// TODO: Could even set all bones in one go if they're all dirty.
#ifdef USE_BONE_ARRAY
if (u_bone != -1) {
float allBones[8 * 16];
@@ -346,6 +355,15 @@ void LinkedShader::updateUniforms() {
}
}
}
#else
float bonetemp[16];
for (int i = 0; i < numBones; i++) {
if (dirtyUniforms & (DIRTY_BONEMATRIX0 << i)) {
ConvertMatrix4x3To4x4(gstate.boneMatrix + 12 * i, bonetemp);
glUniformMatrix4fv(u_bone[i], 1, GL_FALSE, bonetemp);
}
}
#endif
// Lighting
if (u_ambient != -1 && (dirtyUniforms & DIRTY_AMBIENT)) {