|
|
|
|
@@ -6,13 +6,9 @@
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#if EMBREE_MAJOR_VERSION >= 4
|
|
|
|
|
# include <embree4/rtcore_ray.h>
|
|
|
|
|
# include <embree4/rtcore_scene.h>
|
|
|
|
|
#else
|
|
|
|
|
# include <embree3/rtcore_ray.h>
|
|
|
|
|
# include <embree3/rtcore_scene.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <embree4/rtcore_geometry.h>
|
|
|
|
|
#include <embree4/rtcore_ray.h>
|
|
|
|
|
#include <embree4/rtcore_scene.h>
|
|
|
|
|
|
|
|
|
|
#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<intptr_t>(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<RTCFilterFunctionN>(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<RTCFilterFunctionN>(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<RTCFilterFunctionN>(
|
|
|
|
|
@@ -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<RTCFilterFunctionN>(
|
|
|
|
|
@@ -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
|
|
|
|
|
|