diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/textures/astc.cpp | 61 |
1 files changed, 22 insertions, 39 deletions
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 3c4ad1c9d..b2adbe888 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp | |||
| @@ -25,16 +25,15 @@ | |||
| 25 | 25 | ||
| 26 | class BitStream { | 26 | class BitStream { |
| 27 | public: | 27 | public: |
| 28 | BitStream(unsigned char* ptr, int nBits = 0, int start_offset = 0) | 28 | explicit BitStream(unsigned char* ptr, int nBits = 0, int start_offset = 0) |
| 29 | : m_BitsWritten(0), m_BitsRead(0), m_NumBits(nBits), m_CurByte(ptr), | 29 | : m_NumBits(nBits), m_CurByte(ptr), m_NextBit(start_offset % 8) {} |
| 30 | m_NextBit(start_offset % 8), done(false) {} | 30 | |
| 31 | ~BitStream() = default; | ||
| 31 | 32 | ||
| 32 | int GetBitsWritten() const { | 33 | int GetBitsWritten() const { |
| 33 | return m_BitsWritten; | 34 | return m_BitsWritten; |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | ~BitStream() {} | ||
| 37 | |||
| 38 | void WriteBitsR(unsigned int val, unsigned int nBits) { | 37 | void WriteBitsR(unsigned int val, unsigned int nBits) { |
| 39 | for (unsigned int i = 0; i < nBits; i++) { | 38 | for (unsigned int i = 0; i < nBits; i++) { |
| 40 | WriteBit((val >> (nBits - i - 1)) & 1); | 39 | WriteBit((val >> (nBits - i - 1)) & 1); |
| @@ -95,13 +94,13 @@ private: | |||
| 95 | done = done || ++m_BitsWritten >= m_NumBits; | 94 | done = done || ++m_BitsWritten >= m_NumBits; |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | int m_BitsWritten; | 97 | int m_BitsWritten = 0; |
| 99 | const int m_NumBits; | 98 | const int m_NumBits; |
| 100 | unsigned char* m_CurByte; | 99 | unsigned char* m_CurByte; |
| 101 | int m_NextBit; | 100 | int m_NextBit = 0; |
| 102 | int m_BitsRead; | 101 | int m_BitsRead = 0; |
| 103 | 102 | ||
| 104 | bool done; | 103 | bool done = false; |
| 105 | }; | 104 | }; |
| 106 | 105 | ||
| 107 | template <typename IntType> | 106 | template <typename IntType> |
| @@ -382,17 +381,13 @@ private: | |||
| 382 | namespace ASTCC { | 381 | namespace ASTCC { |
| 383 | 382 | ||
| 384 | struct TexelWeightParams { | 383 | struct TexelWeightParams { |
| 385 | uint32_t m_Width; | 384 | uint32_t m_Width = 0; |
| 386 | uint32_t m_Height; | 385 | uint32_t m_Height = 0; |
| 387 | bool m_bDualPlane; | 386 | bool m_bDualPlane = false; |
| 388 | uint32_t m_MaxWeight; | 387 | uint32_t m_MaxWeight = 0; |
| 389 | bool m_bError; | 388 | bool m_bError = false; |
| 390 | bool m_bVoidExtentLDR; | 389 | bool m_bVoidExtentLDR = false; |
| 391 | bool m_bVoidExtentHDR; | 390 | bool m_bVoidExtentHDR = false; |
| 392 | |||
| 393 | TexelWeightParams() { | ||
| 394 | memset(this, 0, sizeof(*this)); | ||
| 395 | } | ||
| 396 | 391 | ||
| 397 | uint32_t GetPackedBitSize() { | 392 | uint32_t GetPackedBitSize() { |
| 398 | // How many indices do we have? | 393 | // How many indices do we have? |
| @@ -668,27 +663,15 @@ IntType Replicate(const IntType& val, uint32_t numBits, uint32_t toBit) { | |||
| 668 | 663 | ||
| 669 | class Pixel { | 664 | class Pixel { |
| 670 | protected: | 665 | protected: |
| 671 | typedef int16_t ChannelType; | 666 | using ChannelType = int16_t; |
| 672 | uint8_t m_BitDepth[4]; | 667 | uint8_t m_BitDepth[4] = {8, 8, 8, 8}; |
| 673 | int16_t color[4]; | 668 | int16_t color[4] = {}; |
| 674 | 669 | ||
| 675 | public: | 670 | public: |
| 676 | Pixel() { | 671 | Pixel() = default; |
| 677 | for (int i = 0; i < 4; i++) { | 672 | Pixel(ChannelType a, ChannelType r, ChannelType g, ChannelType b, unsigned bitDepth = 8) |
| 678 | m_BitDepth[i] = 8; | 673 | : m_BitDepth{uint8_t(bitDepth), uint8_t(bitDepth), uint8_t(bitDepth), uint8_t(bitDepth)}, |
| 679 | color[i] = 0; | 674 | color{a, r, g, b} {} |
| 680 | } | ||
| 681 | } | ||
| 682 | |||
| 683 | Pixel(ChannelType a, ChannelType r, ChannelType g, ChannelType b, unsigned bitDepth = 8) { | ||
| 684 | for (int i = 0; i < 4; i++) | ||
| 685 | m_BitDepth[i] = bitDepth; | ||
| 686 | |||
| 687 | color[0] = a; | ||
| 688 | color[1] = r; | ||
| 689 | color[2] = g; | ||
| 690 | color[3] = b; | ||
| 691 | } | ||
| 692 | 675 | ||
| 693 | // Changes the depth of each pixel. This scales the values to | 676 | // Changes the depth of each pixel. This scales the values to |
| 694 | // the appropriate bit depth by either truncating the least | 677 | // the appropriate bit depth by either truncating the least |