summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/textures/astc.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp
index 55f9aa0e4..f62d5c987 100644
--- a/src/video_core/textures/astc.cpp
+++ b/src/video_core/textures/astc.cpp
@@ -20,6 +20,8 @@
20#include <cstring> 20#include <cstring>
21#include <vector> 21#include <vector>
22 22
23#include <boost/container/static_vector.hpp>
24
23#include "common/common_types.h" 25#include "common/common_types.h"
24 26
25#include "video_core/textures/astc.h" 27#include "video_core/textures/astc.h"
@@ -189,9 +191,13 @@ struct IntegerEncodedValue {
189 u32 trit_value; 191 u32 trit_value;
190 }; 192 };
191}; 193};
194using IntegerEncodedVector = boost::container::static_vector<
195 IntegerEncodedValue, 64,
196 boost::container::static_vector_options<
197 boost::container::inplace_alignment<alignof(IntegerEncodedValue)>,
198 boost::container::throw_on_overflow<false>>::type>;
192 199
193static void DecodeTritBlock(InputBitStream& bits, std::vector<IntegerEncodedValue>& result, 200static void DecodeTritBlock(InputBitStream& bits, IntegerEncodedVector& result, u32 nBitsPerValue) {
194 u32 nBitsPerValue) {
195 // Implement the algorithm in section C.2.12 201 // Implement the algorithm in section C.2.12
196 u32 m[5]; 202 u32 m[5];
197 u32 t[5]; 203 u32 t[5];
@@ -249,7 +255,7 @@ static void DecodeTritBlock(InputBitStream& bits, std::vector<IntegerEncodedValu
249 } 255 }
250} 256}
251 257
252static void DecodeQus32Block(InputBitStream& bits, std::vector<IntegerEncodedValue>& result, 258static void DecodeQus32Block(InputBitStream& bits, IntegerEncodedVector& result,
253 u32 nBitsPerValue) { 259 u32 nBitsPerValue) {
254 // Implement the algorithm in section C.2.12 260 // Implement the algorithm in section C.2.12
255 u32 m[3]; 261 u32 m[3];
@@ -337,8 +343,8 @@ static constexpr std::array EncodingsValues = MakeEncodedValues();
337// Fills result with the values that are encoded in the given 343// Fills result with the values that are encoded in the given
338// bitstream. We must know beforehand what the maximum possible 344// bitstream. We must know beforehand what the maximum possible
339// value is, and how many values we're decoding. 345// value is, and how many values we're decoding.
340static void DecodeIntegerSequence(std::vector<IntegerEncodedValue>& result, InputBitStream& bits, 346static void DecodeIntegerSequence(IntegerEncodedVector& result, InputBitStream& bits, u32 maxRange,
341 u32 maxRange, u32 nValues) { 347 u32 nValues) {
342 // Determine encoding parameters 348 // Determine encoding parameters
343 IntegerEncodedValue val = EncodingsValues[maxRange]; 349 IntegerEncodedValue val = EncodingsValues[maxRange];
344 350
@@ -895,8 +901,7 @@ static void DecodeColorValues(u32* out, u8* data, const u32* modes, const u32 nP
895 } 901 }
896 902
897 // We now have enough to decode our integer sequence. 903 // We now have enough to decode our integer sequence.
898 std::vector<IntegerEncodedValue> decodedColorValues; 904 IntegerEncodedVector decodedColorValues;
899 decodedColorValues.reserve(32);
900 905
901 InputBitStream colorStream(data); 906 InputBitStream colorStream(data);
902 DecodeIntegerSequence(decodedColorValues, colorStream, range, nValues); 907 DecodeIntegerSequence(decodedColorValues, colorStream, range, nValues);
@@ -1126,7 +1131,7 @@ static u32 UnquantizeTexelWeight(const IntegerEncodedValue& val) {
1126 return result; 1131 return result;
1127} 1132}
1128 1133
1129static void UnquantizeTexelWeights(u32 out[2][144], const std::vector<IntegerEncodedValue>& weights, 1134static void UnquantizeTexelWeights(u32 out[2][144], const IntegerEncodedVector& weights,
1130 const TexelWeightParams& params, const u32 blockWidth, 1135 const TexelWeightParams& params, const u32 blockWidth,
1131 const u32 blockHeight) { 1136 const u32 blockHeight) {
1132 u32 weightIdx = 0; 1137 u32 weightIdx = 0;
@@ -1624,8 +1629,7 @@ static void DecompressBlock(const u8 inBuf[16], const u32 blockWidth, const u32
1624 static_cast<u8>((1 << (weightParams.GetPackedBitSize() % 8)) - 1); 1629 static_cast<u8>((1 << (weightParams.GetPackedBitSize() % 8)) - 1);
1625 memset(texelWeightData + clearByteStart, 0, 16 - clearByteStart); 1630 memset(texelWeightData + clearByteStart, 0, 16 - clearByteStart);
1626 1631
1627 std::vector<IntegerEncodedValue> texelWeightValues; 1632 IntegerEncodedVector texelWeightValues;
1628 texelWeightValues.reserve(64);
1629 1633
1630 InputBitStream weightStream(texelWeightData); 1634 InputBitStream weightStream(texelWeightData);
1631 1635