diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2021-10-24 15:31:22 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2021-10-24 15:31:22 +0300 |
commit | 1aa953bd1913c81b22c80a00edbf4ad88a32c52f (patch) | |
tree | 7fa65e43d5a9bac6496555b723f37e0031e2737e /intern/cycles/kernel/geom/geom_motion_triangle.h | |
parent | fc171c1be9da36485e892339b86dc8d4251914af (diff) | |
parent | 6ce383a9dfba5c49a48676c3a651804fde3dfe34 (diff) |
Merge branch 'master' into soc-2020-io-performance
Diffstat (limited to 'intern/cycles/kernel/geom/geom_motion_triangle.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_motion_triangle.h | 54 |
1 files changed, 9 insertions, 45 deletions
diff --git a/intern/cycles/kernel/geom/geom_motion_triangle.h b/intern/cycles/kernel/geom/geom_motion_triangle.h index 161b358110d..69d15f950ec 100644 --- a/intern/cycles/kernel/geom/geom_motion_triangle.h +++ b/intern/cycles/kernel/geom/geom_motion_triangle.h @@ -27,42 +27,13 @@ #pragma once +#include "kernel/bvh/bvh_util.h" + CCL_NAMESPACE_BEGIN /* Time interpolation of vertex positions and normals */ -ccl_device_inline int find_attribute_motion(ccl_global const KernelGlobals *kg, - int object, - uint id, - ccl_private AttributeElement *elem) -{ - /* todo: find a better (faster) solution for this, maybe store offset per object */ - uint attr_offset = object_attribute_map_offset(kg, object); - uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset); - - while (attr_map.x != id) { - if (UNLIKELY(attr_map.x == ATTR_STD_NONE)) { - if (UNLIKELY(attr_map.y == 0)) { - return (int)ATTR_STD_NOT_FOUND; - } - else { - /* Chain jump to a different part of the table. */ - attr_offset = attr_map.z; - } - } - else { - attr_offset += ATTR_PRIM_TYPES; - } - attr_map = kernel_tex_fetch(__attributes_map, attr_offset); - } - - *elem = (AttributeElement)attr_map.y; - - /* return result */ - return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : (int)attr_map.z; -} - -ccl_device_inline void motion_triangle_verts_for_step(ccl_global const KernelGlobals *kg, +ccl_device_inline void motion_triangle_verts_for_step(KernelGlobals kg, uint4 tri_vindex, int offset, int numverts, @@ -89,7 +60,7 @@ ccl_device_inline void motion_triangle_verts_for_step(ccl_global const KernelGlo } } -ccl_device_inline void motion_triangle_normals_for_step(ccl_global const KernelGlobals *kg, +ccl_device_inline void motion_triangle_normals_for_step(KernelGlobals kg, uint4 tri_vindex, int offset, int numverts, @@ -117,7 +88,7 @@ ccl_device_inline void motion_triangle_normals_for_step(ccl_global const KernelG } ccl_device_inline void motion_triangle_vertices( - ccl_global const KernelGlobals *kg, int object, int prim, float time, float3 verts[3]) + KernelGlobals kg, int object, int prim, float time, float3 verts[3]) { /* get motion info */ int numsteps, numverts; @@ -129,8 +100,7 @@ ccl_device_inline void motion_triangle_vertices( float t = time * maxstep - step; /* find attribute */ - AttributeElement elem; - int offset = find_attribute_motion(kg, object, ATTR_STD_MOTION_VERTEX_POSITION, &elem); + int offset = intersection_find_attribute(kg, object, ATTR_STD_MOTION_VERTEX_POSITION); kernel_assert(offset != ATTR_STD_NOT_FOUND); /* fetch vertex coordinates */ @@ -146,13 +116,8 @@ ccl_device_inline void motion_triangle_vertices( verts[2] = (1.0f - t) * verts[2] + t * next_verts[2]; } -ccl_device_inline float3 motion_triangle_smooth_normal(ccl_global const KernelGlobals *kg, - float3 Ng, - int object, - int prim, - float u, - float v, - float time) +ccl_device_inline float3 motion_triangle_smooth_normal( + KernelGlobals kg, float3 Ng, int object, int prim, float u, float v, float time) { /* get motion info */ int numsteps, numverts; @@ -164,8 +129,7 @@ ccl_device_inline float3 motion_triangle_smooth_normal(ccl_global const KernelGl float t = time * maxstep - step; /* find attribute */ - AttributeElement elem; - int offset = find_attribute_motion(kg, object, ATTR_STD_MOTION_VERTEX_NORMAL, &elem); + int offset = intersection_find_attribute(kg, object, ATTR_STD_MOTION_VERTEX_NORMAL); kernel_assert(offset != ATTR_STD_NOT_FOUND); /* fetch normals */ |