Blender V4.3
BLI_simd.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
13/* sse2neon.h uses a newer pre-processor which is no available for C language when using MSVC.
14 * For the consistency require C++ for all build configurations. */
15#if !defined(__cplusplus)
16# error Including BLI_simd.hh requires C++
17#endif
18
19#if (defined(__ARM_NEON) || (defined(_M_ARM64) && defined(_MSC_VER))) && \
20 defined(WITH_SSE2NEON) && !defined(DISABLE_SSE2NEON)
21/* SSE/SSE2 emulation on ARM Neon. Match SSE precision. */
22# if !defined(SSE2NEON_PRECISE_MINMAX)
23# define SSE2NEON_PRECISE_MINMAX 1
24# endif
25# if !defined(SSE2NEON_PRECISE_DIV)
26# define SSE2NEON_PRECISE_DIV 1
27# endif
28# if !defined(SSE2NEON_PRECISE_SQRT)
29# define SSE2NEON_PRECISE_SQRT 1
30# endif
31# include <sse2neon.h>
32# define BLI_HAVE_SSE2 1
33#elif defined(__SSE2__)
34/* Native SSE2 on Intel/AMD. */
35# include <emmintrin.h>
36# define BLI_HAVE_SSE2 1
37#else
38# define BLI_HAVE_SSE2 0
39#endif
40
41#if (defined(__ARM_NEON) || (defined(_M_ARM64) && defined(_MSC_VER))) && \
42 defined(WITH_SSE2NEON) && !defined(DISABLE_SSE2NEON)
43/* SSE4 is emulated via sse2neon. */
44# define BLI_HAVE_SSE4 1
45#elif defined(__SSE4_2__)
46/* Native SSE4.2. */
47# include <nmmintrin.h>
48# define BLI_HAVE_SSE4 1
49#else
50# define BLI_HAVE_SSE4 0
51#endif