2014-01-13 19:12:33 +01:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2018-10-28 03:17:36 +01:00
|
|
|
/** @file 32bpp_sse_type.h Types related to SSE 32 bpp blitter. */
|
2014-01-13 19:12:33 +01:00
|
|
|
|
2018-10-28 03:17:36 +01:00
|
|
|
#ifndef BLITTER_32BPP_SSE_TYPE_H
|
|
|
|
#define BLITTER_32BPP_SSE_TYPE_H
|
2014-01-13 19:12:33 +01:00
|
|
|
|
2024-03-17 00:42:38 +01:00
|
|
|
/* ATTENTION
|
|
|
|
* This file is compiled multiple times with different defines for SSE_VERSION.
|
|
|
|
* Be careful when declaring things with external linkage.
|
|
|
|
* Use internal linkage instead, i.e. "static".
|
|
|
|
*/
|
|
|
|
|
2014-01-13 19:12:33 +01:00
|
|
|
#ifdef WITH_SSE
|
|
|
|
|
|
|
|
#include "32bpp_simple.hpp"
|
|
|
|
#if (SSE_VERSION == 2)
|
|
|
|
#include <emmintrin.h>
|
|
|
|
#elif (SSE_VERSION == 3)
|
|
|
|
#include <tmmintrin.h>
|
|
|
|
#elif (SSE_VERSION == 4)
|
|
|
|
#include <smmintrin.h>
|
|
|
|
#endif
|
|
|
|
|
2023-05-08 19:01:06 +02:00
|
|
|
#define META_LENGTH 2 ///< Number of uint32_t inserted before each line of pixels in a sprite.
|
2024-04-04 19:51:46 +02:00
|
|
|
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_8X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
|
2014-01-13 19:12:33 +01:00
|
|
|
#define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
|
|
|
|
|
2018-01-28 23:01:10 +01:00
|
|
|
#undef ALIGN
|
|
|
|
|
2014-01-13 19:12:33 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define ALIGN(n) __declspec(align(n))
|
|
|
|
#else
|
|
|
|
#define ALIGN(n) __attribute__ ((aligned (n)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef union ALIGN(16) um128i {
|
|
|
|
__m128i m128i;
|
2023-05-08 19:01:06 +02:00
|
|
|
uint8_t m128i_u8[16];
|
|
|
|
uint16_t m128i_u16[8];
|
|
|
|
uint32_t m128i_u32[4];
|
|
|
|
uint64_t m128i_u64[2];
|
2014-01-13 19:12:33 +01:00
|
|
|
} um128i;
|
|
|
|
|
|
|
|
#define CLEAR_HIGH_BYTE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0)
|
|
|
|
#define ALPHA_CONTROL_MASK _mm_setr_epi8( 6, 7, 6, 7, 6, 7, -1, -1, 14, 15, 14, 15, 14, 15, -1, -1)
|
2021-01-16 16:43:37 +01:00
|
|
|
#define PACK_LOW_CONTROL_MASK _mm_setr_epi8( 0, 2, 4, 6, 8, 10, 12, 14, -1, -1, -1, -1, -1, -1, -1, -1)
|
2014-01-13 19:12:33 +01:00
|
|
|
#define PACK_HIGH_CONTROL_MASK _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 0, 2, 4, -1, 8, 10, 12, -1)
|
|
|
|
#define BRIGHTNESS_LOW_CONTROL_MASK _mm_setr_epi8( 1, 2, 1, 2, 1, 2, 0, 2, 3, 2, 3, 2, 3, 2, 0, 2)
|
|
|
|
#define BRIGHTNESS_DIV_CLEANER _mm_setr_epi8(-1, 1, -1, 1, -1, 1, -1, 0, -1, 1, -1, 1, -1, 1, -1, 0)
|
|
|
|
#define OVERBRIGHT_PRESENCE_MASK _mm_setr_epi8( 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0)
|
|
|
|
#define OVERBRIGHT_VALUE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0)
|
|
|
|
#define OVERBRIGHT_CONTROL_MASK _mm_setr_epi8( 0, 1, 0, 1, 0, 1, 7, 7, 2, 3, 2, 3, 2, 3, 7, 7)
|
|
|
|
#define TRANSPARENT_NOM_BASE _mm_setr_epi16(256, 256, 256, 256, 256, 256, 256, 256)
|
2022-09-29 01:46:31 +02:00
|
|
|
#define ALPHA_AND_MASK _mm_setr_epi16( 0, 0, 0, -1, 0, 0, 0, -1)
|
2014-01-13 19:12:33 +01:00
|
|
|
|
|
|
|
#endif /* WITH_SSE */
|
2018-10-28 03:17:36 +01:00
|
|
|
#endif /* BLITTER_32BPP_SSE_TYPE_H */
|