Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-10-13 19:19:51 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-10-15 16:42:44 +0300
commit5d565062edc25575bbabf173a4e26f184103944b (patch)
treed0f41f75cbdf1260b3126f909ae2917a8ca52c2f /intern/cycles/kernel/bvh
parent509b637d594f97ce1504c65430d0643ecb4c6f9a (diff)
Cleanup: refactor OptiX shadow intersection for upcoming changes
Diffstat (limited to 'intern/cycles/kernel/bvh')
-rw-r--r--intern/cycles/kernel/bvh/bvh_shadow_all.h2
-rw-r--r--intern/cycles/kernel/bvh/bvh_util.h35
2 files changed, 32 insertions, 5 deletions
diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index ea1ee26b863..4f2164a86ae 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -197,7 +197,7 @@ ccl_device_inline
/* todo: optimize so primitive visibility flag indicates if
* the primitive has a transparent shadow shader? */
- const int flags = intersection_get_shader_flags(kg, isect);
+ const int flags = intersection_get_shader_flags(kg, isect->prim, isect->type);
if (!(flags & SD_HAS_TRANSPARENT_SHADOW) || max_hits == 0) {
/* If no transparent shadows, all light is blocked and we can
diff --git a/intern/cycles/kernel/bvh/bvh_util.h b/intern/cycles/kernel/bvh/bvh_util.h
index fb546f568f3..31aae389da0 100644
--- a/intern/cycles/kernel/bvh/bvh_util.h
+++ b/intern/cycles/kernel/bvh/bvh_util.h
@@ -140,14 +140,12 @@ ccl_device_inline void sort_intersections_and_normals(ccl_private Intersection *
/* Utility to quickly get flags from an intersection. */
ccl_device_forceinline int intersection_get_shader_flags(
- ccl_global const KernelGlobals *ccl_restrict kg,
- ccl_private const Intersection *ccl_restrict isect)
+ ccl_global const KernelGlobals *ccl_restrict kg, const int prim, const int type)
{
- const int prim = isect->prim;
int shader = 0;
#ifdef __HAIR__
- if (isect->type & PRIMITIVE_ALL_TRIANGLE)
+ if (type & PRIMITIVE_ALL_TRIANGLE)
#endif
{
shader = kernel_tex_fetch(__tri_shader, prim);
@@ -195,4 +193,33 @@ ccl_device_forceinline int intersection_get_object_flags(
return kernel_tex_fetch(__object_flag, isect->object);
}
+/* TODO: find a better (faster) solution for this. Maybe store offset per object for
+ * attributes needed in intersection? */
+ccl_device_inline int intersection_find_attribute(ccl_global const KernelGlobals *kg,
+ const int object,
+ const uint id)
+{
+ uint attr_offset = kernel_tex_fetch(__objects, object).attribute_map_offset;
+ 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);
+ }
+
+ /* return result */
+ return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : (int)attr_map.z;
+}
+
CCL_NAMESPACE_END