OpenTTD Source: src/blitter/32bpp_sse_type.h Source File

OpenTTD Source 14.1

32bpp_sse_type.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef BLITTER_32BPP_SSE_TYPE_H
11 #define BLITTER_32BPP_SSE_TYPE_H
12
13 /* ATTENTION
14 * This file is compiled multiple times with different defines for SSE_VERSION.
15 * Be careful when declaring things with external linkage.
16 * Use internal linkage instead, i.e. "static".
17 */
18
19 #ifdef WITH_SSE
20
21 #include "32bpp_simple.hpp"
22 #if (SSE_VERSION == 2)
23 #include <emmintrin.h>
24 #elif (SSE_VERSION == 3)
25 #include <tmmintrin.h>
26 #elif (SSE_VERSION == 4)
27 #include <smmintrin.h>
28 #endif
29
30 #define META_LENGTH 2
31 #define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4)
32 #define MARGIN_REMAP_THRESHOLD 4
33
34 #undef ALIGN
35
36 #ifdef _MSC_VER
37 #define ALIGN(n) __declspec(align(n))
38 #else
39 #define ALIGN(n) __attribute__ ((aligned (n)))
40 #endif
41
42 typedef union ALIGN(16) um128i {
43 __m128i m128i;
44 uint8_t m128i_u8[16];
45 uint16_t m128i_u16[8];
46 uint32_t m128i_u32[4];
47 uint64_t m128i_u64[2];
48 } um128i;
49
50 #define CLEAR_HIGH_BYTE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0)
51 #define ALPHA_CONTROL_MASK _mm_setr_epi8( 6, 7, 6, 7, 6, 7, -1, -1, 14, 15, 14, 15, 14, 15, -1, -1)
52 #define PACK_LOW_CONTROL_MASK _mm_setr_epi8( 0, 2, 4, 6, 8, 10, 12, 14, -1, -1, -1, -1, -1, -1, -1, -1)
53 #define PACK_HIGH_CONTROL_MASK _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 0, 2, 4, -1, 8, 10, 12, -1)
54 #define BRIGHTNESS_LOW_CONTROL_MASK _mm_setr_epi8( 1, 2, 1, 2, 1, 2, 0, 2, 3, 2, 3, 2, 3, 2, 0, 2)
55 #define BRIGHTNESS_DIV_CLEANER _mm_setr_epi8(-1, 1, -1, 1, -1, 1, -1, 0, -1, 1, -1, 1, -1, 1, -1, 0)
56 #define OVERBRIGHT_PRESENCE_MASK _mm_setr_epi8( 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0)
57 #define OVERBRIGHT_VALUE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0)
58 #define OVERBRIGHT_CONTROL_MASK _mm_setr_epi8( 0, 1, 0, 1, 0, 1, 7, 7, 2, 3, 2, 3, 2, 3, 7, 7)
59 #define TRANSPARENT_NOM_BASE _mm_setr_epi16(256, 256, 256, 256, 256, 256, 256, 256)
60 #define ALPHA_AND_MASK _mm_setr_epi16( 0, 0, 0, -1, 0, 0, 0, -1)
61
62 #endif /* WITH_SSE */
63 #endif /* BLITTER_32BPP_SSE_TYPE_H */
32bpp_simple.hpp