Improve some initialization in CrossSIMD.h. Add comments about CLUT variants

This commit is contained in:
Henrik Rydgård
2026-06-09 10:15:08 +02:00
parent f65b3f7a6b
commit 54d5c1d5e3
3 changed files with 12 additions and 10 deletions
+7 -7
View File
@@ -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
+4 -3
View File
@@ -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 {
+1
View File
@@ -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() {