Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh.h
| Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | |||||
| #endif | #endif | ||||
| #ifdef __SHADOW_RECORD_ALL__ | #ifdef __SHADOW_RECORD_ALL__ | ||||
| ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg, | ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg, | ||||
| IntegratorShadowState state, | IntegratorShadowState state, | ||||
| ccl_private const Ray *ray, | ccl_private const Ray *ray, | ||||
| uint visibility, | uint visibility, | ||||
| uint max_hits, | uint max_hits, | ||||
| ccl_private uint *num_hits) | ccl_private uint *num_recorded_hits, | ||||
| ccl_private float *throughput) | |||||
| { | { | ||||
| # ifdef __KERNEL_OPTIX__ | # ifdef __KERNEL_OPTIX__ | ||||
| uint p0 = state; | uint p0 = state; | ||||
| uint p1 = 0; /* Number of hits. */ | uint p1 = 0; /* Number of hits. */ | ||||
| uint p2 = max_hits; | uint p2 = max_hits; | ||||
| uint p3 = visibility; | uint p3 = visibility; | ||||
| uint p4 = false; /* Opaque hit. */ | uint p4 = false; /* Opaque hit. */ | ||||
| uint p5 = 0; /* Unused. */ | uint p5 = __float_as_uint(1.0f); /* Throughput. */ | ||||
| uint ray_mask = visibility & 0xFF; | uint ray_mask = visibility & 0xFF; | ||||
| if (0 == ray_mask && (visibility & ~0xFF) != 0) { | if (0 == ray_mask && (visibility & ~0xFF) != 0) { | ||||
| ray_mask = 0xFF; | ray_mask = 0xFF; | ||||
| } | } | ||||
| *num_hits = 0; /* Initialize hit count to zero. */ | |||||
| optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0, | optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0, | ||||
| ray->P, | ray->P, | ||||
| ray->D, | ray->D, | ||||
| 0.0f, | 0.0f, | ||||
| ray->t, | ray->t, | ||||
| ray->time, | ray->time, | ||||
| ray_mask, | ray_mask, | ||||
| /* Need to always call into __anyhit__kernel_optix_shadow_all_hit. */ | /* Need to always call into __anyhit__kernel_optix_shadow_all_hit. */ | ||||
| OPTIX_RAY_FLAG_ENFORCE_ANYHIT, | OPTIX_RAY_FLAG_ENFORCE_ANYHIT, | ||||
| 1, /* SBT offset for PG_HITS */ | 1, /* SBT offset for PG_HITS */ | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| p0, | p0, | ||||
| p1, | p1, | ||||
| p2, | p2, | ||||
| p3, | p3, | ||||
| p4, | p4, | ||||
| p5); | p5); | ||||
leesonw: These are running out fast :-( | |||||
| *num_hits = p2; | *num_recorded_hits = uint16_unpack_from_uint_0(p2); | ||||
| *throughput = __uint_as_float(p5); | |||||
| return p5; | return p5; | ||||
| # else /* __KERNEL_OPTIX__ */ | # else /* __KERNEL_OPTIX__ */ | ||||
| if (!scene_intersect_valid(ray)) { | if (!scene_intersect_valid(ray)) { | ||||
| *num_hits = 0; | *num_recorded_hits = 0; | ||||
| *throughput = 1.0f; | |||||
| return false; | return false; | ||||
| } | } | ||||
| # ifdef __EMBREE__ | # ifdef __EMBREE__ | ||||
| if (kernel_data.bvh.scene) { | if (kernel_data.bvh.scene) { | ||||
| CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SHADOW_ALL); | CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SHADOW_ALL); | ||||
| Intersection *isect_array = (Intersection *)state->shadow_isect; | Intersection *isect_array = (Intersection *)state->shadow_isect; | ||||
| ctx.isect_s = isect_array; | ctx.isect_s = isect_array; | ||||
| ctx.max_hits = max_hits; | ctx.max_hits = max_hits; | ||||
| IntersectContext rtc_ctx(&ctx); | IntersectContext rtc_ctx(&ctx); | ||||
| RTCRay rtc_ray; | RTCRay rtc_ray; | ||||
| kernel_embree_setup_ray(*ray, rtc_ray, visibility); | kernel_embree_setup_ray(*ray, rtc_ray, visibility); | ||||
| rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray); | rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray); | ||||
| *num_hits = ctx.num_hits; | *num_recorded_hits = ctx.num_recorded_hits; | ||||
| *throughput = ctx.throughput; | |||||
| return ctx.opaque_hit; | return ctx.opaque_hit; | ||||
| } | } | ||||
| # endif /* __EMBREE__ */ | # endif /* __EMBREE__ */ | ||||
| # ifdef __OBJECT_MOTION__ | # ifdef __OBJECT_MOTION__ | ||||
| if (kernel_data.bvh.have_motion) { | if (kernel_data.bvh.have_motion) { | ||||
| # ifdef __HAIR__ | # ifdef __HAIR__ | ||||
| if (kernel_data.bvh.have_curves) { | if (kernel_data.bvh.have_curves) { | ||||
| return bvh_intersect_shadow_all_hair_motion(kg, ray, state, visibility, max_hits, num_hits); | return bvh_intersect_shadow_all_hair_motion( | ||||
| kg, ray, state, visibility, max_hits, num_recorded_hits, throughput); | |||||
| } | } | ||||
| # endif /* __HAIR__ */ | # endif /* __HAIR__ */ | ||||
| return bvh_intersect_shadow_all_motion(kg, ray, state, visibility, max_hits, num_hits); | return bvh_intersect_shadow_all_motion( | ||||
| kg, ray, state, visibility, max_hits, num_recorded_hits, throughput); | |||||
| } | } | ||||
| # endif /* __OBJECT_MOTION__ */ | # endif /* __OBJECT_MOTION__ */ | ||||
| # ifdef __HAIR__ | # ifdef __HAIR__ | ||||
| if (kernel_data.bvh.have_curves) { | if (kernel_data.bvh.have_curves) { | ||||
| return bvh_intersect_shadow_all_hair(kg, ray, state, visibility, max_hits, num_hits); | return bvh_intersect_shadow_all_hair( | ||||
| kg, ray, state, visibility, max_hits, num_recorded_hits, throughput); | |||||
| } | } | ||||
| # endif /* __HAIR__ */ | # endif /* __HAIR__ */ | ||||
| return bvh_intersect_shadow_all(kg, ray, state, visibility, max_hits, num_hits); | return bvh_intersect_shadow_all( | ||||
| kg, ray, state, visibility, max_hits, num_recorded_hits, throughput); | |||||
| # endif /* __KERNEL_OPTIX__ */ | # endif /* __KERNEL_OPTIX__ */ | ||||
| } | } | ||||
| #endif /* __SHADOW_RECORD_ALL__ */ | #endif /* __SHADOW_RECORD_ALL__ */ | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg, | ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg, | ||||
| ccl_private const Ray *ray, | ccl_private const Ray *ray, | ||||
| ccl_private Intersection *isect, | ccl_private Intersection *isect, | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||
These are running out fast :-(