mirror of https://github.com/OpenTTD/OpenTTD
Fix #9935: Use more selectivity when building SSE specific code
parent
e9507e7ffa
commit
bba6ad1f4e
|
@ -29,11 +29,6 @@ add_files(
|
||||||
viewport_sprite_sorter_sse4.cpp
|
viewport_sprite_sorter_sse4.cpp
|
||||||
CONDITION SSE_FOUND
|
CONDITION SSE_FOUND
|
||||||
)
|
)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
set_compile_flags(
|
|
||||||
viewport_sprite_sorter_sse4.cpp
|
|
||||||
COMPILE_FLAGS -msse4.1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
aircraft.h
|
aircraft.h
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
/** Instantiation of the partially SSSE2 32bpp with animation blitter factory. */
|
/** Instantiation of the partially SSSE2 32bpp with animation blitter factory. */
|
||||||
static FBlitter_32bppSSE2_Anim iFBlitter_32bppSSE2_Anim;
|
static FBlitter_32bppSSE2_Anim iFBlitter_32bppSSE2_Anim;
|
||||||
|
|
||||||
|
GNU_TARGET("sse2")
|
||||||
void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
|
void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
|
||||||
{
|
{
|
||||||
assert(!_screen_disable_anim);
|
assert(!_screen_disable_anim);
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#define SSE_VERSION 2
|
#define SSE_VERSION 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SSE_TARGET
|
||||||
|
#define SSE_TARGET "sse2"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FULL_ANIMATION
|
#ifndef FULL_ANIMATION
|
||||||
#define FULL_ANIMATION 1
|
#define FULL_ANIMATION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,6 +29,7 @@ static FBlitter_32bppSSE4_Anim iFBlitter_32bppSSE4_Anim;
|
||||||
*/
|
*/
|
||||||
IGNORE_UNINITIALIZED_WARNING_START
|
IGNORE_UNINITIALIZED_WARNING_START
|
||||||
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last, bool translucent, bool animated>
|
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last, bool translucent, bool animated>
|
||||||
|
GNU_TARGET("sse4.1")
|
||||||
inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||||
{
|
{
|
||||||
const byte * const remap = bp->remap;
|
const byte * const remap = bp->remap;
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#define SSE_VERSION 4
|
#define SSE_VERSION 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SSE_TARGET
|
||||||
|
#define SSE_TARGET "sse4.1"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FULL_ANIMATION
|
#ifndef FULL_ANIMATION
|
||||||
#define FULL_ANIMATION 1
|
#define FULL_ANIMATION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#define SSE_VERSION 2
|
#define SSE_VERSION 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SSE_TARGET
|
||||||
|
#define SSE_TARGET "sse2"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FULL_ANIMATION
|
#ifndef FULL_ANIMATION
|
||||||
#define FULL_ANIMATION 0
|
#define FULL_ANIMATION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#define SSE_VERSION 4
|
#define SSE_VERSION 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SSE_TARGET
|
||||||
|
#define SSE_TARGET "sse4.1"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FULL_ANIMATION
|
#ifndef FULL_ANIMATION
|
||||||
#define FULL_ANIMATION 0
|
#define FULL_ANIMATION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#ifdef WITH_SSE
|
#ifdef WITH_SSE
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline void InsertFirstUint32(const uint32 value, __m128i &into)
|
static inline void InsertFirstUint32(const uint32 value, __m128i &into)
|
||||||
{
|
{
|
||||||
#if (SSE_VERSION >= 4)
|
#if (SSE_VERSION >= 4)
|
||||||
|
@ -22,6 +23,7 @@ static inline void InsertFirstUint32(const uint32 value, __m128i &into)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline void InsertSecondUint32(const uint32 value, __m128i &into)
|
static inline void InsertSecondUint32(const uint32 value, __m128i &into)
|
||||||
{
|
{
|
||||||
#if (SSE_VERSION >= 4)
|
#if (SSE_VERSION >= 4)
|
||||||
|
@ -32,6 +34,7 @@ static inline void InsertSecondUint32(const uint32 value, __m128i &into)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline void LoadUint64(const uint64 value, __m128i &into)
|
static inline void LoadUint64(const uint64 value, __m128i &into)
|
||||||
{
|
{
|
||||||
#ifdef POINTER_IS_64BIT
|
#ifdef POINTER_IS_64BIT
|
||||||
|
@ -46,6 +49,7 @@ static inline void LoadUint64(const uint64 value, __m128i &into)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
|
static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
|
||||||
{
|
{
|
||||||
#if (SSE_VERSION == 2)
|
#if (SSE_VERSION == 2)
|
||||||
|
@ -56,6 +60,7 @@ static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
|
static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
|
||||||
{
|
{
|
||||||
#if (SSE_VERSION == 2)
|
#if (SSE_VERSION == 2)
|
||||||
|
@ -66,6 +71,7 @@ static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask)
|
static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask)
|
||||||
{
|
{
|
||||||
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8 into uint16
|
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8 into uint16
|
||||||
|
@ -86,6 +92,7 @@ static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128
|
||||||
/* Darken 2 pixels.
|
/* Darken 2 pixels.
|
||||||
* rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
|
* rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
|
||||||
*/
|
*/
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
|
static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
|
||||||
{
|
{
|
||||||
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
|
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
|
||||||
|
@ -99,6 +106,7 @@ static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &d
|
||||||
}
|
}
|
||||||
|
|
||||||
IGNORE_UNINITIALIZED_WARNING_START
|
IGNORE_UNINITIALIZED_WARNING_START
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness)
|
static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness)
|
||||||
{
|
{
|
||||||
uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32;
|
uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32;
|
||||||
|
@ -141,6 +149,7 @@ static inline Colour AdjustBrightneSSE(Colour colour, uint8 brightness)
|
||||||
return ReallyAdjustBrightness(colour, brightness);
|
return ReallyAdjustBrightness(colour, brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32 brightness)
|
static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32 brightness)
|
||||||
{
|
{
|
||||||
#if (SSE_VERSION < 3)
|
#if (SSE_VERSION < 3)
|
||||||
|
@ -192,6 +201,7 @@ static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32 brightnes
|
||||||
*/
|
*/
|
||||||
IGNORE_UNINITIALIZED_WARNING_START
|
IGNORE_UNINITIALIZED_WARNING_START
|
||||||
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last, bool translucent>
|
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last, bool translucent>
|
||||||
|
GNU_TARGET(SSE_TARGET)
|
||||||
#if (SSE_VERSION == 2)
|
#if (SSE_VERSION == 2)
|
||||||
inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||||
#elif (SSE_VERSION == 3)
|
#elif (SSE_VERSION == 3)
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#define SSE_VERSION 3
|
#define SSE_VERSION 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SSE_TARGET
|
||||||
|
#define SSE_TARGET "ssse3"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FULL_ANIMATION
|
#ifndef FULL_ANIMATION
|
||||||
#define FULL_ANIMATION 0
|
#define FULL_ANIMATION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,21 +38,6 @@ add_files(
|
||||||
CONDITION NOT OPTION_DEDICATED AND OPENGL_FOUND
|
CONDITION NOT OPTION_DEDICATED AND OPENGL_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
set_compile_flags(
|
|
||||||
32bpp_anim_sse2.cpp
|
|
||||||
32bpp_sse2.cpp
|
|
||||||
COMPILE_FLAGS -msse2)
|
|
||||||
set_compile_flags(
|
|
||||||
32bpp_ssse3.cpp
|
|
||||||
COMPILE_FLAGS -mssse3)
|
|
||||||
set_compile_flags(
|
|
||||||
32bpp_anim_sse4.cpp
|
|
||||||
32bpp_sse4.cpp
|
|
||||||
COMPILE_FLAGS -msse4.1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
base.hpp
|
base.hpp
|
||||||
common.hpp
|
common.hpp
|
||||||
|
|
10
src/stdafx.h
10
src/stdafx.h
|
@ -418,11 +418,13 @@ static_assert(SIZE_MAX >= UINT32_MAX);
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
# define likely(x) __builtin_expect(!!(x), 1)
|
# define likely(x) __builtin_expect(!!(x), 1)
|
||||||
# define unlikely(x) __builtin_expect(!!(x), 0)
|
# define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
# define GNU_TARGET(x) [[gnu::target(x)]]
|
||||||
#else
|
#else
|
||||||
# define likely(x) (x)
|
# define likely(x) (x)
|
||||||
# define unlikely(x) (x)
|
# define unlikely(x) (x)
|
||||||
|
# define GNU_TARGET(x)
|
||||||
#endif /* __GNUC__ || __clang__ */
|
#endif /* __GNUC__ || __clang__ */
|
||||||
|
|
||||||
/* For the FMT library we only want to use the headers, not link to some library. */
|
/* For the FMT library we only want to use the headers, not link to some library. */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
# define LOAD_128 _mm_loadu_si128
|
# define LOAD_128 _mm_loadu_si128
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GNU_TARGET("sse4.1")
|
||||||
void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
|
void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
|
||||||
{
|
{
|
||||||
if (psdv->size() < 2) return;
|
if (psdv->size() < 2) return;
|
||||||
|
|
Loading…
Reference in New Issue