Add SIMD support to Web with SSE4.2

This commit is contained in:
Wojtek Figat
2026-03-13 10:21:21 +01:00
parent c91c209974
commit 2cb12e3c0f
2 changed files with 25 additions and 2 deletions

View File

@@ -5,7 +5,9 @@
#include "Engine/Core/Types/String.h"
#include "Engine/Core/Types/StringView.h"
#if PLATFORM_SIMD_SSE4_2
#if PLATFORM_WEB
#define RAPIDJSON_SSE2
#elif PLATFORM_SIMD_SSE4_2
#define RAPIDJSON_SSE42
#elif PLATFORM_SIMD_SSE2
#define RAPIDJSON_SSE2

View File

@@ -95,7 +95,7 @@ namespace Flax.Build.Platforms
options.CompileEnv.PreprocessorDefinitions.Add("PLATFORM_UNIX");
options.CompileEnv.PreprocessorDefinitions.Add("__EMSCRIPTEN__");
options.CompileEnv.EnableExceptions = false;
options.CompileEnv.CpuArchitecture = CpuArchitecture.None; // TODO: try SIMD support in Emscripten
options.CompileEnv.CpuArchitecture = CpuArchitecture.SSE4_2;
}
private void AddSharedArgs(List<string> args, BuildOptions options, bool debugInformation, bool optimization)
@@ -129,6 +129,27 @@ namespace Flax.Build.Platforms
else
args.Add("-fno-exceptions");
if (options.CompileEnv.CpuArchitecture != CpuArchitecture.None)
args.Add("-msimd128 -mno-nontrapping-fptoint");
switch (options.CompileEnv.CpuArchitecture)
{
case CpuArchitecture.AVX:
args.Add("-mavx");
break;
case CpuArchitecture.AVX2:
args.Add("-mavx2");
break;
case CpuArchitecture.SSE2:
args.Add("-msse2");
break;
case CpuArchitecture.SSE4_2:
args.Add("-msse4.2");
break;
case CpuArchitecture.NEON:
args.Add("-mfpu=neon");
break;
}
if (options.LinkEnv.LinkTimeCodeGeneration)
args.Add("-flto");