mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-30 10:15:36 +01:00
Use static initialization to get the correct masking function
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ namespace Platform
|
||||
#ifdef __ANDROID__
|
||||
Platform::AndroidInitClassLoader();
|
||||
#endif // __ANDROID__
|
||||
|
||||
MaskInit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user