From 6b3260df9a121b61b793d16b529e7b3324fc3825 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 12 Jan 2016 00:20:36 -0800 Subject: [PATCH] Correct SSE alpha check for 4444 textures. Oops, can't use cmplt here. --- GPU/Common/TextureDecoder.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/GPU/Common/TextureDecoder.cpp b/GPU/Common/TextureDecoder.cpp index 87cba7ae1f..d70b3b31f3 100644 --- a/GPU/Common/TextureDecoder.cpp +++ b/GPU/Common/TextureDecoder.cpp @@ -476,16 +476,19 @@ CheckAlphaResult CheckAlphaABGR4444SSE2(const u32 *pixelData, int stride, int w, __m128i hasAnyCursor = _mm_setzero_si128(); for (int i = 0; i < w8; ++i) { + // This moves XXXA to A000. const __m128i a = _mm_slli_epi16(_mm_load_si128(&p[i]), 12); + // At least one bit in isZero, and therefore hasZeroCursor, will get set if there's a zero. const __m128i isZero = _mm_cmpeq_epi16(a, zero); hasZeroCursor = _mm_or_si128(hasZeroCursor, isZero); - // If a = F, isNotFull will be 0 -> hasAny will be 0. - // If a = 0, a & isNotFull will be 0 -> hasAny will be 0. + // If a = F, isFull will be 1 -> hasAny will be 0. + // If a = 0, a & !isFull will be 0 -> hasAny will be 0. // In any other case, hasAny will have some bits set. - const __m128i isNotFull = _mm_cmplt_epi32(a, full); - hasAnyCursor = _mm_or_si128(hasAnyCursor, _mm_and_si128(a, isNotFull)); + const __m128i isFull = _mm_cmpeq_epi32(a, full); + const __m128i hasAny = _mm_andnot_si128(isFull, a); + hasAnyCursor = _mm_or_si128(hasAnyCursor, hasAny); } p += stride8;