# 32bpp_sse_type.h

    00001 /* $Id: 32bpp_sse_type.h 26258 2014-01-13 18:12:33Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef BLITTER_32BPP_SSE_TYPE_HPP
    00013 #define BLITTER_32BPP_SSE_TYPE_HPP
    00014
    00015 #ifdef WITH_SSE
    00016
    00017 #include "32bpp_simple.hpp"
    00018 #if (SSE_VERSION == 2)
    00019 #include <emmintrin.h>
    00020 #elif (SSE_VERSION == 3)
    00021 #include <tmmintrin.h>
    00022 #elif (SSE_VERSION == 4)
    00023 #include <smmintrin.h>
    00024 #endif
    00025
    00026 #define META_LENGTH 2 ///< Number of uint32 inserted before each line of pixels in a sprite.
    00027 #define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
    00028 #define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
    00029
    00030 #ifdef _MSC_VER
    00031   #define ALIGN(n) __declspec(align(n))
    00032 #else
    00033   #define ALIGN(n) __attribute__ ((aligned (n)))
    00034 #endif
    00035
    00036 typedef union ALIGN(16) um128i {
    00037   __m128i m128i;
    00038   uint8 m128i_u8[16];
    00039   uint16 m128i_u16[8];
    00040   uint32 m128i_u32[4];
    00041   uint64 m128i_u64[2];
    00042 } um128i;
    00043
    00044 #define CLEAR_HIGH_BYTE_MASK        _mm_setr_epi8(-1,  0, -1,  0, -1,  0, -1,  0, -1,  0, -1,  0, -1,  0, -1,  0)
    00045 #define ALPHA_CONTROL_MASK          _mm_setr_epi8( 6,  7,  6,  7,  6,  7, -1, -1, 14, 15, 14, 15, 14, 15, -1, -1)
    00046 #define PACK_LOW_CONTROL_MASK       _mm_setr_epi8( 0,  2,  4, -1,  8, 10, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1)
    00047 #define PACK_HIGH_CONTROL_MASK      _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1,  0,  2,  4, -1,  8, 10, 12, -1)
    00048 #define BRIGHTNESS_LOW_CONTROL_MASK _mm_setr_epi8( 1,  2,  1,  2,  1,  2,  0,  2,  3,  2,  3,  2,  3,  2,  0,  2)
    00049 #define BRIGHTNESS_DIV_CLEANER      _mm_setr_epi8(-1,  1, -1,  1, -1,  1, -1,  0, -1,  1, -1,  1, -1,  1, -1,  0)
    00050 #define OVERBRIGHT_PRESENCE_MASK    _mm_setr_epi8( 1,  0,  1,  0,  1,  0,  0,  0,  1,  0,  1,  0,  1,  0,  0,  0)
    00051 #define OVERBRIGHT_VALUE_MASK       _mm_setr_epi8(-1,  0, -1,  0, -1,  0,  0,  0, -1,  0, -1,  0, -1,  0,  0,  0)
    00052 #define OVERBRIGHT_CONTROL_MASK     _mm_setr_epi8( 0,  1,  0,  1,  0,  1,  7,  7,  2,  3,  2,  3,  2,  3,  7,  7)
    00053 #define TRANSPARENT_NOM_BASE        _mm_setr_epi16(256, 256, 256, 256, 256, 256, 256, 256)
    00054
    00055 #endif /* WITH_SSE */
    00056 #endif /* BLITTER_32BPP_SSE_TYPE_HPP */