Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_shadow_all.h
| Show All 32 Lines | |||||
| #ifndef __KERNEL_GPU__ | #ifndef __KERNEL_GPU__ | ||||
| ccl_device | ccl_device | ||||
| #else | #else | ||||
| ccl_device_inline | ccl_device_inline | ||||
| #endif | #endif | ||||
| bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals kg, | bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals kg, | ||||
| ccl_private const Ray *ray, | ccl_private const Ray *ray, | ||||
| ccl_private Intersection *isect_array, | IntegratorShadowState state, | ||||
| const uint visibility, | const uint visibility, | ||||
| const uint max_hits, | const uint max_hits, | ||||
| ccl_private uint *num_hits) | ccl_private uint *num_hits) | ||||
| { | { | ||||
| /* todo: | /* todo: | ||||
| * - likely and unlikely for if() statements | * - likely and unlikely for if() statements | ||||
| * - test restrict attribute for pointers | * - test restrict attribute for pointers | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | #endif | ||||
| * simply not record those and only keep the max_hits closest. */ | * simply not record those and only keep the max_hits closest. */ | ||||
| uint record_index = (*num_hits)++; | uint record_index = (*num_hits)++; | ||||
| if (record_index >= max_hits - 1) { | if (record_index >= max_hits - 1) { | ||||
| /* If maximum number of hits reached, find the intersection with | /* If maximum number of hits reached, find the intersection with | ||||
| * the largest distance to potentially replace when another hit | * the largest distance to potentially replace when another hit | ||||
| * is found. */ | * is found. */ | ||||
| const int num_recorded_hits = min(max_hits, record_index); | const int num_recorded_hits = min(max_hits, record_index); | ||||
| float max_recorded_t = isect_array[0].t; | float max_recorded_t = INTEGRATOR_STATE_ARRAY(state, shadow_isect, 0, t); | ||||
| int max_recorded_hit = 0; | int max_recorded_hit = 0; | ||||
| for (int i = 1; i < num_recorded_hits; i++) { | for (int i = 1; i < num_recorded_hits; i++) { | ||||
| if (isect_array[i].t > max_recorded_t) { | const float isect_t = INTEGRATOR_STATE_ARRAY(state, shadow_isect, i, t); | ||||
| max_recorded_t = isect_array[i].t; | if (isect_t > max_recorded_t) { | ||||
| max_recorded_t = isect_t; | |||||
| max_recorded_hit = i; | max_recorded_hit = i; | ||||
| } | } | ||||
| } | } | ||||
| if (record_index >= max_hits) { | if (record_index >= max_hits) { | ||||
| record_index = max_recorded_hit; | record_index = max_recorded_hit; | ||||
| } | } | ||||
| /* Limit the ray distance and stop counting hits beyond this. */ | /* Limit the ray distance and stop counting hits beyond this. */ | ||||
| t_max_world = max(max_recorded_t, isect.t); | t_max_world = max(max_recorded_t, isect.t); | ||||
| t_max_current = t_max_world * t_world_to_instance; | t_max_current = t_max_world * t_world_to_instance; | ||||
| } | } | ||||
| isect_array[record_index] = isect; | integrator_state_write_shadow_isect(state, &isect, record_index); | ||||
| } | } | ||||
| prim_addr++; | prim_addr++; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* instance push */ | /* instance push */ | ||||
| object = kernel_tex_fetch(__prim_object, -prim_addr - 1); | object = kernel_tex_fetch(__prim_object, -prim_addr - 1); | ||||
| Show All 37 Lines | #endif | ||||
| } | } | ||||
| } while (node_addr != ENTRYPOINT_SENTINEL); | } while (node_addr != ENTRYPOINT_SENTINEL); | ||||
| return false; | return false; | ||||
| } | } | ||||
| ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals kg, | ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals kg, | ||||
| ccl_private const Ray *ray, | ccl_private const Ray *ray, | ||||
| ccl_private Intersection *isect_array, | IntegratorShadowState state, | ||||
| const uint visibility, | const uint visibility, | ||||
| const uint max_hits, | const uint max_hits, | ||||
| ccl_private uint *num_hits) | ccl_private uint *num_hits) | ||||
| { | { | ||||
| return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, visibility, max_hits, num_hits); | return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, state, visibility, max_hits, num_hits); | ||||
| } | } | ||||
| #undef BVH_FUNCTION_NAME | #undef BVH_FUNCTION_NAME | ||||
| #undef BVH_FUNCTION_FEATURES | #undef BVH_FUNCTION_FEATURES | ||||
| #undef NODE_INTERSECT | #undef NODE_INTERSECT | ||||