Skip to content

Commit

Permalink
embree: Enable raycast module build for Web and Windows x86_32
Browse files Browse the repository at this point in the history
Embree initially only supported x86_64, then got arm64 support added.
Now it seems to be possible to build it with Emscripten (wasm32) and
on x86_32 Windows.
  • Loading branch information
akien-mga authored and rohanrhu committed Dec 28, 2022
1 parent 6750713 commit 60a843c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions modules/raycast/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if env["builtin_embree"]:
env_raycast.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.

if not env.msvc:
if env["arch"] == "x86_64":
if env["arch"] in ["x86_64", "x86_32"]:
env_raycast.Append(CPPFLAGS=["-msse2", "-mxsave"])

if env["platform"] == "windows":
Expand All @@ -87,10 +87,13 @@ if env["builtin_embree"]:
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)

if env["arch"] == "arm64" or env.msvc:
if env["arch"] != "x86_64" or env.msvc:
# Embree needs those, it will automatically use SSE2NEON in ARM
env_thirdparty.Append(CPPDEFINES=["__SSE2__", "__SSE__"])

if env["platform"] == "web":
env_thirdparty.Append(CPPFLAGS=["-msimd128"])

if not env.msvc:
env_thirdparty.Append(
CPPFLAGS=[
Expand Down
14 changes: 9 additions & 5 deletions modules/raycast/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
def can_build(env, platform):
# Depends on Embree library, which only supports x86_64 and arm64.
if platform == "windows":
return env["arch"] == "x86_64" # TODO build for Windows on ARM

return env["arch"] in ["x86_64", "arm64"]
# Supported architectures depend on the Embree library.
# No ARM32 support planned.
if env["arch"] == "arm32":
return False
# x86_32 only seems supported on Windows for now.
if env["arch"] == "x86_32" and platform != "windows":
return False
# The rest works, even wasm32!
return True


def configure(env):
Expand Down

0 comments on commit 60a843c

Please sign in to comment.