diff --git a/Common/Math/CrossSIMD.h b/Common/Math/CrossSIMD.h index c274c61b77..af30c25b06 100644 --- a/Common/Math/CrossSIMD.h +++ b/Common/Math/CrossSIMD.h @@ -204,7 +204,7 @@ struct Vec4F32 { static Vec4F32 Load2(const float *src) { return Vec4F32{ _mm_castpd_ps(_mm_load_sd((const double *)src)) }; } static Vec4F32 LoadS8Norm(const int8_t *src) { - __m128i value = _mm_set1_epi32(*((uint32_t *)src)); + __m128i value = _mm_cvtsi32_si128(*((uint32_t *)src)); __m128i value16 = _mm_unpacklo_epi8(value, value); __m128i value32 = _mm_unpacklo_epi16(value16, value16); // Sign extension. A bit ugly without SSE4. @@ -213,7 +213,7 @@ struct Vec4F32 { } static Vec4F32 LoadU8Norm(const uint8_t *src) { - __m128i value = _mm_set1_epi32(*((uint32_t *)src)); + __m128i value = _mm_cvtsi32_si128(*((uint32_t *)src)); __m128i value16 = _mm_unpacklo_epi8(value, _mm_setzero_si128()); __m128i value32 = _mm_unpacklo_epi16(value16, _mm_setzero_si128()); return Vec4F32{_mm_mul_ps(_mm_cvtepi32_ps(value32), _mm_set1_ps(1.0f / 255.0f))}; @@ -225,22 +225,22 @@ struct Vec4F32 { return Vec4F32 { _mm_mul_ps(_mm_cvtepi32_ps(bits), _mm_set1_ps(1.0f / 32768.0f)) }; } - static Vec4F32 LoadConvertS16(const int16_t *src) { // Note: will load 8 bytes + static Vec4F32 LoadConvertS16(const int16_t *src) { // Note: will load 8 bytes (4*2) __m128i value = _mm_loadl_epi64((const __m128i *)src); // 16-bit to 32-bit, use the upper words and an arithmetic shift right to sign extend return Vec4F32{ _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(value, value), 16)) }; } - static Vec4F32 LoadConvertS8(const int8_t *src) { // Note: will load 8 bytes - __m128i value = _mm_loadl_epi64((const __m128i *)src); + static Vec4F32 LoadConvertS8(const int8_t *src) { + __m128i value = _mm_cvtsi32_si128(*((uint32_t *)src)); __m128i value16 = _mm_unpacklo_epi8(value, value); // 16-bit to 32-bit, use the upper words and an arithmetic shift right to sign extend return Vec4F32{ _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(value16, value16), 24)) }; } // NOTE: Does not normalize to 0..255 range. - static Vec4F32 LoadConvertU8(const uint8_t *src) { // Note: will load 8 bytes - __m128i value = _mm_loadl_epi64((const __m128i *)src); + static Vec4F32 LoadConvertU8(const uint8_t *src) { + __m128i value = _mm_cvtsi32_si128(*((uint32_t *)src)); __m128i zero = _mm_setzero_si128(); __m128i value16 = _mm_unpacklo_epi8(value, zero); // 16-bit to 32-bit, use the upper words and an arithmetic shift right to sign extend diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 923b83933a..5125f7611d 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -52,7 +52,8 @@ #define TEXTURE_KILL_AGE_LOWMEM 60 // Not used in lowmem mode. #define TEXTURE_SECOND_KILL_AGE 100 -// Used when there are multiple CLUT variants of a texture. +// Used when there are multiple CLUT variants of a texture, to avoid blowing up memory. See #10418 +// We should change this to do shader-based palette expansion. #define TEXTURE_KILL_AGE_CLUT 6 #define TEXTURE_CLUT_VARIANTS_MIN 6 @@ -836,8 +837,8 @@ void TextureCacheCommon::Decimate(TexCacheEntry *exceptThisOne, bool forcePressu ++iter; continue; } - bool hasClut = (iter->second->status & TexCacheEntry::STATUS_CLUT_VARIANTS) != 0; - int killAge = hasClut ? TEXTURE_KILL_AGE_CLUT : killAgeBase; + bool hasClutVariants = (iter->second->status & TexCacheEntry::STATUS_CLUT_VARIANTS) != 0; + int killAge = hasClutVariants ? TEXTURE_KILL_AGE_CLUT : killAgeBase; if (iter->second->lastFrame + killAge < gpuStats.totals.numFlips) { DeleteTexture(iter++); } else { diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index a62f331046..8a1d770db1 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -130,6 +130,7 @@ struct TextureDefinition { // At one point we might merge the concepts of framebuffers and textures, but that // moment is far away. + // TODO: Shrink this struct. There is some fluff. struct TexCacheEntry { ~TexCacheEntry() {