diff options
| author | 2019-07-05 13:39:13 -0400 | |
|---|---|---|
| committer | 2019-07-05 13:39:13 -0400 | |
| commit | 772c86a260eb446b0fe4232b0a50666511bef25c (patch) | |
| tree | 013d92268c06454c93565c83eff2b79b56a00839 /src/common/bit_util.h | |
| parent | Merge pull request #2669 from FearlessTobi/move-cpujit-setting (diff) | |
| parent | texture_cache: Address Feedback (diff) | |
| download | yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.gz yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.xz yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.zip | |
Merge pull request #2601 from FernandoS27/texture_cache
Implement a new Texture Cache
Diffstat (limited to 'src/common/bit_util.h')
| -rw-r--r-- | src/common/bit_util.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h index d032df413..6f7d5a947 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h | |||
| @@ -97,4 +97,48 @@ inline u32 CountTrailingZeroes64(u64 value) { | |||
| 97 | } | 97 | } |
| 98 | #endif | 98 | #endif |
| 99 | 99 | ||
| 100 | #ifdef _MSC_VER | ||
| 101 | |||
| 102 | inline u32 MostSignificantBit32(const u32 value) { | ||
| 103 | unsigned long result; | ||
| 104 | _BitScanReverse(&result, value); | ||
| 105 | return static_cast<u32>(result); | ||
| 106 | } | ||
| 107 | |||
| 108 | inline u32 MostSignificantBit64(const u64 value) { | ||
| 109 | unsigned long result; | ||
| 110 | _BitScanReverse64(&result, value); | ||
| 111 | return static_cast<u32>(result); | ||
| 112 | } | ||
| 113 | |||
| 114 | #else | ||
| 115 | |||
| 116 | inline u32 MostSignificantBit32(const u32 value) { | ||
| 117 | return 31U - static_cast<u32>(__builtin_clz(value)); | ||
| 118 | } | ||
| 119 | |||
| 120 | inline u32 MostSignificantBit64(const u64 value) { | ||
| 121 | return 63U - static_cast<u32>(__builtin_clzll(value)); | ||
| 122 | } | ||
| 123 | |||
| 124 | #endif | ||
| 125 | |||
| 126 | inline u32 Log2Floor32(const u32 value) { | ||
| 127 | return MostSignificantBit32(value); | ||
| 128 | } | ||
| 129 | |||
| 130 | inline u32 Log2Ceil32(const u32 value) { | ||
| 131 | const u32 log2_f = Log2Floor32(value); | ||
| 132 | return log2_f + ((value ^ (1U << log2_f)) != 0U); | ||
| 133 | } | ||
| 134 | |||
| 135 | inline u32 Log2Floor64(const u64 value) { | ||
| 136 | return MostSignificantBit64(value); | ||
| 137 | } | ||
| 138 | |||
| 139 | inline u32 Log2Ceil64(const u64 value) { | ||
| 140 | const u64 log2_f = static_cast<u64>(Log2Floor64(value)); | ||
| 141 | return static_cast<u32>(log2_f + ((value ^ (1ULL << log2_f)) != 0ULL)); | ||
| 142 | } | ||
| 143 | |||
| 100 | } // namespace Common | 144 | } // namespace Common |