Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2.4] Fix lightmapper build on llvm-mingw on Linux #45285

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/lightmapper_cpu/lightmapper_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ _ALWAYS_INLINE_ float uniform_rand() {
state ^= state << 13;
state ^= state >> 17;
state ^= state << 5;
return float(state) / UINT32_MAX;
/* implicit conversion from 'unsigned int' to 'float' changes value from 4294967295 to 4294967296 */
return float(state) / float(UINT32_MAX);
}

void LightmapperCPU::_compute_indirect_light(uint32_t p_idx, void *r_lightmap) {
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/lightmapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#if !defined(__aligned)

#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(__CYGWIN__)
#if defined(_WIN32) && defined(_MSC_VER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh I'm pretty sure I had commented on the original PR that this was a very convoluted way to check _MSC_VER... looks like it was missed.

#define __aligned(...) __declspec(align(__VA_ARGS__))
#else
#define __aligned(...) __attribute__((aligned(__VA_ARGS__)))
Expand Down
6 changes: 3 additions & 3 deletions thirdparty/embree/common/math/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <xmmintrin.h>
#include <immintrin.h>

#if defined(__WIN32__) && !defined(__MINGW32__)
#if (__MSV_VER <= 1700)
#if defined(__WIN32__)
#if defined(_MSC_VER) && (_MSC_VER <= 1700)
namespace std
{
__forceinline bool isinf ( const float x ) { return _finite(x) == 0; }
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace embree
return _mm_cvtss_f32(c);
}

#if defined(__WIN32__) && (__MSC_VER <= 1700)
#if defined(__WIN32__) && defined(_MSC_VER) && (_MSC_VER <= 1700)
__forceinline float nextafter(float x, float y) { if ((x<y) == (x>0)) return x*(1.1f+float(ulp)); else return x*(0.9f-float(ulp)); }
__forceinline double nextafter(double x, double y) { return _nextafter(x, y); }
__forceinline int roundf(float f) { return (int)(f + 0.5f); }
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/embree/include/embree3/rtcore_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef int ssize_t;
#endif
#endif

#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
# define RTC_ALIGN(...) __declspec(align(__VA_ARGS__))
#else
# define RTC_ALIGN(...) __attribute__((aligned(__VA_ARGS__)))
Expand Down
31 changes: 26 additions & 5 deletions thirdparty/embree/pathces/godot-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ diff --git a/common/math/math.h b/common/math/math.h
index 5af0691a2..1982c27c1 100644
--- a/common/math/math.h
+++ b/common/math/math.h
@@ -12,7 +12,7 @@
#include <xmmintrin.h>
@@ -13,7 +13,7 @@
#include <immintrin.h>

-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__MINGW32__)
#if (__MSV_VER <= 1700)
#if defined(__WIN32__)
-#if (__MSV_VER <= 1700)
+#if defined(_MSC_VER) && (_MSC_VER <= 1700)
namespace std
{
__forceinline bool isinf ( const float x ) { return _finite(x) == 0; }
@@ -86,7 +86,7 @@
return _mm_cvtss_f32(c);
}

-#if defined(__WIN32__) && (__MSC_VER <= 1700)
+#if defined(__WIN32__) && defined(_MSC_VER) && (_MSC_VER <= 1700)
__forceinline float nextafter(float x, float y) { if ((x<y) == (x>0)) return x*(1.1f+float(ulp)); else return x*(0.9f-float(ulp)); }
__forceinline double nextafter(double x, double y) { return _nextafter(x, y); }
__forceinline int roundf(float f) { return (int)(f + 0.5f); }
diff --git a/common/sys/intrinsics.h b/common/sys/intrinsics.h
index 3f0619cac..58f5c3bb4 100644
--- a/common/sys/intrinsics.h
Expand Down Expand Up @@ -190,3 +199,15 @@ index 98dba2687..369e5edf0 100644
#endif

// We need to define these to avoid implicit linkage against
diff a/include/embree3/rtcore_common.h b/include/embree3/rtcore_common.h
--- a/include/embree3/rtcore_common.h
+++ b/include/embree3/rtcore_common.h
@@ -19,7 +19,7 @@
#endif
#endif

-#ifdef _WIN32
+#if defined(_WIN32) && defined(_MSC_VER)
# define RTC_ALIGN(...) __declspec(align(__VA_ARGS__))
#else
# define RTC_ALIGN(...) __attribute__((aligned(__VA_ARGS__)))