summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/textures/astc.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp
index bafd137d5..1f2eca787 100644
--- a/src/video_core/textures/astc.cpp
+++ b/src/video_core/textures/astc.cpp
@@ -106,16 +106,16 @@ private:
106template <typename IntType> 106template <typename IntType>
107class Bits { 107class Bits {
108public: 108public:
109 explicit Bits(IntType& v) : m_Bits(v) {} 109 explicit Bits(const IntType& v) : m_Bits(v) {}
110 110
111 Bits(const Bits&) = delete; 111 Bits(const Bits&) = delete;
112 Bits& operator=(const Bits&) = delete; 112 Bits& operator=(const Bits&) = delete;
113 113
114 uint8_t operator[](uint32_t bitPos) { 114 uint8_t operator[](uint32_t bitPos) const {
115 return static_cast<uint8_t>((m_Bits >> bitPos) & 1); 115 return static_cast<uint8_t>((m_Bits >> bitPos) & 1);
116 } 116 }
117 117
118 IntType operator()(uint32_t start, uint32_t end) { 118 IntType operator()(uint32_t start, uint32_t end) const {
119 if (start == end) { 119 if (start == end) {
120 return (*this)[start]; 120 return (*this)[start];
121 } else if (start > end) { 121 } else if (start > end) {
@@ -183,12 +183,12 @@ public:
183 m_QuintValue = val; 183 m_QuintValue = val;
184 } 184 }
185 185
186 bool MatchesEncoding(const IntegerEncodedValue& other) { 186 bool MatchesEncoding(const IntegerEncodedValue& other) const {
187 return m_Encoding == other.m_Encoding && m_NumBits == other.m_NumBits; 187 return m_Encoding == other.m_Encoding && m_NumBits == other.m_NumBits;
188 } 188 }
189 189
190 // Returns the number of bits required to encode nVals values. 190 // Returns the number of bits required to encode nVals values.
191 uint32_t GetBitLength(uint32_t nVals) { 191 uint32_t GetBitLength(uint32_t nVals) const {
192 uint32_t totalBits = m_NumBits * nVals; 192 uint32_t totalBits = m_NumBits * nVals;
193 if (m_Encoding == eIntegerEncoding_Trit) { 193 if (m_Encoding == eIntegerEncoding_Trit) {
194 totalBits += (nVals * 8 + 4) / 5; 194 totalBits += (nVals * 8 + 4) / 5;
@@ -387,7 +387,7 @@ struct TexelWeightParams {
387 bool m_bVoidExtentLDR = false; 387 bool m_bVoidExtentLDR = false;
388 bool m_bVoidExtentHDR = false; 388 bool m_bVoidExtentHDR = false;
389 389
390 uint32_t GetPackedBitSize() { 390 uint32_t GetPackedBitSize() const {
391 // How many indices do we have? 391 // How many indices do we have?
392 uint32_t nIdxs = m_Height * m_Width; 392 uint32_t nIdxs = m_Height * m_Width;
393 if (m_bDualPlane) { 393 if (m_bDualPlane) {
@@ -788,8 +788,8 @@ public:
788 } 788 }
789}; 789};
790 790
791void DecodeColorValues(uint32_t* out, uint8_t* data, uint32_t* modes, const uint32_t nPartitions, 791void DecodeColorValues(uint32_t* out, uint8_t* data, const uint32_t* modes,
792 const uint32_t nBitsForColorData) { 792 const uint32_t nPartitions, const uint32_t nBitsForColorData) {
793 // First figure out how many color values we have 793 // First figure out how many color values we have
794 uint32_t nValues = 0; 794 uint32_t nValues = 0;
795 for (uint32_t i = 0; i < nPartitions; i++) { 795 for (uint32_t i = 0; i < nPartitions; i++) {
@@ -825,8 +825,7 @@ void DecodeColorValues(uint32_t* out, uint8_t* data, uint32_t* modes, const uint
825 // Once we have the decoded values, we need to dequantize them to the 0-255 range 825 // Once we have the decoded values, we need to dequantize them to the 0-255 range
826 // This procedure is outlined in ASTC spec C.2.13 826 // This procedure is outlined in ASTC spec C.2.13
827 uint32_t outIdx = 0; 827 uint32_t outIdx = 0;
828 std::vector<IntegerEncodedValue>::const_iterator itr; 828 for (auto itr = decodedColorValues.begin(); itr != decodedColorValues.end(); ++itr) {
829 for (itr = decodedColorValues.begin(); itr != decodedColorValues.end(); itr++) {
830 // Have we already decoded all that we need? 829 // Have we already decoded all that we need?
831 if (outIdx >= nValues) { 830 if (outIdx >= nValues) {
832 break; 831 break;
@@ -1048,17 +1047,17 @@ uint32_t UnquantizeTexelWeight(const IntegerEncodedValue& val) {
1048 return result; 1047 return result;
1049} 1048}
1050 1049
1051void UnquantizeTexelWeights(uint32_t out[2][144], std::vector<IntegerEncodedValue>& weights, 1050void UnquantizeTexelWeights(uint32_t out[2][144], const std::vector<IntegerEncodedValue>& weights,
1052 const TexelWeightParams& params, const uint32_t blockWidth, 1051 const TexelWeightParams& params, const uint32_t blockWidth,
1053 const uint32_t blockHeight) { 1052 const uint32_t blockHeight) {
1054 uint32_t weightIdx = 0; 1053 uint32_t weightIdx = 0;
1055 uint32_t unquantized[2][144]; 1054 uint32_t unquantized[2][144];
1056 std::vector<IntegerEncodedValue>::const_iterator itr; 1055
1057 for (itr = weights.begin(); itr != weights.end(); itr++) { 1056 for (auto itr = weights.begin(); itr != weights.end(); ++itr) {
1058 unquantized[0][weightIdx] = UnquantizeTexelWeight(*itr); 1057 unquantized[0][weightIdx] = UnquantizeTexelWeight(*itr);
1059 1058
1060 if (params.m_bDualPlane) { 1059 if (params.m_bDualPlane) {
1061 itr++; 1060 ++itr;
1062 unquantized[1][weightIdx] = UnquantizeTexelWeight(*itr); 1061 unquantized[1][weightIdx] = UnquantizeTexelWeight(*itr);
1063 if (itr == weights.end()) { 1062 if (itr == weights.end()) {
1064 break; 1063 break;