diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-05-24 22:58:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-05-24 23:37:03 +0300 |
commit | 3480f3ad939e2ae5d0191ed739a57e834658c32e (patch) | |
tree | 268acbda26a8a4e4849362f681e95ed8b4a6de16 /src/resources/dye/dyepalette.cpp | |
parent | c3699037bc32dd43ae1b5501261808eb3425697c (diff) | |
download | mv-3480f3ad939e2ae5d0191ed739a57e834658c32e.tar.gz mv-3480f3ad939e2ae5d0191ed739a57e834658c32e.tar.bz2 mv-3480f3ad939e2ae5d0191ed739a57e834658c32e.tar.xz mv-3480f3ad939e2ae5d0191ed739a57e834658c32e.zip |
Switch in replaceSColor into using custom despatcher.
Diffstat (limited to 'src/resources/dye/dyepalette.cpp')
-rw-r--r-- | src/resources/dye/dyepalette.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp index dfe6e95a2..5a350c8e2 100644 --- a/src/resources/dye/dyepalette.cpp +++ b/src/resources/dye/dyepalette.cpp @@ -38,8 +38,16 @@ #include <SDL_endian.h> #endif // SDL_BYTEORDER +#ifdef SIMD_SUPPORTED +#include "utils/cpu.h" +#endif // SIMD_SUPPORTED + #include "debug.h" +DyeFunctionPtr DyePalette::funcReplaceSColor = nullptr; +DyeFunctionPtr DyePalette::funcReplaceSColorSse2 = nullptr; +DyeFunctionPtr DyePalette::funcReplaceSColorAvx2 = nullptr; + DyePalette::DyePalette(const std::string &restrict description, const uint8_t blockSize) : mColors() @@ -224,3 +232,28 @@ void DyePalette::getColor(double intensity, color[2] = CAST_S32(rest * colorI.value[2] + intensity * colorJ.value[2]); } + +void DyePalette::initFunctions() +{ +#ifdef SIMD_SUPPORTED + const uint32_t flags = Cpu::getFlags(); + if (flags & Cpu::FEATURE_AVX2) + { + funcReplaceSColor = &DyePalette::replaceSColorAvx2; + funcReplaceSColorAvx2 = &DyePalette::replaceSColorAvx2; + funcReplaceSColorSse2 = &DyePalette::replaceSColorSse2; + } + else if (flags & Cpu::FEATURE_SSE2) + { + funcReplaceSColor = &DyePalette::replaceSColorSse2; + funcReplaceSColorAvx2 = &DyePalette::replaceSColorSse2; + funcReplaceSColorSse2 = &DyePalette::replaceSColorSse2; + } + else +#endif // SIMD_SUPPORTED + { + funcReplaceSColor = &DyePalette::replaceSColorDefault; + funcReplaceSColorAvx2 = &DyePalette::replaceSColorDefault; + funcReplaceSColorSse2 = &DyePalette::replaceSColorDefault; + } +} |