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

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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 == ZoomLevel::Out8x ? 8 : 4)
32#define MARGIN_REMAP_THRESHOLD 4
33
34typedef union alignas(16) um128i {
35 __m128i m128i;
36 uint8_t m128i_u8[16];
37 uint16_t m128i_u16[8];
38 uint32_t m128i_u32[4];
39 uint64_t m128i_u64[2];
40} um128i;
41
42#define CLEAR_HIGH_BYTE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0)
43#define ALPHA_CONTROL_MASK _mm_setr_epi8( 6, 7, 6, 7, 6, 7, -1, -1, 14, 15, 14, 15, 14, 15, -1, -1)
44#define PACK_LOW_CONTROL_MASK _mm_setr_epi8( 0, 2, 4, 6, 8, 10, 12, 14, -1, -1, -1, -1, -1, -1, -1, -1)
45#define PACK_HIGH_CONTROL_MASK _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 0, 2, 4, -1, 8, 10, 12, -1)
46#define BRIGHTNESS_LOW_CONTROL_MASK _mm_setr_epi8( 1, 2, 1, 2, 1, 2, 0, 2, 3, 2, 3, 2, 3, 2, 0, 2)
47#define BRIGHTNESS_DIV_CLEANER _mm_setr_epi8(-1, 1, -1, 1, -1, 1, -1, 0, -1, 1, -1, 1, -1, 1, -1, 0)
48#define OVERBRIGHT_PRESENCE_MASK _mm_setr_epi8( 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0)
49#define OVERBRIGHT_VALUE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0)
50#define OVERBRIGHT_CONTROL_MASK _mm_setr_epi8( 0, 1, 0, 1, 0, 1, 7, 7, 2, 3, 2, 3, 2, 3, 7, 7)
51#define TRANSPARENT_NOM_BASE _mm_setr_epi16(256, 256, 256, 256, 256, 256, 256, 256)
52#define ALPHA_AND_MASK _mm_setr_epi16( 0, 0, 0, -1, 0, 0, 0, -1)
53
54#endif /* WITH_SSE */
55#endif /* BLITTER_32BPP_SSE_TYPE_H */
32bpp_simple.hpp
Simple 32 bpp blitter.