]> git.sesse.net Git - movit/blobdiff - util.cpp
Merge branch 'master' into epoxy
[movit] / util.cpp
index cd820bc74afe3d7ee8314ee1d47da82bb33cf55a..ac6a218098873953d25036605d728ed98257ec70 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -215,4 +215,22 @@ void cleanup_vertex_attribute(GLuint glsl_program_num, const string &attribute_n
        check_error();
 }
 
+unsigned div_round_up(unsigned a, unsigned b)
+{
+       return (a + b - 1) / b;
+}
+
+// Algorithm from http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2.
+unsigned next_power_of_two(unsigned v)
+{
+       v--;
+       v |= v >> 1;
+       v |= v >> 2;
+       v |= v >> 4;
+       v |= v >> 8;
+       v |= v >> 16;
+       v++;
+       return v;
+}
+
 }  // namespace movit