diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-07 18:14:11 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 18:52:48 +0300 |
commit | cca941f614a4d7f8b7e0055606f82a95d6f81f66 (patch) | |
tree | 0e1ec61c2f0d0f1edd95244bd16a526c478ce370 /source | |
parent | e053f6b1d8169d54bc3cae058a3caaf72e479d63 (diff) |
Cleanup: GPUShader: Use switch instead of ifs
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 3d5b0dda5e4..4b130cdbb3e 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -729,23 +729,28 @@ void GPU_shader_uniform_vector( return; } - if (length == 1) { - glUniform1fv(location, arraysize, value); - } - else if (length == 2) { - glUniform2fv(location, arraysize, value); - } - else if (length == 3) { - glUniform3fv(location, arraysize, value); - } - else if (length == 4) { - glUniform4fv(location, arraysize, value); - } - else if (length == 9) { - glUniformMatrix3fv(location, arraysize, 0, value); - } - else if (length == 16) { - glUniformMatrix4fv(location, arraysize, 0, value); + switch (length) { + case 1: + glUniform1fv(location, arraysize, value); + break; + case 2: + glUniform2fv(location, arraysize, value); + break; + case 3: + glUniform3fv(location, arraysize, value); + break; + case 4: + glUniform4fv(location, arraysize, value); + break; + case 9: + glUniformMatrix3fv(location, arraysize, 0, value); + break; + case 16: + glUniformMatrix4fv(location, arraysize, 0, value); + break; + default: + BLI_assert(0); + break; } } @@ -756,17 +761,22 @@ void GPU_shader_uniform_vector_int( return; } - if (length == 1) { - glUniform1iv(location, arraysize, value); - } - else if (length == 2) { - glUniform2iv(location, arraysize, value); - } - else if (length == 3) { - glUniform3iv(location, arraysize, value); - } - else if (length == 4) { - glUniform4iv(location, arraysize, value); + switch (length) { + case 1: + glUniform1iv(location, arraysize, value); + break; + case 2: + glUniform2iv(location, arraysize, value); + break; + case 3: + glUniform3iv(location, arraysize, value); + break; + case 4: + glUniform4iv(location, arraysize, value); + break; + default: + BLI_assert(0); + break; } } |