diff options
author | bunnei <bunneidev@gmail.com> | 2021-11-21 01:51:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 01:51:13 +0100 |
commit | ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e (patch) | |
tree | 3eb75c6d43296f2a4cbb41099b4f4e787918b1a1 /src/common | |
parent | Merge pull request #7294 from vonchenplus/fix_image_update_error_when_width_too_small (diff) | |
parent | TextureCache: Refactor and fix linux compiling. (diff) | |
download | yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.gz yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.bz2 yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.lz yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.xz yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.zst yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.zip |
Diffstat (limited to '')
-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 |