Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/qbvh_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 qbvh_node_intersect | # define NODE_INTERSECT qbvh_node_intersect | ||||
| # define NODE_INTERSECT_ROBUST qbvh_node_intersect_robust | |||||
| #else | #else | ||||
| # define NODE_INTERSECT qbvh_aligned_node_intersect | # define NODE_INTERSECT qbvh_aligned_node_intersect | ||||
| # define NODE_INTERSECT_ROBUST qbvh_aligned_node_intersect_robust | |||||
| #endif | #endif | ||||
| ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, | ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(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 | |||||
| ) | |||||
| { | { | ||||
| /* TODO(sergey): | /* TODO(sergey): | ||||
| * - Test if pushing distance on the stack helps (for non shadow rays). | * - Test if pushing distance on the stack helps (for non shadow rays). | ||||
| * - Separate version for shadow rays. | * - Separate version for shadow rays. | ||||
| * - 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 71 Lines • ▼ Show 20 Lines | #endif | ||||
| continue; | continue; | ||||
| } | } | ||||
| int child_mask; | int child_mask; | ||||
| ssef dist; | ssef 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 207 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 = ssef(isect->t); | tfar = ssef(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 | |||||