From b63a0c501b5ef5d8af808ae5e84171803e6a47e0 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 9 Jun 2026 08:31:55 +0200 Subject: [PATCH 01/19] Fix -Wextra warnings - Add explicit copy constructors to BBox, LBBox, CubicBezierCurve - Add explicit copy assignment operator to range - Fix base class initialization in Atomic copy constructor - Suppress -Wunused-parameter, -Wcast-function-type, -Wdeprecated-copy --- common/cmake/gnu.cmake | 6 +++++- common/math/bbox.h | 1 + common/math/lbbox.h | 2 ++ common/math/range.h | 2 ++ common/sys/atomic.h | 4 +--- kernels/subdiv/bezier_curve.h | 4 +++- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/common/cmake/gnu.cmake b/common/cmake/gnu.cmake index d43a1b534c..b4de72da85 100644 --- a/common/cmake/gnu.cmake +++ b/common/cmake/gnu.cmake @@ -33,8 +33,12 @@ IF (EMBREE_ARM) ENDIF (EMBREE_ARM) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") # enables extra warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") # disables clearing an object of type ‘XXX’ with no trivial copy-assignment; use assignment or value-initialization instead +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") # disables clearing an object of type +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # disables warnings for unused function parameters +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") # disables warnings for intentional function pointer casts +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") # disables deprecated copy warnings from explicit operator= ‘XXX’ with no trivial copy-assignment; use assignment or value-initialization instead # these prevent compile to optimize away security checks SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-overflow") # assume that signed overflow occurs diff --git a/common/math/bbox.h b/common/math/bbox.h index 651b29a8fe..8af07e213a 100644 --- a/common/math/bbox.h +++ b/common/math/bbox.h @@ -27,6 +27,7 @@ namespace embree __forceinline BBox ( ) { } template __forceinline BBox ( const BBox& other ) : lower(other.lower), upper(other.upper) {} + BBox ( const BBox& other ) = default; __forceinline BBox& operator=( const BBox& other ) { lower = other.lower; upper = other.upper; return *this; } __forceinline BBox ( const T& v ) : lower(v), upper(v) {} diff --git a/common/math/lbbox.h b/common/math/lbbox.h index 7619199780..a9d4cb3c78 100644 --- a/common/math/lbbox.h +++ b/common/math/lbbox.h @@ -27,6 +27,8 @@ namespace embree __forceinline LBBox ( const LBBox& other ) : bounds0(other.bounds0), bounds1(other.bounds1) {} + LBBox ( const LBBox& other ) = default; + __forceinline LBBox& operator= ( const LBBox& other ) { bounds0 = other.bounds0; bounds1 = other.bounds1; return *this; } diff --git a/common/math/range.h b/common/math/range.h index f397615ea2..1290fa4c15 100644 --- a/common/math/range.h +++ b/common/math/range.h @@ -22,6 +22,8 @@ namespace embree __forceinline range(const range& other) : _begin(other._begin), _end(other._end) {} + __forceinline range& operator=(const range& other) = default; + template __forceinline range(const range& other) : _begin(Ty(other._begin)), _end(Ty(other._end)) {} diff --git a/common/sys/atomic.h b/common/sys/atomic.h index cf9909aad9..4e6b549ebc 100644 --- a/common/sys/atomic.h +++ b/common/sys/atomic.h @@ -25,9 +25,7 @@ namespace embree atomic (const T& a) : std::atomic(a) {} - atomic (const atomic& a) { - this->store(a.load()); - } + atomic (const atomic& a) : std::atomic(a.load()) {} atomic& operator=(const atomic& other) { this->store(other.load()); diff --git a/kernels/subdiv/bezier_curve.h b/kernels/subdiv/bezier_curve.h index 5e3b5c83b3..46f60c5acf 100644 --- a/kernels/subdiv/bezier_curve.h +++ b/kernels/subdiv/bezier_curve.h @@ -154,7 +154,9 @@ namespace embree template __forceinline CubicBezierCurve (const CubicBezierCurve& other) : v0(other.v0), v1(other.v1), v2(other.v2), v3(other.v3) {} - + + CubicBezierCurve (const CubicBezierCurve& other) = default; + __forceinline CubicBezierCurve& operator= (const CubicBezierCurve& other) { v0 = other.v0; v1 = other.v1; v2 = other.v2; v3 = other.v3; return *this; } From bfdcf9d8766095b8b37718989e9941d4ed7aae54 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 9 Jun 2026 09:18:33 +0200 Subject: [PATCH 02/19] Add -Wdouble-promotion, -Wextra-semi, -Wundefined-inline fixes; update clang.cmake --- common/algorithms/parallel_partition.h | 2 +- common/cmake/clang.cmake | 14 ++++++++++++++ common/cmake/gnu.cmake | 17 +++++++++++++++++ common/math/color.h | 4 ++-- common/math/emath.h | 2 +- common/math/interval.h | 12 ++++++------ common/math/vec2.h | 2 +- common/math/vec2fa.h | 2 +- common/math/vec3.h | 2 +- common/math/vec3ba.h | 2 +- common/math/vec3fa.h | 4 ++-- common/math/vec3ia.h | 2 +- common/math/vec4.h | 2 +- common/simd/vboold4_avx.h | 2 +- common/simd/vboolf8_avx.h | 2 +- common/simd/vint8_avx.h | 2 +- common/simd/vuint8_avx.h | 2 +- common/sys/regression.cpp | 2 +- common/sys/sysinfo.cpp | 6 +++--- common/sys/thread.cpp | 2 +- kernels/builders/bvh_builder_hair.h | 2 +- kernels/builders/bvh_builder_morton.h | 4 ++-- kernels/builders/bvh_builder_msmblur.h | 2 +- kernels/builders/bvh_builder_msmblur_hair.h | 2 +- kernels/bvh/bvh.h | 2 +- kernels/bvh/bvh_builder_sah.cpp | 8 ++++---- kernels/bvh/bvh_builder_sah_mb.cpp | 4 ++-- kernels/bvh/bvh_builder_twolevel.cpp | 6 +++--- kernels/bvh/bvh_node_qaabb.h | 2 +- kernels/bvh/node_intersector1.h | 4 ++-- kernels/common/accel.h | 4 ++-- kernels/common/alloc.h | 4 ++-- kernels/common/device.h | 2 +- kernels/common/geometry.h | 2 +- kernels/common/isa.h | 4 ++-- kernels/common/scene_points.h | 2 +- kernels/common/scene_subdiv_mesh.h | 2 +- kernels/common/state.cpp | 2 +- kernels/geometry/curveNi_mb_intersector.h | 4 ++-- kernels/subdiv/catmullclark_patch.h | 12 ++++++------ 40 files changed, 95 insertions(+), 64 deletions(-) diff --git a/common/algorithms/parallel_partition.h b/common/algorithms/parallel_partition.h index 53d4d6f0db..8cf101ea32 100644 --- a/common/algorithms/parallel_partition.h +++ b/common/algorithms/parallel_partition.h @@ -51,7 +51,7 @@ namespace embree template class __aligned(64) parallel_partition_task { - ALIGNED_CLASS_(64); + ALIGNED_CLASS_(64) private: static const size_t MAX_TASKS = 64; diff --git a/common/cmake/clang.cmake b/common/cmake/clang.cmake index 2666d1be8b..2cb01ca2f3 100644 --- a/common/cmake/clang.cmake +++ b/common/cmake/clang.cmake @@ -88,7 +88,21 @@ ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") # enables extra warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") # enables pedantic warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # disables warnings for unused function parameters + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") # disables warnings for intentional function pointer casts + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") # disables deprecated copy warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wundef") # warn about undefined preprocessor identifiers + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") # warn about shadowed variables + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-equal") # warn about floating point equality checks + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-align") # disable: intentional aligned loads in SIMD code + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal") # disable: intentional exact-zero checks in normalize_safe + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow") # disable: pervasive in vector class constructors + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types") # disable: anonymous types in unions for SIMD + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # disable: int/size_t comparisons in template code + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") # treat all warnings as errors SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char") # treat char as signed on all processors, including ARM IF (NOT APPLE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") # enables support for more secure position independent execution diff --git a/common/cmake/gnu.cmake b/common/cmake/gnu.cmake index b4de72da85..b467f05284 100644 --- a/common/cmake/gnu.cmake +++ b/common/cmake/gnu.cmake @@ -34,11 +34,28 @@ ENDIF (EMBREE_ARM) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") # enables extra warnings +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") # enables pedantic warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") # disables clearing an object of type SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # disables warnings for unused function parameters SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") # disables warnings for intentional function pointer casts SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") # disables deprecated copy warnings from explicit operator= ‘XXX’ with no trivial copy-assignment; use assignment or value-initialization instead +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wundef") # warn about undefined preprocessor identifiers +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnull-dereference") # warn about potential NULL dereferences +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wduplicated-cond") # warn about duplicated conditions in if/else +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-duplicated-branches") # disable: intentional identical branch values (e.g. PATCH_MAX_EVAL_DEPTH_*) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op") # warn about logical operations with constant operands +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrestrict") # warn about overlapping memcpy arguments +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshift-overflow=2") # warn about undefined shift behavior +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Walloc-size-larger-than=9223372036854775807") # warn about allocation exceeding max object size +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstringop-overflow") # warn about buffer overflow in string operations +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Warith-conversion") # warn about implicit arithmetic conversions +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-align") # disable: intentional aligned loads in SIMD code +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-declarations") # disable: intentional factory pattern without declarations +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow") # disable: pervasive in vector class constructors +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal") # disable: intentional exact-zero checks in normalize_safe +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-decls") # warn about redundant declarations +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") # these prevent compile to optimize away security checks SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-overflow") # assume that signed overflow occurs diff --git a/common/math/color.h b/common/math/color.h index 8b28ff9447..52dbe2ad57 100644 --- a/common/math/color.h +++ b/common/math/color.h @@ -23,7 +23,7 @@ namespace embree { union { __m128 m128; - struct { float r,g,b,a; }; + __extension__ struct { float r,g,b,a; }; }; //////////////////////////////////////////////////////////////////////////////// @@ -91,7 +91,7 @@ namespace embree { union { __m128 m128; - struct { float r,g,b; }; + __extension__ struct { float r,g,b; }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/common/math/emath.h b/common/math/emath.h index 22a89a7669..1c52bc3c03 100644 --- a/common/math/emath.h +++ b/common/math/emath.h @@ -343,7 +343,7 @@ __forceinline float nmsub ( const float a, const float b, const float c) { retur template<> __forceinline float random() { return rand()/float(RAND_MAX); } template<> __forceinline double random() { return rand()/double(RAND_MAX); } -#if _WIN32 +#ifdef _WIN32 __forceinline double drand48() { return double(rand())/double(RAND_MAX); } diff --git a/common/math/interval.h b/common/math/interval.h index 310add2129..09b3a10a5f 100644 --- a/common/math/interval.h +++ b/common/math/interval.h @@ -132,29 +132,29 @@ inline void swap(float& a, float& b) { float tmp = a; a = b; b = tmp; } inline Interval1f shift(const Interval1f& v, float shift) { return Interval1f(v.lower + shift, v.upper + shift); } -#define TWO_PI (2.0*M_PI) +#define TWO_PI (2.0f*float(M_PI)) inline Interval1f sin(Interval1f interval) { - if (interval.upper-interval.lower >= M_PI) { return Interval1f(-1.0, 1.0); } + if (interval.upper-interval.lower >= float(M_PI)) { return Interval1f(-1.0f, 1.0f); } if (interval.upper > TWO_PI) { interval = shift(interval, -TWO_PI*floor(interval.upper/TWO_PI)); } if (interval.lower < 0) { interval = shift(interval, -TWO_PI*floor(interval.lower/TWO_PI)); } float sinLower = sin(interval.lower); float sinUpper = sin(interval.upper); if (sinLower > sinUpper) swap(sinLower, sinUpper); - if (interval.lower < M_PI / 2.0 && interval.upper > M_PI / 2.0) sinUpper = 1.0; - if (interval.lower < 3.0 * M_PI / 2.0 && interval.upper > 3.0 * M_PI / 2.0) sinLower = -1.0; + if (interval.lower < float(M_PI) / 2.0f && interval.upper > float(M_PI) / 2.0f) sinUpper = 1.0f; + if (interval.lower < 3.0f * float(M_PI) / 2.0f && interval.upper > 3.0f * float(M_PI) / 2.0f) sinLower = -1.0f; return Interval1f(sinLower, sinUpper); } inline Interval1f cos(Interval1f interval) { - if (interval.upper-interval.lower >= M_PI) { return Interval1f(-1.0, 1.0); } + if (interval.upper-interval.lower >= float(M_PI)) { return Interval1f(-1.0f, 1.0f); } if (interval.upper > TWO_PI) { interval = shift(interval, -TWO_PI*floor(interval.upper/TWO_PI)); } if (interval.lower < 0) { interval = shift(interval, -TWO_PI*floor(interval.lower/TWO_PI)); } float cosLower = cos(interval.lower); float cosUpper = cos(interval.upper); if (cosLower > cosUpper) swap(cosLower, cosUpper); - if (interval.lower < M_PI && interval.upper > M_PI) cosLower = -1.0; + if (interval.lower < float(M_PI) && interval.upper > float(M_PI)) cosLower = -1.0f; return Interval1f(cosLower, cosUpper); } #undef TWO_PI diff --git a/common/math/vec2.h b/common/math/vec2.h index 4e641ec249..6b0930b268 100644 --- a/common/math/vec2.h +++ b/common/math/vec2.h @@ -17,7 +17,7 @@ namespace embree { enum { N = 2 }; union { - struct { T x, y; }; + __extension__ struct { T x, y; }; #if !(defined(__WIN32__) && _MSC_VER == 1800) // workaround for older VS 2013 compiler T components[N]; #endif diff --git a/common/math/vec2fa.h b/common/math/vec2fa.h index d57e549e68..67f237bafb 100644 --- a/common/math/vec2fa.h +++ b/common/math/vec2fa.h @@ -26,7 +26,7 @@ namespace embree enum { N = 2 }; union { __m128 m128; - struct { float x,y,az,aw; }; + __extension__ struct { float x,y,az,aw; }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/common/math/vec3.h b/common/math/vec3.h index d5e78befe8..037e6ab13a 100644 --- a/common/math/vec3.h +++ b/common/math/vec3.h @@ -18,7 +18,7 @@ namespace embree enum { N = 3 }; union { - struct { + __extension__ struct { T x, y, z; }; #if !(defined(__WIN32__) && _MSC_VER == 1800) // workaround for older VS 2013 compiler diff --git a/common/math/vec3ba.h b/common/math/vec3ba.h index bf24a2a3b6..1ecc0bb36a 100644 --- a/common/math/vec3ba.h +++ b/common/math/vec3ba.h @@ -24,7 +24,7 @@ namespace embree union { __m128 m128; - struct { int x,y,z; }; + __extension__ struct { int x,y,z; }; }; typedef int Scalar; diff --git a/common/math/vec3fa.h b/common/math/vec3fa.h index 967e75da74..7ce5f93d51 100644 --- a/common/math/vec3fa.h +++ b/common/math/vec3fa.h @@ -26,7 +26,7 @@ namespace embree enum { N = 3 }; union { __m128 m128; - struct { float x,y,z; }; + __extension__ struct { float x,y,z; }; }; //////////////////////////////////////////////////////////////////////////////// @@ -429,7 +429,7 @@ namespace embree enum { N = 3 }; union { __m128 m128; - struct { float x,y,z; union { int a; unsigned u; float w; }; }; + __extension__ struct { float x,y,z; union { int a; unsigned u; float w; }; }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/common/math/vec3ia.h b/common/math/vec3ia.h index 1472fe9135..6d68fc02df 100644 --- a/common/math/vec3ia.h +++ b/common/math/vec3ia.h @@ -24,7 +24,7 @@ namespace embree union { __m128i m128; - struct { int x,y,z; }; + __extension__ struct { int x,y,z; }; }; typedef int Scalar; diff --git a/common/math/vec4.h b/common/math/vec4.h index 5647859257..a4cca14e1d 100644 --- a/common/math/vec4.h +++ b/common/math/vec4.h @@ -16,7 +16,7 @@ namespace embree { enum { N = 4 }; union { - struct { T x, y, z, w; }; + __extension__ struct { T x, y, z, w; }; #if !(defined(__WIN32__) && _MSC_VER == 1800) // workaround for older VS 2013 compiler T components[N]; #endif diff --git a/common/simd/vboold4_avx.h b/common/simd/vboold4_avx.h index 450bd7a4eb..fa32d4df2e 100644 --- a/common/simd/vboold4_avx.h +++ b/common/simd/vboold4_avx.h @@ -24,7 +24,7 @@ namespace embree enum { size = 4 }; // number of SIMD elements union { // data __m256d v; - struct { __m128d vl,vh; }; + __extension__ struct { __m128d vl,vh; }; long long i[4]; }; diff --git a/common/simd/vboolf8_avx.h b/common/simd/vboolf8_avx.h index 18cede19c6..5367b4fbff 100644 --- a/common/simd/vboolf8_avx.h +++ b/common/simd/vboolf8_avx.h @@ -26,7 +26,7 @@ namespace embree enum { size = 8 }; // number of SIMD elements union { // data __m256 v; - struct { __m128 vl,vh; }; + __extension__ struct { __m128 vl,vh; }; int i[8]; }; diff --git a/common/simd/vint8_avx.h b/common/simd/vint8_avx.h index 48f5a9b203..76b1b1ddac 100644 --- a/common/simd/vint8_avx.h +++ b/common/simd/vint8_avx.h @@ -26,7 +26,7 @@ namespace embree enum { size = 8 }; // number of SIMD elements union { // data __m256i v; - struct { __m128i vl,vh; }; + __extension__ struct { __m128i vl,vh; }; int i[8]; }; diff --git a/common/simd/vuint8_avx.h b/common/simd/vuint8_avx.h index cb8b5158c1..6d5d7111f0 100644 --- a/common/simd/vuint8_avx.h +++ b/common/simd/vuint8_avx.h @@ -26,7 +26,7 @@ namespace embree enum { size = 8 }; // number of SIMD elements union { // data __m256i v; - struct { __m128i vl,vh; }; + __extension__ struct { __m128i vl,vh; }; unsigned int i[8]; }; diff --git a/common/sys/regression.cpp b/common/sys/regression.cpp index 45315b1105..2cc5fcefac 100644 --- a/common/sys/regression.cpp +++ b/common/sys/regression.cpp @@ -9,7 +9,7 @@ namespace embree * we cannot have the regression_tests variable as global static * variable due to issues with static variable initialization * order. */ - std::vector& get_regression_tests() + static std::vector& get_regression_tests() { static std::vector regression_tests; return regression_tests; diff --git a/common/sys/sysinfo.cpp b/common/sys/sysinfo.cpp index 5f375cd95c..c564bb11bd 100644 --- a/common/sys/sysinfo.cpp +++ b/common/sys/sysinfo.cpp @@ -256,7 +256,7 @@ namespace embree #endif #if defined(__X86_ASM__) - __noinline int64_t get_xcr0() + static __noinline int64_t get_xcr0() { #if defined (__WIN32__) && !defined (__MINGW32__) && defined(_XCR_XFEATURE_ENABLED_MASK) int64_t xcr0 = 0; // int64_t is workaround for compiler bug under VS2013, Win32 @@ -293,7 +293,7 @@ namespace embree int cpuid_leaf_7[4] = { 0,0,0,0 }; int cpuid_leaf_e1[4] = { 0,0,0,0 }; if (nIds >= 1) __cpuid (cpuid_leaf_1,0x00000001); -#if _WIN32 +#ifdef _WIN32 #if _MSC_VER && (_MSC_FULL_VER < 160040219) #else if (nIds >= 7) __cpuidex(cpuid_leaf_7,0x00000007,0); @@ -434,7 +434,7 @@ namespace embree return "UNKNOWN"; } - bool hasISA(int features, int isa) { + static bool hasISA(int features, int isa) { return (features & isa) == isa; } diff --git a/common/sys/thread.cpp b/common/sys/thread.cpp index 8b072067e6..6cbd0c35c6 100644 --- a/common/sys/thread.cpp +++ b/common/sys/thread.cpp @@ -173,7 +173,7 @@ namespace embree static std::vector threadIDs; /* changes thread ID mapping such that we first fill up all thread on one core */ - size_t mapThreadID(size_t threadID) + static size_t mapThreadID(size_t threadID) { Lock lock(mutex); diff --git a/kernels/builders/bvh_builder_hair.h b/kernels/builders/bvh_builder_hair.h index d83e8918a1..7728c22d86 100644 --- a/kernels/builders/bvh_builder_hair.h +++ b/kernels/builders/bvh_builder_hair.h @@ -46,7 +46,7 @@ namespace embree class BuilderT { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) friend struct BVHBuilderHair; typedef FastAllocator::CachedAllocator Allocator; diff --git a/kernels/builders/bvh_builder_morton.h b/kernels/builders/bvh_builder_morton.h index 87d4786810..6cb9fe3a5e 100644 --- a/kernels/builders/bvh_builder_morton.h +++ b/kernels/builders/bvh_builder_morton.h @@ -53,7 +53,7 @@ namespace embree struct __aligned(8) BuildPrim { union { - struct { + __extension__ struct { unsigned int code; //!< morton code unsigned int index; //!< i'th primitive }; @@ -184,7 +184,7 @@ namespace embree class BuilderT : private Settings { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: diff --git a/kernels/builders/bvh_builder_msmblur.h b/kernels/builders/bvh_builder_msmblur.h index d4e3388db5..fabd28f2c5 100644 --- a/kernels/builders/bvh_builder_msmblur.h +++ b/kernels/builders/bvh_builder_msmblur.h @@ -255,7 +255,7 @@ namespace embree class BuilderT { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) static const size_t MAX_BRANCHING_FACTOR = 16; //!< maximum supported BVH branching factor static const size_t MIN_LARGE_LEAF_LEVELS = 8; //!< create balanced tree if we are that many levels before the maximum tree depth diff --git a/kernels/builders/bvh_builder_msmblur_hair.h b/kernels/builders/bvh_builder_msmblur_hair.h index 397e8636b1..63ecc94359 100644 --- a/kernels/builders/bvh_builder_msmblur_hair.h +++ b/kernels/builders/bvh_builder_msmblur_hair.h @@ -63,7 +63,7 @@ namespace embree class BuilderT { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) static const size_t MAX_BRANCHING_FACTOR = 8; //!< maximum supported BVH branching factor static const size_t MIN_LARGE_LEAF_LEVELS = 8; //!< create balanced tree if we are that many levels before the maximum tree depth diff --git a/kernels/bvh/bvh.h b/kernels/bvh/bvh.h index e0ffb86af9..123dd9d6ed 100644 --- a/kernels/bvh/bvh.h +++ b/kernels/bvh/bvh.h @@ -41,7 +41,7 @@ namespace embree template class BVHN : public AccelData { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: /*! forward declaration of node ref type */ diff --git a/kernels/bvh/bvh_builder_sah.cpp b/kernels/bvh/bvh_builder_sah.cpp index e20c088bba..3584468c24 100644 --- a/kernels/bvh/bvh_builder_sah.cpp +++ b/kernels/bvh/bvh_builder_sah.cpp @@ -131,7 +131,7 @@ namespace embree double t0 = bvh->preBuild(mesh ? "" : TOSTRING(isa) "::BVH" + toString(N) + "BuilderSAH"); -#if PROFILE +#if defined(PROFILE) && PROFILE profile(2,PROFILE_RUNS,numPrimitives,[&] (ProfileTimer& timer) { #endif @@ -170,7 +170,7 @@ namespace embree bvh->set(root,LBBox3fa(pinfo.geomBounds),pinfo.size()); bvh->layoutLargeNodes(size_t(pinfo.size()*0.005f)); -#if PROFILE +#if defined(PROFILE) && PROFILE }); #endif @@ -237,7 +237,7 @@ namespace embree double t0 = bvh->preBuild(mesh ? "" : TOSTRING(isa) "::QBVH" + toString(N) + "BuilderSAH"); -#if PROFILE +#if defined(PROFILE) && PROFILE profile(2,PROFILE_RUNS,numPrimitives,[&] (ProfileTimer& timer) { #endif /* create primref array */ @@ -258,7 +258,7 @@ namespace embree NodeRef root = BVHNBuilderQuantizedVirtual::build(&bvh->alloc,CreateLeafQuantized(bvh),bvh->scene->progressInterface,prims.data(),pinfo,settings); bvh->set(root,LBBox3fa(pinfo.geomBounds),pinfo.size()); //bvh->layoutLargeNodes(pinfo.size()*0.005f); // FIXME: COPY LAYOUT FOR LARGE NODES !!! -#if PROFILE +#if defined(PROFILE) && PROFILE }); #endif diff --git a/kernels/bvh/bvh_builder_sah_mb.cpp b/kernels/bvh/bvh_builder_sah_mb.cpp index 0dcf98a5be..3d556419ed 100644 --- a/kernels/bvh/bvh_builder_sah_mb.cpp +++ b/kernels/bvh/bvh_builder_sah_mb.cpp @@ -117,7 +117,7 @@ namespace embree double t0 = bvh->preBuild(TOSTRING(isa) "::BVH" + toString(N) + "BuilderMBlurSAH"); -#if PROFILE +#ifdef PROFILE profile(2,PROFILE_RUNS,numPrimitives,[&] (ProfileTimer& timer) { #endif @@ -129,7 +129,7 @@ namespace embree else*/ buildMultiSegment(numPrimitives); -#if PROFILE +#ifdef PROFILE }); #endif diff --git a/kernels/bvh/bvh_builder_twolevel.cpp b/kernels/bvh/bvh_builder_twolevel.cpp index 990b1d59ad..0cf955a80b 100644 --- a/kernels/bvh/bvh_builder_twolevel.cpp +++ b/kernels/bvh/bvh_builder_twolevel.cpp @@ -44,7 +44,7 @@ namespace embree }); } -#if PROFILE +#if defined(PROFILE) && PROFILE while(1) #endif { @@ -108,7 +108,7 @@ namespace embree }); -#if PROFILE +#if defined(PROFILE) && PROFILE double d0 = getSeconds(); #endif /* fast path for single geometry scenes */ @@ -215,7 +215,7 @@ namespace embree bvh->alloc.cleanup(); bvh->postBuild(t0); -#if PROFILE +#if defined(PROFILE) && PROFILE double d1 = getSeconds(); std::cout << "TOP_LEVEL OPENING/REBUILD TIME " << 1000.0*(d1-d0) << " ms" << std::endl; #endif diff --git a/kernels/bvh/bvh_node_qaabb.h b/kernels/bvh/bvh_node_qaabb.h index 99671ddc5a..6e00722637 100644 --- a/kernels/bvh/bvh_node_qaabb.h +++ b/kernels/bvh/bvh_node_qaabb.h @@ -118,7 +118,7 @@ namespace embree #endif union { - struct { + __extension__ struct { T lower_x[N]; //!< 8bit discretized X dimension of lower bounds of all N children T upper_x[N]; //!< 8bit discretized X dimension of upper bounds of all N children T lower_y[N]; //!< 8bit discretized Y dimension of lower bounds of all N children diff --git a/kernels/bvh/node_intersector1.h b/kernels/bvh/node_intersector1.h index 17641fa888..446a9122b9 100644 --- a/kernels/bvh/node_intersector1.h +++ b/kernels/bvh/node_intersector1.h @@ -424,7 +424,7 @@ namespace embree ////////////////////////////////////////////////////////////////////////////////////// template - __forceinline size_t intersectNode(const typename BVHN::AABBNode* node, const TravRay& ray, vfloat& dist); + size_t intersectNode(const typename BVHN::AABBNode* node, const TravRay& ray, vfloat& dist); template<> __forceinline size_t intersectNode<4>(const typename BVH4::AABBNode* node, const TravRay<4,false>& ray, vfloat4& dist) @@ -730,7 +730,7 @@ namespace embree ////////////////////////////////////////////////////////////////////////////////////// template - __forceinline size_t intersectNode(const typename BVHN::QuantizedBaseNode* node, const TravRay& ray, vfloat& dist); + size_t intersectNode(const typename BVHN::QuantizedBaseNode* node, const TravRay& ray, vfloat& dist); template<> __forceinline size_t intersectNode<4>(const typename BVH4::QuantizedBaseNode* node, const TravRay<4,false>& ray, vfloat4& dist) diff --git a/kernels/common/accel.h b/kernels/common/accel.h index 7d959377ae..94347c8c7a 100644 --- a/kernels/common/accel.h +++ b/kernels/common/accel.h @@ -15,7 +15,7 @@ namespace embree /*! Base class for the acceleration structure data. */ class AccelData : public RefCount { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: enum Type { TY_UNKNOWN = 0, TY_ACCELN = 1, TY_ACCEL_INSTANCE = 2, TY_BVH4 = 3, TY_BVH8 = 4, TY_GPU = 5 }; @@ -57,7 +57,7 @@ namespace embree /*! Base class for all intersectable and buildable acceleration structures. */ class Accel : public AccelData { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: struct Intersectors; diff --git a/kernels/common/alloc.h b/kernels/common/alloc.h index 2bd292de4d..759bc5f31a 100644 --- a/kernels/common/alloc.h +++ b/kernels/common/alloc.h @@ -33,7 +33,7 @@ namespace embree /*! Per thread structure holding the current memory block. */ struct __aligned(64) ThreadLocal { - ALIGNED_CLASS_(64); + ALIGNED_CLASS_(64) public: /*! Constructor for usage with ThreadLocalData */ @@ -121,7 +121,7 @@ namespace embree /*! Two thread local structures. */ struct __aligned(64) ThreadLocal2 { - ALIGNED_CLASS_(64); + ALIGNED_CLASS_(64) public: __forceinline ThreadLocal2() diff --git a/kernels/common/device.h b/kernels/common/device.h index 9203956c27..cb0220c5eb 100644 --- a/kernels/common/device.h +++ b/kernels/common/device.h @@ -15,7 +15,7 @@ namespace embree class Device : public State, public MemoryMonitorInterface { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: diff --git a/kernels/common/geometry.h b/kernels/common/geometry.h index 3c7ce99564..e5f6f69336 100644 --- a/kernels/common/geometry.h +++ b/kernels/common/geometry.h @@ -656,7 +656,7 @@ namespace embree unsigned int mask; //!< for masking out geometry unsigned int modCounter_ = 1; //!< counter for every modification - used to rebuild scenes when geo is modified - struct { + __extension__ struct { GType gtype : 8; //!< geometry type GSubType gsubtype : 8; //!< geometry subtype RTCBuildQuality quality : 3; //!< build quality for geometry diff --git a/kernels/common/isa.h b/kernels/common/isa.h index 9e1132e1a0..6d62b6207a 100644 --- a/kernels/common/isa.h +++ b/kernels/common/isa.h @@ -10,7 +10,7 @@ namespace embree { #define DEFINE_SYMBOL2(type,name) \ typedef type (*name##Func)(); \ - name##Func name; + name##Func name #define DECLARE_SYMBOL2(type,name) \ namespace sse2 { extern type name(); } \ @@ -33,7 +33,7 @@ namespace embree #define DEFINE_ISA_FUNCTION(type,symbol,args) \ typedef type (*symbol##Func)(args); \ - symbol##Func symbol; + symbol##Func symbol #define ZERO_SYMBOL(features,intersector) \ intersector = intersector##_zero; diff --git a/kernels/common/scene_points.h b/kernels/common/scene_points.h index ea24277bc9..5800f0c51a 100644 --- a/kernels/common/scene_points.h +++ b/kernels/common/scene_points.h @@ -247,7 +247,7 @@ namespace embree __forceinline float projectedPrimitiveArea(const size_t i) const { const float R = radius(i); - return 1 + 2*M_PI*R*R; + return 1.0f + 2.0f*float(M_PI)*R*R; } public: diff --git a/kernels/common/scene_subdiv_mesh.h b/kernels/common/scene_subdiv_mesh.h index 49bb8e769a..a99f695687 100644 --- a/kernels/common/scene_subdiv_mesh.h +++ b/kernels/common/scene_subdiv_mesh.h @@ -18,7 +18,7 @@ namespace embree class SubdivMesh : public Geometry { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: typedef HalfEdge::Edge Edge; diff --git a/kernels/common/state.cpp b/kernels/common/state.cpp index cce5eafce1..b9803d6cfa 100644 --- a/kernels/common/state.cpp +++ b/kernels/common/state.cpp @@ -114,7 +114,7 @@ namespace embree numThreads = 0; numUserThreads = 0; -#if TASKING_INTERNAL +#ifdef TASKING_INTERNAL set_affinity = true; #else set_affinity = false; diff --git a/kernels/geometry/curveNi_mb_intersector.h b/kernels/geometry/curveNi_mb_intersector.h index 4c14c2f004..7c8d0b7f9f 100644 --- a/kernels/geometry/curveNi_mb_intersector.h +++ b/kernels/geometry/curveNi_mb_intersector.h @@ -27,7 +27,7 @@ namespace embree static __forceinline vbool intersect(Ray& ray, const Primitive& prim, vfloat& tNear_o) { const size_t N = prim.N; -#if __SYCL_DEVICE_ONLY__ +#ifdef __SYCL_DEVICE_ONLY__ const Vec3f offset = *prim.offset(N); const float scale = *prim.scale(N); #else @@ -278,7 +278,7 @@ namespace embree static __forceinline vbool intersect(RayK& ray, const size_t k, const Primitive& prim, vfloat& tNear_o) { const size_t N = prim.N; -#if __SYCL_DEVICE_ONLY__ +#ifdef __SYCL_DEVICE_ONLY__ const Vec3f offset = *prim.offset(N); const float scale = *prim.scale(N); #else diff --git a/kernels/subdiv/catmullclark_patch.h b/kernels/subdiv/catmullclark_patch.h index 91772d94ed..2f992ea893 100644 --- a/kernels/subdiv/catmullclark_patch.h +++ b/kernels/subdiv/catmullclark_patch.h @@ -535,14 +535,14 @@ namespace embree const Vertex b03 = ring[i1].getLimitVertex(); const Vertex b33 = ring[i2].getLimitVertex(); - const Vertex b01 = madd(1.0/3.0f,t0_p,b00); - const Vertex b11 = madd(1.0/3.0f,t0_m,b00); + const Vertex b01 = madd(1.0f/3.0f,t0_p,b00); + const Vertex b11 = madd(1.0f/3.0f,t0_m,b00); - //const Vertex b13 = madd(1.0/3.0f,t1_p,b03); - const Vertex b02 = madd(1.0/3.0f,t1_m,b03); + //const Vertex b13 = madd(1.0f/3.0f,t1_p,b03); + const Vertex b02 = madd(1.0f/3.0f,t1_m,b03); - const Vertex b22 = madd(1.0/3.0f,t2_p,b33); - const Vertex b23 = madd(1.0/3.0f,t2_m,b33); + const Vertex b22 = madd(1.0f/3.0f,t2_p,b33); + const Vertex b23 = madd(1.0f/3.0f,t2_m,b33); new (&curves[0]) BezierCurve(b00,b01,b02,b03); new (&curves[1]) BezierCurve(b33,b22,b11,b00); From 99ed174774b61f8f13036e072e9d83df8994437d Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 9 Jun 2026 12:17:26 +0200 Subject: [PATCH 03/19] Fix remaining tutorial warnings for GCC and Clang - Fix viewer.cpp: wrap extern C variables with initializers in extern C blocks - Fix viewer.cpp: remove redundant renderFrameStandard declaration - Fix verify.cpp: add [[fallthrough]] for case 20 fall-through - Fix verify.cpp: remove extra semicolon after ALIGNED_CLASS_ macro - Fix constraints.h: remove extra semicolon after ALIGNED_CLASS_ macro - Fix intersection_filter_device.cpp: construct Ray directly instead of default-init + assign - Fix clang.cmake: add -Wno-c++17-attribute-extensions for [[fallthrough]] in C++11 mode Both GCC-15 and Clang-21 builds with tutorials now emit zero warnings/errors. --- common/cmake/clang.cmake | 1 + kernels/common/device.cpp | 8 ++++---- tutorials/collide/constraints.h | 2 +- tutorials/common/image/CMakeLists.txt | 5 +++++ tutorials/common/imgui/CMakeLists.txt | 2 +- tutorials/common/tutorial/benchmark.cpp | 2 +- tutorials/common/tutorial/camera.h | 2 +- tutorials/common/tutorial/tutorial.cpp | 2 -- tutorials/hair_geometry/hair_geometry_device.h | 2 +- tutorials/hair_geometry/hair_geometry_device.isph | 2 +- tutorials/instanced_geometry/instanced_geometry_device.h | 2 +- .../instanced_geometry/instanced_geometry_device.isph | 2 +- .../intersection_filter/intersection_filter_device.cpp | 5 ++--- .../intersection_filter/intersection_filter_device.ispc | 2 +- .../motion_blur_geometry/motion_blur_geometry_device.h | 2 +- .../motion_blur_geometry_device.isph | 2 +- .../multi_instanced_geometry_device.h | 2 +- .../multi_instanced_geometry_device.isph | 2 +- .../quaternion_motion_blur_device.h | 2 +- .../quaternion_motion_blur_device.isph | 2 +- tutorials/user_geometry/user_geometry_device.cpp | 2 +- tutorials/user_geometry/user_geometry_device.h | 2 +- tutorials/user_geometry/user_geometry_device.ispc | 2 +- tutorials/user_geometry/user_geometry_device.isph | 2 +- tutorials/verify/verify.cpp | 7 +++++-- tutorials/viewer/viewer.cpp | 9 ++++----- 26 files changed, 40 insertions(+), 35 deletions(-) diff --git a/common/cmake/clang.cmake b/common/cmake/clang.cmake index 2cb01ca2f3..9b98111a50 100644 --- a/common/cmake/clang.cmake +++ b/common/cmake/clang.cmake @@ -102,6 +102,7 @@ ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow") # disable: pervasive in vector class constructors SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types") # disable: anonymous types in unions for SIMD SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # disable: int/size_t comparisons in template code + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++17-attribute-extensions") # disable: [[fallthrough]] etc in C++11 mode SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") # treat all warnings as errors SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char") # treat char as signed on all processors, including ARM IF (NOT APPLE) diff --git a/kernels/common/device.cpp b/kernels/common/device.cpp index edbcb9cc33..fb684e5801 100644 --- a/kernels/common/device.cpp +++ b/kernels/common/device.cpp @@ -42,7 +42,7 @@ namespace embree struct TaskArena { -#if USE_TASK_ARENA +#if defined(USE_TASK_ARENA) && USE_TASK_ARENA std::unique_ptr arena; #endif }; @@ -379,7 +379,7 @@ namespace embree /* create task scheduler */ size_t maxNumThreads = getMaxNumThreads(); TaskScheduler::create(maxNumThreads,State::set_affinity,State::start_threads); -#if USE_TASK_ARENA +#if defined(USE_TASK_ARENA) && USE_TASK_ARENA const size_t nThreads = min(maxNumThreads,TaskScheduler::threadCount()); const size_t uThreads = min(max(numUserThreads,(size_t)1),nThreads); arena->arena = make_unique(new tbb::task_arena((int)nThreads,(unsigned int)uThreads)); @@ -400,14 +400,14 @@ namespace embree size_t maxNumThreads = getMaxNumThreads(); TaskScheduler::create(maxNumThreads,State::set_affinity,State::start_threads); } -#if USE_TASK_ARENA +#if defined(USE_TASK_ARENA) && USE_TASK_ARENA arena->arena.reset(); #endif } void Device::execute(bool join, const std::function& func) { -#if USE_TASK_ARENA +#if defined(USE_TASK_ARENA) && USE_TASK_ARENA if (join) { arena->arena->execute(func); } diff --git a/tutorials/collide/constraints.h b/tutorials/collide/constraints.h index 9c27fe3dbc..9e382d3853 100644 --- a/tutorials/collide/constraints.h +++ b/tutorials/collide/constraints.h @@ -52,7 +52,7 @@ class DistanceConstraint : public Constraint { }; class CollisionConstraint : public Constraint { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: CollisionConstraint () diff --git a/tutorials/common/image/CMakeLists.txt b/tutorials/common/image/CMakeLists.txt index da77eaa96a..a081bd5078 100644 --- a/tutorials/common/image/CMakeLists.txt +++ b/tutorials/common/image/CMakeLists.txt @@ -19,3 +19,8 @@ ADD_LIBRARY(image STATIC TARGET_LINK_LIBRARIES(image sys math ${ADDITIONAL_LIBRARIES}) SET_PROPERTY(TARGET image PROPERTY FOLDER tutorials/common) SET_PROPERTY(TARGET image APPEND PROPERTY COMPILE_FLAGS " ${FLAGS_LOWEST}") +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + TARGET_COMPILE_OPTIONS(image PRIVATE -Wno-missing-field-initializers -Wno-stringop-overflow -Wno-array-bounds) +ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + TARGET_COMPILE_OPTIONS(image PRIVATE -Wno-missing-field-initializers) +ENDIF() diff --git a/tutorials/common/imgui/CMakeLists.txt b/tutorials/common/imgui/CMakeLists.txt index eb2c6fa4a0..0033406ae8 100644 --- a/tutorials/common/imgui/CMakeLists.txt +++ b/tutorials/common/imgui/CMakeLists.txt @@ -13,6 +13,6 @@ ADD_LIBRARY(imgui STATIC TARGET_INCLUDE_DIRECTORIES(imgui PUBLIC . ./backends) TARGET_LINK_LIBRARIES(imgui glfw) SET_PROPERTY(TARGET imgui PROPERTY FOLDER tutorials/common) -SET_PROPERTY(TARGET imgui APPEND PROPERTY COMPILE_FLAGS " ${FLAGS_LOWEST}") +SET_PROPERTY(TARGET imgui APPEND PROPERTY COMPILE_FLAGS " ${FLAGS_LOWEST} -Wno-uninitialized-const-pointer") TARGET_COMPILE_DEFINITIONS(imgui PUBLIC IMGUI_DISABLE_SSE) diff --git a/tutorials/common/tutorial/benchmark.cpp b/tutorials/common/tutorial/benchmark.cpp index a707e23947..30e9b60ab1 100644 --- a/tutorials/common/tutorial/benchmark.cpp +++ b/tutorials/common/tutorial/benchmark.cpp @@ -108,7 +108,7 @@ int TutorialBenchmark::main(int argc, char** argv, std::string name) CommandLine commandLine(argc, argv); -#if USE_GOOGLE_BENCHMARK +#ifdef USE_GOOGLE_BENCHMARK if (!params.legacy && params.minTimeOrIterations > 0) commandLine.add({"--benchmark_min_time=" + std::to_string(params.minTimeOrIterations)}); if (!params.legacy && params.repetitions > 0) diff --git a/tutorials/common/tutorial/camera.h b/tutorials/common/tutorial/camera.h index acbc8702c4..93f424c53b 100644 --- a/tutorials/common/tutorial/camera.h +++ b/tutorials/common/tutorial/camera.h @@ -131,7 +131,7 @@ namespace embree typedef Camera::ISPCCamera ISPCCamera; } -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 namespace sycl { template<> struct is_device_copyable : std::true_type {}; template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/common/tutorial/tutorial.cpp b/tutorials/common/tutorial/tutorial.cpp index 01c9f7d095..844abb7d0a 100644 --- a/tutorials/common/tutorial/tutorial.cpp +++ b/tutorials/common/tutorial/tutorial.cpp @@ -39,8 +39,6 @@ namespace embree sycl::queue* global_gpu_queue = nullptr; #endif - extern "C" void renderFrameStandard(int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera); - /* access to debug shader render frame functions */ typedef void (* renderFrameFunc)(int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera); renderFrameFunc renderFrame = renderFrameStandard; diff --git a/tutorials/hair_geometry/hair_geometry_device.h b/tutorials/hair_geometry/hair_geometry_device.h index b3e021671c..ff5396535c 100644 --- a/tutorials/hair_geometry/hair_geometry_device.h +++ b/tutorials/hair_geometry/hair_geometry_device.h @@ -38,7 +38,7 @@ struct TutorialData Vec3fa hair_Kt; //!< transparency of hair }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/hair_geometry/hair_geometry_device.isph b/tutorials/hair_geometry/hair_geometry_device.isph index 69ccd217d6..c4b49b4b1c 100644 --- a/tutorials/hair_geometry/hair_geometry_device.isph +++ b/tutorials/hair_geometry/hair_geometry_device.isph @@ -36,7 +36,7 @@ struct TutorialData uniform Vec3f hair_Kt; //!< transparency of hair }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/instanced_geometry/instanced_geometry_device.h b/tutorials/instanced_geometry/instanced_geometry_device.h index 18efcd8477..8d67115a29 100644 --- a/tutorials/instanced_geometry/instanced_geometry_device.h +++ b/tutorials/instanced_geometry/instanced_geometry_device.h @@ -21,7 +21,7 @@ struct TutorialData Vec3fa* colors; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/instanced_geometry/instanced_geometry_device.isph b/tutorials/instanced_geometry/instanced_geometry_device.isph index 1e7998311a..cf8a33a05a 100644 --- a/tutorials/instanced_geometry/instanced_geometry_device.isph +++ b/tutorials/instanced_geometry/instanced_geometry_device.isph @@ -19,7 +19,7 @@ struct TutorialData uniform Vec3f* uniform colors; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/intersection_filter/intersection_filter_device.cpp b/tutorials/intersection_filter/intersection_filter_device.cpp index 90cb1592a7..261788fe1d 100644 --- a/tutorials/intersection_filter/intersection_filter_device.cpp +++ b/tutorials/intersection_filter/intersection_filter_device.cpp @@ -5,7 +5,7 @@ namespace embree { -#if EMBREE_SYCL_TUTORIAL +#if defined(EMBREE_SYCL_TUTORIAL) && EMBREE_SYCL_TUTORIAL #define USE_ARGUMENT_CALLBACKS 1 #else #define USE_ARGUMENT_CALLBACKS 0 @@ -60,8 +60,7 @@ void renderPixelStandard(const TutorialData& data, InitIntersectionContext(&context); /* initialize ray */ - Ray primary; - init_Ray(primary,Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf); + Ray primary(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf); float primary_transparency = 0.0f; while (true) diff --git a/tutorials/intersection_filter/intersection_filter_device.ispc b/tutorials/intersection_filter/intersection_filter_device.ispc index 9dbfbb62b2..207e93a246 100644 --- a/tutorials/intersection_filter/intersection_filter_device.ispc +++ b/tutorials/intersection_filter/intersection_filter_device.ispc @@ -3,7 +3,7 @@ #include "intersection_filter_device.isph" -#if EMBREE_SYCL_TUTORIAL +#if defined(EMBREE_SYCL_TUTORIAL) && EMBREE_SYCL_TUTORIAL #define USE_ARGUMENT_CALLBACKS 1 #else #define USE_ARGUMENT_CALLBACKS 0 diff --git a/tutorials/motion_blur_geometry/motion_blur_geometry_device.h b/tutorials/motion_blur_geometry/motion_blur_geometry_device.h index 4634a8e850..9066b9d8d1 100644 --- a/tutorials/motion_blur_geometry/motion_blur_geometry_device.h +++ b/tutorials/motion_blur_geometry/motion_blur_geometry_device.h @@ -49,7 +49,7 @@ struct TutorialData Sphere* sphere1; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/motion_blur_geometry/motion_blur_geometry_device.isph b/tutorials/motion_blur_geometry/motion_blur_geometry_device.isph index 56877f286c..805c48dfa3 100644 --- a/tutorials/motion_blur_geometry/motion_blur_geometry_device.isph +++ b/tutorials/motion_blur_geometry/motion_blur_geometry_device.isph @@ -47,7 +47,7 @@ struct TutorialData uniform Sphere* uniform sphere1; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.h b/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.h index 1568d3e97d..1783820e2f 100644 --- a/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.h +++ b/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.h @@ -36,7 +36,7 @@ struct TutorialData LinearSpace3fa** g_normalTransforms; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.isph b/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.isph index 3009cdac7e..58a4aa8a69 100644 --- a/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.isph +++ b/tutorials/multi_instanced_geometry/multi_instanced_geometry_device.isph @@ -34,7 +34,7 @@ struct TutorialData LinearSpace3fa** g_normalTransforms; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.h b/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.h index f4c18a1ffe..f028acc4c8 100644 --- a/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.h +++ b/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.h @@ -36,7 +36,7 @@ struct TutorialData Vec3fa g_accu_p; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.isph b/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.isph index 149a9c1c38..ee09a54dfa 100644 --- a/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.isph +++ b/tutorials/quaternion_motion_blur/quaternion_motion_blur_device.isph @@ -34,7 +34,7 @@ struct TutorialData uniform Vec3f g_accu_p; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/user_geometry/user_geometry_device.cpp b/tutorials/user_geometry/user_geometry_device.cpp index e1eb167ad7..1b14e197a1 100644 --- a/tutorials/user_geometry/user_geometry_device.cpp +++ b/tutorials/user_geometry/user_geometry_device.cpp @@ -5,7 +5,7 @@ namespace embree { -#if EMBREE_SYCL_TUTORIAL +#if defined(EMBREE_SYCL_TUTORIAL) && EMBREE_SYCL_TUTORIAL #define USE_ARGUMENT_CALLBACKS 1 #else #define USE_ARGUMENT_CALLBACKS 0 diff --git a/tutorials/user_geometry/user_geometry_device.h b/tutorials/user_geometry/user_geometry_device.h index 8e5b811dcb..279518e97e 100644 --- a/tutorials/user_geometry/user_geometry_device.h +++ b/tutorials/user_geometry/user_geometry_device.h @@ -53,7 +53,7 @@ struct TutorialData Vec3fa* colors; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/user_geometry/user_geometry_device.ispc b/tutorials/user_geometry/user_geometry_device.ispc index 4b9c4a9d2b..9d01f19527 100644 --- a/tutorials/user_geometry/user_geometry_device.ispc +++ b/tutorials/user_geometry/user_geometry_device.ispc @@ -3,7 +3,7 @@ #include "user_geometry_device.isph" -#if EMBREE_SYCL_TUTORIAL +#if defined(EMBREE_SYCL_TUTORIAL) && EMBREE_SYCL_TUTORIAL #define USE_ARGUMENT_CALLBACKS 1 #else #define USE_ARGUMENT_CALLBACKS 0 diff --git a/tutorials/user_geometry/user_geometry_device.isph b/tutorials/user_geometry/user_geometry_device.isph index 4e93fbc9b6..caebd65cfd 100644 --- a/tutorials/user_geometry/user_geometry_device.isph +++ b/tutorials/user_geometry/user_geometry_device.isph @@ -51,7 +51,7 @@ struct TutorialData uniform Vec3f* uniform colors; }; -#if __SYCL_COMPILER_VERSION >= 20210801 +#if defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20210801 } namespace sycl { template<> struct is_device_copyable : std::true_type {}; diff --git a/tutorials/verify/verify.cpp b/tutorials/verify/verify.cpp index cb1edc00aa..14fd060d48 100644 --- a/tutorials/verify/verify.cpp +++ b/tutorials/verify/verify.cpp @@ -125,7 +125,7 @@ namespace embree struct Sphere { - ALIGNED_CLASS_(16); + ALIGNED_CLASS_(16) public: Sphere () : pos(zero), r(zero) {} Sphere (const Vec3fa& pos, float r) : pos(pos), r(r) {} @@ -4960,6 +4960,7 @@ namespace embree std::pair> geom[numSlots]; int types[numSlots]; RTCBuildQuality quality[numSlots]; + (void)quality; Sphere spheres[numSlots]; size_t numVertices[numSlots]; for (size_t i=0; idevice, RTC_DEVICE_PROPERTY_USER_GEOMETRY_SUPPORTED)) { @@ -5109,6 +5111,7 @@ namespace embree quality[index] = RTC_BUILD_QUALITY_REFIT; break; } + [[fallthrough]]; case 20: if (rtcGetDeviceProperty(thread->device, RTC_DEVICE_PROPERTY_USER_GEOMETRY_SUPPORTED)) { @@ -5117,7 +5120,7 @@ namespace embree quality[index] = RTC_BUILD_QUALITY_LOW; break; } - + [[fallthrough]]; case 24: geom[index] = task->scene->addHair(task->sampler, RTC_BUILD_QUALITY_MEDIUM, pos, 1.0f, 2.0f, numTriangles); quality[index] = RTC_BUILD_QUALITY_MEDIUM; diff --git a/tutorials/viewer/viewer.cpp b/tutorials/viewer/viewer.cpp index 8b6bdbb280..969c4a123a 100644 --- a/tutorials/viewer/viewer.cpp +++ b/tutorials/viewer/viewer.cpp @@ -15,18 +15,17 @@ namespace embree { - extern "C" float g_min_width = 0.0f; + extern "C" { float g_min_width = 0.0f; } extern "C" float g_min_width_max_radius_scale; - extern "C" bool g_use_scene_features = true; - extern "C" RTCFeatureFlags g_feature_mask = RTC_FEATURE_FLAG_ALL; + extern "C" { bool g_use_scene_features = true; } + extern "C" { RTCFeatureFlags g_feature_mask = RTC_FEATURE_FLAG_ALL; } extern "C" float scale; extern "C" bool g_changed; - extern "C" Shader shader = SHADER_DEFAULT; + extern "C" { Shader shader = SHADER_DEFAULT; } typedef void (* renderFrameFunc)(int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera); extern renderFrameFunc renderFrame; - extern "C" void renderFrameStandard(int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera); extern "C" void renderFrameDebugShader(int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera); extern "C" void renderFrameAOShader(int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera); From 0ce622d19dc33f228e872109d37de25546c7ad8f Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 9 Jun 2026 13:29:32 +0200 Subject: [PATCH 04/19] Add -Werror to SYCL build and fix warnings - Add -Wall -Wextra -Werror with appropriate suppressions to dpcpp.cmake - Remove unused hasDriverExtension function and hDriver variable - Fix const return types on uint32_t/bool functions - Fix sign comparison in instance_array.h and thread.cpp --- common/cmake/dpcpp.cmake | 7 +++++++ common/sys/sycl.h | 8 ++++---- common/sys/thread.cpp | 2 +- kernels/geometry/instance_array.h | 2 +- kernels/sycl/rthwif_embree_builder.cpp | 24 +----------------------- kernels/sycl/rthwif_embree_builder.h | 2 +- 6 files changed, 15 insertions(+), 30 deletions(-) diff --git a/common/cmake/dpcpp.cmake b/common/cmake/dpcpp.cmake index a15c179ab9..43a98d3fb6 100644 --- a/common/cmake/dpcpp.cmake +++ b/common/cmake/dpcpp.cmake @@ -220,7 +220,14 @@ ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2") # perform extra security checks for some standard library calls SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char") # treat char as signed on all processors, including ARM SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") # enables extra warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # disables warnings for unused function parameters + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") # disables warnings for intentional function pointer casts + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type-mismatch") # disables warnings for intentional function pointer casts + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # disable: int/size_t comparisons in template code + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") # disable: intentional partial struct init with zero fill + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") # treat all warnings as errors SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise") # makes dpcpp compiler compatible with clang++ ENDIF() diff --git a/common/sys/sycl.h b/common/sys/sycl.h index 6bef829fc2..b4fc5f0d86 100644 --- a/common/sys/sycl.h +++ b/common/sys/sycl.h @@ -192,19 +192,19 @@ namespace embree #endif } - __forceinline const uint32_t get_sub_group_local_id() { + __forceinline uint32_t get_sub_group_local_id() { return this_sub_group().get_local_id()[0]; } - __forceinline const uint32_t get_sub_group_size() { + __forceinline uint32_t get_sub_group_size() { return this_sub_group().get_max_local_range().size(); } - __forceinline const uint32_t get_sub_group_id() { + __forceinline uint32_t get_sub_group_id() { return this_sub_group().get_group_id()[0]; } - __forceinline const uint32_t get_num_sub_groups() { + __forceinline uint32_t get_num_sub_groups() { return this_sub_group().get_group_range().size(); } diff --git a/common/sys/thread.cpp b/common/sys/thread.cpp index 6cbd0c35c6..afb850a086 100644 --- a/common/sys/thread.cpp +++ b/common/sys/thread.cpp @@ -228,7 +228,7 @@ namespace embree { if (!CPU_ISSET(i,&set)) continue; - if (j == ID) { + if (size_t(j) == ID) { ID = i; break; } diff --git a/kernels/geometry/instance_array.h b/kernels/geometry/instance_array.h index fdbe79b3a8..b858649e0d 100644 --- a/kernels/geometry/instance_array.h +++ b/kernels/geometry/instance_array.h @@ -39,7 +39,7 @@ namespace embree {} __forceinline bool valid() const { - return primID_ != -1; + return primID_ != ~0u; } void fill(const PrimRef* prims, size_t& i, size_t end, Scene* scene) diff --git a/kernels/sycl/rthwif_embree_builder.cpp b/kernels/sycl/rthwif_embree_builder.cpp index 891f767415..786ad98f28 100644 --- a/kernels/sycl/rthwif_embree_builder.cpp +++ b/kernels/sycl/rthwif_embree_builder.cpp @@ -150,7 +150,7 @@ namespace embree return sycl_device.get_info(); } - const bool isPVC(const ze_device_handle_t hDevice) + bool isPVC(const ze_device_handle_t hDevice) { ze_device_properties_t device_props{ ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES }; ze_result_t status = ZeWrapper::zeDeviceGetProperties(hDevice, &device_props); @@ -172,32 +172,10 @@ namespace embree return pvc; } - static bool hasDriverExtension(ze_driver_handle_t hDriver, const char* extensionName) - { - uint32_t count = 0; - ze_result_t result = ZeWrapper::zeDriverGetExtensionProperties(hDriver, &count, nullptr); - if (result != ZE_RESULT_SUCCESS) - return false; - - std::vector extensions(count); - result = ZeWrapper::zeDriverGetExtensionProperties(hDriver, &count, extensions.data()); - if (result != ZE_RESULT_SUCCESS) - return false; - - for (uint32_t i = 0; i < count; i++) - { - if (strncmp(extensionName, extensions[i].name, sizeof(extensions[i].name)) == 0) - return true; - } - return false; - } - void* rthwifAllocAccelBuffer(Device* embree_device, size_t bytes, sycl::device device, sycl::context context, sycl::usm::alloc alloc_type) { ze_context_handle_t hContext = sycl::get_native(context); ze_device_handle_t hDevice = sycl::get_native(device); - sycl::platform platform = device.get_platform(); - ze_driver_handle_t hDriver = sycl::get_native(platform); ze_rtas_device_ext_properties_t rtasProp = { ZE_STRUCTURE_TYPE_RTAS_DEVICE_EXT_PROPERTIES }; ze_device_properties_t devProp = { ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES, &rtasProp }; diff --git a/kernels/sycl/rthwif_embree_builder.h b/kernels/sycl/rthwif_embree_builder.h index bf438b9fea..6e28a9629e 100644 --- a/kernels/sycl/rthwif_embree_builder.h +++ b/kernels/sycl/rthwif_embree_builder.h @@ -23,7 +23,7 @@ namespace embree int rthwifIsSYCLDeviceSupported(const sycl::device& sycl_device); - const bool isPVC(const ze_device_handle_t hDevice); + bool isPVC(const ze_device_handle_t hDevice); /*! allocator that performs BVH memory allocations */ template From aeb1ca12e2e516b285d51d2870194b3c83a9fa6a Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Mon, 15 Jun 2026 09:22:37 +0200 Subject: [PATCH 05/19] Removed __extension__, disabled warning for anonymous structs --- common/cmake/clang.cmake | 1 + common/cmake/gnu.cmake | 2 +- common/math/color.h | 4 ++-- common/math/vec2.h | 2 +- common/math/vec2fa.h | 2 +- common/math/vec3.h | 2 +- common/math/vec3ba.h | 2 +- common/math/vec3fa.h | 4 ++-- common/math/vec3ia.h | 2 +- common/math/vec4.h | 2 +- common/simd/vboold4_avx.h | 2 +- common/simd/vboolf8_avx.h | 2 +- common/simd/vint8_avx.h | 2 +- common/simd/vuint8_avx.h | 2 +- kernels/builders/bvh_builder_morton.h | 2 +- kernels/bvh/bvh_node_qaabb.h | 2 +- kernels/common/geometry.h | 2 +- 17 files changed, 19 insertions(+), 18 deletions(-) diff --git a/common/cmake/clang.cmake b/common/cmake/clang.cmake index 9b98111a50..c29428228f 100644 --- a/common/cmake/clang.cmake +++ b/common/cmake/clang.cmake @@ -101,6 +101,7 @@ ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal") # disable: intentional exact-zero checks in normalize_safe SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow") # disable: pervasive in vector class constructors SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types") # disable: anonymous types in unions for SIMD + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-anonymous-struct") # disable: anonymous structs in unions for SIMD SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # disable: int/size_t comparisons in template code SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++17-attribute-extensions") # disable: [[fallthrough]] etc in C++11 mode SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") # treat all warnings as errors diff --git a/common/cmake/gnu.cmake b/common/cmake/gnu.cmake index b467f05284..664cd43375 100644 --- a/common/cmake/gnu.cmake +++ b/common/cmake/gnu.cmake @@ -34,7 +34,6 @@ ENDIF (EMBREE_ARM) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") # enables extra warnings -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") # enables pedantic warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") # disables clearing an object of type SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # disables warnings for unused function parameters @@ -54,6 +53,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-align") # disable: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-declarations") # disable: intentional factory pattern without declarations SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow") # disable: pervasive in vector class constructors SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal") # disable: intentional exact-zero checks in normalize_safe +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types") # disable: anonymous types in unions for SIMD SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-decls") # warn about redundant declarations SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") diff --git a/common/math/color.h b/common/math/color.h index 52dbe2ad57..8b28ff9447 100644 --- a/common/math/color.h +++ b/common/math/color.h @@ -23,7 +23,7 @@ namespace embree { union { __m128 m128; - __extension__ struct { float r,g,b,a; }; + struct { float r,g,b,a; }; }; //////////////////////////////////////////////////////////////////////////////// @@ -91,7 +91,7 @@ namespace embree { union { __m128 m128; - __extension__ struct { float r,g,b; }; + struct { float r,g,b; }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/common/math/vec2.h b/common/math/vec2.h index 6b0930b268..4e641ec249 100644 --- a/common/math/vec2.h +++ b/common/math/vec2.h @@ -17,7 +17,7 @@ namespace embree { enum { N = 2 }; union { - __extension__ struct { T x, y; }; + struct { T x, y; }; #if !(defined(__WIN32__) && _MSC_VER == 1800) // workaround for older VS 2013 compiler T components[N]; #endif diff --git a/common/math/vec2fa.h b/common/math/vec2fa.h index 67f237bafb..d57e549e68 100644 --- a/common/math/vec2fa.h +++ b/common/math/vec2fa.h @@ -26,7 +26,7 @@ namespace embree enum { N = 2 }; union { __m128 m128; - __extension__ struct { float x,y,az,aw; }; + struct { float x,y,az,aw; }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/common/math/vec3.h b/common/math/vec3.h index 037e6ab13a..d5e78befe8 100644 --- a/common/math/vec3.h +++ b/common/math/vec3.h @@ -18,7 +18,7 @@ namespace embree enum { N = 3 }; union { - __extension__ struct { + struct { T x, y, z; }; #if !(defined(__WIN32__) && _MSC_VER == 1800) // workaround for older VS 2013 compiler diff --git a/common/math/vec3ba.h b/common/math/vec3ba.h index 1ecc0bb36a..bf24a2a3b6 100644 --- a/common/math/vec3ba.h +++ b/common/math/vec3ba.h @@ -24,7 +24,7 @@ namespace embree union { __m128 m128; - __extension__ struct { int x,y,z; }; + struct { int x,y,z; }; }; typedef int Scalar; diff --git a/common/math/vec3fa.h b/common/math/vec3fa.h index 7ce5f93d51..967e75da74 100644 --- a/common/math/vec3fa.h +++ b/common/math/vec3fa.h @@ -26,7 +26,7 @@ namespace embree enum { N = 3 }; union { __m128 m128; - __extension__ struct { float x,y,z; }; + struct { float x,y,z; }; }; //////////////////////////////////////////////////////////////////////////////// @@ -429,7 +429,7 @@ namespace embree enum { N = 3 }; union { __m128 m128; - __extension__ struct { float x,y,z; union { int a; unsigned u; float w; }; }; + struct { float x,y,z; union { int a; unsigned u; float w; }; }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/common/math/vec3ia.h b/common/math/vec3ia.h index 6d68fc02df..1472fe9135 100644 --- a/common/math/vec3ia.h +++ b/common/math/vec3ia.h @@ -24,7 +24,7 @@ namespace embree union { __m128i m128; - __extension__ struct { int x,y,z; }; + struct { int x,y,z; }; }; typedef int Scalar; diff --git a/common/math/vec4.h b/common/math/vec4.h index a4cca14e1d..5647859257 100644 --- a/common/math/vec4.h +++ b/common/math/vec4.h @@ -16,7 +16,7 @@ namespace embree { enum { N = 4 }; union { - __extension__ struct { T x, y, z, w; }; + struct { T x, y, z, w; }; #if !(defined(__WIN32__) && _MSC_VER == 1800) // workaround for older VS 2013 compiler T components[N]; #endif diff --git a/common/simd/vboold4_avx.h b/common/simd/vboold4_avx.h index fa32d4df2e..450bd7a4eb 100644 --- a/common/simd/vboold4_avx.h +++ b/common/simd/vboold4_avx.h @@ -24,7 +24,7 @@ namespace embree enum { size = 4 }; // number of SIMD elements union { // data __m256d v; - __extension__ struct { __m128d vl,vh; }; + struct { __m128d vl,vh; }; long long i[4]; }; diff --git a/common/simd/vboolf8_avx.h b/common/simd/vboolf8_avx.h index 5367b4fbff..18cede19c6 100644 --- a/common/simd/vboolf8_avx.h +++ b/common/simd/vboolf8_avx.h @@ -26,7 +26,7 @@ namespace embree enum { size = 8 }; // number of SIMD elements union { // data __m256 v; - __extension__ struct { __m128 vl,vh; }; + struct { __m128 vl,vh; }; int i[8]; }; diff --git a/common/simd/vint8_avx.h b/common/simd/vint8_avx.h index 76b1b1ddac..48f5a9b203 100644 --- a/common/simd/vint8_avx.h +++ b/common/simd/vint8_avx.h @@ -26,7 +26,7 @@ namespace embree enum { size = 8 }; // number of SIMD elements union { // data __m256i v; - __extension__ struct { __m128i vl,vh; }; + struct { __m128i vl,vh; }; int i[8]; }; diff --git a/common/simd/vuint8_avx.h b/common/simd/vuint8_avx.h index 6d5d7111f0..cb8b5158c1 100644 --- a/common/simd/vuint8_avx.h +++ b/common/simd/vuint8_avx.h @@ -26,7 +26,7 @@ namespace embree enum { size = 8 }; // number of SIMD elements union { // data __m256i v; - __extension__ struct { __m128i vl,vh; }; + struct { __m128i vl,vh; }; unsigned int i[8]; }; diff --git a/kernels/builders/bvh_builder_morton.h b/kernels/builders/bvh_builder_morton.h index 6cb9fe3a5e..ccafd286e8 100644 --- a/kernels/builders/bvh_builder_morton.h +++ b/kernels/builders/bvh_builder_morton.h @@ -53,7 +53,7 @@ namespace embree struct __aligned(8) BuildPrim { union { - __extension__ struct { + struct { unsigned int code; //!< morton code unsigned int index; //!< i'th primitive }; diff --git a/kernels/bvh/bvh_node_qaabb.h b/kernels/bvh/bvh_node_qaabb.h index 6e00722637..99671ddc5a 100644 --- a/kernels/bvh/bvh_node_qaabb.h +++ b/kernels/bvh/bvh_node_qaabb.h @@ -118,7 +118,7 @@ namespace embree #endif union { - __extension__ struct { + struct { T lower_x[N]; //!< 8bit discretized X dimension of lower bounds of all N children T upper_x[N]; //!< 8bit discretized X dimension of upper bounds of all N children T lower_y[N]; //!< 8bit discretized Y dimension of lower bounds of all N children diff --git a/kernels/common/geometry.h b/kernels/common/geometry.h index e5f6f69336..3c7ce99564 100644 --- a/kernels/common/geometry.h +++ b/kernels/common/geometry.h @@ -656,7 +656,7 @@ namespace embree unsigned int mask; //!< for masking out geometry unsigned int modCounter_ = 1; //!< counter for every modification - used to rebuild scenes when geo is modified - __extension__ struct { + struct { GType gtype : 8; //!< geometry type GSubType gsubtype : 8; //!< geometry subtype RTCBuildQuality quality : 3; //!< build quality for geometry From e1f6a6cc0b3e02fc3e2e4aa814cf6e11c7cd6417 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 16 Jun 2026 11:14:31 +0200 Subject: [PATCH 06/19] Enable /W4 /WX on MSVC and suppress intentional-pattern warnings Add /W4 (high warning level) and /WX (warnings as errors) to the MSVC build. Suppress a curated set of warnings that fire on intentional patterns throughout the codebase: /wd4100 - unreferenced formal parameter (template/virtual boilerplate) /wd4127 - constant conditional expression (template/SIMD idioms) /wd4201 - nameless struct/union (SIMD vector types) /wd4244 - narrowing conversion (geometry/SIMD math) /wd4267 - size_t narrowing (index arithmetic) /wd4324 - struct padded for alignment (SIMD alignment specifiers) /wd4512 - assignment operator not generated (const-member types) /wd4714 - __forceinline not inlined (compiler decision) /wd4702 - unreachable code (false positives in inlined templates) /wd4800 - implicit int-to-bool (flag/mask code) Also strip the CMake-injected /W3 so /W4 is unambiguous. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/cmake/msvc.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/cmake/msvc.cmake b/common/cmake/msvc.cmake index 9f08cd0f03..b30b7ce74a 100644 --- a/common/cmake/msvc.cmake +++ b/common/cmake/msvc.cmake @@ -12,6 +12,18 @@ SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /EHsc") # catch C++ exceptions SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /MP") # compile source files in parallel SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GR") # enable runtime type information (on by default) SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /Gy") # package individual functions +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /W4") # enable highest practical warning level +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /WX") # treat warnings as errors +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4100") # disable: unreferenced formal parameter (intentional in template/virtual code) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4127") # disable: conditional expression is constant (intentional in template/SIMD code) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4201") # disable: nonstandard extension used: nameless struct/union (intentional for SIMD vec types) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4244") # disable: conversion from X to Y, possible loss of data (intentional in SIMD/geometry math) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4267") # disable: conversion from size_t to smaller type (intentional in index arithmetic) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4324") # disable: structure was padded due to alignment specifier (intentional for SIMD alignment) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4512") # disable: assignment operator could not be generated (C++03 compat, types with const members) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4714") # disable: function marked __forceinline not inlined (compiler decision, not an error) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4702") # disable: unreachable code (false-positive in heavily-inlined/templated code) +SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /wd4800") # disable: implicit conversion from int to bool (intentional in flag/mask code) IF (EMBREE_STACK_PROTECTOR) SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS") # protects against return address overrides ELSE() @@ -26,6 +38,9 @@ ENDMACRO() SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEPENDENTLOADFLAG:0x2000") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEPENDENTLOADFLAG:0x2000") +# Remove CMake-injected /W3 so our /W4 is unambiguous +STRING(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS}") STRING(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) # disable native runtime checks SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DDEBUG") # enables assertions From 288bb0cb8bfbffba49ea6868fb9fda73e8ed5618 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 16 Jun 2026 11:26:51 +0200 Subject: [PATCH 07/19] Fix MSVC /W4 warnings in common library and kernels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve all MSVC warnings that fire under /W4 /WX in the core library (common/) and BVH kernels (kernels/). Changes are purely mechanical renames and casts — no logic is altered. Warning categories fixed: C4189 unused initialized local variable (alloc.h: 'done' only live inside assert, which is a no-op in Release; add (void)done) C4245 signed/unsigned mismatch (ray.mask = -1 -> 0xFFFFFFFFu, and various index/count assignments) C4456 local declaration hides outer local (loop-variable shadowing) C4457 local declaration hides function parameter C4458 local declaration hides class member (lambda captures, etc.) C4459 local declaration hides global (parameter named same as global) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/algorithms/parallel_filter.h | 4 +- common/algorithms/parallel_for_for.h | 12 +- common/algorithms/parallel_sort.h | 20 +- common/lexers/stream.h | 2 +- common/lexers/tokenstream.cpp | 4 +- common/simd/vfloat16_avx512.h | 2 +- common/sys/alloc.h | 5 +- common/sys/barrier.cpp | 4 +- common/sys/barrier.h | 4 +- common/sys/ref.h | 2 +- kernels/builders/bvh_builder_morton.h | 8 +- kernels/builders/bvh_builder_msmblur.h | 10 +- kernels/builders/bvh_builder_sah.h | 6 +- .../heuristic_binning_array_unaligned.h | 9 +- kernels/builders/heuristic_strand_array.h | 4 +- kernels/builders/primref_mb.h | 4 +- kernels/builders/primrefgen_presplit.h | 1 + kernels/bvh/bvh.cpp | 15 +- kernels/bvh/bvh_builder_morton.cpp | 56 +++--- kernels/bvh/bvh_builder_sah_mb.cpp | 20 +- kernels/bvh/bvh_builder_subdiv.cpp | 15 +- kernels/bvh/bvh_builder_twolevel.h | 6 +- kernels/bvh/bvh_intersector_hybrid.cpp | 12 +- kernels/bvh/bvh_node_ref.h | 2 +- kernels/bvh/bvh_rotate.cpp | 2 +- kernels/common/accelset.h | 38 ++-- kernels/common/alloc.h | 58 +++--- kernels/common/buffer.h | 11 +- kernels/common/default.h | 12 +- kernels/common/device.cpp | 6 +- kernels/common/geometry.h | 16 +- kernels/common/profile.h | 22 +-- kernels/common/rtcore.cpp | 13 +- kernels/common/scene_curves.cpp | 30 +-- kernels/common/scene_grid_mesh.cpp | 10 +- kernels/common/scene_grid_mesh.h | 16 +- kernels/common/scene_instance.cpp | 22 +-- kernels/common/scene_instance.h | 20 +- kernels/common/scene_instance_array.cpp | 22 +-- kernels/common/scene_instance_array.h | 20 +- kernels/common/scene_line_segments.cpp | 12 +- kernels/common/scene_line_segments.h | 26 +-- kernels/common/scene_points.cpp | 12 +- kernels/common/scene_points.h | 18 +- kernels/common/scene_quad_mesh.cpp | 10 +- kernels/common/scene_quad_mesh.h | 8 +- kernels/common/scene_subdiv_mesh.cpp | 20 +- kernels/common/scene_triangle_mesh.cpp | 10 +- kernels/common/scene_triangle_mesh.h | 8 +- kernels/common/scene_user_geometry.cpp | 6 +- kernels/common/scene_user_geometry.h | 4 +- kernels/geometry/curveNi.h | 107 +++++------ kernels/geometry/curveNi_mb.h | 174 +++++++++--------- kernels/geometry/curveNv.h | 16 +- kernels/geometry/curve_intersector_ribbon.h | 6 +- kernels/geometry/curve_intersector_sweep.h | 6 +- kernels/geometry/grid_soa.cpp | 26 +-- kernels/geometry/grid_soa.h | 6 +- kernels/geometry/instance.h | 26 +-- kernels/geometry/instance_array.h | 4 +- .../geometry/instance_array_intersector.cpp | 1 - kernels/geometry/linei.h | 30 +-- kernels/geometry/object.h | 8 +- kernels/geometry/pointi.h | 14 +- kernels/geometry/quadi.h | 14 +- kernels/geometry/quadv.h | 28 +-- kernels/geometry/subgrid.h | 2 +- kernels/geometry/triangle.h | 26 +-- kernels/geometry/trianglei.h | 14 +- kernels/geometry/trianglev.h | 24 +-- kernels/geometry/trianglev_mb.h | 10 +- kernels/subdiv/bezier_curve.h | 25 +-- kernels/subdiv/bilinear_patch.h | 14 +- kernels/subdiv/bspline_curve.h | 25 +-- kernels/subdiv/bspline_patch.h | 21 ++- kernels/subdiv/catmullclark_ring.h | 10 +- kernels/subdiv/catmullrom_curve.h | 25 +-- kernels/subdiv/gregory_patch.h | 14 +- kernels/subdiv/half_edge.h | 6 +- kernels/subdiv/patch_eval_grid.h | 8 +- kernels/subdiv/tessellation_cache.h | 2 +- 81 files changed, 692 insertions(+), 679 deletions(-) diff --git a/common/algorithms/parallel_filter.h b/common/algorithms/parallel_filter.h index 090ef164c2..92c7627685 100644 --- a/common/algorithms/parallel_filter.h +++ b/common/algorithms/parallel_filter.h @@ -78,8 +78,8 @@ namespace embree if (k0 > r1) break; Index k1 = k0+nused[i]; Index src = begin+(i+0)*(end-begin)/taskCount+nused[i]; - for (Index i=max(r0,k0); i= begin && dst < end); assert(isrc >= begin && isrc < end); data[dst++] = data[isrc]; diff --git a/common/algorithms/parallel_for_for.h b/common/algorithms/parallel_for_for.h index 7838ef11b3..5d79e792eb 100644 --- a/common/algorithms/parallel_for_for.h +++ b/common/algorithms/parallel_for_for.h @@ -41,22 +41,22 @@ namespace embree __forceinline void init ( const size_t numArrays, const SizeFunc& getSize, const size_t minStepSize ) { /* first calculate total number of elements */ - size_t N = 0; + size_t num = 0; for (size_t i=0; iN = N; + this->N = num; /* calculate number of tasks to use */ const size_t numThreads = TaskScheduler::threadCount(); - const size_t numBlocks = (N+minStepSize-1)/minStepSize; + const size_t numBlocks = (num+minStepSize-1)/minStepSize; taskCount = max(size_t(1),min(numThreads,numBlocks,size_t(ParallelForForState::MAX_TASKS))); /* calculate start (i,j) for each task */ size_t taskIndex = 0; i0[taskIndex] = 0; j0[taskIndex] = 0; - size_t k0 = (++taskIndex)*N/taskCount; + size_t k0 = (++taskIndex)*num/taskCount; for (size_t i=0, k=0; taskIndex < taskCount; i++) { assert(i> (size_t)shift) & (size_t)mask; + const size_t index = ((size_t)(Key)pSrc[i] >> (size_t)shift) & (size_t)mask; #else - const Key index = ((Key)src[i] >> shift) & mask; + const Key index = ((Key)pSrc[i] >> shift) & mask; #endif count[index]++; } } void tbbRadixIteration1(const Key shift, - const Ty* __restrict const src, + const Ty* __restrict const pSrc, Ty* __restrict const dst, const size_t threadIndex, const size_t threadCount) { @@ -381,23 +381,23 @@ namespace embree #pragma nounroll #endif for (size_t i=startID; i> (size_t)shift) & (size_t)mask; + const size_t index = ((size_t)(Key)pSrc[i] >> (size_t)shift) & (size_t)mask; #else - const size_t index = ((Key)src[i] >> shift) & mask; + const size_t index = ((Key)pSrc[i] >> shift) & mask; #endif dst[offset[index]++] = elt; } } void tbbRadixIteration(const Key shift, const bool last, - const Ty* __restrict src, Ty* __restrict dst, + const Ty* __restrict pSrc, Ty* __restrict dst, const size_t numTasks) { affinity_partitioner ap; - parallel_for_affinity(numTasks,[&] (size_t taskIndex) { tbbRadixIteration0(shift,src,dst,taskIndex,numTasks); },ap); - parallel_for_affinity(numTasks,[&] (size_t taskIndex) { tbbRadixIteration1(shift,src,dst,taskIndex,numTasks); },ap); + parallel_for_affinity(numTasks,[&] (size_t taskIndex) { tbbRadixIteration0(shift,pSrc,dst,taskIndex,numTasks); },ap); + parallel_for_affinity(numTasks,[&] (size_t taskIndex) { tbbRadixIteration1(shift,pSrc,dst,taskIndex,numTasks); },ap); } void tbbRadixSort(const size_t numTasks) diff --git a/common/lexers/stream.h b/common/lexers/stream.h index 9ad72af4e6..7c972af899 100644 --- a/common/lexers/stream.h +++ b/common/lexers/stream.h @@ -190,7 +190,7 @@ namespace embree : i(0), j(0), charNumber(0), name(std::shared_ptr(new std::string(name))) { if (argc > 0) { - for (size_t i=0; argv[0][i] && i<1024; i++) charNumber++; + for (size_t ci=0; argv[0][ci] && ci<1024; ci++) charNumber++; charNumber++; } for (ssize_t k=1; k >& cin, //< stream to read from - const std::string& alpha, //< valid characters for identifiers + const std::string& alphaChars, //< valid characters for identifiers const std::string& seps, //< characters that act as separators const std::vector& symbols) //< symbols : cin(cin), symbols(symbols) { - createCharMap(isAlphaMap,alpha); + createCharMap(isAlphaMap,alphaChars); createCharMap(isSepMap,seps); createCharMap(isStringCharMap,stringChars); } diff --git a/common/simd/vfloat16_avx512.h b/common/simd/vfloat16_avx512.h index b6160a438c..b5f0f8abae 100644 --- a/common/simd/vfloat16_avx512.h +++ b/common/simd/vfloat16_avx512.h @@ -36,7 +36,7 @@ namespace embree __forceinline vfloat() {} __forceinline vfloat(const vfloat16& t) { v = t; } - __forceinline vfloat16& operator =(const vfloat16& f) { v = f.v; return *this; } + __forceinline vfloat16& operator =(const vfloat16& rhs) { v = rhs.v; return *this; } __forceinline vfloat(const __m512& t) { v = t; } __forceinline operator __m512() const { return v; } diff --git a/common/sys/alloc.h b/common/sys/alloc.h index 5c63d0bfaf..d57b1582d2 100644 --- a/common/sys/alloc.h +++ b/common/sys/alloc.h @@ -169,7 +169,7 @@ namespace embree else { if (size_t(nextID)+1 > max_id) - return -1; + return (T)-1; return nextID++; } @@ -203,8 +203,9 @@ namespace embree void deallocate( T id ) { assert(id < nextID); - MAYBE_UNUSED auto done = IDs.insert(id).second; + auto done = IDs.insert(id).second; assert(done); + (void)done; } private: diff --git a/common/sys/barrier.cpp b/common/sys/barrier.cpp index db5b009a64..2df2f93b2a 100644 --- a/common/sys/barrier.cpp +++ b/common/sys/barrier.cpp @@ -269,10 +269,10 @@ namespace embree /* run test */ for (size_t i=0; i<1000; i++) { - for (size_t i=0; i refCounter; }; diff --git a/kernels/builders/bvh_builder_morton.h b/kernels/builders/bvh_builder_morton.h index ccafd286e8..0998681a5d 100644 --- a/kernels/builders/bvh_builder_morton.h +++ b/kernels/builders/bvh_builder_morton.h @@ -223,7 +223,7 @@ namespace embree do { /* find best child with largest number of primitives */ - size_t bestChild = -1; + size_t bestChild = (size_t)-1; size_t bestSize = 0; for (size_t i=0; i> new_vector = split(csplit,brecord.prims,lrecord.prims,rrecord.prims); - hasTimeSplits |= new_vector != nullptr; - children.split(bestChild,lrecord,rrecord,std::move(new_vector)); + Split brecord_split = find(brecord.prims); + std::unique_ptr> brecord_new_vector = split(brecord_split,brecord.prims,lrecord.prims,rrecord.prims); + hasTimeSplits |= brecord_new_vector != nullptr; + children.split(bestChild,lrecord,rrecord,std::move(brecord_new_vector)); } /* detect time_ranges that have shrunken */ diff --git a/kernels/builders/bvh_builder_sah.h b/kernels/builders/bvh_builder_sah.h index 034e067d1a..d26d2bfab6 100644 --- a/kernels/builders/bvh_builder_sah.h +++ b/kernels/builders/bvh_builder_sah.h @@ -164,7 +164,7 @@ namespace embree do { /* find best child with largest bounding box area */ - size_t bestChild = -1; + size_t bestChild = (size_t)-1; size_t bestSize = 0; for (size_t i=0; i& set) { Vec3fa axis(0,0,1); - uint64_t bestGeomPrimID = -1; + uint64_t bestGeomPrimID = (uint64_t)-1; /*! find curve with minimum ID that defines valid direction */ for (size_t i=set.begin(); i= bestGeomPrimID) continue; - const Geometry* mesh = scene->get(geomID); + const Geometry* mesh = pScene->get(geomID); const range tbounds = mesh->timeSegmentRange(set.time_range); if (tbounds.size() == 0) continue; @@ -300,3 +300,4 @@ namespace embree }; } } + diff --git a/kernels/builders/heuristic_strand_array.h b/kernels/builders/heuristic_strand_array.h index 19c7fcdaa8..b47a08d1e1 100644 --- a/kernels/builders/heuristic_strand_array.h +++ b/kernels/builders/heuristic_strand_array.h @@ -65,7 +65,7 @@ namespace embree const Split find(const range& set, size_t logBlockSize) { Vec3fa axis0(0,0,1); - uint64_t bestGeomPrimID = -1; + uint64_t bestGeomPrimID = (uint64_t)-1; /* curve with minimum ID determines first axis */ for (size_t i=set.begin(); i 0); @@ -159,7 +159,7 @@ namespace embree bbox.upper.a = primID; } - __forceinline PrimRefMB (EmptyTy empty, const LBBox3fa& bounds, unsigned int activeTimeSegments, BBox1f time_range, unsigned int totalTimeSegments, size_t id) + __forceinline PrimRefMB (EmptyTy, const LBBox3fa& bounds, unsigned int activeTimeSegments, BBox1f time_range, unsigned int totalTimeSegments, size_t id) : bbox(bounds.interpolate(0.5f)), _activeTimeSegments(activeTimeSegments), _totalTimeSegments(totalTimeSegments), time_range(time_range) { assert(activeTimeSegments > 0); diff --git a/kernels/builders/primrefgen_presplit.h b/kernels/builders/primrefgen_presplit.h index a63371235d..7e5b293f16 100644 --- a/kernels/builders/primrefgen_presplit.h +++ b/kernels/builders/primrefgen_presplit.h @@ -395,6 +395,7 @@ namespace embree splitPrimitive(prims[primrefID],splitprims,grid,subPrims,numSubPrims); const unsigned int numSubPrimsExpected MAYBE_UNUSED = preSplitItem0[j].data >> 16; + (void)numSubPrimsExpected; assert(numSubPrims-1 == numSubPrimsExpected); const size_t newID = numPrimitives + primOffset1[j-center]; diff --git a/kernels/bvh/bvh.cpp b/kernels/bvh/bvh.cpp index f6cf626465..ec3e3a950f 100644 --- a/kernels/bvh/bvh.cpp +++ b/kernels/bvh/bvh.cpp @@ -29,11 +29,11 @@ namespace embree } template - void BVHN::set (NodeRef root, const LBBox3fa& bounds, size_t numPrimitives) + void BVHN::set (NodeRef bvhRoot, const LBBox3fa& bvhBounds, size_t numPrims) { - this->root = root; - this->bounds = bounds; - this->numPrimitives = numPrimitives; + this->root = bvhRoot; + this->bounds = bvhBounds; + this->numPrimitives = numPrims; } template @@ -151,12 +151,12 @@ namespace embree if (device->verbosity(2)) { - FastAllocator::AllStatistics stat(&alloc); + FastAllocator::AllStatistics innerStat(&alloc); for (size_t i=0; ialloc); + innerStat = innerStat + FastAllocator::AllStatistics(&objects[i]->alloc); - stat.print(numPrimitives); + innerStat.print(numPrimitives); } if (device->verbosity(3)) @@ -187,4 +187,3 @@ namespace embree template class BVHN<4>; #endif } - diff --git a/kernels/bvh/bvh_builder_morton.cpp b/kernels/bvh/bvh_builder_morton.cpp index f93fa16340..4ae5abe79d 100644 --- a/kernels/bvh/bvh_builder_morton.cpp +++ b/kernels/bvh/bvh_builder_morton.cpp @@ -101,17 +101,17 @@ namespace embree /* allocate leaf node */ Triangle4* accel = (Triangle4*) alloc.malloc1(sizeof(Triangle4),BVH::byteAlignment); NodeRef ref = BVH::encodeLeaf((char*)accel,1); - vuint4 vgeomID = -1, vprimID = -1; + vuint4 vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; Vec3vf4 v0 = zero, v1 = zero, v2 = zero; - const TriangleMesh* __restrict__ const mesh = this->mesh; + const TriangleMesh* __restrict__ const pMesh = this->mesh; for (size_t i=0; itriangle(primID); - const Vec3fa& p0 = mesh->vertex(tri.v[0]); - const Vec3fa& p1 = mesh->vertex(tri.v[1]); - const Vec3fa& p2 = mesh->vertex(tri.v[2]); + const TriangleMesh::Triangle& tri = pMesh->triangle(primID); + const Vec3fa& p0 = pMesh->vertex(tri.v[0]); + const Vec3fa& p1 = pMesh->vertex(tri.v[1]); + const Vec3fa& p2 = pMesh->vertex(tri.v[2]); lower = min(lower,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2); upper = max(upper,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2); vgeomID [i] = geomID_; @@ -157,17 +157,17 @@ namespace embree /* allocate leaf node */ Triangle4v* accel = (Triangle4v*) alloc.malloc1(sizeof(Triangle4v),BVH::byteAlignment); NodeRef ref = BVH::encodeLeaf((char*)accel,1); - vuint4 vgeomID = -1, vprimID = -1; + vuint4 vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; Vec3vf4 v0 = zero, v1 = zero, v2 = zero; - const TriangleMesh* __restrict__ mesh = this->mesh; + const TriangleMesh* __restrict__ pMesh = this->mesh; for (size_t i=0; itriangle(primID); - const Vec3fa& p0 = mesh->vertex(tri.v[0]); - const Vec3fa& p1 = mesh->vertex(tri.v[1]); - const Vec3fa& p2 = mesh->vertex(tri.v[2]); + const TriangleMesh::Triangle& tri = pMesh->triangle(primID); + const Vec3fa& p0 = pMesh->vertex(tri.v[0]); + const Vec3fa& p1 = pMesh->vertex(tri.v[1]); + const Vec3fa& p2 = pMesh->vertex(tri.v[2]); lower = min(lower,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2); upper = max(upper,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2); vgeomID [i] = geomID_; @@ -213,16 +213,16 @@ namespace embree NodeRef ref = BVH::encodeLeaf((char*)accel,1); vuint4 v0 = zero, v1 = zero, v2 = zero; - vuint4 vgeomID = -1, vprimID = -1; - const TriangleMesh* __restrict__ const mesh = this->mesh; + vuint4 vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + const TriangleMesh* __restrict__ const pMesh = this->mesh; for (size_t i=0; itriangle(primID); - const Vec3fa& p0 = mesh->vertex(tri.v[0]); - const Vec3fa& p1 = mesh->vertex(tri.v[1]); - const Vec3fa& p2 = mesh->vertex(tri.v[2]); + const TriangleMesh::Triangle& tri = pMesh->triangle(primID); + const Vec3fa& p0 = pMesh->vertex(tri.v[0]); + const Vec3fa& p1 = pMesh->vertex(tri.v[1]); + const Vec3fa& p2 = pMesh->vertex(tri.v[2]); lower = min(lower,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2); upper = max(upper,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2); vgeomID[i] = geomID_; @@ -236,7 +236,7 @@ namespace embree for (size_t i=items; i<4; i++) { vgeomID[i] = vgeomID[0]; - vprimID[i] = -1; + vprimID[i] = (unsigned int)-1; v0[i] = 0; v1[i] = 0; v2[i] = 0; @@ -277,18 +277,18 @@ namespace embree Quad4v* accel = (Quad4v*) alloc.malloc1(sizeof(Quad4v),BVH::byteAlignment); NodeRef ref = BVH::encodeLeaf((char*)accel,1); - vuint4 vgeomID = -1, vprimID = -1; + vuint4 vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; Vec3vf4 v0 = zero, v1 = zero, v2 = zero, v3 = zero; - const QuadMesh* __restrict__ mesh = this->mesh; + const QuadMesh* __restrict__ pMesh = this->mesh; for (size_t i=0; iquad(primID); - const Vec3fa& p0 = mesh->vertex(tri.v[0]); - const Vec3fa& p1 = mesh->vertex(tri.v[1]); - const Vec3fa& p2 = mesh->vertex(tri.v[2]); - const Vec3fa& p3 = mesh->vertex(tri.v[3]); + const QuadMesh::Quad& tri = pMesh->quad(primID); + const Vec3fa& p0 = pMesh->vertex(tri.v[0]); + const Vec3fa& p1 = pMesh->vertex(tri.v[1]); + const Vec3fa& p2 = pMesh->vertex(tri.v[2]); + const Vec3fa& p3 = pMesh->vertex(tri.v[3]); lower = min(lower,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2,(vfloat4)p3); upper = max(upper,(vfloat4)p0,(vfloat4)p1,(vfloat4)p2,(vfloat4)p3); vgeomID [i] = geomID_; @@ -332,14 +332,14 @@ namespace embree /* allocate leaf node */ Object* accel = (Object*) alloc.malloc1(items*sizeof(Object),BVH::byteAlignment); NodeRef ref = BVH::encodeLeaf((char*)accel,items); - const UserGeometry* mesh = this->mesh; + const UserGeometry* pMesh = this->mesh; BBox3fa bounds = empty; for (size_t i=0; ibounds(primID)); + bounds.extend(pMesh->bounds(primID)); new (&accel[i]) Object(geomID_,primID); } diff --git a/kernels/bvh/bvh_builder_sah_mb.cpp b/kernels/bvh/bvh_builder_sah_mb.cpp index 3d556419ed..0521f86c40 100644 --- a/kernels/bvh/bvh_builder_sah_mb.cpp +++ b/kernels/bvh/bvh_builder_sah_mb.cpp @@ -229,7 +229,7 @@ namespace embree __forceinline GridRecalculatePrimRef (Scene* scene, const SubGridBuildData * const sgrids) : scene(scene), sgrids(sgrids) {} - __forceinline PrimRefMB operator() (const PrimRefMB& prim, const BBox1f time_range) const + __forceinline PrimRefMB operator() (const PrimRefMB& prim, const BBox1f trange) const { const unsigned int geomID = prim.geomID(); const GridMesh* mesh = scene->get(geomID); @@ -238,13 +238,13 @@ namespace embree const unsigned int primID = subgrid.primID; const size_t x = subgrid.x(); const size_t y = subgrid.y(); - const LBBox3fa lbounds = mesh->linearBounds(mesh->grid(primID),x,y,time_range); + const LBBox3fa lbounds = mesh->linearBounds(mesh->grid(primID),x,y,trange); const unsigned num_time_segments = mesh->numTimeSegments(); - const range tbounds = mesh->timeSegmentRange(time_range); + const range tbounds = mesh->timeSegmentRange(trange); return PrimRefMB (lbounds, tbounds.size(), mesh->time_range, num_time_segments, geomID, buildID); } - __forceinline LBBox3fa linearBounds(const PrimRefMB& prim, const BBox1f time_range) const { + __forceinline LBBox3fa linearBounds(const PrimRefMB& prim, const BBox1f trange) const { const unsigned int geomID = prim.geomID(); const GridMesh* mesh = scene->get(geomID); const unsigned int buildID = prim.primID(); @@ -252,7 +252,7 @@ namespace embree const unsigned int primID = subgrid.primID; const size_t x = subgrid.x(); const size_t y = subgrid.y(); - return mesh->linearBounds(mesh->grid(primID),x,y,time_range); + return mesh->linearBounds(mesh->grid(primID),x,y,trange); } }; @@ -312,9 +312,9 @@ namespace embree x[pos] = sgrid_bd.sx; y[pos] = sgrid_bd.sy; primID[pos] = sgrid_bd.primID; - const size_t x = sgrid_bd.x(); - const size_t y = sgrid_bd.y(); - LBBox3fa newBounds = mesh->linearBounds(mesh->grid(sgrid_bd.primID),x,y,current.prims.time_range); + const size_t sx = sgrid_bd.x(); + const size_t sy = sgrid_bd.y(); + LBBox3fa newBounds = mesh->linearBounds(mesh->grid(sgrid_bd.primID),sx,sy,current.prims.time_range); allBounds.extend(newBounds); bounds0[pos] = newBounds.bounds0; bounds1[pos] = newBounds.bounds1; @@ -489,11 +489,11 @@ namespace embree return pinfo; } - PrimInfoMB createPrimRefArrayMSMBlurGrid(Scene* scene, mvector& prims, BuildProgressMonitor& progressMonitor, BBox1f t0t1 = BBox1f(0.0f,1.0f)) + PrimInfoMB createPrimRefArrayMSMBlurGrid(Scene* pScene, mvector& prims, BuildProgressMonitor& progressMonitor, BBox1f t0t1 = BBox1f(0.0f,1.0f)) { /* first run to get #primitives */ ParallelForForPrefixSumState pstate; - Scene::Iterator iter(scene); + Scene::Iterator iter(pScene); pstate.init(iter,size_t(1024)); /* iterate over all meshes in the scene */ diff --git a/kernels/bvh/bvh_builder_subdiv.cpp b/kernels/bvh/bvh_builder_subdiv.cpp index fd7a208276..3aac43ee76 100644 --- a/kernels/bvh/bvh_builder_subdiv.cpp +++ b/kernels/bvh/bvh_builder_subdiv.cpp @@ -194,19 +194,19 @@ namespace embree __forceinline SubdivRecalculatePrimRef (mvector& bounds, SubdivPatch1* patches) : bounds(bounds), patches(patches) {} - __forceinline PrimRefMB operator() (const size_t patchIndexMB, const BBox1f prim_time_range, const unsigned prim_num_time_segments, const BBox1f time_range) const + __forceinline PrimRefMB operator() (const size_t patchIndexMB, const BBox1f prim_time_range, const unsigned prim_num_time_segments, const BBox1f trange) const { - const LBBox3fa lbounds = LBBox3fa([&] (size_t itime) { return bounds[patchIndexMB+itime]; }, time_range, prim_time_range, (float)prim_num_time_segments); - const range tbounds = getTimeSegmentRange(time_range, prim_time_range, (float)prim_num_time_segments); + const LBBox3fa lbounds = LBBox3fa([&] (size_t itime) { return bounds[patchIndexMB+itime]; }, trange, prim_time_range, (float)prim_num_time_segments); + const range tbounds = getTimeSegmentRange(trange, prim_time_range, (float)prim_num_time_segments); return PrimRefMB (empty, lbounds, tbounds.size(), prim_time_range, prim_num_time_segments, patchIndexMB); } - __forceinline PrimRefMB operator() (const PrimRefMB& prim, const BBox1f time_range) const { - return operator()(prim.ID(),prim.time_range,prim.totalTimeSegments(),time_range); + __forceinline PrimRefMB operator() (const PrimRefMB& prim, const BBox1f trange) const { + return operator()(prim.ID(),prim.time_range,prim.totalTimeSegments(),trange); } - __forceinline LBBox3fa linearBounds(const PrimRefMB& prim, const BBox1f time_range) const { - return LBBox3fa([&] (size_t itime) { return bounds[prim.ID()+itime]; }, time_range, prim.time_range, (float)prim.totalTimeSegments()); + __forceinline LBBox3fa linearBounds(const PrimRefMB& prim, const BBox1f trange) const { + return LBBox3fa([&] (size_t itime) { return bounds[prim.ID()+itime]; }, trange, prim.time_range, (float)prim.totalTimeSegments()); } }; @@ -301,6 +301,7 @@ namespace embree auto createLeafFunc = [&] (const BVHBuilderMSMBlur::BuildRecord& current, const Allocator& alloc) -> NodeRecordMB4D { mvector& prims = *current.prims.prims; size_t items MAYBE_UNUSED = current.prims.size(); + (void)items; assert(items == 1); const size_t patchIndexMB = prims[current.prims.begin()].ID(); SubdivPatch1Base& patch = subdiv_patches[patchIndexMB+0]; diff --git a/kernels/bvh/bvh_builder_twolevel.h b/kernels/bvh/bvh_builder_twolevel.h index 97ae41a87d..74ef0e7320 100644 --- a/kernels/bvh/bvh_builder_twolevel.h +++ b/kernels/bvh/bvh_builder_twolevel.h @@ -81,10 +81,10 @@ namespace embree }; - __forceinline size_t openBuildRef(BuildRef &bref, BuildRef *const refs) { + __forceinline size_t openBuildRef(BuildRef &bref, BuildRef *const pRefs) { if (bref.node.isLeaf()) { - refs[0] = bref; + pRefs[0] = bref; return 1; } NodeRef ref = bref.node; @@ -94,7 +94,7 @@ namespace embree size_t n = 0; for (size_t i=0; ichild(i) == BVH::emptyNode) continue; - refs[i] = BuildRef(node->bounds(i),node->child(i),geomID,numPrims); + pRefs[i] = BuildRef(node->bounds(i),node->child(i),geomID,numPrims); n++; } assert(n > 1); diff --git a/kernels/bvh/bvh_intersector_hybrid.cpp b/kernels/bvh/bvh_intersector_hybrid.cpp index e7b22af2dd..2720ae26d0 100644 --- a/kernels/bvh/bvh_intersector_hybrid.cpp +++ b/kernels/bvh/bvh_intersector_hybrid.cpp @@ -208,7 +208,8 @@ namespace embree stack_near[0] = inf; stack_node[1] = bvh->root; stack_near[1] = tray.tnear; - NodeRef* stackEnd MAYBE_UNUSED = stack_node+stackSizeChunk; + NodeRef* stackEnd = stack_node+stackSizeChunk; + (void)stackEnd; NodeRef* __restrict__ sptr_node = stack_node + 2; vfloat* __restrict__ sptr_near = stack_near + 2; @@ -642,7 +643,7 @@ namespace embree tray.tfar = select(valid, org_ray_tfar , vfloat(neg_inf)); vbool terminated = !valid; - const vfloat inf = vfloat(pos_inf); + const vfloat inf_val = vfloat(pos_inf); /* determine switch threshold based on flags */ const size_t switchThreshold = (context->user && context->isCoherent()) ? 2 : switchThresholdIncoherent; @@ -651,10 +652,11 @@ namespace embree vfloat stack_near[stackSizeChunk]; NodeRef stack_node[stackSizeChunk]; stack_node[0] = BVH::invalidNode; - stack_near[0] = inf; + stack_near[0] = inf_val; stack_node[1] = bvh->root; stack_near[1] = tray.tnear; - NodeRef* stackEnd MAYBE_UNUSED = stack_node+stackSizeChunk; + NodeRef* stackEnd = stack_node+stackSizeChunk; + (void)stackEnd; NodeRef* __restrict__ sptr_node = stack_node + 2; vfloat* __restrict__ sptr_near = stack_near + 2; @@ -724,7 +726,7 @@ namespace embree { assert(sptr_node < stackEnd); assert(child != BVH::emptyNode); - const vfloat childDist = select(lhit, lnearP, inf); + const vfloat childDist = select(lhit, lnearP, inf_val); /* push 'cur' node onto stack and continue with hit child */ if (likely(cur != BVH::emptyNode)) { diff --git a/kernels/bvh/bvh_node_ref.h b/kernels/bvh/bvh_node_ref.h index 6f6da758de..e6180d1d4e 100644 --- a/kernels/bvh/bvh_node_ref.h +++ b/kernels/bvh/bvh_node_ref.h @@ -66,7 +66,7 @@ namespace embree static const size_t byteNodeAlignment = 4*N; /*! highest address bit is used as barrier for some algorithms */ - static const size_t barrier_mask = (1LL << (8*sizeof(size_t)-1)); + static const size_t barrier_mask = (size_t(1) << (8*sizeof(size_t)-1)); /*! Masks the bits that store the number of items per leaf. */ static const size_t align_mask = byteAlignment-1; diff --git a/kernels/bvh/bvh_rotate.cpp b/kernels/bvh/bvh_rotate.cpp index 460bd60c62..2ec6727559 100644 --- a/kernels/bvh/bvh_rotate.cpp +++ b/kernels/bvh/bvh_rotate.cpp @@ -40,7 +40,7 @@ namespace embree (child2child) of a different second child (child2), and swap child1 and child2child. We perform the best such swap. */ float bestArea = 0; - size_t bestChild1 = -1, bestChild2 = -1, bestChild2Child = -1; + size_t bestChild1 = (size_t)-1, bestChild2 = (size_t)-1, bestChild2Child = (size_t)-1; for (size_t c2=0; c2<4; c2++) { /*! ignore leaf nodes as we cannot descent into them */ diff --git a/kernels/common/accelset.h b/kernels/common/accelset.h index f78830e397..f1f27044cd 100644 --- a/kernels/common/accelset.h +++ b/kernels/common/accelset.h @@ -123,9 +123,9 @@ namespace embree } /*! calculates the linear bounds of the i'th primitive for the specified time range */ - __forceinline bool linearBounds(size_t i, const BBox1f& time_range, LBBox3fa& bbox) const { - if (!valid(i, timeSegmentRange(time_range))) return false; - bbox = linearBounds(i, time_range); + __forceinline bool linearBounds(size_t i, const BBox1f& trange, LBBox3fa& bbox) const { + if (!valid(i, timeSegmentRange(trange))) return false; + bbox = linearBounds(i, trange); return true; } @@ -146,9 +146,9 @@ namespace embree { assert(primID < size()); - int mask = -1; + int rayMask = -1; IntersectFunctionNArguments args; - args.valid = &mask; + args.valid = &rayMask; args.geometryUserPtr = userPtr; args.context = context->user; args.rayhit = (RTCRayHitN*)&ray; @@ -168,7 +168,7 @@ namespace embree assert(intersectFunc); intersectFunc(&args); - return mask != 0; + return rayMask != 0; } /*! Tests if single ray is occluded by the scene. */ @@ -176,9 +176,9 @@ namespace embree { assert(primID < size()); - int mask = -1; + int rayMask = -1; OccludedFunctionNArguments args; - args.valid = &mask; + args.valid = &rayMask; args.geometryUserPtr = userPtr; args.context = context->user; args.ray = (RTCRayN*)&ray; @@ -198,7 +198,7 @@ namespace embree assert(occludedFunc); occludedFunc(&args); - return mask != 0; + return rayMask != 0; } /*! Intersects a single ray with the scene. */ @@ -206,9 +206,9 @@ namespace embree { assert(primID < size()); - int mask = -1; + int rayMask = -1; IntersectFunctionNArguments args; - args.valid = &mask; + args.valid = &rayMask; args.geometryUserPtr = userPtr; args.context = context->user; args.rayhit = (RTCRayHitN*)&ray; @@ -235,7 +235,7 @@ namespace embree intersectFunc(&args); forward_scene = args.forward_scene; - return mask != 0; + return rayMask != 0; } /*! Tests if single ray is occluded by the scene. */ @@ -243,9 +243,9 @@ namespace embree { assert(primID < size()); - int mask = -1; + int rayMask = -1; OccludedFunctionNArguments args; - args.valid = &mask; + args.valid = &rayMask; args.geometryUserPtr = userPtr; args.context = context->user; args.ray = (RTCRayN*)&ray; @@ -272,7 +272,7 @@ namespace embree occludedFunc(&args); forward_scene = args.forward_scene; - return mask != 0; + return rayMask != 0; } /*! Intersects a packet of K rays with the scene. */ @@ -281,9 +281,9 @@ namespace embree { assert(primID < size()); - vint mask = valid.mask32(); + vint validMask = valid.mask32(); IntersectFunctionNArguments args; - args.valid = (int*)&mask; + args.valid = (int*)&validMask; args.geometryUserPtr = userPtr; args.context = context->user; args.rayhit = (RTCRayHitN*)&ray; @@ -310,9 +310,9 @@ namespace embree { assert(primID < size()); - vint mask = valid.mask32(); + vint validMask = valid.mask32(); OccludedFunctionNArguments args; - args.valid = (int*)&mask; + args.valid = (int*)&validMask; args.geometryUserPtr = userPtr; args.context = context->user; args.ray = (RTCRayN*)&ray; diff --git a/kernels/common/alloc.h b/kernels/common/alloc.h index 759bc5f31a..bed067d7e4 100644 --- a/kernels/common/alloc.h +++ b/kernels/common/alloc.h @@ -570,19 +570,19 @@ namespace embree Statistics () : bytesUsed(0), bytesFree(0), bytesWasted(0) {} - Statistics (size_t bytesUsed, size_t bytesFree, size_t bytesWasted) - : bytesUsed(bytesUsed), bytesFree(bytesFree), bytesWasted(bytesWasted) {} + Statistics (size_t bytesUsed_, size_t bytesFree_, size_t bytesWasted_) + : bytesUsed(bytesUsed_), bytesFree(bytesFree_), bytesWasted(bytesWasted_) {} - Statistics (FastAllocator* alloc, AllocationType atype, bool huge_pages = false) + Statistics (FastAllocator* alloc, AllocationType alloc_type, bool huge_pages = false) : bytesUsed(0), bytesFree(0), bytesWasted(0) { - Block* usedBlocks = alloc->usedBlocks.load(); - Block* freeBlocks = alloc->freeBlocks.load(); - if (usedBlocks) bytesUsed += usedBlocks->getUsedBytes(atype,huge_pages); - if (freeBlocks) bytesFree += freeBlocks->getAllocatedBytes(atype,huge_pages); - if (usedBlocks) bytesFree += usedBlocks->getFreeBytes(atype,huge_pages); - if (freeBlocks) bytesWasted += freeBlocks->getWastedBytes(atype,huge_pages); - if (usedBlocks) bytesWasted += usedBlocks->getWastedBytes(atype,huge_pages); + Block* pUsedBlocks = alloc->usedBlocks.load(); + Block* pFreeBlocks = alloc->freeBlocks.load(); + if (pUsedBlocks) bytesUsed += pUsedBlocks->getUsedBytes(alloc_type,huge_pages); + if (pFreeBlocks) bytesFree += pFreeBlocks->getAllocatedBytes(alloc_type,huge_pages); + if (pUsedBlocks) bytesFree += pUsedBlocks->getFreeBytes(alloc_type,huge_pages); + if (pFreeBlocks) bytesWasted += pFreeBlocks->getWastedBytes(alloc_type,huge_pages); + if (pUsedBlocks) bytesWasted += pUsedBlocks->getWastedBytes(alloc_type,huge_pages); } std::string str(size_t numPrimitives) @@ -614,8 +614,8 @@ namespace embree size_t bytesWasted; }; - Statistics getStatistics(AllocationType atype, bool huge_pages = false) { - return Statistics(this,atype,huge_pages); + Statistics getStatistics(AllocationType alloc_type, bool huge_pages = false) { + return Statistics(this,alloc_type,huge_pages); } size_t getUsedBytes() { @@ -819,9 +819,9 @@ namespace embree { Block* block = this; while (block) { - Block* next = block->next; + Block* nextBlock = block->next; block->clear_block(device, useUSM); - block = next; + block = nextBlock; } } @@ -845,11 +845,11 @@ namespace embree } } - void* malloc(MemoryMonitorInterface* device, size_t& bytes_in, size_t align, bool partial) + void* malloc(MemoryMonitorInterface* device, size_t& bytes_in, size_t alignment, bool partial) { size_t bytes = bytes_in; - assert(align <= maxAlignment); - bytes = (bytes+(align-1)) & ~(align-1); + assert(alignment <= maxAlignment); + bytes = (bytes+(alignment-1)) & ~(alignment-1); if (unlikely(cur+bytes > reserveEnd && !partial)) return nullptr; const size_t i = cur.fetch_add(bytes); if (unlikely(i+bytes > reserveEnd && !partial)) return nullptr; @@ -900,37 +900,37 @@ namespace embree else return atype_i == atype; } - size_t getUsedBytes(AllocationType atype, bool huge_pages = false) const { + size_t getUsedBytes(AllocationType alloc_type, bool use_huge_pages = false) const { size_t bytes = 0; for (const Block* block = this; block; block = block->next) { - if (!block->hasType(atype,huge_pages)) continue; + if (!block->hasType(alloc_type,use_huge_pages)) continue; bytes += block->getBlockUsedBytes(); } return bytes; } - size_t getFreeBytes(AllocationType atype, bool huge_pages = false) const { + size_t getFreeBytes(AllocationType alloc_type, bool use_huge_pages = false) const { size_t bytes = 0; for (const Block* block = this; block; block = block->next) { - if (!block->hasType(atype,huge_pages)) continue; + if (!block->hasType(alloc_type,use_huge_pages)) continue; bytes += block->getBlockFreeBytes(); } return bytes; } - size_t getWastedBytes(AllocationType atype, bool huge_pages = false) const { + size_t getWastedBytes(AllocationType alloc_type, bool use_huge_pages = false) const { size_t bytes = 0; for (const Block* block = this; block; block = block->next) { - if (!block->hasType(atype,huge_pages)) continue; + if (!block->hasType(alloc_type,use_huge_pages)) continue; bytes += block->getBlockWastedBytes(); } return bytes; } - size_t getAllocatedBytes(AllocationType atype, bool huge_pages = false) const { + size_t getAllocatedBytes(AllocationType alloc_type, bool use_huge_pages = false) const { size_t bytes = 0; for (const Block* block = this; block; block = block->next) { - if (!block->hasType(atype,huge_pages)) continue; + if (!block->hasType(alloc_type,use_huge_pages)) continue; bytes += block->getBlockAllocatedBytes(); } return bytes; @@ -948,10 +948,10 @@ namespace embree else if (atype == EMBREE_OS_MALLOC) std::cout << "O"; else if (atype == SHARED) std::cout << "S"; if (huge_pages) std::cout << "H"; - size_t bytesUsed = getBlockUsedBytes(); - size_t bytesFree = getBlockFreeBytes(); - size_t bytesWasted = getBlockWastedBytes(); - std::cout << "[" << bytesUsed << ", " << bytesFree << ", " << bytesWasted << "] "; + size_t blockBytesUsed = getBlockUsedBytes(); + size_t blockBytesFree = getBlockFreeBytes(); + size_t blockBytesWasted = getBlockWastedBytes(); + std::cout << "[" << blockBytesUsed << ", " << blockBytesFree << ", " << blockBytesWasted << "] "; } public: diff --git a/kernels/common/buffer.h b/kernels/common/buffer.h index 984ed43ddd..1b92e46698 100644 --- a/kernels/common/buffer.h +++ b/kernels/common/buffer.h @@ -18,16 +18,16 @@ namespace embree class Buffer : public RefCount { private: - char* alloc(void* ptr_in, bool &shared, EmbreeMemoryType memoryType) + char* alloc(void* ptr_in, bool &isShared, EmbreeMemoryType memoryType) { if (ptr_in) { - shared = true; + isShared = true; return (char*)ptr_in; } else { - shared = false; + isShared = false; device->memoryMonitor(this->bytes(), false); size_t b = (this->bytes()+15) & ssize_t(-16); return (char*)device->malloc(b,16,memoryType); @@ -359,7 +359,10 @@ namespace embree __forceinline void checkPadding16() const { if (ptr_ofs && num) - volatile int MAYBE_UNUSED w = *((int*)getPtr(size()-1)+3); // FIXME: is failing hard avoidable? + { + volatile int w = *((int*)getPtr(size()-1)+3); // FIXME: is failing hard avoidable? + (void)w; + } } public: diff --git a/kernels/common/default.h b/kernels/common/default.h index 3b00ad3c88..cc075d8ca5 100644 --- a/kernels/common/default.h +++ b/kernels/common/default.h @@ -247,20 +247,20 @@ namespace embree } /* calculate overlapping time segment range */ - __forceinline range getTimeSegmentRange(const BBox1f& time_range, float numTimeSegments) + __forceinline range getTimeSegmentRange(const BBox1f& trange, float numTimeSegments) { const float round_up = 1.0f+2.0f*float(ulp); // corrects inaccuracies to precisely match time step const float round_down = 1.0f-2.0f*float(ulp); - const int itime_lower = (int)max(floor(round_up *time_range.lower*numTimeSegments), 0.0f); - const int itime_upper = (int)min(ceil (round_down*time_range.upper*numTimeSegments), numTimeSegments); + const int itime_lower = (int)max(floor(round_up *trange.lower*numTimeSegments), 0.0f); + const int itime_upper = (int)min(ceil (round_down*trange.upper*numTimeSegments), numTimeSegments); return make_range(itime_lower, itime_upper); } /* calculate overlapping time segment range */ - __forceinline range getTimeSegmentRange(const BBox1f& range, BBox1f time_range, float numTimeSegments) + __forceinline range getTimeSegmentRange(const BBox1f& range, BBox1f trange, float numTimeSegments) { - const float lower = (range.lower-time_range.lower)/time_range.size(); - const float upper = (range.upper-time_range.lower)/time_range.size(); + const float lower = (range.lower-trange.lower)/trange.size(); + const float upper = (range.upper-trange.lower)/trange.size(); return getTimeSegmentRange(BBox1f(lower,upper),numTimeSegments); } } diff --git a/kernels/common/device.cpp b/kernels/common/device.cpp index fb684e5801..facea679d7 100644 --- a/kernels/common/device.cpp +++ b/kernels/common/device.cpp @@ -368,13 +368,13 @@ namespace embree #endif } - void Device::initTaskingSystem(size_t numThreads) + void Device::initTaskingSystem(size_t requestedNumThreads) { Lock lock(g_mutex); - if (numThreads == 0) + if (requestedNumThreads == 0) g_num_threads_map[this] = std::numeric_limits::max(); else - g_num_threads_map[this] = numThreads; + g_num_threads_map[this] = requestedNumThreads; /* create task scheduler */ size_t maxNumThreads = getMaxNumThreads(); diff --git a/kernels/common/geometry.h b/kernels/common/geometry.h index 3c7ce99564..7fe7080b54 100644 --- a/kernels/common/geometry.h +++ b/kernels/common/geometry.h @@ -457,7 +457,7 @@ namespace embree /*! Sets ray mask. */ - virtual void setMask(unsigned mask) { + virtual void setMask(unsigned msk) { throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); } @@ -519,7 +519,7 @@ namespace embree public: /*! Set bounds function. */ - virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) { + virtual void setBoundsFunction (RTCBoundsFunction bounds, void* ptr) { throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); } @@ -599,7 +599,7 @@ namespace embree throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry"); } - virtual LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f time_range) const { + virtual LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f trange) const { throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry"); } @@ -623,19 +623,19 @@ namespace embree throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry"); } - virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const { + virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry"); } - virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range, const SubGridBuildData * const sgrids) const { - return vlinearBounds(primID,time_range); + virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange, const SubGridBuildData * const sgrids) const { + return vlinearBounds(primID,trange); } - virtual LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const { + virtual LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& trange) const { throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry"); } - virtual LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const { + virtual LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& trange) const { throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry"); } diff --git a/kernels/common/profile.h b/kernels/common/profile.h index 5ef7f6ec0f..718026a607 100644 --- a/kernels/common/profile.h +++ b/kernels/common/profile.h @@ -16,11 +16,11 @@ namespace embree ProfileTimer (const size_t numSkip) : i(0), j(0), maxJ(0), numSkip(numSkip), t0(0) { - for (size_t i=0; iget(i,query1); @@ -2132,7 +2131,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte RTC_TRACE(rtcGetGeometryFirstHalfEdge); return geometry->getFirstHalfEdge(faceID); RTC_CATCH_END2(geometry); - return -1; + return (unsigned int)-1; } RTC_API unsigned int rtcGetGeometryFace(RTCGeometry hgeometry, unsigned int edgeID) @@ -2142,7 +2141,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte RTC_TRACE(rtcGetGeometryFace); return geometry->getFace(edgeID); RTC_CATCH_END2(geometry); - return -1; + return (unsigned int)-1; } RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry hgeometry, unsigned int edgeID) @@ -2152,7 +2151,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte RTC_TRACE(rtcGetGeometryNextHalfEdge); return geometry->getNextHalfEdge(edgeID); RTC_CATCH_END2(geometry); - return -1; + return (unsigned int)-1; } RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry hgeometry, unsigned int edgeID) @@ -2162,7 +2161,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte RTC_TRACE(rtcGetGeometryPreviousHalfEdge); return geometry->getPreviousHalfEdge(edgeID); RTC_CATCH_END2(geometry); - return -1; + return (unsigned int)-1; } RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry hgeometry, unsigned int topologyID, unsigned int edgeID) @@ -2172,7 +2171,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte RTC_TRACE(rtcGetGeometryOppositeHalfEdge); return geometry->getOppositeHalfEdge(topologyID,edgeID); RTC_CATCH_END2(geometry); - return -1; + return (unsigned int)-1; } RTC_API void rtcSetGeometryOccludedFunction (RTCGeometry hgeometry, RTCOccludedFunctionN occluded) @@ -2261,7 +2260,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"inputs are from different devices"); return scene->bind(RTC_INVALID_GEOMETRY_ID,geometry); RTC_CATCH_END2(scene); - return -1; + return (unsigned int)-1; } RTC_API void rtcAttachGeometryByID (RTCScene hscene, RTCGeometry hgeometry, unsigned int geomID) diff --git a/kernels/common/scene_curves.cpp b/kernels/common/scene_curves.cpp index df2637932d..bae8d7f42b 100644 --- a/kernels/common/scene_curves.cpp +++ b/kernels/common/scene_curves.cpp @@ -29,16 +29,16 @@ namespace embree resizeBuffers(numTimeSteps); } - void CurveGeometry::setMask (unsigned mask) + void CurveGeometry::setMask (unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } - void CurveGeometry::setNumTimeSteps (unsigned int numTimeSteps) + void CurveGeometry::setNumTimeSteps (unsigned int newNumTimeSteps) { - resizeBuffers(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + resizeBuffers(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void CurveGeometry::setVertexAttributeCount (unsigned int N) @@ -487,12 +487,12 @@ namespace embree return frame(axisz); } - LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f time_range) const + LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f trange) const { Vec3fa axisz(0,0,1); Vec3fa axisy(0,1,0); - const range tbounds = this->timeSegmentRange(time_range); + const range tbounds = this->timeSegmentRange(trange); if (tbounds.size() == 0) return frame(axisz); const size_t t = (tbounds.begin()+tbounds.end())/2; @@ -596,10 +596,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(this->time_range, time_range); + const BBox1f t0t1 = BBox1f::intersect(this->time_range, trange); if (t0t1.empty()) return pinfo; for (size_t j=r.begin(); jmask = mask; + this->mask = newMask; Geometry::update(); } - void GridMesh::setNumTimeSteps (unsigned int numTimeSteps) + void GridMesh::setNumTimeSteps (unsigned int newNumTimeSteps) { - vertices.resize(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + vertices.resize(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void GridMesh::setVertexAttributeCount (unsigned int N) diff --git a/kernels/common/scene_grid_mesh.h b/kernels/common/scene_grid_mesh.h index cd374912f5..9e6b10ffd9 100644 --- a/kernels/common/scene_grid_mesh.h +++ b/kernels/common/scene_grid_mesh.h @@ -123,12 +123,12 @@ namespace embree const vfloat Q0 = select(left,p0,p2); const vfloat Q1 = select(left,p1,p3); const vfloat Q2 = select(left,p3,p1); - const vfloat U = select(left,u,vfloat(1.0f)-u); - const vfloat V = select(left,v,vfloat(1.0f)-v); - const vfloat W = 1.0f-U-V; + const vfloat baryU = select(left,u,vfloat(1.0f)-u); + const vfloat baryV = select(left,v,vfloat(1.0f)-v); + const vfloat W = 1.0f-baryU-baryV; if (P) { - mem>::storeu(valid,P+i,madd(W,Q0,madd(U,Q1,V*Q2))); + mem>::storeu(valid,P+i,madd(W,Q0,madd(baryU,Q1,baryV*Q2))); } if (dPdu) { assert(dPdu); mem>::storeu(valid,dPdu+i,select(left,Q1-Q0,Q0-Q1)*rcp_grid_width); @@ -386,12 +386,12 @@ namespace embree GridMeshISA (Device* device) : GridMesh(device) {} - LBBox3fa vlinearBounds(size_t buildID, const BBox1f& time_range, const SubGridBuildData * const sgrids) const override { + LBBox3fa vlinearBounds(size_t buildID, const BBox1f& trange, const SubGridBuildData * const sgrids) const override { const SubGridBuildData &subgrid = sgrids[buildID]; const unsigned int primID = subgrid.primID; const size_t x = subgrid.x(); const size_t y = subgrid.y(); - return linearBounds(grid(primID),x,y,time_range); + return linearBounds(grid(primID),x,y,trange); } #if defined(EMBREE_SYCL_SUPPORT) @@ -436,9 +436,9 @@ namespace embree } #if defined(EMBREE_SYCL_SUPPORT) - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const override + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const override { - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); PrimInfo pinfo(empty); for (size_t j=r.begin(); jmask = mask; + this->mask = newMask; Geometry::update(); } @@ -339,11 +339,11 @@ namespace embree { LBBox3fa lbbox = empty; /* normalize global time_range_in to local geom_time_range */ - const BBox1f time_range((time_range_in.lower-geom_time_range.lower)/geom_time_range.size(), - (time_range_in.upper-geom_time_range.lower)/geom_time_range.size()); + const BBox1f local_time_range((time_range_in.lower-geom_time_range.lower)/geom_time_range.size(), + (time_range_in.upper-geom_time_range.lower)/geom_time_range.size()); - const float lower = time_range.lower*geom_time_segments; - const float upper = time_range.upper*geom_time_segments; + const float lower = local_time_range.lower*geom_time_segments; + const float upper = local_time_range.upper*geom_time_segments; const float ilowerf = floor(lower); const float iupperf = ceil(upper); const float ilowerfc = max(0.0f,ilowerf); @@ -358,8 +358,8 @@ namespace embree if (iupper_iter-ilower_iter == 1) { - const float f0 = (ilowerc / geom_time_segments - time_range.lower) / time_range.size(); - const float f1 = (iupperc / geom_time_segments - time_range.lower) / time_range.size(); + const float f0 = (ilowerc / geom_time_segments - local_time_range.lower) / local_time_range.size(); + const float f1 = (iupperc / geom_time_segments - local_time_range.lower) / local_time_range.size(); lbbox.bounds0 = bounds(ilowerc, iupperc, max(0.0f,lower-ilowerfc)); lbbox.bounds1 = bounds(iupperc, ilowerc, max(0.0f,iupperfc-upper)); @@ -378,7 +378,7 @@ namespace embree for (int i = ilower_iter+1; i < iupper_iter; i++) { - const float f = (float(i) / geom_time_segments - time_range.lower) / time_range.size(); + const float f = (float(i) / geom_time_segments - local_time_range.lower) / local_time_range.size(); const BBox3fa bt = lerp(b0, b1, f); const BBox3fa bi = bounds(0, i); const Vec3fa dlower = min(bi.lower-bt.lower, Vec3fa(zero)); @@ -391,8 +391,8 @@ namespace embree for (int i = max(1, ilower_iter+1); i <= min((int)fnumTimeSegments, iupper_iter); i++) { // compute local times for local itimes - const float f0 = ((i-1) / geom_time_segments - time_range.lower) / time_range.size(); - const float f1 = ((i ) / geom_time_segments - time_range.lower) / time_range.size(); + const float f0 = ((i-1) / geom_time_segments - local_time_range.lower) / local_time_range.size(); + const float f1 = ((i ) / geom_time_segments - local_time_range.lower) / local_time_range.size(); const float tmin = (i == max(1, ilower_iter+1)) ? max(0.f, lower-ilowerfc) : 0.f; const float tmax = (i == max(1, min((int)fnumTimeSegments, iupper_iter))) ? 1.f - max(0.f, iupperfc-upper) : 1.f; const BBox3fa d = boundSegment(i-1, getObjectBounds(i-1), getObjectBounds(i), diff --git a/kernels/common/scene_instance.h b/kernels/common/scene_instance.h index 7d3633d7bd..4b25e2a168 100644 --- a/kernels/common/scene_instance.h +++ b/kernels/common/scene_instance.h @@ -185,9 +185,9 @@ namespace embree vbool valid1 = valid; while (any(valid1)) { vbool valid2; - const int itime = next_unique(valid1, itime_k, valid2); - space0 = select(valid2, AffineSpace3vff(local2world[itime+0]), space0); - space1 = select(valid2, AffineSpace3vff(local2world[itime+1]), space1); + const int itime2 = next_unique(valid1, itime_k, valid2); + space0 = select(valid2, AffineSpace3vff(local2world[itime2+0]), space0); + space1 = select(valid2, AffineSpace3vff(local2world[itime2+1]), space1); } return rcp(slerp(space0, space1, ftime)); } @@ -210,9 +210,9 @@ namespace embree vbool valid1 = valid; while (any(valid1)) { vbool valid2; - const int itime = next_unique(valid1, itime_k, valid2); - space0 = select(valid2, AffineSpace3vf((AffineSpace3fa)local2world[itime+0]), space0); - space1 = select(valid2, AffineSpace3vf((AffineSpace3fa)local2world[itime+1]), space1); + const int itime2 = next_unique(valid1, itime_k, valid2); + space0 = select(valid2, AffineSpace3vf((AffineSpace3fa)local2world[itime2+0]), space0); + space1 = select(valid2, AffineSpace3vf((AffineSpace3fa)local2world[itime2+1]), space1); } return rcp(lerp(space0, space1, ftime)); } @@ -231,8 +231,8 @@ namespace embree InstanceISA (Device* device) : Instance(device) {} - LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const { - return linearBounds(primID,time_range); + LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { + return linearBounds(primID,trange); } PrimInfo createPrimRefArray(PrimRef* prims, const range& r, size_t k, unsigned int geomID) const @@ -268,13 +268,13 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { assert(r.begin() == 0); assert(r.end() == 1); PrimInfo pinfo(empty); - const BBox1f t0t1 = intersect(getTimeRange(), time_range); + const BBox1f t0t1 = intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; const BBox3fa bounds = linearBounds(0, t0t1).bounds(); diff --git a/kernels/common/scene_instance_array.cpp b/kernels/common/scene_instance_array.cpp index cc00b81c50..bd2c7efc7f 100644 --- a/kernels/common/scene_instance_array.cpp +++ b/kernels/common/scene_instance_array.cpp @@ -165,9 +165,9 @@ namespace embree Geometry::update(); } - void InstanceArray::setMask (unsigned mask) + void InstanceArray::setMask (unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } @@ -389,11 +389,11 @@ namespace embree { LBBox3fa lbbox = empty; /* normalize global time_range_in to local geom_time_range */ - const BBox1f time_range((time_range_in.lower-geom_time_range.lower)/geom_time_range.size(), - (time_range_in.upper-geom_time_range.lower)/geom_time_range.size()); + const BBox1f local_time_range((time_range_in.lower-geom_time_range.lower)/geom_time_range.size(), + (time_range_in.upper-geom_time_range.lower)/geom_time_range.size()); - const float lower = time_range.lower*geom_time_segments; - const float upper = time_range.upper*geom_time_segments; + const float lower = local_time_range.lower*geom_time_segments; + const float upper = local_time_range.upper*geom_time_segments; const float ilowerf = floor(lower); const float iupperf = ceil(upper); const float ilowerfc = max(0.0f,ilowerf); @@ -408,8 +408,8 @@ namespace embree if (iupper_iter-ilower_iter == 1) { - const float f0 = (ilowerc / geom_time_segments - time_range.lower) / time_range.size(); - const float f1 = (iupperc / geom_time_segments - time_range.lower) / time_range.size(); + const float f0 = (ilowerc / geom_time_segments - local_time_range.lower) / local_time_range.size(); + const float f1 = (iupperc / geom_time_segments - local_time_range.lower) / local_time_range.size(); lbbox.bounds0 = bounds(instance, ilowerc, iupperc, max(0.0f,lower-ilowerfc)); lbbox.bounds1 = bounds(instance, iupperc, ilowerc, max(0.0f,iupperfc-upper)); @@ -428,7 +428,7 @@ namespace embree for (int i = ilower_iter+1; i < iupper_iter; i++) { - const float f = (float(i) / geom_time_segments - time_range.lower) / time_range.size(); + const float f = (float(i) / geom_time_segments - local_time_range.lower) / local_time_range.size(); const BBox3fa bt = lerp(b0, b1, f); const BBox3fa bi = bounds(instance, i); const Vec3fa dlower = min(bi.lower-bt.lower, Vec3fa(zero)); @@ -441,8 +441,8 @@ namespace embree for (int i = max(1, ilower_iter+1); i <= min((int)fnumTimeSegments, iupper_iter); i++) { // compute local times for local itimes - const float f0 = ((i-1) / geom_time_segments - time_range.lower) / time_range.size(); - const float f1 = ((i ) / geom_time_segments - time_range.lower) / time_range.size(); + const float f0 = ((i-1) / geom_time_segments - local_time_range.lower) / local_time_range.size(); + const float f1 = ((i ) / geom_time_segments - local_time_range.lower) / local_time_range.size(); const float tmin = (i == max(1, ilower_iter+1)) ? max(0.f, lower-ilowerfc) : 0.f; const float tmax = (i == max(1, min((int)fnumTimeSegments, iupper_iter))) ? 1.f - max(0.f, iupperfc-upper) : 1.f; const BBox3fa d = boundSegment(instance, i-1, getObjectBounds(instance, i-1), getObjectBounds(instance, i), diff --git a/kernels/common/scene_instance_array.h b/kernels/common/scene_instance_array.h index f3caa06e87..c6ad71634f 100644 --- a/kernels/common/scene_instance_array.h +++ b/kernels/common/scene_instance_array.h @@ -220,9 +220,9 @@ namespace embree vbool valid1 = valid; while (any(valid1)) { vbool valid2; - const int itime = next_unique(valid1, itime_k, valid2); - space0 = select(valid2, AffineSpace3vff(l2w(i, itime+0)), space0); - space1 = select(valid2, AffineSpace3vff(l2w(i, itime+1)), space1); + const int itime2 = next_unique(valid1, itime_k, valid2); + space0 = select(valid2, AffineSpace3vff(l2w(i, itime2+0)), space0); + space1 = select(valid2, AffineSpace3vff(l2w(i, itime2+1)), space1); } return rcp(slerp(space0, space1, ftime)); } @@ -245,9 +245,9 @@ namespace embree vbool valid1 = valid; while (any(valid1)) { vbool valid2; - const int itime = next_unique(valid1, itime_k, valid2); - space0 = select(valid2, AffineSpace3vf((AffineSpace3fa)l2w(i, itime+0)), space0); - space1 = select(valid2, AffineSpace3vf((AffineSpace3fa)l2w(i, itime+1)), space1); + const int itime2 = next_unique(valid1, itime_k, valid2); + space0 = select(valid2, AffineSpace3vf((AffineSpace3fa)l2w(i, itime2+0)), space0); + space1 = select(valid2, AffineSpace3vf((AffineSpace3fa)l2w(i, itime2+1)), space1); } return rcp(lerp(space0, space1, ftime)); } @@ -318,8 +318,8 @@ namespace embree InstanceArrayISA (Device* device) : InstanceArray(device) {} - LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const { - return linearBounds(primID,time_range); + LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { + return linearBounds(primID,trange); } PrimInfo createPrimRefArray(PrimRef* prims, const range& r, size_t k, unsigned int geomID) const @@ -350,10 +350,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; for (size_t j = r.begin(); j < r.end(); j++) { diff --git a/kernels/common/scene_line_segments.cpp b/kernels/common/scene_line_segments.cpp index f6a0051e55..2753e0da29 100644 --- a/kernels/common/scene_line_segments.cpp +++ b/kernels/common/scene_line_segments.cpp @@ -14,18 +14,18 @@ namespace embree vertices.resize(numTimeSteps); } - void LineSegments::setMask (unsigned mask) + void LineSegments::setMask (unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } - void LineSegments::setNumTimeSteps (unsigned int numTimeSteps) + void LineSegments::setNumTimeSteps (unsigned int newNumTimeSteps) { - vertices.resize(numTimeSteps); + vertices.resize(newNumTimeSteps); if (getCurveType() == GTY_SUBTYPE_ORIENTED_CURVE) - normals.resize(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + normals.resize(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void LineSegments::setVertexAttributeCount (unsigned int N) diff --git a/kernels/common/scene_line_segments.h b/kernels/common/scene_line_segments.h index a672abd8d2..ae6202a9cf 100644 --- a/kernels/common/scene_line_segments.h +++ b/kernels/common/scene_line_segments.h @@ -479,10 +479,10 @@ namespace embree } /*! calculates the linear bounds of the i'th primitive for the specified time range */ - __forceinline bool linearBounds(size_t i, const BBox1f& time_range, LBBox3fa& bbox) const + __forceinline bool linearBounds(size_t i, const BBox1f& trange, LBBox3fa& bbox) const { - if (!valid(i, timeSegmentRange(time_range))) return false; - bbox = linearBounds(i, time_range); + if (!valid(i, timeSegmentRange(trange))) return false; + bbox = linearBounds(i, trange); return true; } @@ -517,12 +517,12 @@ namespace embree else return LinearSpace3fa(one); } - LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f time_range) const + LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f trange) const { Vec3fa axisz(0,0,1); Vec3fa axisy(0,1,0); - const range tbounds = this->timeSegmentRange(time_range); + const range tbounds = this->timeSegmentRange(trange); if (tbounds.size() == 0) return frame(axisz); const size_t itime = (tbounds.begin()+tbounds.end())/2; @@ -576,10 +576,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; for (size_t j = r.begin(); j < r.end(); j++) { @@ -618,16 +618,16 @@ namespace embree return bounds(ofs,scale,r_scale0,space,i,itime); } - LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const { - return linearBounds(primID,time_range); + LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { + return linearBounds(primID,trange); } - LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const { - return linearBounds(space,primID,time_range); + LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& trange) const { + return linearBounds(space,primID,trange); } - LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const { - return linearBounds(ofs,scale,r_scale0,space,primID,time_range); + LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& trange) const { + return linearBounds(ofs,scale,r_scale0,space,primID,trange); } }; } diff --git a/kernels/common/scene_points.cpp b/kernels/common/scene_points.cpp index a95b10778e..77fe3c6cee 100644 --- a/kernels/common/scene_points.cpp +++ b/kernels/common/scene_points.cpp @@ -15,18 +15,18 @@ namespace embree normals.resize(numTimeSteps); } - void Points::setMask(unsigned mask) + void Points::setMask(unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } - void Points::setNumTimeSteps(unsigned int numTimeSteps) + void Points::setNumTimeSteps(unsigned int newNumTimeSteps) { - vertices.resize(numTimeSteps); + vertices.resize(newNumTimeSteps); if (getType() == GTY_ORIENTED_DISC_POINT) - normals.resize(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + normals.resize(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void Points::setVertexAttributeCount(unsigned int N) diff --git a/kernels/common/scene_points.h b/kernels/common/scene_points.h index 5800f0c51a..f1943e67fd 100644 --- a/kernels/common/scene_points.h +++ b/kernels/common/scene_points.h @@ -233,10 +233,10 @@ namespace embree } /*! calculates the linear bounds of the i'th primitive for the specified time range */ - __forceinline bool linearBounds(size_t i, const BBox1f& time_range, LBBox3fa& bbox) const + __forceinline bool linearBounds(size_t i, const BBox1f& trange, LBBox3fa& bbox) const { - if (!valid(i, timeSegmentRange(time_range))) return false; - bbox = linearBounds(i, time_range); + if (!valid(i, timeSegmentRange(trange))) return false; + bbox = linearBounds(i, trange); return true; } @@ -303,10 +303,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; for (size_t j = r.begin(); j < r.end(); j++) { @@ -347,14 +347,14 @@ namespace embree return bounds(space, i); } - LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const + LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { - return linearBounds(primID, time_range); + return linearBounds(primID, trange); } - LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const + LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& trange) const { - return linearBounds(space, primID, time_range); + return linearBounds(space, primID, trange); } }; } // namespace isa diff --git a/kernels/common/scene_quad_mesh.cpp b/kernels/common/scene_quad_mesh.cpp index ed3d8129cd..f3e80b9365 100644 --- a/kernels/common/scene_quad_mesh.cpp +++ b/kernels/common/scene_quad_mesh.cpp @@ -14,16 +14,16 @@ namespace embree vertices.resize(numTimeSteps); } - void QuadMesh::setMask (unsigned mask) + void QuadMesh::setMask (unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } - void QuadMesh::setNumTimeSteps (unsigned int numTimeSteps) + void QuadMesh::setNumTimeSteps (unsigned int newNumTimeSteps) { - vertices.resize(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + vertices.resize(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void QuadMesh::setVertexAttributeCount (unsigned int N) diff --git a/kernels/common/scene_quad_mesh.h b/kernels/common/scene_quad_mesh.h index 646b08c1ab..8119169924 100644 --- a/kernels/common/scene_quad_mesh.h +++ b/kernels/common/scene_quad_mesh.h @@ -310,8 +310,8 @@ namespace embree QuadMeshISA (Device* device) : QuadMesh(device) {} - LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const { - return linearBounds(primID,time_range); + LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { + return linearBounds(primID,trange); } PrimInfo createPrimRefArray(PrimRef* prims, const range& r, size_t k, unsigned int geomID) const @@ -342,10 +342,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; for (size_t j = r.begin(); j < r.end(); j++) { diff --git a/kernels/common/scene_subdiv_mesh.cpp b/kernels/common/scene_subdiv_mesh.cpp index 4dc2080d36..5fa95c0967 100644 --- a/kernels/common/scene_subdiv_mesh.cpp +++ b/kernels/common/scene_subdiv_mesh.cpp @@ -57,9 +57,9 @@ namespace embree else counts.numMBSubdivPatches += numPrimitives; } - void SubdivMesh::setMask (unsigned mask) + void SubdivMesh::setMask (unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } @@ -87,11 +87,11 @@ namespace embree } } - void SubdivMesh::setNumTimeSteps (unsigned int numTimeSteps) + void SubdivMesh::setNumTimeSteps (unsigned int newNumTimeSteps) { - vertices.resize(numTimeSteps); - vertex_buffer_tags.resize(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + vertices.resize(newNumTimeSteps); + vertex_buffer_tags.resize(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void SubdivMesh::setVertexAttributeCount (unsigned int N) @@ -422,7 +422,7 @@ namespace embree const size_t blockSize = 4096; const size_t numEdges = mesh->numEdges(); const size_t numFaces = mesh->numFaces(); - const size_t numHalfEdges = mesh->numHalfEdges; + const size_t halfEdgeCount = mesh->numHalfEdges; /* allocate temporary array */ halfEdges0.resize(numEdges); @@ -470,10 +470,10 @@ namespace embree }); /* sort half edges to find adjacent edges */ - radix_sort_u64(halfEdges1.data(),halfEdges0.data(),numHalfEdges); + radix_sort_u64(halfEdges1.data(),halfEdges0.data(),halfEdgeCount); /* link all adjacent pairs of edges */ - parallel_for( size_t(0), numHalfEdges, blockSize, [&](const range& r) + parallel_for( size_t(0), halfEdgeCount, blockSize, [&](const range& r) { /* skip if start of adjacent edges was not in our range */ size_t e=r.begin(); @@ -487,7 +487,7 @@ namespace embree { const uint64_t key = halfEdges1[e].key; if (key == std::numeric_limits::max()) break; - size_t N=1; while (e+Nmask = mask; + this->mask = newMask; Geometry::update(); } - void TriangleMesh::setNumTimeSteps (unsigned int numTimeSteps) + void TriangleMesh::setNumTimeSteps (unsigned int newNumTimeSteps) { - vertices.resize(numTimeSteps); - Geometry::setNumTimeSteps(numTimeSteps); + vertices.resize(newNumTimeSteps); + Geometry::setNumTimeSteps(newNumTimeSteps); } void TriangleMesh::setVertexAttributeCount (unsigned int N) diff --git a/kernels/common/scene_triangle_mesh.h b/kernels/common/scene_triangle_mesh.h index 3f014d85a2..a4835a6a76 100644 --- a/kernels/common/scene_triangle_mesh.h +++ b/kernels/common/scene_triangle_mesh.h @@ -286,8 +286,8 @@ namespace embree : TriangleMesh(device) {} #if !defined(__SYCL_DEVICE_ONLY__) - LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const { - return linearBounds(primID,time_range); + LBBox3fa vlinearBounds(size_t primID, const BBox1f& trange) const { + return linearBounds(primID,trange); } PrimInfo createPrimRefArray(PrimRef* prims, const range& r, size_t k, unsigned int geomID) const @@ -318,10 +318,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; for (size_t j = r.begin(); j < r.end(); j++) { diff --git a/kernels/common/scene_user_geometry.cpp b/kernels/common/scene_user_geometry.cpp index 4bd07d39b2..e5f9b40439 100644 --- a/kernels/common/scene_user_geometry.cpp +++ b/kernels/common/scene_user_geometry.cpp @@ -17,13 +17,13 @@ namespace embree else counts.numMBUserGeometries += numPrimitives; } - void UserGeometry::setMask (unsigned mask) + void UserGeometry::setMask (unsigned newMask) { - this->mask = mask; + this->mask = newMask; Geometry::update(); } - void UserGeometry::setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) { + void UserGeometry::setBoundsFunction (RTCBoundsFunction bounds, void* /*userPtr*/) { this->boundsFunc = bounds; } diff --git a/kernels/common/scene_user_geometry.h b/kernels/common/scene_user_geometry.h index b1376cdf7f..5d66859f85 100644 --- a/kernels/common/scene_user_geometry.h +++ b/kernels/common/scene_user_geometry.h @@ -62,10 +62,10 @@ namespace embree return pinfo; } - PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range& r, size_t k, unsigned int geomID) const + PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& trange, const range& r, size_t k, unsigned int geomID) const { PrimInfo pinfo(empty); - const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range); + const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), trange); if (t0t1.empty()) return pinfo; for (size_t j = r.begin(); j < r.end(); j++) { diff --git a/kernels/geometry/curveNi.h b/kernels/geometry/curveNi.h index 6366a6fb9c..bb9277766a 100644 --- a/kernels/geometry/curveNi.h +++ b/kernels/geometry/curveNi.h @@ -74,31 +74,31 @@ namespace embree const LinearSpace3fa space2 = scene->get(geomID)->computeAlignedSpace(primID); const LinearSpace3fa space3(trunc(126.0f*space2.vx),trunc(126.0f*space2.vy),trunc(126.0f*space2.vz)); - const BBox3fa bounds = scene->get(geomID)->vbounds(loffset,lscale,max(length(space3.vx),length(space3.vy),length(space3.vz)),space3.transposed(),primID); + const BBox3fa alignedBounds = scene->get(geomID)->vbounds(loffset,lscale,max(length(space3.vx),length(space3.vy),length(space3.vz)),space3.transposed(),primID); bounds_vx_x(N)[i] = (char) space3.vx.x; bounds_vx_y(N)[i] = (char) space3.vx.y; bounds_vx_z(N)[i] = (char) space3.vx.z; - bounds_vx_lower(N)[i] = (short) clamp(floor(bounds.lower.x),-32767.0f,32767.0f); - bounds_vx_upper(N)[i] = (short) clamp(ceil (bounds.upper.x),-32767.0f,32767.0f); - assert(-32767.0f <= floor(bounds.lower.x) && floor(bounds.lower.x) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.upper.x) && ceil (bounds.upper.x) <= 32767.0f); + bounds_vx_lower(N)[i] = (short) clamp(floor(alignedBounds.lower.x),-32767.0f,32767.0f); + bounds_vx_upper(N)[i] = (short) clamp(ceil (alignedBounds.upper.x),-32767.0f,32767.0f); + assert(-32767.0f <= floor(alignedBounds.lower.x) && floor(alignedBounds.lower.x) <= 32767.0f); + assert(-32767.0f <= ceil (alignedBounds.upper.x) && ceil (alignedBounds.upper.x) <= 32767.0f); bounds_vy_x(N)[i] = (char) space3.vy.x; bounds_vy_y(N)[i] = (char) space3.vy.y; bounds_vy_z(N)[i] = (char) space3.vy.z; - bounds_vy_lower(N)[i] = (short) clamp(floor(bounds.lower.y),-32767.0f,32767.0f); - bounds_vy_upper(N)[i] = (short) clamp(ceil (bounds.upper.y),-32767.0f,32767.0f); - assert(-32767.0f <= floor(bounds.lower.y) && floor(bounds.lower.y) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.upper.y) && ceil (bounds.upper.y) <= 32767.0f); + bounds_vy_lower(N)[i] = (short) clamp(floor(alignedBounds.lower.y),-32767.0f,32767.0f); + bounds_vy_upper(N)[i] = (short) clamp(ceil (alignedBounds.upper.y),-32767.0f,32767.0f); + assert(-32767.0f <= floor(alignedBounds.lower.y) && floor(alignedBounds.lower.y) <= 32767.0f); + assert(-32767.0f <= ceil (alignedBounds.upper.y) && ceil (alignedBounds.upper.y) <= 32767.0f); bounds_vz_x(N)[i] = (char) space3.vz.x; bounds_vz_y(N)[i] = (char) space3.vz.y; bounds_vz_z(N)[i] = (char) space3.vz.z; - bounds_vz_lower(N)[i] = (short) clamp(floor(bounds.lower.z),-32767.0f,32767.0f); - bounds_vz_upper(N)[i] = (short) clamp(ceil (bounds.upper.z),-32767.0f,32767.0f); - assert(-32767.0f <= floor(bounds.lower.z) && floor(bounds.lower.z) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.upper.z) && ceil (bounds.upper.z) <= 32767.0f); + bounds_vz_lower(N)[i] = (short) clamp(floor(alignedBounds.lower.z),-32767.0f,32767.0f); + bounds_vz_upper(N)[i] = (short) clamp(ceil (alignedBounds.upper.z),-32767.0f,32767.0f); + assert(-32767.0f <= floor(alignedBounds.lower.z) && floor(alignedBounds.lower.z) <= 32767.0f); + assert(-32767.0f <= ceil (alignedBounds.upper.z) && ceil (alignedBounds.upper.z) <= 32767.0f); this->primID(N)[i] = primID; } @@ -153,65 +153,65 @@ namespace embree }; */ - __forceinline unsigned int& geomID(size_t N) { return *(unsigned int*)((char*)this+2); } - __forceinline const unsigned int& geomID(size_t N) const { return *(unsigned int*)((char*)this+2); } + __forceinline unsigned int& geomID(size_t) { return *(unsigned int*)((char*)this+2); } + __forceinline const unsigned int& geomID(size_t) const { return *(unsigned int*)((char*)this+2); } - __forceinline unsigned int* primID(size_t N) { return (unsigned int*)((char*)this+6); } - __forceinline const unsigned int* primID(size_t N) const { return (unsigned int*)((char*)this+6); } + __forceinline unsigned int* primID(size_t) { return (unsigned int*)((char*)this+6); } + __forceinline const unsigned int* primID(size_t) const { return (unsigned int*)((char*)this+6); } - __forceinline char* bounds_vx_x(size_t N) { return (char*)((char*)this+6+4*N); } - __forceinline const char* bounds_vx_x(size_t N) const { return (char*)((char*)this+6+4*N); } + __forceinline char* bounds_vx_x(size_t num) { return (char*)((char*)this+6+4*num); } + __forceinline const char* bounds_vx_x(size_t num) const { return (char*)((char*)this+6+4*num); } - __forceinline char* bounds_vx_y(size_t N) { return (char*)((char*)this+6+5*N); } - __forceinline const char* bounds_vx_y(size_t N) const { return (char*)((char*)this+6+5*N); } + __forceinline char* bounds_vx_y(size_t num) { return (char*)((char*)this+6+5*num); } + __forceinline const char* bounds_vx_y(size_t num) const { return (char*)((char*)this+6+5*num); } - __forceinline char* bounds_vx_z(size_t N) { return (char*)((char*)this+6+6*N); } - __forceinline const char* bounds_vx_z(size_t N) const { return (char*)((char*)this+6+6*N); } + __forceinline char* bounds_vx_z(size_t num) { return (char*)((char*)this+6+6*num); } + __forceinline const char* bounds_vx_z(size_t num) const { return (char*)((char*)this+6+6*num); } - __forceinline short* bounds_vx_lower(size_t N) { return (short*)((char*)this+6+7*N); } - __forceinline const short* bounds_vx_lower(size_t N) const { return (short*)((char*)this+6+7*N); } + __forceinline short* bounds_vx_lower(size_t num) { return (short*)((char*)this+6+7*num); } + __forceinline const short* bounds_vx_lower(size_t num) const { return (short*)((char*)this+6+7*num); } - __forceinline short* bounds_vx_upper(size_t N) { return (short*)((char*)this+6+9*N); } - __forceinline const short* bounds_vx_upper(size_t N) const { return (short*)((char*)this+6+9*N); } + __forceinline short* bounds_vx_upper(size_t num) { return (short*)((char*)this+6+9*num); } + __forceinline const short* bounds_vx_upper(size_t num) const { return (short*)((char*)this+6+9*num); } - __forceinline char* bounds_vy_x(size_t N) { return (char*)((char*)this+6+11*N); } - __forceinline const char* bounds_vy_x(size_t N) const { return (char*)((char*)this+6+11*N); } + __forceinline char* bounds_vy_x(size_t num) { return (char*)((char*)this+6+11*num); } + __forceinline const char* bounds_vy_x(size_t num) const { return (char*)((char*)this+6+11*num); } - __forceinline char* bounds_vy_y(size_t N) { return (char*)((char*)this+6+12*N); } - __forceinline const char* bounds_vy_y(size_t N) const { return (char*)((char*)this+6+12*N); } + __forceinline char* bounds_vy_y(size_t num) { return (char*)((char*)this+6+12*num); } + __forceinline const char* bounds_vy_y(size_t num) const { return (char*)((char*)this+6+12*num); } - __forceinline char* bounds_vy_z(size_t N) { return (char*)((char*)this+6+13*N); } - __forceinline const char* bounds_vy_z(size_t N) const { return (char*)((char*)this+6+13*N); } + __forceinline char* bounds_vy_z(size_t num) { return (char*)((char*)this+6+13*num); } + __forceinline const char* bounds_vy_z(size_t num) const { return (char*)((char*)this+6+13*num); } - __forceinline short* bounds_vy_lower(size_t N) { return (short*)((char*)this+6+14*N); } - __forceinline const short* bounds_vy_lower(size_t N) const { return (short*)((char*)this+6+14*N); } + __forceinline short* bounds_vy_lower(size_t num) { return (short*)((char*)this+6+14*num); } + __forceinline const short* bounds_vy_lower(size_t num) const { return (short*)((char*)this+6+14*num); } - __forceinline short* bounds_vy_upper(size_t N) { return (short*)((char*)this+6+16*N); } - __forceinline const short* bounds_vy_upper(size_t N) const { return (short*)((char*)this+6+16*N); } + __forceinline short* bounds_vy_upper(size_t num) { return (short*)((char*)this+6+16*num); } + __forceinline const short* bounds_vy_upper(size_t num) const { return (short*)((char*)this+6+16*num); } - __forceinline char* bounds_vz_x(size_t N) { return (char*)((char*)this+6+18*N); } - __forceinline const char* bounds_vz_x(size_t N) const { return (char*)((char*)this+6+18*N); } + __forceinline char* bounds_vz_x(size_t num) { return (char*)((char*)this+6+18*num); } + __forceinline const char* bounds_vz_x(size_t num) const { return (char*)((char*)this+6+18*num); } - __forceinline char* bounds_vz_y(size_t N) { return (char*)((char*)this+6+19*N); } - __forceinline const char* bounds_vz_y(size_t N) const { return (char*)((char*)this+6+19*N); } + __forceinline char* bounds_vz_y(size_t num) { return (char*)((char*)this+6+19*num); } + __forceinline const char* bounds_vz_y(size_t num) const { return (char*)((char*)this+6+19*num); } - __forceinline char* bounds_vz_z(size_t N) { return (char*)((char*)this+6+20*N); } - __forceinline const char* bounds_vz_z(size_t N) const { return (char*)((char*)this+6+20*N); } + __forceinline char* bounds_vz_z(size_t num) { return (char*)((char*)this+6+20*num); } + __forceinline const char* bounds_vz_z(size_t num) const { return (char*)((char*)this+6+20*num); } - __forceinline short* bounds_vz_lower(size_t N) { return (short*)((char*)this+6+21*N); } - __forceinline const short* bounds_vz_lower(size_t N) const { return (short*)((char*)this+6+21*N); } + __forceinline short* bounds_vz_lower(size_t num) { return (short*)((char*)this+6+21*num); } + __forceinline const short* bounds_vz_lower(size_t num) const { return (short*)((char*)this+6+21*num); } - __forceinline short* bounds_vz_upper(size_t N) { return (short*)((char*)this+6+23*N); } - __forceinline const short* bounds_vz_upper(size_t N) const { return (short*)((char*)this+6+23*N); } + __forceinline short* bounds_vz_upper(size_t num) { return (short*)((char*)this+6+23*num); } + __forceinline const short* bounds_vz_upper(size_t num) const { return (short*)((char*)this+6+23*num); } - __forceinline Vec3f* offset(size_t N) { return (Vec3f*)((char*)this+6+25*N); } - __forceinline const Vec3f* offset(size_t N) const { return (Vec3f*)((char*)this+6+25*N); } + __forceinline Vec3f* offset(size_t num) { return (Vec3f*)((char*)this+6+25*num); } + __forceinline const Vec3f* offset(size_t num) const { return (Vec3f*)((char*)this+6+25*num); } - __forceinline float* scale(size_t N) { return (float*)((char*)this+6+25*N+12); } - __forceinline const float* scale(size_t N) const { return (float*)((char*)this+6+25*N+12); } + __forceinline float* scale(size_t num) { return (float*)((char*)this+6+25*num+12); } + __forceinline const float* scale(size_t num) const { return (float*)((char*)this+6+25*num+12); } - __forceinline char* end(size_t N) { return (char*)this+6+25*N+16; } - __forceinline const char* end(size_t N) const { return (char*)this+6+25*N+16; } + __forceinline char* end(size_t num) { return (char*)this+6+25*num+16; } + __forceinline const char* end(size_t num) const { return (char*)this+6+25*num+16; } }; template @@ -220,3 +220,4 @@ namespace embree typedef CurveNi<4> Curve4i; typedef CurveNi<8> Curve8i; } + diff --git a/kernels/geometry/curveNi_mb.h b/kernels/geometry/curveNi_mb.h index 5d972b43a0..2b4c9b5370 100644 --- a/kernels/geometry/curveNi_mb.h +++ b/kernels/geometry/curveNi_mb.h @@ -40,7 +40,7 @@ namespace embree __forceinline CurveNiMB () {} /*! fill curve from curve list */ - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t _end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t _end, Scene* scene, const BBox1f trange) { size_t end = min(begin+M,_end); N = (unsigned char)(end-begin); @@ -55,7 +55,7 @@ namespace embree const PrimRefMB& prim = prims[begin+i]; const unsigned int geomID = prim.geomID(); assert(geomID == geomID0); const unsigned int primID = prim.primID(); - lbounds.extend(scene->get(geomID)->vlinearBounds(primID,time_range)); + lbounds.extend(scene->get(geomID)->vlinearBounds(primID,trange)); } BBox3fa bounds = lbounds.bounds(); @@ -65,8 +65,8 @@ namespace embree if (bounds.size() == Vec3fa(zero)) lscale = 0.0f; *this->offset(N) = loffset; *this->scale(N) = lscale; - this->time_offset(N) = time_range.lower; - this->time_scale(N) = 1.0f/time_range.size(); + this->time_offset(N) = trange.lower; + this->time_scale(N) = 1.0f/trange.size(); /* encode all primitives */ for (size_t i=0; iget(geomID)->computeAlignedSpaceMB(primID,time_range); + const LinearSpace3fa space2 = scene->get(geomID)->computeAlignedSpaceMB(primID,trange); const LinearSpace3fa space3(trunc(126.0f*space2.vx),trunc(126.0f*space2.vy),trunc(126.0f*space2.vz)); - const LBBox3fa bounds = scene->get(geomID)->vlinearBounds(loffset,lscale,max(length(space3.vx),length(space3.vy),length(space3.vz)),space3.transposed(),primID,time_range); + const LBBox3fa prim_bounds = scene->get(geomID)->vlinearBounds(loffset,lscale,max(length(space3.vx),length(space3.vy),length(space3.vz)),space3.transposed(),primID,trange); // NOTE: this weird (char) (short) cast works around VS2015 Win32 compiler bug bounds_vx_x(N)[i] = (char) (short) space3.vx.x; bounds_vx_y(N)[i] = (char) (short) space3.vx.y; bounds_vx_z(N)[i] = (char) (short) space3.vx.z; - bounds_vx_lower0(N)[i] = (short) clamp(floor(bounds.bounds0.lower.x),-32767.0f,32767.0f); - bounds_vx_upper0(N)[i] = (short) clamp(ceil (bounds.bounds0.upper.x),-32767.0f,32767.0f); - bounds_vx_lower1(N)[i] = (short) clamp(floor(bounds.bounds1.lower.x),-32767.0f,32767.0f); - bounds_vx_upper1(N)[i] = (short) clamp(ceil (bounds.bounds1.upper.x),-32767.0f,32767.0f); - assert(-32767.0f <= floor(bounds.bounds0.lower.x) && floor(bounds.bounds0.lower.x) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.bounds0.upper.x) && ceil (bounds.bounds0.upper.x) <= 32767.0f); - assert(-32767.0f <= floor(bounds.bounds1.lower.x) && floor(bounds.bounds1.lower.x) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.bounds1.upper.x) && ceil (bounds.bounds1.upper.x) <= 32767.0f); + bounds_vx_lower0(N)[i] = (short) clamp(floor(prim_bounds.bounds0.lower.x),-32767.0f,32767.0f); + bounds_vx_upper0(N)[i] = (short) clamp(ceil (prim_bounds.bounds0.upper.x),-32767.0f,32767.0f); + bounds_vx_lower1(N)[i] = (short) clamp(floor(prim_bounds.bounds1.lower.x),-32767.0f,32767.0f); + bounds_vx_upper1(N)[i] = (short) clamp(ceil (prim_bounds.bounds1.upper.x),-32767.0f,32767.0f); + assert(-32767.0f <= floor(prim_bounds.bounds0.lower.x) && floor(prim_bounds.bounds0.lower.x) <= 32767.0f); + assert(-32767.0f <= ceil (prim_bounds.bounds0.upper.x) && ceil (prim_bounds.bounds0.upper.x) <= 32767.0f); + assert(-32767.0f <= floor(prim_bounds.bounds1.lower.x) && floor(prim_bounds.bounds1.lower.x) <= 32767.0f); + assert(-32767.0f <= ceil (prim_bounds.bounds1.upper.x) && ceil (prim_bounds.bounds1.upper.x) <= 32767.0f); bounds_vy_x(N)[i] = (char) (short) space3.vy.x; bounds_vy_y(N)[i] = (char) (short) space3.vy.y; bounds_vy_z(N)[i] = (char) (short) space3.vy.z; - bounds_vy_lower0(N)[i] = (short) clamp(floor(bounds.bounds0.lower.y),-32767.0f,32767.0f); - bounds_vy_upper0(N)[i] = (short) clamp(ceil (bounds.bounds0.upper.y),-32767.0f,32767.0f); - bounds_vy_lower1(N)[i] = (short) clamp(floor(bounds.bounds1.lower.y),-32767.0f,32767.0f); - bounds_vy_upper1(N)[i] = (short) clamp(ceil (bounds.bounds1.upper.y),-32767.0f,32767.0f); - assert(-32767.0f <= floor(bounds.bounds0.lower.y) && floor(bounds.bounds0.lower.y) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.bounds0.upper.y) && ceil (bounds.bounds0.upper.y) <= 32767.0f); - assert(-32767.0f <= floor(bounds.bounds1.lower.y) && floor(bounds.bounds1.lower.y) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.bounds1.upper.y) && ceil (bounds.bounds1.upper.y) <= 32767.0f); + bounds_vy_lower0(N)[i] = (short) clamp(floor(prim_bounds.bounds0.lower.y),-32767.0f,32767.0f); + bounds_vy_upper0(N)[i] = (short) clamp(ceil (prim_bounds.bounds0.upper.y),-32767.0f,32767.0f); + bounds_vy_lower1(N)[i] = (short) clamp(floor(prim_bounds.bounds1.lower.y),-32767.0f,32767.0f); + bounds_vy_upper1(N)[i] = (short) clamp(ceil (prim_bounds.bounds1.upper.y),-32767.0f,32767.0f); + assert(-32767.0f <= floor(prim_bounds.bounds0.lower.y) && floor(prim_bounds.bounds0.lower.y) <= 32767.0f); + assert(-32767.0f <= ceil (prim_bounds.bounds0.upper.y) && ceil (prim_bounds.bounds0.upper.y) <= 32767.0f); + assert(-32767.0f <= floor(prim_bounds.bounds1.lower.y) && floor(prim_bounds.bounds1.lower.y) <= 32767.0f); + assert(-32767.0f <= ceil (prim_bounds.bounds1.upper.y) && ceil (prim_bounds.bounds1.upper.y) <= 32767.0f); bounds_vz_x(N)[i] = (char) (short) space3.vz.x; bounds_vz_y(N)[i] = (char) (short) space3.vz.y; bounds_vz_z(N)[i] = (char) (short) space3.vz.z; - bounds_vz_lower0(N)[i] = (short) clamp(floor(bounds.bounds0.lower.z),-32767.0f,32767.0f); - bounds_vz_upper0(N)[i] = (short) clamp(ceil (bounds.bounds0.upper.z),-32767.0f,32767.0f); - bounds_vz_lower1(N)[i] = (short) clamp(floor(bounds.bounds1.lower.z),-32767.0f,32767.0f); - bounds_vz_upper1(N)[i] = (short) clamp(ceil (bounds.bounds1.upper.z),-32767.0f,32767.0f); - assert(-32767.0f <= floor(bounds.bounds0.lower.z) && floor(bounds.bounds0.lower.z) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.bounds0.upper.z) && ceil (bounds.bounds0.upper.z) <= 32767.0f); - assert(-32767.0f <= floor(bounds.bounds1.lower.z) && floor(bounds.bounds1.lower.z) <= 32767.0f); - assert(-32767.0f <= ceil (bounds.bounds1.upper.z) && ceil (bounds.bounds1.upper.z) <= 32767.0f); + bounds_vz_lower0(N)[i] = (short) clamp(floor(prim_bounds.bounds0.lower.z),-32767.0f,32767.0f); + bounds_vz_upper0(N)[i] = (short) clamp(ceil (prim_bounds.bounds0.upper.z),-32767.0f,32767.0f); + bounds_vz_lower1(N)[i] = (short) clamp(floor(prim_bounds.bounds1.lower.z),-32767.0f,32767.0f); + bounds_vz_upper1(N)[i] = (short) clamp(ceil (prim_bounds.bounds1.upper.z),-32767.0f,32767.0f); + assert(-32767.0f <= floor(prim_bounds.bounds0.lower.z) && floor(prim_bounds.bounds0.lower.z) <= 32767.0f); + assert(-32767.0f <= ceil (prim_bounds.bounds0.upper.z) && ceil (prim_bounds.bounds0.upper.z) <= 32767.0f); + assert(-32767.0f <= floor(prim_bounds.bounds1.lower.z) && floor(prim_bounds.bounds1.lower.z) <= 32767.0f); + assert(-32767.0f <= ceil (prim_bounds.bounds1.upper.z) && ceil (prim_bounds.bounds1.upper.z) <= 32767.0f); this->primID(N)[i] = primID; } @@ -185,89 +185,89 @@ namespace embree }; */ - __forceinline unsigned int& geomID(size_t N) { return *(unsigned int*)((char*)this+2); } - __forceinline const unsigned int& geomID(size_t N) const { return *(unsigned int*)((char*)this+2); } + __forceinline unsigned int& geomID(size_t) { return *(unsigned int*)((char*)this+2); } + __forceinline const unsigned int& geomID(size_t) const { return *(unsigned int*)((char*)this+2); } - __forceinline unsigned int* primID(size_t N) { return (unsigned int*)((char*)this+6); } - __forceinline const unsigned int* primID(size_t N) const { return (unsigned int*)((char*)this+6); } + __forceinline unsigned int* primID(size_t) { return (unsigned int*)((char*)this+6); } + __forceinline const unsigned int* primID(size_t) const { return (unsigned int*)((char*)this+6); } - __forceinline char* bounds_vx_x(size_t N) { return (char*)((char*)this+6+4*N); } - __forceinline const char* bounds_vx_x(size_t N) const { return (char*)((char*)this+6+4*N); } + __forceinline char* bounds_vx_x(size_t num) { return (char*)((char*)this+6+4*num); } + __forceinline const char* bounds_vx_x(size_t num) const { return (char*)((char*)this+6+4*num); } - __forceinline char* bounds_vx_y(size_t N) { return (char*)((char*)this+6+5*N); } - __forceinline const char* bounds_vx_y(size_t N) const { return (char*)((char*)this+6+5*N); } + __forceinline char* bounds_vx_y(size_t num) { return (char*)((char*)this+6+5*num); } + __forceinline const char* bounds_vx_y(size_t num) const { return (char*)((char*)this+6+5*num); } - __forceinline char* bounds_vx_z(size_t N) { return (char*)((char*)this+6+6*N); } - __forceinline const char* bounds_vx_z(size_t N) const { return (char*)((char*)this+6+6*N); } + __forceinline char* bounds_vx_z(size_t num) { return (char*)((char*)this+6+6*num); } + __forceinline const char* bounds_vx_z(size_t num) const { return (char*)((char*)this+6+6*num); } - __forceinline short* bounds_vx_lower0(size_t N) { return (short*)((char*)this+6+7*N); } - __forceinline const short* bounds_vx_lower0(size_t N) const { return (short*)((char*)this+6+7*N); } + __forceinline short* bounds_vx_lower0(size_t num) { return (short*)((char*)this+6+7*num); } + __forceinline const short* bounds_vx_lower0(size_t num) const { return (short*)((char*)this+6+7*num); } - __forceinline short* bounds_vx_upper0(size_t N) { return (short*)((char*)this+6+9*N); } - __forceinline const short* bounds_vx_upper0(size_t N) const { return (short*)((char*)this+6+9*N); } + __forceinline short* bounds_vx_upper0(size_t num) { return (short*)((char*)this+6+9*num); } + __forceinline const short* bounds_vx_upper0(size_t num) const { return (short*)((char*)this+6+9*num); } - __forceinline short* bounds_vx_lower1(size_t N) { return (short*)((char*)this+6+11*N); } - __forceinline const short* bounds_vx_lower1(size_t N) const { return (short*)((char*)this+6+11*N); } + __forceinline short* bounds_vx_lower1(size_t num) { return (short*)((char*)this+6+11*num); } + __forceinline const short* bounds_vx_lower1(size_t num) const { return (short*)((char*)this+6+11*num); } - __forceinline short* bounds_vx_upper1(size_t N) { return (short*)((char*)this+6+13*N); } - __forceinline const short* bounds_vx_upper1(size_t N) const { return (short*)((char*)this+6+13*N); } + __forceinline short* bounds_vx_upper1(size_t num) { return (short*)((char*)this+6+13*num); } + __forceinline const short* bounds_vx_upper1(size_t num) const { return (short*)((char*)this+6+13*num); } - __forceinline char* bounds_vy_x(size_t N) { return (char*)((char*)this+6+15*N); } - __forceinline const char* bounds_vy_x(size_t N) const { return (char*)((char*)this+6+15*N); } + __forceinline char* bounds_vy_x(size_t num) { return (char*)((char*)this+6+15*num); } + __forceinline const char* bounds_vy_x(size_t num) const { return (char*)((char*)this+6+15*num); } - __forceinline char* bounds_vy_y(size_t N) { return (char*)((char*)this+6+16*N); } - __forceinline const char* bounds_vy_y(size_t N) const { return (char*)((char*)this+6+16*N); } + __forceinline char* bounds_vy_y(size_t num) { return (char*)((char*)this+6+16*num); } + __forceinline const char* bounds_vy_y(size_t num) const { return (char*)((char*)this+6+16*num); } - __forceinline char* bounds_vy_z(size_t N) { return (char*)((char*)this+6+17*N); } - __forceinline const char* bounds_vy_z(size_t N) const { return (char*)((char*)this+6+17*N); } + __forceinline char* bounds_vy_z(size_t num) { return (char*)((char*)this+6+17*num); } + __forceinline const char* bounds_vy_z(size_t num) const { return (char*)((char*)this+6+17*num); } - __forceinline short* bounds_vy_lower0(size_t N) { return (short*)((char*)this+6+18*N); } - __forceinline const short* bounds_vy_lower0(size_t N) const { return (short*)((char*)this+6+18*N); } + __forceinline short* bounds_vy_lower0(size_t num) { return (short*)((char*)this+6+18*num); } + __forceinline const short* bounds_vy_lower0(size_t num) const { return (short*)((char*)this+6+18*num); } - __forceinline short* bounds_vy_upper0(size_t N) { return (short*)((char*)this+6+20*N); } - __forceinline const short* bounds_vy_upper0(size_t N) const { return (short*)((char*)this+6+20*N); } + __forceinline short* bounds_vy_upper0(size_t num) { return (short*)((char*)this+6+20*num); } + __forceinline const short* bounds_vy_upper0(size_t num) const { return (short*)((char*)this+6+20*num); } - __forceinline short* bounds_vy_lower1(size_t N) { return (short*)((char*)this+6+22*N); } - __forceinline const short* bounds_vy_lower1(size_t N) const { return (short*)((char*)this+6+22*N); } + __forceinline short* bounds_vy_lower1(size_t num) { return (short*)((char*)this+6+22*num); } + __forceinline const short* bounds_vy_lower1(size_t num) const { return (short*)((char*)this+6+22*num); } - __forceinline short* bounds_vy_upper1(size_t N) { return (short*)((char*)this+6+24*N); } - __forceinline const short* bounds_vy_upper1(size_t N) const { return (short*)((char*)this+6+24*N); } + __forceinline short* bounds_vy_upper1(size_t num) { return (short*)((char*)this+6+24*num); } + __forceinline const short* bounds_vy_upper1(size_t num) const { return (short*)((char*)this+6+24*num); } - __forceinline char* bounds_vz_x(size_t N) { return (char*)((char*)this+6+26*N); } - __forceinline const char* bounds_vz_x(size_t N) const { return (char*)((char*)this+6+26*N); } + __forceinline char* bounds_vz_x(size_t num) { return (char*)((char*)this+6+26*num); } + __forceinline const char* bounds_vz_x(size_t num) const { return (char*)((char*)this+6+26*num); } - __forceinline char* bounds_vz_y(size_t N) { return (char*)((char*)this+6+27*N); } - __forceinline const char* bounds_vz_y(size_t N) const { return (char*)((char*)this+6+27*N); } + __forceinline char* bounds_vz_y(size_t num) { return (char*)((char*)this+6+27*num); } + __forceinline const char* bounds_vz_y(size_t num) const { return (char*)((char*)this+6+27*num); } - __forceinline char* bounds_vz_z(size_t N) { return (char*)((char*)this+6+28*N); } - __forceinline const char* bounds_vz_z(size_t N) const { return (char*)((char*)this+6+28*N); } + __forceinline char* bounds_vz_z(size_t num) { return (char*)((char*)this+6+28*num); } + __forceinline const char* bounds_vz_z(size_t num) const { return (char*)((char*)this+6+28*num); } - __forceinline short* bounds_vz_lower0(size_t N) { return (short*)((char*)this+6+29*N); } - __forceinline const short* bounds_vz_lower0(size_t N) const { return (short*)((char*)this+6+29*N); } + __forceinline short* bounds_vz_lower0(size_t num) { return (short*)((char*)this+6+29*num); } + __forceinline const short* bounds_vz_lower0(size_t num) const { return (short*)((char*)this+6+29*num); } - __forceinline short* bounds_vz_upper0(size_t N) { return (short*)((char*)this+6+31*N); } - __forceinline const short* bounds_vz_upper0(size_t N) const { return (short*)((char*)this+6+31*N); } + __forceinline short* bounds_vz_upper0(size_t num) { return (short*)((char*)this+6+31*num); } + __forceinline const short* bounds_vz_upper0(size_t num) const { return (short*)((char*)this+6+31*num); } - __forceinline short* bounds_vz_lower1(size_t N) { return (short*)((char*)this+6+33*N); } - __forceinline const short* bounds_vz_lower1(size_t N) const { return (short*)((char*)this+6+33*N); } + __forceinline short* bounds_vz_lower1(size_t num) { return (short*)((char*)this+6+33*num); } + __forceinline const short* bounds_vz_lower1(size_t num) const { return (short*)((char*)this+6+33*num); } - __forceinline short* bounds_vz_upper1(size_t N) { return (short*)((char*)this+6+35*N); } - __forceinline const short* bounds_vz_upper1(size_t N) const { return (short*)((char*)this+6+35*N); } + __forceinline short* bounds_vz_upper1(size_t num) { return (short*)((char*)this+6+35*num); } + __forceinline const short* bounds_vz_upper1(size_t num) const { return (short*)((char*)this+6+35*num); } - __forceinline Vec3f* offset(size_t N) { return (Vec3f*)((char*)this+6+37*N); } - __forceinline const Vec3f* offset(size_t N) const { return (Vec3f*)((char*)this+6+37*N); } + __forceinline Vec3f* offset(size_t num) { return (Vec3f*)((char*)this+6+37*num); } + __forceinline const Vec3f* offset(size_t num) const { return (Vec3f*)((char*)this+6+37*num); } - __forceinline float* scale(size_t N) { return (float*)((char*)this+6+37*N+12); } - __forceinline const float* scale(size_t N) const { return (float*)((char*)this+6+37*N+12); } + __forceinline float* scale(size_t num) { return (float*)((char*)this+6+37*num+12); } + __forceinline const float* scale(size_t num) const { return (float*)((char*)this+6+37*num+12); } - __forceinline float& time_offset(size_t N) { return *(float*)((char*)this+6+37*N+16); } - __forceinline const float& time_offset(size_t N) const { return *(float*)((char*)this+6+37*N+16); } + __forceinline float& time_offset(size_t num) { return *(float*)((char*)this+6+37*num+16); } + __forceinline const float& time_offset(size_t num) const { return *(float*)((char*)this+6+37*num+16); } - __forceinline float& time_scale(size_t N) { return *(float*)((char*)this+6+37*N+20); } - __forceinline const float& time_scale(size_t N) const { return *(float*)((char*)this+6+37*N+20); } + __forceinline float& time_scale(size_t num) { return *(float*)((char*)this+6+37*num+20); } + __forceinline const float& time_scale(size_t num) const { return *(float*)((char*)this+6+37*num+20); } - __forceinline char* end(size_t N) { return (char*)this+6+37*N+24; } - __forceinline const char* end(size_t N) const { return (char*)this+6+37*N+24; } + __forceinline char* end(size_t num) { return (char*)this+6+37*num+24; } + __forceinline const char* end(size_t num) const { return (char*)this+6+37*num+24; } }; template @@ -276,3 +276,5 @@ namespace embree typedef CurveNiMB<4> Curve4iMB; typedef CurveNiMB<8> Curve8iMB; } + + diff --git a/kernels/geometry/curveNv.h b/kernels/geometry/curveNv.h index e41a381706..d2c39a0e4e 100644 --- a/kernels/geometry/curveNv.h +++ b/kernels/geometry/curveNv.h @@ -44,20 +44,20 @@ namespace embree __forceinline void fill(const PrimRef* prims, size_t& begin, size_t _end, Scene* scene) { size_t end = min(begin+M,_end); - size_t N = end-begin; + size_t num = end-begin; /* encode all primitives */ - for (size_t i=0; iget(geomID); const unsigned vtxID = mesh->curve(primID); - Vec3fa::storeu(&this->vertices(i,N)[0],mesh->vertex(vtxID+0)); - Vec3fa::storeu(&this->vertices(i,N)[1],mesh->vertex(vtxID+1)); - Vec3fa::storeu(&this->vertices(i,N)[2],mesh->vertex(vtxID+2)); - Vec3fa::storeu(&this->vertices(i,N)[3],mesh->vertex(vtxID+3)); + Vec3fa::storeu(&this->vertices(i,num)[0],mesh->vertex(vtxID+0)); + Vec3fa::storeu(&this->vertices(i,num)[1],mesh->vertex(vtxID+1)); + Vec3fa::storeu(&this->vertices(i,num)[2],mesh->vertex(vtxID+2)); + Vec3fa::storeu(&this->vertices(i,num)[3],mesh->vertex(vtxID+3)); } } @@ -89,8 +89,8 @@ namespace embree public: unsigned char data[4*16*M]; - __forceinline Vec3fa* vertices(size_t i, size_t N) { return (Vec3fa*)CurveNi::end(N)+4*i; } - __forceinline const Vec3fa* vertices(size_t i, size_t N) const { return (Vec3fa*)CurveNi::end(N)+4*i; } + __forceinline Vec3fa* vertices(size_t i, size_t num) { return (Vec3fa*)CurveNi::end(num)+4*i; } + __forceinline const Vec3fa* vertices(size_t i, size_t num) const { return (Vec3fa*)CurveNi::end(num)+4*i; } }; template diff --git a/kernels/geometry/curve_intersector_ribbon.h b/kernels/geometry/curve_intersector_ribbon.h index 423fd5b08d..487269ebdb 100644 --- a/kernels/geometry/curve_intersector_ribbon.h +++ b/kernels/geometry/curve_intersector_ribbon.h @@ -30,9 +30,9 @@ namespace embree vt = T; } - __forceinline Vec2f uv (const size_t i) const { return Vec2f(vu[i],vv[i]); } - __forceinline float t (const size_t i) const { return vt[i]; } - __forceinline Vec3fa Ng(const size_t i) const { return curve3D.eval_du(vu[i]); } + __forceinline Vec2f uv (const size_t idx) const { return Vec2f(vu[idx],vv[idx]); } + __forceinline float t (const size_t idx) const { return vt[idx]; } + __forceinline Vec3fa Ng(const size_t idx) const { return curve3D.eval_du(vu[idx]); } __forceinline Vec2vf uv() const { return Vec2vf(vu,vv); } __forceinline vfloat t () const { return vt; } diff --git a/kernels/geometry/curve_intersector_sweep.h b/kernels/geometry/curve_intersector_sweep.h index c5ed5b6236..dc8c47c038 100644 --- a/kernels/geometry/curve_intersector_sweep.h +++ b/kernels/geometry/curve_intersector_sweep.h @@ -130,9 +130,9 @@ namespace embree t+=dt; if (!(ray.tnear() <= t && t <= ray.tfar)) return false; // rejects NaNs if (!(u >= 0.0f && u <= 1.0f)) return false; // rejects NaNs - const Vec3fa R = normalize(Q-P); - const Vec3fa U = madd(Vec3fa(dPdu.w),R,dPdu); - const Vec3fa V = cross(dPdu,R); + const Vec3fa Rnorm = normalize(Q-P); + const Vec3fa U = madd(Vec3fa(dPdu.w),Rnorm,dPdu); + const Vec3fa V = cross(dPdu,Rnorm); BezierCurveHit hit(t,u,cross(V,U)); return epilog(hit); } diff --git a/kernels/geometry/grid_soa.cpp b/kernels/geometry/grid_soa.cpp index 615070be9d..dd5a1b981f 100644 --- a/kernels/geometry/grid_soa.cpp +++ b/kernels/geometry/grid_soa.cpp @@ -82,15 +82,15 @@ namespace embree return bytes; } - size_t GridSOA::getTemporalBVHBytes(const range time_range, const size_t nodeBytes) + size_t GridSOA::getTemporalBVHBytes(const range trange, const size_t nodeBytes) { - if (time_range.size() <= 1) + if (trange.size() <= 1) return 0; size_t bytes = nodeBytes; for (int i=0; i<4; i++) { - const int begin = time_range.begin() + (i+0)*time_range.size()/4; - const int end = time_range.begin() + (i+1)*time_range.size()/4; + const int begin = trange.begin() + (i+0)*trange.size()/4; + const int end = trange.begin() + (i+1)*trange.size()/4; bytes += getTemporalBVHBytes(make_range(begin,end),nodeBytes); } return bytes; @@ -187,12 +187,12 @@ namespace embree } } - std::pair GridSOA::buildMSMBlurBVH(const range time_range, size_t& allocator, BBox3fa* bounds_o) + std::pair GridSOA::buildMSMBlurBVH(const range trange, size_t& allocator, BBox3fa* bounds_o) { - assert(time_range.size() > 0); - if (time_range.size() == 1) + assert(trange.size() > 0); + if (trange.size() == 1) { - size_t t = time_range.begin(); + size_t t = trange.begin(); GridRange range(0,width-1,0,height-1); std::pair root_bounds = buildMBlurBVH(t,range,allocator); root(t) = root_bounds.first; @@ -208,8 +208,8 @@ namespace embree for (int i=0, j=0; i<4; i++) { - const int begin = time_range.begin() + (i+0)*time_range.size()/4; - const int end = time_range.begin() + (i+1)*time_range.size()/4; + const int begin = trange.begin() + (i+0)*trange.size()/4; + const int end = trange.begin() + (i+1)*trange.size()/4; if (end-begin <= 0) continue; std::pair node_bounds = buildMSMBlurBVH(make_range(begin,end),allocator,bounds_o); const float t0 = float(begin)/float(time_steps-1); @@ -222,14 +222,14 @@ namespace embree j++; } - const LBBox3fa lbounds = LBBox3fa([&] ( int i ) { return bounds_o[i]; }, time_range, time_steps-1); + const LBBox3fa lbounds = LBBox3fa([&] ( int i ) { return bounds_o[i]; }, trange, time_steps-1); return std::make_pair(BVH4::encodeNode(node),lbounds); } - std::pair GridSOA::buildMSMBlurBVH(const range time_range, BBox3fa* bounds_o) + std::pair GridSOA::buildMSMBlurBVH(const range trange, BBox3fa* bounds_o) { size_t allocator = 0; - std::pair root = buildMSMBlurBVH(time_range,allocator,bounds_o); + std::pair root = buildMSMBlurBVH(trange,allocator,bounds_o); assert(allocator == gridOffset); return root; } diff --git a/kernels/geometry/grid_soa.h b/kernels/geometry/grid_soa.h index 64d9813434..03e5810ae1 100644 --- a/kernels/geometry/grid_soa.h +++ b/kernels/geometry/grid_soa.h @@ -80,7 +80,7 @@ namespace embree static size_t getBVHBytes(const GridRange& range, const size_t nodeBytes, const size_t leafBytes); /*! returns the size of the temporal BVH over the time range BVHs */ - static size_t getTemporalBVHBytes(const range time_range, const size_t nodeBytes); + static size_t getTemporalBVHBytes(const range trange, const size_t nodeBytes); /*! calculates bounding box of grid range */ __forceinline BBox3fa calculateBounds(size_t time, const GridRange& range) const @@ -113,13 +113,13 @@ namespace embree std::pair buildBVH(const GridRange& range, size_t& allocator); /*! Evaluates grid over patch and builds MSMBlur BVH4 tree over the grid. */ - std::pair buildMSMBlurBVH(const range time_range, BBox3fa* bounds_o); + std::pair buildMSMBlurBVH(const range trange, BBox3fa* bounds_o); /*! Create MBlur BVH4 tree over grid. */ std::pair buildMBlurBVH(size_t time, const GridRange& range, size_t& allocator); /*! Create MSMBlur BVH4 tree over grid. */ - std::pair buildMSMBlurBVH(const range time_range, size_t& allocator, BBox3fa* bounds_o); + std::pair buildMSMBlurBVH(const range trange, size_t& allocator, BBox3fa* bounds_o); template struct MapUV diff --git a/kernels/geometry/instance.h b/kernels/geometry/instance.h index 7c0e7e0f49..83185151a3 100644 --- a/kernels/geometry/instance.h +++ b/kernels/geometry/instance.h @@ -32,8 +32,8 @@ namespace embree public: - InstancePrimitive (const Instance* instance, unsigned int instID) - : instance(instance) + InstancePrimitive (const Instance* inst, unsigned int instID) + : instance(inst) , instID_(instID) {} @@ -42,8 +42,8 @@ namespace embree assert(end-i == 1); const PrimRef& prim = prims[i]; i++; const unsigned int geomID = prim.geomID(); - const Instance* instance = scene->get(geomID); - new (this) InstancePrimitive(instance, geomID); + const Instance* inst = scene->get(geomID); + new (this) InstancePrimitive(inst, geomID); } __forceinline LBBox3fa fillMB(const PrimRef* prims, size_t& i, size_t end, Scene* scene, size_t itime) @@ -51,24 +51,24 @@ namespace embree assert(end-i == 1); const PrimRef& prim = prims[i]; i++; const unsigned int geomID = prim.geomID(); - const Instance* instance = scene->get(geomID); - new (this) InstancePrimitive(instance,geomID); - return instance->linearBounds(0,itime); + const Instance* inst = scene->get(geomID); + new (this) InstancePrimitive(inst,geomID); + return inst->linearBounds(0,itime); } - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f trange) { assert(end-i == 1); const PrimRefMB& prim = prims[i]; i++; const unsigned int geomID = prim.geomID(); - const Instance* instance = scene->get(geomID); - new (this) InstancePrimitive(instance,geomID); - return instance->linearBounds(0,time_range); + const Instance* inst = scene->get(geomID); + new (this) InstancePrimitive(inst,geomID); + return inst->linearBounds(0,trange); } /* Updates the primitive */ - __forceinline BBox3fa update(Instance* instance) { - return instance->bounds(0); + __forceinline BBox3fa update(Instance* inst) { + return inst->bounds(0); } public: diff --git a/kernels/geometry/instance_array.h b/kernels/geometry/instance_array.h index b858649e0d..09404cfe4d 100644 --- a/kernels/geometry/instance_array.h +++ b/kernels/geometry/instance_array.h @@ -62,7 +62,7 @@ namespace embree return instanceArray->linearBounds(primID,itime); } - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f trange) { assert(end-i == 1); const PrimRefMB& prim = prims[i]; i++; @@ -70,7 +70,7 @@ namespace embree const size_t primID = prim.primID(); new (this) InstanceArrayPrimitive(geomID, primID); const InstanceArray* instanceArray = scene->get(geomID); - return instanceArray->linearBounds(primID,time_range); + return instanceArray->linearBounds(primID,trange); } /* Updates the primitive */ diff --git a/kernels/geometry/instance_array_intersector.cpp b/kernels/geometry/instance_array_intersector.cpp index 0cb6f50073..c2510fa2d3 100644 --- a/kernels/geometry/instance_array_intersector.cpp +++ b/kernels/geometry/instance_array_intersector.cpp @@ -56,7 +56,6 @@ namespace embree if (likely(instance_id_stack::push(user_context, prim.instID_, prim.primID_))) { const AffineSpace3fa world2local = instance->getWorld2Local(prim.primID_); - Accel* object = instance->getObject(prim.primID_); const Vec3ff ray_org = ray.org; const Vec3ff ray_dir = ray.dir; ray.org = Vec3ff(xfmPoint(world2local, ray_org), ray.tnear()); diff --git a/kernels/geometry/linei.h b/kernels/geometry/linei.h index 3305025fc9..aedca52598 100644 --- a/kernels/geometry/linei.h +++ b/kernels/geometry/linei.h @@ -41,13 +41,13 @@ namespace embree /* Construction from vertices and IDs */ __forceinline LineMi(const vuint& v0, unsigned short leftExists, unsigned short rightExists, const vuint& geomIDs, const vuint& primIDs, Geometry::GType gtype) - : gtype((unsigned char)gtype), m((unsigned char)popcnt(vuint(primIDs) != vuint(-1))), sharedGeomID(geomIDs[0]), leftExists (leftExists), rightExists(rightExists), v0(v0), primIDs(primIDs) + : gtype((unsigned char)gtype), m((unsigned char)popcnt(vuint(primIDs) != vuint((unsigned int)-1))), sharedGeomID(geomIDs[0]), leftExists (leftExists), rightExists(rightExists), v0(v0), primIDs(primIDs) { assert(all(vuint(geomID()) == geomIDs)); } /* Returns a mask that tells which line segments are valid */ - __forceinline vbool valid() const { return primIDs != vuint(-1); } + __forceinline vbool valid() const { return primIDs != vuint((unsigned)-1); } /* Returns if the specified line segment is valid */ __forceinline bool valid(const size_t i) const { assert(iget(geomID((unsigned int)i)); - allBounds.extend(geom->linearBounds(primID(i), time_range)); + allBounds.extend(geom->linearBounds(primID(i), trange)); } return allBounds; } @@ -173,9 +173,9 @@ namespace embree { Geometry::GType gty = scene->get(prims[begin].geomID())->getType(); vuint geomID, primID; - vuint v0; - unsigned short leftExists = 0; - unsigned short rightExists = 0; + vuint lv0; + unsigned short lLeftExists = 0; + unsigned short lRightExists = 0; const PrimRefT* prim = &prims[begin]; for (size_t i=0; igeomID(); primID[i] = prim->primID(); - v0[i] = geom->segment(prim->primID()); - leftExists |= geom->segmentLeftExists(primID[i]) << i; - rightExists |= geom->segmentRightExists(primID[i]) << i; + lv0[i] = geom->segment(prim->primID()); + lLeftExists |= geom->segmentLeftExists(primID[i]) << i; + lRightExists |= geom->segmentRightExists(primID[i]) << i; begin++; } else { assert(i); if (i>0) { geomID[i] = geomID[i-1]; - primID[i] = -1; - v0[i] = v0[i-1]; + primID[i] = (unsigned int)-1; + lv0[i] = lv0[i-1]; } } if (begin @@ -220,10 +220,10 @@ namespace embree return linearBounds(scene,itime); } - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f trange) { fill(prims,begin,end,scene); - return linearBounds(scene,time_range); + return linearBounds(scene,trange); } template diff --git a/kernels/geometry/object.h b/kernels/geometry/object.h index 9525b97880..4035461b4e 100644 --- a/kernels/geometry/object.h +++ b/kernels/geometry/object.h @@ -62,25 +62,25 @@ namespace embree } /*! fill triangle from triangle list */ - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t i, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t i, Scene* scene, const BBox1f trange) { const PrimRefMB& prim = prims[i]; i++; const unsigned geomID = prim.geomID(); const unsigned primID = prim.primID(); new (this) Object(geomID, primID); AccelSet* accel = (AccelSet*) scene->get(geomID); - return accel->linearBounds(primID,time_range); + return accel->linearBounds(primID,trange); } /*! fill triangle from triangle list */ - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f trange) { const PrimRefMB& prim = prims[i]; i++; const unsigned geomID = prim.geomID(); const unsigned primID = prim.primID(); new (this) Object(geomID, primID); AccelSet* accel = (AccelSet*) scene->get(geomID); - return accel->linearBounds(primID,time_range); + return accel->linearBounds(primID,trange); } /* Updates the primitive */ diff --git a/kernels/geometry/pointi.h b/kernels/geometry/pointi.h index aba8ec4ab3..142eec3c8c 100644 --- a/kernels/geometry/pointi.h +++ b/kernels/geometry/pointi.h @@ -124,12 +124,12 @@ namespace embree return allBounds; } - __forceinline LBBox3fa linearBounds(const Scene* const scene, const BBox1f time_range) + __forceinline LBBox3fa linearBounds(const Scene* const scene, const BBox1f trange) { LBBox3fa allBounds = empty; for (size_t i = 0; i < M && valid(i); i++) { const Points* geom = scene->get(geomID((unsigned int)i)); - allBounds.extend(geom->linearBounds(primID(i), time_range)); + allBounds.extend(geom->linearBounds(primID(i), trange)); } return allBounds; } @@ -143,13 +143,13 @@ namespace embree vuint v0; const PrimRefT* prim = &prims[begin]; - int numPrimitives = 0; + int primCount = 0; for (size_t i = 0; i < M; i++) { if (begin < end) { geomID[i] = prim->geomID(); primID[i] = prim->primID(); begin++; - numPrimitives++; + primCount++; } else { assert(i); if (i > 0) { @@ -160,7 +160,7 @@ namespace embree if (begin < end) prim = &prims[begin]; // FIXME: remove this line } - new (this) PointMi(geomID, primID, gty, numPrimitives); // FIXME: use non temporal store + new (this) PointMi(geomID, primID, gty, primCount); // FIXME: use non temporal store } template @@ -186,10 +186,10 @@ namespace embree } __forceinline LBBox3fa fillMB( - const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f time_range) + const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f trange) { fill(prims, begin, end, scene); - return linearBounds(scene, time_range); + return linearBounds(scene, trange); } template diff --git a/kernels/geometry/quadi.h b/kernels/geometry/quadi.h index 70a7bdf158..6d97df860b 100644 --- a/kernels/geometry/quadi.h +++ b/kernels/geometry/quadi.h @@ -52,7 +52,7 @@ namespace embree #endif /* Returns a mask that tells which quads are valid */ - __forceinline vbool valid() const { return primIDs != vuint(-1); } + __forceinline vbool valid() const { return primIDs != vuint((unsigned int)-1); } /* Returns if the specified quad is valid */ __forceinline bool valid(const size_t i) const { assert(iget(geomID(i)); - allBounds.extend(mesh->linearBounds(primID(i), time_range)); + allBounds.extend(mesh->linearBounds(primID(i), trange)); } return allBounds; } @@ -112,7 +112,7 @@ namespace embree template __forceinline void fill(const PrimRefT* prims, size_t& begin, size_t end, Scene* scene) { - vuint geomID = -1, primID = -1; + vuint geomID = (unsigned int)-1, primID = (unsigned int)-1; const PrimRefT* prim = &prims[begin]; vuint v0 = zero, v1 = zero, v2 = zero, v3 = zero; @@ -135,7 +135,7 @@ namespace embree assert(i); if (likely(i > 0)) { geomID[i] = geomID[0]; // always valid geomIDs - primID[i] = -1; // indicates invalid data + primID[i] = (unsigned int)-1; // indicates invalid data v0[i] = v0[0]; v1[i] = v0[0]; v2[i] = v0[0]; @@ -153,10 +153,10 @@ namespace embree return linearBounds(scene, itime); } - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f trange) { fill(prims, begin, end, scene); - return linearBounds(scene, time_range); + return linearBounds(scene, trange); } friend embree_ostream operator<<(embree_ostream cout, const QuadMi& quad) { diff --git a/kernels/geometry/quadv.h b/kernels/geometry/quadv.h index 514e519b0c..190f1ed6b7 100644 --- a/kernels/geometry/quadv.h +++ b/kernels/geometry/quadv.h @@ -39,7 +39,7 @@ namespace embree : v0(v0), v1(v1), v2(v2), v3(v3), geomIDs(geomIDs), primIDs(primIDs) {} /* Returns a mask that tells which quads are valid */ - __forceinline vbool valid() const { return geomIDs != vuint(-1); } + __forceinline vbool valid() const { return geomIDs != vuint((unsigned int)-1); } /* Returns true if the specified quad is valid */ __forceinline bool valid(const size_t i) const { assert(i vgeomID = -1, vprimID = -1; - Vec3vf v0 = zero, v1 = zero, v2 = zero, v3 = zero; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero, lv3 = zero; for (size_t i=0; ivertex(quad.v[3]); vgeomID [i] = geomID; vprimID [i] = primID; - v0.x[i] = p0.x; v0.y[i] = p0.y; v0.z[i] = p0.z; - v1.x[i] = p1.x; v1.y[i] = p1.y; v1.z[i] = p1.z; - v2.x[i] = p2.x; v2.y[i] = p2.y; v2.z[i] = p2.z; - v3.x[i] = p3.x; v3.y[i] = p3.y; v3.z[i] = p3.z; + lv0.x[i] = p0.x; lv0.y[i] = p0.y; lv0.z[i] = p0.z; + lv1.x[i] = p1.x; lv1.y[i] = p1.y; lv1.z[i] = p1.z; + lv2.x[i] = p2.x; lv2.y[i] = p2.y; lv2.z[i] = p2.z; + lv3.x[i] = p3.x; lv3.y[i] = p3.y; lv3.z[i] = p3.z; } - QuadMv::store_nt(this,QuadMv(v0,v1,v2,v3,vgeomID,vprimID)); + QuadMv::store_nt(this,QuadMv(lv0,lv1,lv2,lv3,vgeomID,vprimID)); } /* Updates the primitive */ __forceinline BBox3fa update(QuadMesh* mesh) { BBox3fa bounds = empty; - vuint vgeomID = -1, vprimID = -1; - Vec3vf v0 = zero, v1 = zero, v2 = zero; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero; for (size_t i=0; i valid() const { return geomIDs != vuint(-1); } + __forceinline vbool valid() const { return geomIDs != vuint((unsigned int)-1); } /* Returns true if the specified triangle is valid */ __forceinline bool valid(const size_t i) const { assert(i vgeomID = -1, vprimID = -1; - Vec3vf v0 = zero, v1 = zero, v2 = zero; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero; for (size_t i=0; ivertex(tri.v[2]); vgeomID [i] = geomID; vprimID [i] = primID; - v0.x[i] = p0.x; v0.y[i] = p0.y; v0.z[i] = p0.z; - v1.x[i] = p1.x; v1.y[i] = p1.y; v1.z[i] = p1.z; - v2.x[i] = p2.x; v2.y[i] = p2.y; v2.z[i] = p2.z; + lv0.x[i] = p0.x; lv0.y[i] = p0.y; lv0.z[i] = p0.z; + lv1.x[i] = p1.x; lv1.y[i] = p1.y; lv1.z[i] = p1.z; + lv2.x[i] = p2.x; lv2.y[i] = p2.y; lv2.z[i] = p2.z; } - TriangleM::store_nt(this,TriangleM(v0,v1,v2,vgeomID,vprimID)); + TriangleM::store_nt(this,TriangleM(lv0,lv1,lv2,vgeomID,vprimID)); } /* Updates the primitive */ __forceinline BBox3fa update(TriangleMesh* mesh) { BBox3fa bounds = empty; - vuint vgeomID = -1, vprimID = -1; - Vec3vf v0 = zero, v1 = zero, v2 = zero; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero; for (size_t i=0; i valid() const { return primIDs != vuint(-1); } + __forceinline vbool valid() const { return primIDs != vuint((unsigned int)-1); } /* Returns if the specified triangle is valid */ __forceinline bool valid(const size_t i) const { assert(iget(geomID(i)); - allBounds.extend(mesh->linearBounds(primID(i), time_range)); + allBounds.extend(mesh->linearBounds(primID(i), trange)); } return allBounds; } @@ -122,7 +122,7 @@ namespace embree __forceinline void fill(const PrimRefT* prims, size_t& begin, size_t end, Scene* scene) { vuint v0 = zero, v1 = zero, v2 = zero; - vuint geomID = -1, primID = -1; + vuint geomID = (unsigned int)-1, primID = (unsigned int)-1; const PrimRefT* prim = &prims[begin]; for (size_t i=0; i 0)) { geomID[i] = geomID[0]; - primID[i] = -1; + primID[i] = (unsigned int)-1; v0[i] = v0[0]; v1[i] = v0[0]; v2[i] = v0[0]; @@ -160,10 +160,10 @@ namespace embree return linearBounds(scene, itime); } - __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f time_range) + __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& begin, size_t end, Scene* scene, const BBox1f trange) { fill(prims, begin, end, scene); - return linearBounds(scene, time_range); + return linearBounds(scene, trange); } /* Updates the primitive */ diff --git a/kernels/geometry/trianglev.h b/kernels/geometry/trianglev.h index cd94756b9e..2c5a4301e9 100644 --- a/kernels/geometry/trianglev.h +++ b/kernels/geometry/trianglev.h @@ -39,7 +39,7 @@ namespace embree : v0(v0), v1(v1), v2(v2), geomIDs(geomIDs), primIDs(primIDs) {} /* Returns a mask that tells which triangles are valid */ - __forceinline vbool valid() const { return geomIDs != vuint(-1); } + __forceinline vbool valid() const { return geomIDs != vuint((unsigned int)-1); } /* Returns true if the specified triangle is valid */ __forceinline bool valid(const size_t i) const { assert(i vgeomID = -1, vprimID = -1; - Vec3vf v0 = zero, v1 = zero, v2 = zero; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero; for (size_t i=0; ivertex(tri.v[2]); vgeomID [i] = geomID; vprimID [i] = primID; - v0.x[i] = p0.x; v0.y[i] = p0.y; v0.z[i] = p0.z; - v1.x[i] = p1.x; v1.y[i] = p1.y; v1.z[i] = p1.z; - v2.x[i] = p2.x; v2.y[i] = p2.y; v2.z[i] = p2.z; + lv0.x[i] = p0.x; lv0.y[i] = p0.y; lv0.z[i] = p0.z; + lv1.x[i] = p1.x; lv1.y[i] = p1.y; lv1.z[i] = p1.z; + lv2.x[i] = p2.x; lv2.y[i] = p2.y; lv2.z[i] = p2.z; } TriangleMv::store_nt(this,TriangleMv(v0,v1,v2,vgeomID,vprimID)); } @@ -118,8 +118,8 @@ namespace embree __forceinline BBox3fa update(TriangleMesh* mesh) { BBox3fa bounds = empty; - vuint vgeomID = -1, vprimID = -1; - Vec3vf v0 = zero, v1 = zero, v2 = zero; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero; for (size_t i=0; i valid() const { return geomIDs != vuint(-1); } + __forceinline vbool valid() const { return geomIDs != vuint((unsigned int)-1); } /* Returns if the specified triangle is valid */ __forceinline bool valid(const size_t i) const { assert(i vgeomID = -1, vprimID = -1; + vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; Vec3vf va0 = zero, vb0 = zero, vc0 = zero; Vec3vf va1 = zero, vb1 = zero, vc1 = zero; @@ -153,11 +153,11 @@ namespace embree const unsigned geomID = prim.geomID(); const unsigned primID = prim.primID(); const TriangleMesh* const mesh = scene->get(geomID); - const range itime_range = mesh->timeSegmentRange(time_range); + const range itime_range = mesh->timeSegmentRange(trange); assert(itime_range.size() == 1); const int ilower = itime_range.begin(); const TriangleMesh::Triangle& tri = mesh->triangle(primID); - allBounds.extend(mesh->linearBounds(primID, time_range)); + allBounds.extend(mesh->linearBounds(primID, trange)); const Vec3fa& a0 = mesh->vertex(tri.v[0],size_t(ilower+0)); const Vec3fa& a1 = mesh->vertex(tri.v[0],size_t(ilower+1)); const Vec3fa& b0 = mesh->vertex(tri.v[1],size_t(ilower+0)); diff --git a/kernels/subdiv/bezier_curve.h b/kernels/subdiv/bezier_curve.h index 46f60c5acf..3f3bf7219b 100644 --- a/kernels/subdiv/bezier_curve.h +++ b/kernels/subdiv/bezier_curve.h @@ -634,10 +634,10 @@ namespace embree { if (likely(N == 4)) { - const Vec4vf4 pi = eval0<4>(0,4); - const Vec3fa lower(reduce_min(pi.x),reduce_min(pi.y),reduce_min(pi.z)); - const Vec3fa upper(reduce_max(pi.x),reduce_max(pi.y),reduce_max(pi.z)); - const Vec3fa upper_r = Vec3fa(reduce_max(abs(pi.w))); + const Vec4vf4 pt = eval0<4>(0,4); + const Vec3fa lower(reduce_min(pt.x),reduce_min(pt.y),reduce_min(pt.z)); + const Vec3fa upper(reduce_max(pt.x),reduce_max(pt.y),reduce_max(pt.z)); + const Vec3fa upper_r = Vec3fa(reduce_max(abs(pt.w))); return enlarge(BBox3fa(min(lower,v3),max(upper,v3)),max(upper_r,Vec3fa(abs(v3.w)))); } else @@ -646,17 +646,17 @@ namespace embree for (int i=0; i(i,N); + const Vec4vfx pt = eval0(i,N); - pl.x = select(valid,min(pl.x,pi.x),pl.x); // FIXME: use masked min - pl.y = select(valid,min(pl.y,pi.y),pl.y); - pl.z = select(valid,min(pl.z,pi.z),pl.z); + pl.x = select(valid,min(pl.x,pt.x),pl.x); // FIXME: use masked min + pl.y = select(valid,min(pl.y,pt.y),pl.y); + pl.z = select(valid,min(pl.z,pt.z),pl.z); - pu.x = select(valid,max(pu.x,pi.x),pu.x); // FIXME: use masked min - pu.y = select(valid,max(pu.y,pi.y),pu.y); - pu.z = select(valid,max(pu.z,pi.z),pu.z); + pu.x = select(valid,max(pu.x,pt.x),pu.x); // FIXME: use masked min + pu.y = select(valid,max(pu.y,pt.y),pu.y); + pu.z = select(valid,max(pu.z,pt.z),pu.z); - ru = select(valid,max(ru,abs(pi.w)),ru); + ru = select(valid,max(ru,abs(pt.w)),ru); } const Vec3fa lower(reduce_min(pl.x),reduce_min(pl.y),reduce_min(pl.z)); const Vec3fa upper(reduce_max(pu.x),reduce_max(pu.y),reduce_max(pu.z)); @@ -729,3 +729,4 @@ namespace embree enlargeRadiusToMinWidth(context,geom,ray_org,curve.v3)); } } + diff --git a/kernels/subdiv/bilinear_patch.h b/kernels/subdiv/bilinear_patch.h index cade104a6c..5474f7f5b6 100644 --- a/kernels/subdiv/bilinear_patch.h +++ b/kernels/subdiv/bilinear_patch.h @@ -83,21 +83,21 @@ namespace embree return cross(eval_du(uu,vv),eval_dv(uu,vv)); } - __forceinline void eval(const float u, const float v, + __forceinline void eval(const float u, const float vv, Vertex* P, Vertex* dPdu, Vertex* dPdv, Vertex* ddPdudu, Vertex* ddPdvdv, Vertex* ddPdudv, const float dscale = 1.0f) const { if (P) { - *P = eval(u,v); + *P = eval(u,vv); } if (dPdu) { - assert(dPdu); *dPdu = eval_du(u,v)*dscale; - assert(dPdv); *dPdv = eval_dv(u,v)*dscale; + assert(dPdu); *dPdu = eval_du(u,vv)*dscale; + assert(dPdv); *dPdv = eval_dv(u,vv)*dscale; } if (ddPdudu) { - assert(ddPdudu); *ddPdudu = eval_dudu(u,v)*sqr(dscale); - assert(ddPdvdv); *ddPdvdv = eval_dvdv(u,v)*sqr(dscale); - assert(ddPdudv); *ddPdudv = eval_dudv(u,v)*sqr(dscale); + assert(ddPdudu); *ddPdudu = eval_dudu(u,vv)*sqr(dscale); + assert(ddPdvdv); *ddPdvdv = eval_dvdv(u,vv)*sqr(dscale); + assert(ddPdudv); *ddPdudv = eval_dudv(u,vv)*sqr(dscale); } } diff --git a/kernels/subdiv/bspline_curve.h b/kernels/subdiv/bspline_curve.h index 5d25ebb8e4..14fdd68c7d 100644 --- a/kernels/subdiv/bspline_curve.h +++ b/kernels/subdiv/bspline_curve.h @@ -245,10 +245,10 @@ namespace embree { if (likely(N == 4)) { - const Vec4vf4 pi = eval0<4>(0,4); - const Vec3fa lower(reduce_min(pi.x),reduce_min(pi.y),reduce_min(pi.z)); - const Vec3fa upper(reduce_max(pi.x),reduce_max(pi.y),reduce_max(pi.z)); - const Vec3fa upper_r = Vec3fa(reduce_max(abs(pi.w))); + const Vec4vf4 pt = eval0<4>(0,4); + const Vec3fa lower(reduce_min(pt.x),reduce_min(pt.y),reduce_min(pt.z)); + const Vec3fa upper(reduce_max(pt.x),reduce_max(pt.y),reduce_max(pt.z)); + const Vec3fa upper_r = Vec3fa(reduce_max(abs(pt.w))); const Vec3ff pe = end(); return enlarge(BBox3fa(min(lower,pe),max(upper,pe)),max(upper_r,Vec3fa(abs(pe.w)))); } @@ -258,17 +258,17 @@ namespace embree for (int i=0; i<=N; i+=VSIZEX) { vboolx valid = vintx(i)+vintx(step) <= vintx(N); - const Vec4vfx pi = eval0(i,N); + const Vec4vfx pt = eval0(i,N); - pl.x = select(valid,min(pl.x,pi.x),pl.x); // FIXME: use masked min - pl.y = select(valid,min(pl.y,pi.y),pl.y); - pl.z = select(valid,min(pl.z,pi.z),pl.z); + pl.x = select(valid,min(pl.x,pt.x),pl.x); // FIXME: use masked min + pl.y = select(valid,min(pl.y,pt.y),pl.y); + pl.z = select(valid,min(pl.z,pt.z),pl.z); - pu.x = select(valid,max(pu.x,pi.x),pu.x); // FIXME: use masked min - pu.y = select(valid,max(pu.y,pi.y),pu.y); - pu.z = select(valid,max(pu.z,pi.z),pu.z); + pu.x = select(valid,max(pu.x,pt.x),pu.x); // FIXME: use masked min + pu.y = select(valid,max(pu.y,pt.y),pu.y); + pu.z = select(valid,max(pu.z,pt.z),pu.z); - ru = select(valid,max(ru,abs(pi.w)),ru); + ru = select(valid,max(ru,abs(pt.w)),ru); } const Vec3fa lower(reduce_min(pl.x),reduce_min(pl.y),reduce_min(pl.z)); const Vec3fa upper(reduce_max(pu.x),reduce_max(pu.y),reduce_max(pu.z)); @@ -324,3 +324,4 @@ namespace embree typedef BSplineCurveT BSplineCurve3fa; } + diff --git a/kernels/subdiv/bspline_patch.h b/kernels/subdiv/bspline_patch.h index ff47f01c7a..e67bb47bf1 100644 --- a/kernels/subdiv/bspline_patch.h +++ b/kernels/subdiv/bspline_patch.h @@ -82,10 +82,11 @@ namespace embree const Vertex& v10, const Vertex& v11, const Vertex& v12, const Vertex& v20, const Vertex& v21, const Vertex& v22) { - const bool MAYBE_UNUSED has_back1 = edge0.has_opposite_back(1); - const bool has_back0 = edge0.has_opposite_back(0); - const bool has_front1 = edge0.has_opposite_front(1); + const bool MAYBE_UNUSED has_back1 = edge0.has_opposite_back(1); + const bool has_back0 = edge0.has_opposite_back(0); + const bool has_front1 = edge0.has_opposite_front(1); const bool MAYBE_UNUSED has_front2 = edge0.has_opposite_front(2); + (void)has_back1; (void)has_front2; if (likely(has_back0)) { if (likely(has_front1)) { assert(has_back1 && has_front2); v00 = edge0.back(3); } @@ -357,21 +358,21 @@ namespace embree return cross(eval_du(uu,vv),eval_dv(uu,vv)); } - void eval(const float u, const float v, + void eval(const float u, const float vv, Vertex* P, Vertex* dPdu, Vertex* dPdv, Vertex* ddPdudu, Vertex* ddPdvdv, Vertex* ddPdudv, const float dscale = 1.0f) const { if (P) { - *P = eval(u,v); + *P = eval(u,vv); } if (dPdu) { - assert(dPdu); *dPdu = eval_du(u,v)*dscale; - assert(dPdv); *dPdv = eval_dv(u,v)*dscale; + assert(dPdu); *dPdu = eval_du(u,vv)*dscale; + assert(dPdv); *dPdv = eval_dv(u,vv)*dscale; } if (ddPdudu) { - assert(ddPdudu); *ddPdudu = eval_dudu(u,v)*sqr(dscale); - assert(ddPdvdv); *ddPdvdv = eval_dvdv(u,v)*sqr(dscale); - assert(ddPdudv); *ddPdudv = eval_dudv(u,v)*sqr(dscale); + assert(ddPdudu); *ddPdudu = eval_dudu(u,vv)*sqr(dscale); + assert(ddPdvdv); *ddPdvdv = eval_dvdv(u,vv)*sqr(dscale); + assert(ddPdudv); *ddPdudv = eval_dudv(u,vv)*sqr(dscale); } } diff --git a/kernels/subdiv/catmullclark_ring.h b/kernels/subdiv/catmullclark_ring.h index eab91d9ee6..0b10f36cbc 100644 --- a/kernels/subdiv/catmullclark_ring.h +++ b/kernels/subdiv/catmullclark_ring.h @@ -174,13 +174,13 @@ namespace embree else { /* find minimum start vertex */ - const unsigned index0 = p->getStartVertexIndex(); - if (index0 < min_vertex_index) { min_vertex_index = index0; min_vertex_index_face = i>>1; } + const unsigned borderIndex0 = p->getStartVertexIndex(); + if (borderIndex0 < min_vertex_index) { min_vertex_index = borderIndex0; min_vertex_index_face = i>>1; } /*! mark first border edge and store dummy vertex for face between the two border edges */ border_index = i; crease_weight[i/2] = inf; - ring[i++] = Vertex_t::loadu(vertices+index0*stride); + ring[i++] = Vertex_t::loadu(vertices+borderIndex0*stride); ring[i++] = vtx; // dummy vertex /*! goto other side of border */ @@ -620,8 +620,8 @@ namespace embree else { /* find minimum start vertex */ - unsigned vertex_index = p->getStartVertexIndex(); - if (vertex_index < min_vertex_index) { min_vertex_index = vertex_index; min_vertex_index_face = f; min_vertex_index_vertex = e; } + unsigned border_vertex_index = p->getStartVertexIndex(); + if (border_vertex_index < min_vertex_index) { min_vertex_index = border_vertex_index; min_vertex_index_face = f; min_vertex_index_vertex = e; } /*! mark first border edge and store dummy vertex for face between the two border edges */ border_face = f; diff --git a/kernels/subdiv/catmullrom_curve.h b/kernels/subdiv/catmullrom_curve.h index c42435b9d7..7ced302b12 100644 --- a/kernels/subdiv/catmullrom_curve.h +++ b/kernels/subdiv/catmullrom_curve.h @@ -253,10 +253,10 @@ namespace embree { if (likely(N == 4)) { - const Vec4vf4 pi = eval0<4>(0,4); - const Vec3fa lower(reduce_min(pi.x),reduce_min(pi.y),reduce_min(pi.z)); - const Vec3fa upper(reduce_max(pi.x),reduce_max(pi.y),reduce_max(pi.z)); - const Vec3fa upper_r = Vec3fa(reduce_max(abs(pi.w))); + const Vec4vf4 pt = eval0<4>(0,4); + const Vec3fa lower(reduce_min(pt.x),reduce_min(pt.y),reduce_min(pt.z)); + const Vec3fa upper(reduce_max(pt.x),reduce_max(pt.y),reduce_max(pt.z)); + const Vec3fa upper_r = Vec3fa(reduce_max(abs(pt.w))); const Vec3ff pe = end(); return enlarge(BBox3fa(min(lower,pe),max(upper,pe)),max(upper_r,Vec3fa(abs(pe.w)))); } @@ -266,17 +266,17 @@ namespace embree for (int i=0; i<=N; i+=VSIZEX) { vboolx valid = vintx(i)+vintx(step) <= vintx(N); - const Vec4vfx pi = eval0(i,N); + const Vec4vfx pt = eval0(i,N); - pl.x = select(valid,min(pl.x,pi.x),pl.x); // FIXME: use masked min - pl.y = select(valid,min(pl.y,pi.y),pl.y); - pl.z = select(valid,min(pl.z,pi.z),pl.z); + pl.x = select(valid,min(pl.x,pt.x),pl.x); // FIXME: use masked min + pl.y = select(valid,min(pl.y,pt.y),pl.y); + pl.z = select(valid,min(pl.z,pt.z),pl.z); - pu.x = select(valid,max(pu.x,pi.x),pu.x); // FIXME: use masked min - pu.y = select(valid,max(pu.y,pi.y),pu.y); - pu.z = select(valid,max(pu.z,pi.z),pu.z); + pu.x = select(valid,max(pu.x,pt.x),pu.x); // FIXME: use masked min + pu.y = select(valid,max(pu.y,pt.y),pu.y); + pu.z = select(valid,max(pu.z,pt.z),pu.z); - ru = select(valid,max(ru,abs(pi.w)),ru); + ru = select(valid,max(ru,abs(pt.w)),ru); } const Vec3fa lower(reduce_min(pl.x),reduce_min(pl.y),reduce_min(pl.z)); const Vec3fa upper(reduce_max(pu.x),reduce_max(pu.y),reduce_max(pu.z)); @@ -312,3 +312,4 @@ namespace embree typedef CatmullRomCurveT CatmullRomCurve3fa; } + diff --git a/kernels/subdiv/gregory_patch.h b/kernels/subdiv/gregory_patch.h index 9026d5c407..637e489854 100644 --- a/kernels/subdiv/gregory_patch.h +++ b/kernels/subdiv/gregory_patch.h @@ -562,22 +562,22 @@ namespace embree return normal(v,f,uu,vv); } - __forceinline void eval(const float u, const float v, + __forceinline void eval(const float u, const float vv, Vertex* P, Vertex* dPdu, Vertex* dPdv, Vertex* ddPdudu, Vertex* ddPdvdv, Vertex* ddPdudv, const float dscale = 1.0f) const { if (P) { - *P = eval(u,v); + *P = eval(u,vv); } if (dPdu) { - assert(dPdu); *dPdu = eval_du(u,v)*dscale; - assert(dPdv); *dPdv = eval_dv(u,v)*dscale; + assert(dPdu); *dPdu = eval_du(u,vv)*dscale; + assert(dPdv); *dPdv = eval_dv(u,vv)*dscale; } if (ddPdudu) { - assert(ddPdudu); *ddPdudu = eval_dudu(u,v)*sqr(dscale); - assert(ddPdvdv); *ddPdvdv = eval_dvdv(u,v)*sqr(dscale); - assert(ddPdudv); *ddPdudv = eval_dudv(u,v)*sqr(dscale); + assert(ddPdudu); *ddPdudu = eval_dudu(u,vv)*sqr(dscale); + assert(ddPdvdv); *ddPdvdv = eval_dvdv(u,vv)*sqr(dscale); + assert(ddPdudv); *ddPdudv = eval_dudv(u,vv)*sqr(dscale); } } diff --git a/kernels/subdiv/half_edge.h b/kernels/subdiv/half_edge.h index 8cb4f24845..1c2fb0c5a7 100644 --- a/kernels/subdiv/half_edge.h +++ b/kernels/subdiv/half_edge.h @@ -47,7 +47,7 @@ namespace embree }; HalfEdge () - : vtx_index(-1), next_half_edge_ofs(0), prev_half_edge_ofs(0), opposite_half_edge_ofs(0), edge_crease_weight(0), + : vtx_index((unsigned int)-1), next_half_edge_ofs(0), prev_half_edge_ofs(0), opposite_half_edge_ofs(0), edge_crease_weight(0), vertex_crease_weight(0), edge_level(0), patch_type(COMPLEX_PATCH), vertex_type(REGULAR_VERTEX) { static_assert(sizeof(HalfEdge) == 32, "invalid half edge size"); @@ -313,8 +313,8 @@ namespace embree if (!isvalid(v)) return false; size_t n = 1; for (const HalfEdge* p = next(); p!=this; p=p->next(), n++) { - const Vec3fa v = vertices[p->getStartVertexIndex()]; - if (!isvalid(v)) return false; + const Vec3fa edge_v = vertices[p->getStartVertexIndex()]; + if (!isvalid(edge_v)) return false; } if (n < 2) return false; N += n-2; diff --git a/kernels/subdiv/patch_eval_grid.h b/kernels/subdiv/patch_eval_grid.h index 167e1ebe1c..ada111e525 100644 --- a/kernels/subdiv/patch_eval_grid.h +++ b/kernels/subdiv/patch_eval_grid.h @@ -50,7 +50,8 @@ namespace embree assert(swidth < (2<<20) && sheight < (2<<20)); const BBox2f srange(Vec2f(0.0f,0.0f),Vec2f(float(swidth-1),float(sheight-1))); const BBox2f erange(Vec2f(float(x0),float(y0)),Vec2f((float)x1,(float)y1)); - bool done MAYBE_UNUSED = eval(patch,subPatch,srange,erange); + bool done = eval(patch,subPatch,srange,erange); + (void)done; assert(done); assert(count == (x1-x0+1)*(y1-y0+1)); } @@ -228,8 +229,8 @@ namespace embree { assert(i 16"); - const int h = (i >> 2) & 3, l = i & 3; - const Vec2f subPatchID((float)l,(float)h); + const int innerH = (i >> 2) & 3, l = i & 3; + const Vec2f subPatchID((float)l,(float)innerH); const Vec2f uv[4] = { 2.0f*subPatchID + (0.5f+Vec2f(0.0f,0.0f)), 2.0f*subPatchID + (0.5f+Vec2f(1.0f,0.0f)), 2.0f*subPatchID + (0.5f+Vec2f(1.0f,1.0f)), @@ -242,4 +243,3 @@ namespace embree } } } - diff --git a/kernels/subdiv/tessellation_cache.h b/kernels/subdiv/tessellation_cache.h index 99edf49be4..25f518fc8e 100644 --- a/kernels/subdiv/tessellation_cache.h +++ b/kernels/subdiv/tessellation_cache.h @@ -285,7 +285,7 @@ namespace embree static __forceinline void* malloc(const size_t bytes) { - size_t block_index = -1; + size_t block_index = (size_t)-1; ThreadWorkState *const t_state = threadState(); while (true) { From 4931c786f67b6442ae2e5e036f6f5437a99fae93 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 16 Jun 2026 11:27:12 +0200 Subject: [PATCH 08/19] Fix MSVC /W4 warnings in tutorials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve all MSVC warnings under /W4 /WX across every tutorial and the shared tutorial infrastructure. Warning categories fixed: C4189 unused initialized local (alloc.h 'done' pattern) C4245 signed/unsigned mismatch — ray/shadow mask initialisation (mask = -1 -> 0xFFFFFFFFu) and size_t argument mismatches C4389 signed/unsigned mismatch in == operator C4456 local hides outer local — shadowed loop variables (i, j), mesh, hgeom, vertices, quad, tri C4457 local hides function parameter (v in geometry lambdas) C4458 local hides class member (N, ivariant, sampler) C4459 local hides global — renderPixelStandard/postIntersect/ createPoints 'data' parameter renamed to 'td' throughout; quaternion_motion_blur 'qdc' parameter renamed C4505 unreferenced static function — benchmark.h helpers changed from 'static MAYBE_UNUSED' to 'inline' C5051 [[maybe_unused]] / [[fallthrough]] require /std:c++17; replaced with MAYBE_UNUSED macro and /* falls through */ comments respectively Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tutorials/buildbench/buildbench_device.cpp | 56 +-- tutorials/collide/collide_device.cpp | 32 +- tutorials/common/image/exr.cpp | 8 + tutorials/common/imgui/CMakeLists.txt | 4 +- .../common/scenegraph/geometry_creation.cpp | 22 +- tutorials/common/scenegraph/obj_loader.cpp | 24 +- tutorials/common/scenegraph/ply_loader.cpp | 6 +- tutorials/common/scenegraph/scenegraph.cpp | 474 +++++++++--------- tutorials/common/scenegraph/scenegraph.h | 29 +- tutorials/common/scenegraph/texture.cpp | 2 +- tutorials/common/scenegraph/xml_loader.cpp | 18 +- tutorials/common/scenegraph/xml_parser.h | 4 +- tutorials/common/scenegraph/xml_writer.cpp | 68 +-- tutorials/common/tutorial/benchmark.h | 4 +- tutorials/common/tutorial/noise.cpp | 8 +- tutorials/common/tutorial/scene_device.cpp | 60 +-- tutorials/common/tutorial/scene_device.h | 2 +- tutorials/common/tutorial/tutorial.cpp | 68 +-- tutorials/common/tutorial/tutorial_device.cpp | 14 +- .../curve_geometry/curve_geometry_device.cpp | 38 +- .../dynamic_scene/dynamic_scene_device.cpp | 8 +- .../parallel_for_for_prefix_sum.cpp | 12 +- .../common/algorithms/parallel_partition.cpp | 6 +- tutorials/forest/forest_device.cpp | 30 +- .../grid_geometry/grid_geometry_device.cpp | 40 +- .../hair_geometry/hair_geometry_device.cpp | 38 +- .../host_device_memory_device.cpp | 8 +- .../instanced_geometry_device.cpp | 16 +- .../interpolation/interpolation_device.cpp | 14 +- .../intersection_filter_device.cpp | 8 +- tutorials/minimal/minimal.cpp | 2 +- tutorials/minimal/minimal_sycl.cpp | 2 +- .../motion_blur_geometry_device.cpp | 26 +- .../multiscene_geometry_device.cpp | 8 +- tutorials/next_hit/next_hit_device.cpp | 66 +-- tutorials/pathtracer/pathtracer_device.cpp | 136 ++--- .../point_geometry/point_geometry_device.cpp | 8 +- .../quaternion_motion_blur_device.cpp | 34 +- tutorials/ray_mask/ray_mask_device.cpp | 12 +- .../triangle_geometry_device.cpp | 8 +- .../user_geometry/user_geometry_device.cpp | 22 +- tutorials/verify/rtcore_helpers.h | 32 +- tutorials/verify/verify.cpp | 343 +++++++------ tutorials/viewer/viewer_device.cpp | 24 +- tutorials/viewer/viewer_device_debug.cpp | 14 +- tutorials/voronoi/voronoi_device.cpp | 28 +- 46 files changed, 948 insertions(+), 938 deletions(-) diff --git a/tutorials/buildbench/buildbench_device.cpp b/tutorials/buildbench/buildbench_device.cpp index 20abbac68b..20bed767cb 100644 --- a/tutorials/buildbench/buildbench_device.cpp +++ b/tutorials/buildbench/buildbench_device.cpp @@ -496,8 +496,8 @@ namespace embree { double time = 0.0; const size_t numThreads = g_num_user_threads; - Helper helper; - helper.barrier.init(numThreads); + Helper helper_state; + helper_state.barrier.init(numThreads); std::vector threads; threads.reserve(numThreads); @@ -505,18 +505,18 @@ namespace embree { /* ramp up threads */ setAffinity(0); for (size_t i=1; i threads; threads.reserve(numThreads); @@ -588,40 +588,40 @@ namespace embree { /* ramp up threads */ setAffinity(0); for (size_t i=1; iPauseTiming(); - helper.scene = createScene(RTC_SCENE_FLAG_NONE,qflags); - convertScene(helper.scene,ispc_scene,quality); + helper_state.scene = createScene(RTC_SCENE_FLAG_NONE,qflags); + convertScene(helper_state.scene,ispc_scene,quality); state.state->ResumeTiming(); - helper.barrier.wait(); - rtcJoinCommitScene(helper.scene); - helper.barrier.wait(); + helper_state.barrier.wait(); + rtcJoinCommitScene(helper_state.scene); + helper_state.barrier.wait(); state.state->PauseTiming(); - rtcReleaseScene(helper.scene); + rtcReleaseScene(helper_state.scene); state.state->ResumeTiming(); } /* terminate task loop */ - helper.term = true; - helper.barrier.wait(); + helper_state.term = true; + helper_state.barrier.wait(); for (auto& thread: threads) thread.join(); diff --git a/tutorials/collide/collide_device.cpp b/tutorials/collide/collide_device.cpp index 21f8880cf9..5f0f77bb16 100644 --- a/tutorials/collide/collide_device.cpp +++ b/tutorials/collide/collide_device.cpp @@ -369,7 +369,7 @@ Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera) ray.tfar = inf; ray.geomID = RTC_INVALID_GEOMETRY_ID; ray.primID = RTC_INVALID_GEOMETRY_ID; - ray.mask = -1; + ray.mask = ~0u; ray.time() = 0.0f; /* intersect ray with scene */ @@ -394,8 +394,8 @@ Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera) void renderTileStandard(int taskIndex, int threadIndex, int* pixels, - const unsigned int width, - const unsigned int height, + const unsigned int fbWidth, + const unsigned int fbHeight, const float time, const ISPCCamera& camera, const int numTilesX, @@ -405,9 +405,9 @@ void renderTileStandard(int taskIndex, const unsigned int tileY = t / numTilesX; const unsigned int tileX = t - tileY * numTilesX; const unsigned int x0 = tileX * TILE_SIZE_X; - const unsigned int x1 = min(x0+TILE_SIZE_X,width); + const unsigned int x1 = min(x0+TILE_SIZE_X,fbWidth); const unsigned int y0 = tileY * TILE_SIZE_Y; - const unsigned int y1 = min(y0+TILE_SIZE_Y,height); + const unsigned int y1 = min(y0+TILE_SIZE_Y,fbHeight); for (unsigned int y=y0; y& range) { const int threadIndex = (int)TaskScheduler::threadIndex(); for (size_t i=range.begin(); ipositions[1].push_back(Vec3fa(Vec3ff(x,y,z,w))); + const float mx = cast_i2f(RandomSampler_getUInt(sampler)); + const float my = cast_i2f(RandomSampler_getUInt(sampler)); + const float mz = cast_i2f(RandomSampler_getUInt(sampler)); + const float mw = cast_i2f(RandomSampler_getUInt(sampler)); + mesh->positions[1].push_back(Vec3fa(Vec3ff(mx,my,mz,mw))); } } } @@ -680,11 +680,11 @@ namespace embree if (mblur) { - const float x = cast_i2f(RandomSampler_getUInt(sampler)); - const float y = cast_i2f(RandomSampler_getUInt(sampler)); - const float z = cast_i2f(RandomSampler_getUInt(sampler)); - const float r = cast_i2f(RandomSampler_getUInt(sampler)); - mesh->positions[1].push_back(Vec3ff(x, y, z, r)); + const float mx = cast_i2f(RandomSampler_getUInt(sampler)); + const float my = cast_i2f(RandomSampler_getUInt(sampler)); + const float mz = cast_i2f(RandomSampler_getUInt(sampler)); + const float mr = cast_i2f(RandomSampler_getUInt(sampler)); + mesh->positions[1].push_back(Vec3ff(mx, my, mz, mr)); } } diff --git a/tutorials/common/scenegraph/obj_loader.cpp b/tutorials/common/scenegraph/obj_loader.cpp index 17deb2496a..28415205e6 100644 --- a/tutorials/common/scenegraph/obj_loader.cpp +++ b/tutorials/common/scenegraph/obj_loader.cpp @@ -17,7 +17,7 @@ namespace embree struct Crease { float w; unsigned int a, b; - Crease() : w(0), a(-1), b(-1) {}; + Crease() : w(0), a((unsigned int)-1), b((unsigned int)-1) {}; Crease(float w, unsigned int a, unsigned int b) : w(w), a(a), b(b) {}; }; @@ -225,7 +225,7 @@ namespace embree for (unsigned int i=0; i& vertexMap, Ref mesh, const Vertex& i) @@ -597,7 +597,7 @@ namespace embree const std::vector& face = curGroup[j]; /* triangulate the face with a triangle fan */ - Vertex i0 = face[0], i1 = Vertex(-1), i2 = face[1]; + Vertex i0 = face[0], i1 = Vertex((unsigned int)-1), i2 = face[1]; for (size_t k=2; k < face.size(); k++) { i1 = i2; i2 = face[k]; diff --git a/tutorials/common/scenegraph/ply_loader.cpp b/tutorials/common/scenegraph/ply_loader.cpp index 20d18c3430..96eb50ddcd 100644 --- a/tutorials/common/scenegraph/ply_loader.cpp +++ b/tutorials/common/scenegraph/ply_loader.cpp @@ -189,9 +189,9 @@ namespace embree header.pop_front(); Type ty = parseType(line); - std::string name; line >> name; - elt.type[name] = ty; - elt.properties.emplace_back(name); + std::string propName; line >> propName; + elt.type[propName] = ty; + elt.properties.emplace_back(propName); } mesh.elements[name] = elt; diff --git a/tutorials/common/scenegraph/scenegraph.cpp b/tutorials/common/scenegraph/scenegraph.cpp index 85d78ba948..932228a7af 100644 --- a/tutorials/common/scenegraph/scenegraph.cpp +++ b/tutorials/common/scenegraph/scenegraph.cpp @@ -902,53 +902,53 @@ namespace embree } else THROW_RUNTIME_ERROR("incompatible scene graph"); } - else if (Ref mesh0 = node0.dynamicCast()) + else if (Ref qmesh0 = node0.dynamicCast()) { if (Ref mesh1 = node1.dynamicCast()) { - if (mesh0->numVertices() != mesh1->numVertices()) + if (qmesh0->numVertices() != mesh1->numVertices()) THROW_RUNTIME_ERROR("incompatible scene graph"); for (auto& p : mesh1->positions) - mesh0->positions.push_back(std::move(p)); + qmesh0->positions.push_back(std::move(p)); } else THROW_RUNTIME_ERROR("incompatible scene graph"); } - else if (Ref mesh0 = node0.dynamicCast()) + else if (Ref hmesh0 = node0.dynamicCast()) { if (Ref mesh1 = node1.dynamicCast()) { - if (mesh0->numVertices() != mesh1->numVertices()) + if (hmesh0->numVertices() != mesh1->numVertices()) THROW_RUNTIME_ERROR("incompatible scene graph"); for (auto& p : mesh1->positions) - mesh0->positions.push_back(std::move(p)); + hmesh0->positions.push_back(std::move(p)); } else THROW_RUNTIME_ERROR("incompatible scene graph"); } - else if (Ref mesh0 = node0.dynamicCast()) + else if (Ref pmesh0 = node0.dynamicCast()) { if (Ref mesh1 = node1.dynamicCast()) { - if (mesh0->numVertices() != mesh1->numVertices()) + if (pmesh0->numVertices() != mesh1->numVertices()) THROW_RUNTIME_ERROR("incompatible scene graph"); for (auto& p : mesh1->positions) - mesh0->positions.push_back(std::move(p)); + pmesh0->positions.push_back(std::move(p)); } else THROW_RUNTIME_ERROR("incompatible scene graph"); } - else if (Ref mesh0 = node0.dynamicCast()) + else if (Ref smesh0 = node0.dynamicCast()) { if (Ref mesh1 = node1.dynamicCast()) { - if (mesh0->numPositions() != mesh1->numPositions()) + if (smesh0->numPositions() != mesh1->numPositions()) THROW_RUNTIME_ERROR("incompatible scene graph"); - if (mesh0->verticesPerFace != mesh1->verticesPerFace) + if (smesh0->verticesPerFace != mesh1->verticesPerFace) THROW_RUNTIME_ERROR("incompatible scene graph"); for (auto& p : mesh1->positions) - mesh0->positions.push_back(std::move(p)); + smesh0->positions.push_back(std::move(p)); } else THROW_RUNTIME_ERROR("incompatible scene graph"); } @@ -973,41 +973,41 @@ namespace embree if (equal) mesh->positions.resize(1); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref qmesh = node.dynamicCast()) { bool equal = true; - for (size_t i=1; inumTimeSteps(); i++) - equal &= mesh->positions[0] == mesh->positions[i]; + for (size_t i=1; inumTimeSteps(); i++) + equal &= qmesh->positions[0] == qmesh->positions[i]; if (equal) - mesh->positions.resize(1); + qmesh->positions.resize(1); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref hmesh = node.dynamicCast()) { bool equal = true; - for (size_t i=1; inumTimeSteps(); i++) - equal &= mesh->positions[0] == mesh->positions[i]; + for (size_t i=1; inumTimeSteps(); i++) + equal &= hmesh->positions[0] == hmesh->positions[i]; if (equal) - mesh->positions.resize(1); + hmesh->positions.resize(1); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref pmesh = node.dynamicCast()) { bool equal = true; - for (size_t i=1; inumTimeSteps(); i++) - equal &= mesh->positions[0] == mesh->positions[i]; + for (size_t i=1; inumTimeSteps(); i++) + equal &= pmesh->positions[0] == pmesh->positions[i]; if (equal) - mesh->positions.resize(1); + pmesh->positions.resize(1); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref smesh = node.dynamicCast()) { bool equal = true; - for (size_t i=1; inumTimeSteps(); i++) - equal &= mesh->positions[0] == mesh->positions[i]; + for (size_t i=1; inumTimeSteps(); i++) + equal &= smesh->positions[0] == smesh->positions[i]; if (equal) - mesh->positions.resize(1); + smesh->positions.resize(1); } } @@ -1028,43 +1028,43 @@ namespace embree positions1.push_back(P+dP); mesh->positions.push_back(std::move(positions1)); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref qmesh = node.dynamicCast()) { avector positions1; - for (auto& P : mesh->positions.back()) + for (auto& P : qmesh->positions.back()) positions1.push_back(P+dP); - mesh->positions.push_back(std::move(positions1)); + qmesh->positions.push_back(std::move(positions1)); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref gridMesh = node.dynamicCast()) { avector positions1; - for (auto& P : mesh->positions.back()) + for (auto& P : gridMesh->positions.back()) positions1.push_back(P+dP); - mesh->positions.push_back(std::move(positions1)); + gridMesh->positions.push_back(std::move(positions1)); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref hmesh = node.dynamicCast()) { avector positions1; - for (auto& P : mesh->positions.back()) + for (auto& P : hmesh->positions.back()) positions1.push_back(P+Vec3ff(dP,0.0f)); - mesh->positions.push_back(std::move(positions1)); + hmesh->positions.push_back(std::move(positions1)); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref pmesh = node.dynamicCast()) { avector positions1; - for (auto& P : mesh->positions.back()) + for (auto& P : pmesh->positions.back()) positions1.push_back(P+Vec3ff(dP,0.0f)); - mesh->positions.push_back(std::move(positions1)); + pmesh->positions.push_back(std::move(positions1)); - if (mesh->normals.size()) - mesh->normals.push_back(mesh->normals[0]); + if (pmesh->normals.size()) + pmesh->normals.push_back(pmesh->normals[0]); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref smesh = node.dynamicCast()) { avector positions1; - for (auto& P : mesh->positions.back()) + for (auto& P : smesh->positions.back()) positions1.push_back(P+dP); - mesh->positions.push_back(std::move(positions1)); + smesh->positions.push_back(std::move(positions1)); } } @@ -1088,58 +1088,58 @@ namespace embree mesh->positions.push_back(std::move(tpositions)); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref qmesh = node.dynamicCast()) { - avector positions = std::move(mesh->positions[0]); - mesh->positions.clear(); + avector positions = std::move(qmesh->positions[0]); + qmesh->positions.clear(); for (size_t t=0; t tpositions(positions.size()); for (size_t i=0; ipositions.push_back(std::move(tpositions)); + qmesh->positions.push_back(std::move(tpositions)); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref gridMesh = node.dynamicCast()) { - avector positions = std::move(mesh->positions[0]); - mesh->positions.clear(); + avector positions = std::move(gridMesh->positions[0]); + gridMesh->positions.clear(); for (size_t t=0; t tpositions(positions.size()); for (size_t i=0; ipositions.push_back(std::move(tpositions)); + gridMesh->positions.push_back(std::move(tpositions)); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref hmesh = node.dynamicCast()) { - avector positions = std::move(mesh->positions[0]); - mesh->positions.clear(); + avector positions = std::move(hmesh->positions[0]); + hmesh->positions.clear(); for (size_t t=0; t tpositions(positions.size()); for (size_t i=0; ipositions.push_back(std::move(tpositions)); + hmesh->positions.push_back(std::move(tpositions)); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref pmesh = node.dynamicCast()) { - avector positions = std::move(mesh->positions[0]); - mesh->positions.clear(); + avector positions = std::move(pmesh->positions[0]); + pmesh->positions.clear(); for (size_t t=0; t tpositions(positions.size()); for (size_t i=0; ipositions.push_back(std::move(tpositions)); + pmesh->positions.push_back(std::move(tpositions)); } - if (mesh->normals.size()) { + if (pmesh->normals.size()) { for (size_t t=1; tnormals.push_back(mesh->normals[0]); + pmesh->normals.push_back(pmesh->normals[0]); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref smesh = node.dynamicCast()) { - avector positions = std::move(mesh->positions[0]); - mesh->positions.clear(); + avector positions = std::move(smesh->positions[0]); + smesh->positions.clear(); for (size_t t=0; t tpositions(positions.size()); for (size_t i=0; ipositions.push_back(std::move(tpositions)); + smesh->positions.push_back(std::move(tpositions)); } } } @@ -1163,33 +1163,33 @@ namespace embree else mesh->triangles.push_back(mesh->triangles[j]); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref qmesh = node.dynamicCast()) { - if (!mesh->quads.size()) return; + if (!qmesh->quads.size()) return; for (size_t i=0; iquads.size(),N)); - if (i < mesh->quads.size()) std::swap(mesh->quads[i],mesh->quads[j]); - else mesh->quads.push_back(mesh->quads[j]); + size_t j = RandomSampler_getInt(sampler)%(min(qmesh->quads.size(),N)); + if (i < qmesh->quads.size()) std::swap(qmesh->quads[i],qmesh->quads[j]); + else qmesh->quads.push_back(qmesh->quads[j]); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref hmesh = node.dynamicCast()) { - if (!mesh->hairs.size()) return; + if (!hmesh->hairs.size()) return; for (size_t i=0; ihairs.size(),N)); - if (i < mesh->hairs.size()) std::swap(mesh->hairs[i],mesh->hairs[j]); - else mesh->hairs.push_back(mesh->hairs[j]); + size_t j = RandomSampler_getInt(sampler)%(min(hmesh->hairs.size(),N)); + if (i < hmesh->hairs.size()) std::swap(hmesh->hairs[i],hmesh->hairs[j]); + else hmesh->hairs.push_back(hmesh->hairs[j]); } } - else if (Ref mesh = node.dynamicCast()) + else if (Ref pmesh = node.dynamicCast()) { - if (mesh->positions.size() <= N) return; - mesh->positions.resize(N); + if (pmesh->positions.size() <= N) return; + pmesh->positions.resize(N); } - else if (Ref mesh = node.dynamicCast()) + else if (Ref smesh = node.dynamicCast()) { - if (mesh->verticesPerFace.size() <= N) return; - mesh->verticesPerFace.resize(N); + if (smesh->verticesPerFace.size() <= N) return; + smesh->verticesPerFace.resize(N); } } @@ -1198,9 +1198,9 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->spaces.time_range = time_range; } - else if (Ref xfmNode = node.dynamicCast()) { - for (size_t i = 0; i < xfmNode->spaces.size(); ++i) - xfmNode->spaces[i].time_range = time_range; + else if (Ref multiXfmNode = node.dynamicCast()) { + for (size_t i = 0; i < multiXfmNode->spaces.size(); ++i) + multiXfmNode->spaces[i].time_range = time_range; } else if (Ref groupNode = node.dynamicCast()) { @@ -1210,20 +1210,20 @@ namespace embree else if (Ref mesh = node.dynamicCast()) { mesh->time_range = time_range; } - else if (Ref mesh = node.dynamicCast()) { - mesh->time_range = time_range; + else if (Ref qmesh = node.dynamicCast()) { + qmesh->time_range = time_range; } - else if (Ref mesh = node.dynamicCast()) { - mesh->time_range = time_range; + else if (Ref qmesh2 = node.dynamicCast()) { + qmesh2->time_range = time_range; } - else if (Ref mesh = node.dynamicCast()) { - mesh->time_range = time_range; + else if (Ref gridMesh = node.dynamicCast()) { + gridMesh->time_range = time_range; } - else if (Ref mesh = node.dynamicCast()) { - mesh->time_range = time_range; + else if (Ref hmesh = node.dynamicCast()) { + hmesh->time_range = time_range; } - else if (Ref mesh = node.dynamicCast()) { - mesh->time_range = time_range; + else if (Ref pmesh = node.dynamicCast()) { + pmesh->time_range = time_range; } } @@ -1294,8 +1294,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_triangles_to_quads(xfmNode->child,prop); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_triangles_to_quads(xfmNode->child,prop); + else if (Ref multiXfmNode = node.dynamicCast()) { + multiXfmNode->child = convert_triangles_to_quads(multiXfmNode->child,prop); } else if (Ref groupNode = node.dynamicCast()) { @@ -1347,8 +1347,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_quads_to_grids(xfmNode->child, resX, resY); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_quads_to_grids(xfmNode->child, resX, resY); + else if (Ref multiXfmNode = node.dynamicCast()) { + multiXfmNode->child = convert_quads_to_grids(multiXfmNode->child, resX, resY); } else if (Ref groupNode = node.dynamicCast()) { @@ -1395,8 +1395,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_grids_to_quads(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_grids_to_quads(xfmNode->child); + else if (Ref multiXfmNode = node.dynamicCast()) { + multiXfmNode->child = convert_grids_to_quads(multiXfmNode->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1420,7 +1420,7 @@ namespace embree /* test if all neighboring faces of top exist and are properly connected */ - unsigned int prev_opposite_edge = -1; + unsigned int prev_opposite_edge = (unsigned int)-1; for (size_t i=0; i xfmNode = node.dynamicCast()) { xfmNode->child = my_merge_quads_to_grids(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = my_merge_quads_to_grids(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + xfmNode2->child = my_merge_quads_to_grids(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1589,8 +1589,8 @@ namespace embree avector positions; positions.resize((width+1)*(height+1)); gather_grid(geom,positions,width,height,(unsigned int*)qmesh->quads.data(), qmesh->positions[t], left.front()); - for (size_t i=0; ipositions[t].push_back(positions[i]); + for (size_t vi=0; vipositions[t].push_back(positions[vi]); } } @@ -1606,8 +1606,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_quads_to_subdivs(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_quads_to_subdivs(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + xfmNode2->child = convert_quads_to_subdivs(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1650,8 +1650,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_bezier_to_lines(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_bezier_to_lines(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + xfmNode2->child = convert_bezier_to_lines(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1680,8 +1680,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_flat_to_round_curves(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_flat_to_round_curves(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + xfmNode2->child = convert_flat_to_round_curves(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1707,8 +1707,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { xfmNode->child = convert_round_to_flat_curves(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - xfmNode->child = convert_round_to_flat_curves(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + xfmNode2->child = convert_round_to_flat_curves(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1734,8 +1734,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { convert_bezier_to_bspline(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - convert_bezier_to_bspline(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + convert_bezier_to_bspline(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1754,8 +1754,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { convert_bspline_to_bezier(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - convert_bspline_to_bezier(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + convert_bspline_to_bezier(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1773,8 +1773,8 @@ namespace embree if (Ref xfmNode = node.dynamicCast()) { convert_bezier_to_hermite(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - convert_bezier_to_hermite(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + convert_bezier_to_hermite(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1800,15 +1800,15 @@ namespace embree } xfmNode->child = remove_mblur(xfmNode->child, mblur); } - else if (Ref xfmNode = node.dynamicCast()) { + else if (Ref xfmNode2 = node.dynamicCast()) { if (mblur) { - if (xfmNode->spaces.size() == 0 || xfmNode->spaces[0].size() > 1) + if (xfmNode2->spaces.size() == 0 || xfmNode2->spaces[0].size() > 1) return nullptr; } else { - if (xfmNode->spaces.size() > 0 && xfmNode->spaces[0].size() > 1) + if (xfmNode2->spaces.size() > 0 && xfmNode2->spaces[0].size() > 1) return node; } - xfmNode->child = remove_mblur(xfmNode->child, mblur); + xfmNode2->child = remove_mblur(xfmNode2->child, mblur); } else if (Ref groupNode = node.dynamicCast()) { @@ -1820,24 +1820,24 @@ namespace embree if ((mesh->numTimeSteps() > 1) == mblur) return nullptr; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh2 = node.dynamicCast()) { - if ((mesh->numTimeSteps() > 1) == mblur) + if ((mesh2->numTimeSteps() > 1) == mblur) return nullptr; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh3 = node.dynamicCast()) { - if ((mesh->numTimeSteps() > 1) == mblur) + if ((mesh3->numTimeSteps() > 1) == mblur) return nullptr; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh4 = node.dynamicCast()) { - if ((mesh->numTimeSteps() > 1) == mblur) + if ((mesh4->numTimeSteps() > 1) == mblur) return nullptr; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh5 = node.dynamicCast()) { - if ((mesh->numTimeSteps() > 1) == mblur) + if ((mesh5->numTimeSteps() > 1) == mblur) return nullptr; } return node; @@ -1849,10 +1849,10 @@ namespace embree xfmNode->spaces.spaces.resize(1); convert_mblur_to_nonmblur(xfmNode->child); } - else if (Ref xfmNode = node.dynamicCast()) { - for (size_t i = 0; i < xfmNode->spaces.size(); ++i) - xfmNode->spaces[i].spaces.resize(1); - convert_mblur_to_nonmblur(xfmNode->child); + else if (Ref xfmNode2 = node.dynamicCast()) { + for (size_t i = 0; i < xfmNode2->spaces.size(); ++i) + xfmNode2->spaces[i].spaces.resize(1); + convert_mblur_to_nonmblur(xfmNode2->child); } else if (Ref groupNode = node.dynamicCast()) { @@ -1863,26 +1863,26 @@ namespace embree if (mesh->positions.size()) mesh->positions.resize(1); if (mesh->normals.size()) mesh->normals.resize(1); } - else if (Ref mesh = node.dynamicCast()) { - if (mesh->positions.size()) mesh->positions.resize(1); - if (mesh->normals.size()) mesh->normals.resize(1); + else if (Ref mesh2 = node.dynamicCast()) { + if (mesh2->positions.size()) mesh2->positions.resize(1); + if (mesh2->normals.size()) mesh2->normals.resize(1); } - else if (Ref mesh = node.dynamicCast()) { - if (mesh->positions.size()) mesh->positions.resize(1); - if (mesh->normals.size()) mesh->normals.resize(1); - if (mesh->tangents.size()) mesh->tangents.resize(1); - if (mesh->dnormals.size()) mesh->dnormals.resize(1); + else if (Ref mesh3 = node.dynamicCast()) { + if (mesh3->positions.size()) mesh3->positions.resize(1); + if (mesh3->normals.size()) mesh3->normals.resize(1); + if (mesh3->tangents.size()) mesh3->tangents.resize(1); + if (mesh3->dnormals.size()) mesh3->dnormals.resize(1); } - else if (Ref mesh = node.dynamicCast()) { - if (mesh->positions.size()) mesh->positions.resize(1); - if (mesh->normals.size()) mesh->normals.resize(1); + else if (Ref mesh4 = node.dynamicCast()) { + if (mesh4->positions.size()) mesh4->positions.resize(1); + if (mesh4->normals.size()) mesh4->normals.resize(1); } - else if (Ref mesh = node.dynamicCast()) { - if (mesh->positions.size()) mesh->positions.resize(1); - if (mesh->normals .size()) mesh->normals .resize(1); + else if (Ref mesh5 = node.dynamicCast()) { + if (mesh5->positions.size()) mesh5->positions.resize(1); + if (mesh5->normals .size()) mesh5->normals .resize(1); } - else if (Ref mesh = node.dynamicCast()) { - mesh->positions.resize(1); + else if (Ref mesh6 = node.dynamicCast()) { + mesh6->positions.resize(1); } } @@ -1929,191 +1929,191 @@ namespace embree } } - void convertLightsAndCameras(std::vector>& group, const Ref& node, const SceneGraph::Transformations& spaces) + void convertLightsAndCameras(std::vector>& group, const Ref& inputNode, const SceneGraph::Transformations& spaces) { - if (!node->hasLightOrCamera) return; + if (!inputNode->hasLightOrCamera) return; - if (Ref xfmNode = node.dynamicCast()) { + if (Ref xfmNode = inputNode.dynamicCast()) { convertLightsAndCameras(group,xfmNode->child, spaces*xfmNode->spaces); } - else if (Ref groupNode = node.dynamicCast()) { + else if (Ref groupNode = inputNode.dynamicCast()) { for (const auto& child : groupNode->children) convertLightsAndCameras(group,child,spaces); } - else if (Ref lightNode = node.dynamicCast()) { + else if (Ref lightNode = inputNode.dynamicCast()) { if (spaces.size() != 1) throw std::runtime_error("animated lights cannot get instantiated with a transform animation"); group.push_back(lightNode->transform(spaces[0]).dynamicCast()); } - else if (Ref lightNode = node.dynamicCast()) + else if (Ref lightNode2 = inputNode.dynamicCast()) { if (spaces.size() == 1) - group.push_back(lightNode->transform(spaces[0]).dynamicCast()); + group.push_back(lightNode2->transform(spaces[0]).dynamicCast()); else { std::vector> lights(spaces.size()); for (size_t i=0; itransform(spaces[i]); + lights[i] = lightNode2->transform(spaces[i]); group.push_back(new SceneGraph::AnimatedLightNode(std::move(lights),spaces.time_range)); } } - else if (Ref cameraNode = node.dynamicCast()) + else if (Ref cameraNode = inputNode.dynamicCast()) { if (spaces.size() != 1) throw std::runtime_error("animated cameras cannot get instantiated with a transform animation"); group.push_back(new SceneGraph::AnimatedPerspectiveCameraNode(cameraNode,spaces[0],makeUniqueID(cameraNode->name))); } - else if (Ref cameraNode = node.dynamicCast()) + else if (Ref cameraNode2 = inputNode.dynamicCast()) { if (spaces.size() == 1) - group.push_back(new SceneGraph::PerspectiveCameraNode(cameraNode,spaces[0],makeUniqueID(cameraNode->name))); + group.push_back(new SceneGraph::PerspectiveCameraNode(cameraNode2,spaces[0],makeUniqueID(cameraNode2->name))); else { std::vector> cameras(spaces.size()); for (size_t i=0; iname))); + group.push_back(new SceneGraph::AnimatedPerspectiveCameraNode(std::move(cameras),spaces.time_range,makeUniqueID(cameraNode2->name))); } } } - void convertGeometries(std::vector>& group, const Ref& node, const SceneGraph::Transformations& spaces) + void convertGeometries(std::vector>& group, const Ref& inputNode, const SceneGraph::Transformations& spaces) { - if (Ref xfmNode = node.dynamicCast()) { + if (Ref xfmNode = inputNode.dynamicCast()) { convertGeometries(group,xfmNode->child, spaces*xfmNode->spaces); } - else if (Ref xfmNode = node.dynamicCast()) { - for (size_t i = 0; i < xfmNode->spaces.size(); ++i) - convertGeometries(group,xfmNode->child, spaces*xfmNode->spaces[i]); + else if (Ref xfmNode2 = inputNode.dynamicCast()) { + for (size_t i = 0; i < xfmNode2->spaces.size(); ++i) + convertGeometries(group,xfmNode2->child, spaces*xfmNode2->spaces[i]); } - else if (Ref groupNode = node.dynamicCast()) { + else if (Ref groupNode = inputNode.dynamicCast()) { for (const auto& child : groupNode->children) convertGeometries(group,child,spaces); } - else if (Ref mesh = node.dynamicCast()) { + else if (Ref mesh = inputNode.dynamicCast()) { group.push_back(new SceneGraph::TriangleMeshNode(mesh,spaces)); } - else if (Ref mesh = node.dynamicCast()) { - group.push_back(new SceneGraph::QuadMeshNode(mesh,spaces)); + else if (Ref mesh2 = inputNode.dynamicCast()) { + group.push_back(new SceneGraph::QuadMeshNode(mesh2,spaces)); } - else if (Ref mesh = node.dynamicCast()) { - group.push_back(new SceneGraph::GridMeshNode(mesh,spaces)); + else if (Ref mesh3 = inputNode.dynamicCast()) { + group.push_back(new SceneGraph::GridMeshNode(mesh3,spaces)); } - else if (Ref mesh = node.dynamicCast()) { - group.push_back(new SceneGraph::SubdivMeshNode(mesh,spaces)); + else if (Ref mesh4 = inputNode.dynamicCast()) { + group.push_back(new SceneGraph::SubdivMeshNode(mesh4,spaces)); } - else if (Ref mesh = node.dynamicCast()) { - group.push_back(new SceneGraph::HairSetNode(mesh,spaces)); + else if (Ref mesh5 = inputNode.dynamicCast()) { + group.push_back(new SceneGraph::HairSetNode(mesh5,spaces)); } - else if (Ref mesh = node.dynamicCast()) { - group.push_back(new SceneGraph::PointSetNode(mesh,spaces)); + else if (Ref mesh6 = inputNode.dynamicCast()) { + group.push_back(new SceneGraph::PointSetNode(mesh6,spaces)); } } - Ref lookupGeometries(Ref node) + Ref lookupGeometries(Ref inputNode) { - if (object_mapping.find(node) == object_mapping.end()) + if (object_mapping.find(inputNode) == object_mapping.end()) { std::vector> geometries; - convertGeometries(geometries,node,one); - object_mapping[node] = new SceneGraph::GroupNode(geometries); + convertGeometries(geometries,inputNode,one); + object_mapping[inputNode] = new SceneGraph::GroupNode(geometries); } - return object_mapping[node]; + return object_mapping[inputNode]; } - void convertInstances(std::vector>& group, const Ref& node, const std::vector& spaces) + void convertInstances(std::vector>& group, const Ref& inputNode, const std::vector& spaces) { - if (node->isClosed()) { + if (inputNode->isClosed()) { //if (group.size() % 10000 == 0) std::cout << "." << std::flush; - group.push_back(new SceneGraph::MultiTransformNode(spaces,lookupGeometries(node))); + group.push_back(new SceneGraph::MultiTransformNode(spaces,lookupGeometries(inputNode))); } - else if (Ref xfmNode = node.dynamicCast()) { + else if (Ref xfmNode3 = inputNode.dynamicCast()) { for (size_t i = 0; i < spaces.size(); ++i) - convertInstances(group,xfmNode->child, spaces[i]*xfmNode->spaces); + convertInstances(group,xfmNode3->child, spaces[i]*xfmNode3->spaces); } - else if (Ref xfmNode = node.dynamicCast()) { - convertInstances(group,xfmNode->child, spaces*xfmNode->spaces); + else if (Ref xfmNode4 = inputNode.dynamicCast()) { + convertInstances(group,xfmNode4->child, spaces*xfmNode4->spaces); } - else if (Ref groupNode = node.dynamicCast()) { - for (const auto& child : groupNode->children) convertInstances(group,child,spaces); + else if (Ref groupNode2 = inputNode.dynamicCast()) { + for (const auto& child : groupNode2->children) convertInstances(group,child,spaces); } } - void convertInstances(std::vector>& group, const Ref& node, const SceneGraph::Transformations& spaces) + void convertInstances(std::vector>& group, const Ref& inputNode, const SceneGraph::Transformations& spaces) { - if (node->isClosed()) { + if (inputNode->isClosed()) { //if (group.size() % 10000 == 0) std::cout << "." << std::flush; - group.push_back(new SceneGraph::TransformNode(spaces,lookupGeometries(node))); + group.push_back(new SceneGraph::TransformNode(spaces,lookupGeometries(inputNode))); } - else if (Ref xfmNode = node.dynamicCast()) { - convertInstances(group,xfmNode->child, spaces*xfmNode->spaces); + else if (Ref xfmNode5 = inputNode.dynamicCast()) { + convertInstances(group,xfmNode5->child, spaces*xfmNode5->spaces); } - else if (Ref xfmNode = node.dynamicCast()) { - convertInstances(group,xfmNode->child, spaces*xfmNode->spaces); + else if (Ref xfmNode6 = inputNode.dynamicCast()) { + convertInstances(group,xfmNode6->child, spaces*xfmNode6->spaces); } - else if (Ref groupNode = node.dynamicCast()) { - for (const auto& child : groupNode->children) convertInstances(group,child,spaces); + else if (Ref groupNode3 = inputNode.dynamicCast()) { + for (const auto& child : groupNode3->children) convertInstances(group,child,spaces); } } - void convertMultiLevelInstances(std::vector>& group, const Ref& node) + void convertMultiLevelInstances(std::vector>& group, const Ref& inputNode) { - if (Ref groupNode = node.dynamicCast()) { + if (Ref groupNode = inputNode.dynamicCast()) { for (const auto& child : groupNode->children) convertMultiLevelInstances(group,child); } - else if (node.dynamicCast()) { - group.push_back(node); + else if (inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (node.dynamicCast()) { - group.push_back(node); + else if (inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (node.dynamicCast()) { - group.push_back(node); + else if (inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (node.dynamicCast()) { - group.push_back(node); + else if (inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (node.dynamicCast()) { - group.push_back(node); + else if (inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (node.dynamicCast()) { - group.push_back(node); + else if (inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (object_mapping.find(node) != object_mapping.end()) { - group.push_back(object_mapping[node]); + else if (object_mapping.find(inputNode) != object_mapping.end()) { + group.push_back(object_mapping[inputNode]); } - else if (Ref xfmNode = node.dynamicCast()) + else if (Ref xfmNode = inputNode.dynamicCast()) { auto new_node = new SceneGraph::TransformNode(xfmNode->spaces,convertMultiLevelInstances(xfmNode->child)); - object_mapping[node] = new_node; + object_mapping[inputNode] = new_node; group.push_back(new_node); } - else if (Ref xfmNode = node.dynamicCast()) + else if (Ref xfmNode2 = inputNode.dynamicCast()) { - auto new_node = new SceneGraph::MultiTransformNode(xfmNode->spaces,convertMultiLevelInstances(xfmNode->child)); - object_mapping[node] = new_node; + auto new_node = new SceneGraph::MultiTransformNode(xfmNode2->spaces,convertMultiLevelInstances(xfmNode2->child)); + object_mapping[inputNode] = new_node; group.push_back(new_node); } } - Ref convertMultiLevelInstances(const Ref& node) + Ref convertMultiLevelInstances(const Ref& inputNode) { - if (object_mapping.find(node) != object_mapping.end()) { - return object_mapping[node]; + if (object_mapping.find(inputNode) != object_mapping.end()) { + return object_mapping[inputNode]; } std::vector> group; - convertMultiLevelInstances(group,node); + convertMultiLevelInstances(group,inputNode); auto new_node = new SceneGraph::GroupNode(group); - object_mapping[node] = new_node; + object_mapping[inputNode] = new_node; return new_node; } - void convertFlattenedInstances(std::vector>& group, const Ref& node) + void convertFlattenedInstances(std::vector>& group, const Ref& inputNode) { - if (Ref xfmNode = node.dynamicCast()) { - group.push_back(node); + if (Ref xfmNode = inputNode.dynamicCast()) { + group.push_back(inputNode); } - else if (Ref groupNode = node.dynamicCast()) { + else if (Ref groupNode = inputNode.dynamicCast()) { for (const auto& child : groupNode->children) convertFlattenedInstances(group,child); } } diff --git a/tutorials/common/scenegraph/scenegraph.h b/tutorials/common/scenegraph/scenegraph.h index 6019ec7f2c..93f9dd22ad 100644 --- a/tutorials/common/scenegraph/scenegraph.h +++ b/tutorials/common/scenegraph/scenegraph.h @@ -101,10 +101,10 @@ namespace embree struct Node : public RefCount { Node (bool closed = false) - : indegree(0), closed(closed), hasLightOrCamera(false), id(-1), geometry(nullptr) {} + : indegree(0), closed(closed), hasLightOrCamera(false), id((unsigned int)-1), geometry(nullptr) {} Node (const std::string& name) - : name(name), indegree(0), closed(false), id(-1), geometry(nullptr) {} + : name(name), indegree(0), closed(false), id((unsigned int)-1), geometry(nullptr) {} ~Node() { if (opaque_geometry_destruction) @@ -1083,8 +1083,8 @@ namespace embree normals(transformMSMBlurNormalBuffer(imesh->normals,spaces)), texcoords(imesh->texcoords), triangles(imesh->triangles), material(imesh->material) {} - virtual void setMaterial(Ref material) { - this->material = material; + virtual void setMaterial(Ref newMaterial) { + this->material = newMaterial; } virtual BBox3fa bounds() const @@ -1170,8 +1170,8 @@ namespace embree normals(transformMSMBlurNormalBuffer(imesh->normals,spaces)), texcoords(imesh->texcoords), quads(imesh->quads), material(imesh->material) {} - virtual void setMaterial(Ref material) { - this->material = material; + virtual void setMaterial(Ref newMaterial) { + this->material = newMaterial; } virtual BBox3fa bounds() const @@ -1277,8 +1277,8 @@ namespace embree } } - virtual void setMaterial(Ref material) { - this->material = material; + virtual void setMaterial(Ref newMaterial) { + this->material = newMaterial; } virtual BBox3fa bounds() const @@ -1394,8 +1394,8 @@ namespace embree dnormals(transformMSMBlurVectorVec3faBuffer(imesh->dnormals,spaces)), hairs(imesh->hairs), flags(imesh->flags), material(imesh->material), tessellation_rate(imesh->tessellation_rate) {} - virtual void setMaterial(Ref material) { - this->material = material; + virtual void setMaterial(Ref newMaterial) { + this->material = newMaterial; } virtual BBox3fa bounds() const @@ -1485,8 +1485,8 @@ namespace embree normals(transformMSMBlurNormalBuffer(imesh->normals,spaces)), material(imesh->material) {} - virtual void setMaterial(Ref material) { - this->material = material; + virtual void setMaterial(Ref newMaterial) { + this->material = newMaterial; } virtual BBox3fa bounds() const @@ -1579,8 +1579,8 @@ namespace embree positions(transformMSMBlurVec3faBuffer(imesh->positions,spaces)), grids(imesh->grids), material(imesh->material) {} - virtual void setMaterial(Ref material) { - this->material = material; + virtual void setMaterial(Ref newMaterial) { + this->material = newMaterial; } virtual BBox3fa bounds() const @@ -1658,3 +1658,4 @@ namespace embree #include "materials.h" + diff --git a/tutorials/common/scenegraph/texture.cpp b/tutorials/common/scenegraph/texture.cpp index d7706ef069..877d85bf64 100644 --- a/tutorials/common/scenegraph/texture.cpp +++ b/tutorials/common/scenegraph/texture.cpp @@ -19,7 +19,7 @@ namespace embree } Texture::Texture () - : width(-1), height(-1), format(INVALID), bytesPerTexel(0), width_mask(0), height_mask(0), data(nullptr) {} + : width((unsigned int)-1), height((unsigned int)-1), format(INVALID), bytesPerTexel(0), width_mask(0), height_mask(0), data(nullptr) {} Texture::Texture(Ref img, const std::string &&fileName) : width(unsigned(img->width)), height(unsigned(img->height)), format(RGBA8), bytesPerTexel(4), width_mask(0), height_mask(0), data(nullptr), fileName(fileName) diff --git a/tutorials/common/scenegraph/xml_loader.cpp b/tutorials/common/scenegraph/xml_loader.cpp index 479844aee8..184b5d2321 100644 --- a/tutorials/common/scenegraph/xml_loader.cpp +++ b/tutorials/common/scenegraph/xml_loader.cpp @@ -1414,7 +1414,7 @@ namespace embree uint32_t rand_int = 1234; uint32_t a = 1103515245; uint32_t c = 12345; - uint32_t m = 1 << 31; + uint32_t m = 1u << 31; auto rand_float = [&rand_int, &a, &c, &m]() { rand_int = (a * rand_int + c) % m; return rand_int / float(m); @@ -1438,9 +1438,9 @@ namespace embree Vec3fa last = Vec3fa(sin(phi) * cos(theta), cos(phi), sin(phi) * sin(theta)); for (int i = 0; i < N; i++) { - float theta = 2.0f * float(pi) * rand_float(); - float phi = acos(1 - 2 * rand_float()); - Vec3fa d = Vec3fa(sin(phi) * cos(theta), cos(phi), sin(phi) * sin(theta)); + float innerTheta = 2.0f * float(pi) * rand_float(); + float innerPhi = acos(1 - 2 * rand_float()); + Vec3fa d = Vec3fa(sin(innerPhi) * cos(innerTheta), cos(innerPhi), sin(innerPhi) * sin(innerTheta)); Vec3fa p = normalize(cross(d, last)); last = p; @@ -1558,15 +1558,15 @@ namespace embree avector spaces(time_steps); size_t j = 0; for (size_t i=0; ichildren[i]->name == "AffineSpace") { - space = (AffineSpace3ff) load(xml->children[i]); - spaces[j++] = space; + innerSpace = (AffineSpace3ff) load(xml->children[i]); + spaces[j++] = innerSpace; } else if (xml->children[i]->name == "Quaternion") { - space = loadQuaternion(xml->children[i]); + innerSpace = loadQuaternion(xml->children[i]); quaternion = true; - spaces[j++] = space; + spaces[j++] = innerSpace; } else { THROW_RUNTIME_ERROR(xml->loc.str()+": unknown transformation representation"); diff --git a/tutorials/common/scenegraph/xml_parser.h b/tutorials/common/scenegraph/xml_parser.h index 6fe9267cff..5ece4333af 100644 --- a/tutorials/common/scenegraph/xml_parser.h +++ b/tutorials/common/scenegraph/xml_parser.h @@ -73,8 +73,8 @@ namespace embree } /*! adds a new parameter to the node */ - Ref add(const std::string& name, const std::string& val) { - parms[name] = val; + Ref add(const std::string& paramName, const std::string& val) { + parms[paramName] = val; return this; } diff --git a/tutorials/common/scenegraph/xml_writer.cpp b/tutorials/common/scenegraph/xml_writer.cpp index 0a26b21284..3686f98560 100644 --- a/tutorials/common/scenegraph/xml_writer.cpp +++ b/tutorials/common/scenegraph/xml_writer.cpp @@ -343,20 +343,20 @@ namespace embree void XMLWriter::store(Ref node, ssize_t id) { - if (auto light = node.dynamicCast>()) - store(light->light,id); - else if (auto light = node.dynamicCast>()) - store(light->light,id); - else if (auto light = node.dynamicCast>()) - store(light->light,id); - else if (auto light = node.dynamicCast>()) - store(light->light,id); - else if (auto light = node.dynamicCast>()) - store(light->light,id); - else if (auto light = node.dynamicCast>()) - store(light->light,id); - else if (auto light = node.dynamicCast>()) - store(light->light,id); + if (auto lightA = node.dynamicCast>()) + store(lightA->light,id); + else if (auto lightP = node.dynamicCast>()) + store(lightP->light,id); + else if (auto lightD = node.dynamicCast>()) + store(lightD->light,id); + else if (auto lightS = node.dynamicCast>()) + store(lightS->light,id); + else if (auto lightDist = node.dynamicCast>()) + store(lightDist->light,id); + else if (auto lightT = node.dynamicCast>()) + store(lightT->light,id); + else if (auto lightQ = node.dynamicCast>()) + store(lightQ->light,id); else throw std::runtime_error("unsupported light"); } @@ -505,16 +505,16 @@ namespace embree } const ssize_t id = nodeMap[node] = currentNodeID++; - if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); - else if (Ref m = mnode.dynamicCast()) store(m,id); + if (Ref mOBJ = mnode.dynamicCast()) store(mOBJ,id); + else if (Ref mThinD = mnode.dynamicCast()) store(mThinD,id); + else if (Ref mMetal = mnode.dynamicCast()) store(mMetal,id); + else if (Ref mVelvet = mnode.dynamicCast()) store(mVelvet,id); + else if (Ref mDielec = mnode.dynamicCast()) store(mDielec,id); + else if (Ref mMetalPaint = mnode.dynamicCast()) store(mMetalPaint,id); + else if (Ref mMatte = mnode.dynamicCast()) store(mMatte,id); + else if (Ref mMirror = mnode.dynamicCast()) store(mMirror,id); + else if (Ref mReflMetal = mnode.dynamicCast()) store(mReflMetal,id); + else if (Ref mHair = mnode.dynamicCast()) store(mHair,id); else throw std::runtime_error("unsupported material"); } @@ -757,17 +757,17 @@ namespace embree tab(); xml << "fileName << "\"/>" << std::endl; return; } - if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); + if (Ref cnodeAL = node.dynamicCast()) store(cnodeAL,id); + else if (Ref cnodeL = node.dynamicCast()) store(cnodeL,id); //else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); - else if (Ref cnode = node.dynamicCast()) store(cnode,id); + else if (Ref cnodeTri = node.dynamicCast()) store(cnodeTri,id); + else if (Ref cnodeQuad = node.dynamicCast()) store(cnodeQuad,id); + else if (Ref cnodeSubdiv = node.dynamicCast()) store(cnodeSubdiv,id); + else if (Ref cnodeHair = node.dynamicCast()) store(cnodeHair,id); + else if (Ref cnodeAnimCam = node.dynamicCast()) store(cnodeAnimCam,id); + else if (Ref cnodeCam = node.dynamicCast()) store(cnodeCam,id); + else if (Ref cnodeXfm = node.dynamicCast()) store(cnodeXfm,id); + else if (Ref cnodeGroup = node.dynamicCast()) store(cnodeGroup,id); else throw std::runtime_error("unknown node type"); } diff --git a/tutorials/common/tutorial/benchmark.h b/tutorials/common/tutorial/benchmark.h index e90595e269..826a9958fb 100644 --- a/tutorials/common/tutorial/benchmark.h +++ b/tutorials/common/tutorial/benchmark.h @@ -25,7 +25,7 @@ enum BuildBenchType { ALL = 511 }; -static MAYBE_UNUSED BuildBenchType getBuildBenchType(std::string const& str) +inline BuildBenchType getBuildBenchType(std::string const& str) { if (str == "update_dynamic_deformable") return BuildBenchType::UPDATE_DYNAMIC_DEFORMABLE; else if (str == "update_dynamic_dynamic") return BuildBenchType::UPDATE_DYNAMIC_DYNAMIC; @@ -39,7 +39,7 @@ static MAYBE_UNUSED BuildBenchType getBuildBenchType(std::string const& str) return BuildBenchType::ALL; } -static MAYBE_UNUSED std::string getBuildBenchTypeString(BuildBenchType type) +inline std::string getBuildBenchTypeString(BuildBenchType type) { if (type == BuildBenchType::UPDATE_DYNAMIC_DEFORMABLE) return "update_dynamic_deformable"; else if (type == BuildBenchType::UPDATE_DYNAMIC_DYNAMIC) return "update_dynamic_dynamic"; diff --git a/tutorials/common/tutorial/noise.cpp b/tutorials/common/tutorial/noise.cpp index 6b0f8a9dc9..433336c58e 100644 --- a/tutorials/common/tutorial/noise.cpp +++ b/tutorials/common/tutorial/noise.cpp @@ -156,11 +156,11 @@ namespace embree mylerp(v,mylerp(u,g001,g101),mylerp(u,g011,g111))); } - Vec3fa noise3D(const Vec3fa& p) + Vec3fa noise3D(const Vec3fa& pos) { - float x = noise(p.x+128.0f); - float y = noise(p.y+64.0f); - float z = noise(p.z+192.0f); + float x = noise(pos.x+128.0f); + float y = noise(pos.y+64.0f); + float z = noise(pos.z+192.0f); return Vec3fa(x,y,z); } } diff --git a/tutorials/common/tutorial/scene_device.cpp b/tutorials/common/tutorial/scene_device.cpp index 52c6aba3f2..48280e517e 100644 --- a/tutorials/common/tutorial/scene_device.cpp +++ b/tutorials/common/tutorial/scene_device.cpp @@ -181,14 +181,14 @@ namespace embree void ISPCScene::updateLight(const Ref& in, Light* out) { - if (auto light = in.dynamicCast>()) - updateLight(light->light, out); - else if (auto light = in.dynamicCast>()) - updateLight(light->light, out); - else if (auto light = in.dynamicCast>()) - updateLight(light->light, out); - else if (auto light = in.dynamicCast>()) - updateLight(light->light, out); + if (auto ambientLightNode = in.dynamicCast>()) + updateLight(ambientLightNode->light, out); + else if (auto dirLightNode = in.dynamicCast>()) + updateLight(dirLightNode->light, out); + else if (auto distLightNode = in.dynamicCast>()) + updateLight(distLightNode->light, out); + else if (auto pointLightNode = in.dynamicCast>()) + updateLight(pointLightNode->light, out); } void ISPCScene::commit() @@ -426,13 +426,13 @@ namespace embree numNormals = unsigned(in->numNormals()); numTexCoords = unsigned(in->texcoords.size()); geom.materialID = scene_in->materialID(in->material); - size_t numEdges = in->position_indices.size(); - size_t numFaces = in->verticesPerFace.size(); - subdivlevel = new float[numEdges]; - face_offsets = new unsigned[numFaces]; - for (size_t i=0; iposition_indices.size(); + size_t localNumFaces = in->verticesPerFace.size(); + subdivlevel = new float[localNumEdges]; + face_offsets = new unsigned[localNumFaces]; + for (size_t i=0; igeometry; else if (Ref mesh = in.dynamicCast()) geom = (ISPCGeometry*) new ISPCTriangleMesh(device,scene,mesh); - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCQuadMesh(device,scene,mesh); - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCSubdivMesh(device,scene,mesh); - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCHairSet(device,scene,mesh->type,mesh); - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCGridMesh(device,scene,mesh); - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCInstance(device,scene,mesh); - else if (Ref mesh = in.dynamicCast()) { - geom = (ISPCGeometry*) new ISPCInstanceArray(device,scene,mesh); + else if (Ref mesh2 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCQuadMesh(device,scene,mesh2); + else if (Ref mesh3 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCSubdivMesh(device,scene,mesh3); + else if (Ref mesh4 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCHairSet(device,scene,mesh4->type,mesh4); + else if (Ref mesh5 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCGridMesh(device,scene,mesh5); + else if (Ref mesh6 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCInstance(device,scene,mesh6); + else if (Ref mesh7 = in.dynamicCast()) { + geom = (ISPCGeometry*) new ISPCInstanceArray(device,scene,mesh7); } - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCGroup(device,scene,mesh); - else if (Ref mesh = in.dynamicCast()) - geom = (ISPCGeometry*) new ISPCPointSet(device,scene, mesh->type, mesh); + else if (Ref mesh8 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCGroup(device,scene,mesh8); + else if (Ref mesh9 = in.dynamicCast()) + geom = (ISPCGeometry*) new ISPCPointSet(device,scene, mesh9->type, mesh9); else THROW_RUNTIME_ERROR("unknown geometry type"); diff --git a/tutorials/common/tutorial/scene_device.h b/tutorials/common/tutorial/scene_device.h index 5fcb83580c..fb51346404 100644 --- a/tutorials/common/tutorial/scene_device.h +++ b/tutorials/common/tutorial/scene_device.h @@ -68,7 +68,7 @@ namespace embree #if !defined(ISPC) ALIGNED_STRUCT_USM_(16); - ISPCGeometry (ISPCType type) : type(type), geometry(nullptr), materialID(-1), visited(false) {} + ISPCGeometry (ISPCType type) : type(type), geometry(nullptr), materialID((unsigned int)-1), visited(false) {} ~ISPCGeometry () { if (geometry) rtcReleaseGeometry(geometry); } #endif ISPCType type; diff --git a/tutorials/common/tutorial/tutorial.cpp b/tutorials/common/tutorial/tutorial.cpp index 844abb7d0a..e4b46bf1ac 100644 --- a/tutorials/common/tutorial/tutorial.cpp +++ b/tutorials/common/tutorial/tutorial.cpp @@ -661,16 +661,16 @@ namespace embree rtcSetDeviceProperty(nullptr,(RTCDeviceProperty)parm,val); } - void TutorialApplication::resize(unsigned width, unsigned height) + void TutorialApplication::resize(unsigned newWidth, unsigned newHeight) { - if (width == this->width && height == this->height && pixels) + if (newWidth == this->width && newHeight == this->height && pixels) return; - this->width = width; - this->height = height; + this->width = newWidth; + this->height = newHeight; if (pixels) alignedUSMFree(pixels); - pixels = (unsigned*) alignedUSMMalloc(width*height*sizeof(unsigned),64,EmbreeUSMMode::DEVICE_READ_WRITE); + pixels = (unsigned*) alignedUSMMalloc(newWidth*newHeight*sizeof(unsigned),64,EmbreeUSMMode::DEVICE_READ_WRITE); } void TutorialApplication::set_scene (TutorialScene* in) @@ -701,16 +701,16 @@ namespace embree TutorialApplication::instance->reshapeFunc(window,width,height); } - void TutorialApplication::setCallbackFunctions(GLFWwindow* window) + void TutorialApplication::setCallbackFunctions(GLFWwindow* callbackWindow) { - glfwSetKeyCallback(window,embree::keyboardFunc); - glfwSetCursorPosCallback(window,embree::motionFunc); - glfwSetMouseButtonCallback(window,embree::clickFunc); - glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback); - glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback); - glfwSetWindowSizeCallback(window,embree::reshapeFunc); - glfwSetWindowFocusCallback(window, ImGui_ImplGlfw_WindowFocusCallback); - glfwSetCursorEnterCallback(window, ImGui_ImplGlfw_CursorEnterCallback); + glfwSetKeyCallback(callbackWindow,embree::keyboardFunc); + glfwSetCursorPosCallback(callbackWindow,embree::motionFunc); + glfwSetMouseButtonCallback(callbackWindow,embree::clickFunc); + glfwSetCharCallback(callbackWindow, ImGui_ImplGlfw_CharCallback); + glfwSetScrollCallback(callbackWindow, ImGui_ImplGlfw_ScrollCallback); + glfwSetWindowSizeCallback(callbackWindow,embree::reshapeFunc); + glfwSetWindowFocusCallback(callbackWindow, ImGui_ImplGlfw_WindowFocusCallback); + glfwSetCursorEnterCallback(callbackWindow, ImGui_ImplGlfw_CursorEnterCallback); glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback); } @@ -722,16 +722,16 @@ namespace embree glfwWindowHint(GLFW_GREEN_BITS,mode->greenBits); glfwWindowHint(GLFW_BLUE_BITS,mode->blueBits); glfwWindowHint(GLFW_REFRESH_RATE,mode->refreshRate); - GLFWwindow* window = glfwCreateWindow(mode->width,mode->height,tutorialName.c_str(),monitor,nullptr); + GLFWwindow* newWindow = glfwCreateWindow(mode->width,mode->height,tutorialName.c_str(),monitor,nullptr); resize(mode->width,mode->height); - return window; + return newWindow; } - GLFWwindow* TutorialApplication::createStandardWindow(int width, int height) + GLFWwindow* TutorialApplication::createStandardWindow(int winWidth, int winHeight) { - GLFWwindow* window = glfwCreateWindow(width,height,tutorialName.c_str(),nullptr,nullptr); - resize(width,height); - return window; + GLFWwindow* newWindow = glfwCreateWindow(winWidth,winHeight,tutorialName.c_str(),nullptr,nullptr); + resize(winWidth,winHeight); + return newWindow; } /* called when a key is pressed */ @@ -820,13 +820,13 @@ namespace embree } } - void TutorialApplication::clickFunc(GLFWwindow* window, int button, int action, int mods) + void TutorialApplication::clickFunc(GLFWwindow* clickWindow, int button, int action, int mods) { - ImGui_ImplGlfw_MouseButtonCallback(window,button,action,mods); + ImGui_ImplGlfw_MouseButtonCallback(clickWindow,button,action,mods); if (ImGui::GetIO().WantCaptureMouse) return; double x,y; - glfwGetCursorPos(window,&x,&y); + glfwGetCursorPos(clickWindow,&x,&y); if (action == GLFW_RELEASE) { @@ -860,9 +860,9 @@ namespace embree } } - void TutorialApplication::motionFunc(GLFWwindow* window, double x, double y) + void TutorialApplication::motionFunc(GLFWwindow* motionWindow, double x, double y) { - ImGui_ImplGlfw_CursorPosCallback(window, x, y); + ImGui_ImplGlfw_CursorPosCallback(motionWindow, x, y); if (ImGui::GetIO().WantCaptureMouse) return; float dClickX = float(clickX - x), dClickY = float(clickY - y); @@ -982,13 +982,13 @@ namespace embree } } - void TutorialApplication::reshapeFunc(GLFWwindow* window, int, int) + void TutorialApplication::reshapeFunc(GLFWwindow* reshapeWindow, int, int) { - int width,height; - glfwGetFramebufferSize(window, &width, &height); - resize(width,height); - glViewport(0, 0, width, height); - this->width = width; this->height = height; + int newWidth,newHeight; + glfwGetFramebufferSize(reshapeWindow, &newWidth, &newHeight); + resize(newWidth,newHeight); + glViewport(0, 0, newWidth, newHeight); + this->width = newWidth; this->height = newHeight; } void TutorialApplication::renderInteractive() @@ -1036,10 +1036,10 @@ namespace embree #endif - void TutorialApplication::render(unsigned* pixels, const unsigned width, const unsigned height, const float time, const ISPCCamera& camera) + void TutorialApplication::render(unsigned* renderPixels, const unsigned renderWidth, const unsigned renderHeight, const float time, const ISPCCamera& renderCamera) { - device_render(pixels,width,height,time,camera); - renderFrame((int*)pixels,width,height,time,camera); + device_render(renderPixels,renderWidth,renderHeight,time,renderCamera); + renderFrame((int*)renderPixels,renderWidth,renderHeight,time,renderCamera); } void TutorialApplication::run(int argc, char** argv) diff --git a/tutorials/common/tutorial/tutorial_device.cpp b/tutorials/common/tutorial/tutorial_device.cpp index ba6e313a14..fa3d82716b 100644 --- a/tutorials/common/tutorial/tutorial_device.cpp +++ b/tutorials/common/tutorial/tutorial_device.cpp @@ -27,7 +27,7 @@ extern "C" bool device_pick(const float x, ray.tfar = inf; ray.geomID = RTC_INVALID_GEOMETRY_ID; ray.primID = RTC_INVALID_GEOMETRY_ID; - ray.mask = -1; + ray.mask = (unsigned int)-1; ray.time() = g_debug; /* intersect ray with scene */ @@ -106,8 +106,8 @@ float getTextureTexel1f(const Texture* texture, float s, float t) else if (texture->format == Texture::RGBA8) { const int offset = (iv * texture->width + iu) * 4; - unsigned char * t = (unsigned char*)texture->data; - return t[offset+0]*(1.0f/255.0f); + unsigned char * texData = (unsigned char*)texture->data; + return texData[offset+0]*(1.0f/255.0f); } return 0.0f; } @@ -124,10 +124,10 @@ Vec3fa getTextureTexel3f(const Texture* texture, float s, float t) if (texture->format == Texture::RGBA8) { const int offset = (iv * texture->width + iu) * 4; - unsigned char * t = (unsigned char*)texture->data; - const unsigned char r = t[offset+0]; - const unsigned char g = t[offset+1]; - const unsigned char b = t[offset+2]; + unsigned char * texData = (unsigned char*)texture->data; + const unsigned char r = texData[offset+0]; + const unsigned char g = texData[offset+1]; + const unsigned char b = texData[offset+2]; return Vec3fa( (float)r * 1.0f/255.0f, (float)g * 1.0f/255.0f, (float)b * 1.0f/255.0f ); } return Vec3fa(0.0f,0.0f,0.0f); diff --git a/tutorials/curve_geometry/curve_geometry_device.cpp b/tutorials/curve_geometry/curve_geometry_device.cpp index e8aac91557..2ea2f5c0f5 100644 --- a/tutorials/curve_geometry/curve_geometry_device.cpp +++ b/tutorials/curve_geometry/curve_geometry_device.cpp @@ -23,19 +23,19 @@ namespace embree { RTCScene g_scene = nullptr; TutorialData data; -Vec3fa interpolate_linear(const TutorialData& data, unsigned int primID, float u) +Vec3fa interpolate_linear(const TutorialData& tutorialData, unsigned int primID, float u) { - const Vec3fa c0 = ((Vec3fa*) data.hair_vertex_colors)[primID+1]; - const Vec3fa c1 = ((Vec3fa*) data.hair_vertex_colors)[primID+2]; + const Vec3fa c0 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+1]; + const Vec3fa c1 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+2]; return Vec3fa(c0*(1.0f-u) + c1*u); } -Vec3fa interpolate_bspline(const TutorialData& data, unsigned int primID, float u) +Vec3fa interpolate_bspline(const TutorialData& tutorialData, unsigned int primID, float u) { - const Vec3fa c0 = ((Vec3fa*) data.hair_vertex_colors)[primID+0]; - const Vec3fa c1 = ((Vec3fa*) data.hair_vertex_colors)[primID+1]; - const Vec3fa c2 = ((Vec3fa*) data.hair_vertex_colors)[primID+2]; - const Vec3fa c3 = ((Vec3fa*) data.hair_vertex_colors)[primID+3]; + const Vec3fa c0 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+0]; + const Vec3fa c1 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+1]; + const Vec3fa c2 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+2]; + const Vec3fa c3 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+3]; const float t = u; const float s = 1.0f - u; const float n0 = s*s*s; @@ -45,12 +45,12 @@ Vec3fa interpolate_bspline(const TutorialData& data, unsigned int primID, float return Vec3fa((1.0f/6.0f)*(n0*c0 + n1*c1 + n2*c2 + n3*c3)); } -Vec3fa interpolate_catmull_rom(const TutorialData& data, unsigned int primID, float u) +Vec3fa interpolate_catmull_rom(const TutorialData& tutorialData, unsigned int primID, float u) { - const Vec3fa c0 = ((Vec3fa*) data.hair_vertex_colors)[primID+0]; - const Vec3fa c1 = ((Vec3fa*) data.hair_vertex_colors)[primID+1]; - const Vec3fa c2 = ((Vec3fa*) data.hair_vertex_colors)[primID+2]; - const Vec3fa c3 = ((Vec3fa*) data.hair_vertex_colors)[primID+3]; + const Vec3fa c0 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+0]; + const Vec3fa c1 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+1]; + const Vec3fa c2 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+2]; + const Vec3fa c3 = ((Vec3fa*) tutorialData.hair_vertex_colors)[primID+3]; const float t = u; const float s = 1.0f - u; const float n0 = - t * s * s; @@ -144,7 +144,7 @@ extern "C" void device_init (char* cfg) } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -159,7 +159,7 @@ void renderPixelStandard(const TutorialData& data, RTCIntersectArguments iargs; rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ @@ -171,9 +171,9 @@ void renderPixelStandard(const TutorialData& data, if (ray.geomID > 0) { switch (ray.geomID) { - case 1: case 2: case 6: diffuse = interpolate_linear(data,ray.primID,ray.u); break; - case 3: case 4: case 5: diffuse = interpolate_bspline(data,ray.primID,ray.u); break; - case 7: case 8: case 9: diffuse = interpolate_catmull_rom(data,ray.primID,ray.u); break; + case 1: case 2: case 6: diffuse = interpolate_linear(tutorialData,ray.primID,ray.u); break; + case 3: case 4: case 5: diffuse = interpolate_bspline(tutorialData,ray.primID,ray.u); break; + case 7: case 8: case 9: diffuse = interpolate_catmull_rom(tutorialData,ray.primID,ray.u); break; } diffuse = 0.5f*diffuse; @@ -191,7 +191,7 @@ void renderPixelStandard(const TutorialData& data, RTCOccludedArguments sargs; rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/dynamic_scene/dynamic_scene_device.cpp b/tutorials/dynamic_scene/dynamic_scene_device.cpp index b1624f35cc..3cf8ac3521 100644 --- a/tutorials/dynamic_scene/dynamic_scene_device.cpp +++ b/tutorials/dynamic_scene/dynamic_scene_device.cpp @@ -167,7 +167,7 @@ void animateSphere (int taskIndex, int threadIndex, Vertex* vertices, } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -183,14 +183,14 @@ void renderPixelStandard(const TutorialData& data, rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ Vec3fa color = Vec3fa(0.0f); if (ray.geomID != RTC_INVALID_GEOMETRY_ID) { - Vec3fa diffuse = Vec3fa(data.colors[ray.geomID]); + Vec3fa diffuse = Vec3fa(tutorialData.colors[ray.geomID]); color = color + diffuse*0.1f; Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1)); @@ -201,7 +201,7 @@ void renderPixelStandard(const TutorialData& data, RTCOccludedArguments sargs; rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/embree_tests/common/algorithms/parallel_for_for_prefix_sum.cpp b/tutorials/embree_tests/common/algorithms/parallel_for_for_prefix_sum.cpp index ffdac70612..f0cbbfa2ff 100644 --- a/tutorials/embree_tests/common/algorithms/parallel_for_for_prefix_sum.cpp +++ b/tutorials/embree_tests/common/algorithms/parallel_for_for_prefix_sum.cpp @@ -41,8 +41,8 @@ TEST_CASE("Test parallel_for_for_prefix_sum", "[parallel_for_for_prefix_sum]") [&](std::vector *v, const range &r, size_t k, size_t i) -> size_t { size_t s = 0; - for (size_t i=r.begin(); i *v, const range &r, size_t k, size_t i, const size_t base) -> size_t { size_t s = 0; - for (size_t i=r.begin(); i array(N); - for (unsigned i=0; i= split; + for (uint64_t j=0; j= split; } REQUIRE(passed); diff --git a/tutorials/forest/forest_device.cpp b/tutorials/forest/forest_device.cpp index 0266706bf9..e8958d74d0 100644 --- a/tutorials/forest/forest_device.cpp +++ b/tutorials/forest/forest_device.cpp @@ -331,7 +331,7 @@ void rebuild_instances(size_t old_num_trees) } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -343,8 +343,8 @@ void renderPixelStandard(const TutorialData& data, // multiple samples per pixel because otherwise it looks very // bad due to geometric noise/aliasing in the far-field - for (int j = 0; j < data.spp; ++j) - for (int i = 0; i < data.spp; ++i) + for (int j = 0; j < tutorialData.spp; ++j) + for (int i = 0; i < tutorialData.spp; ++i) { float fx = (float) x + ((float)i + 0.5f) / 3; float fy = (float) y + ((float)j + 0.5f) / 3; @@ -355,7 +355,7 @@ void renderPixelStandard(const TutorialData& data, RTCIntersectArguments iargs; rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ @@ -365,20 +365,20 @@ void renderPixelStandard(const TutorialData& data, Vec3fa diffuse = Vec3fa(1.0f); if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID) { unsigned int tree_idx = 0; - if (data.use_instance_array && ray.instPrimID[0] != RTC_INVALID_GEOMETRY_ID) { + if (tutorialData.use_instance_array && ray.instPrimID[0] != RTC_INVALID_GEOMETRY_ID) { tree_idx = ray.instPrimID[0]; } else { tree_idx = ray.instID[0] - 1; } - unsigned int tree_id = data.trees_selected[data.tree_ids_device[tree_idx]]; - Triangle* tree_triangles = data.tree_triangles[tree_id]; + unsigned int tree_id = tutorialData.trees_selected[tutorialData.tree_ids_device[tree_idx]]; + Triangle* tree_triangles = tutorialData.tree_triangles[tree_id]; Triangle triangle = tree_triangles[ray.primID]; - Vec3f* tree_colors = data.tree_vertex_colors[tree_id]; - Vec3f c0 = tree_colors[triangle.v0]; - Vec3f c1 = tree_colors[triangle.v1]; - Vec3f c2 = tree_colors[triangle.v2]; + Vec3f* vertex_colors = tutorialData.tree_vertex_colors[tree_id]; + Vec3f c0 = vertex_colors[triangle.v0]; + Vec3f c1 = vertex_colors[triangle.v1]; + Vec3f c2 = vertex_colors[triangle.v2]; float u = ray.u, v = ray.v, w = 1.0f-ray.u-ray.v; Vec3f c = w*c0 + u*c1 + v*c2; diffuse = Vec3fa(c); @@ -399,7 +399,7 @@ void renderPixelStandard(const TutorialData& data, RTCOccludedArguments sargs; rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ @@ -413,9 +413,9 @@ void renderPixelStandard(const TutorialData& data, } /* write color to framebuffer */ - unsigned int r = (unsigned int) (255.0f * clamp(color_accum.x/(data.spp*data.spp),0.0f,1.0f)); - unsigned int g = (unsigned int) (255.0f * clamp(color_accum.y/(data.spp*data.spp),0.0f,1.0f)); - unsigned int b = (unsigned int) (255.0f * clamp(color_accum.z/(data.spp*data.spp),0.0f,1.0f)); + unsigned int r = (unsigned int) (255.0f * clamp(color_accum.x/(tutorialData.spp*tutorialData.spp),0.0f,1.0f)); + unsigned int g = (unsigned int) (255.0f * clamp(color_accum.y/(tutorialData.spp*tutorialData.spp),0.0f,1.0f)); + unsigned int b = (unsigned int) (255.0f * clamp(color_accum.z/(tutorialData.spp*tutorialData.spp),0.0f,1.0f)); pixels[y*width+x] = (b << 16) + (g << 8) + r; } diff --git a/tutorials/grid_geometry/grid_geometry_device.cpp b/tutorials/grid_geometry/grid_geometry_device.cpp index 1033b9737c..af6ec70644 100644 --- a/tutorials/grid_geometry/grid_geometry_device.cpp +++ b/tutorials/grid_geometry/grid_geometry_device.cpp @@ -358,9 +358,9 @@ void createGridGeometry (GridMesh& gmesh) float v = (float)y / (SUB_GRID_RESOLUTION_Y-1); /* encode UVs */ - const int h = (i >> 2) & 3, l = i & 3; + const int h_uv = (i >> 2) & 3, l = i & 3; const float U = 2.0f*l + 0.5f + u; - const float V = 2.0f*h + 0.5f + v; + const float V = 2.0f*h_uv + 0.5f + v; /* evaluate subdiv surface and displace points */ Vec3fa P,dPdu,dPdv; @@ -414,7 +414,7 @@ void createGridGeometry (GridMesh& gmesh) /* find start of ring */ bool first = true; int startEdge = h+i; - while (first || startEdge != h+i) + while (first || startEdge != int(h+i)) { first = false; int oedge = rtcGetGeometryOppositeHalfEdge(geomSubdiv,0,startEdge); @@ -555,7 +555,7 @@ Vec3fa mylerp(float f, const Vec3fa& a, const Vec3fa& b) { // FIXME: use lerpr, } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -570,7 +570,7 @@ void renderPixelStandard(const TutorialData& data, RTCIntersectArguments iargs; rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ @@ -584,20 +584,20 @@ void renderPixelStandard(const TutorialData& data, if (ray.geomID == 1) { - unsigned int startVertexID = data.gmesh.egrids[ray.primID].startVertexID; - int width = data.gmesh.egrids[ray.primID].width; - int height = data.gmesh.egrids[ray.primID].height; - unsigned int stride = data.gmesh.egrids[ray.primID].stride; - float U = ray.u*(width-1); - float V = ray.v*(height-1); - int x = min((int)floor(U),width -2); - int y = min((int)floor(V),height-2); - float u = U-x; - float v = V-y; - Vec3fa N00 = data.gmesh.normals[startVertexID+(y+0)*stride+(x+0)]; - Vec3fa N01 = data.gmesh.normals[startVertexID+(y+0)*stride+(x+1)]; - Vec3fa N10 = data.gmesh.normals[startVertexID+(y+1)*stride+(x+0)]; - Vec3fa N11 = data.gmesh.normals[startVertexID+(y+1)*stride+(x+1)]; + unsigned int startVertexID = tutorialData.gmesh.egrids[ray.primID].startVertexID; + int gridWidth = tutorialData.gmesh.egrids[ray.primID].width; + int gridHeight = tutorialData.gmesh.egrids[ray.primID].height; + unsigned int stride = tutorialData.gmesh.egrids[ray.primID].stride; + float U = ray.u*(gridWidth-1); + float V = ray.v*(gridHeight-1); + int gridX = min((int)floor(U),gridWidth -2); + int gridY = min((int)floor(V),gridHeight-2); + float u = U-gridX; + float v = V-gridY; + Vec3fa N00 = tutorialData.gmesh.normals[startVertexID+(gridY+0)*stride+(gridX+0)]; + Vec3fa N01 = tutorialData.gmesh.normals[startVertexID+(gridY+0)*stride+(gridX+1)]; + Vec3fa N10 = tutorialData.gmesh.normals[startVertexID+(gridY+1)*stride+(gridX+0)]; + Vec3fa N11 = tutorialData.gmesh.normals[startVertexID+(gridY+1)*stride+(gridX+1)]; Vec3fa N0 = mylerp(u,N00,N01); Vec3fa N1 = mylerp(u,N10,N11); Ng = normalize(mylerp(v,N0,N1)); @@ -611,7 +611,7 @@ void renderPixelStandard(const TutorialData& data, RTCOccludedArguments sargs; rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/hair_geometry/hair_geometry_device.cpp b/tutorials/hair_geometry/hair_geometry_device.cpp index b29a0e2d13..0ed095f4d4 100644 --- a/tutorials/hair_geometry/hair_geometry_device.cpp +++ b/tutorials/hair_geometry/hair_geometry_device.cpp @@ -209,7 +209,7 @@ RTC_SYCL_INDIRECTLY_CALLABLE void occlusionFilter(const RTCFilterFunctionNArgume { RayQueryContext* context = (RayQueryContext*) args->context; - const TutorialData* data = (const TutorialData*) context->tutorialData; + const TutorialData* tutorialData = (const TutorialData*) context->tutorialData; Vec3fa* transparency = (Vec3fa*) context->userRayExt; if (!transparency) return; @@ -227,7 +227,7 @@ RTC_SYCL_INDIRECTLY_CALLABLE void occlusionFilter(const RTCFilterFunctionNArgume *transparency = Vec3fa(0.0f); return; }*/ - Vec3fa T = data->hair_Kt; + Vec3fa T = tutorialData->hair_Kt; T = T * *transparency; *transparency = T; if (max(T.x,max(T.y,T.z)) > 0.02f) @@ -241,7 +241,7 @@ Vec3fa occluded(RTCTraversable traversable, RayQueryContext* context, Ray& ray) ray.geomID = RTC_INVALID_GEOMETRY_ID; ray.primID = RTC_INVALID_GEOMETRY_ID; - ray.mask = -1; + ray.mask = 0xFFFFFFFFu; RTCOccludedArguments args; rtcInitOccludedArguments(&args); @@ -257,17 +257,17 @@ Vec3fa occluded(RTCTraversable traversable, RayQueryContext* context, Ray& ray) } /* task that renders a single screen tile */ -Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& camera, RayStats& stats) +Vec3fa renderPixel(const TutorialData& tutorialData, float x, float y, const ISPCCamera& camera, RayStats& stats) { RandomSampler sampler; - RandomSampler_init(sampler, (int)x, (int)y, data.accu_count); + RandomSampler_init(sampler, (int)x, (int)y, tutorialData.accu_count); x += RandomSampler_get1D(sampler); y += RandomSampler_get1D(sampler); float time = RandomSampler_get1D(sampler); RayQueryContext context; InitIntersectionContext(&context); - context.tutorialData = (void*) &data; + context.tutorialData = (void*) &tutorialData; RTCIntersectArguments args; rtcInitIntersectArguments(&args); @@ -288,18 +288,18 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& return color; /* intersect ray with scene and gather all hits */ - rtcTraversableIntersect1(data.traversable,RTCRayHit_(ray),&args); + rtcTraversableIntersect1(tutorialData.traversable,RTCRayHit_(ray),&args); RayStats_addRay(stats); /* exit if we hit environment */ if (ray.geomID == RTC_INVALID_GEOMETRY_ID) - return color + weight*Vec3fa(data.ambient_intensity); + return color + weight*Vec3fa(tutorialData.ambient_intensity); /* calculate transmissivity of hair */ AnisotropicBlinn brdf; float eps = 0.0001f; - ISPCGeometry* geometry = data.ispc_scene->geometries[ray.geomID]; + ISPCGeometry* geometry = tutorialData.ispc_scene->geometries[ray.geomID]; if (geometry->type == CURVES) { /* calculate tangent space */ @@ -308,8 +308,8 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& const Vec3fa dz = normalize(cross(dy,dx)); /* generate anisotropic BRDF */ - AnisotropicBlinn__Constructor(&brdf,data.hair_Kr,data.hair_Kt,dx,20.0f,dy,2.0f,dz); - brdf.Kr = data.hair_Kr; + AnisotropicBlinn__Constructor(&brdf,tutorialData.hair_Kr,tutorialData.hair_Kt,dx,20.0f,dy,2.0f,dz); + brdf.Kr = tutorialData.hair_Kr; } else if (geometry->type == TRIANGLE_MESH) { @@ -327,11 +327,11 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& return color; /* sample directional light */ - Ray shadow(ray.org + ray.tfar*ray.dir, neg(Vec3fa(data.dirlight_direction)), eps, inf, time); - Vec3fa T = occluded(data.traversable,&context,shadow); + Ray shadow(ray.org + ray.tfar*ray.dir, neg(Vec3fa(tutorialData.dirlight_direction)), eps, inf, time); + Vec3fa T = occluded(tutorialData.traversable,&context,shadow); RayStats_addShadowRay(stats); - Vec3fa c = AnisotropicBlinn__eval(&brdf,neg(ray.dir),neg(Vec3fa(data.dirlight_direction))); - color = color + weight*c*T*Vec3fa(data.dirlight_intensity); + Vec3fa c = AnisotropicBlinn__eval(&brdf,neg(ray.dir),neg(Vec3fa(tutorialData.dirlight_direction))); + color = color + weight*c*T*Vec3fa(tutorialData.dirlight_intensity); #if 1 /* sample BRDF */ @@ -350,7 +350,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& ray.tfar = inf; ray.geomID = RTC_INVALID_GEOMETRY_ID; ray.primID = RTC_INVALID_GEOMETRY_ID; - ray.mask = -1; + ray.mask = 0xFFFFFFFFu; ray.time() = time; weight = weight * c/wi.w; @@ -370,7 +370,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -378,10 +378,10 @@ void renderPixelStandard(const TutorialData& data, const float time, const ISPCCamera& camera, RayStats& stats) { - Vec3fa color = renderPixel(data, (float)x,(float)y,camera,stats); + Vec3fa color = renderPixel(tutorialData, (float)x,(float)y,camera,stats); /* write color to framebuffer */ - Vec3ff accu_color = data.accu[y*width+x] + Vec3ff(color.x,color.y,color.z,1.0f); data.accu[y*width+x] = accu_color; + Vec3ff accu_color = tutorialData.accu[y*width+x] + Vec3ff(color.x,color.y,color.z,1.0f); tutorialData.accu[y*width+x] = accu_color; float f = rcp(max(0.001f,accu_color.w)); unsigned int r = (unsigned int) (255.01f * clamp(accu_color.x*f,0.0f,1.0f)); unsigned int g = (unsigned int) (255.01f * clamp(accu_color.y*f,0.0f,1.0f)); diff --git a/tutorials/host_device_memory/host_device_memory_device.cpp b/tutorials/host_device_memory/host_device_memory_device.cpp index 7add5f11a8..5fab08c154 100644 --- a/tutorials/host_device_memory/host_device_memory_device.cpp +++ b/tutorials/host_device_memory/host_device_memory_device.cpp @@ -379,7 +379,7 @@ static inline float doodlef(uint32_t x) } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -397,14 +397,14 @@ void renderPixelStandard(const TutorialData& data, RTCIntersectArguments iargs; rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ Vec3fa color = Vec3fa(0.0f); if (ray.geomID != RTC_INVALID_GEOMETRY_ID) // || ray.instID[0] != RTC_INVALID_GEOMETRY_ID) { - Vec3fa diffuse = data.face_colors[ray.primID]; + Vec3fa diffuse = tutorialData.face_colors[ray.primID]; color = color + diffuse*0.5f; Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1)); @@ -415,7 +415,7 @@ void renderPixelStandard(const TutorialData& data, RTCOccludedArguments sargs; rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/instanced_geometry/instanced_geometry_device.cpp b/tutorials/instanced_geometry/instanced_geometry_device.cpp index 88b3bd2d3b..b09a3725a9 100644 --- a/tutorials/instanced_geometry/instanced_geometry_device.cpp +++ b/tutorials/instanced_geometry/instanced_geometry_device.cpp @@ -166,7 +166,7 @@ extern "C" void device_init (char* cfg) } /* task that renders a single screen tile */ -Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& camera, RayStats& stats) +Vec3fa renderPixel(const TutorialData& tutorialData, float x, float y, const ISPCCamera& camera, RayStats& stats) { /* initialize ray */ Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf); @@ -176,7 +176,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ @@ -188,16 +188,16 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID) { AffineSpace3fa xfm; - rtcGetGeometryTransformFromTraversable(data.g_traversable,ray.instID[0],0.0f,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,&xfm); + rtcGetGeometryTransformFromTraversable(tutorialData.g_traversable,ray.instID[0],0.0f,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,&xfm); Ns = xfmNormal(xfm,Ns); - //Ns = xfmVector(data.normal_xfm[ray.instID[0]],Ns); + //Ns = xfmVector(tutorialData.normal_xfm[ray.instID[0]],Ns); } Ns = normalize(Ns); /* calculate diffuse color of geometries */ Vec3fa diffuse = Vec3fa(1,1,1); if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID) - diffuse = data.colors[4*ray.instID[0]+ray.geomID]; + diffuse = tutorialData.colors[4*ray.instID[0]+ray.geomID]; color = color + diffuse*0.5; /* initialize shadow ray */ @@ -209,7 +209,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ @@ -219,7 +219,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& return color; } -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -228,7 +228,7 @@ void renderPixelStandard(const TutorialData& data, const ISPCCamera& camera, RayStats& stats) { /* calculate pixel color */ - Vec3fa color = renderPixel(data, (float)x,(float)y,camera, stats); + Vec3fa color = renderPixel(tutorialData, (float)x,(float)y,camera, stats); /* write color to framebuffer */ unsigned int r = (unsigned int) (255.0f * clamp(color.x,0.0f,1.0f)); diff --git a/tutorials/interpolation/interpolation_device.cpp b/tutorials/interpolation/interpolation_device.cpp index 2a17460dbd..34691b69d1 100644 --- a/tutorials/interpolation/interpolation_device.cpp +++ b/tutorials/interpolation/interpolation_device.cpp @@ -349,13 +349,13 @@ extern "C" void device_init (char* cfg) } /* task that renders a single screen tile */ -Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& camera, RayStats& stats) +Vec3fa renderPixel(const TutorialData& tutorialData, float x, float y, const ISPCCamera& camera, RayStats& stats) { /* initialize ray */ Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf); /* intersect ray with scene */ - rtcIntersect1(data.scene,RTCRayHit_(ray)); + rtcIntersect1(tutorialData.scene,RTCRayHit_(ray)); RayStats_addRay(stats); /* shade pixels */ @@ -367,7 +367,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& if (ray.geomID > 0) { auto geomID = ray.geomID; { - rtcInterpolate0(rtcGetGeometry(data.scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,0,&diffuse.x,3); + rtcInterpolate0(rtcGetGeometry(tutorialData.scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,0,&diffuse.x,3); } //return diffuse; diffuse = 0.5f*diffuse; @@ -378,7 +378,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& /*if (ray.geomID == 2 || ray.geomID == 3) { Vec3fa dPdu,dPdv; auto geomID = ray.geomID; { - rtcInterpolate1(rtcGetGeometry(data.scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX,0,nullptr,&dPdu.x,&dPdv.x,3); + rtcInterpolate1(rtcGetGeometry(tutorialData.scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX,0,nullptr,&dPdu.x,&dPdv.x,3); } //return dPdu; Ng = cross(dPdu,dPdv); @@ -391,7 +391,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf); /* trace shadow ray */ - rtcOccluded1(data.scene,RTCRay_(shadow)); + rtcOccluded1(tutorialData.scene,RTCRay_(shadow)); RayStats_addShadowRay(stats); /* add light contribution */ @@ -405,7 +405,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& return color; } -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -415,7 +415,7 @@ void renderPixelStandard(const TutorialData& data, RayStats& stats) { /* calculate pixel color */ - Vec3fa color = renderPixel(data,(float)x,(float)y,camera,stats); + Vec3fa color = renderPixel(tutorialData,(float)x,(float)y,camera,stats); /* write color to framebuffer */ unsigned int r = (unsigned int) (255.0f * clamp(color.x,0.0f,1.0f)); diff --git a/tutorials/intersection_filter/intersection_filter_device.cpp b/tutorials/intersection_filter/intersection_filter_device.cpp index 261788fe1d..c6e5ada7a7 100644 --- a/tutorials/intersection_filter/intersection_filter_device.cpp +++ b/tutorials/intersection_filter/intersection_filter_device.cpp @@ -45,7 +45,7 @@ inline float transparencyFunction(Vec3fa& h) /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -75,7 +75,7 @@ void renderPixelStandard(const TutorialData& data, #if USE_ARGUMENT_CALLBACKS iargs.filter = intersectionFilter; #endif - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(primary),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(primary),&iargs); RayStats_addRay(stats); /* shade pixels */ @@ -83,7 +83,7 @@ void renderPixelStandard(const TutorialData& data, break; float opacity = 1.0f-primary_transparency; - Vec3fa diffuse = data.colors[primary.primID]; + Vec3fa diffuse = tutorialData.colors[primary.primID]; Vec3fa La = diffuse*0.5f; color = color + weight*opacity*La; Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1)); @@ -102,7 +102,7 @@ void renderPixelStandard(const TutorialData& data, #if USE_ARGUMENT_CALLBACKS sargs.filter = occlusionFilter; #endif - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/minimal/minimal.cpp b/tutorials/minimal/minimal.cpp index 72bf595835..ad7cecf091 100644 --- a/tutorials/minimal/minimal.cpp +++ b/tutorials/minimal/minimal.cpp @@ -168,7 +168,7 @@ void castRay(RTCScene scene, rayhit.ray.dir_z = dz; rayhit.ray.tnear = 0; rayhit.ray.tfar = std::numeric_limits::infinity(); - rayhit.ray.mask = -1; + rayhit.ray.mask = (unsigned int)-1; rayhit.ray.flags = 0; rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID; rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; diff --git a/tutorials/minimal/minimal_sycl.cpp b/tutorials/minimal/minimal_sycl.cpp index eff1d1b34e..f15eb33f4f 100644 --- a/tutorials/minimal/minimal_sycl.cpp +++ b/tutorials/minimal/minimal_sycl.cpp @@ -237,7 +237,7 @@ void castRay(sycl::queue& queue, const RTCTraversable traversable, rayhit.ray.dir_z = dz; rayhit.ray.tnear = 0; rayhit.ray.tfar = std::numeric_limits::infinity(); - rayhit.ray.mask = -1; + rayhit.ray.mask = 0xFFFFFFFFu; rayhit.ray.flags = 0; rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID; rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; diff --git a/tutorials/motion_blur_geometry/motion_blur_geometry_device.cpp b/tutorials/motion_blur_geometry/motion_blur_geometry_device.cpp index ba84edc918..715271066f 100644 --- a/tutorials/motion_blur_geometry/motion_blur_geometry_device.cpp +++ b/tutorials/motion_blur_geometry/motion_blur_geometry_device.cpp @@ -612,10 +612,10 @@ extern "C" void device_init (char* cfg) } /* task that renders a single screen tile */ -Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& camera, RayStats& stats) +Vec3fa renderPixel(const TutorialData& tutorialData, float x, float y, const ISPCCamera& camera, RayStats& stats) { - float time = abs((int)(0.01f*data.frameID) - 0.01f*data.frameID); - if (data.g_time != -1) time = data.g_time; + float time = abs((int)(0.01f*tutorialData.frameID) - 0.01f*tutorialData.frameID); + if (tutorialData.g_time != -1) time = tutorialData.g_time; /* initialize ray */ Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf, time); @@ -628,7 +628,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& iargs.intersect = sphereIntersectFuncN; #endif - rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable,RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ @@ -639,16 +639,16 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& if (ray.instID[0] == RTC_INVALID_GEOMETRY_ID) ray.instID[0] = ray.geomID; switch (ray.instID[0] / 2) { - case 0: diffuse = data.face_colors[ray.primID]; break; - case 1: diffuse = data.face_colors[2*ray.primID]; break; - case 2: diffuse = data.face_colors[2*ray.primID]; break; + case 0: diffuse = tutorialData.face_colors[ray.primID]; break; + case 1: diffuse = tutorialData.face_colors[2*ray.primID]; break; + case 2: diffuse = tutorialData.face_colors[2*ray.primID]; break; case 3: diffuse = Vec3fa(0.5f,0.0f,0.0f); break; case 4: diffuse = Vec3fa(0.0f,0.5f,0.0f); break; case 5: diffuse = Vec3fa(0.0f,0.0f,0.5f); break; - case 6: diffuse = data.face_colors[ray.primID]; break; - case 7: diffuse = data.face_colors[2*ray.primID]; break; + case 6: diffuse = tutorialData.face_colors[ray.primID]; break; + case 7: diffuse = tutorialData.face_colors[2*ray.primID]; break; case 8: diffuse = Vec3fa(0.5f,0.5f,0.0f); break; default: diffuse = Vec3fa(0.5f,0.5f,0.5f); break; } @@ -665,7 +665,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& #if USE_ARGUMENT_CALLBACKS sargs.occluded = sphereOccludedFuncN; #endif - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ @@ -675,7 +675,7 @@ Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& return color; } -void renderPixelStandard(const TutorialData& data, int x, int y, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, const unsigned int height, @@ -683,10 +683,10 @@ void renderPixelStandard(const TutorialData& data, int x, int y, const ISPCCamera& camera, RayStats& stats) { /* calculate pixel color */ - Vec3fa color = renderPixel(data,(float)x,(float)y,camera,stats); + Vec3fa color = renderPixel(tutorialData,(float)x,(float)y,camera,stats); /* write color to framebuffer */ - Vec3ff accu_color = data.g_accu[y*width+x] + Vec3ff(color.x,color.y,color.z,1.0f); data.g_accu[y*width+x] = accu_color; + Vec3ff accu_color = tutorialData.g_accu[y*width+x] + Vec3ff(color.x,color.y,color.z,1.0f); tutorialData.g_accu[y*width+x] = accu_color; float f = rcp(max(0.001f,accu_color.w)); unsigned int r = (unsigned int) (255.0f * clamp(accu_color.x*f,0.0f,1.0f)); unsigned int g = (unsigned int) (255.0f * clamp(accu_color.y*f,0.0f,1.0f)); diff --git a/tutorials/multiscene_geometry/multiscene_geometry_device.cpp b/tutorials/multiscene_geometry/multiscene_geometry_device.cpp index 03cc499b87..004c2aa04f 100644 --- a/tutorials/multiscene_geometry/multiscene_geometry_device.cpp +++ b/tutorials/multiscene_geometry/multiscene_geometry_device.cpp @@ -183,7 +183,7 @@ namespace embree { } /* task that renders a single screen tile */ - void renderPixelStandard(const TutorialData& data, + void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -199,14 +199,14 @@ namespace embree { rtcInitIntersectArguments(&iargs); iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableIntersect1(data.g_traversable, RTCRayHit_(ray),&iargs); + rtcTraversableIntersect1(tutorialData.g_traversable, RTCRayHit_(ray),&iargs); RayStats_addRay(stats); /* shade pixels */ Vec3fa color = Vec3fa(0.0f); if (ray.geomID != RTC_INVALID_GEOMETRY_ID) { - Vec3fa diffuse = data.colors[ray.geomID]; + Vec3fa diffuse = tutorialData.colors[ray.geomID]; color = color + diffuse * 0.1f; Vec3fa lightDir = normalize(Vec3fa(-1, -1, -1)); @@ -218,7 +218,7 @@ namespace embree { rtcInitOccludedArguments(&sargs); sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable, RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.g_traversable, RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/next_hit/next_hit_device.cpp b/tutorials/next_hit/next_hit_device.cpp index 0978c6bb6b..00cab66ccd 100644 --- a/tutorials/next_hit/next_hit_device.cpp +++ b/tutorials/next_hit/next_hit_device.cpp @@ -25,8 +25,8 @@ RTCFeatureFlags g_feature_mask; /* extended ray structure that gathers all hits along the ray */ struct HitList { - HitList (const TutorialData& data) - : data(data), begin(0), end(0) { + HitList (const TutorialData& tutorialData) + : data(tutorialData), begin(0), end(0) { } /* Hit structure that defines complete order over hits */ @@ -102,8 +102,8 @@ struct HitList /* we store the Hit list inside the ray query context to access it from the filter functions */ struct RayQueryContext { - RayQueryContext(const TutorialData& data, HitList& hits) - : hits(hits), max_next_hits(data.max_next_hits) {} + RayQueryContext(const TutorialData& tutorialData, HitList& hits) + : hits(hits), max_next_hits(tutorialData.max_next_hits) {} RTCRayQueryContext context; HitList& hits; @@ -143,11 +143,11 @@ RTC_SYCL_INDIRECTLY_CALLABLE void gather_all_hits(const RTCFilterFunctionNArgume } /* gathers hits in a single pass */ -void single_pass(const TutorialData& data, const Ray& ray_i, HitList& hits_o, RandomSampler& sampler, RayStats& stats, const RTCFeatureFlags feature_mask) +void single_pass(const TutorialData& tutorialData, const Ray& ray_i, HitList& hits_o, RandomSampler& sampler, RayStats& stats, const RTCFeatureFlags feature_mask) { /* trace ray to gather all hits */ Ray ray = ray_i; - RayQueryContext context(data,hits_o); + RayQueryContext context(tutorialData,hits_o); rtcInitRayQueryContext(&context.context); RTCIntersectArguments args; rtcInitIntersectArguments(&args); @@ -155,7 +155,7 @@ void single_pass(const TutorialData& data, const Ray& ray_i, HitList& hits_o, Ra args.filter = gather_all_hits; args.feature_mask = feature_mask; args.flags = RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER; // invoke filter for each geometry - rtcTraversableIntersect1(data.traversable,RTCRayHit_(ray),&args); + rtcTraversableIntersect1(tutorialData.traversable,RTCRayHit_(ray),&args); RayStats_addRay(stats); /* sort hits by extended order */ @@ -174,16 +174,16 @@ void single_pass(const TutorialData& data, const Ray& ray_i, HitList& hits_o, Ra } /* drop hits in case we found too many */ - hits_o.end = std::min(hits_o.end, data.max_total_hits); + hits_o.end = std::min(hits_o.end, tutorialData.max_total_hits); /* shade all hits */ - if (data.enable_opacity) + if (tutorialData.enable_opacity) { for (unsigned int i=context.hits.begin; itype == TRIANGLE_MESH) { @@ -1121,10 +1121,10 @@ void postIntersectGeometry(const TutorialData& data, const Ray& ray, Differentia if (mesh->texcoords) { - ISPCTriangle* tri = &mesh->triangles[dg.primID]; - const Vec2f st0 = mesh->texcoords[tri->v0]; - const Vec2f st1 = mesh->texcoords[tri->v1]; - const Vec2f st2 = mesh->texcoords[tri->v2]; + ISPCTriangle* tex_tri = &mesh->triangles[dg.primID]; + const Vec2f st0 = mesh->texcoords[tex_tri->v0]; + const Vec2f st1 = mesh->texcoords[tex_tri->v1]; + const Vec2f st2 = mesh->texcoords[tex_tri->v2]; const float u = ray.u, v = ray.v, w = 1.0f-ray.u-ray.v; const Vec2f st = w*st0 + u*st1 + v*st2; dg.u = st.x; @@ -1134,26 +1134,26 @@ void postIntersectGeometry(const TutorialData& data, const Ray& ray, Differentia { if (mesh->numTimeSteps == 1) { - ISPCTriangle* tri = &mesh->triangles[dg.primID]; - const Vec3fa n0 = Vec3fa(mesh->normals[0][tri->v0]); - const Vec3fa n1 = Vec3fa(mesh->normals[0][tri->v1]); - const Vec3fa n2 = Vec3fa(mesh->normals[0][tri->v2]); + ISPCTriangle* normal_tri = &mesh->triangles[dg.primID]; + const Vec3fa n0 = Vec3fa(mesh->normals[0][normal_tri->v0]); + const Vec3fa n1 = Vec3fa(mesh->normals[0][normal_tri->v1]); + const Vec3fa n2 = Vec3fa(mesh->normals[0][normal_tri->v2]); const float u = ray.u, v = ray.v, w = 1.0f-ray.u-ray.v; dg.Ns = w*n0 + u*n1 + v*n2; } else { - ISPCTriangle* tri = &mesh->triangles[dg.primID]; + ISPCTriangle* tri_mb = &mesh->triangles[dg.primID]; float f = mesh->numTimeSteps*ray.time(); int itime = clamp((int)floor(f),0,(int)mesh->numTimeSteps-2); float t1 = f-itime; float t0 = 1.0f-t1; - const Vec3fa a0 = Vec3fa(mesh->normals[itime+0][tri->v0]); - const Vec3fa a1 = Vec3fa(mesh->normals[itime+0][tri->v1]); - const Vec3fa a2 = Vec3fa(mesh->normals[itime+0][tri->v2]); - const Vec3fa b0 = Vec3fa(mesh->normals[itime+1][tri->v0]); - const Vec3fa b1 = Vec3fa(mesh->normals[itime+1][tri->v1]); - const Vec3fa b2 = Vec3fa(mesh->normals[itime+1][tri->v2]); + const Vec3fa a0 = Vec3fa(mesh->normals[itime+0][tri_mb->v0]); + const Vec3fa a1 = Vec3fa(mesh->normals[itime+0][tri_mb->v1]); + const Vec3fa a2 = Vec3fa(mesh->normals[itime+0][tri_mb->v2]); + const Vec3fa b0 = Vec3fa(mesh->normals[itime+1][tri_mb->v0]); + const Vec3fa b1 = Vec3fa(mesh->normals[itime+1][tri_mb->v1]); + const Vec3fa b2 = Vec3fa(mesh->normals[itime+1][tri_mb->v2]); const Vec3fa n0 = t0*a0 + t1*b0; const Vec3fa n1 = t0*a1 + t1*b1; const Vec3fa n2 = t0*a2 + t1*b2; @@ -1177,11 +1177,11 @@ void postIntersectGeometry(const TutorialData& data, const Ray& ray, Differentia if (mesh->texcoords) { - ISPCQuad* quad = &mesh->quads[dg.primID]; - const Vec2f st0 = mesh->texcoords[quad->v0]; - const Vec2f st1 = mesh->texcoords[quad->v1]; - const Vec2f st2 = mesh->texcoords[quad->v2]; - const Vec2f st3 = mesh->texcoords[quad->v3]; + ISPCQuad* tex_quad = &mesh->quads[dg.primID]; + const Vec2f st0 = mesh->texcoords[tex_quad->v0]; + const Vec2f st1 = mesh->texcoords[tex_quad->v1]; + const Vec2f st2 = mesh->texcoords[tex_quad->v2]; + const Vec2f st3 = mesh->texcoords[tex_quad->v3]; if (ray.u+ray.v < 1.0f) { const float u = ray.u, v = ray.v; const float w = 1.0f-u-v; const Vec2f st = w*st0 + u*st1 + v*st3; @@ -1198,11 +1198,11 @@ void postIntersectGeometry(const TutorialData& data, const Ray& ray, Differentia { if (mesh->numTimeSteps == 1) { - ISPCQuad* quad = &mesh->quads[dg.primID]; - const Vec3fa n0 = Vec3fa(mesh->normals[0][quad->v0]); - const Vec3fa n1 = Vec3fa(mesh->normals[0][quad->v1]); - const Vec3fa n2 = Vec3fa(mesh->normals[0][quad->v2]); - const Vec3fa n3 = Vec3fa(mesh->normals[0][quad->v3]); + ISPCQuad* quad_norm = &mesh->quads[dg.primID]; + const Vec3fa n0 = Vec3fa(mesh->normals[0][quad_norm->v0]); + const Vec3fa n1 = Vec3fa(mesh->normals[0][quad_norm->v1]); + const Vec3fa n2 = Vec3fa(mesh->normals[0][quad_norm->v2]); + const Vec3fa n3 = Vec3fa(mesh->normals[0][quad_norm->v3]); if (ray.u+ray.v < 1.0f) { const float u = ray.u, v = ray.v; const float w = 1.0f-u-v; dg.Ns = w*n0 + u*n1 + v*n3; @@ -1213,19 +1213,19 @@ void postIntersectGeometry(const TutorialData& data, const Ray& ray, Differentia } else { - ISPCQuad* quad = &mesh->quads[dg.primID]; + ISPCQuad* quad_mb = &mesh->quads[dg.primID]; float f = mesh->numTimeSteps*ray.time(); int itime = clamp((int)floor(f),0,(int)mesh->numTimeSteps-2); float t1 = f-itime; float t0 = 1.0f-t1; - const Vec3fa a0 = Vec3fa(mesh->normals[itime+0][quad->v0]); - const Vec3fa a1 = Vec3fa(mesh->normals[itime+0][quad->v1]); - const Vec3fa a2 = Vec3fa(mesh->normals[itime+0][quad->v2]); - const Vec3fa a3 = Vec3fa(mesh->normals[itime+0][quad->v3]); - const Vec3fa b0 = Vec3fa(mesh->normals[itime+1][quad->v0]); - const Vec3fa b1 = Vec3fa(mesh->normals[itime+1][quad->v1]); - const Vec3fa b2 = Vec3fa(mesh->normals[itime+1][quad->v2]); - const Vec3fa b3 = Vec3fa(mesh->normals[itime+1][quad->v3]); + const Vec3fa a0 = Vec3fa(mesh->normals[itime+0][quad_mb->v0]); + const Vec3fa a1 = Vec3fa(mesh->normals[itime+0][quad_mb->v1]); + const Vec3fa a2 = Vec3fa(mesh->normals[itime+0][quad_mb->v2]); + const Vec3fa a3 = Vec3fa(mesh->normals[itime+0][quad_mb->v3]); + const Vec3fa b0 = Vec3fa(mesh->normals[itime+1][quad_mb->v0]); + const Vec3fa b1 = Vec3fa(mesh->normals[itime+1][quad_mb->v1]); + const Vec3fa b2 = Vec3fa(mesh->normals[itime+1][quad_mb->v2]); + const Vec3fa b3 = Vec3fa(mesh->normals[itime+1][quad_mb->v3]); const Vec3fa n0 = t0*a0 + t1*b0; const Vec3fa n1 = t0*a1 + t1*b1; const Vec3fa n2 = t0*a2 + t1*b2; @@ -1246,7 +1246,7 @@ void postIntersectGeometry(const TutorialData& data, const Ray& ray, Differentia ISPCSubdivMesh* mesh = (ISPCSubdivMesh*) geometry; materialID = mesh->geom.materialID; - if (data.use_smooth_normals) + if (tutorialData.use_smooth_normals) { Vec3fa dPdu,dPdv; rtcInterpolate1(mesh->geom.geometry,dg.primID,dg.u,dg.v,RTC_BUFFER_TYPE_VERTEX,0,nullptr,&dPdu.x,&dPdv.x,3); @@ -1355,16 +1355,16 @@ AffineSpace3fa calculate_interpolated_space (ISPCInstance* instance, float gtime typedef ISPCInstance* ISPCInstancePtr; -inline int postIntersect(const TutorialData& data, const Ray& ray, DifferentialGeometry& dg) +inline int postIntersect(const TutorialData& tutorialData, const Ray& ray, DifferentialGeometry& dg) { dg.eps = 32.0f*1.19209e-07f*max(max(abs(dg.P.x),abs(dg.P.y)),max(abs(dg.P.z),ray.tfar)); AffineSpace3fa local2world = AffineSpace3fa::scale(Vec3fa(1)); - ISPCGeometry** geometries = data.ispc_scene->geometries; + ISPCGeometry** geometries = tutorialData.ispc_scene->geometries; - for (int i=0; icontext; TutorialData* pdata = (TutorialData*) context->tutorialData; - TutorialData& data = *pdata; + TutorialData& tutorialDataRef = *pdata; Vec3fa* transparency = (Vec3fa*) context->userRayExt; if (!transparency) return; @@ -1423,11 +1423,11 @@ RTC_SYCL_INDIRECTLY_CALLABLE void occlusionFilterHair(const RTCFilterFunctionNAr Vec3fa Kt = Vec3fa(0.0f); auto geomID = hit_geomID; { - ISPCGeometry* geometry = data.ispc_scene->geometries[geomID]; + ISPCGeometry* geometry = tutorialDataRef.ispc_scene->geometries[geomID]; if (geometry->type == CURVES) { int materialID = ((ISPCHairSet*)geometry)->geom.materialID; - ISPCMaterial* material = data.ispc_scene->materials[materialID]; + ISPCMaterial* material = tutorialDataRef.ispc_scene->materials[materialID]; switch (material->type) { case MATERIAL_HAIR: Kt = Vec3fa(((ISPCHairMaterial*)material)->Kt); break; default: break; @@ -1445,7 +1445,7 @@ RTC_SYCL_INDIRECTLY_CALLABLE void contextFilterFunction(const RTCFilterFunctionN { RayQueryContext* context = (RayQueryContext*) args->context; TutorialData* pdata = (TutorialData*) context->tutorialData; - TutorialData& data = *pdata; + TutorialData& tutorialData = *pdata; int* valid_i = args->valid; bool valid = *((int*) valid_i); @@ -1455,7 +1455,7 @@ RTC_SYCL_INDIRECTLY_CALLABLE void contextFilterFunction(const RTCFilterFunctionN if (potential_hit->instID[0] == -1) { unsigned int geomID = potential_hit->geomID; - ISPCGeometry* geometry = data.ispc_scene->geometries[geomID]; + ISPCGeometry* geometry = tutorialData.ispc_scene->geometries[geomID]; if (geometry->type == SUBDIV_MESH || geometry->type == TRIANGLE_MESH || @@ -1471,7 +1471,7 @@ RTC_SYCL_INDIRECTLY_CALLABLE void contextFilterFunction(const RTCFilterFunctionN } } -Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSampler& sampler, const ISPCCamera& camera, RayStats& stats, const RTCFeatureFlags features) +Vec3fa renderPixelFunction(const TutorialData& tutorialData, float x, float y, RandomSampler& sampler, const ISPCCamera& camera, RayStats& stats, const RTCFeatureFlags features) { /* radiance accumulator and weight */ Vec3fa L = Vec3fa(0.0f); @@ -1486,7 +1486,7 @@ Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSam DifferentialGeometry dg; /* iterative path tracer loop */ - for (int i=0; inumLights; i++) + for (unsigned int j=0; jnumLights; j++) { - const Light* l = data.ispc_scene->lights[i]; + const Light* l = tutorialData.ispc_scene->lights[j]; //Light_EvalRes le = l->eval(l,dg,ray.dir); Light_EvalRes le = Lights_eval(l,dg,ray.dir); L = L + Lw*le.value; @@ -1530,8 +1530,8 @@ Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSam Vec3fa Ns = normalize(ray.Ng); /* compute differential geometry */ - for (int i=0; inumMaterials; - ISPCMaterial** material_array = &data.ispc_scene->materials[0]; + int numMaterials = tutorialData.ispc_scene->numMaterials; + ISPCMaterial** material_array = &tutorialData.ispc_scene->materials[0]; Material__preprocess(material_array,materialID,numMaterials,brdf,wo,dg,medium); /* sample BRDF at hit point */ @@ -1561,9 +1561,9 @@ Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSam c = c * Material__sample(material_array,materialID,numMaterials,brdf,Lw, wo, dg, wi1, medium, RandomSampler_get2D(sampler)); /* iterate over lights */ - for (unsigned int i=0; inumLights; i++) + for (unsigned int j=0; jnumLights; j++) { - const Light* l = data.ispc_scene->lights[i]; + const Light* l = tutorialData.ispc_scene->lights[j]; //Light_SampleRes ls = l->sample(l,dg,RandomSampler_get2D(sampler)); Light_SampleRes ls = Lights_sample(l,dg,RandomSampler_get2D(sampler)); if (ls.pdf <= 0.0f) continue; @@ -1574,12 +1574,12 @@ Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSam RTCOccludedArguments sargs; rtcInitOccludedArguments(&sargs); sargs.context = &context.context; - sargs.flags = data.iflags_incoherent; + sargs.flags = tutorialData.iflags_incoherent; sargs.feature_mask = features; #if USE_ARGUMENT_CALLBACKS && ENABLE_FILTER_FUNCTION sargs.filter = contextFilterFunction; #endif - rtcTraversableOccluded1(data.traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(tutorialData.traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); #if !ENABLE_FILTER_FUNCTION if (shadow.tfar > 0.0f) @@ -1602,7 +1602,7 @@ Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSam } /* task that renders a single screen tile */ -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& tutorialData, int x, int y, int* pixels, const unsigned int width, @@ -1616,19 +1616,19 @@ void renderPixelStandard(const TutorialData& data, Vec3fa L = Vec3fa(0.0f); - for (int i=0; inormal2world,Vec3fa(Ns)); + Ns = xfmVector(td.g_instance[ray.instID[0]]->normal2world,Vec3fa(Ns)); } Ns = face_forward(ray.dir,normalize(Ns)); /* calculate diffuse color of geometries */ Vec3fa diffuse = Vec3fa(0.0f); - if (ray.instID[0] == 0) diffuse = data.colors[4*ray.instID[0]+ray.primID]; - else if (ray.instID[0] == -1) diffuse = data.colors[4*4+ray.primID]; - else diffuse = data.colors[4*ray.instID[0]+ray.geomID]; + if (ray.instID[0] == 0) diffuse = td.colors[4*ray.instID[0]+ray.primID]; + else if (ray.instID[0] == -1) diffuse = td.colors[4*4+ray.primID]; + else diffuse = td.colors[4*ray.instID[0]+ray.geomID]; color = color + diffuse*0.5f; /* initialize shadow ray */ @@ -799,7 +799,7 @@ Vec3fa renderPixelStandard(const TutorialData& data, #endif sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); - rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); + rtcTraversableOccluded1(td.g_traversable,RTCRay_(shadow),&sargs); RayStats_addShadowRay(stats); /* add light contribution */ @@ -809,7 +809,7 @@ Vec3fa renderPixelStandard(const TutorialData& data, return color; } -void renderPixelStandard(const TutorialData& data, +void renderPixelStandard(const TutorialData& td, int x, int y, int* pixels, const unsigned int width, @@ -817,7 +817,7 @@ void renderPixelStandard(const TutorialData& data, const float time, const ISPCCamera& camera, RayStats& stats) { - Vec3fa color = renderPixelStandard(data,x,y,camera,stats); + Vec3fa color = renderPixelStandard(td,x,y,camera,stats); /* write color to framebuffer */ unsigned int r = (unsigned int) (255.0f * clamp(color.x,0.0f,1.0f)); diff --git a/tutorials/verify/rtcore_helpers.h b/tutorials/verify/rtcore_helpers.h index e585cb7353..116edf28c4 100644 --- a/tutorials/verify/rtcore_helpers.h +++ b/tutorials/verify/rtcore_helpers.h @@ -126,15 +126,15 @@ namespace embree rh.ray.tnear = pos_inf; rh.ray.tfar = neg_inf; rh.ray.time = 0; - rh.ray.mask = -1; - rh.ray.id = -1; + rh.ray.mask = (unsigned int)-1; + rh.ray.id = (unsigned int)-1; rh.hit.Ng_x = 0.0f; rh.hit.Ng_y = 0.0f; rh.hit.Ng_z = 0.0f; rh.hit.u = 0.0f; rh.hit.v = 0.0f; - rh.hit.geomID = -1; - rh.hit.primID = -1; + rh.hit.geomID = (unsigned int)-1; + rh.hit.primID = (unsigned int)-1; for (unsigned l = 0; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l) { rh.hit.instID[l] = RTC_INVALID_GEOMETRY_ID; #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) @@ -149,8 +149,8 @@ namespace embree rh.ray.org_x = org.x; rh.ray.org_y = org.y; rh.ray.org_z = org.z; rh.ray.dir_x = dir.x; rh.ray.dir_y = dir.y; rh.ray.dir_z = dir.z; rh.ray.tnear = 0.0f; rh.ray.tfar = inf; - rh.ray.time = 0; rh.ray.mask = -1; - rh.hit.geomID = rh.hit.primID = -1; + rh.ray.time = 0; rh.ray.mask = (unsigned int)-1; + rh.hit.geomID = rh.hit.primID = (unsigned int)-1; for (unsigned l = 0; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l) { rh.hit.instID[l] = RTC_INVALID_GEOMETRY_ID; #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) @@ -166,8 +166,8 @@ namespace embree rh.ray.org_x = org.x; rh.ray.org_y = org.y; rh.ray.org_z = org.z; rh.ray.dir_x = dir.x; rh.ray.dir_y = dir.y; rh.ray.dir_z = dir.z; rh.ray.tnear = tnear; rh.ray.tfar = tfar; - rh.ray.time = 0; rh.ray.mask = -1; - rh.hit.geomID = rh.hit.primID = -1; + rh.ray.time = 0; rh.ray.mask = (unsigned int)-1; + rh.hit.geomID = rh.hit.primID = (unsigned int)-1; for (unsigned l = 0; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l) { rh.hit.instID[l] = RTC_INVALID_GEOMETRY_ID; #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) @@ -185,9 +185,9 @@ namespace embree rh.ray.tnear = 0.0f; rh.ray.tfar = inf; rh.ray.time = 0; - rh.ray.mask = -1; - rh.ray.id = -1; - rh.hit.geomID = rh.hit.primID = -1; + rh.ray.mask = (unsigned int)-1; + rh.ray.id = (unsigned int)-1; + rh.hit.geomID = rh.hit.primID = (unsigned int)-1; for (unsigned l = 0; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l) { rh.hit.instID[l] = RTC_INVALID_GEOMETRY_ID; #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) @@ -209,9 +209,9 @@ namespace embree rh.ray.tnear = 0.0f; rh.ray.tfar = inf; rh.ray.time = 0; - rh.ray.mask = -1; - rh.ray.id = -1; - rh.hit.geomID = rh.hit.primID = rh.hit.instID[0] = -1; + rh.ray.mask = (unsigned int)-1; + rh.ray.id = (unsigned int)-1; + rh.hit.geomID = rh.hit.primID = rh.hit.instID[0] = (unsigned int)-1; #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) rh.hit.instPrimID[0] = RTC_INVALID_GEOMETRY_ID; #endif @@ -228,8 +228,8 @@ namespace embree rh.ray.org_x = org.x; rh.ray.org_y = org.y; rh.ray.org_z = org.z; // FIXME: optimize rh.ray.dir_x = dir.x; rh.ray.dir_y = dir.y; rh.ray.dir_z = dir.z; rh.ray.tnear = tnear; rh.ray.tfar = tfar; - rh.ray.time = 0; rh.ray.mask = -1; rh.ray.id = -1; - rh.hit.geomID = rh.hit.primID = -1; + rh.ray.time = 0; rh.ray.mask = (unsigned int)-1; rh.ray.id = (unsigned int)-1; + rh.hit.geomID = rh.hit.primID = (unsigned int)-1; for (unsigned l = 0; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l) { rh.hit.instID[l] = RTC_INVALID_GEOMETRY_ID; #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) diff --git a/tutorials/verify/verify.cpp b/tutorials/verify/verify.cpp index 14fd060d48..fcdb8196cb 100644 --- a/tutorials/verify/verify.cpp +++ b/tutorials/verify/verify.cpp @@ -186,89 +186,89 @@ namespace embree rtcReleaseGeometry(geom); return geomID; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh2 = node.dynamicCast()) { RTCGeometry geom = rtcNewGeometry (device, RTC_GEOMETRY_TYPE_QUAD); AssertNoError(device); - rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh->numTimeSteps()); + rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh2->numTimeSteps()); rtcSetGeometryBuildQuality(geom,quality); AssertNoError(device); - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT4,mesh->quads.data(),0,sizeof(SceneGraph::QuadMeshNode::Quad), mesh->quads.size()); - for (unsigned int t=0; tnumTimeSteps(); t++) - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT3,mesh->positions[t].data(),0,sizeof(SceneGraph::QuadMeshNode::Vertex), mesh->positions[t].size()); + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT4,mesh2->quads.data(),0,sizeof(SceneGraph::QuadMeshNode::Quad), mesh2->quads.size()); + for (unsigned int t=0; tnumTimeSteps(); t++) + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT3,mesh2->positions[t].data(),0,sizeof(SceneGraph::QuadMeshNode::Vertex), mesh2->positions[t].size()); AssertNoError(device); rtcCommitGeometry(geom); unsigned int geomID = rtcAttachGeometry(scene,geom); rtcReleaseGeometry(geom); return geomID; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh3 = node.dynamicCast()) { RTCGeometry geom = rtcNewGeometry (device, RTC_GEOMETRY_TYPE_GRID); AssertNoError(device); - rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh->numTimeSteps()); + rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh3->numTimeSteps()); rtcSetGeometryBuildQuality(geom,quality); AssertNoError(device); - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_GRID,0,RTC_FORMAT_GRID,mesh->grids.data(),0,sizeof(SceneGraph::GridMeshNode::Grid), mesh->grids.size()); - for (unsigned int t=0; tnumTimeSteps(); t++) - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT3,mesh->positions[t].data(),0,sizeof(SceneGraph::GridMeshNode::Vertex), mesh->positions[t].size()); + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_GRID,0,RTC_FORMAT_GRID,mesh3->grids.data(),0,sizeof(SceneGraph::GridMeshNode::Grid), mesh3->grids.size()); + for (unsigned int t=0; tnumTimeSteps(); t++) + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT3,mesh3->positions[t].data(),0,sizeof(SceneGraph::GridMeshNode::Vertex), mesh3->positions[t].size()); AssertNoError(device); rtcCommitGeometry(geom); unsigned int geomID = rtcAttachGeometry(scene,geom); rtcReleaseGeometry(geom); return geomID; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh4 = node.dynamicCast()) { RTCGeometry geom = rtcNewGeometry (device, RTC_GEOMETRY_TYPE_SUBDIVISION); AssertNoError(device); - rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh->numTimeSteps()); + rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh4->numTimeSteps()); rtcSetGeometryBuildQuality(geom,quality); AssertNoError(device); - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_FACE, 0,RTC_FORMAT_UINT,mesh->verticesPerFace.data(),0,sizeof(int), mesh->verticesPerFace.size()); - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT,mesh->position_indices.data(),0,sizeof(int), mesh->position_indices.size()); - for (unsigned int t=0; tnumTimeSteps(); t++) - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT3,mesh->positions[t].data(),0,sizeof(SceneGraph::SubdivMeshNode::Vertex), mesh->positions[t].size()); - if (mesh->edge_creases.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_EDGE_CREASE_INDEX,0,RTC_FORMAT_UINT2,mesh->edge_creases.data(),0,2*sizeof(int), mesh->edge_creases.size()); - if (mesh->edge_crease_weights.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_EDGE_CREASE_WEIGHT,0,RTC_FORMAT_FLOAT,mesh->edge_crease_weights.data(),0,sizeof(float),mesh->edge_crease_weights.size()); - if (mesh->vertex_creases.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX_CREASE_INDEX,0,RTC_FORMAT_UINT,mesh->vertex_creases.data(),0,sizeof(int), mesh->vertex_creases.size()); - if (mesh->vertex_crease_weights.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX_CREASE_WEIGHT,0,RTC_FORMAT_FLOAT,mesh->vertex_crease_weights.data(),0,sizeof(float), mesh->vertex_crease_weights.size()); - if (mesh->holes.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_HOLE,0,RTC_FORMAT_UINT,mesh->holes.data(),0,sizeof(int),mesh->holes.size()); - rtcSetGeometryTessellationRate(geom,mesh->tessellationRate); - rtcSetGeometrySubdivisionMode(geom,0,mesh->position_subdiv_mode); + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_FACE, 0,RTC_FORMAT_UINT,mesh4->verticesPerFace.data(),0,sizeof(int), mesh4->verticesPerFace.size()); + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT,mesh4->position_indices.data(),0,sizeof(int), mesh4->position_indices.size()); + for (unsigned int t=0; tnumTimeSteps(); t++) + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT3,mesh4->positions[t].data(),0,sizeof(SceneGraph::SubdivMeshNode::Vertex), mesh4->positions[t].size()); + if (mesh4->edge_creases.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_EDGE_CREASE_INDEX,0,RTC_FORMAT_UINT2,mesh4->edge_creases.data(),0,2*sizeof(int), mesh4->edge_creases.size()); + if (mesh4->edge_crease_weights.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_EDGE_CREASE_WEIGHT,0,RTC_FORMAT_FLOAT,mesh4->edge_crease_weights.data(),0,sizeof(float),mesh4->edge_crease_weights.size()); + if (mesh4->vertex_creases.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX_CREASE_INDEX,0,RTC_FORMAT_UINT,mesh4->vertex_creases.data(),0,sizeof(int), mesh4->vertex_creases.size()); + if (mesh4->vertex_crease_weights.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX_CREASE_WEIGHT,0,RTC_FORMAT_FLOAT,mesh4->vertex_crease_weights.data(),0,sizeof(float), mesh4->vertex_crease_weights.size()); + if (mesh4->holes.size()) rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_HOLE,0,RTC_FORMAT_UINT,mesh4->holes.data(),0,sizeof(int),mesh4->holes.size()); + rtcSetGeometryTessellationRate(geom,mesh4->tessellationRate); + rtcSetGeometrySubdivisionMode(geom,0,mesh4->position_subdiv_mode); AssertNoError(device); rtcCommitGeometry(geom); unsigned int geomID = rtcAttachGeometry(scene,geom); rtcReleaseGeometry(geom); return geomID; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh5 = node.dynamicCast()) { - RTCGeometry geom = rtcNewGeometry (device, mesh->type); + RTCGeometry geom = rtcNewGeometry (device, mesh5->type); AssertNoError(device); - rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh->numTimeSteps()); + rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh5->numTimeSteps()); rtcSetGeometryBuildQuality(geom,quality); AssertNoError(device); - for (unsigned int t=0; tnumTimeSteps(); t++) - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT4,mesh->positions[t].data(),0,sizeof(SceneGraph::HairSetNode::Vertex), mesh->positions[t].size()); - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT,mesh->hairs.data(),0,sizeof(SceneGraph::HairSetNode::Hair), mesh->hairs.size()); + for (unsigned int t=0; tnumTimeSteps(); t++) + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT4,mesh5->positions[t].data(),0,sizeof(SceneGraph::HairSetNode::Vertex), mesh5->positions[t].size()); + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT,mesh5->hairs.data(),0,sizeof(SceneGraph::HairSetNode::Hair), mesh5->hairs.size()); AssertNoError(device); rtcCommitGeometry(geom); unsigned int geomID = rtcAttachGeometry(scene,geom); rtcReleaseGeometry(geom); return geomID; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh6 = node.dynamicCast()) { - RTCGeometry geom = rtcNewGeometry (device, mesh->type); + RTCGeometry geom = rtcNewGeometry (device, mesh6->type); AssertNoError(device); - rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh->numTimeSteps()); + rtcSetGeometryTimeStepCount(geom, (unsigned int)mesh6->numTimeSteps()); rtcSetGeometryBuildQuality(geom,quality); AssertNoError(device); - for (unsigned int t=0; tnumTimeSteps(); t++) { - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT4,mesh->positions[t].data(),0,sizeof(SceneGraph::PointSetNode::Vertex), mesh->positions[t].size()); - if (mesh->normals.size()) - rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_NORMAL,t,RTC_FORMAT_FLOAT3,mesh->normals[t].data(),0,sizeof(SceneGraph::PointSetNode::Vertex), mesh->normals[t].size()); + for (unsigned int t=0; tnumTimeSteps(); t++) { + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,t,RTC_FORMAT_FLOAT4,mesh6->positions[t].data(),0,sizeof(SceneGraph::PointSetNode::Vertex), mesh6->positions[t].size()); + if (mesh6->normals.size()) + rtcSetSharedGeometryBuffer(geom,RTC_BUFFER_TYPE_NORMAL,t,RTC_FORMAT_FLOAT3,mesh6->normals[t].data(),0,sizeof(SceneGraph::PointSetNode::Vertex), mesh6->normals[t].size()); } AssertNoError(device); rtcCommitGeometry(geom); @@ -276,21 +276,21 @@ namespace embree rtcReleaseGeometry(geom); return geomID; } - else if (Ref mesh = node.dynamicCast()) + else if (Ref mesh7 = node.dynamicCast()) { VerifyScene exemplar(device, flags); - exemplar.addGeometry(quality, mesh->child); + exemplar.addGeometry(quality, mesh7->child); rtcCommitScene(exemplar); RTCGeometry geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_INSTANCE); rtcSetGeometryInstancedScene(geom, exemplar); - rtcSetGeometryTimeStepCount(geom, (unsigned) mesh->spaces.size()); - for (size_t i = 0; i < mesh->spaces.size(); ++i) + rtcSetGeometryTimeStepCount(geom, (unsigned) mesh7->spaces.size()); + for (size_t i = 0; i < mesh7->spaces.size(); ++i) { rtcSetGeometryTransform(geom, (unsigned)i, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, - reinterpret_cast(&mesh->spaces[i])); + reinterpret_cast(&mesh7->spaces[i])); } rtcCommitGeometry(geom); unsigned int geomID = rtcAttachGeometry(scene, geom); @@ -383,17 +383,17 @@ namespace embree { rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT3,mesh->triangles.data(),0,sizeof(SceneGraph::TriangleMeshNode::Triangle), RandomSampler_getInt(sampler) % (mesh->triangles.size()+1)); } - else if (Ref mesh = geom.second.dynamicCast()) + else if (Ref quad_mesh = geom.second.dynamicCast()) { - rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT4,mesh->quads.data(),0,sizeof(SceneGraph::QuadMeshNode::Quad), RandomSampler_getInt(sampler) % (mesh->quads.size()+1)); + rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT4,quad_mesh->quads.data(),0,sizeof(SceneGraph::QuadMeshNode::Quad), RandomSampler_getInt(sampler) % (quad_mesh->quads.size()+1)); } - else if (Ref mesh = geom.second.dynamicCast()) + else if (Ref subdiv_mesh = geom.second.dynamicCast()) { - rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_FACE,0,RTC_FORMAT_UINT,mesh->verticesPerFace.data(), 0,sizeof(int), RandomSampler_getInt(sampler) % (mesh->verticesPerFace.size()+1)); + rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_FACE,0,RTC_FORMAT_UINT,subdiv_mesh->verticesPerFace.data(), 0,sizeof(int), RandomSampler_getInt(sampler) % (subdiv_mesh->verticesPerFace.size()+1)); } - else if (Ref mesh = geom.second.dynamicCast()) + else if (Ref hair_mesh = geom.second.dynamicCast()) { - rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT,mesh->hairs.data(),0,sizeof(SceneGraph::HairSetNode::Hair), RandomSampler_getInt(sampler) % (mesh->hairs.size()+1)); + rtcSetSharedGeometryBuffer(rtcGetGeometry(scene,geom.first),RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT,hair_mesh->hairs.data(),0,sizeof(SceneGraph::HairSetNode::Hair), RandomSampler_getInt(sampler) % (hair_mesh->hairs.size()+1)); } } @@ -1535,7 +1535,7 @@ namespace embree VerifyScene scene(device,sflags); AssertNoError(device); unsigned int geom[128]; - for (size_t i=0; i<128; i++) geom[i] = -1; + for (size_t i=0; i<128; i++) geom[i] = RTC_INVALID_GEOMETRY_ID; Sphere spheres[128]; memset(spheres,0,sizeof(spheres)); @@ -1544,18 +1544,18 @@ namespace embree for (size_t j=0; j<10; j++) { int index = random_int()%128; Vec3fa pos = 100.0f*random_Vec3fa(); - if (geom[index] == -1) { + if (geom[index] == RTC_INVALID_GEOMETRY_ID) { switch (random_int()%11) { case 0: geom[index] = scene.addSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10).first; break; - case 1: geom[index] = scene.addSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10,-1,random_motion_vector(1.0f)).first; break; + case 1: geom[index] = scene.addSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10,(size_t)-1,random_motion_vector(1.0f)).first; break; case 2: geom[index] = scene.addQuadSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10).first; break; - case 3: geom[index] = scene.addQuadSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10,-1,random_motion_vector(1.0f)).first; break; + case 3: geom[index] = scene.addQuadSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10,(size_t)-1,random_motion_vector(1.0f)).first; break; case 4: geom[index] = scene.addGridSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10).first; break; - case 5: geom[index] = scene.addGridSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10,-1,random_motion_vector(1.0f)).first; break; + case 5: geom[index] = scene.addGridSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,10,(size_t)-1,random_motion_vector(1.0f)).first; break; case 6: geom[index] = scene.addHair(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,1.0f,2.0f,10).first; break; case 7: geom[index] = scene.addHair(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,1.0f,2.0f,10,random_motion_vector(1.0f)).first; break; case 8: geom[index] = scene.addSubdivSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,4,4).first; break; - case 9: geom[index] = scene.addSubdivSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,4,4,-1,random_motion_vector(1.0f)).first; break; + case 9: geom[index] = scene.addSubdivSphere(sampler,RTC_BUILD_QUALITY_MEDIUM,pos,2.0f,4,4,(size_t)-1,random_motion_vector(1.0f)).first; break; case 10: spheres[index] = Sphere(pos,2.0f); geom[index] = scene.addUserGeometryEmpty(sampler,RTC_BUILD_QUALITY_MEDIUM,&spheres[index]).first; break; @@ -1565,7 +1565,7 @@ namespace embree else { rtcDetachGeometry(scene,geom[index]); AssertNoError(device); - geom[index] = -1; + geom[index] = RTC_INVALID_GEOMETRY_ID; } } rtcCommitScene(scene); @@ -1577,7 +1577,7 @@ namespace embree /* now delete all geometries */ for (size_t i=0; i<128; i++) - if (geom[i] != -1) rtcDetachGeometry(scene,geom[i]); + if (geom[i] != RTC_INVALID_GEOMETRY_ID) rtcDetachGeometry(scene,geom[i]); rtcCommitScene(scene); AssertNoError(device); @@ -1893,15 +1893,15 @@ namespace embree const unsigned int maxRays = 100; RTCRayHit rays[maxRays]; for (unsigned int numRays=1; numRays= 0.f); + assert(rays0[j].ray.time <= 1.f); + assert(rays0[j].ray.time >= 0.f); } IntersectWithMode(imode,ivariant,tl_instance_array_scene,rays0,num_rays,&args0); IntersectWithMode(imode,ivariant,tl_instance_scene, rays1,num_rays,&args1); - for (int i = 0; i < num_rays; ++i) { - RTCRayHit& ray0 = rays0[i]; - RTCRayHit& ray1 = rays1[i]; + for (int j = 0; j < num_rays; ++j) { + RTCRayHit& ray0 = rays0[j]; + RTCRayHit& ray1 = rays1[j]; // TODO: reenable this when accuracy problem of instancing vs // instance arrays with >= AVX2 is fixed. - //passed &= (ctx0.numHits[i] == ctx1.numHits[i]); + //passed &= (ctx0.numHits[j] == ctx1.numHits[j]); if (ray0.hit.instID[0] != RTC_INVALID_GEOMETRY_ID) { assert(ray0.hit.instPrimID[0] != RTC_INVALID_GEOMETRY_ID); // TODO: reenable this when accuracy problem of instancing vs @@ -3653,7 +3653,7 @@ namespace embree size_t numTests = 0; size_t numFailures = 0; - for (auto ivariant : state->intersectVariants) + for (auto cur_ivariant : state->intersectVariants) for (size_t i=0; iintensity); i++) { for (unsigned int M=1; MintersectVariants) - IntersectVariant ivariant = VARIANT_INTERSECT_INCOHERENT; + IntersectVariant fixed_ivariant = VARIANT_INTERSECT_INCOHERENT; size_t numRays = size_t(N*state->intensity); for (size_t i=0; iintersectVariants) + for (auto cur_ivariant : state->intersectVariants) for (size_t i=0; iintensity); i++) { for (unsigned int M=1; Mdevice, RTC_DEVICE_PROPERTY_USER_GEOMETRY_SUPPORTED)) { @@ -5111,7 +5111,7 @@ namespace embree quality[index] = RTC_BUILD_QUALITY_REFIT; break; } - [[fallthrough]]; + /* falls through */ case 20: if (rtcGetDeviceProperty(thread->device, RTC_DEVICE_PROPERTY_USER_GEOMETRY_SUPPORTED)) { @@ -5120,7 +5120,7 @@ namespace embree quality[index] = RTC_BUILD_QUALITY_LOW; break; } - [[fallthrough]]; + /* falls through */ case 24: geom[index] = task->scene->addHair(task->sampler, RTC_BUILD_QUALITY_MEDIUM, pos, 1.0f, 2.0f, numTriangles); quality[index] = RTC_BUILD_QUALITY_MEDIUM; @@ -5205,14 +5205,14 @@ namespace embree case 26: break; // does not work for hair for some reason default: - RTCGeometry hgeom = rtcGetGeometry(*task->scene, geom[index].first); - Vec3fa *vertices = (Vec3fa *)rtcGetGeometryBufferData(hgeom, RTC_BUFFER_TYPE_VERTEX, 0); - if (vertices) + RTCGeometry base_hgeom = rtcGetGeometry(*task->scene, geom[index].first); + Vec3fa *base_vertices = (Vec3fa *)rtcGetGeometryBufferData(base_hgeom, RTC_BUFFER_TYPE_VERTEX, 0); + if (base_vertices) { - for (size_t i = 0; i < numVertices[index]; i++) - vertices[i] += Vec3fa(0.1f); + for (size_t m = 0; m < numVertices[index]; m++) + base_vertices[m] += Vec3fa(0.1f); } - rtcUpdateGeometryBuffer(hgeom, RTC_BUFFER_TYPE_VERTEX, 0); + rtcUpdateGeometryBuffer(base_hgeom, RTC_BUFFER_TYPE_VERTEX, 0); switch (types[index]) { @@ -5220,16 +5220,16 @@ namespace embree case 5: case 10: case 11: - RTCGeometry hgeom = rtcGetGeometry(*task->scene, geom[index].first); - Vec3fa *vertices = (Vec3fa *)rtcGetGeometryBufferData(hgeom, RTC_BUFFER_TYPE_VERTEX, 1); - if (vertices) + RTCGeometry motion_hgeom = rtcGetGeometry(*task->scene, geom[index].first); + Vec3fa *motion_vertices = (Vec3fa *)rtcGetGeometryBufferData(motion_hgeom, RTC_BUFFER_TYPE_VERTEX, 1); + if (motion_vertices) { - for (size_t i = 0; i < numVertices[index]; i++) - vertices[i] += Vec3fa(0.1f); + for (size_t k = 0; k < numVertices[index]; k++) + motion_vertices[k] += Vec3fa(0.1f); } - rtcUpdateGeometryBuffer(hgeom, RTC_BUFFER_TYPE_VERTEX, 1); + rtcUpdateGeometryBuffer(motion_hgeom, RTC_BUFFER_TYPE_VERTEX, 1); } - rtcCommitGeometry(hgeom); + rtcCommitGeometry(base_hgeom); break; } break; @@ -5777,9 +5777,9 @@ namespace embree CoherentRaysBenchmark (std::string name, int isa, GeometryType gtype, SceneFlags sflags, RTCBuildQuality quality, IntersectMode imode, IntersectVariant ivariant, size_t numPhi) : ParallelIntersectBenchmark(name,isa,numTilesX*numTilesY,1), gtype(gtype), sflags(sflags), quality(quality), imode(imode), ivariant(ivariant), numPhi(numPhi) {} - size_t setNumPrimitives(size_t N) + size_t setNumPrimitives(size_t numPrims) { - numPhi = size_t(ceilf(sqrtf(N/4.0f))); + numPhi = size_t(ceilf(sqrtf(numPrims/4.0f))); return 4*numPhi*numPhi; } @@ -5939,9 +5939,9 @@ namespace embree IncoherentRaysBenchmark (std::string name, int isa, GeometryType gtype, SceneFlags sflags, RTCBuildQuality quality, IntersectMode imode, IntersectVariant ivariant, size_t numPhi) : ParallelIntersectBenchmark(name,isa,numRays,deltaRays), gtype(gtype), sflags(sflags), quality(quality), imode(imode), ivariant(ivariant), numPhi(numPhi), device(nullptr) {} - size_t setNumPrimitives(size_t N) + size_t setNumPrimitives(size_t numPrims) { - numPhi = size_t(ceilf(sqrtf(N/4.0f))); + numPhi = size_t(ceilf(sqrtf(numPrims/4.0f))); return 4*numPhi*numPhi; } @@ -5987,8 +5987,8 @@ namespace embree args.context = &context; args.flags = ((ivariant & VARIANT_COHERENT_INCOHERENT_MASK) == VARIANT_COHERENT) ? RTC_RAY_QUERY_FLAG_COHERENT : RTC_RAY_QUERY_FLAG_INCOHERENT; - RandomSampler sampler; - RandomSampler_init(sampler, (int)i); + RandomSampler ray_sampler; + RandomSampler_init(ray_sampler, (int)i); switch (imode) { @@ -5996,7 +5996,7 @@ namespace embree { for (size_t j=0; jgeometries; + ISPCGeometry** geometries = td.ispc_scene->geometries; for (int i=0; imaterials[materialID]->type == MATERIAL_OBJ) { - ISPCOBJMaterial* material = (ISPCOBJMaterial*) data.ispc_scene->materials[materialID]; + if (td.ispc_scene->materials[materialID]->type == MATERIAL_OBJ) { + ISPCOBJMaterial* material = (ISPCOBJMaterial*) td.ispc_scene->materials[materialID]; color = Vec3fa(material->Kd); } diff --git a/tutorials/viewer/viewer_device_debug.cpp b/tutorials/viewer/viewer_device_debug.cpp index a33cfe7a53..e5ae1e3ddb 100644 --- a/tutorials/viewer/viewer_device_debug.cpp +++ b/tutorials/viewer/viewer_device_debug.cpp @@ -221,7 +221,7 @@ Vec3fa renderPixelDebugShader(const DebugShaderData& data, float x, float y, con ray.tfar = inf; ray.geomID = RTC_INVALID_GEOMETRY_ID; ray.primID = RTC_INVALID_GEOMETRY_ID; - ray.mask = -1; + ray.mask = 0xFFFFFFFFu; ray.time() = data.debug; /* intersect ray with scene */ @@ -328,7 +328,7 @@ Vec3fa renderPixelAOShader(const DebugShaderData& data, float x, float y, const ray.tfar = inf; ray.geomID = RTC_INVALID_GEOMETRY_ID; ray.primID = RTC_INVALID_GEOMETRY_ID; - ray.mask = -1; + ray.mask = 0xFFFFFFFFu; ray.time() = data.debug; /* intersect ray with scene */ @@ -366,14 +366,14 @@ Vec3fa renderPixelAOShader(const DebugShaderData& data, float x, float y, const shadow.tfar = inf; shadow.geomID = RTC_INVALID_GEOMETRY_ID; shadow.primID = RTC_INVALID_GEOMETRY_ID; - shadow.mask = -1; + shadow.mask = 0xFFFFFFFFu; shadow.time() = data.debug; /* trace shadow ray */ - RTCOccludedArguments args; - rtcInitOccludedArguments(&args); - args.feature_mask = feature_mask; - rtcTraversableOccluded1(data.traversable,RTCRay_(shadow),&args); + RTCOccludedArguments occ_args; + rtcInitOccludedArguments(&occ_args); + occ_args.feature_mask = feature_mask; + rtcTraversableOccluded1(data.traversable,RTCRay_(shadow),&occ_args); RayStats_addShadowRay(stats); /* add light contribution */ diff --git a/tutorials/voronoi/voronoi_device.cpp b/tutorials/voronoi/voronoi_device.cpp index 8f00b2cad3..30a7a60c7b 100644 --- a/tutorials/voronoi/voronoi_device.cpp +++ b/tutorials/voronoi/voronoi_device.cpp @@ -119,34 +119,34 @@ void knnQuery(Vec3f const& q, float radius, KNNResult* result) rtcPointQuery(data.scene, &query, &context, pointQueryFunc, (void*)result); } -void createPoints (TutorialData& data) +void createPoints (TutorialData& td) { RTCGeometry geom = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_USER); - data.points = (Point*) alignedMalloc(data.num_points*sizeof(Point), 16); - data.points_tmp = (Point*) alignedMalloc(data.num_points*sizeof(Point), 16); - unsigned int geomID = rtcAttachGeometry(data.scene, geom); - for (int i=0; i Date: Tue, 16 Jun 2026 18:50:54 +0200 Subject: [PATCH 09/19] Fix dpcpp.cmake to recognise icx-cl as the ICX compiler on Windows The SYCL_ONEAPI_ICX detection checked for 'icx' and 'icpx' but not for 'icx-cl', the MSVC-compatibility-mode variant of the ICX compiler used when building with Ninja/CMake on Windows. Without this match the cmake logic fell through to the Linux/Clang flag path, injecting flags such as -std=c++17, -fvisibility=hidden and -ffp-model=precise that icx-cl rejects with -Werror,-Wunknown-argument errors. Add 'icx-cl' to the SYCL_ONEAPI_ICX name check so the correct Windows ICX flag set is selected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/cmake/dpcpp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cmake/dpcpp.cmake b/common/cmake/dpcpp.cmake index 43a98d3fb6..b03b4f9d0a 100644 --- a/common/cmake/dpcpp.cmake +++ b/common/cmake/dpcpp.cmake @@ -24,7 +24,7 @@ GET_FILENAME_COMPONENT(SYCL_COMPILER_DIR ${CMAKE_CXX_COMPILER} PATH) GET_FILENAME_COMPONENT(SYCL_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME_WE) IF (NOT SYCL_COMPILER_NAME STREQUAL "clang++") SET(SYCL_ONEAPI TRUE) - IF (SYCL_COMPILER_NAME STREQUAL "icx" OR SYCL_COMPILER_NAME STREQUAL "icpx") + IF (SYCL_COMPILER_NAME STREQUAL "icx" OR SYCL_COMPILER_NAME STREQUAL "icpx" OR SYCL_COMPILER_NAME STREQUAL "icx-cl") SET(SYCL_ONEAPI_ICX TRUE) ELSE() SET(SYCL_ONEAPI_ICX FALSE) From eecccf30450f855e1dec685485629127cfdd93ab Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 16 Jun 2026 18:51:13 +0200 Subject: [PATCH 10/19] Fix SYCL/ICX warnings in tutorial SYCL device code Three classes of warning fixed, all from the ICX SYCL device compiler: 1. [-Wundefined-internal] sycl::detail::get_spec_constant_symbolic_ID has internal linkage but is not defined. 'const' variables at C++ namespace scope have *internal* linkage by default (same as 'static const'). The SYCL compiler generates a per-variable helper function with matching linkage; when that linkage is internal the function has no definition visible to the SYCL runtime and the warning fires. Fix: declare all sycl::specialization_id objects as 'inline const'. C++17 inline variables have external linkage, so the compiler emits one uniquely-identifiable definition. viewer_device_debug.cpp re-declares the same spec_feature_mask as inline const; the ODR rule merges it with viewer_device.cpp's definition at link time. Files changed: viewer_device.cpp, viewer_device_debug.cpp, next_hit_device.cpp, pathtracer_device.cpp 2. [-Wuninitialized-const-pointer] imgui_widgets.cpp: 'empty_string' passed as a const-pointer before being initialised. Fix: zero-initialise the STB_TEXTEDIT_CHARTYPE variable at the point of declaration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tutorials/common/imgui/imgui_widgets.cpp | 2 +- tutorials/next_hit/next_hit_device.cpp | 2 +- tutorials/pathtracer/pathtracer_device.cpp | 2 +- tutorials/viewer/viewer_device.cpp | 2 +- tutorials/viewer/viewer_device_debug.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorials/common/imgui/imgui_widgets.cpp b/tutorials/common/imgui/imgui_widgets.cpp index 5095fca0f9..080cb0a655 100644 --- a/tutorials/common/imgui/imgui_widgets.cpp +++ b/tutorials/common/imgui/imgui_widgets.cpp @@ -4439,7 +4439,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ // Clear input apply_new_text = ""; apply_new_text_length = 0; - STB_TEXTEDIT_CHARTYPE empty_string; + STB_TEXTEDIT_CHARTYPE empty_string = 0; stb_textedit_replace(state, &state->Stb, &empty_string, 0); } else if (strcmp(buf, state->InitialTextA.Data) != 0) diff --git a/tutorials/next_hit/next_hit_device.cpp b/tutorials/next_hit/next_hit_device.cpp index 00cab66ccd..cce78a8534 100644 --- a/tutorials/next_hit/next_hit_device.cpp +++ b/tutorials/next_hit/next_hit_device.cpp @@ -17,7 +17,7 @@ RTCScene g_scene = nullptr; TutorialData data; #if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION) && defined(USE_SPECIALIZATION_CONSTANTS) -static const sycl::specialization_id spec_feature_mask; +inline const sycl::specialization_id spec_feature_mask; #endif RTCFeatureFlags g_feature_mask; diff --git a/tutorials/pathtracer/pathtracer_device.cpp b/tutorials/pathtracer/pathtracer_device.cpp index 33e18d8f91..9a2fb8fc51 100644 --- a/tutorials/pathtracer/pathtracer_device.cpp +++ b/tutorials/pathtracer/pathtracer_device.cpp @@ -39,7 +39,7 @@ bool g_subdiv_mode = false; unsigned int keyframeID = 0; #if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION) && defined(USE_SPECIALIZATION_CONSTANTS) -const static sycl::specialization_id rtc_feature_mask(RTC_FEATURE_FLAG_ALL); +inline const sycl::specialization_id rtc_feature_mask(RTC_FEATURE_FLAG_ALL); #endif RTCFeatureFlags g_used_features = RTC_FEATURE_FLAG_NONE; diff --git a/tutorials/viewer/viewer_device.cpp b/tutorials/viewer/viewer_device.cpp index 6253a91f9a..b41848b95b 100644 --- a/tutorials/viewer/viewer_device.cpp +++ b/tutorials/viewer/viewer_device.cpp @@ -10,7 +10,7 @@ extern "C" bool g_changed; TutorialData data; #if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION) && defined(USE_SPECIALIZATION_CONSTANTS) -const sycl::specialization_id spec_feature_mask; +inline const sycl::specialization_id spec_feature_mask; #endif extern "C" RTCFeatureFlags g_feature_mask; diff --git a/tutorials/viewer/viewer_device_debug.cpp b/tutorials/viewer/viewer_device_debug.cpp index e5ae1e3ddb..0168229033 100644 --- a/tutorials/viewer/viewer_device_debug.cpp +++ b/tutorials/viewer/viewer_device_debug.cpp @@ -19,7 +19,7 @@ extern "C" bool g_changed; extern "C" float g_debug; #if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION) -static const sycl::specialization_id spec_feature_mask; +inline const sycl::specialization_id spec_feature_mask; #endif extern "C" RTCFeatureFlags g_feature_mask; From 7376304576a3d954c9e3877f47ae5247a362198b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Jun 2026 10:35:00 +0000 Subject: [PATCH 11/19] Fix -Warith-conversion incompatibility with GCC < 10 on Rocky Linux 8 --- common/cmake/gnu.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/cmake/gnu.cmake b/common/cmake/gnu.cmake index 664cd43375..86c5323b4f 100644 --- a/common/cmake/gnu.cmake +++ b/common/cmake/gnu.cmake @@ -48,7 +48,9 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrestrict") # warn abo SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshift-overflow=2") # warn about undefined shift behavior SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Walloc-size-larger-than=9223372036854775807") # warn about allocation exceeding max object size SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstringop-overflow") # warn about buffer overflow in string operations -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Warith-conversion") # warn about implicit arithmetic conversions +IF (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Warith-conversion") # warn about implicit arithmetic conversions (GCC 10+) +ENDIF() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-align") # disable: intentional aligned loads in SIMD code SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-declarations") # disable: intentional factory pattern without declarations SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow") # disable: pervasive in vector class constructors From ebcf1c9f9e6a9bb8c45bcd4841e2e562b8dc9d26 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 09:35:20 +0200 Subject: [PATCH 12/19] Fix shift-overflow warning for CPU_FEATURE_BIT_AVX512VL Use (int)(1u << 31) instead of 1 << 31 to avoid -Werror=shift-overflow= when shifting into the sign bit of a signed int. Keeps the constant type consistent with all other CPU_FEATURE_BIT_* constants. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/sys/sysinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/sys/sysinfo.cpp b/common/sys/sysinfo.cpp index c564bb11bd..c41bc36e56 100644 --- a/common/sys/sysinfo.cpp +++ b/common/sys/sysinfo.cpp @@ -248,7 +248,7 @@ namespace embree static const int CPU_FEATURE_BIT_AVX512ER = 1 << 27; // AVX512ER (exponential and reciprocal instructions) static const int CPU_FEATURE_BIT_AVX512CD = 1 << 28; // AVX512CD (conflict detection instructions) static const int CPU_FEATURE_BIT_AVX512BW = 1 << 30; // AVX512BW (byte and word instructions) - static const int CPU_FEATURE_BIT_AVX512VL = 1 << 31; // AVX512VL (vector length extensions) + static const int CPU_FEATURE_BIT_AVX512VL = (int)(1u << 31); // AVX512VL (vector length extensions) static const int CPU_FEATURE_BIT_AVX512IFMA = 1 << 21; // AVX512IFMA (integer fused multiple-add instructions) /* cpuid[eax=7,ecx=0].ecx */ From 76e9f86257dc7fc1e6dbd0982491db688d54e9ed Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 09:48:34 +0200 Subject: [PATCH 13/19] Fix fill() using stale member vertices instead of locals The PR renamed locals v0/v1/v2 to lv0/lv1/lv2 to fix shadowing warnings, but forgot to update the store_nt() call in fill(), causing it to pass the stale member vectors instead of the newly loaded triangle vertices. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- kernels/geometry/trianglev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernels/geometry/trianglev.h b/kernels/geometry/trianglev.h index 2c5a4301e9..659af208a5 100644 --- a/kernels/geometry/trianglev.h +++ b/kernels/geometry/trianglev.h @@ -111,7 +111,7 @@ namespace embree lv1.x[i] = p1.x; lv1.y[i] = p1.y; lv1.z[i] = p1.z; lv2.x[i] = p2.x; lv2.y[i] = p2.y; lv2.z[i] = p2.z; } - TriangleMv::store_nt(this,TriangleMv(v0,v1,v2,vgeomID,vprimID)); + TriangleMv::store_nt(this,TriangleMv(lv0,lv1,lv2,vgeomID,vprimID)); } /* Updates the primitive */ From f3c3de5b6ea47580b69f62e9268d1cbd1f12b1aa Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 09:50:31 +0200 Subject: [PATCH 14/19] Fix update() in quadv.h using member v3 instead of local lv3 update() declared locals lv0/lv1/lv2 but used the member v3 directly, leaving stale data in unused lanes and being inconsistent with the other vertex vectors. Add a zero-initialized local lv3 and pass it into the placement-new, matching the pattern used by fill() and by trianglev.h. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- kernels/geometry/quadv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernels/geometry/quadv.h b/kernels/geometry/quadv.h index 190f1ed6b7..1ec6b855d9 100644 --- a/kernels/geometry/quadv.h +++ b/kernels/geometry/quadv.h @@ -124,7 +124,7 @@ namespace embree { BBox3fa bounds = empty; vuint vgeomID = (unsigned int)-1, vprimID = (unsigned int)-1; - Vec3vf lv0 = zero, lv1 = zero, lv2 = zero; + Vec3vf lv0 = zero, lv1 = zero, lv2 = zero, lv3 = zero; for (size_t i=0; i Date: Wed, 17 Jun 2026 09:51:46 +0200 Subject: [PATCH 15/19] Fix imgui CMakeLists: always apply FLAGS_LOWEST, gate warning flag to Clang The previous change stopped applying FLAGS_LOWEST on MSVC and passed -Wno-uninitialized-const-pointer to all non-MSVC compilers including GCC, which may not support that flag. Restore the unconditional FLAGS_LOWEST (matching master) and gate the Clang-specific warning suppression behind a Clang compiler check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tutorials/common/imgui/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tutorials/common/imgui/CMakeLists.txt b/tutorials/common/imgui/CMakeLists.txt index 9fd0c42d1e..3b5dc685a6 100644 --- a/tutorials/common/imgui/CMakeLists.txt +++ b/tutorials/common/imgui/CMakeLists.txt @@ -13,8 +13,9 @@ ADD_LIBRARY(imgui STATIC TARGET_INCLUDE_DIRECTORIES(imgui PUBLIC . ./backends) TARGET_LINK_LIBRARIES(imgui glfw) SET_PROPERTY(TARGET imgui PROPERTY FOLDER tutorials/common) -IF(NOT MSVC) - SET_PROPERTY(TARGET imgui APPEND PROPERTY COMPILE_FLAGS " ${FLAGS_LOWEST} -Wno-uninitialized-const-pointer") +SET_PROPERTY(TARGET imgui APPEND PROPERTY COMPILE_FLAGS " ${FLAGS_LOWEST}") +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET_PROPERTY(TARGET imgui APPEND PROPERTY COMPILE_FLAGS " -Wno-uninitialized-const-pointer") ENDIF() TARGET_COMPILE_DEFINITIONS(imgui PUBLIC IMGUI_DISABLE_SSE) From ffbec7a4a0c6bade0102c56bd99a5ea18c62229b Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 10:13:08 +0200 Subject: [PATCH 16/19] Fix sign-compare warning in user_geometry_device.cpp Comparing ray.instID[0] (unsigned) to -1 triggers -Wsign-compare. Use RTC_INVALID_GEOMETRY_ID consistently, matching the check on line 775. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tutorials/user_geometry/user_geometry_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/user_geometry/user_geometry_device.cpp b/tutorials/user_geometry/user_geometry_device.cpp index d0ba8f2df5..8f9ac6d5c9 100644 --- a/tutorials/user_geometry/user_geometry_device.cpp +++ b/tutorials/user_geometry/user_geometry_device.cpp @@ -780,7 +780,7 @@ Vec3fa renderPixelStandard(const TutorialData& td, /* calculate diffuse color of geometries */ Vec3fa diffuse = Vec3fa(0.0f); if (ray.instID[0] == 0) diffuse = td.colors[4*ray.instID[0]+ray.primID]; - else if (ray.instID[0] == -1) diffuse = td.colors[4*4+ray.primID]; + else if (ray.instID[0] == RTC_INVALID_GEOMETRY_ID) diffuse = td.colors[4*4+ray.primID]; else diffuse = td.colors[4*ray.instID[0]+ray.geomID]; color = color + diffuse*0.5f; From bd8ae3bf35b303dd5ee73a2525c4b06a70c4f9fa Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 11:57:29 +0200 Subject: [PATCH 17/19] Fix -Wundefined-internal in minimal_sycl.cpp 'const' variables at namespace scope have internal linkage by default. The SYCL compiler generates get_spec_constant_symbolic_ID with matching linkage, causing [-Wundefined-internal] when -Werror is set. Fix: declare feature_mask as 'inline const', giving it external linkage so the compiler emits a single visible definition. Same fix already applied to viewer_device.cpp, viewer_device_debug.cpp, next_hit_device.cpp, and pathtracer_device.cpp in eecccf304. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tutorials/minimal/minimal_sycl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/minimal/minimal_sycl.cpp b/tutorials/minimal/minimal_sycl.cpp index f15eb33f4f..af2e2d5294 100644 --- a/tutorials/minimal/minimal_sycl.cpp +++ b/tutorials/minimal/minimal_sycl.cpp @@ -29,7 +29,7 @@ RTC_NAMESPACE_USE #endif -const sycl::specialization_id feature_mask; +inline const sycl::specialization_id feature_mask; const RTCFeatureFlags required_features = RTC_FEATURE_FLAG_TRIANGLE; struct Result { From 0aaac5abdd654859eeb7307955d2ba71a6a02c30 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 12:18:38 +0200 Subject: [PATCH 18/19] Fix -Wdeprecated-declarations from SYCL runtime headers in device pass The SYCL compiler runs a separate device-side compilation pass that re-includes headers without any of the host-side pragma guards. sycl/access/access.hpp uses constant_space internally and warns about its own deprecated usage during this pass. The pragma in tutorials/common/device_default.h already suppresses this for the host pass when including sycl.hpp, but it has no effect on the device pass. Fix by adding -Wno-deprecated-declarations to CMAKE_CXX_FLAGS_SYCL so the suppression applies to both passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/cmake/dpcpp.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/common/cmake/dpcpp.cmake b/common/cmake/dpcpp.cmake index b03b4f9d0a..acf7b32f4c 100644 --- a/common/cmake/dpcpp.cmake +++ b/common/cmake/dpcpp.cmake @@ -47,6 +47,7 @@ IF (EMBREE_SYCL_SUPPORT) SET(CMAKE_CXX_FLAGS_SYCL "-fsycl -fsycl-unnamed-lambda -Xclang -fsycl-allow-func-ptr") SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -Wno-mismatched-tags -Wno-pessimizing-move -Wno-reorder -Wno-unneeded-internal-declaration -Wno-delete-non-abstract-non-virtual-dtor -Wno-dangling-field -Wno-unknown-pragmas -Wno-logical-op-parentheses") + SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -Wno-deprecated-declarations") # suppress deprecation warnings from SYCL runtime headers in the device pass IF (SYCL_ONEAPI_ICX AND WIN32) SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} /debug:none") # FIXME: debug information generation takes forever in SYCL From 45b4bdf63771dfac645ab3d5b8319922e72cecdf Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 17 Jun 2026 13:03:26 +0200 Subject: [PATCH 19/19] cmake: treat Intel SYCL runtime headers as system headers on Windows Replace -I with -imsvc for Intel oneAPI SYCL include directories on Windows (icx-cl), matching the -isystem flags already used on Linux. This suppresses deprecation warnings emitted by Intel's own SYCL runtime headers (e.g. constant_space in sycl/access/access.hpp) without blanket-suppressing -Wdeprecated-declarations in Embree code. Remove the previously added -Wno-deprecated-declarations workaround. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/cmake/dpcpp.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/cmake/dpcpp.cmake b/common/cmake/dpcpp.cmake index acf7b32f4c..bba48c0684 100644 --- a/common/cmake/dpcpp.cmake +++ b/common/cmake/dpcpp.cmake @@ -47,7 +47,6 @@ IF (EMBREE_SYCL_SUPPORT) SET(CMAKE_CXX_FLAGS_SYCL "-fsycl -fsycl-unnamed-lambda -Xclang -fsycl-allow-func-ptr") SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -Wno-mismatched-tags -Wno-pessimizing-move -Wno-reorder -Wno-unneeded-internal-declaration -Wno-delete-non-abstract-non-virtual-dtor -Wno-dangling-field -Wno-unknown-pragmas -Wno-logical-op-parentheses") - SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -Wno-deprecated-declarations") # suppress deprecation warnings from SYCL runtime headers in the device pass IF (SYCL_ONEAPI_ICX AND WIN32) SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} /debug:none") # FIXME: debug information generation takes forever in SYCL @@ -145,10 +144,19 @@ IF (EMBREE_SYCL_SUPPORT) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pessimizing-move") # disabled: warning: moving a temporary object prevents copy elision [-Wpessimizing-move] IF (SYCL_ONEAPI_ICX AND WIN32) - IF (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 2024.0) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I\"${SYCL_COMPILER_DIR}/../opt/compiler/include/sycl\" -I\"${SYCL_COMPILER_DIR}/../opt/compiler/include/sycl/sycl\"") # disable warning from SYCL header + IF (SYCL_COMPILER_NAME STREQUAL "icx-cl") + # icx-cl is MSVC-compatible: use -imsvc (clang-cl equivalent of -isystem) + IF (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 2024.0) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -imsvc \"${SYCL_COMPILER_DIR}/../opt/compiler/include/sycl\" -imsvc \"${SYCL_COMPILER_DIR}/../opt/compiler/include/sycl/sycl\"") # treat Intel SYCL runtime headers as system headers (suppresses their internal warnings) + ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -imsvc \"${SYCL_COMPILER_DIR}/../include/sycl\" -imsvc \"${SYCL_COMPILER_DIR}/../include/\"") # treat Intel SYCL runtime headers as system headers (suppresses their internal warnings) + ELSE() + # icx/icpx on Windows: GCC-compatible frontend, use -isystem + IF (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 2024.0) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${SYCL_COMPILER_DIR}/../opt/compiler/include/sycl\" -isystem \"${SYCL_COMPILER_DIR}/../opt/compiler/include/sycl/sycl\"") # treat Intel SYCL runtime headers as system headers (suppresses their internal warnings) + ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${SYCL_COMPILER_DIR}/../include/sycl\" -isystem \"${SYCL_COMPILER_DIR}/../include/\"") # treat Intel SYCL runtime headers as system headers (suppresses their internal warnings) ENDIF() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I\"${SYCL_COMPILER_DIR}/../include/sycl\" -I\"${SYCL_COMPILER_DIR}/../include/\"") # disable warning from SYCL header SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qstd=c++17") ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")