diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-11-20 14:46:19 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-11-20 14:46:19 +0100 |
commit | da2fe8190518d3266df7f4a48f9b651eaea84d4b (patch) | |
tree | d584caaa250a596a3cbd3cd9d7e3767c13f46663 /src/common/bit_util.h | |
parent | 4ca6e9a9e23b96d259cc1f1ba50b9464a8fa12e8 (diff) |
TextureCache: Refactor and fix linux compiling.
Diffstat (limited to 'src/common/bit_util.h')
-rw-r--r-- | src/common/bit_util.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h index 64520ca4e..eef8c1c5a 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -7,6 +7,7 @@ #include <bit> #include <climits> #include <cstddef> +#include <type_traits> #include "common/common_types.h" @@ -44,4 +45,10 @@ template <typename T> return static_cast<u32>(log2_f + static_cast<u64>((value ^ (1ULL << log2_f)) != 0ULL)); } +template <typename T> +requires std::is_integral_v<T> +[[nodiscard]] T NextPow2(T value) { + return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U))); +} + } // namespace Common |