diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index dbdbe752a8..5b46494e2c 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -709,30 +709,34 @@ ImageCatalogue ImageId::GetCatalogue() const return ImageCatalogue::UNKNOWN; } -void (*MaskFn)( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) - = nullptr; - -void MaskInit() +static auto GetMaskFunction() { if (AVX2Available()) { LOG_VERBOSE("registering AVX2 mask function"); - MaskFn = MaskAvx2; + return MaskAvx2; } else if (SSE41Available()) { LOG_VERBOSE("registering SSE4.1 mask function"); - MaskFn = MaskSse4_1; + return MaskSse4_1; } else { LOG_VERBOSE("registering scalar mask function"); - MaskFn = MaskScalar; + return MaskScalar; } } +static const auto MaskFunc = GetMaskFunction(); + +void MaskFn( + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, + int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) +{ + MaskFunc(width, height, maskSrc, colourSrc, dst, maskWrap, colourWrap, dstWrap); +} + void GfxFilterPixel(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, FilterPaletteID palette) { GfxFilterRect(dpi, { coords, coords }, palette); diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index 690b6c3e30..35da0cfd23 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -597,9 +597,8 @@ void MaskSse4_1( void MaskAvx2( int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); -void MaskInit(); -extern void (*MaskFn)( +void MaskFn( int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); diff --git a/src/openrct2/platform/Platform.Common.cpp b/src/openrct2/platform/Platform.Common.cpp index 83b4e13fa9..fbbfd2afb0 100644 --- a/src/openrct2/platform/Platform.Common.cpp +++ b/src/openrct2/platform/Platform.Common.cpp @@ -47,8 +47,6 @@ namespace Platform #ifdef __ANDROID__ Platform::AndroidInitClassLoader(); #endif // __ANDROID__ - - MaskInit(); } }