From 2c99edbffa9f4b5defe33eb77d96a224d30443e2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 30 Apr 2025 19:50:14 +0200 Subject: [PATCH] Cycles: Bump Embree minimum version to 4.0.0 The build is already failing with Embree 3, as noticed in #137556. And Embree 4 was released 2 years ago. Pull Request: https://projects.blender.org/blender/blender/pulls/138221 --- .../cmake/platform/platform_apple.cmake | 2 +- .../cmake/platform/platform_unix.cmake | 2 +- intern/cycles/bvh/embree.cpp | 41 +-- intern/cycles/bvh/embree.h | 9 +- intern/cycles/device/cpu/device_impl.cpp | 6 +- intern/cycles/device/cpu/device_impl.h | 6 +- intern/cycles/kernel/device/cpu/bvh.h | 242 ++---------------- intern/cycles/kernel/types.h | 9 +- 8 files changed, 33 insertions(+), 284 deletions(-) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 3ae71a26a69..ce01827caf2 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -340,7 +340,7 @@ endif() add_bundled_libraries(osl/lib) if(WITH_CYCLES AND WITH_CYCLES_EMBREE) - find_package(Embree 3.8.0 REQUIRED) + find_package(Embree 4.0.0 REQUIRED) endif() add_bundled_libraries(embree/lib) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 723dd1b7a48..b43a520fd1f 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -518,7 +518,7 @@ endif() add_bundled_libraries(opencolorio/lib) if(WITH_CYCLES AND WITH_CYCLES_EMBREE) - find_package(Embree 3.8.0 REQUIRED) + find_package(Embree 4.0.0 REQUIRED) endif() add_bundled_libraries(embree/lib) diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index 05aff627cf5..2cb8545c678 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -18,11 +18,7 @@ #ifdef WITH_EMBREE -# if EMBREE_MAJOR_VERSION >= 4 -# include -# else -# include -# endif +# include # include "bvh/embree.h" @@ -35,10 +31,6 @@ # include "util/progress.h" # include "util/stats.h" -# if EMBREE_MAJOR_VERSION < 4 -# include "kernel/device/cpu/bvh.h" -# endif - CCL_NAMESPACE_BEGIN static_assert(Object::MAX_MOTION_STEPS <= RTC_MAX_TIME_STEP_COUNT, @@ -136,11 +128,8 @@ void BVHEmbree::build(Progress &progress, scene = rtcNewScene(rtc_device); const RTCSceneFlags scene_flags = (dynamic ? RTC_SCENE_FLAG_DYNAMIC : RTC_SCENE_FLAG_NONE) | (compact ? RTC_SCENE_FLAG_COMPACT : RTC_SCENE_FLAG_NONE) | - RTC_SCENE_FLAG_ROBUST -# if EMBREE_MAJOR_VERSION >= 4 - | RTC_SCENE_FLAG_FILTER_FUNCTION_IN_ARGUMENTS -# endif - ; + RTC_SCENE_FLAG_ROBUST | + RTC_SCENE_FLAG_FILTER_FUNCTION_IN_ARGUMENTS; rtcSetSceneFlags(scene, scene_flags); build_quality = dynamic ? RTC_BUILD_QUALITY_LOW : (params.use_spatial_split ? RTC_BUILD_QUALITY_HIGH : @@ -291,9 +280,7 @@ void BVHEmbree::add_instance(Object *ob, const int i) rtcSetGeometryUserData(geom_id, (void *)instance_bvh->scene); rtcSetGeometryMask(geom_id, ob->visibility_for_tracing()); -# if EMBREE_MAJOR_VERSION >= 4 rtcSetGeometryEnableFilterFunctionFromArguments(geom_id, true); -# endif rtcCommitGeometry(geom_id); rtcAttachGeometryByID(scene, geom_id, i * 2); @@ -350,12 +337,7 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, const int i) rtcSetGeometryUserData(geom_id, (void *)prim_offset); rtcSetGeometryMask(geom_id, ob->visibility_for_tracing()); -# if EMBREE_MAJOR_VERSION >= 4 rtcSetGeometryEnableFilterFunctionFromArguments(geom_id, true); -# else - rtcSetGeometryOccludedFilterFunction(geom_id, kernel_embree_filter_occluded_func); - rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_intersection_func); -# endif rtcCommitGeometry(geom_id); rtcAttachGeometryByID(scene, geom_id, i * 2); @@ -603,12 +585,7 @@ void BVHEmbree::add_points(const Object *ob, const PointCloud *pointcloud, const rtcSetGeometryUserData(geom_id, (void *)prim_offset); rtcSetGeometryMask(geom_id, ob->visibility_for_tracing()); -# if EMBREE_MAJOR_VERSION >= 4 rtcSetGeometryEnableFilterFunctionFromArguments(geom_id, true); -# else - rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_func_backface_cull); - rtcSetGeometryOccludedFilterFunction(geom_id, kernel_embree_filter_occluded_func_backface_cull); -# endif rtcCommitGeometry(geom_id); rtcAttachGeometryByID(scene, geom_id, i * 2); @@ -666,19 +643,7 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, const int i) rtcSetGeometryUserData(geom_id, (void *)prim_offset); rtcSetGeometryMask(geom_id, ob->visibility_for_tracing()); -# if EMBREE_MAJOR_VERSION >= 4 rtcSetGeometryEnableFilterFunctionFromArguments(geom_id, true); -# else - if (hair->curve_shape == CURVE_RIBBON) { - rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_intersection_func); - rtcSetGeometryOccludedFilterFunction(geom_id, kernel_embree_filter_occluded_func); - } - else { - rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_func_backface_cull); - rtcSetGeometryOccludedFilterFunction(geom_id, - kernel_embree_filter_occluded_func_backface_cull); - } -# endif rtcCommitGeometry(geom_id); rtcAttachGeometryByID(scene, geom_id, i * 2 + 1); diff --git a/intern/cycles/bvh/embree.h b/intern/cycles/bvh/embree.h index d26b70ab380..635b726b91b 100644 --- a/intern/cycles/bvh/embree.h +++ b/intern/cycles/bvh/embree.h @@ -6,13 +6,8 @@ #ifdef WITH_EMBREE -# if EMBREE_MAJOR_VERSION >= 4 -# include -# include -# else -# include -# include -# endif +# include +# include # include "bvh/bvh.h" # include "bvh/params.h" diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp index a0705910cfc..72d906aa039 100644 --- a/intern/cycles/device/cpu/device_impl.cpp +++ b/intern/cycles/device/cpu/device_impl.cpp @@ -17,11 +17,7 @@ #endif #ifdef WITH_EMBREE -# if EMBREE_MAJOR_VERSION >= 4 -# include -# else -# include -# endif +# include #endif #include "device/cpu/kernel.h" diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index 92b29f6be25..79772cb9f90 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -14,11 +14,7 @@ #endif #ifdef WITH_EMBREE -# if EMBREE_MAJOR_VERSION >= 4 -# include -# else -# include -# endif +# include #endif #include "device/cpu/kernel.h" diff --git a/intern/cycles/kernel/device/cpu/bvh.h b/intern/cycles/kernel/device/cpu/bvh.h index 5142bb1d8b6..66d04cba868 100644 --- a/intern/cycles/kernel/device/cpu/bvh.h +++ b/intern/cycles/kernel/device/cpu/bvh.h @@ -6,13 +6,9 @@ #pragma once -#if EMBREE_MAJOR_VERSION >= 4 -# include -# include -#else -# include -# include -#endif +#include +#include +#include #ifdef __KERNEL_ONEAPI__ # include "kernel/device/oneapi/compat.h" @@ -50,32 +46,17 @@ using numhit_t = uint32_t; #define EMBREE_IS_HAIR(x) (x & 1) -#if EMBREE_MAJOR_VERSION < 4 -# define rtcGetGeometryUserDataFromScene(scene, id) \ - (rtcGetGeometryUserData(rtcGetGeometry(scene, id))) -#endif - /* Intersection context. */ -struct CCLFirstHitContext -#if EMBREE_MAJOR_VERSION >= 4 - : public RTCRayQueryContext -#endif -{ +struct CCLFirstHitContext : public RTCRayQueryContext { KernelGlobals kg; /* For avoiding self intersections */ const Ray *ray; }; -struct CCLShadowContext -#if EMBREE_MAJOR_VERSION >= 4 - : public RTCRayQueryContext -#endif -{ -#if EMBREE_MAJOR_VERSION >= 4 +struct CCLShadowContext : public RTCRayQueryContext { KernelGlobals kg; const Ray *ray; -#endif IntegratorShadowState isect_s; float throughput; float max_t; @@ -85,72 +66,26 @@ struct CCLShadowContext numhit_t num_recorded_hits; }; -struct CCLLocalContext -#if EMBREE_MAJOR_VERSION >= 4 - : public RTCRayQueryContext -#endif -{ -#if EMBREE_MAJOR_VERSION >= 4 +struct CCLLocalContext : public RTCRayQueryContext { KernelGlobals kg; const Ray *ray; numhit_t max_hits; -#endif int local_object_id; LocalIntersection *local_isect; uint *lcg_state; bool is_sss; }; -struct CCLVolumeContext -#if EMBREE_MAJOR_VERSION >= 4 - : public RTCRayQueryContext -#endif -{ -#if EMBREE_MAJOR_VERSION >= 4 +struct CCLVolumeContext : public RTCRayQueryContext { KernelGlobals kg; const Ray *ray; -# ifdef __VOLUME_RECORD_ALL__ +#ifdef __VOLUME_RECORD_ALL__ numhit_t max_hits; -# endif - numhit_t num_hits; #endif + numhit_t num_hits; Intersection *vol_isect; }; -#if EMBREE_MAJOR_VERSION < 4 -struct CCLIntersectContext : public RTCIntersectContext, - public CCLFirstHitContext, - public CCLShadowContext, - public CCLLocalContext, - public CCLVolumeContext { - enum RayType { - RAY_REGULAR = 0, - RAY_SHADOW_ALL = 1, - RAY_LOCAL = 2, - RAY_SSS = 3, - RAY_VOLUME_ALL = 4, - }; - - RayType type; - - CCLIntersectContext(KernelGlobals kg_, RayType type_) - { - kg = kg_; - type = type_; - ray = nullptr; - max_hits = numhit_t(1); - num_hits = numhit_t(0); - num_recorded_hits = numhit_t(0); - throughput = 1.0f; - opaque_hit = false; - isect_s = nullptr; - local_isect = nullptr; - local_object_id = -1; - lcg_state = nullptr; - } -}; -#endif - /* Utilities. */ ccl_device_inline void kernel_embree_setup_ray(const Ray &ray, @@ -276,11 +211,7 @@ ccl_device_forceinline void kernel_embree_filter_intersection_func_impl( assert(args->N == 1); RTCHit *hit = (RTCHit *)args->hit; -#if EMBREE_MAJOR_VERSION >= 4 CCLFirstHitContext *ctx = (CCLFirstHitContext *)(args->context); -#else - CCLIntersectContext *ctx = (CCLIntersectContext *)(args->context); -#endif #ifdef __KERNEL_ONEAPI__ KernelGlobalsGPU *kg = nullptr; #else @@ -316,11 +247,7 @@ ccl_device_forceinline void kernel_embree_filter_occluded_shadow_all_func_impl( const RTCRay *ray = (RTCRay *)args->ray; RTCHit *hit = (RTCHit *)args->hit; -#if EMBREE_MAJOR_VERSION >= 4 CCLShadowContext *ctx = (CCLShadowContext *)(args->context); -#else - CCLIntersectContext *ctx = (CCLIntersectContext *)(args->context); -#endif #ifdef __KERNEL_ONEAPI__ KernelGlobalsGPU *kg = nullptr; #else @@ -443,11 +370,7 @@ ccl_device_forceinline void kernel_embree_filter_occluded_local_func_impl( const RTCRay *ray = (RTCRay *)args->ray; RTCHit *hit = (RTCHit *)args->hit; -#if EMBREE_MAJOR_VERSION >= 4 CCLLocalContext *ctx = (CCLLocalContext *)(args->context); -#else - CCLIntersectContext *ctx = (CCLIntersectContext *)(args->context); -#endif #ifdef __KERNEL_ONEAPI__ KernelGlobalsGPU *kg = nullptr; #else @@ -546,11 +469,7 @@ ccl_device_forceinline void kernel_embree_filter_occluded_volume_all_func_impl( const RTCRay *ray = (RTCRay *)args->ray; RTCHit *hit = (RTCHit *)args->hit; -#if EMBREE_MAJOR_VERSION >= 4 CCLVolumeContext *ctx = (CCLVolumeContext *)(args->context); -#else - CCLIntersectContext *ctx = (CCLIntersectContext *)(args->context); -#endif #ifdef __KERNEL_ONEAPI__ KernelGlobalsGPU *kg = nullptr; #else @@ -591,78 +510,6 @@ ccl_device_forceinline void kernel_embree_filter_occluded_volume_all_func_impl( #endif } -#if EMBREE_MAJOR_VERSION < 4 -ccl_device_forceinline void kernel_embree_filter_occluded_func( - const RTCFilterFunctionNArguments *args) -{ - /* Current implementation in Cycles assumes only single-ray intersection queries. */ - assert(args->N == 1); - - CCLIntersectContext *ctx = (CCLIntersectContext *)(args->context); - - switch (ctx->type) { - case CCLIntersectContext::RAY_SHADOW_ALL: - kernel_embree_filter_occluded_shadow_all_func_impl(args); - break; - case CCLIntersectContext::RAY_LOCAL: - case CCLIntersectContext::RAY_SSS: - kernel_embree_filter_occluded_local_func_impl(args); - break; - case CCLIntersectContext::RAY_VOLUME_ALL: - kernel_embree_filter_occluded_volume_all_func_impl(args); - break; - - case CCLIntersectContext::RAY_REGULAR: - default: - /* We should never reach this point, because - * REGULAR intersection is handled in intersection filter. */ - kernel_assert(false); - break; - } -} - -ccl_device void kernel_embree_filter_func_backface_cull(const RTCFilterFunctionNArguments *args) -{ - const RTCRay *ray = (RTCRay *)args->ray; - RTCHit *hit = (RTCHit *)args->hit; - - /* Always ignore back-facing intersections. */ - if (dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z), - make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) - { - *args->valid = 0; - return; - } - - CCLIntersectContext *ctx = ((CCLIntersectContext *)args->context); - const ThreadKernelGlobalsCPU *kg = ctx->kg; - const Ray *cray = ctx->ray; - - if (kernel_embree_is_self_intersection( - kg, hit, cray, reinterpret_cast(args->geometryUserPtr))) - { - *args->valid = 0; - } -} - -ccl_device void kernel_embree_filter_occluded_func_backface_cull( - const RTCFilterFunctionNArguments *args) -{ - const RTCRay *ray = (RTCRay *)args->ray; - RTCHit *hit = (RTCHit *)args->hit; - - /* Always ignore back-facing intersections. */ - if (dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z), - make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) - { - *args->valid = 0; - return; - } - - kernel_embree_filter_occluded_func(args); -} -#endif - #ifdef __KERNEL_ONEAPI__ /* Static wrappers so we can call the callbacks from out side the ONEAPIKernelContext class */ RTC_SYCL_INDIRECTLY_CALLABLE static void ccl_always_inline @@ -711,13 +558,11 @@ kernel_embree_filter_occluded_volume_all_func_static(const RTCFilterFunctionNArg ONEAPIKernelContext::kernel_embree_filter_occluded_volume_all_func_static #else # define kernel_embree_filter_intersection_func kernel_embree_filter_intersection_func_impl -# if EMBREE_MAJOR_VERSION >= 4 -# define kernel_embree_filter_occluded_shadow_all_func \ - kernel_embree_filter_occluded_shadow_all_func_impl -# define kernel_embree_filter_occluded_local_func kernel_embree_filter_occluded_local_func_impl -# define kernel_embree_filter_occluded_volume_all_func \ - kernel_embree_filter_occluded_volume_all_func_impl -# endif +# define kernel_embree_filter_occluded_shadow_all_func \ + kernel_embree_filter_occluded_shadow_all_func_impl +# define kernel_embree_filter_occluded_local_func kernel_embree_filter_occluded_local_func_impl +# define kernel_embree_filter_occluded_volume_all_func \ + kernel_embree_filter_occluded_volume_all_func_impl #endif /* Scene intersection. */ @@ -728,37 +573,28 @@ ccl_device_intersect bool kernel_embree_intersect(KernelGlobals kg, ccl_private Intersection *isect) { isect->t = ray->tmax; -#if EMBREE_MAJOR_VERSION >= 4 CCLFirstHitContext ctx; rtcInitRayQueryContext(&ctx); -# ifdef __KERNEL_ONEAPI__ +#ifdef __KERNEL_ONEAPI__ /* NOTE(sirgienko): Cycles GPU back-ends passes nullptr to KernelGlobals and * uses global device allocation (CUDA, Optix, HIP) or passes all needed data * as a class context (Metal, oneAPI). So we need to pass this context here * in order to have an access to it later in Embree filter functions on GPU. */ ctx.kg = (KernelGlobals)this; -# else - ctx.kg = kg; -# endif #else - CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_REGULAR); - rtcInitIntersectContext(&ctx); + ctx.kg = kg; #endif RTCRayHit ray_hit; ctx.ray = ray; kernel_embree_setup_rayhit(*ray, ray_hit, visibility); -#if EMBREE_MAJOR_VERSION >= 4 RTCIntersectArguments args; rtcInitIntersectArguments(&args); args.filter = reinterpret_cast(kernel_embree_filter_intersection_func); args.feature_mask = CYCLES_EMBREE_USED_FEATURES; args.context = &ctx; rtcIntersect1(kernel_data.device_bvh, &ray_hit, &args); -#else - rtcIntersect1(kernel_data.device_bvh, &ctx, &ray_hit); -#endif if (ray_hit.hit.geomID == RTC_INVALID_GEOMETRY_ID || ray_hit.hit.primID == RTC_INVALID_GEOMETRY_ID) { @@ -779,22 +615,16 @@ ccl_device_intersect bool kernel_embree_intersect_local(KernelGlobals kg, { const bool has_bvh = !(kernel_data_fetch(object_flag, local_object) & SD_OBJECT_TRANSFORM_APPLIED); -# if EMBREE_MAJOR_VERSION >= 4 CCLLocalContext ctx; rtcInitRayQueryContext(&ctx); -# ifdef __KERNEL_ONEAPI__ +# ifdef __KERNEL_ONEAPI__ /* NOTE(sirgienko): Cycles GPU back-ends passes nullptr to KernelGlobals and * uses global device allocation (CUDA, Optix, HIP) or passes all needed data * as a class context (Metal, oneAPI). So we need to pass this context here * in order to have an access to it later in Embree filter functions on GPU. */ ctx.kg = (KernelGlobals)this; -# else - ctx.kg = kg; -# endif # else - CCLIntersectContext ctx(kg, - has_bvh ? CCLIntersectContext::RAY_SSS : CCLIntersectContext::RAY_LOCAL); - rtcInitIntersectContext(&ctx); + ctx.kg = kg; # endif ctx.is_sss = has_bvh; ctx.lcg_state = lcg_state; @@ -808,13 +638,11 @@ ccl_device_intersect bool kernel_embree_intersect_local(KernelGlobals kg, RTCRay rtc_ray; kernel_embree_setup_ray(*ray, rtc_ray, PATH_RAY_ALL_VISIBILITY); -# if EMBREE_MAJOR_VERSION >= 4 RTCOccludedArguments args; rtcInitOccludedArguments(&args); args.filter = reinterpret_cast(kernel_embree_filter_occluded_local_func); args.feature_mask = CYCLES_EMBREE_USED_FEATURES; args.context = &ctx; -# endif /* If this object has its own BVH, use it. */ if (has_bvh) { @@ -839,19 +667,11 @@ ccl_device_intersect bool kernel_embree_intersect_local(KernelGlobals kg, local_object * 2); kernel_assert(scene); if (scene) { -# if EMBREE_MAJOR_VERSION >= 4 rtcOccluded1(scene, &rtc_ray, &args); -# else - rtcOccluded1(scene, &ctx, &rtc_ray); -# endif } } else { -# if EMBREE_MAJOR_VERSION >= 4 rtcOccluded1(kernel_data.device_bvh, &rtc_ray, &args); -# else - rtcOccluded1(kernel_data.device_bvh, &ctx, &rtc_ray); -# endif } /* rtcOccluded1 sets tfar to -inf if a hit was found. */ @@ -868,21 +688,16 @@ ccl_device_intersect bool kernel_embree_intersect_shadow_all(KernelGlobals kg, ccl_private uint *num_recorded_hits, ccl_private float *throughput) { -# if EMBREE_MAJOR_VERSION >= 4 CCLShadowContext ctx; rtcInitRayQueryContext(&ctx); -# ifdef __KERNEL_ONEAPI__ +# ifdef __KERNEL_ONEAPI__ /* NOTE(sirgienko): Cycles GPU back-ends passes nullptr to KernelGlobals and * uses global device allocation (CUDA, Optix, HIP) or passes all needed data * as a class context (Metal, oneAPI). So we need to pass this context here * in order to have an access to it later in Embree filter functions on GPU. */ ctx.kg = (KernelGlobals)this; -# else - ctx.kg = kg; -# endif # else - CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SHADOW_ALL); - rtcInitIntersectContext(&ctx); + ctx.kg = kg; # endif ctx.num_transparent_hits = ctx.num_recorded_hits = numhit_t(0); ctx.throughput = 1.0f; @@ -893,7 +708,6 @@ ccl_device_intersect bool kernel_embree_intersect_shadow_all(KernelGlobals kg, ctx.ray = ray; RTCRay rtc_ray; kernel_embree_setup_ray(*ray, rtc_ray, visibility); -# if EMBREE_MAJOR_VERSION >= 4 RTCOccludedArguments args; rtcInitOccludedArguments(&args); args.filter = reinterpret_cast( @@ -901,9 +715,6 @@ ccl_device_intersect bool kernel_embree_intersect_shadow_all(KernelGlobals kg, args.feature_mask = CYCLES_EMBREE_USED_FEATURES; args.context = &ctx; rtcOccluded1(kernel_data.device_bvh, &rtc_ray, &args); -# else - rtcOccluded1(kernel_data.device_bvh, &ctx, &rtc_ray); -# endif *num_recorded_hits = ctx.num_recorded_hits; *throughput = ctx.throughput; @@ -920,21 +731,16 @@ ccl_device_intersect uint kernel_embree_intersect_volume(KernelGlobals kg, # endif const uint visibility) { -# if EMBREE_MAJOR_VERSION >= 4 CCLVolumeContext ctx; rtcInitRayQueryContext(&ctx); -# ifdef __KERNEL_ONEAPI__ +# ifdef __KERNEL_ONEAPI__ /* NOTE(sirgienko) Cycles GPU back-ends passes nullptr to KernelGlobals and * uses global device allocation (CUDA, Optix, HIP) or passes all needed data * as a class context (Metal, oneAPI). So we need to pass this context here * in order to have an access to it later in Embree filter functions on GPU. */ ctx.kg = (KernelGlobals)this; -# else - ctx.kg = kg; -# endif # else - CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_VOLUME_ALL); - rtcInitIntersectContext(&ctx); + ctx.kg = kg; # endif ctx.vol_isect = isect; # ifdef __VOLUME_RECORD_ALL__ @@ -944,7 +750,6 @@ ccl_device_intersect uint kernel_embree_intersect_volume(KernelGlobals kg, ctx.ray = ray; RTCRay rtc_ray; kernel_embree_setup_ray(*ray, rtc_ray, visibility); -# if EMBREE_MAJOR_VERSION >= 4 RTCOccludedArguments args; rtcInitOccludedArguments(&args); args.filter = reinterpret_cast( @@ -952,9 +757,6 @@ ccl_device_intersect uint kernel_embree_intersect_volume(KernelGlobals kg, args.feature_mask = CYCLES_EMBREE_USED_FEATURES; args.context = &ctx; rtcOccluded1(kernel_data.device_bvh, &rtc_ray, &args); -# else - rtcOccluded1(kernel_data.device_bvh, &ctx, &rtc_ray); -# endif return ctx.num_hits; } #endif diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index 7f5183169c1..109ddb62869 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -10,13 +10,8 @@ #if (!defined(__KERNEL_GPU__) || (defined(__KERNEL_ONEAPI__) && defined(WITH_EMBREE_GPU))) && \ defined(WITH_EMBREE) -# if EMBREE_MAJOR_VERSION == 4 -# include -# include -# else -# include -# include -# endif +# include +# include # define __EMBREE__ #endif