Skip to content

Commit 8eadc3d

Browse files
committed
FastNoise2: Add simd support for arm
1 parent c4094df commit 8eadc3d

File tree

2 files changed

+55
-76
lines changed

2 files changed

+55
-76
lines changed

SCsub

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# This is the entry point for SCons to build this engine as a module.
32
# It has to be integrated to Godot's codebase, so it cannot be run on its own, see `README` for more information.
43
# To build as an extension, see `SConstruct`.
@@ -11,82 +10,67 @@ import voxel_version
1110

1211
voxel_version.generate_version_header(True)
1312

14-
# Note, support for FastNoise2 requires C++17, and only works on x86.
13+
# Note, support for FastNoise2 requires C++17.
1514
FAST_NOISE_2_SRC = env["voxel_fast_noise_2"]
16-
if not env["arch"].startswith("x86"):
17-
FAST_NOISE_2_SRC = False
1815

1916
env_voxel = env_modules.Clone()
2017

2118
voxel_files = common.get_sources(env_voxel, env.editor_build)
2219

23-
env_voxel.Append(CPPDEFINES=[
24-
# Tell engine-agnostic code we are using Godot Engine as a module
25-
"ZN_GODOT"
26-
])
20+
env_voxel.Append(
21+
CPPDEFINES=[
22+
# Tell engine-agnostic code we are using Godot Engine as a module
23+
"ZN_GODOT"
24+
]
25+
)
2726

2827
if env["voxel_sqlite"]:
29-
env_sqlite = env_voxel.Clone()
28+
env_sqlite = env_voxel.Clone()
3029

31-
# Turn off warnings, we get some with Clang and with `warnings=extra`
32-
env_sqlite.disable_warnings()
30+
# Turn off warnings, we get some with Clang and with `warnings=extra`
31+
env_sqlite.disable_warnings()
3332

34-
# if not env_sqlite.msvc:
35-
# env_sqlite.Append(CXXFLAGS=["-Wno-discarded-qualifiers"])
33+
# if not env_sqlite.msvc:
34+
# env_sqlite.Append(CXXFLAGS=["-Wno-discarded-qualifiers"])
3635

37-
# TODO Enhancement: the way SQLite is integrated should not be duplicated between Godot and GodotCpp targets.
38-
# Had to do so, because this line below is specific to Godot's build system!
39-
env_sqlite.add_source_files(env.modules_sources, ["thirdparty/sqlite/sqlite3.c"])
36+
# TODO Enhancement: the way SQLite is integrated should not be duplicated between Godot and GodotCpp targets.
37+
# Had to do so, because this line below is specific to Godot's build system!
38+
env_sqlite.add_source_files(env.modules_sources, ["thirdparty/sqlite/sqlite3.c"])
4039

4140
# ----------------------------------------------------------------------------------------------------------------------
4241
# FastNoise 2
4342

4443
if FAST_NOISE_2_SRC:
45-
if not env.msvc:
46-
# TODO Enhancement: workaround for https://github.com/Auburn/FastNoise2/issues/80
47-
# FastNoise2 is using MSVC-specific compiler directives.
48-
# Done before calling FastNoise2 SConscript, as FastNoise2 also includes the headers
49-
env_voxel.Append(CXXFLAGS=["-Wno-unknown-pragmas"])
50-
51-
# Build from source. Should be the simplest, but requires C++17
52-
SConscript("thirdparty/fast_noise_2/SConscript", exports = ["env", "env_voxel"])
53-
54-
env_voxel.Append(CPPPATH=["thirdparty/fast_noise_2/include"])
55-
56-
voxel_files += [
57-
"util/noise/fast_noise_2.cpp"
58-
]
59-
60-
if env.editor_build:
61-
voxel_files += [
62-
"editor/fast_noise_2/*.cpp"
63-
]
64-
65-
if env["voxel_tests"]:
66-
voxel_files += ["tests/fast_noise_2/*.cpp"]
44+
if not env.msvc:
45+
# TODO Enhancement: workaround for https://github.com/Auburn/FastNoise2/issues/80
46+
# FastNoise2 is using MSVC-specific compiler directives.
47+
# Done before calling FastNoise2 SConscript, as FastNoise2 also includes the headers
48+
env_voxel.Append(CXXFLAGS=["-Wno-unknown-pragmas"])
49+
50+
# Build from source. Should be the simplest, but requires C++17
51+
SConscript("thirdparty/fast_noise_2/SConscript", exports=["env", "env_voxel"])
52+
53+
env_voxel.Append(CPPPATH=["thirdparty/fast_noise_2/include"])
54+
55+
voxel_files += ["util/noise/fast_noise_2.cpp"]
56+
57+
if env.editor_build:
58+
env_voxel.add_source_files(env.modules_sources, "editor/fast_noise_2/*.cpp")
59+
60+
if env["voxel_tests"]:
61+
env_voxel.add_source_files(env.modules_sources, "tests/fast_noise_2/*.cpp")
6762

6863
# ----------------------------------------------------------------------------------------------------------------------
6964
# Tracy library
7065

7166
if env["tracy"]:
72-
# This is not a feature of Godot's build system so we have to define a few things ourselves
73-
env.Append(CPPDEFINES="TRACY_ENABLE")
74-
env_voxel.Append(CPPDEFINES="TRACY_ENABLE")
75-
env_voxel.Append(CPPPATH=["#thirdparty/tracy/public"])
76-
voxel_files += [
77-
"#thirdparty/tracy/public/TracyClient.cpp"
78-
]
67+
# This is not a feature of Godot's build system so we have to define a few things ourselves
68+
env.Append(CPPDEFINES="TRACY_ENABLE")
69+
env_voxel.Append(CPPDEFINES="TRACY_ENABLE")
70+
env_voxel.Append(CPPPATH=["#thirdparty/tracy/public"])
71+
voxel_files += ["#thirdparty/tracy/public/TracyClient.cpp"]
7972

80-
# ----------------------------------------------------------------------------------------------------------------------
8173

82-
for f in voxel_files:
83-
env_voxel.add_source_files(env.modules_sources, f)
74+
env_voxel.add_source_files(env.modules_sources, voxel_files)
8475

8576
# TODO Feature: check webassembly builds (`env["platform"] == "javascript"`)
86-
87-
# Doesn't work, since the rest of Godot doesn't use this, linking fails.
88-
# No safe STL boundary checks for you.
89-
#if env["target"] == "debug":
90-
# if env.msvc:
91-
# # Enable STL bound checks, Godot's master environment doesn't do it
92-
# env_voxel.Append(CXXFLAGS=["/D_DEBUG"])

thirdparty/fast_noise_2/SConscript

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn2_sources_arm = [
5252
env_fn2 = env_voxel.Clone()
5353
# In case we need common options for FastNoise2 we can add them here
5454

55-
# Note: when compiling with clang-cl on Windows, `env.msvc` is still True because clang-cl behaves like an MSVC
55+
# Note: when compiling with clang-cl on Windows, `env.msvc` is still True because clang-cl behaves like an MSVC
5656
# frontend. However, Clang is more picky and generates more warnings, so we use Clang options anyways.
5757
if env.msvc and not env["use_llvm"]:
5858
# Avoid a compiler bug in VS 2022 (doesn't occur in VS 2019).
@@ -68,7 +68,7 @@ else:
6868
# We compile with `-Wall`, but FastNoise2 does not, so a lot of pedantic things show up treated as errors
6969
env_fn2.Append(CXXFLAGS=["-Wno-parentheses"])
7070
# This one might be legitimate in SmartNode.cpp but we assume the devs got the `memset` right
71-
env_fn2.Append(CXXFLAGS=["-Wno-class-memaccess"])
71+
env_fn2.Append(CXXFLAGS=["-Wno-class-memaccess"])
7272
# Since may 2023 Godot build scripts warn heavily against variable name shadowing.
7373
# Example: Metadata.h NameDesc constructor, prevents from building because treated as error.
7474
# TODO This doesn't work because for some reason `-Wshadow` FOLLOWS this parameter in the command line, as if Godot
@@ -87,9 +87,8 @@ env_fn2_sse42 = env_fn2.Clone()
8787
env_fn2_avx2 = env_fn2.Clone()
8888
env_fn2_avx512 = env_fn2.Clone()
8989
env_fn2_arm = env_fn2.Clone()
90-
# TODO NEON?
9190

92-
# Note: when compiling with clang-cl on Windows, `env.msvc` is still True because clang-cl behaves like an MSVC
91+
# Note: when compiling with clang-cl on Windows, `env.msvc` is still True because clang-cl behaves like an MSVC
9392
# frontend. However, Clang is more picky about architecture, so we have to specify each option, which MSVC doesnt have.
9493
# Since Clang still allows to pass `-`style arguments, might as well use the non-MSVC path...
9594
if env.msvc and not env["use_llvm"]:
@@ -130,20 +129,16 @@ else: # Clang, GCC, AppleClang, Clang-Cl
130129

131130
env_fn2.add_source_files(env.modules_sources, fn2_sources_common)
132131
env_fn2_scalar.add_source_files(env.modules_sources, fn2_sources_scalar)
133-
env_fn2_sse2.add_source_files(env.modules_sources, fn2_sources_sse2)
134-
env_fn2_sse3.add_source_files(env.modules_sources, fn2_sources_sse3)
135-
env_fn2_ssse3.add_source_files(env.modules_sources, fn2_sources_ssse3)
136-
env_fn2_sse41.add_source_files(env.modules_sources, fn2_sources_sse41)
137-
env_fn2_sse42.add_source_files(env.modules_sources, fn2_sources_sse42)
138-
139-
# if env["platform"] == "android":
140-
# # Both Android and IOS have ARM chips, but only android build tools have necessary headers
141-
# env_fn2_arm.add_source_files(env.modules_sources, fn2_sources_arm)
142-
143-
# elif env["platform"] in ["windows", "linuxbsd", "osx"]:
144-
# # AVX is supported on desktop only
145-
# env_fn2_avx2.add_source_files(env.modules_sources, fn2_sources_avx2)
146-
# env_fn2_avx512.add_source_files(env.modules_sources, fn2_sources_avx512)
147-
148-
env_fn2_avx2.add_source_files(env.modules_sources, fn2_sources_avx2)
149-
env_fn2_avx512.add_source_files(env.modules_sources, fn2_sources_avx512)
132+
133+
if env["arch"].startswith("x86"):
134+
env_fn2_sse2.add_source_files(env.modules_sources, fn2_sources_sse2)
135+
env_fn2_sse3.add_source_files(env.modules_sources, fn2_sources_sse3)
136+
env_fn2_ssse3.add_source_files(env.modules_sources, fn2_sources_ssse3)
137+
env_fn2_sse41.add_source_files(env.modules_sources, fn2_sources_sse41)
138+
env_fn2_sse42.add_source_files(env.modules_sources, fn2_sources_sse42)
139+
env_fn2_avx2.add_source_files(env.modules_sources, fn2_sources_avx2)
140+
env_fn2_avx512.add_source_files(env.modules_sources, fn2_sources_avx512)
141+
142+
elif env["arch"].startswith("arm"):
143+
# Both Android and IOS have ARM chips, but only android build tools have necessary headers
144+
env_fn2_arm.add_source_files(env.modules_sources, fn2_sources_arm)

0 commit comments

Comments
 (0)