diff options
| author | 2020-04-09 02:54:05 -0300 | |
|---|---|---|
| committer | 2020-04-09 02:54:05 -0300 | |
| commit | d22a6892506395d7348f42c21288ab5ac9d7be5a (patch) | |
| tree | 192e363dda9454ff494bc6062b35333767998d8f /src | |
| parent | astc: OutputBitStream style changes and make it constexpr (diff) | |
| download | yuzu-d22a6892506395d7348f42c21288ab5ac9d7be5a.tar.gz yuzu-d22a6892506395d7348f42c21288ab5ac9d7be5a.tar.xz yuzu-d22a6892506395d7348f42c21288ab5ac9d7be5a.zip | |
astc: Make InputBitStream constexpr
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/textures/astc.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 20706bda0..91b4c5d7e 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp | |||
| @@ -39,25 +39,25 @@ constexpr u32 Popcnt(u32 n) { | |||
| 39 | 39 | ||
| 40 | class InputBitStream { | 40 | class InputBitStream { |
| 41 | public: | 41 | public: |
| 42 | explicit InputBitStream(const u8* ptr, std::size_t start_offset = 0) | 42 | constexpr explicit InputBitStream(const u8* ptr, std::size_t start_offset = 0) |
| 43 | : cur_byte(ptr), next_bit(start_offset % 8) {} | 43 | : cur_byte{ptr}, next_bit{start_offset % 8} {} |
| 44 | 44 | ||
| 45 | std::size_t GetBitsRead() const { | 45 | constexpr std::size_t GetBitsRead() const { |
| 46 | return m_BitsRead; | 46 | return bits_read; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | u32 ReadBit() { | 49 | constexpr bool ReadBit() { |
| 50 | u32 bit = *cur_byte >> next_bit++; | 50 | const bool bit = (*cur_byte >> next_bit++) & 1; |
| 51 | while (next_bit >= 8) { | 51 | while (next_bit >= 8) { |
| 52 | next_bit -= 8; | 52 | next_bit -= 8; |
| 53 | cur_byte++; | 53 | cur_byte++; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | m_BitsRead++; | 56 | bits_read++; |
| 57 | return bit & 1; | 57 | return bit; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | u32 ReadBits(std::size_t nBits) { | 60 | constexpr u32 ReadBits(std::size_t nBits) { |
| 61 | u32 ret = 0; | 61 | u32 ret = 0; |
| 62 | for (std::size_t i = 0; i < nBits; ++i) { | 62 | for (std::size_t i = 0; i < nBits; ++i) { |
| 63 | ret |= (ReadBit() & 1) << i; | 63 | ret |= (ReadBit() & 1) << i; |
| @@ -66,7 +66,7 @@ public: | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | template <std::size_t nBits> | 68 | template <std::size_t nBits> |
| 69 | u32 ReadBits() { | 69 | constexpr u32 ReadBits() { |
| 70 | u32 ret = 0; | 70 | u32 ret = 0; |
| 71 | for (std::size_t i = 0; i < nBits; ++i) { | 71 | for (std::size_t i = 0; i < nBits; ++i) { |
| 72 | ret |= (ReadBit() & 1) << i; | 72 | ret |= (ReadBit() & 1) << i; |
| @@ -77,7 +77,7 @@ public: | |||
| 77 | private: | 77 | private: |
| 78 | const u8* cur_byte; | 78 | const u8* cur_byte; |
| 79 | std::size_t next_bit = 0; | 79 | std::size_t next_bit = 0; |
| 80 | std::size_t m_BitsRead = 0; | 80 | std::size_t bits_read = 0; |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | class OutputBitStream { | 83 | class OutputBitStream { |