Fixing small textures. This was painful.

Fixes #173.
This commit is contained in:
Ben Vanik
2015-03-05 22:22:34 -08:00
parent 4b5f77bde4
commit b19c98fd9a
5 changed files with 168 additions and 79 deletions

View File

@@ -145,6 +145,15 @@ inline bool bit_scan_forward(int64_t v, uint32_t* out_first_set_index) {
return bit_scan_forward(static_cast<uint64_t>(v), out_first_set_index);
}
template <typename T>
inline T log2_floor(T v) {
return sizeof(T) * 8 - 1 - lzcnt(v);
}
template <typename T>
inline T log2_ceil(T v) {
return sizeof(T) * 8 - lzcnt(v - 1);
}
template <typename T>
inline T rotate_left(T v, uint8_t sh) {
return (T(v) << sh) | (T(v) >> ((sizeof(T) * 8) - sh));