summaryrefslogtreecommitdiff
path: root/src/blitter/32bpp_ssse3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/blitter/32bpp_ssse3.cpp')
-rw-r--r--src/blitter/32bpp_ssse3.cpp70
1 files changed, 36 insertions, 34 deletions
diff --git a/src/blitter/32bpp_ssse3.cpp b/src/blitter/32bpp_ssse3.cpp
index 9cee7dbf9..3c42d359c 100644
--- a/src/blitter/32bpp_ssse3.cpp
+++ b/src/blitter/32bpp_ssse3.cpp
@@ -74,8 +74,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
for (uint x = (uint) effective_width / 2; x > 0; x--) {
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
- ALPHA_BLEND_2();
- _mm_storel_epi64((__m128i*) dst, srcABCD);
+ _mm_storel_epi64((__m128i*) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm));
src += 2;
dst += 2;
}
@@ -83,8 +82,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
- ALPHA_BLEND_2();
- dst->data = _mm_cvtsi128_si32(srcABCD);
+ dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm));
}
break;
@@ -96,33 +94,39 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
/* Remap colours. */
if (mvX2 & 0x00FF00FF) {
- /* Written so the compiler uses CMOV. */
- const Colour src0 = src[0];
- const uint m0 = (byte) mvX2;
- const uint r0 = remap[m0];
- const Colour c0map = (this->LookupColourInPalette(r0).data & 0x00FFFFFF) | (src0.data & 0xFF000000);
- Colour c0 = 0; // Use alpha of 0 to keep dst as is.
- c0 = r0 == 0 ? c0 : c0map;
- c0 = m0 != 0 ? c0 : src0;
- srcABCD = _mm_cvtsi32_si128(c0.data);
-
- const Colour src1 = src[1];
- const uint m1 = (byte) (mvX2 >> 16);
- const uint r1 = remap[m1];
- const Colour c1map = (this->LookupColourInPalette(r1).data & 0x00FFFFFF) | (src1.data & 0xFF000000);
- Colour c1 = 0;
- c1 = r1 == 0 ? c1 : c1map;
- c1 = m1 != 0 ? c1 : src1;
- INSR32(c1.data, srcABCD, 1);
-
- if ((mvX2 & 0xFF00FF00) != 0x80008000) {
- ADJUST_BRIGHTNESS_2(srcABCD, mvX2);
- }
+ #define CMOV_REMAP(m_colour, m_src, m_m) \
+ /* Written so the compiler uses CMOV. */ \
+ Colour m_colour = 0; \
+ { \
+ const Colour srcm = (Colour) (m_src); \
+ const uint m = (byte) (m_m); \
+ const uint r = remap[m]; \
+ const Colour cmap = (this->LookupColourInPalette(r).data & 0x00FFFFFF) | (srcm.data & 0xFF000000); \
+ m_colour = r == 0 ? m_colour : cmap; \
+ m_colour = m != 0 ? m_colour : srcm; \
+ }
+#ifdef _SQ64
+ uint64 srcs = _mm_cvtsi128_si64(srcABCD);
+ uint64 remapped_src = 0;
+ CMOV_REMAP(c0, srcs, mvX2);
+ remapped_src = c0.data;
+ CMOV_REMAP(c1, srcs >> 32, mvX2 >> 16);
+ remapped_src |= (uint64) c1.data << 32;
+ srcABCD = _mm_cvtsi64_si128(remapped_src);
+#else
+ Colour remapped_src[2];
+ CMOV_REMAP(c0, _mm_cvtsi128_si32(srcABCD), mvX2);
+ remapped_src[0] = c0.data;
+ CMOV_REMAP(c1, src[1], mvX2 >> 16);
+ remapped_src[1] = c1.data;
+ srcABCD = _mm_loadl_epi64((__m128i*) &remapped_src);
+#endif
+
+ if ((mvX2 & 0xFF00FF00) != 0x80008000) srcABCD = AdjustBrightnessOfTwoPixels(srcABCD, mvX2);
}
/* Blend colours. */
- ALPHA_BLEND_2();
- _mm_storel_epi64((__m128i *) dst, srcABCD);
+ _mm_storel_epi64((__m128i *) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm));
dst += 2;
src += 2;
src_mv += 2;
@@ -134,7 +138,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
if (src_mv->m) {
const uint r = remap[src_mv->m];
if (r != 0) {
- Colour remapped_colour = AdjustBrightness(this->LookupColourInPalette(r), src_mv->v);
+ Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), src_mv->v);
if (src->a == 255) {
*dst = remapped_colour;
} else {
@@ -148,7 +152,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
if (src->a < 255) {
bmcr_alpha_blend_single:
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
- ALPHA_BLEND_2();
+ srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm);
}
dst->data = _mm_cvtsi128_si32(srcABCD);
}
@@ -160,8 +164,7 @@ bmcr_alpha_blend_single:
for (uint x = (uint) bp->width / 2; x > 0; x--) {
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
- DARKEN_2();
- _mm_storel_epi64((__m128i *) dst, dstAB);
+ _mm_storel_epi64((__m128i *) dst, DarkenTwoPixels(srcABCD, dstABCD, a_cm, tr_nom_base));
src += 2;
dst += 2;
}
@@ -169,8 +172,7 @@ bmcr_alpha_blend_single:
if ((bt_last == BT_NONE && bp->width & 1) || bt_last == BT_ODD) {
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
- DARKEN_2();
- dst->data = _mm_cvtsi128_si32(dstAB);
+ dst->data = _mm_cvtsi128_si32(DarkenTwoPixels(srcABCD, dstABCD, a_cm, tr_nom_base));
}
break;
}