diff options
| author | 2020-03-13 22:20:12 -0300 | |
|---|---|---|
| committer | 2020-03-13 22:20:12 -0300 | |
| commit | d3dc4e399ca64e8d6c07d8e73640d2d87f3724fc (patch) | |
| tree | 24bcc9a7d2546fe8cc3c607dfe8b9aec2cc63414 /src/video_core | |
| parent | Merge pull request #3473 from ReinUsesLisp/shader-purge (diff) | |
| download | yuzu-d3dc4e399ca64e8d6c07d8e73640d2d87f3724fc.tar.gz yuzu-d3dc4e399ca64e8d6c07d8e73640d2d87f3724fc.tar.xz yuzu-d3dc4e399ca64e8d6c07d8e73640d2d87f3724fc.zip | |
astc: Use 'enum class' instead of 'enum' for EIntegerEncoding
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/textures/astc.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 33bd31865..af5a6c4ce 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp | |||
| @@ -144,11 +144,11 @@ private: | |||
| 144 | const IntType& m_Bits; | 144 | const IntType& m_Bits; |
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| 147 | enum EIntegerEncoding { eIntegerEncoding_JustBits, eIntegerEncoding_Quint, eIntegerEncoding_Trit }; | 147 | enum class IntegerEncoding { JustBits, Quint, Trit }; |
| 148 | 148 | ||
| 149 | class IntegerEncodedValue { | 149 | class IntegerEncodedValue { |
| 150 | private: | 150 | private: |
| 151 | const EIntegerEncoding m_Encoding; | 151 | const IntegerEncoding m_Encoding; |
| 152 | const uint32_t m_NumBits; | 152 | const uint32_t m_NumBits; |
| 153 | uint32_t m_BitValue; | 153 | uint32_t m_BitValue; |
| 154 | union { | 154 | union { |
| @@ -164,10 +164,10 @@ public: | |||
| 164 | return *this; | 164 | return *this; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | IntegerEncodedValue(EIntegerEncoding encoding, uint32_t numBits) | 167 | IntegerEncodedValue(IntegerEncoding encoding, uint32_t numBits) |
| 168 | : m_Encoding(encoding), m_NumBits(numBits) {} | 168 | : m_Encoding(encoding), m_NumBits(numBits) {} |
| 169 | 169 | ||
| 170 | EIntegerEncoding GetEncoding() const { | 170 | IntegerEncoding GetEncoding() const { |
| 171 | return m_Encoding; | 171 | return m_Encoding; |
| 172 | } | 172 | } |
| 173 | uint32_t BaseBitLength() const { | 173 | uint32_t BaseBitLength() const { |
| @@ -202,9 +202,9 @@ public: | |||
| 202 | // Returns the number of bits required to encode nVals values. | 202 | // Returns the number of bits required to encode nVals values. |
| 203 | uint32_t GetBitLength(uint32_t nVals) const { | 203 | uint32_t GetBitLength(uint32_t nVals) const { |
| 204 | uint32_t totalBits = m_NumBits * nVals; | 204 | uint32_t totalBits = m_NumBits * nVals; |
| 205 | if (m_Encoding == eIntegerEncoding_Trit) { | 205 | if (m_Encoding == IntegerEncoding::Trit) { |
| 206 | totalBits += (nVals * 8 + 4) / 5; | 206 | totalBits += (nVals * 8 + 4) / 5; |
| 207 | } else if (m_Encoding == eIntegerEncoding_Quint) { | 207 | } else if (m_Encoding == IntegerEncoding::Quint) { |
| 208 | totalBits += (nVals * 7 + 2) / 3; | 208 | totalBits += (nVals * 7 + 2) / 3; |
| 209 | } | 209 | } |
| 210 | return totalBits; | 210 | return totalBits; |
| @@ -227,24 +227,24 @@ public: | |||
| 227 | 227 | ||
| 228 | // Is maxVal a power of two? | 228 | // Is maxVal a power of two? |
| 229 | if (!(check & (check - 1))) { | 229 | if (!(check & (check - 1))) { |
| 230 | return IntegerEncodedValue(eIntegerEncoding_JustBits, Popcnt(maxVal)); | 230 | return IntegerEncodedValue(IntegerEncoding::JustBits, Popcnt(maxVal)); |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | // Is maxVal of the type 3*2^n - 1? | 233 | // Is maxVal of the type 3*2^n - 1? |
| 234 | if ((check % 3 == 0) && !((check / 3) & ((check / 3) - 1))) { | 234 | if ((check % 3 == 0) && !((check / 3) & ((check / 3) - 1))) { |
| 235 | return IntegerEncodedValue(eIntegerEncoding_Trit, Popcnt(check / 3 - 1)); | 235 | return IntegerEncodedValue(IntegerEncoding::Trit, Popcnt(check / 3 - 1)); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | // Is maxVal of the type 5*2^n - 1? | 238 | // Is maxVal of the type 5*2^n - 1? |
| 239 | if ((check % 5 == 0) && !((check / 5) & ((check / 5) - 1))) { | 239 | if ((check % 5 == 0) && !((check / 5) & ((check / 5) - 1))) { |
| 240 | return IntegerEncodedValue(eIntegerEncoding_Quint, Popcnt(check / 5 - 1)); | 240 | return IntegerEncodedValue(IntegerEncoding::Quint, Popcnt(check / 5 - 1)); |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | // Apparently it can't be represented with a bounded integer sequence... | 243 | // Apparently it can't be represented with a bounded integer sequence... |
| 244 | // just iterate. | 244 | // just iterate. |
| 245 | maxVal--; | 245 | maxVal--; |
| 246 | } | 246 | } |
| 247 | return IntegerEncodedValue(eIntegerEncoding_JustBits, 0); | 247 | return IntegerEncodedValue(IntegerEncoding::JustBits, 0); |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | // Fills result with the values that are encoded in the given | 250 | // Fills result with the values that are encoded in the given |
| @@ -259,17 +259,17 @@ public: | |||
| 259 | uint32_t nValsDecoded = 0; | 259 | uint32_t nValsDecoded = 0; |
| 260 | while (nValsDecoded < nValues) { | 260 | while (nValsDecoded < nValues) { |
| 261 | switch (val.GetEncoding()) { | 261 | switch (val.GetEncoding()) { |
| 262 | case eIntegerEncoding_Quint: | 262 | case IntegerEncoding::Quint: |
| 263 | DecodeQuintBlock(bits, result, val.BaseBitLength()); | 263 | DecodeQuintBlock(bits, result, val.BaseBitLength()); |
| 264 | nValsDecoded += 3; | 264 | nValsDecoded += 3; |
| 265 | break; | 265 | break; |
| 266 | 266 | ||
| 267 | case eIntegerEncoding_Trit: | 267 | case IntegerEncoding::Trit: |
| 268 | DecodeTritBlock(bits, result, val.BaseBitLength()); | 268 | DecodeTritBlock(bits, result, val.BaseBitLength()); |
| 269 | nValsDecoded += 5; | 269 | nValsDecoded += 5; |
| 270 | break; | 270 | break; |
| 271 | 271 | ||
| 272 | case eIntegerEncoding_JustBits: | 272 | case IntegerEncoding::JustBits: |
| 273 | val.SetBitValue(bits.ReadBits(val.BaseBitLength())); | 273 | val.SetBitValue(bits.ReadBits(val.BaseBitLength())); |
| 274 | result.push_back(val); | 274 | result.push_back(val); |
| 275 | nValsDecoded++; | 275 | nValsDecoded++; |
| @@ -332,7 +332,7 @@ private: | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | for (uint32_t i = 0; i < 5; i++) { | 334 | for (uint32_t i = 0; i < 5; i++) { |
| 335 | IntegerEncodedValue val(eIntegerEncoding_Trit, nBitsPerValue); | 335 | IntegerEncodedValue val(IntegerEncoding::Trit, nBitsPerValue); |
| 336 | val.SetBitValue(m[i]); | 336 | val.SetBitValue(m[i]); |
| 337 | val.SetTritValue(t[i]); | 337 | val.SetTritValue(t[i]); |
| 338 | result.push_back(val); | 338 | result.push_back(val); |
| @@ -380,7 +380,7 @@ private: | |||
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | for (uint32_t i = 0; i < 3; i++) { | 382 | for (uint32_t i = 0; i < 3; i++) { |
| 383 | IntegerEncodedValue val(eIntegerEncoding_Quint, nBitsPerValue); | 383 | IntegerEncodedValue val(IntegerEncoding::Quint, nBitsPerValue); |
| 384 | val.m_BitValue = m[i]; | 384 | val.m_BitValue = m[i]; |
| 385 | val.m_QuintValue = q[i]; | 385 | val.m_QuintValue = q[i]; |
| 386 | result.push_back(val); | 386 | result.push_back(val); |
| @@ -859,12 +859,12 @@ static void DecodeColorValues(uint32_t* out, uint8_t* data, const uint32_t* mode | |||
| 859 | 859 | ||
| 860 | switch (val.GetEncoding()) { | 860 | switch (val.GetEncoding()) { |
| 861 | // Replicate bits | 861 | // Replicate bits |
| 862 | case eIntegerEncoding_JustBits: | 862 | case IntegerEncoding::JustBits: |
| 863 | out[outIdx++] = Replicate(bitval, bitlen, 8); | 863 | out[outIdx++] = Replicate(bitval, bitlen, 8); |
| 864 | break; | 864 | break; |
| 865 | 865 | ||
| 866 | // Use algorithm in C.2.13 | 866 | // Use algorithm in C.2.13 |
| 867 | case eIntegerEncoding_Trit: { | 867 | case IntegerEncoding::Trit: { |
| 868 | 868 | ||
| 869 | D = val.GetTritValue(); | 869 | D = val.GetTritValue(); |
| 870 | 870 | ||
| @@ -912,10 +912,10 @@ static void DecodeColorValues(uint32_t* out, uint8_t* data, const uint32_t* mode | |||
| 912 | assert(!"Unsupported trit encoding for color values!"); | 912 | assert(!"Unsupported trit encoding for color values!"); |
| 913 | break; | 913 | break; |
| 914 | } // switch(bitlen) | 914 | } // switch(bitlen) |
| 915 | } // case eIntegerEncoding_Trit | 915 | } // case IntegerEncoding::Trit |
| 916 | break; | 916 | break; |
| 917 | 917 | ||
| 918 | case eIntegerEncoding_Quint: { | 918 | case IntegerEncoding::Quint: { |
| 919 | 919 | ||
| 920 | D = val.GetQuintValue(); | 920 | D = val.GetQuintValue(); |
| 921 | 921 | ||
| @@ -956,11 +956,11 @@ static void DecodeColorValues(uint32_t* out, uint8_t* data, const uint32_t* mode | |||
| 956 | assert(!"Unsupported quint encoding for color values!"); | 956 | assert(!"Unsupported quint encoding for color values!"); |
| 957 | break; | 957 | break; |
| 958 | } // switch(bitlen) | 958 | } // switch(bitlen) |
| 959 | } // case eIntegerEncoding_Quint | 959 | } // case IntegerEncoding::Quint |
| 960 | break; | 960 | break; |
| 961 | } // switch(val.GetEncoding()) | 961 | } // switch(val.GetEncoding()) |
| 962 | 962 | ||
| 963 | if (val.GetEncoding() != eIntegerEncoding_JustBits) { | 963 | if (val.GetEncoding() != IntegerEncoding::JustBits) { |
| 964 | uint32_t T = D * C + B; | 964 | uint32_t T = D * C + B; |
| 965 | T ^= A; | 965 | T ^= A; |
| 966 | T = (A & 0x80) | (T >> 2); | 966 | T = (A & 0x80) | (T >> 2); |
| @@ -983,11 +983,11 @@ static uint32_t UnquantizeTexelWeight(const IntegerEncodedValue& val) { | |||
| 983 | 983 | ||
| 984 | uint32_t result = 0; | 984 | uint32_t result = 0; |
| 985 | switch (val.GetEncoding()) { | 985 | switch (val.GetEncoding()) { |
| 986 | case eIntegerEncoding_JustBits: | 986 | case IntegerEncoding::JustBits: |
| 987 | result = Replicate(bitval, bitlen, 6); | 987 | result = Replicate(bitval, bitlen, 6); |
| 988 | break; | 988 | break; |
| 989 | 989 | ||
| 990 | case eIntegerEncoding_Trit: { | 990 | case IntegerEncoding::Trit: { |
| 991 | D = val.GetTritValue(); | 991 | D = val.GetTritValue(); |
| 992 | assert(D < 3); | 992 | assert(D < 3); |
| 993 | 993 | ||
| @@ -1019,7 +1019,7 @@ static uint32_t UnquantizeTexelWeight(const IntegerEncodedValue& val) { | |||
| 1019 | } | 1019 | } |
| 1020 | } break; | 1020 | } break; |
| 1021 | 1021 | ||
| 1022 | case eIntegerEncoding_Quint: { | 1022 | case IntegerEncoding::Quint: { |
| 1023 | D = val.GetQuintValue(); | 1023 | D = val.GetQuintValue(); |
| 1024 | assert(D < 5); | 1024 | assert(D < 5); |
| 1025 | 1025 | ||
| @@ -1046,7 +1046,7 @@ static uint32_t UnquantizeTexelWeight(const IntegerEncodedValue& val) { | |||
| 1046 | } break; | 1046 | } break; |
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| 1049 | if (val.GetEncoding() != eIntegerEncoding_JustBits && bitlen > 0) { | 1049 | if (val.GetEncoding() != IntegerEncoding::JustBits && bitlen > 0) { |
| 1050 | // Decode the value... | 1050 | // Decode the value... |
| 1051 | result = D * C + B; | 1051 | result = D * C + B; |
| 1052 | result ^= A; | 1052 | result ^= A; |