From 96c324da088fcb31404c1c891fe66cc3d2c5bbc2 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 16 May 2014 18:11:47 +0200 Subject: [PATCH] Avoid needless branch. --- gfx/shader_glsl.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index d021e981f4..f498c73536 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -559,25 +559,22 @@ static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *un find_uniforms_frame(prog, &uni->orig, frame_base); } - if (pass) + for (i = 0; i + 1 < pass; i++) { - for (i = 0; i < pass - 1; i++) - { - snprintf(frame_base, sizeof(frame_base), "Pass%u", i + 1); - clear_uniforms_frame(&uni->pass[i]); - find_uniforms_frame(prog, &uni->pass[i], frame_base); - snprintf(frame_base, sizeof(frame_base), "PassPrev%u", pass - (i + 1)); - find_uniforms_frame(prog, &uni->pass[i], frame_base); - } + snprintf(frame_base, sizeof(frame_base), "Pass%u", i + 1); + clear_uniforms_frame(&uni->pass[i]); + find_uniforms_frame(prog, &uni->pass[i], frame_base); + snprintf(frame_base, sizeof(frame_base), "PassPrev%u", pass - (i + 1)); + find_uniforms_frame(prog, &uni->pass[i], frame_base); + } - clear_uniforms_frame(&uni->prev[0]); - find_uniforms_frame(prog, &uni->prev[0], "Prev"); - for (i = 1; i < PREV_TEXTURES; i++) - { - snprintf(frame_base, sizeof(frame_base), "Prev%u", i); - clear_uniforms_frame(&uni->prev[i]); - find_uniforms_frame(prog, &uni->prev[i], frame_base); - } + clear_uniforms_frame(&uni->prev[0]); + find_uniforms_frame(prog, &uni->prev[0], "Prev"); + for (i = 1; i < PREV_TEXTURES; i++) + { + snprintf(frame_base, sizeof(frame_base), "Prev%u", i); + clear_uniforms_frame(&uni->prev[i]); + find_uniforms_frame(prog, &uni->prev[i], frame_base); } glUseProgram(0);