X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.cpp;h=310e7be7f6627bf58fc5f5556712eafab4a3fa3f;hp=b86e3f77c9d4842fdea43cfbfe025bc786a2fa1c;hb=3ccf5fb197c9a72545affc0b7286349d5603b72e;hpb=d398770154ecc4bc95282dc45656789dd5686309 diff --git a/util.cpp b/util.cpp index b86e3f7..310e7be 100644 --- 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