Skip to content

Commit 52bd020

Browse files
authored
Merge branch 'master' into sw/fuzzing_fixes
2 parents e7c4340 + c9e873d commit 52bd020

13 files changed

Lines changed: 366 additions & 115 deletions

File tree

‎common/simd/vboolf4_sse2.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ namespace embree
2626
typedef vfloat4 Float;
2727

2828
enum { size = 4 }; // number of SIMD elements
29+
// The __m128_wrapper indirection is only required to work around an
30+
// MSVC/ARM64 overload-ambiguity issue (__m128 and __m128i both alias
31+
// __n128 there). On all other platforms we keep the plain __m128 union
32+
// member, which is what x86 and non-MSVC ARM64 builds have always used
33+
// (see simd_wrapper_types.h); wrapping it unconditionally previously
34+
// caused miscompiles/segfaults with some optimizing compilers (e.g. ICX).
35+
#if defined(_MSC_VER) && defined(_M_ARM64)
2936
union { __m128_wrapper v; int i[4]; }; // data
37+
#else
38+
union { __m128 v; int i[4]; }; // data
39+
#endif
3040

3141
////////////////////////////////////////////////////////////////////////////////
3242
/// Constructors, Assignment & Cast Operators
@@ -37,11 +47,22 @@ namespace embree
3747
__forceinline vboolf4& operator =(const vboolf4& other) { v = other.v; return *this; }
3848

3949
__forceinline vboolf(__m128 input) : v(input) {}
50+
#if defined(_MSC_VER) && defined(_M_ARM64)
4051
__forceinline operator const __m128&() const { return v.data; }
4152
#if !defined(__EMSCRIPTEN__)
4253
__forceinline const __m128i m128i() const { return _mm_castps_si128(v.data); }
4354
__forceinline const __m128d m128d() const { return _mm_castps_pd(v.data); }
4455
#endif
56+
#else
57+
__forceinline operator const __m128&() const { return v; }
58+
#if !defined(__EMSCRIPTEN__)
59+
__forceinline operator const __m128i() const { return _mm_castps_si128(v); }
60+
__forceinline operator const __m128d() const { return _mm_castps_pd(v); }
61+
#endif
62+
/* kept for source compatibility with code that calls .m128i()/.m128d() explicitly */
63+
__forceinline const __m128i m128i() const { return _mm_castps_si128(v); }
64+
__forceinline const __m128d m128d() const { return _mm_castps_pd(v); }
65+
#endif
4566

4667
__forceinline vboolf(bool a)
4768
: v(mm_lookupmask_ps[(size_t(a) << 3) | (size_t(a) << 2) | (size_t(a) << 1) | size_t(a)]) {}

‎common/simd/vfloat4_sse2.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ namespace embree
2626
typedef vfloat4 Float;
2727

2828
enum { size = 4 }; // number of SIMD elements
29+
// See vboolf4_sse2.h for why the wrapper is restricted to MSVC/ARM64.
30+
#if defined(_MSC_VER) && defined(_M_ARM64)
2931
union { __m128_wrapper v; float f[4]; int i[4]; }; // data
32+
#else
33+
union { __m128 v; float f[4]; int i[4]; }; // data
34+
#endif
3035

3136
////////////////////////////////////////////////////////////////////////////////
3237
/// Constructors, Assignment & Cast Operators
@@ -39,8 +44,13 @@ namespace embree
3944
__forceinline vfloat4& operator =(const vfloat4& other) { v = other.v; return *this; }
4045

4146
__forceinline vfloat(__m128 a) : v(a) {}
47+
#if defined(_MSC_VER) && defined(_M_ARM64)
4248
__forceinline operator const __m128&() const { return v.data; }
4349
__forceinline operator __m128&() { return v.data; }
50+
#else
51+
__forceinline operator const __m128&() const { return v; }
52+
__forceinline operator __m128&() { return v; }
53+
#endif
4454

4555
__forceinline vfloat(float a) : v(_mm_set1_ps(a)) {}
4656
__forceinline vfloat(float a, float b, float c, float d) : v(_mm_set_ps(d, c, b, a)) {}

‎common/simd/vint4_sse2.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ namespace embree
2727
typedef vfloat4 Float;
2828

2929
enum { size = 4 }; // number of SIMD elements
30+
// See vboolf4_sse2.h for why the wrapper is restricted to MSVC/ARM64.
31+
#if defined(_MSC_VER) && defined(_M_ARM64)
3032
union { __m128i_wrapper v; int i[4]; }; // data
33+
#else
34+
union { __m128i v; int i[4]; }; // data
35+
#endif
3136

3237
////////////////////////////////////////////////////////////////////////////////
3338
/// Constructors, Assignment & Cast Operators
@@ -38,8 +43,13 @@ namespace embree
3843
__forceinline vint4& operator =(const vint4& a) { v = a.v; return *this; }
3944

4045
__forceinline vint(__m128i a) : v(a) {}
46+
#if defined(_MSC_VER) && defined(_M_ARM64)
4147
__forceinline operator const __m128i&() const { return v.data; }
4248
__forceinline operator __m128i&() { return v.data; }
49+
#else
50+
__forceinline operator const __m128i&() const { return v; }
51+
__forceinline operator __m128i&() { return v; }
52+
#endif
4353

4454
__forceinline vint(int a) : v(_mm_set1_epi32(a)) {}
4555
__forceinline vint(int a, int b, int c, int d) : v(_mm_set_epi32(d, c, b, a)) {}

‎common/simd/vuint4_sse2.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ namespace embree
2727
typedef vfloat4 Float;
2828

2929
enum { size = 4 }; // number of SIMD elements
30+
// See vboolf4_sse2.h for why the wrapper is restricted to MSVC/ARM64.
31+
#if defined(_MSC_VER) && defined(_M_ARM64)
3032
union { __m128i_wrapper v; unsigned int i[4]; }; // data
33+
#else
34+
union { __m128i v; unsigned int i[4]; }; // data
35+
#endif
3136

3237
////////////////////////////////////////////////////////////////////////////////
3338
/// Constructors, Assignment & Cast Operators
@@ -38,8 +43,13 @@ namespace embree
3843
__forceinline vuint4& operator =(const vuint4& a) { v = a.v; return *this; }
3944

4045
__forceinline vuint(const __m128i a) : v(a) {}
46+
#if defined(_MSC_VER) && defined(_M_ARM64)
4147
__forceinline operator const __m128i&() const { return v.data; }
4248
__forceinline operator __m128i&() { return v.data; }
49+
#else
50+
__forceinline operator const __m128i&() const { return v; }
51+
__forceinline operator __m128i&() { return v; }
52+
#endif
4353

4454

4555
__forceinline vuint(unsigned int a) : v(_mm_set1_epi32(a)) {}

‎common/sys/sysinfo.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,12 @@ namespace embree
765765
cpu_set_t set;
766766
if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)
767767
nThreads = CPU_COUNT(&set);
768+
else
769+
nThreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
768770
#endif
769-
770-
assert(nThreads);
771+
772+
if (nThreads < 1)
773+
nThreads = 1;
771774
return nThreads;
772775
}
773776

‎doc/src/api-ref.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360
\pagebreak
361361

362362
## rtcGetGeometryUserDataFromTraversable
363-
``` {include=src/api/rtcGetGeometryUserDataFromScenTraversable
363+
``` {include=src/api/rtcGetGeometryUserDataFromTraversable.md}
364364
```
365365
\pagebreak
366366

‎kernels/common/device.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ namespace embree
7878
case CPU::XEON_PHI_KNIGHTS_MILL : frequency_level = FREQUENCY_SIMD512; break;
7979
case CPU::XEON_PHI_KNIGHTS_LANDING: frequency_level = FREQUENCY_SIMD512; break;
8080
case CPU::ARM: frequency_level = FREQUENCY_SIMD256; break;
81+
default:
82+
frequency_level = FREQUENCY_SIMD256; break;
8183
}
8284

8385
/* initialize global state */

‎kernels/common/instance_stack.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ RTC_FORCEINLINE bool push(RTCPointQueryContext* context,
8484
{
8585
assert(context);
8686
const size_t stackSize = context->instStackSize;
87-
assert(stackSize < RTC_MAX_INSTANCE_LEVEL_COUNT);
87+
88+
/* We assert here because instances are silently dropped when the stack is full.
89+
This might be quite hard to find in production. */
90+
const bool spaceAvailable = stackSize < RTC_MAX_INSTANCE_LEVEL_COUNT;
91+
assert(spaceAvailable);
92+
if (unlikely(!spaceAvailable))
93+
return false;
94+
8895
context->instID[stackSize] = instanceId;
8996
#if defined(RTC_GEOMETRY_INSTANCE_ARRAY)
9097
context->instPrimID[stackSize] = instancePrimId;

‎kernels/common/scene_subdiv_mesh.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ namespace embree
531531
{
532532
for (size_t f=r.begin(); f<r.end(); f++)
533533
{
534+
/* Skip faces with zero vertices. */
535+
if (mesh->faceVertices[f] == 0) {
536+
continue;
537+
}
538+
534539
HalfEdge* edge = &halfEdges[mesh->faceStartEdge[f]];
535540

536541
/* for vertex topology we also test if vertices are valid */

‎kernels/sycl/rthwif_embree_builder.cpp‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,32 +172,10 @@ namespace embree
172172
return pvc;
173173
}
174174

175-
static bool hasDriverExtension(ze_driver_handle_t hDriver, const char* extensionName)
176-
{
177-
uint32_t count = 0;
178-
ze_result_t result = ZeWrapper::zeDriverGetExtensionProperties(hDriver, &count, nullptr);
179-
if (result != ZE_RESULT_SUCCESS)
180-
return false;
181-
182-
std::vector<ze_driver_extension_properties_t> extensions(count);
183-
result = ZeWrapper::zeDriverGetExtensionProperties(hDriver, &count, extensions.data());
184-
if (result != ZE_RESULT_SUCCESS)
185-
return false;
186-
187-
for (uint32_t i = 0; i < count; i++)
188-
{
189-
if (strncmp(extensionName, extensions[i].name, sizeof(extensions[i].name)) == 0)
190-
return true;
191-
}
192-
return false;
193-
}
194-
195175
void* rthwifAllocAccelBuffer(Device* embree_device, size_t bytes, sycl::device device, sycl::context context, sycl::usm::alloc alloc_type)
196176
{
197177
ze_context_handle_t hContext = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(context);
198178
ze_device_handle_t hDevice = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(device);
199-
sycl::platform platform = device.get_platform();
200-
ze_driver_handle_t hDriver = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(platform);
201179

202180
ze_rtas_device_ext_properties_t rtasProp = { ZE_STRUCTURE_TYPE_RTAS_DEVICE_EXT_PROPERTIES };
203181
ze_device_properties_t devProp = { ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES, &rtasProp };

0 commit comments

Comments
 (0)