Merge pull request #48637 from akien-mga/embree-raycaster-check-sse2

This commit is contained in:
Rémi Verschelde 2021-05-11 15:12:21 +02:00 committed by GitHub
commit 9fdcab77ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -1,10 +1,16 @@
def can_build(env, platform): def can_build(env, platform):
# Depends on Embree library, which supports only x86_64 (originally)
# and aarch64 (thanks to the embree-aarch64 fork).
if platform == "android": if platform == "android":
return env["android_arch"] in ["arm64v8", "x86", "x86_64"] return env["android_arch"] in ["arm64v8", "x86_64"]
if platform == "javascript": if platform == "javascript":
return False # No SIMD support yet return False # No SIMD support yet
if env["bits"] == "32":
return False
return True return True

View File

@ -32,7 +32,9 @@
#include "lightmap_raycaster.h" #include "lightmap_raycaster.h"
#ifdef __SSE2__
#include <pmmintrin.h> #include <pmmintrin.h>
#endif
LightmapRaycaster *LightmapRaycasterEmbree::create_embree_raycaster() { LightmapRaycaster *LightmapRaycasterEmbree::create_embree_raycaster() {
return memnew(LightmapRaycasterEmbree); return memnew(LightmapRaycasterEmbree);
@ -171,8 +173,10 @@ void embree_error_handler(void *p_user_data, RTCError p_code, const char *p_str)
} }
LightmapRaycasterEmbree::LightmapRaycasterEmbree() { LightmapRaycasterEmbree::LightmapRaycasterEmbree() {
#ifdef __SSE2__
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
#endif
embree_device = rtcNewDevice(nullptr); embree_device = rtcNewDevice(nullptr);
rtcSetDeviceErrorFunction(embree_device, &embree_error_handler, nullptr); rtcSetDeviceErrorFunction(embree_device, &embree_error_handler, nullptr);
@ -180,8 +184,10 @@ LightmapRaycasterEmbree::LightmapRaycasterEmbree() {
} }
LightmapRaycasterEmbree::~LightmapRaycasterEmbree() { LightmapRaycasterEmbree::~LightmapRaycasterEmbree() {
#ifdef __SSE2__
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF); _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF);
#endif
if (embree_scene != nullptr) { if (embree_scene != nullptr) {
rtcReleaseScene(embree_scene); rtcReleaseScene(embree_scene);