Sort uniforms in ShaderBlocks;

This commit is contained in:
bjorn 2018-12-14 15:48:09 -08:00
parent 6dae6ecd07
commit 28a53e8df5
1 changed files with 7 additions and 1 deletions

View File

@ -1740,7 +1740,13 @@ static void lovrShaderSetupUniforms(Shader* shader) {
} else {
uniform.size = 4 * (uniform.components == 3 ? 4 : uniform.components);
}
vec_push(&block->uniforms, uniform);
// Uniforms in the block need to be in order of their offset, so find the right index for it
int index = 0;
while (index < block->uniforms.length && block->uniforms.data[index].offset < uniform.offset) {
index++;
}
vec_insert(&block->uniforms, index, uniform);
continue;
} else if (uniform.location == -1) {
continue;