mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
astc: Move Popcnt to an anonymous namespace and make it constexpr
This commit is contained in:
parent
731a9a322e
commit
835a3d09c6
1 changed files with 13 additions and 9 deletions
|
@ -25,6 +25,19 @@
|
||||||
|
|
||||||
#include "video_core/textures/astc.h"
|
#include "video_core/textures/astc.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
/// Count the number of bits set in a number.
|
||||||
|
constexpr u32 Popcnt(u32 n) {
|
||||||
|
u32 c = 0;
|
||||||
|
for (; n; c++) {
|
||||||
|
n &= n - 1;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
class InputBitStream {
|
class InputBitStream {
|
||||||
public:
|
public:
|
||||||
explicit InputBitStream(const unsigned char* ptr, int start_offset = 0)
|
explicit InputBitStream(const unsigned char* ptr, int start_offset = 0)
|
||||||
|
@ -212,15 +225,6 @@ public:
|
||||||
return totalBits;
|
return totalBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of bits set in a number.
|
|
||||||
static inline u32 Popcnt(u32 n) {
|
|
||||||
u32 c;
|
|
||||||
for (c = 0; n; c++) {
|
|
||||||
n &= n - 1;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a new instance of this struct that corresponds to the
|
// Returns a new instance of this struct that corresponds to the
|
||||||
// can take no more than maxval values
|
// can take no more than maxval values
|
||||||
static IntegerEncodedValue CreateEncoding(u32 maxVal) {
|
static IntegerEncodedValue CreateEncoding(u32 maxVal) {
|
||||||
|
|
Loading…
Reference in a new issue