From 1bf65eff60c7cda71fddd3664d80e3ffb072f28c Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Mon, 5 Jun 2023 23:32:04 +0530 Subject: [PATCH] [dense] Add compilation fixes for meson * builds/meson/parse_modules_cfg.py: Add dense module * meson.build: Add SSE flags to ft2_defines, -lm to link_args * src/dense/ftdense.c: Fixes for compilation errors --- builds/meson/parse_modules_cfg.py | 1 + meson.build | 9 ++++++++- src/dense/ftdense.c | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/builds/meson/parse_modules_cfg.py b/builds/meson/parse_modules_cfg.py index d48129fe7..bd65d02a8 100644 --- a/builds/meson/parse_modules_cfg.py +++ b/builds/meson/parse_modules_cfg.py @@ -87,6 +87,7 @@ def generate_ftmodule(lists): names = { "raster": ("ft_raster1",), "smooth": ("ft_smooth",), + "dense": ("ft_dense",), "svg": ("ft_svg",), "sdf": ("ft_sdf", "ft_bitmap_sdf"), }.get(module) diff --git a/meson.build b/meson.build index f81de3e2f..e0acfb77c 100644 --- a/meson.build +++ b/meson.build @@ -395,6 +395,13 @@ if use_unix_ftsystem_c endif +if cc.get_id() == 'msvc' + ft2_defines += ['/arch:AVX'] +else + ft2_defines += ['-msse4.1'] +endif + + ft2_lib = library('freetype', sources: ft2_sources + [ftmodule_h], c_args: ft2_defines, @@ -403,7 +410,7 @@ ft2_lib = library('freetype', dependencies: ft2_deps, install: true, version: ft2_so_version, - link_args: common_ldflags, + link_args: common_ldflags + ['-lm'], ) diff --git a/src/dense/ftdense.c b/src/dense/ftdense.c index e95e0ae63..f0f3e59f9 100644 --- a/src/dense/ftdense.c +++ b/src/dense/ftdense.c @@ -154,7 +154,7 @@ dense_render_line( dense_worker* worker, FT_Pos tox, FT_Pos toy ) { int linestart = y * worker->m_w; - FT26D6 dy = min( (y + 1)<<6, to_y ) - max( y<<6, from_y ); + FT26D6 dy = FT_MIN( (y + 1)<<6, to_y ) - FT_MAX( y<<6, from_y ); m_a[linestart + x0i] += dir*dy*(64 - x + x0floor); m_a[linestart + ( x0i + 1 )] += dir*dy*(x-x0floor); @@ -457,7 +457,7 @@ __m128i offset = _mm_setzero_si128(); // shuffle y = _mm_shuffle_epi8( y, mask ); - _mm_store_ss( (float*)&dest[i], (__m128)y ); + _mm_store_ss( (float*)&dest[i], _mm_castsi128_ps(y) ); // store the current prefix sum in offset offset = _mm_castps_si128( _mm_shuffle_ps( _mm_castsi128_ps( x ),