diff options
| author | 2021-06-24 21:47:05 -0700 | |
|---|---|---|
| committer | 2021-06-24 21:47:05 -0700 | |
| commit | c805c0b395347b8094964924d85a3151ff2c6593 (patch) | |
| tree | c9f018055025fa3c973bacec5f056f68d8f8e67c /src/video_core/textures/astc.cpp | |
| parent | Merge pull request #6519 from Wunkolo/mem-size-literal (diff) | |
| parent | util_shaders: Specify ASTC decoder memory barrier bits (diff) | |
| download | yuzu-c805c0b395347b8094964924d85a3151ff2c6593.tar.gz yuzu-c805c0b395347b8094964924d85a3151ff2c6593.tar.xz yuzu-c805c0b395347b8094964924d85a3151ff2c6593.zip | |
Merge pull request #6496 from ameerj/astc-fixes
astc: Various robustness enhancements for the gpu decoder
Diffstat (limited to 'src/video_core/textures/astc.cpp')
| -rw-r--r-- | src/video_core/textures/astc.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 9b2177ebd..7b756ba41 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp | |||
| @@ -269,7 +269,7 @@ static void DecodeQuintBlock(InputBitStream& bits, IntegerEncodedVector& result, | |||
| 269 | static void DecodeIntegerSequence(IntegerEncodedVector& result, InputBitStream& bits, u32 maxRange, | 269 | static void DecodeIntegerSequence(IntegerEncodedVector& result, InputBitStream& bits, u32 maxRange, |
| 270 | u32 nValues) { | 270 | u32 nValues) { |
| 271 | // Determine encoding parameters | 271 | // Determine encoding parameters |
| 272 | IntegerEncodedValue val = EncodingsValues[maxRange]; | 272 | IntegerEncodedValue val = ASTC_ENCODINGS_VALUES[maxRange]; |
| 273 | 273 | ||
| 274 | // Start decoding | 274 | // Start decoding |
| 275 | u32 nValsDecoded = 0; | 275 | u32 nValsDecoded = 0; |
| @@ -310,7 +310,7 @@ struct TexelWeightParams { | |||
| 310 | nIdxs *= 2; | 310 | nIdxs *= 2; |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | return EncodingsValues[m_MaxWeight].GetBitLength(nIdxs); | 313 | return ASTC_ENCODINGS_VALUES[m_MaxWeight].GetBitLength(nIdxs); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | u32 GetNumWeightValues() const { | 316 | u32 GetNumWeightValues() const { |
| @@ -551,6 +551,8 @@ static void FillError(std::span<u32> outBuf, u32 blockWidth, u32 blockHeight) { | |||
| 551 | } | 551 | } |
| 552 | } | 552 | } |
| 553 | } | 553 | } |
| 554 | |||
| 555 | static constexpr auto REPLICATE_BYTE_TO_16_TABLE = MakeReplicateTable<u32, 8, 16>(); | ||
| 554 | static constexpr u32 ReplicateByteTo16(std::size_t value) { | 556 | static constexpr u32 ReplicateByteTo16(std::size_t value) { |
| 555 | return REPLICATE_BYTE_TO_16_TABLE[value]; | 557 | return REPLICATE_BYTE_TO_16_TABLE[value]; |
| 556 | } | 558 | } |
| @@ -753,12 +755,12 @@ static void DecodeColorValues(u32* out, std::span<u8> data, const u32* modes, co | |||
| 753 | // figure out the max value for each of them... | 755 | // figure out the max value for each of them... |
| 754 | u32 range = 256; | 756 | u32 range = 256; |
| 755 | while (--range > 0) { | 757 | while (--range > 0) { |
| 756 | IntegerEncodedValue val = EncodingsValues[range]; | 758 | IntegerEncodedValue val = ASTC_ENCODINGS_VALUES[range]; |
| 757 | u32 bitLength = val.GetBitLength(nValues); | 759 | u32 bitLength = val.GetBitLength(nValues); |
| 758 | if (bitLength <= nBitsForColorData) { | 760 | if (bitLength <= nBitsForColorData) { |
| 759 | // Find the smallest possible range that matches the given encoding | 761 | // Find the smallest possible range that matches the given encoding |
| 760 | while (--range > 0) { | 762 | while (--range > 0) { |
| 761 | IntegerEncodedValue newval = EncodingsValues[range]; | 763 | IntegerEncodedValue newval = ASTC_ENCODINGS_VALUES[range]; |
| 762 | if (!newval.MatchesEncoding(val)) { | 764 | if (!newval.MatchesEncoding(val)) { |
| 763 | break; | 765 | break; |
| 764 | } | 766 | } |