Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_util.h
| Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | for (int j = 0; j < num_hits - 1; ++j) { | ||||
| } | } | ||||
| } | } | ||||
| --num_hits; | --num_hits; | ||||
| } while (swapped); | } while (swapped); | ||||
| } | } | ||||
| /* Utility to quickly get flags from an intersection. */ | /* Utility to quickly get flags from an intersection. */ | ||||
| ccl_device_forceinline int intersection_get_shader_flags( | ccl_device_forceinline int intersection_get_shader_flags(KernelGlobals kg, | ||||
| ccl_global const KernelGlobals *ccl_restrict kg, const int prim, const int type) | const int prim, | ||||
| const int type) | |||||
| { | { | ||||
| int shader = 0; | int shader = 0; | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| if (type & PRIMITIVE_ALL_TRIANGLE) | if (type & PRIMITIVE_ALL_TRIANGLE) | ||||
| #endif | #endif | ||||
| { | { | ||||
| shader = kernel_tex_fetch(__tri_shader, prim); | shader = kernel_tex_fetch(__tri_shader, prim); | ||||
| } | } | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| else { | else { | ||||
| shader = kernel_tex_fetch(__curves, prim).shader_id; | shader = kernel_tex_fetch(__curves, prim).shader_id; | ||||
| } | } | ||||
| #endif | #endif | ||||
| return kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags; | return kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags; | ||||
| } | } | ||||
| ccl_device_forceinline int intersection_get_shader_from_isect_prim( | ccl_device_forceinline int intersection_get_shader_from_isect_prim(KernelGlobals kg, | ||||
| ccl_global const KernelGlobals *ccl_restrict kg, const int prim, const int isect_type) | const int prim, | ||||
| const int isect_type) | |||||
| { | { | ||||
| int shader = 0; | int shader = 0; | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| if (isect_type & PRIMITIVE_ALL_TRIANGLE) | if (isect_type & PRIMITIVE_ALL_TRIANGLE) | ||||
| #endif | #endif | ||||
| { | { | ||||
| shader = kernel_tex_fetch(__tri_shader, prim); | shader = kernel_tex_fetch(__tri_shader, prim); | ||||
| } | } | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| else { | else { | ||||
| shader = kernel_tex_fetch(__curves, prim).shader_id; | shader = kernel_tex_fetch(__curves, prim).shader_id; | ||||
| } | } | ||||
| #endif | #endif | ||||
| return shader & SHADER_MASK; | return shader & SHADER_MASK; | ||||
| } | } | ||||
| ccl_device_forceinline int intersection_get_shader(ccl_global const KernelGlobals *ccl_restrict kg, | ccl_device_forceinline int intersection_get_shader( | ||||
| ccl_private const Intersection *ccl_restrict | KernelGlobals kg, ccl_private const Intersection *ccl_restrict isect) | ||||
| isect) | |||||
| { | { | ||||
| return intersection_get_shader_from_isect_prim(kg, isect->prim, isect->type); | return intersection_get_shader_from_isect_prim(kg, isect->prim, isect->type); | ||||
| } | } | ||||
| ccl_device_forceinline int intersection_get_object_flags( | ccl_device_forceinline int intersection_get_object_flags( | ||||
| ccl_global const KernelGlobals *ccl_restrict kg, | KernelGlobals kg, ccl_private const Intersection *ccl_restrict isect) | ||||
| ccl_private const Intersection *ccl_restrict isect) | |||||
| { | { | ||||
| return kernel_tex_fetch(__object_flag, isect->object); | return kernel_tex_fetch(__object_flag, isect->object); | ||||
| } | } | ||||
| /* TODO: find a better (faster) solution for this. Maybe store offset per object for | /* TODO: find a better (faster) solution for this. Maybe store offset per object for | ||||
| * attributes needed in intersection? */ | * attributes needed in intersection? */ | ||||
| ccl_device_inline int intersection_find_attribute(ccl_global const KernelGlobals *kg, | ccl_device_inline int intersection_find_attribute(KernelGlobals kg, | ||||
| const int object, | const int object, | ||||
| const uint id) | const uint id) | ||||
| { | { | ||||
| uint attr_offset = kernel_tex_fetch(__objects, object).attribute_map_offset; | uint attr_offset = kernel_tex_fetch(__objects, object).attribute_map_offset; | ||||
| uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset); | uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset); | ||||
| while (attr_map.x != id) { | while (attr_map.x != id) { | ||||
| if (UNLIKELY(attr_map.x == ATTR_STD_NONE)) { | if (UNLIKELY(attr_map.x == ATTR_STD_NONE)) { | ||||
| Show All 19 Lines | |||||