Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/obvh_traversal.h
| Show All 14 Lines | |||||
| */ | */ | ||||
| /* This is a template BVH traversal function, where various features can be | /* This is a template BVH traversal function, where various features can be | ||||
| * enabled/disabled. This way we can compile optimized versions for each case | * enabled/disabled. This way we can compile optimized versions for each case | ||||
| * without new features slowing things down. | * without new features slowing things down. | ||||
| * | * | ||||
| * BVH_INSTANCING: object instancing | * BVH_INSTANCING: object instancing | ||||
| * BVH_HAIR: hair curve rendering | * BVH_HAIR: hair curve rendering | ||||
| * BVH_HAIR_MINIMUM_WIDTH: hair curve rendering with minimum width | |||||
| * BVH_MOTION: motion blur rendering | * BVH_MOTION: motion blur rendering | ||||
| */ | */ | ||||
| #if BVH_FEATURE(BVH_HAIR) | #if BVH_FEATURE(BVH_HAIR) | ||||
| # define NODE_INTERSECT obvh_node_intersect | # define NODE_INTERSECT obvh_node_intersect | ||||
| # define NODE_INTERSECT_ROBUST obvh_node_intersect_robust | |||||
| #else | #else | ||||
| # define NODE_INTERSECT obvh_aligned_node_intersect | # define NODE_INTERSECT obvh_aligned_node_intersect | ||||
| # define NODE_INTERSECT_ROBUST obvh_aligned_node_intersect_robust | |||||
| #endif | #endif | ||||
| ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, | ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, | ||||
| const Ray *ray, | const Ray *ray, | ||||
| Intersection *isect, | Intersection *isect, | ||||
| const uint visibility | const uint visibility) | ||||
| #if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) | |||||
| ,uint *lcg_state, | |||||
| float difl, | |||||
| float extmax | |||||
| #endif | |||||
| ) | |||||
| { | { | ||||
| /* Traversal stack in CUDA thread-local memory. */ | /* Traversal stack in CUDA thread-local memory. */ | ||||
| OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; | OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; | ||||
| traversal_stack[0].addr = ENTRYPOINT_SENTINEL; | traversal_stack[0].addr = ENTRYPOINT_SENTINEL; | ||||
| traversal_stack[0].dist = -FLT_MAX; | traversal_stack[0].dist = -FLT_MAX; | ||||
| /* Traversal variables in registers. */ | /* Traversal variables in registers. */ | ||||
| int stack_ptr = 0; | int stack_ptr = 0; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | #endif | ||||
| continue; | continue; | ||||
| } | } | ||||
| int child_mask; | int child_mask; | ||||
| avxf dist; | avxf dist; | ||||
| BVH_DEBUG_NEXT_NODE(); | BVH_DEBUG_NEXT_NODE(); | ||||
| #if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) | |||||
| if(difl != 0.0f) { | |||||
| /* NOTE: We extend all the child BB instead of fetching | |||||
| * and checking visibility flags for each of the, | |||||
| * | |||||
| * Need to test if doing opposite would be any faster. | |||||
| */ | |||||
| child_mask = NODE_INTERSECT_ROBUST(kg, | |||||
| tnear, | |||||
| tfar, | |||||
| # ifdef __KERNEL_AVX2__ | |||||
| P_idir4, | |||||
| # endif | |||||
| # if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) | |||||
| org4, | |||||
| # endif | |||||
| # if BVH_FEATURE(BVH_HAIR) | |||||
| dir4, | |||||
| # endif | |||||
| idir4, | |||||
| near_x, near_y, near_z, | |||||
| far_x, far_y, far_z, | |||||
| node_addr, | |||||
| difl, | |||||
| &dist); | |||||
| } | |||||
| else | |||||
| #endif /* BVH_HAIR_MINIMUM_WIDTH */ | |||||
| { | { | ||||
| child_mask = NODE_INTERSECT(kg, | child_mask = NODE_INTERSECT(kg, | ||||
| tnear, | tnear, | ||||
| tfar, | tfar, | ||||
| #ifdef __KERNEL_AVX2__ | #ifdef __KERNEL_AVX2__ | ||||
| P_idir4, | P_idir4, | ||||
| #endif | #endif | ||||
| #if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) | #if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) | ||||
| ▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | #if BVH_FEATURE(BVH_HAIR) | ||||
| hit = cardinal_curve_intersect(kg, | hit = cardinal_curve_intersect(kg, | ||||
| isect, | isect, | ||||
| P, | P, | ||||
| dir, | dir, | ||||
| visibility, | visibility, | ||||
| object, | object, | ||||
| prim_addr, | prim_addr, | ||||
| ray->time, | ray->time, | ||||
| curve_type, | curve_type); | ||||
| lcg_state, | |||||
| difl, | |||||
| extmax); | |||||
| } | } | ||||
| else { | else { | ||||
| hit = curve_intersect(kg, | hit = curve_intersect(kg, | ||||
| isect, | isect, | ||||
| P, | P, | ||||
| dir, | dir, | ||||
| visibility, | visibility, | ||||
| object, | object, | ||||
| prim_addr, | prim_addr, | ||||
| ray->time, | ray->time, | ||||
| curve_type, | curve_type); | ||||
| lcg_state, | |||||
| difl, | |||||
| extmax); | |||||
| } | } | ||||
| if(hit) { | if(hit) { | ||||
| tfar = avxf(isect->t); | tfar = avxf(isect->t); | ||||
| /* Shadow ray early termination. */ | /* Shadow ray early termination. */ | ||||
| if(visibility == PATH_RAY_SHADOW_OPAQUE) { | if(visibility == PATH_RAY_SHADOW_OPAQUE) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | # endif | ||||
| } | } | ||||
| #endif /* FEATURE(BVH_INSTANCING) */ | #endif /* FEATURE(BVH_INSTANCING) */ | ||||
| } while(node_addr != ENTRYPOINT_SENTINEL); | } while(node_addr != ENTRYPOINT_SENTINEL); | ||||
| return (isect->prim != PRIM_NONE); | return (isect->prim != PRIM_NONE); | ||||
| } | } | ||||
| #undef NODE_INTERSECT | #undef NODE_INTERSECT | ||||
| #undef NODE_INTERSECT_ROBUST | |||||