Cycles: remove SIMD BVH optimizations, to be replaced by Embree
authorBrecht Van Lommel <brecht@blender.org>
Wed, 10 Jun 2020 16:55:33 +0000 (18:55 +0200)
committerBrecht Van Lommel <brecht@blender.org>
Mon, 22 Jun 2020 11:28:01 +0000 (13:28 +0200)
Ref T73778

Depends on D8011

Maniphest Tasks: T73778

Differential Revision: https://developer.blender.org/D8012

39 files changed:
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
intern/cycles/bvh/CMakeLists.txt
intern/cycles/bvh/bvh.cpp
intern/cycles/bvh/bvh.h
intern/cycles/bvh/bvh4.cpp [deleted file]
intern/cycles/bvh/bvh4.h [deleted file]
intern/cycles/bvh/bvh8.cpp [deleted file]
intern/cycles/bvh/bvh8.h [deleted file]
intern/cycles/device/device_cpu.cpp
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/bvh/bvh.h
intern/cycles/kernel/bvh/bvh_local.h
intern/cycles/kernel/bvh/bvh_nodes.h
intern/cycles/kernel/bvh/bvh_shadow_all.h
intern/cycles/kernel/bvh/bvh_traversal.h
intern/cycles/kernel/bvh/bvh_types.h
intern/cycles/kernel/bvh/bvh_volume.h
intern/cycles/kernel/bvh/bvh_volume_all.h
intern/cycles/kernel/bvh/obvh_local.h [deleted file]
intern/cycles/kernel/bvh/obvh_nodes.h [deleted file]
intern/cycles/kernel/bvh/obvh_shadow_all.h [deleted file]
intern/cycles/kernel/bvh/obvh_traversal.h [deleted file]
intern/cycles/kernel/bvh/obvh_volume.h [deleted file]
intern/cycles/kernel/bvh/obvh_volume_all.h [deleted file]
intern/cycles/kernel/bvh/qbvh_local.h [deleted file]
intern/cycles/kernel/bvh/qbvh_nodes.h [deleted file]
intern/cycles/kernel/bvh/qbvh_shadow_all.h [deleted file]
intern/cycles/kernel/bvh/qbvh_traversal.h [deleted file]
intern/cycles/kernel/bvh/qbvh_volume.h [deleted file]
intern/cycles/kernel/bvh/qbvh_volume_all.h [deleted file]
intern/cycles/kernel/geom/geom_curve_intersect.h
intern/cycles/kernel/geom/geom_motion_curve.h
intern/cycles/kernel/geom/geom_object.h
intern/cycles/kernel/geom/geom_triangle_intersect.h
intern/cycles/kernel/kernel_types.h
intern/cycles/util/util_debug.cpp
intern/cycles/util/util_debug.h

index 89ed059af21f7f5c00f20cc67d51fb7a7a773b40..f0f7d24002fa89e394729fb94c7fda5ca091786d 100644 (file)
@@ -53,12 +53,6 @@ enum_displacement_methods = (
     ('BOTH', "Displacement and Bump", "Combination of true displacement and bump mapping for finer detail"),
 )
 
-enum_bvh_layouts = (
-    ('BVH2', "BVH2", "", 1),
-    ('BVH4', "BVH4", "", 2),
-    ('BVH8', "BVH8", "", 4),
-)
-
 enum_bvh_types = (
     ('DYNAMIC_BVH', "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"),
     ('STATIC_BVH', "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"),
@@ -772,11 +766,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
     debug_use_cpu_sse41: BoolProperty(name="SSE41", default=True)
     debug_use_cpu_sse3: BoolProperty(name="SSE3", default=True)
     debug_use_cpu_sse2: BoolProperty(name="SSE2", default=True)
-    debug_bvh_layout: EnumProperty(
-        name="BVH Layout",
-        items=enum_bvh_layouts,
-        default='BVH8',
-    )
     debug_use_cpu_split_kernel: BoolProperty(name="Split Kernel", default=False)
 
     debug_use_cuda_adaptive_compile: BoolProperty(name="Adaptive Compile", default=False)
index 9680bd04751bdd3a3ebc68532e5262781a9c63f4..0859a8a82b0f099de30542e58cff4ec6acbc8c37 100644 (file)
@@ -688,16 +688,20 @@ class CYCLES_RENDER_PT_performance_acceleration_structure(CyclesButtonsPanel, Pa
 
         col = layout.column()
 
-        if _cycles.with_embree:
-            row = col.row()
-            row.active = use_cpu(context)
-            row.prop(cscene, "use_bvh_embree")
+        use_embree = False
+        if use_cpu(context):
+            use_embree = _cycles.with_embree
+            if not use_embree:
+              sub = col.column(align=True)
+              sub.label(text="Cycles built without Embree support")
+              sub.label(text="CPU raytracing performance will be poor")
+
         col.prop(cscene, "debug_use_spatial_splits")
         sub = col.column()
-        sub.active = not cscene.use_bvh_embree or not _cycles.with_embree
+        sub.active = not use_embree
         sub.prop(cscene, "debug_use_hair_bvh")
         sub = col.column()
-        sub.active = not cscene.debug_use_spatial_splits and not cscene.use_bvh_embree
+        sub.active = not cscene.debug_use_spatial_splits and not use_embree
         sub.prop(cscene, "debug_bvh_time_steps")
 
 
index 09813dc8c05d8b90d6a466f1fbc482f671914032..f5fd6f31c75fbdff849480b8817363652fabd81d 100644 (file)
@@ -751,15 +751,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
     params.texture_limit = 0;
   }
 
-  /* TODO(sergey): Once OSL supports per-microarchitecture optimization get
-   * rid of this.
-   */
-  if (params.shadingsystem == SHADINGSYSTEM_OSL) {
-    params.bvh_layout = BVH_LAYOUT_BVH4;
-  }
-  else {
-    params.bvh_layout = DebugFlags().cpu.bvh_layout;
-  }
+  params.bvh_layout = DebugFlags().cpu.bvh_layout;
 
 #ifdef WITH_EMBREE
   params.bvh_layout = RNA_boolean_get(&cscene, "use_bvh_embree") ? BVH_LAYOUT_EMBREE :
index fb724704a84acdce6c9816cbd2022c83fad2f0cd..8b8f3ca72657102af25a8ad6d97ab5a58110b88a 100644 (file)
@@ -9,8 +9,6 @@ set(INC_SYS
 set(SRC
   bvh.cpp
   bvh2.cpp
-  bvh4.cpp
-  bvh8.cpp
   bvh_binning.cpp
   bvh_build.cpp
   bvh_embree.cpp
@@ -24,8 +22,6 @@ set(SRC
 set(SRC_HEADERS
   bvh.h
   bvh2.h
-  bvh4.h
-  bvh8.h
   bvh_binning.h
   bvh_build.h
   bvh_embree.h
index 8749bcfc07ec71531d42a4ba22700dfb3439b246..e9e67fd13053ef94e15270d5750913f656d2d0da 100644 (file)
@@ -22,8 +22,6 @@
 #include "render/object.h"
 
 #include "bvh/bvh2.h"
-#include "bvh/bvh4.h"
-#include "bvh/bvh8.h"
 #include "bvh/bvh_build.h"
 #include "bvh/bvh_embree.h"
 #include "bvh/bvh_node.h"
@@ -42,10 +40,6 @@ const char *bvh_layout_name(BVHLayout layout)
   switch (layout) {
     case BVH_LAYOUT_BVH2:
       return "BVH2";
-    case BVH_LAYOUT_BVH4:
-      return "BVH4";
-    case BVH_LAYOUT_BVH8:
-      return "BVH8";
     case BVH_LAYOUT_NONE:
       return "NONE";
     case BVH_LAYOUT_EMBREE:
@@ -109,10 +103,6 @@ BVH *BVH::create(const BVHParams &params,
   switch (params.bvh_layout) {
     case BVH_LAYOUT_BVH2:
       return new BVH2(params, geometry, objects);
-    case BVH_LAYOUT_BVH4:
-      return new BVH4(params, geometry, objects);
-    case BVH_LAYOUT_BVH8:
-      return new BVH8(params, geometry, objects);
     case BVH_LAYOUT_EMBREE:
 #ifdef WITH_EMBREE
       return new BVHEmbree(params, geometry, objects);
@@ -332,13 +322,6 @@ void BVH::pack_primitives()
 
 void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
 {
-  /* The BVH's for instances are built separately, but for traversal all
-   * BVH's are stored in global arrays. This function merges them into the
-   * top level BVH, adjusting indexes and offsets where appropriate.
-   */
-  const bool use_qbvh = (params.bvh_layout == BVH_LAYOUT_BVH4);
-  const bool use_obvh = (params.bvh_layout == BVH_LAYOUT_BVH8);
-
   /* Adjust primitive index to point to the triangle in the global array, for
    * geometry with transform applied and already in the top level BVH.
    */
@@ -501,53 +484,21 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
       for (size_t i = 0, j = 0; i < bvh_nodes_size; j++) {
         size_t nsize, nsize_bbox;
         if (bvh_nodes[i].x & PATH_RAY_NODE_UNALIGNED) {
-          if (use_obvh) {
-            nsize = BVH_UNALIGNED_ONODE_SIZE;
-            nsize_bbox = BVH_UNALIGNED_ONODE_SIZE - 1;
-          }
-          else {
-            nsize = use_qbvh ? BVH_UNALIGNED_QNODE_SIZE : BVH_UNALIGNED_NODE_SIZE;
-            nsize_bbox = (use_qbvh) ? BVH_UNALIGNED_QNODE_SIZE - 1 : 0;
-          }
+          nsize = BVH_UNALIGNED_NODE_SIZE;
+          nsize_bbox = 0;
         }
         else {
-          if (use_obvh) {
-            nsize = BVH_ONODE_SIZE;
-            nsize_bbox = BVH_ONODE_SIZE - 1;
-          }
-          else {
-            nsize = (use_qbvh) ? BVH_QNODE_SIZE : BVH_NODE_SIZE;
-            nsize_bbox = (use_qbvh) ? BVH_QNODE_SIZE - 1 : 0;
-          }
+          nsize = BVH_NODE_SIZE;
+          nsize_bbox = 0;
         }
 
         memcpy(pack_nodes + pack_nodes_offset, bvh_nodes + i, nsize_bbox * sizeof(int4));
 
         /* Modify offsets into arrays */
         int4 data = bvh_nodes[i + nsize_bbox];
-
-        if (use_obvh) {
-          int4 data1 = bvh_nodes[i + nsize_bbox - 1];
-          data.z += (data.z < 0) ? -noffset_leaf : noffset;
-          data.w += (data.w < 0) ? -noffset_leaf : noffset;
-          data.x += (data.x < 0) ? -noffset_leaf : noffset;
-          data.y += (data.y < 0) ? -noffset_leaf : noffset;
-          data1.z += (data1.z < 0) ? -noffset_leaf : noffset;
-          data1.w += (data1.w < 0) ? -noffset_leaf : noffset;
-          data1.x += (data1.x < 0) ? -noffset_leaf : noffset;
-          data1.y += (data1.y < 0) ? -noffset_leaf : noffset;
-          pack_nodes[pack_nodes_offset + nsize_bbox] = data;
-          pack_nodes[pack_nodes_offset + nsize_bbox - 1] = data1;
-        }
-        else {
-          data.z += (data.z < 0) ? -noffset_leaf : noffset;
-          data.w += (data.w < 0) ? -noffset_leaf : noffset;
-          if (use_qbvh) {
-            data.x += (data.x < 0) ? -noffset_leaf : noffset;
-            data.y += (data.y < 0) ? -noffset_leaf : noffset;
-          }
-          pack_nodes[pack_nodes_offset + nsize_bbox] = data;
-        }
+        data.z += (data.z < 0) ? -noffset_leaf : noffset;
+        data.w += (data.w < 0) ? -noffset_leaf : noffset;
+        pack_nodes[pack_nodes_offset + nsize_bbox] = data;
 
         /* Usually this copies nothing, but we better
          * be prepared for possible node size extension.
index bdde38640c9ba9a95f6f591a8f549a8f2bda8191..6639e06b0bc4feeec1065785883850b548dfb8fc 100644 (file)
@@ -76,7 +76,7 @@ struct PackedBVH {
   }
 };
 
-enum BVH_TYPE { bvh2, bvh4, bvh8 };
+enum BVH_TYPE { bvh2 };
 
 /* BVH */
 
diff --git a/intern/cycles/bvh/bvh4.cpp b/intern/cycles/bvh/bvh4.cpp
deleted file mode 100644 (file)
index 143c3e5..0000000
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Adapted from code copyright 2009-2010 NVIDIA Corporation
- * Modifications Copyright 2011, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "bvh/bvh4.h"
-
-#include "render/mesh.h"
-#include "render/object.h"
-
-#include "bvh/bvh_node.h"
-#include "bvh/bvh_unaligned.h"
-
-CCL_NAMESPACE_BEGIN
-
-/* Can we avoid this somehow or make more generic?
- *
- * Perhaps we can merge nodes in actual tree and make our
- * life easier all over the place.
- */
-
-BVH4::BVH4(const BVHParams &params_,
-           const vector<Geometry *> &geometry_,
-           const vector<Object *> &objects_)
-    : BVH(params_, geometry_, objects_)
-{
-  params.bvh_layout = BVH_LAYOUT_BVH4;
-}
-
-namespace {
-
-BVHNode *bvh_node_merge_children_recursively(const BVHNode *node)
-{
-  if (node->is_leaf()) {
-    return new LeafNode(*reinterpret_cast<const LeafNode *>(node));
-  }
-  /* Collect nodes of one layer deeper, allowing us to have more children in an inner layer. */
-  assert(node->num_children() <= 2);
-  const BVHNode *children[4];
-  const BVHNode *child0 = node->get_child(0);
-  const BVHNode *child1 = node->get_child(1);
-  int num_children = 0;
-  if (child0->is_leaf()) {
-    children[num_children++] = child0;
-  }
-  else {
-    children[num_children++] = child0->get_child(0);
-    children[num_children++] = child0->get_child(1);
-  }
-  if (child1->is_leaf()) {
-    children[num_children++] = child1;
-  }
-  else {
-    children[num_children++] = child1->get_child(0);
-    children[num_children++] = child1->get_child(1);
-  }
-  /* Merge children in subtrees. */
-  BVHNode *children4[4];
-  for (int i = 0; i < num_children; ++i) {
-    children4[i] = bvh_node_merge_children_recursively(children[i]);
-  }
-  /* Allocate new node. */
-  BVHNode *node4 = new InnerNode(node->bounds, children4, num_children);
-  /* TODO(sergey): Consider doing this from the InnerNode() constructor.
-   * But in order to do this nicely need to think of how to pass all the
-   * parameters there. */
-  if (node->is_unaligned) {
-    node4->is_unaligned = true;
-    node4->aligned_space = new Transform();
-    *node4->aligned_space = *node->aligned_space;
-  }
-  return node4;
-}
-
-}  // namespace
-
-BVHNode *BVH4::widen_children_nodes(const BVHNode *root)
-{
-  if (root == NULL) {
-    return NULL;
-  }
-  if (root->is_leaf()) {
-    return const_cast<BVHNode *>(root);
-  }
-  BVHNode *root4 = bvh_node_merge_children_recursively(root);
-  /* TODO(sergey): Pack children nodes to parents which has less that 4
-   * children. */
-  return root4;
-}
-
-void BVH4::pack_leaf(const BVHStackEntry &e, const LeafNode *leaf)
-{
-  float4 data[BVH_QNODE_LEAF_SIZE];
-  memset(data, 0, sizeof(data));
-  if (leaf->num_triangles() == 1 && pack.prim_index[leaf->lo] == -1) {
-    /* object */
-    data[0].x = __int_as_float(~(leaf->lo));
-    data[0].y = __int_as_float(0);
-  }
-  else {
-    /* triangle */
-    data[0].x = __int_as_float(leaf->lo);
-    data[0].y = __int_as_float(leaf->hi);
-  }
-  data[0].z = __uint_as_float(leaf->visibility);
-  if (leaf->num_triangles() != 0) {
-    data[0].w = __uint_as_float(pack.prim_type[leaf->lo]);
-  }
-
-  memcpy(&pack.leaf_nodes[e.idx], data, sizeof(float4) * BVH_QNODE_LEAF_SIZE);
-}
-
-void BVH4::pack_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num)
-{
-  bool has_unaligned = false;
-  /* Check whether we have to create unaligned node or all nodes are aligned
-   * and we can cut some corner here.
-   */
-  if (params.use_unaligned_nodes) {
-    for (int i = 0; i < num; i++) {
-      if (en[i].node->is_unaligned) {
-        has_unaligned = true;
-        break;
-      }
-    }
-  }
-  if (has_unaligned) {
-    /* There's no unaligned children, pack into AABB node. */
-    pack_unaligned_inner(e, en, num);
-  }
-  else {
-    /* Create unaligned node with orientation transform for each of the
-     * children.
-     */
-    pack_aligned_inner(e, en, num);
-  }
-}
-
-void BVH4::pack_aligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num)
-{
-  BoundBox bounds[4];
-  int child[4];
-  for (int i = 0; i < num; ++i) {
-    bounds[i] = en[i].node->bounds;
-    child[i] = en[i].encodeIdx();
-  }
-  pack_aligned_node(
-      e.idx, bounds, child, e.node->visibility, e.node->time_from, e.node->time_to, num);
-}
-
-void BVH4::pack_aligned_node(int idx,
-                             const BoundBox *bounds,
-                             const int *child,
-                             const uint visibility,
-                             const float time_from,
-                             const float time_to,
-                             const int num)
-{
-  float4 data[BVH_QNODE_SIZE];
-  memset(data, 0, sizeof(data));
-
-  data[0].x = __uint_as_float(visibility & ~PATH_RAY_NODE_UNALIGNED);
-  data[0].y = time_from;
-  data[0].z = time_to;
-
-  for (int i = 0; i < num; i++) {
-    float3 bb_min = bounds[i].min;
-    float3 bb_max = bounds[i].max;
-
-    data[1][i] = bb_min.x;
-    data[2][i] = bb_max.x;
-    data[3][i] = bb_min.y;
-    data[4][i] = bb_max.y;
-    data[5][i] = bb_min.z;
-    data[6][i] = bb_max.z;
-
-    data[7][i] = __int_as_float(child[i]);
-  }
-
-  for (int i = num; i < 4; i++) {
-    /* We store BB which would never be recorded as intersection
-     * so kernel might safely assume there are always 4 child nodes.
-     */
-    data[1][i] = FLT_MAX;
-    data[2][i] = -FLT_MAX;
-
-    data[3][i] = FLT_MAX;
-    data[4][i] = -FLT_MAX;
-
-    data[5][i] = FLT_MAX;
-    data[6][i] = -FLT_MAX;
-
-    data[7][i] = __int_as_float(0);
-  }
-
-  memcpy(&pack.nodes[idx], data, sizeof(float4) * BVH_QNODE_SIZE);
-}
-
-void BVH4::pack_unaligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num)
-{
-  Transform aligned_space[4];
-  BoundBox bounds[4];
-  int child[4];
-  for (int i = 0; i < num; ++i) {
-    aligned_space[i] = en[i].node->get_aligned_space();
-    bounds[i] = en[i].node->bounds;
-    child[i] = en[i].encodeIdx();
-  }
-  pack_unaligned_node(e.idx,
-                      aligned_space,
-                      bounds,
-                      child,
-                      e.node->visibility,
-                      e.node->time_from,
-                      e.node->time_to,
-                      num);
-}
-
-void BVH4::pack_unaligned_node(int idx,
-                               const Transform *aligned_space,
-                               const BoundBox *bounds,
-                               const int *child,
-                               const uint visibility,
-                               const float time_from,
-                               const float time_to,
-                               const int num)
-{
-  float4 data[BVH_UNALIGNED_QNODE_SIZE];
-  memset(data, 0, sizeof(data));
-
-  data[0].x = __uint_as_float(visibility | PATH_RAY_NODE_UNALIGNED);
-  data[0].y = time_from;
-  data[0].z = time_to;
-
-  for (int i = 0; i < num; i++) {
-    Transform space = BVHUnaligned::compute_node_transform(bounds[i], aligned_space[i]);
-
-    data[1][i] = space.x.x;
-    data[2][i] = space.x.y;
-    data[3][i] = space.x.z;
-
-    data[4][i] = space.y.x;
-    data[5][i] = space.y.y;
-    data[6][i] = space.y.z;
-
-    data[7][i] = space.z.x;
-    data[8][i] = space.z.y;
-    data[9][i] = space.z.z;
-
-    data[10][i] = space.x.w;
-    data[11][i] = space.y.w;
-    data[12][i] = space.z.w;
-
-    data[13][i] = __int_as_float(child[i]);
-  }
-
-  for (int i = num; i < 4; i++) {
-    /* We store BB which would never be recorded as intersection
-     * so kernel might safely assume there are always 4 child nodes.
-     */
-
-    data[1][i] = NAN;
-    data[2][i] = NAN;
-    data[3][i] = NAN;
-
-    data[4][i] = NAN;
-    data[5][i] = NAN;
-    data[6][i] = NAN;
-
-    data[7][i] = NAN;
-    data[8][i] = NAN;
-    data[9][i] = NAN;
-
-    data[10][i] = NAN;
-    data[11][i] = NAN;
-    data[12][i] = NAN;
-
-    data[13][i] = __int_as_float(0);
-  }
-
-  memcpy(&pack.nodes[idx], data, sizeof(float4) * BVH_UNALIGNED_QNODE_SIZE);
-}
-
-/* Quad SIMD Nodes */
-
-void BVH4::pack_nodes(const BVHNode *root)
-{
-  /* Calculate size of the arrays required. */
-  const size_t num_nodes = root->getSubtreeSize(BVH_STAT_NODE_COUNT);
-  const size_t num_leaf_nodes = root->getSubtreeSize(BVH_STAT_LEAF_COUNT);
-  assert(num_leaf_nodes <= num_nodes);
-  const size_t num_inner_nodes = num_nodes - num_leaf_nodes;
-  size_t node_size;
-  if (params.use_unaligned_nodes) {
-    const size_t num_unaligned_nodes = root->getSubtreeSize(BVH_STAT_UNALIGNED_INNER_COUNT);
-    node_size = (num_unaligned_nodes * BVH_UNALIGNED_QNODE_SIZE) +
-                (num_inner_nodes - num_unaligned_nodes) * BVH_QNODE_SIZE;
-  }
-  else {
-    node_size = num_inner_nodes * BVH_QNODE_SIZE;
-  }
-  /* Resize arrays. */
-  pack.nodes.clear();
-  pack.leaf_nodes.clear();
-  /* For top level BVH, first merge existing BVH's so we know the offsets. */
-  if (params.top_level) {
-    pack_instances(node_size, num_leaf_nodes * BVH_QNODE_LEAF_SIZE);
-  }
-  else {
-    pack.nodes.resize(node_size);
-    pack.leaf_nodes.resize(num_leaf_nodes * BVH_QNODE_LEAF_SIZE);
-  }
-
-  int nextNodeIdx = 0, nextLeafNodeIdx = 0;
-
-  vector<BVHStackEntry> stack;
-  stack.reserve(BVHParams::MAX_DEPTH * 2);
-  if (root->is_leaf()) {
-    stack.push_back(BVHStackEntry(root, nextLeafNodeIdx++));
-  }
-  else {
-    stack.push_back(BVHStackEntry(root, nextNodeIdx));
-    nextNodeIdx += root->has_unaligned() ? BVH_UNALIGNED_QNODE_SIZE : BVH_QNODE_SIZE;
-  }
-
-  while (stack.size()) {
-    BVHStackEntry e = stack.back();
-    stack.pop_back();
-
-    if (e.node->is_leaf()) {
-      /* leaf node */
-      const LeafNode *leaf = reinterpret_cast<const LeafNode *>(e.node);
-      pack_leaf(e, leaf);
-    }
-    else {
-      /* Inner node. */
-      /* Collect nodes. */
-      const BVHNode *children[4];
-      const int num_children = e.node->num_children();
-      /* Push entries on the stack. */
-      for (int i = 0; i < num_children; ++i) {
-        int idx;
-        children[i] = e.node->get_child(i);
-        assert(children[i] != NULL);
-        if (children[i]->is_leaf()) {
-          idx = nextLeafNodeIdx++;
-        }
-        else {
-          idx = nextNodeIdx;
-          nextNodeIdx += children[i]->has_unaligned() ? BVH_UNALIGNED_QNODE_SIZE : BVH_QNODE_SIZE;
-        }
-        stack.push_back(BVHStackEntry(children[i], idx));
-      }
-      /* Set node. */
-      pack_inner(e, &stack[stack.size() - num_children], num_children);
-    }
-  }
-
-  assert(node_size == nextNodeIdx);
-  /* Root index to start traversal at, to handle case of single leaf node. */
-  pack.root_index = (root->is_leaf()) ? -1 : 0;
-}
-
-void BVH4::refit_nodes()
-{
-  assert(!params.top_level);
-
-  BoundBox bbox = BoundBox::empty;
-  uint visibility = 0;
-  refit_node(0, (pack.root_index == -1) ? true : false, bbox, visibility);
-}
-
-void BVH4::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility)
-{
-  if (leaf) {
-    /* Refit leaf node. */
-    int4 *data = &pack.leaf_nodes[idx];
-    int4 c = data[0];
-
-    BVH::refit_primitives(c.x, c.y, bbox, visibility);
-
-    /* TODO(sergey): This is actually a copy of pack_leaf(),
-     * but this chunk of code only knows actual data and has
-     * no idea about BVHNode.
-     *
-     * Would be nice to de-duplicate code, but trying to make
-     * making code more general ends up in much nastier code
-     * in my opinion so far.
-     *
-     * Same applies to the inner nodes case below.
-     */
-    float4 leaf_data[BVH_QNODE_LEAF_SIZE];
-    leaf_data[0].x = __int_as_float(c.x);
-    leaf_data[0].y = __int_as_float(c.y);
-    leaf_data[0].z = __uint_as_float(visibility);
-    leaf_data[0].w = __uint_as_float(c.w);
-    memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4) * BVH_QNODE_LEAF_SIZE);
-  }
-  else {
-    int4 *data = &pack.nodes[idx];
-    bool is_unaligned = (data[0].x & PATH_RAY_NODE_UNALIGNED) != 0;
-    int4 c;
-    if (is_unaligned) {
-      c = data[13];
-    }
-    else {
-      c = data[7];
-    }
-    /* Refit inner node, set bbox from children. */
-    BoundBox child_bbox[4] = {BoundBox::empty, BoundBox::empty, BoundBox::empty, BoundBox::empty};
-    uint child_visibility[4] = {0};
-    int num_nodes = 0;
-
-    for (int i = 0; i < 4; ++i) {
-      if (c[i] != 0) {
-        refit_node((c[i] < 0) ? -c[i] - 1 : c[i], (c[i] < 0), child_bbox[i], child_visibility[i]);
-        ++num_nodes;
-        bbox.grow(child_bbox[i]);
-        visibility |= child_visibility[i];
-      }
-    }
-
-    if (is_unaligned) {
-      Transform aligned_space[4] = {
-          transform_identity(), transform_identity(), transform_identity(), transform_identity()};
-      pack_unaligned_node(
-          idx, aligned_space, child_bbox, &c[0], visibility, 0.0f, 1.0f, num_nodes);
-    }
-    else {
-      pack_aligned_node(idx, child_bbox, &c[0], visibility, 0.0f, 1.0f, num_nodes);
-    }
-  }
-}
-
-CCL_NAMESPACE_END
diff --git a/intern/cycles/bvh/bvh4.h b/intern/cycles/bvh/bvh4.h
deleted file mode 100644 (file)
index afbb900..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Adapted from code copyright 2009-2010 NVIDIA Corporation
- * Modifications Copyright 2011, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __BVH4_H__
-#define __BVH4_H__
-
-#include "bvh/bvh.h"
-#include "bvh/bvh_params.h"
-
-#include "util/util_types.h"
-#include "util/util_vector.h"
-
-CCL_NAMESPACE_BEGIN
-
-class BVHNode;
-struct BVHStackEntry;
-class BVHParams;
-class BoundBox;
-class LeafNode;
-class Object;
-class Progress;
-
-#define BVH_QNODE_SIZE 8
-#define BVH_QNODE_LEAF_SIZE 1
-#define BVH_UNALIGNED_QNODE_SIZE 14
-
-/* BVH4
- *
- * Quad BVH, with each node having four children, to use with SIMD instructions.
- */
-class BVH4 : public BVH {
- protected:
-  /* constructor */
-  friend class BVH;
-  BVH4(const BVHParams &params,
-       const vector<Geometry *> &geometry,
-       const vector<Object *> &objects);
-
-  /* Building process. */
-  virtual BVHNode *widen_children_nodes(const BVHNode *root) override;
-
-  /* pack */
-  void pack_nodes(const BVHNode *root) override;
-
-  void pack_leaf(const BVHStackEntry &e, const LeafNode *leaf);
-  void pack_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num);
-
-  void pack_aligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num);
-  void pack_aligned_node(int idx,
-                         const BoundBox *bounds,
-                         const int *child,
-                         const uint visibility,
-                         const float time_from,
-                         const float time_to,
-                         const int num);
-
-  void pack_unaligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num);
-  void pack_unaligned_node(int idx,
-                           const Transform *aligned_space,
-                           const BoundBox *bounds,
-                           const int *child,
-                           const uint visibility,
-                           const float time_from,
-                           const float time_to,
-                           const int num);
-
-  /* refit */
-  void refit_nodes() override;
-  void refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility);
-};
-
-CCL_NAMESPACE_END
-
-#endif /* __BVH4_H__ */
diff --git a/intern/cycles/bvh/bvh8.cpp b/intern/cycles/bvh/bvh8.cpp
deleted file mode 100644 (file)
index b805865..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Original code Copyright 2017, Intel Corporation
- * Modifications Copyright 2018, Blender Foundation.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "bvh/bvh8.h"
-
-#include "render/hair.h"
-#include "render/mesh.h"
-#include "render/object.h"
-
-#include "bvh/bvh_node.h"
-#include "bvh/bvh_unaligned.h"
-
-CCL_NAMESPACE_BEGIN
-
-BVH8::BVH8(const BVHParams &params_,
-           const vector<Geometry *> &geometry_,
-           const vector<Object *> &objects_)
-    : BVH(params_, geometry_, objects_)
-{
-}
-
-namespace {
-
-BVHNode *bvh_node_merge_children_recursively(const BVHNode *node)
-{
-  if (node->is_leaf()) {
-    return new LeafNode(*reinterpret_cast<const LeafNode *>(node));
-  }
-  /* Collect nodes of two layer deeper, allowing us to have more childrem in
-   * an inner layer. */
-  assert(node->num_children() <= 2);
-  const BVHNode *children[8];
-  const BVHNode *child0 = node->get_child(0);
-  const BVHNode *child1 = node->get_child(1);
-  int num_children = 0;
-  if (child0->is_leaf()) {
-    children[num_children++] = child0;
-  }
-  else {
-    const BVHNode *child00 = child0->get_child(0), *child01 = child0->get_child(1);
-    if (child00->is_leaf()) {
-      children[num_children++] = child00;
-    }
-    else {
-      children[num_children++] = child00->get_child(0);
-      children[num_children++] = child00->get_child(1);
-    }
-    if (child01->is_leaf()) {
-      children[num_children++] = child01;
-    }
-    else {
-      children[num_children++] = child01->get_child(0);
-      children[num_children++] = child01->get_child(1);
-    }
-  }
-  if (child1->is_leaf()) {
-    children[num_children++] = child1;
-  }
-  else {
-    const BVHNode *child10 = child1->get_child(0), *child11 = child1->get_child(1);
-    if (child10->is_leaf()) {
-      children[num_children++] = child10;
-    }
-    else {
-      children[num_children++] = child10->get_child(0);
-      children[num_children++] = child10->get_child(1);
-    }
-    if (child11->is_leaf()) {
-      children[num_children++] = child11;
-    }
-    else {
-      children[num_children++] = child11->get_child(0);
-      children[num_children++] = child11->get_child(1);
-    }
-  }
-  /* Merge children in subtrees. */
-  BVHNode *children4[8];
-  for (int i = 0; i < num_children; ++i) {
-    children4[i] = bvh_node_merge_children_recursively(children[i]);
-  }
-  /* Allocate new node. */
-  BVHNode *node8 = new InnerNode(node->bounds, children4, num_children);
-  /* TODO(sergey): Consider doing this from the InnerNode() constructor.
-   * But in order to do this nicely need to think of how to pass all the
-   * parameters there. */
-  if (node->is_unaligned) {
-    node8->is_unaligned = true;
-    node8->aligned_space = new Transform();
-    *node8->aligned_space = *node->aligned_space;
-  }
-  return node8;
-}
-
-}  // namespace
-
-BVHNode *BVH8::widen_children_nodes(const BVHNode *root)
-{
-  if (root == NULL) {
-    return NULL;
-  }
-  if (root->is_leaf()) {
-    return const_cast<BVHNode *>(root);
-  }
-  BVHNode *root8 = bvh_node_merge_children_recursively(root);
-  /* TODO(sergey): Pack children nodes to parents which has less that 4
-   * children. */
-  return root8;
-}
-
-void BVH8::pack_leaf(const BVHStackEntry &e, const LeafNode *leaf)
-{
-  float4 data[BVH_ONODE_LEAF_SIZE];
-  memset(data, 0, sizeof(data));
-  if (leaf->num_triangles() == 1 && pack.prim_index[leaf->lo] == -1) {
-    /* object */
-    data[0].x = __int_as_float(~(leaf->lo));
-    data[0].y = __int_as_float(0);
-  }
-  else {
-    /* triangle */
-    data[0].x = __int_as_float(leaf->lo);
-    data[0].y = __int_as_float(leaf->hi);
-  }
-  data[0].z = __uint_as_float(leaf->visibility);
-  if (leaf->num_triangles() != 0) {
-    data[0].w = __uint_as_float(pack.prim_type[leaf->lo]);
-  }
-
-  memcpy(&pack.leaf_nodes[e.idx], data, sizeof(float4) * BVH_ONODE_LEAF_SIZE);
-}
-
-void BVH8::pack_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num)
-{
-  bool has_unaligned = false;
-  /* Check whether we have to create unaligned node or all nodes are aligned
-   * and we can cut some corner here.
-   */
-  if (params.use_unaligned_nodes) {
-    for (int i = 0; i < num; i++) {
-      if (en[i].node->is_unaligned) {
-        has_unaligned = true;
-        break;
-      }
-    }
-  }
-  if (has_unaligned) {
-    /* There's no unaligned children, pack into AABB node. */
-    pack_unaligned_inner(e, en, num);
-  }
-  else {
-    /* Create unaligned node with orientation transform for each of the
-     * children.
-     */
-    pack_aligned_inner(e, en, num);
-  }
-}
-
-void BVH8::pack_aligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num)
-{
-  BoundBox bounds[8];
-  int child[8];
-  for (int i = 0; i < num; ++i) {
-    bounds[i] = en[i].node->bounds;
-    child[i] = en[i].encodeIdx();
-  }
-  pack_aligned_node(
-      e.idx, bounds, child, e.node->visibility, e.node->time_from, e.node->time_to, num);
-}
-
-void BVH8::pack_aligned_node(int idx,
-                             const BoundBox *bounds,
-                             const int *child,
-                             const uint visibility,
-                             const float time_from,
-                             const float time_to,
-                             const int num)
-{
-  float8 data[8];
-  memset(data, 0, sizeof(data));
-
-  data[0].a = __uint_as_float(visibility & ~PATH_RAY_NODE_UNALIGNED);
-  data[0].b = time_from;
-  data[0].c = time_to;
-
-  for (int i = 0; i < num; i++) {
-    float3 bb_min = bounds[i].min;
-    float3 bb_max = bounds[i].max;
-
-    data[1][i] = bb_min.x;
-    data[2][i] = bb_max.x;
-    data[3][i] = bb_min.y;
-    data[4][i] = bb_max.y;
-    data[5][i] = bb_min.z;
-    data[6][i] = bb_max.z;
-
-    data[7][i] = __int_as_float(child[i]);
-  }
-
-  for (int i = num; i < 8; i++) {
-    /* We store BB which would never be recorded as intersection
-     * so kernel might safely assume there are always 4 child nodes.
-     */
-    data[1][i] = FLT_MAX;
-    data[2][i] = -FLT_MAX;
-
-    data[3][i] = FLT_MAX;
-    data[4][i] = -FLT_MAX;
-
-    data[5][i] = FLT_MAX;
-    data[6][i] = -FLT_MAX;
-
-    data[7][i] = __int_as_float(0);
-  }
-
-  memcpy(&pack.nodes[idx], data, sizeof(float4) * BVH_ONODE_SIZE);
-}
-
-void BVH8::pack_unaligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num)
-{
-  Transform aligned_space[8];
-  BoundBox bounds[8];
-  int child[8];
-  for (int i = 0; i < num; ++i) {
-    aligned_space[i] = en[i].node->get_aligned_space();
-    bounds[i] = en[i].node->bounds;
-    child[i] = en[i].encodeIdx();
-  }
-  pack_unaligned_node(e.idx,
-                      aligned_space,
-                      bounds,
-                      child,
-                      e.node->visibility,
-                      e.node->time_from,
-                      e.node->time_to,
-                      num);
-}
-
-void BVH8::pack_unaligned_node(int idx,
-                               const Transform *aligned_space,
-                               const BoundBox *bounds,
-                               const int *child,
-                               const uint visibility,
-                               const float time_from,
-                               const float time_to,
-                               const int num)
-{
-  float8 data[BVH_UNALIGNED_ONODE_SIZE];
-  memset(data, 0, sizeof(data));
-
-  data[0].a = __uint_as_float(visibility | PATH_RAY_NODE_UNALIGNED);
-  data[0].b = time_from;
-  data[0].c = time_to;
-
-  for (int i = 0; i < num; i++) {
-    Transform space = BVHUnaligned::compute_node_transform(bounds[i], aligned_space[i]);
-
-    data[1][i] = space.x.x;
-    data[2][i] = space.x.y;
-    data[3][i] = space.x.z;
-
-    data[4][i] = space.y.x;
-    data[5][i] = space.y.y;
-    data[6][i] = space.y.z;
-
-    data[7][i] = space.z.x;
-    data[8][i] = space.z.y;
-    data[9][i] = space.z.z;
-
-    data[10][i] = space.x.w;
-    data[11][i] = space.y.w;
-    data[12][i] = space.z.w;
-
-    data[13][i] = __int_as_float(child[i]);
-  }
-
-  for (int i = num; i < 8; i++) {
-    /* We store BB which would never be recorded as intersection
-     * so kernel might safely assume there are always 4 child nodes.
-     */
-
-    data[1][i] = NAN;
-    data[2][i] = NAN;
-    data[3][i] = NAN;
-
-    data[4][i] = NAN;
-    data[5][i] = NAN;
-    data[6][i] = NAN;
-
-    data[7][i] = NAN;
-    data[8][i] = NAN;
-    data[9][i] = NAN;
-
-    data[10][i] = NAN;
-    data[11][i] = NAN;
-    data[12][i] = NAN;
-
-    data[13][i] = __int_as_float(0);
-  }
-
-  memcpy(&pack.nodes[idx], data, sizeof(float4) * BVH_UNALIGNED_ONODE_SIZE);
-}
-
-/* Quad SIMD Nodes */
-
-void BVH8::pack_nodes(const BVHNode *root)
-{
-  /* Calculate size of the arrays required. */
-  const size_t num_nodes = root->getSubtreeSize(BVH_STAT_NODE_COUNT);
-  const size_t num_leaf_nodes = root->getSubtreeSize(BVH_STAT_LEAF_COUNT);
-  assert(num_leaf_nodes <= num_nodes);
-  const size_t num_inner_nodes = num_nodes - num_leaf_nodes;
-  size_t node_size;
-  if (params.use_unaligned_nodes) {
-    const size_t num_unaligned_nodes = root->getSubtreeSize(BVH_STAT_UNALIGNED_INNER_COUNT);
-    node_size = (num_unaligned_nodes * BVH_UNALIGNED_ONODE_SIZE) +
-                (num_inner_nodes - num_unaligned_nodes) * BVH_ONODE_SIZE;
-  }
-  else {
-    node_size = num_inner_nodes * BVH_ONODE_SIZE;
-  }
-  /* Resize arrays. */
-  pack.nodes.clear();
-  pack.leaf_nodes.clear();
-  /* For top level BVH, first merge existing BVH's so we know the offsets. */
-  if (params.top_level) {
-    pack_instances(node_size, num_leaf_nodes * BVH_ONODE_LEAF_SIZE);
-  }
-  else {
-    pack.nodes.resize(node_size);
-    pack.leaf_nodes.resize(num_leaf_nodes * BVH_ONODE_LEAF_SIZE);
-  }
-
-  int nextNodeIdx = 0, nextLeafNodeIdx = 0;
-
-  vector<BVHStackEntry> stack;
-  stack.reserve(BVHParams::MAX_DEPTH * 2);
-  if (root->is_leaf()) {
-    stack.push_back(BVHStackEntry(root, nextLeafNodeIdx++));
-  }
-  else {
-    stack.push_back(BVHStackEntry(root, nextNodeIdx));
-    nextNodeIdx += root->has_unaligned() ? BVH_UNALIGNED_ONODE_SIZE : BVH_ONODE_SIZE;
-  }
-
-  while (stack.size()) {
-    BVHStackEntry e = stack.back();
-    stack.pop_back();
-
-    if (e.node->is_leaf()) {
-      /* leaf node */
-      const LeafNode *leaf = reinterpret_cast<const LeafNode *>(e.node);
-      pack_leaf(e, leaf);
-    }
-    else {
-      /* Inner node. */
-      /* Collect nodes. */
-      const BVHNode *children[8];
-      int num_children = e.node->num_children();
-      /* Push entries on the stack. */
-      for (int i = 0; i < num_children; ++i) {
-        int idx;
-        children[i] = e.node->get_child(i);
-        if (children[i]->is_leaf()) {
-          idx = nextLeafNodeIdx++;
-        }
-        else {
-          idx = nextNodeIdx;
-          nextNodeIdx += children[i]->has_unaligned() ? BVH_UNALIGNED_ONODE_SIZE : BVH_ONODE_SIZE;
-        }
-        stack.push_back(BVHStackEntry(children[i], idx));
-      }
-      /* Set node. */
-      pack_inner(e, &stack[stack.size() - num_children], num_children);
-    }
-  }
-
-  assert(node_size == nextNodeIdx);
-  /* Root index to start traversal at, to handle case of single leaf node. */
-  pack.root_index = (root->is_leaf()) ? -1 : 0;
-}
-
-void BVH8::refit_nodes()
-{
-  assert(!params.top_level);
-
-  BoundBox bbox = BoundBox::empty;
-  uint visibility = 0;
-  refit_node(0, (pack.root_index == -1) ? true : false, bbox, visibility);
-}
-
-void BVH8::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility)
-{
-  if (leaf) {
-    int4 *data = &pack.leaf_nodes[idx];
-    int4 c = data[0];
-    /* Refit leaf node. */
-    for (int prim = c.x; prim < c.y; prim++) {
-      int pidx = pack.prim_index[prim];
-      int tob = pack.prim_object[prim];
-      Object *ob = objects[tob];
-
-      if (pidx == -1) {
-        /* Object instance. */
-        bbox.grow(ob->bounds);
-      }
-      else {
-        /* Primitives. */
-        if (pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) {
-          /* Curves. */
-          const Hair *hair = static_cast<const Hair *>(ob->geometry);
-          int prim_offset = (params.top_level) ? hair->prim_offset : 0;
-          Hair::Curve curve = hair->get_curve(pidx - prim_offset);
-          int k = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]);
-
-          curve.bounds_grow(k, &hair->curve_keys[0], &hair->curve_radius[0], bbox);
-
-          /* Motion curves. */
-          if (hair->use_motion_blur) {
-            Attribute *attr = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
-
-            if (attr) {
-              size_t hair_size = hair->curve_keys.size();
-              size_t steps = hair->motion_steps - 1;
-              float3 *key_steps = attr->data_float3();
-
-              for (size_t i = 0; i < steps; i++) {
-                curve.bounds_grow(k, key_steps + i * hair_size, &hair->curve_radius[0], bbox);
-              }
-            }
-          }
-        }
-        else {
-          /* Triangles. */
-          const Mesh *mesh = static_cast<const Mesh *>(ob->geometry);
-          int prim_offset = (params.top_level) ? mesh->prim_offset : 0;
-          Mesh::Triangle triangle = mesh->get_triangle(pidx - prim_offset);
-          const float3 *vpos = &mesh->verts[0];
-
-          triangle.bounds_grow(vpos, bbox);
-
-          /* Motion triangles. */
-          if (mesh->use_motion_blur) {
-            Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
-
-            if (attr) {
-              size_t mesh_size = mesh->verts.size();
-              size_t steps = mesh->motion_steps - 1;
-              float3 *vert_steps = attr->data_float3();
-
-              for (size_t i = 0; i < steps; i++) {
-                triangle.bounds_grow(vert_steps + i * mesh_size, bbox);
-              }
-            }
-          }
-        }
-      }
-
-      visibility |= ob->visibility;
-    }
-
-    float4 leaf_data[BVH_ONODE_LEAF_SIZE];
-    leaf_data[0].x = __int_as_float(c.x);
-    leaf_data[0].y = __int_as_float(c.y);
-    leaf_data[0].z = __uint_as_float(visibility);
-    leaf_data[0].w = __uint_as_float(c.w);
-    memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4) * BVH_ONODE_LEAF_SIZE);
-  }
-  else {
-    float8 *data = (float8 *)&pack.nodes[idx];
-    bool is_unaligned = (__float_as_uint(data[0].a) & PATH_RAY_NODE_UNALIGNED) != 0;
-    /* Refit inner node, set bbox from children. */
-    BoundBox child_bbox[8] = {BoundBox::empty,
-                              BoundBox::empty,
-                              BoundBox::empty,
-                              BoundBox::empty,
-                              BoundBox::empty,
-                              BoundBox::empty,
-                              BoundBox::empty,
-                              BoundBox::empty};
-    int child[8];
-    uint child_visibility[8] = {0};
-    int num_nodes = 0;
-
-    for (int i = 0; i < 8; ++i) {
-      child[i] = __float_as_int(data[(is_unaligned) ? 13 : 7][i]);
-
-      if (child[i] != 0) {
-        refit_node((child[i] < 0) ? -child[i] - 1 : child[i],
-                   (child[i] < 0),
-                   child_bbox[i],
-                   child_visibility[i]);
-        ++num_nodes;
-        bbox.grow(child_bbox[i]);
-        visibility |= child_visibility[i];
-      }
-    }
-
-    if (is_unaligned) {
-      Transform aligned_space[8] = {transform_identity(),
-                                    transform_identity(),
-                                    transform_identity(),
-                                    transform_identity(),
-                                    transform_identity(),
-                                    transform_identity(),
-                                    transform_identity(),
-                                    transform_identity()};
-      pack_unaligned_node(
-          idx, aligned_space, child_bbox, child, visibility, 0.0f, 1.0f, num_nodes);
-    }
-    else {
-      pack_aligned_node(idx, child_bbox, child, visibility, 0.0f, 1.0f, num_nodes);
-    }
-  }
-}
-
-CCL_NAMESPACE_END
diff --git a/intern/cycles/bvh/bvh8.h b/intern/cycles/bvh/bvh8.h
deleted file mode 100644 (file)
index d23fa52..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Original code Copyright 2017, Intel Corporation
- * Modifications Copyright 2018, Blender Foundation.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __BVH8_H__
-#define __BVH8_H__
-
-#include "bvh/bvh.h"
-#include "bvh/bvh_params.h"
-
-#include "util/util_types.h"
-#include "util/util_vector.h"
-
-CCL_NAMESPACE_BEGIN
-
-class BVHNode;
-struct BVHStackEntry;
-class BVHParams;
-class BoundBox;
-class LeafNode;
-class Object;
-class Progress;
-
-#define BVH_ONODE_SIZE 16
-#define BVH_ONODE_LEAF_SIZE 1
-#define BVH_UNALIGNED_ONODE_SIZE 28
-
-/* BVH8
- *
- * Octo BVH, with each node having eight children, to use with SIMD instructions.
- */
-class BVH8 : public BVH {
- protected:
-  /* constructor */
-  friend class BVH;
-  BVH8(const BVHParams &params,
-       const vector<Geometry *> &geometry,
-       const vector<Object *> &objects);
-
-  /* Building process. */
-  virtual BVHNode *widen_children_nodes(const BVHNode *root) override;
-
-  /* pack */
-  void pack_nodes(const BVHNode *root) override;
-
-  void pack_leaf(const BVHStackEntry &e, const LeafNode *leaf);
-  void pack_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num);
-
-  void pack_aligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num);
-  void pack_aligned_node(int idx,
-                         const BoundBox *bounds,
-                         const int *child,
-                         const uint visibility,
-                         const float time_from,
-                         const float time_to,
-                         const int num);
-
-  void pack_unaligned_inner(const BVHStackEntry &e, const BVHStackEntry *en, int num);
-  void pack_unaligned_node(int idx,
-                           const Transform *aligned_space,
-                           const BoundBox *bounds,
-                           const int *child,
-                           const uint visibility,
-                           const float time_from,
-                           const float time_to,
-                           const int num);
-
-  /* refit */
-  void refit_nodes() override;
-  void refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility);
-};
-
-CCL_NAMESPACE_END
-
-#endif /* __BVH8_H__ */
index bc85d9386adf48432436cca098681ebf0513bce3..a36c76c852a317b570b3453d2dce5a37c9f2ff48 100644 (file)
@@ -345,17 +345,6 @@ class CPUDevice : public Device {
   virtual BVHLayoutMask get_bvh_layout_mask() const
   {
     BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_BVH2;
-    if (DebugFlags().cpu.has_sse2() && system_cpu_support_sse2()) {
-      bvh_layout_mask |= BVH_LAYOUT_BVH4;
-    }
-    /* MSVC does not support the -march=native switch and you always end up  */
-    /* with an sse2 kernel when you use WITH_KERNEL_NATIVE. We *cannot* feed */
-    /* that kernel BVH8 even if the CPU flags would allow for it. */
-#if (defined(__x86_64__) || defined(_M_X64)) && !(defined(_MSC_VER) && defined(WITH_KERNEL_NATIVE))
-    if (DebugFlags().cpu.has_avx2() && system_cpu_support_avx2()) {
-      bvh_layout_mask |= BVH_LAYOUT_BVH8;
-    }
-#endif
 #ifdef WITH_EMBREE
     bvh_layout_mask |= BVH_LAYOUT_EMBREE;
 #endif /* WITH_EMBREE */
index 35339abff458def243597274ed5e9e5576cda958..7cc0d32d521bc71b3b88a1bfeee3d5174c7c078a 100644 (file)
@@ -81,18 +81,6 @@ set(SRC_BVH_HEADERS
   bvh/bvh_types.h
   bvh/bvh_volume.h
   bvh/bvh_volume_all.h
-  bvh/qbvh_nodes.h
-  bvh/qbvh_shadow_all.h
-  bvh/qbvh_local.h
-  bvh/qbvh_traversal.h
-  bvh/qbvh_volume.h
-  bvh/qbvh_volume_all.h
-  bvh/obvh_nodes.h
-  bvh/obvh_shadow_all.h
-  bvh/obvh_local.h
-  bvh/obvh_traversal.h
-  bvh/obvh_volume.h
-  bvh/obvh_volume_all.h
   bvh/bvh_embree.h
 )
 
index bf48d3dd82622d76b836e62ffef36269c290884c..80b58f463298b7170847998c2256c76494f9ac4a 100644 (file)
@@ -35,14 +35,6 @@ CCL_NAMESPACE_BEGIN
 
 #ifndef __KERNEL_OPTIX__
 
-/* Common QBVH functions. */
-#  ifdef __QBVH__
-#    include "kernel/bvh/qbvh_nodes.h"
-#    ifdef __KERNEL_AVX2__
-#      include "kernel/bvh/obvh_nodes.h"
-#    endif
-#  endif
-
 /* Regular BVH traversal */
 
 #  include "kernel/bvh/bvh_nodes.h"
index 7a069ef1108b0879b70e1a9026fdde6872ac6077..4006c9c1632a6fbcfd562059c61ea1ffdfa29607 100644 (file)
  * limitations under the License.
  */
 
-#ifdef __QBVH__
-#  include "kernel/bvh/qbvh_local.h"
-#  ifdef __KERNEL_AVX2__
-#    include "kernel/bvh/obvh_local.h"
-#  endif
-#endif
-
 #if BVH_FEATURE(BVH_HAIR)
 #  define NODE_INTERSECT bvh_node_intersect
 #else
@@ -88,26 +81,6 @@ ccl_device_inline
     object = local_object;
   }
 
-#if defined(__KERNEL_SSE2__)
-  const shuffle_swap_t shuf_identity = shuffle_swap_identity();
-  const shuffle_swap_t shuf_swap = shuffle_swap_swap();
-
-  const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-  ssef Psplat[3], idirsplat[3];
-#  if BVH_FEATURE(BVH_HAIR)
-  ssef tnear(0.0f), tfar(isect_t);
-#  endif
-  shuffle_swap_t shufflexyz[3];
-
-  Psplat[0] = ssef(P.x);
-  Psplat[1] = ssef(P.y);
-  Psplat[2] = ssef(P.z);
-
-  ssef tsplat(0.0f, 0.0f, -isect_t, -isect_t);
-
-  gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#endif
-
   /* traversal loop */
   do {
     do {
@@ -117,33 +90,16 @@ ccl_device_inline
         float dist[2];
         float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
 
-#if !defined(__KERNEL_SSE2__)
         traverse_mask = NODE_INTERSECT(kg,
                                        P,
-#  if BVH_FEATURE(BVH_HAIR)
+#if BVH_FEATURE(BVH_HAIR)
                                        dir,
-#  endif
+#endif
                                        idir,
                                        isect_t,
                                        node_addr,
                                        PATH_RAY_ALL_VISIBILITY,
                                        dist);
-#else  // __KERNEL_SSE2__
-        traverse_mask = NODE_INTERSECT(kg,
-                                       P,
-                                       dir,
-#  if BVH_FEATURE(BVH_HAIR)
-                                       tnear,
-                                       tfar,
-#  endif
-                                       tsplat,
-                                       Psplat,
-                                       idirsplat,
-                                       shufflexyz,
-                                       node_addr,
-                                       PATH_RAY_ALL_VISIBILITY,
-                                       dist);
-#endif  // __KERNEL_SSE2__
 
         node_addr = __float_as_int(cnodes.z);
         node_addr_child1 = __float_as_int(cnodes.w);
@@ -247,20 +203,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          uint *lcg_state,
                                          int max_hits)
 {
-  switch (kernel_data.bvh.bvh_layout) {
-#ifdef __KERNEL_AVX2__
-    case BVH_LAYOUT_BVH8:
-      return BVH_FUNCTION_FULL_NAME(OBVH)(kg, ray, local_isect, local_object, lcg_state, max_hits);
-#endif
-#ifdef __QBVH__
-    case BVH_LAYOUT_BVH4:
-      return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, local_isect, local_object, lcg_state, max_hits);
-#endif
-    case BVH_LAYOUT_BVH2:
-      return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, local_isect, local_object, lcg_state, max_hits);
-  }
-  kernel_assert(!"Should not happen");
-  return false;
+  return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, local_isect, local_object, lcg_state, max_hits);
 }
 
 #undef BVH_FUNCTION_NAME
index db598d1c7fabe2a30187576587a3b3922762c8f0..5367bdb633c0e7b52740ae489268a7cae16f9449 100644 (file)
@@ -28,7 +28,6 @@ ccl_device_forceinline Transform bvh_unaligned_node_fetch_space(KernelGlobals *k
   return space;
 }
 
-#if !defined(__KERNEL_SSE2__)
 ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
                                                       const float3 P,
                                                       const float3 idir,
@@ -39,9 +38,9 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
 {
 
   /* fetch node data */
-#  ifdef __VISIBILITY_FLAG__
+#ifdef __VISIBILITY_FLAG__
   float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-#  endif
+#endif
   float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1);
   float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2);
   float4 node2 = kernel_tex_fetch(__bvh_nodes, node_addr + 3);
@@ -68,13 +67,13 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
   dist[0] = c0min;
   dist[1] = c1min;
 
-#  ifdef __VISIBILITY_FLAG__
+#ifdef __VISIBILITY_FLAG__
   /* this visibility test gives a 5% performance hit, how to solve? */
   return (((c0max >= c0min) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
          (((c1max >= c1min) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
-#  else
+#else
   return ((c0max >= c0min) ? 1 : 0) | ((c1max >= c1min) ? 2 : 0);
-#  endif
+#endif
 }
 
 ccl_device_forceinline bool bvh_unaligned_node_intersect_child(KernelGlobals *kg,
@@ -113,21 +112,21 @@ ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
                                                         float dist[2])
 {
   int mask = 0;
-#  ifdef __VISIBILITY_FLAG__
+#ifdef __VISIBILITY_FLAG__
   float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-#  endif
+#endif
   if (bvh_unaligned_node_intersect_child(kg, P, dir, t, node_addr, 0, &dist[0])) {
-#  ifdef __VISIBILITY_FLAG__
+#ifdef __VISIBILITY_FLAG__
     if ((__float_as_uint(cnodes.x) & visibility))
-#  endif
+#endif
     {
       mask |= 1;
     }
   }
   if (bvh_unaligned_node_intersect_child(kg, P, dir, t, node_addr, 1, &dist[1])) {
-#  ifdef __VISIBILITY_FLAG__
+#ifdef __VISIBILITY_FLAG__
     if ((__float_as_uint(cnodes.y) & visibility))
-#  endif
+#endif
     {
       mask |= 2;
     }
@@ -152,125 +151,3 @@ ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg,
     return bvh_aligned_node_intersect(kg, P, idir, t, node_addr, visibility, dist);
   }
 }
-
-#else /* !defined(__KERNEL_SSE2__) */
-
-int ccl_device_forceinline bvh_aligned_node_intersect(KernelGlobals *kg,
-                                                      const float3 &P,
-                                                      const float3 &dir,
-                                                      const ssef &tsplat,
-                                                      const ssef Psplat[3],
-                                                      const ssef idirsplat[3],
-                                                      const shuffle_swap_t shufflexyz[3],
-                                                      const int node_addr,
-                                                      const uint visibility,
-                                                      float dist[2])
-{
-  /* Intersect two child bounding boxes, SSE3 version adapted from Embree */
-  const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-
-  /* fetch node data */
-  const ssef *bvh_nodes = (ssef *)kg->__bvh_nodes.data + node_addr;
-
-  /* intersect ray against child nodes */
-  const ssef tminmaxx = (shuffle_swap(bvh_nodes[1], shufflexyz[0]) - Psplat[0]) * idirsplat[0];
-  const ssef tminmaxy = (shuffle_swap(bvh_nodes[2], shufflexyz[1]) - Psplat[1]) * idirsplat[1];
-  const ssef tminmaxz = (shuffle_swap(bvh_nodes[3], shufflexyz[2]) - Psplat[2]) * idirsplat[2];
-
-  /* calculate { c0min, c1min, -c0max, -c1max} */
-  ssef minmax = max(max(tminmaxx, tminmaxy), max(tminmaxz, tsplat));
-  const ssef tminmax = minmax ^ pn;
-  const sseb lrhit = tminmax <= shuffle<2, 3, 0, 1>(tminmax);
-
-  dist[0] = tminmax[0];
-  dist[1] = tminmax[1];
-
-  int mask = movemask(lrhit);
-
-#  ifdef __VISIBILITY_FLAG__
-  /* this visibility test gives a 5% performance hit, how to solve? */
-  float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-  int cmask = (((mask & 1) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
-              (((mask & 2) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
-  return cmask;
-#  else
-  return mask & 3;
-#  endif
-}
-
-ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
-                                                        const float3 P,
-                                                        const float3 dir,
-                                                        const ssef &isect_near,
-                                                        const ssef &isect_far,
-                                                        const int node_addr,
-                                                        const uint visibility,
-                                                        float dist[2])
-{
-  Transform space0 = bvh_unaligned_node_fetch_space(kg, node_addr, 0);
-  Transform space1 = bvh_unaligned_node_fetch_space(kg, node_addr, 1);
-
-  float3 aligned_dir0 = transform_direction(&space0, dir),
-         aligned_dir1 = transform_direction(&space1, dir);
-  float3 aligned_P0 = transform_point(&space0, P), aligned_P1 = transform_point(&space1, P);
-  float3 nrdir0 = -bvh_inverse_direction(aligned_dir0),
-         nrdir1 = -bvh_inverse_direction(aligned_dir1);
-
-  ssef lower_x = ssef(aligned_P0.x * nrdir0.x, aligned_P1.x * nrdir1.x, 0.0f, 0.0f),
-       lower_y = ssef(aligned_P0.y * nrdir0.y, aligned_P1.y * nrdir1.y, 0.0f, 0.0f),
-       lower_z = ssef(aligned_P0.z * nrdir0.z, aligned_P1.z * nrdir1.z, 0.0f, 0.0f);
-
-  ssef upper_x = lower_x - ssef(nrdir0.x, nrdir1.x, 0.0f, 0.0f),
-       upper_y = lower_y - ssef(nrdir0.y, nrdir1.y, 0.0f, 0.0f),
-       upper_z = lower_z - ssef(nrdir0.z, nrdir1.z, 0.0f, 0.0f);
-
-  ssef tnear_x = min(lower_x, upper_x);
-  ssef tnear_y = min(lower_y, upper_y);
-  ssef tnear_z = min(lower_z, upper_z);
-  ssef tfar_x = max(lower_x, upper_x);
-  ssef tfar_y = max(lower_y, upper_y);
-  ssef tfar_z = max(lower_z, upper_z);
-
-  const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
-  const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
-  sseb vmask = tnear <= tfar;
-  dist[0] = tnear.f[0];
-  dist[1] = tnear.f[1];
-
-  int mask = (int)movemask(vmask);
-
-#  ifdef __VISIBILITY_FLAG__
-  /* this visibility test gives a 5% performance hit, how to solve? */
-  float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-  int cmask = (((mask & 1) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
-              (((mask & 2) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
-  return cmask;
-#  else
-  return mask & 3;
-#  endif
-}
-
-ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg,
-                                              const float3 &P,
-                                              const float3 &dir,
-                                              const ssef &isect_near,
-                                              const ssef &isect_far,
-                                              const ssef &tsplat,
-                                              const ssef Psplat[3],
-                                              const ssef idirsplat[3],
-                                              const shuffle_swap_t shufflexyz[3],
-                                              const int node_addr,
-                                              const uint visibility,
-                                              float dist[2])
-{
-  float4 node = kernel_tex_fetch(__bvh_nodes, node_addr);
-  if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
-    return bvh_unaligned_node_intersect(
-        kg, P, dir, isect_near, isect_far, node_addr, visibility, dist);
-  }
-  else {
-    return bvh_aligned_node_intersect(
-        kg, P, dir, tsplat, Psplat, idirsplat, shufflexyz, node_addr, visibility, dist);
-  }
-}
-#endif /* !defined(__KERNEL_SSE2__) */
index 03916bfdca997f196e7f7a96b8e705e8512b50b4..12b88f159e26a09ccc6660c26ea02fea33257747 100644 (file)
  * limitations under the License.
  */
 
-#ifdef __QBVH__
-#  include "kernel/bvh/qbvh_shadow_all.h"
-#  ifdef __KERNEL_AVX2__
-#    include "kernel/bvh/obvh_shadow_all.h"
-#  endif
-#endif
-
 #if BVH_FEATURE(BVH_HAIR)
 #  define NODE_INTERSECT bvh_node_intersect
 #else
@@ -80,26 +73,6 @@ ccl_device_inline
   *num_hits = 0;
   isect_array->t = tmax;
 
-#if defined(__KERNEL_SSE2__)
-  const shuffle_swap_t shuf_identity = shuffle_swap_identity();
-  const shuffle_swap_t shuf_swap = shuffle_swap_swap();
-
-  const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-  ssef Psplat[3], idirsplat[3];
-#  if BVH_FEATURE(BVH_HAIR)
-  ssef tnear(0.0f), tfar(isect_t);
-#  endif
-  shuffle_swap_t shufflexyz[3];
-
-  Psplat[0] = ssef(P.x);
-  Psplat[1] = ssef(P.y);
-  Psplat[2] = ssef(P.z);
-
-  ssef tsplat(0.0f, 0.0f, -isect_t, -isect_t);
-
-  gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#endif /* __KERNEL_SSE2__ */
-
   /* traversal loop */
   do {
     do {
@@ -109,33 +82,16 @@ ccl_device_inline
         float dist[2];
         float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
 
-#if !defined(__KERNEL_SSE2__)
         traverse_mask = NODE_INTERSECT(kg,
                                        P,
-#  if BVH_FEATURE(BVH_HAIR)
+#if BVH_FEATURE(BVH_HAIR)
                                        dir,
-#  endif
+#endif
                                        idir,
                                        isect_t,
                                        node_addr,
                                        visibility,
                                        dist);
-#else  // __KERNEL_SSE2__
-        traverse_mask = NODE_INTERSECT(kg,
-                                       P,
-                                       dir,
-#  if BVH_FEATURE(BVH_HAIR)
-                                       tnear,
-                                       tfar,
-#  endif
-                                       tsplat,
-                                       Psplat,
-                                       idirsplat,
-                                       shufflexyz,
-                                       node_addr,
-                                       visibility,
-                                       dist);
-#endif  // __KERNEL_SSE2__
 
         node_addr = __float_as_int(cnodes.z);
         node_addr_child1 = __float_as_int(cnodes.w);
@@ -272,18 +228,6 @@ ccl_device_inline
           num_hits_in_instance = 0;
           isect_array->t = isect_t;
 
-#  if defined(__KERNEL_SSE2__)
-          Psplat[0] = ssef(P.x);
-          Psplat[1] = ssef(P.y);
-          Psplat[2] = ssef(P.z);
-
-          tsplat = ssef(0.0f, 0.0f, -isect_t, -isect_t);
-#    if BVH_FEATURE(BVH_HAIR)
-          tfar = ssef(isect_t);
-#    endif
-          gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
           ++stack_ptr;
           kernel_assert(stack_ptr < BVH_STACK_SIZE);
           traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL;
@@ -322,18 +266,6 @@ ccl_device_inline
       isect_t = tmax;
       isect_array->t = isect_t;
 
-#  if defined(__KERNEL_SSE2__)
-      Psplat[0] = ssef(P.x);
-      Psplat[1] = ssef(P.y);
-      Psplat[2] = ssef(P.z);
-
-      tsplat = ssef(0.0f, 0.0f, -isect_t, -isect_t);
-#    if BVH_FEATURE(BVH_HAIR)
-      tfar = ssef(isect_t);
-#    endif
-      gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
       object = OBJECT_NONE;
       node_addr = traversal_stack[stack_ptr];
       --stack_ptr;
@@ -350,20 +282,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          const uint max_hits,
                                          uint *num_hits)
 {
-  switch (kernel_data.bvh.bvh_layout) {
-#ifdef __KERNEL_AVX2__
-    case BVH_LAYOUT_BVH8:
-      return BVH_FUNCTION_FULL_NAME(OBVH)(kg, ray, isect_array, visibility, max_hits, num_hits);
-#endif
-#ifdef __QBVH__
-    case BVH_LAYOUT_BVH4:
-      return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, isect_array, visibility, max_hits, num_hits);
-#endif
-    case BVH_LAYOUT_BVH2:
-      return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, visibility, max_hits, num_hits);
-  }
-  kernel_assert(!"Should not happen");
-  return false;
+  return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, visibility, max_hits, num_hits);
 }
 
 #undef BVH_FUNCTION_NAME
index 2a4677928c5d8f364e89d0cfe6b3658cd9e14cc0..e6236c93caaf8693a779757115c24aea2d209a81 100644 (file)
  * limitations under the License.
  */
 
-#ifdef __QBVH__
-#  include "kernel/bvh/qbvh_traversal.h"
-#endif
-#ifdef __KERNEL_AVX2__
-#  include "kernel/bvh/obvh_traversal.h"
-#endif
-
 #if BVH_FEATURE(BVH_HAIR)
 #  define NODE_INTERSECT bvh_node_intersect
 #else
@@ -76,26 +69,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
   BVH_DEBUG_INIT();
 
-#if defined(__KERNEL_SSE2__)
-  const shuffle_swap_t shuf_identity = shuffle_swap_identity();
-  const shuffle_swap_t shuf_swap = shuffle_swap_swap();
-
-  const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-  ssef Psplat[3], idirsplat[3];
-#  if BVH_FEATURE(BVH_HAIR)
-  ssef tnear(0.0f), tfar(isect->t);
-#  endif
-  shuffle_swap_t shufflexyz[3];
-
-  Psplat[0] = ssef(P.x);
-  Psplat[1] = ssef(P.y);
-  Psplat[2] = ssef(P.z);
-
-  ssef tsplat(0.0f, 0.0f, -isect->t, -isect->t);
-
-  gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#endif
-
   /* traversal loop */
   do {
     do {
@@ -105,37 +78,18 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
         float dist[2];
         float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
 
-#if !defined(__KERNEL_SSE2__)
         {
           traverse_mask = NODE_INTERSECT(kg,
                                          P,
-#  if BVH_FEATURE(BVH_HAIR)
+#if BVH_FEATURE(BVH_HAIR)
                                          dir,
-#  endif
+#endif
                                          idir,
                                          isect->t,
                                          node_addr,
                                          visibility,
                                          dist);
         }
-#else  // __KERNEL_SSE2__
-        {
-          traverse_mask = NODE_INTERSECT(kg,
-                                         P,
-                                         dir,
-#  if BVH_FEATURE(BVH_HAIR)
-                                         tnear,
-                                         tfar,
-#  endif
-                                         tsplat,
-                                         Psplat,
-                                         idirsplat,
-                                         shufflexyz,
-                                         node_addr,
-                                         visibility,
-                                         dist);
-        }
-#endif  // __KERNEL_SSE2__
 
         node_addr = __float_as_int(cnodes.z);
         node_addr_child1 = __float_as_int(cnodes.w);
@@ -188,17 +142,8 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                 kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
                 if (triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr)) {
                   /* shadow ray early termination */
-#if defined(__KERNEL_SSE2__)
                   if (visibility & PATH_RAY_SHADOW_OPAQUE)
                     return true;
-                  tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-                  tfar = ssef(isect->t);
-#  endif
-#else
-                if (visibility & PATH_RAY_SHADOW_OPAQUE)
-                  return true;
-#endif
                 }
               }
               break;
@@ -211,17 +156,8 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                 if (motion_triangle_intersect(
                         kg, isect, P, dir, ray->time, visibility, object, prim_addr)) {
                   /* shadow ray early termination */
-#  if defined(__KERNEL_SSE2__)
-                  if (visibility & PATH_RAY_SHADOW_OPAQUE)
-                    return true;
-                  tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#    if BVH_FEATURE(BVH_HAIR)
-                  tfar = ssef(isect->t);
-#    endif
-#  else
                   if (visibility & PATH_RAY_SHADOW_OPAQUE)
                     return true;
-#  endif
                 }
               }
               break;
@@ -238,17 +174,8 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                     kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
                 if (hit) {
                   /* shadow ray early termination */
-#  if defined(__KERNEL_SSE2__)
-                  if (visibility & PATH_RAY_SHADOW_OPAQUE)
-                    return true;
-                  tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#    if BVH_FEATURE(BVH_HAIR)
-                  tfar = ssef(isect->t);
-#    endif
-#  else
                   if (visibility & PATH_RAY_SHADOW_OPAQUE)
                     return true;
-#  endif
                 }
               }
               break;
@@ -267,19 +194,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
           isect->t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect->t);
 #endif
 
-#  if defined(__KERNEL_SSE2__)
-          Psplat[0] = ssef(P.x);
-          Psplat[1] = ssef(P.y);
-          Psplat[2] = ssef(P.z);
-
-          tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#    if BVH_FEATURE(BVH_HAIR)
-          tfar = ssef(isect->t);
-#    endif
-
-          gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
           ++stack_ptr;
           kernel_assert(stack_ptr < BVH_STACK_SIZE);
           traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL;
@@ -301,19 +215,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
       isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t);
 #endif
 
-#  if defined(__KERNEL_SSE2__)
-      Psplat[0] = ssef(P.x);
-      Psplat[1] = ssef(P.y);
-      Psplat[2] = ssef(P.z);
-
-      tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#    if BVH_FEATURE(BVH_HAIR)
-      tfar = ssef(isect->t);
-#    endif
-
-      gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
       object = OBJECT_NONE;
       node_addr = traversal_stack[stack_ptr];
       --stack_ptr;
@@ -328,20 +229,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          Intersection *isect,
                                          const uint visibility)
 {
-  switch (kernel_data.bvh.bvh_layout) {
-#ifdef __KERNEL_AVX2__
-    case BVH_LAYOUT_BVH8:
-      return BVH_FUNCTION_FULL_NAME(OBVH)(kg, ray, isect, visibility);
-#endif
-#ifdef __QBVH__
-    case BVH_LAYOUT_BVH4:
-      return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, isect, visibility);
-#endif /* __QBVH__ */
-    case BVH_LAYOUT_BVH2:
-      return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect, visibility);
-  }
-  kernel_assert(!"Should not happen");
-  return false;
+  return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect, visibility);
 }
 
 #undef BVH_FUNCTION_NAME
index a7bc52d4435104e8927abec88f5713f0b40d601c..b173568266b3f6405f01d7f6561d6eaf3522bae0 100644 (file)
@@ -31,8 +31,6 @@ CCL_NAMESPACE_BEGIN
 
 /* 64 object BVH + 64 mesh BVH + 64 object node splitting */
 #define BVH_STACK_SIZE 192
-#define BVH_QSTACK_SIZE 384
-#define BVH_OSTACK_SIZE 768
 /* BVH intersection function variations */
 
 #define BVH_MOTION 1
index d8b0bbccd226b3f1ea6b5242197f9275dc940d5a..1f2ea47269ba1695485028f213c4b523399cd45e 100644 (file)
  * limitations under the License.
  */
 
-#ifdef __QBVH__
-#  include "kernel/bvh/qbvh_volume.h"
-#  ifdef __KERNEL_AVX2__
-#    include "kernel/bvh/obvh_volume.h"
-#  endif
-#endif
-
 #if BVH_FEATURE(BVH_HAIR)
 #  define NODE_INTERSECT bvh_node_intersect
 #else
@@ -78,26 +71,6 @@ ccl_device_inline
   isect->prim = PRIM_NONE;
   isect->object = OBJECT_NONE;
 
-#if defined(__KERNEL_SSE2__)
-  const shuffle_swap_t shuf_identity = shuffle_swap_identity();
-  const shuffle_swap_t shuf_swap = shuffle_swap_swap();
-
-  const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-  ssef Psplat[3], idirsplat[3];
-#  if BVH_FEATURE(BVH_HAIR)
-  ssef tnear(0.0f), tfar(isect->t);
-#  endif
-  shuffle_swap_t shufflexyz[3];
-
-  Psplat[0] = ssef(P.x);
-  Psplat[1] = ssef(P.y);
-  Psplat[2] = ssef(P.z);
-
-  ssef tsplat(0.0f, 0.0f, -isect->t, -isect->t);
-
-  gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#endif
-
   /* traversal loop */
   do {
     do {
@@ -107,33 +80,16 @@ ccl_device_inline
         float dist[2];
         float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
 
-#if !defined(__KERNEL_SSE2__)
         traverse_mask = NODE_INTERSECT(kg,
                                        P,
-#  if BVH_FEATURE(BVH_HAIR)
+#if BVH_FEATURE(BVH_HAIR)
                                        dir,
-#  endif
+#endif
                                        idir,
                                        isect->t,
                                        node_addr,
                                        visibility,
                                        dist);
-#else  // __KERNEL_SSE2__
-        traverse_mask = NODE_INTERSECT(kg,
-                                       P,
-                                       dir,
-#  if BVH_FEATURE(BVH_HAIR)
-                                       tnear,
-                                       tfar,
-#  endif
-                                       tsplat,
-                                       Psplat,
-                                       idirsplat,
-                                       shufflexyz,
-                                       node_addr,
-                                       visibility,
-                                       dist);
-#endif  // __KERNEL_SSE2__
 
         node_addr = __float_as_int(cnodes.z);
         node_addr_child1 = __float_as_int(cnodes.w);
@@ -231,19 +187,6 @@ ccl_device_inline
             isect->t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect->t);
 #endif
 
-#  if defined(__KERNEL_SSE2__)
-            Psplat[0] = ssef(P.x);
-            Psplat[1] = ssef(P.y);
-            Psplat[2] = ssef(P.z);
-
-            tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#    if BVH_FEATURE(BVH_HAIR)
-            tfar = ssef(isect->t);
-#    endif
-
-            gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
             ++stack_ptr;
             kernel_assert(stack_ptr < BVH_STACK_SIZE);
             traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL;
@@ -270,19 +213,6 @@ ccl_device_inline
       isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t);
 #endif
 
-#  if defined(__KERNEL_SSE2__)
-      Psplat[0] = ssef(P.x);
-      Psplat[1] = ssef(P.y);
-      Psplat[2] = ssef(P.z);
-
-      tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
-#    if BVH_FEATURE(BVH_HAIR)
-      tfar = ssef(isect->t);
-#    endif
-
-      gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
       object = OBJECT_NONE;
       node_addr = traversal_stack[stack_ptr];
       --stack_ptr;
@@ -297,20 +227,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          Intersection *isect,
                                          const uint visibility)
 {
-  switch (kernel_data.bvh.bvh_layout) {
-#ifdef __KERNEL_AVX2__
-    case BVH_LAYOUT_BVH8:
-      return BVH_FUNCTION_FULL_NAME(OBVH)(kg, ray, isect, visibility);
-#endif
-#ifdef __QBVH__
-    case BVH_LAYOUT_BVH4:
-      return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, isect, visibility);
-#endif
-    case BVH_LAYOUT_BVH2:
-      return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect, visibility);
-  }
-  kernel_assert(!"Should not happen");
-  return false;
+  return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect, visibility);
 }
 
 #undef BVH_FUNCTION_NAME
index 7b1834c7c6f75d9ca5432b1fa92c15c3af6f4019..a8664cc4331474125b767d1d0417be9df8f82661 100644 (file)
  * limitations under the License.
  */
 
-#ifdef __QBVH__
-#  include "kernel/bvh/qbvh_volume_all.h"
-#  ifdef __KERNEL_AVX2__
-#    include "kernel/bvh/obvh_volume_all.h"
-#  endif
-#endif
-
 #if BVH_FEATURE(BVH_HAIR)
 #  define NODE_INTERSECT bvh_node_intersect
 #else
@@ -80,26 +73,6 @@ ccl_device_inline
   uint num_hits = 0;
   isect_array->t = tmax;
 
-#if defined(__KERNEL_SSE2__)
-  const shuffle_swap_t shuf_identity = shuffle_swap_identity();
-  const shuffle_swap_t shuf_swap = shuffle_swap_swap();
-
-  const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-  ssef Psplat[3], idirsplat[3];
-#  if BVH_FEATURE(BVH_HAIR)
-  ssef tnear(0.0f), tfar(isect_t);
-#  endif
-  shuffle_swap_t shufflexyz[3];
-
-  Psplat[0] = ssef(P.x);
-  Psplat[1] = ssef(P.y);
-  Psplat[2] = ssef(P.z);
-
-  ssef tsplat(0.0f, 0.0f, -isect_t, -isect_t);
-
-  gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#endif /* __KERNEL_SSE2__ */
-
   /* traversal loop */
   do {
     do {
@@ -109,33 +82,16 @@ ccl_device_inline
         float dist[2];
         float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
 
-#if !defined(__KERNEL_SSE2__)
         traverse_mask = NODE_INTERSECT(kg,
                                        P,
-#  if BVH_FEATURE(BVH_HAIR)
+#if BVH_FEATURE(BVH_HAIR)
                                        dir,
-#  endif
+#endif
                                        idir,
                                        isect_t,
                                        node_addr,
                                        visibility,
                                        dist);
-#else  // __KERNEL_SSE2__
-        traverse_mask = NODE_INTERSECT(kg,
-                                       P,
-                                       dir,
-#  if BVH_FEATURE(BVH_HAIR)
-                                       tnear,
-                                       tfar,
-#  endif
-                                       tsplat,
-                                       Psplat,
-                                       idirsplat,
-                                       shufflexyz,
-                                       node_addr,
-                                       visibility,
-                                       dist);
-#endif  // __KERNEL_SSE2__
 
         node_addr = __float_as_int(cnodes.z);
         node_addr_child1 = __float_as_int(cnodes.w);
@@ -281,19 +237,6 @@ ccl_device_inline
             num_hits_in_instance = 0;
             isect_array->t = isect_t;
 
-#  if defined(__KERNEL_SSE2__)
-            Psplat[0] = ssef(P.x);
-            Psplat[1] = ssef(P.y);
-            Psplat[2] = ssef(P.z);
-
-            tsplat = ssef(0.0f, 0.0f, -isect_t, -isect_t);
-#    if BVH_FEATURE(BVH_HAIR)
-            tfar = ssef(isect_t);
-#    endif
-
-            gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
             ++stack_ptr;
             kernel_assert(stack_ptr < BVH_STACK_SIZE);
             traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL;
@@ -337,19 +280,6 @@ ccl_device_inline
       isect_t = tmax;
       isect_array->t = isect_t;
 
-#  if defined(__KERNEL_SSE2__)
-      Psplat[0] = ssef(P.x);
-      Psplat[1] = ssef(P.y);
-      Psplat[2] = ssef(P.z);
-
-      tsplat = ssef(0.0f, 0.0f, -isect_t, -isect_t);
-#    if BVH_FEATURE(BVH_HAIR)
-      tfar = ssef(isect_t);
-#    endif
-
-      gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
-#  endif
-
       object = OBJECT_NONE;
       node_addr = traversal_stack[stack_ptr];
       --stack_ptr;
@@ -365,20 +295,7 @@ ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          const uint max_hits,
                                          const uint visibility)
 {
-  switch (kernel_data.bvh.bvh_layout) {
-#ifdef __KERNEL_AVX2__
-    case BVH_LAYOUT_BVH8:
-      return BVH_FUNCTION_FULL_NAME(OBVH)(kg, ray, isect_array, max_hits, visibility);
-#endif
-#ifdef __QBVH__
-    case BVH_LAYOUT_BVH4:
-      return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, isect_array, max_hits, visibility);
-#endif
-    case BVH_LAYOUT_BVH2:
-      return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, max_hits, visibility);
-  }
-  kernel_assert(!"Should not happen");
-  return 0;
+  return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, max_hits, visibility);
 }
 
 #undef BVH_FUNCTION_NAME
diff --git a/intern/cycles/kernel/bvh/obvh_local.h b/intern/cycles/kernel/bvh/obvh_local.h
deleted file mode 100644 (file)
index e6bb548..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function for subsurface scattering, where
- * various features can be enabled/disabled. This way we can compile optimized
- * versions for each case without new features slowing things down.
- *
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT obvh_node_intersect
-#else
-#  define NODE_INTERSECT obvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             LocalIntersection *local_isect,
-                                             int local_object,
-                                             uint *lcg_state,
-                                             int max_hits)
-{
-  /* Traversal stack in CUDA thread-local memory. */
-  OBVHStackItem traversal_stack[BVH_OSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_tex_fetch(__object_node, local_object);
-
-  /* Ray parameters in registers. */
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-  float isect_t = ray->t;
-
-  if (local_isect != NULL) {
-    local_isect->num_hits = 0;
-  }
-  kernel_assert((local_isect == NULL) == (max_hits == 0));
-
-  const int object_flag = kernel_tex_fetch(__object_flag, local_object);
-  if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
-#if BVH_FEATURE(BVH_MOTION)
-    Transform ob_itfm;
-    isect_t = bvh_instance_motion_push(kg, local_object, ray, &P, &dir, &idir, isect_t, &ob_itfm);
-#else
-    isect_t = bvh_instance_push(kg, local_object, ray, &P, &dir, &idir, isect_t);
-#endif
-    object = local_object;
-  }
-
-  avxf tnear(0.0f), tfar(isect_t);
-#if BVH_FEATURE(BVH_HAIR)
-  avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#endif
-  avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        avxf dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-          avxf cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 26);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 14);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c3;
-            traversal_stack[stack_ptr].dist = d3;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-
-          /* Five children are hit, push all onto stack and sort 5
-           * stack items, continue with closest child
-           */
-          r = __bscf(child_mask);
-          int c4 = __float_as_int(cnodes[r]);
-          float d4 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-          /* Six children are hit, push all onto stack and sort 6
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c5 = __float_as_int(cnodes[r]);
-          float d5 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c5;
-            traversal_stack[stack_ptr].dist = d5;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c5;
-          traversal_stack[stack_ptr].dist = d5;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c4;
-          traversal_stack[stack_ptr].dist = d4;
-
-          /* Seven children are hit, push all onto stack and sort 7
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c6 = __float_as_int(cnodes[r]);
-          float d6 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c6;
-            traversal_stack[stack_ptr].dist = d6;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5],
-                            &traversal_stack[stack_ptr - 6]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-          /* Eight children are hit, push all onto stack and sort 8
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c7 = __float_as_int(cnodes[r]);
-          float d7 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c7;
-          traversal_stack[stack_ptr].dist = d7;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c6;
-          traversal_stack[stack_ptr].dist = d6;
-          obvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3],
-                          &traversal_stack[stack_ptr - 4],
-                          &traversal_stack[stack_ptr - 5],
-                          &traversal_stack[stack_ptr - 6],
-                          &traversal_stack[stack_ptr - 7]);
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-        int prim_addr = __float_as_int(leaf.x);
-
-        int prim_addr2 = __float_as_int(leaf.y);
-        const uint type = __float_as_int(leaf.w);
-
-        /* Pop. */
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-
-        /* Primitive intersection. */
-        switch (type & PRIMITIVE_ALL) {
-          case PRIMITIVE_TRIANGLE: {
-            /* Intersect ray against primitive, */
-            for (; prim_addr < prim_addr2; prim_addr++) {
-              kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-              if (triangle_intersect_local(kg,
-                                           local_isect,
-                                           P,
-                                           dir,
-                                           object,
-                                           local_object,
-                                           prim_addr,
-                                           isect_t,
-                                           lcg_state,
-                                           max_hits)) {
-                return true;
-              }
-            }
-            break;
-          }
-#if BVH_FEATURE(BVH_MOTION)
-          case PRIMITIVE_MOTION_TRIANGLE: {
-            /* Intersect ray against primitive. */
-            for (; prim_addr < prim_addr2; prim_addr++) {
-              kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-              if (motion_triangle_intersect_local(kg,
-                                                  local_isect,
-                                                  P,
-                                                  dir,
-                                                  ray->time,
-                                                  object,
-                                                  local_object,
-                                                  prim_addr,
-                                                  isect_t,
-                                                  lcg_state,
-                                                  max_hits)) {
-                return true;
-              }
-            }
-            break;
-          }
-#endif
-          default:
-            break;
-        }
-      }
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-  return false;
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/obvh_nodes.h b/intern/cycles/kernel/bvh/obvh_nodes.h
deleted file mode 100644 (file)
index e5c935b..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright 2011-2014, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Aligned nodes intersection AVX code is adopted from Embree,
- */
-
-struct OBVHStackItem {
-  int addr;
-  float dist;
-};
-
-ccl_device_inline void obvh_near_far_idx_calc(const float3 &idir,
-                                              int *ccl_restrict near_x,
-                                              int *ccl_restrict near_y,
-                                              int *ccl_restrict near_z,
-                                              int *ccl_restrict far_x,
-                                              int *ccl_restrict far_y,
-                                              int *ccl_restrict far_z)
-
-{
-#ifdef __KERNEL_SSE__
-  *near_x = 0;
-  *far_x = 1;
-  *near_y = 2;
-  *far_y = 3;
-  *near_z = 4;
-  *far_z = 5;
-
-  const size_t mask = movemask(ssef(idir.m128));
-
-  const int mask_x = mask & 1;
-  const int mask_y = (mask & 2) >> 1;
-  const int mask_z = (mask & 4) >> 2;
-
-  *near_x += mask_x;
-  *far_x -= mask_x;
-  *near_y += mask_y;
-  *far_y -= mask_y;
-  *near_z += mask_z;
-  *far_z -= mask_z;
-#else
-  if (idir.x >= 0.0f) {
-    *near_x = 0;
-    *far_x = 1;
-  }
-  else {
-    *near_x = 1;
-    *far_x = 0;
-  }
-  if (idir.y >= 0.0f) {
-    *near_y = 2;
-    *far_y = 3;
-  }
-  else {
-    *near_y = 3;
-    *far_y = 2;
-  }
-  if (idir.z >= 0.0f) {
-    *near_z = 4;
-    *far_z = 5;
-  }
-  else {
-    *near_z = 5;
-    *far_z = 4;
-  }
-#endif
-}
-
-ccl_device_inline void obvh_item_swap(OBVHStackItem *ccl_restrict a, OBVHStackItem *ccl_restrict b)
-{
-  OBVHStackItem tmp = *a;
-  *a = *b;
-  *b = tmp;
-}
-
-ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1,
-                                       OBVHStackItem *ccl_restrict s2,
-                                       OBVHStackItem *ccl_restrict s3)
-{
-  if (s2->dist < s1->dist) {
-    obvh_item_swap(s2, s1);
-  }
-  if (s3->dist < s2->dist) {
-    obvh_item_swap(s3, s2);
-  }
-  if (s2->dist < s1->dist) {
-    obvh_item_swap(s2, s1);
-  }
-}
-
-ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1,
-                                       OBVHStackItem *ccl_restrict s2,
-                                       OBVHStackItem *ccl_restrict s3,
-                                       OBVHStackItem *ccl_restrict s4)
-{
-  if (s2->dist < s1->dist) {
-    obvh_item_swap(s2, s1);
-  }
-  if (s4->dist < s3->dist) {
-    obvh_item_swap(s4, s3);
-  }
-  if (s3->dist < s1->dist) {
-    obvh_item_swap(s3, s1);
-  }
-  if (s4->dist < s2->dist) {
-    obvh_item_swap(s4, s2);
-  }
-  if (s3->dist < s2->dist) {
-    obvh_item_swap(s3, s2);
-  }
-}
-
-ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1,
-                                       OBVHStackItem *ccl_restrict s2,
-                                       OBVHStackItem *ccl_restrict s3,
-                                       OBVHStackItem *ccl_restrict s4,
-                                       OBVHStackItem *ccl_restrict s5)
-{
-  obvh_stack_sort(s1, s2, s3, s4);
-  if (s5->dist < s4->dist) {
-    obvh_item_swap(s4, s5);
-    if (s4->dist < s3->dist) {
-      obvh_item_swap(s3, s4);
-      if (s3->dist < s2->dist) {
-        obvh_item_swap(s2, s3);
-        if (s2->dist < s1->dist) {
-          obvh_item_swap(s1, s2);
-        }
-      }
-    }
-  }
-}
-
-ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1,
-                                       OBVHStackItem *ccl_restrict s2,
-                                       OBVHStackItem *ccl_restrict s3,
-                                       OBVHStackItem *ccl_restrict s4,
-                                       OBVHStackItem *ccl_restrict s5,
-                                       OBVHStackItem *ccl_restrict s6)
-{
-  obvh_stack_sort(s1, s2, s3, s4, s5);
-  if (s6->dist < s5->dist) {
-    obvh_item_swap(s5, s6);
-    if (s5->dist < s4->dist) {
-      obvh_item_swap(s4, s5);
-      if (s4->dist < s3->dist) {
-        obvh_item_swap(s3, s4);
-        if (s3->dist < s2->dist) {
-          obvh_item_swap(s2, s3);
-          if (s2->dist < s1->dist) {
-            obvh_item_swap(s1, s2);
-          }
-        }
-      }
-    }
-  }
-}
-
-ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1,
-                                       OBVHStackItem *ccl_restrict s2,
-                                       OBVHStackItem *ccl_restrict s3,
-                                       OBVHStackItem *ccl_restrict s4,
-                                       OBVHStackItem *ccl_restrict s5,
-                                       OBVHStackItem *ccl_restrict s6,
-                                       OBVHStackItem *ccl_restrict s7)
-{
-  obvh_stack_sort(s1, s2, s3, s4, s5, s6);
-  if (s7->dist < s6->dist) {
-    obvh_item_swap(s6, s7);
-    if (s6->dist < s5->dist) {
-      obvh_item_swap(s5, s6);
-      if (s5->dist < s4->dist) {
-        obvh_item_swap(s4, s5);
-        if (s4->dist < s3->dist) {
-          obvh_item_swap(s3, s4);
-          if (s3->dist < s2->dist) {
-            obvh_item_swap(s2, s3);
-            if (s2->dist < s1->dist) {
-              obvh_item_swap(s1, s2);
-            }
-          }
-        }
-      }
-    }
-  }
-}
-
-ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1,
-                                       OBVHStackItem *ccl_restrict s2,
-                                       OBVHStackItem *ccl_restrict s3,
-                                       OBVHStackItem *ccl_restrict s4,
-                                       OBVHStackItem *ccl_restrict s5,
-                                       OBVHStackItem *ccl_restrict s6,
-                                       OBVHStackItem *ccl_restrict s7,
-                                       OBVHStackItem *ccl_restrict s8)
-{
-  obvh_stack_sort(s1, s2, s3, s4, s5, s6, s7);
-  if (s8->dist < s7->dist) {
-    obvh_item_swap(s7, s8);
-    if (s7->dist < s6->dist) {
-      obvh_item_swap(s6, s7);
-      if (s6->dist < s5->dist) {
-        obvh_item_swap(s5, s6);
-        if (s5->dist < s4->dist) {
-          obvh_item_swap(s4, s5);
-          if (s4->dist < s3->dist) {
-            obvh_item_swap(s3, s4);
-            if (s3->dist < s2->dist) {
-              obvh_item_swap(s2, s3);
-              if (s2->dist < s1->dist) {
-                obvh_item_swap(s1, s2);
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}
-
-/* Axis-aligned nodes intersection */
-
-ccl_device_inline int obvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
-                                                  const avxf &isect_near,
-                                                  const avxf &isect_far,
-#ifdef __KERNEL_AVX2__
-                                                  const avx3f &org_idir,
-#else
-                                                  const avx3f &org,
-#endif
-                                                  const avx3f &idir,
-                                                  const int near_x,
-                                                  const int near_y,
-                                                  const int near_z,
-                                                  const int far_x,
-                                                  const int far_y,
-                                                  const int far_z,
-                                                  const int node_addr,
-                                                  avxf *ccl_restrict dist)
-{
-  const int offset = node_addr + 2;
-#ifdef __KERNEL_AVX2__
-  const avxf tnear_x = msub(
-      kernel_tex_fetch_avxf(__bvh_nodes, offset + near_x * 2), idir.x, org_idir.x);
-  const avxf tnear_y = msub(
-      kernel_tex_fetch_avxf(__bvh_nodes, offset + near_y * 2), idir.y, org_idir.y);
-  const avxf tnear_z = msub(
-      kernel_tex_fetch_avxf(__bvh_nodes, offset + near_z * 2), idir.z, org_idir.z);
-  const avxf tfar_x = msub(
-      kernel_tex_fetch_avxf(__bvh_nodes, offset + far_x * 2), idir.x, org_idir.x);
-  const avxf tfar_y = msub(
-      kernel_tex_fetch_avxf(__bvh_nodes, offset + far_y * 2), idir.y, org_idir.y);
-  const avxf tfar_z = msub(
-      kernel_tex_fetch_avxf(__bvh_nodes, offset + far_z * 2), idir.z, org_idir.z);
-
-  const avxf tnear = max4(tnear_x, tnear_y, tnear_z, isect_near);
-  const avxf tfar = min4(tfar_x, tfar_y, tfar_z, isect_far);
-  const avxb vmask = tnear <= tfar;
-  int mask = (int)movemask(vmask);
-  *dist = tnear;
-  return mask;
-#else
-  return 0;
-#endif
-}
-
-/* Unaligned nodes intersection */
-
-ccl_device_inline int obvh_unaligned_node_intersect(KernelGlobals *ccl_restrict kg,
-                                                    const avxf &isect_near,
-                                                    const avxf &isect_far,
-#ifdef __KERNEL_AVX2__
-                                                    const avx3f &org_idir,
-#endif
-                                                    const avx3f &org,
-                                                    const avx3f &dir,
-                                                    const avx3f &idir,
-                                                    const int near_x,
-                                                    const int near_y,
-                                                    const int near_z,
-                                                    const int far_x,
-                                                    const int far_y,
-                                                    const int far_z,
-                                                    const int node_addr,
-                                                    avxf *ccl_restrict dist)
-{
-  const int offset = node_addr;
-  const avxf tfm_x_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 2);
-  const avxf tfm_x_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 4);
-  const avxf tfm_x_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 6);
-
-  const avxf tfm_y_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 8);
-  const avxf tfm_y_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 10);
-  const avxf tfm_y_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 12);
-
-  const avxf tfm_z_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 14);
-  const avxf tfm_z_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 16);
-  const avxf tfm_z_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 18);
-
-  const avxf tfm_t_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 20);
-  const avxf tfm_t_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 22);
-  const avxf tfm_t_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 24);
-
-  const avxf aligned_dir_x = dir.x * tfm_x_x + dir.y * tfm_x_y + dir.z * tfm_x_z,
-             aligned_dir_y = dir.x * tfm_y_x + dir.y * tfm_y_y + dir.z * tfm_y_z,
-             aligned_dir_z = dir.x * tfm_z_x + dir.y * tfm_z_y + dir.z * tfm_z_z;
-
-  const avxf aligned_P_x = org.x * tfm_x_x + org.y * tfm_x_y + org.z * tfm_x_z + tfm_t_x,
-             aligned_P_y = org.x * tfm_y_x + org.y * tfm_y_y + org.z * tfm_y_z + tfm_t_y,
-             aligned_P_z = org.x * tfm_z_x + org.y * tfm_z_y + org.z * tfm_z_z + tfm_t_z;
-
-  const avxf neg_one(-1.0f);
-  const avxf nrdir_x = neg_one / aligned_dir_x, nrdir_y = neg_one / aligned_dir_y,
-             nrdir_z = neg_one / aligned_dir_z;
-
-  const avxf tlower_x = aligned_P_x * nrdir_x, tlower_y = aligned_P_y * nrdir_y,
-             tlower_z = aligned_P_z * nrdir_z;
-
-  const avxf tupper_x = tlower_x - nrdir_x, tupper_y = tlower_y - nrdir_y,
-             tupper_z = tlower_z - nrdir_z;
-
-  const avxf tnear_x = min(tlower_x, tupper_x);
-  const avxf tnear_y = min(tlower_y, tupper_y);
-  const avxf tnear_z = min(tlower_z, tupper_z);
-  const avxf tfar_x = max(tlower_x, tupper_x);
-  const avxf tfar_y = max(tlower_y, tupper_y);
-  const avxf tfar_z = max(tlower_z, tupper_z);
-  const avxf tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
-  const avxf tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
-  const avxb vmask = tnear <= tfar;
-  *dist = tnear;
-  return movemask(vmask);
-}
-
-/* Intersectors wrappers.
- *
- * They'll check node type and call appropriate intersection code.
- */
-
-ccl_device_inline int obvh_node_intersect(KernelGlobals *ccl_restrict kg,
-                                          const avxf &isect_near,
-                                          const avxf &isect_far,
-#ifdef __KERNEL_AVX2__
-                                          const avx3f &org_idir,
-#endif
-                                          const avx3f &org,
-                                          const avx3f &dir,
-                                          const avx3f &idir,
-                                          const int near_x,
-                                          const int near_y,
-                                          const int near_z,
-                                          const int far_x,
-                                          const int far_y,
-                                          const int far_z,
-                                          const int node_addr,
-                                          avxf *ccl_restrict dist)
-{
-  const int offset = node_addr;
-  const float4 node = kernel_tex_fetch(__bvh_nodes, offset);
-  if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
-    return obvh_unaligned_node_intersect(kg,
-                                         isect_near,
-                                         isect_far,
-#ifdef __KERNEL_AVX2__
-                                         org_idir,
-#endif
-                                         org,
-                                         dir,
-                                         idir,
-                                         near_x,
-                                         near_y,
-                                         near_z,
-                                         far_x,
-                                         far_y,
-                                         far_z,
-                                         node_addr,
-                                         dist);
-  }
-  else {
-    return obvh_aligned_node_intersect(kg,
-                                       isect_near,
-                                       isect_far,
-#ifdef __KERNEL_AVX2__
-                                       org_idir,
-#else
-                                       org,
-#endif
-                                       idir,
-                                       near_x,
-                                       near_y,
-                                       near_z,
-                                       far_x,
-                                       far_y,
-                                       far_z,
-                                       node_addr,
-                                       dist);
-  }
-}
diff --git a/intern/cycles/kernel/bvh/obvh_shadow_all.h b/intern/cycles/kernel/bvh/obvh_shadow_all.h
deleted file mode 100644 (file)
index ff82d51..0000000
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function, where various features can be
- * enabled/disabled. This way we can compile optimized versions for each case
- * without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_HAIR: hair curve rendering
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT obvh_node_intersect
-#else
-#  define NODE_INTERSECT obvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect_array,
-                                             const int skip_object,
-                                             const uint max_hits,
-                                             uint *num_hits)
-{
-  /* TODO(sergey):
-   *  - Test if pushing distance on the stack helps.
-   * - Likely and unlikely for if() statements.
-   * - Test restrict attribute for pointers.
-   */
-
-  /* Traversal stack in CUDA thread-local memory. */
-  OBVHStackItem traversal_stack[BVH_OSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-
-  /* Ray parameters in registers. */
-  const float tmax = ray->t;
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-  float isect_t = tmax;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  *num_hits = 0;
-  isect_array->t = tmax;
-
-#if BVH_FEATURE(BVH_INSTANCING)
-  int num_hits_in_instance = 0;
-#endif
-
-  avxf tnear(0.0f), tfar(isect_t);
-#if BVH_FEATURE(BVH_HAIR)
-  avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#endif
-  avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-        (void)inodes;
-
-        if (false
-#ifdef __VISIBILITY_FLAG__
-            || ((__float_as_uint(inodes.x) & PATH_RAY_SHADOW) == 0)
-#endif
-#if BVH_FEATURE(BVH_MOTION)
-            || UNLIKELY(ray->time < inodes.y) || UNLIKELY(ray->time > inodes.z)
-#endif
-        ) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        avxf dist;
-        int child_mask = NODE_INTERSECT(kg,
-                                        tnear,
-                                        tfar,
-#ifdef __KERNEL_AVX2__
-                                        P_idir4,
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-                                        //#if !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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          avxf cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 26);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 14);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c3;
-            traversal_stack[stack_ptr].dist = d3;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-
-          /* Five children are hit, push all onto stack and sort 5
-           * stack items, continue with closest child
-           */
-          r = __bscf(child_mask);
-          int c4 = __float_as_int(cnodes[r]);
-          float d4 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Six children are hit, push all onto stack and sort 6
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c5 = __float_as_int(cnodes[r]);
-          float d5 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c5;
-            traversal_stack[stack_ptr].dist = d5;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c5;
-          traversal_stack[stack_ptr].dist = d5;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c4;
-          traversal_stack[stack_ptr].dist = d4;
-
-          /* Seven children are hit, push all onto stack and sort 7
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c6 = __float_as_int(cnodes[r]);
-          float d6 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c6;
-            traversal_stack[stack_ptr].dist = d6;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5],
-                            &traversal_stack[stack_ptr - 6]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Eight children are hit, push all onto stack and sort 8
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c7 = __float_as_int(cnodes[r]);
-          float d7 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c7;
-          traversal_stack[stack_ptr].dist = d7;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c6;
-          traversal_stack[stack_ptr].dist = d6;
-          obvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3],
-                          &traversal_stack[stack_ptr - 4],
-                          &traversal_stack[stack_ptr - 5],
-                          &traversal_stack[stack_ptr - 6],
-                          &traversal_stack[stack_ptr - 7]);
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-#ifdef __VISIBILITY_FLAG__
-        if ((__float_as_uint(leaf.z) & PATH_RAY_SHADOW) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-#endif
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-          const uint p_type = type & PRIMITIVE_ALL;
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          if (p_type == PRIMITIVE_TRIANGLE) {
-            int prim_count = prim_addr2 - prim_addr;
-            if (prim_count < 3) {
-              while (prim_addr < prim_addr2) {
-                kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) ==
-                              p_type);
-                int hit = triangle_intersect(
-                    kg, isect_array, P, dir, PATH_RAY_SHADOW, object, prim_addr);
-                /* Shadow ray early termination. */
-                if (hit) {
-                  /* detect if this surface has a shader with transparent shadows */
-
-                  /* todo: optimize so primitive visibility flag indicates if
-                   * the primitive has a transparent shadow shader? */
-                  int prim = kernel_tex_fetch(__prim_index, isect_array->prim);
-                  int shader = 0;
-
-#ifdef __HAIR__
-                  if (kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE)
-#endif
-                  {
-                    shader = kernel_tex_fetch(__tri_shader, prim);
-                  }
-#ifdef __HAIR__
-                  else {
-                    float4 str = kernel_tex_fetch(__curves, prim);
-                    shader = __float_as_int(str.z);
-                  }
-#endif
-                  int flag = kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags;
-
-                  /* if no transparent shadows, all light is blocked */
-                  if (!(flag & SD_HAS_TRANSPARENT_SHADOW)) {
-                    return true;
-                  }
-                  /* if maximum number of hits reached, block all light */
-                  else if (*num_hits == max_hits) {
-                    return true;
-                  }
-
-                  /* move on to next entry in intersections array */
-                  isect_array++;
-                  (*num_hits)++;
-#if BVH_FEATURE(BVH_INSTANCING)
-                  num_hits_in_instance++;
-#endif
-
-                  isect_array->t = isect_t;
-                }
-
-                prim_addr++;
-              }  // while
-            }
-            else {
-              kernel_assert((kernel_tex_fetch(__prim_type, (prim_addr)) & PRIMITIVE_ALL) ==
-                            p_type);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-              int *nhiptr = &num_hits_in_instance;
-#else
-            int nhi = 0;
-            int *nhiptr = &nhi;
-#endif
-
-              int result = triangle_intersect8(kg,
-                                               &isect_array,
-                                               P,
-                                               dir,
-                                               PATH_RAY_SHADOW,
-                                               object,
-                                               prim_addr,
-                                               prim_count,
-                                               num_hits,
-                                               max_hits,
-                                               nhiptr,
-                                               isect_t);
-              if (result == 2) {
-                return true;
-              }
-            }  // prim_count
-          }    // PRIMITIVE_TRIANGLE
-          else {
-            while (prim_addr < prim_addr2) {
-              kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type);
-
-#ifdef __SHADOW_TRICKS__
-              uint tri_object = (object == OBJECT_NONE) ?
-                                    kernel_tex_fetch(__prim_object, prim_addr) :
-                                    object;
-              if (tri_object == skip_object) {
-                ++prim_addr;
-                continue;
-              }
-#endif
-
-              bool hit;
-
-              /* todo: specialized intersect functions which don't fill in
-               * isect unless needed and check SD_HAS_TRANSPARENT_SHADOW?
-               * might give a few % performance improvement */
-
-              switch (p_type) {
-
-#if BVH_FEATURE(BVH_MOTION)
-                case PRIMITIVE_MOTION_TRIANGLE: {
-                  hit = motion_triangle_intersect(
-                      kg, isect_array, P, dir, ray->time, PATH_RAY_SHADOW, object, prim_addr);
-                  break;
-                }
-#endif
-#if BVH_FEATURE(BVH_HAIR)
-                case PRIMITIVE_CURVE:
-                case PRIMITIVE_MOTION_CURVE: {
-                  const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
-                  hit = curve_intersect(kg,
-                                                 isect_array,
-                                                 P,
-                                                 dir,
-                                                 PATH_RAY_SHADOW,
-                                                 object,
-                                                 prim_addr,
-                                                 ray->time,
-                                                 curve_type);
-                  break;
-                }
-#endif
-                default: {
-                  hit = false;
-                  break;
-                }
-              }
-
-              /* Shadow ray early termination. */
-              if (hit) {
-                /* detect if this surface has a shader with transparent shadows */
-
-                /* todo: optimize so primitive visibility flag indicates if
-                 * the primitive has a transparent shadow shader? */
-                int prim = kernel_tex_fetch(__prim_index, isect_array->prim);
-                int shader = 0;
-
-#ifdef __HAIR__
-                if (kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE)
-#endif
-                {
-                  shader = kernel_tex_fetch(__tri_shader, prim);
-                }
-#ifdef __HAIR__
-                else {
-                  float4 str = kernel_tex_fetch(__curves, prim);
-                  shader = __float_as_int(str.z);
-                }
-#endif
-                int flag = kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags;
-
-                /* if no transparent shadows, all light is blocked */
-                if (!(flag & SD_HAS_TRANSPARENT_SHADOW)) {
-                  return true;
-                }
-                /* if maximum number of hits reached, block all light */
-                else if (*num_hits == max_hits) {
-                  return true;
-                }
-
-                /* move on to next entry in intersections array */
-                isect_array++;
-                (*num_hits)++;
-#if BVH_FEATURE(BVH_INSTANCING)
-                num_hits_in_instance++;
-#endif
-
-                isect_array->t = isect_t;
-              }
-
-              prim_addr++;
-            }  // while prim
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-
-#  if BVH_FEATURE(BVH_MOTION)
-          isect_t = bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm);
-#  else
-          isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t);
-#  endif
-
-          num_hits_in_instance = 0;
-          isect_array->t = isect_t;
-
-          obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-          tfar = avxf(isect_t);
-#  if BVH_FEATURE(BVH_HAIR)
-          dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-          idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-          P_idir = P * idir;
-          P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-          org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-
-          node_addr = kernel_tex_fetch(__object_node, object);
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-      if (num_hits_in_instance) {
-        float t_fac;
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
-#  else
-        bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
-#  endif
-        /* Scale isect->t to adjust for instancing. */
-        for (int i = 0; i < num_hits_in_instance; i++) {
-          (isect_array - i - 1)->t *= t_fac;
-        }
-      }
-      else {
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX, &ob_itfm);
-#  else
-        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX);
-#  endif
-      }
-
-      isect_t = tmax;
-      isect_array->t = isect_t;
-
-      obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = avxf(isect_t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-      idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return false;
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/obvh_traversal.h b/intern/cycles/kernel/bvh/obvh_traversal.h
deleted file mode 100644 (file)
index 3f1e036..0000000
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function, where various features can be
- * enabled/disabled. This way we can compile optimized versions for each case
- * without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_HAIR: hair curve rendering
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT obvh_node_intersect
-#else
-#  define NODE_INTERSECT obvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect,
-                                             const uint visibility)
-{
-  /* Traversal stack in CUDA thread-local memory. */
-  OBVHStackItem traversal_stack[BVH_OSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-  traversal_stack[0].dist = -FLT_MAX;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-  float node_dist = -FLT_MAX;
-
-  /* Ray parameters in registers. */
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  isect->t = ray->t;
-  isect->u = 0.0f;
-  isect->v = 0.0f;
-  isect->prim = PRIM_NONE;
-  isect->object = OBJECT_NONE;
-
-  BVH_DEBUG_INIT();
-  avxf tnear(0.0f), tfar(ray->t);
-#if BVH_FEATURE(BVH_HAIR)
-  avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#endif
-  avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  avx3f P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  avx3f org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-        (void)inodes;
-
-        if (UNLIKELY(node_dist > isect->t)
-#if BVH_FEATURE(BVH_MOTION)
-            || UNLIKELY(ray->time < inodes.y) || UNLIKELY(ray->time > inodes.z)
-#endif
-#ifdef __VISIBILITY_FLAG__
-            || (__float_as_uint(inodes.x) & visibility) == 0
-#endif
-        ) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-          continue;
-        }
-
-        int child_mask;
-        avxf dist;
-
-        BVH_DEBUG_NEXT_NODE();
-
-        {
-          child_mask = NODE_INTERSECT(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,
-                                      &dist);
-        }
-
-        if (child_mask != 0) {
-          avxf cnodes;
-          /* TODO(sergey): Investigate whether moving cnodes upwards
-           * gives a speedup (will be different cache pattern but will
-           * avoid extra check here).
-           */
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 26);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 14);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          float d0 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            node_dist = d0;
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              node_dist = d1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              node_dist = d0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            node_dist = traversal_stack[stack_ptr].dist;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c3;
-            traversal_stack[stack_ptr].dist = d3;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            node_dist = traversal_stack[stack_ptr].dist;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-
-          /* Five children are hit, push all onto stack and sort 5
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c4 = __float_as_int(cnodes[r]);
-          float d4 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            node_dist = traversal_stack[stack_ptr].dist;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Six children are hit, push all onto stack and sort 6
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c5 = __float_as_int(cnodes[r]);
-          float d5 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c5;
-            traversal_stack[stack_ptr].dist = d5;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            node_dist = traversal_stack[stack_ptr].dist;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c5;
-          traversal_stack[stack_ptr].dist = d5;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c4;
-          traversal_stack[stack_ptr].dist = d4;
-
-          /* Seven children are hit, push all onto stack and sort 7
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c6 = __float_as_int(cnodes[r]);
-          float d6 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c6;
-            traversal_stack[stack_ptr].dist = d6;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5],
-                            &traversal_stack[stack_ptr - 6]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            node_dist = traversal_stack[stack_ptr].dist;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Eight children are hit, push all onto stack and sort 8
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c7 = __float_as_int(cnodes[r]);
-          float d7 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c7;
-          traversal_stack[stack_ptr].dist = d7;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c6;
-          traversal_stack[stack_ptr].dist = d6;
-          obvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3],
-                          &traversal_stack[stack_ptr - 4],
-                          &traversal_stack[stack_ptr - 5],
-                          &traversal_stack[stack_ptr - 6],
-                          &traversal_stack[stack_ptr - 7]);
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-          continue;
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        node_dist = traversal_stack[stack_ptr].dist;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-
-#ifdef __VISIBILITY_FLAG__
-        if (UNLIKELY((node_dist > isect->t) || ((__float_as_uint(leaf.z) & visibility) == 0)))
-#else
-        if (UNLIKELY((node_dist > isect->t)))
-#endif
-        {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-          continue;
-        }
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          switch (type & PRIMITIVE_ALL) {
-            case PRIMITIVE_TRIANGLE: {
-              int prim_count = prim_addr2 - prim_addr;
-              if (prim_count < 3) {
-                for (; prim_addr < prim_addr2; prim_addr++) {
-                  BVH_DEBUG_NEXT_INTERSECTION();
-                  kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                  if (triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr)) {
-                    tfar = avxf(isect->t);
-                    /* Shadow ray early termination. */
-                    if (visibility == PATH_RAY_SHADOW_OPAQUE) {
-                      return true;
-                    }
-                  }
-                }  // for
-              }
-              else {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                if (triangle_intersect8(kg,
-                                        &isect,
-                                        P,
-                                        dir,
-                                        visibility,
-                                        object,
-                                        prim_addr,
-                                        prim_count,
-                                        0,
-                                        0,
-                                        NULL,
-                                        0.0f)) {
-                  tfar = avxf(isect->t);
-                  if (visibility == PATH_RAY_SHADOW_OPAQUE) {
-                    return true;
-                  }
-                }
-              }  // prim count
-              break;
-            }
-#if BVH_FEATURE(BVH_MOTION)
-            case PRIMITIVE_MOTION_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                BVH_DEBUG_NEXT_INTERSECTION();
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                if (motion_triangle_intersect(
-                        kg, isect, P, dir, ray->time, visibility, object, prim_addr)) {
-                  tfar = avxf(isect->t);
-                  /* Shadow ray early termination. */
-                  if (visibility == PATH_RAY_SHADOW_OPAQUE) {
-                    return true;
-                  }
-                }
-              }
-              break;
-            }
-#endif /* BVH_FEATURE(BVH_MOTION) */
-#if BVH_FEATURE(BVH_HAIR)
-            case PRIMITIVE_CURVE:
-            case PRIMITIVE_MOTION_CURVE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                BVH_DEBUG_NEXT_INTERSECTION();
-                const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
-                kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
-                bool hit = curve_intersect(
-                    kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
-                if (hit) {
-                  tfar = avxf(isect->t);
-                  /* Shadow ray early termination. */
-                  if (visibility == PATH_RAY_SHADOW_OPAQUE) {
-                    return true;
-                  }
-                }
-              }
-              break;
-            }
-#endif /* BVH_FEATURE(BVH_HAIR) */
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-
-#  if BVH_FEATURE(BVH_MOTION)
-          qbvh_instance_motion_push(
-              kg, object, ray, &P, &dir, &idir, &isect->t, &node_dist, &ob_itfm);
-#  else
-          qbvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t, &node_dist);
-#  endif
-
-          obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-          tfar = avxf(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-          dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-          idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-          P_idir = P * idir;
-          P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-          org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-          traversal_stack[stack_ptr].dist = -FLT_MAX;
-
-          node_addr = kernel_tex_fetch(__object_node, object);
-
-          BVH_DEBUG_NEXT_INSTANCE();
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-#  if BVH_FEATURE(BVH_MOTION)
-      isect->t = bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm);
-#  else
-      isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t);
-#  endif
-
-      obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = avxf(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-      idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      node_dist = traversal_stack[stack_ptr].dist;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return (isect->prim != PRIM_NONE);
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/obvh_volume.h b/intern/cycles/kernel/bvh/obvh_volume.h
deleted file mode 100644 (file)
index fb41ae7..0000000
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function for volumes, where
- * various features can be enabled/disabled. This way we can compile optimized
- * versions for each case without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT obvh_node_intersect
-#else
-#  define NODE_INTERSECT obvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect,
-                                             const uint visibility)
-{
-  /* Traversal stack in CUDA thread-local memory. */
-  OBVHStackItem traversal_stack[BVH_OSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-
-  /* Ray parameters in registers. */
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  isect->t = ray->t;
-  isect->u = 0.0f;
-  isect->v = 0.0f;
-  isect->prim = PRIM_NONE;
-  isect->object = OBJECT_NONE;
-
-  avxf tnear(0.0f), tfar(ray->t);
-#if BVH_FEATURE(BVH_HAIR)
-  avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#endif
-  avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-
-#ifdef __VISIBILITY_FLAG__
-        if ((__float_as_uint(inodes.x) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-#endif
-
-        avxf dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          avxf cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 26);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 14);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c3;
-            traversal_stack[stack_ptr].dist = d3;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-
-          /* Five children are hit, push all onto stack and sort 5
-           * stack items, continue with closest child
-           */
-          r = __bscf(child_mask);
-          int c4 = __float_as_int(cnodes[r]);
-          float d4 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Six children are hit, push all onto stack and sort 6
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c5 = __float_as_int(cnodes[r]);
-          float d5 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c5;
-            traversal_stack[stack_ptr].dist = d5;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c5;
-          traversal_stack[stack_ptr].dist = d5;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c4;
-          traversal_stack[stack_ptr].dist = d4;
-
-          /* Seven children are hit, push all onto stack and sort 7
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c6 = __float_as_int(cnodes[r]);
-          float d6 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c6;
-            traversal_stack[stack_ptr].dist = d6;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5],
-                            &traversal_stack[stack_ptr - 6]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Eight children are hit, push all onto stack and sort 8
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c7 = __float_as_int(cnodes[r]);
-          float d7 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c7;
-          traversal_stack[stack_ptr].dist = d7;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c6;
-          traversal_stack[stack_ptr].dist = d6;
-          obvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3],
-                          &traversal_stack[stack_ptr - 4],
-                          &traversal_stack[stack_ptr - 5],
-                          &traversal_stack[stack_ptr - 6],
-                          &traversal_stack[stack_ptr - 7]);
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-
-        if ((__float_as_uint(leaf.z) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-          const uint p_type = type & PRIMITIVE_ALL;
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          switch (p_type) {
-            case PRIMITIVE_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr);
-              }
-              break;
-            }
-#if BVH_FEATURE(BVH_MOTION)
-            case PRIMITIVE_MOTION_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                motion_triangle_intersect(
-                    kg, isect, P, dir, ray->time, visibility, object, prim_addr);
-              }
-              break;
-            }
-#endif
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-          int object_flag = kernel_tex_fetch(__object_flag, object);
-          if (object_flag & SD_OBJECT_HAS_VOLUME) {
-#  if BVH_FEATURE(BVH_MOTION)
-            isect->t = bvh_instance_motion_push(
-                kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm);
-#  else
-            isect->t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect->t);
-#  endif
-
-            obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-            tfar = avxf(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-            dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-            idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-            P_idir = P * idir;
-            P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-            org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-
-            node_addr = kernel_tex_fetch(__object_node, object);
-          }
-          else {
-            /* Pop. */
-            object = OBJECT_NONE;
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-          }
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-#  if BVH_FEATURE(BVH_MOTION)
-      isect->t = bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm);
-#  else
-      isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t);
-#  endif
-
-      obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = avxf(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-      idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return (isect->prim != PRIM_NONE);
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/obvh_volume_all.h b/intern/cycles/kernel/bvh/obvh_volume_all.h
deleted file mode 100644 (file)
index 56e2afd..0000000
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function for volumes, where
- * various features can be enabled/disabled. This way we can compile optimized
- * versions for each case without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT obvh_node_intersect
-#else
-#  define NODE_INTERSECT obvh_aligned_node_intersect
-#endif
-
-ccl_device uint BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect_array,
-                                             const uint max_hits,
-                                             const uint visibility)
-{
-  /* Traversal stack in CUDA thread-local memory. */
-  OBVHStackItem traversal_stack[BVH_OSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-
-  /* Ray parameters in registers. */
-  const float tmax = ray->t;
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-  float isect_t = tmax;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  uint num_hits = 0;
-  isect_array->t = tmax;
-
-#if BVH_FEATURE(BVH_INSTANCING)
-  int num_hits_in_instance = 0;
-#endif
-
-  avxf tnear(0.0f), tfar(isect_t);
-#if BVH_FEATURE(BVH_HAIR)
-  avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#endif
-  avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-
-#ifdef __VISIBILITY_FLAG__
-        if ((__float_as_uint(inodes.x) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-#endif
-
-        avxf dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          avxf cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 26);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr + 14);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c3;
-            traversal_stack[stack_ptr].dist = d3;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-
-          /* Five children are hit, push all onto stack and sort 5
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c4 = __float_as_int(cnodes[r]);
-          float d4 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Six children are hit, push all onto stack and sort 6
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c5 = __float_as_int(cnodes[r]);
-          float d5 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c5;
-            traversal_stack[stack_ptr].dist = d5;
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c4;
-            traversal_stack[stack_ptr].dist = d4;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c5;
-          traversal_stack[stack_ptr].dist = d5;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c4;
-          traversal_stack[stack_ptr].dist = d4;
-
-          /* Seven children are hit, push all onto stack and sort 7
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c6 = __float_as_int(cnodes[r]);
-          float d6 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c6;
-            traversal_stack[stack_ptr].dist = d6;
-            obvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2],
-                            &traversal_stack[stack_ptr - 3],
-                            &traversal_stack[stack_ptr - 4],
-                            &traversal_stack[stack_ptr - 5],
-                            &traversal_stack[stack_ptr - 6]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Eight children are hit, push all onto stack and sort 8
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c7 = __float_as_int(cnodes[r]);
-          float d7 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c7;
-          traversal_stack[stack_ptr].dist = d7;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c6;
-          traversal_stack[stack_ptr].dist = d6;
-          obvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3],
-                          &traversal_stack[stack_ptr - 4],
-                          &traversal_stack[stack_ptr - 5],
-                          &traversal_stack[stack_ptr - 6],
-                          &traversal_stack[stack_ptr - 7]);
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-
-        if ((__float_as_uint(leaf.z) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-          const uint p_type = type & PRIMITIVE_ALL;
-          bool hit;
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          switch (p_type) {
-            case PRIMITIVE_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                hit = triangle_intersect(kg, isect_array, P, dir, visibility, object, prim_addr);
-                if (hit) {
-                  /* Move on to next entry in intersections array. */
-                  isect_array++;
-                  num_hits++;
-#if BVH_FEATURE(BVH_INSTANCING)
-                  num_hits_in_instance++;
-#endif
-                  isect_array->t = isect_t;
-                  if (num_hits == max_hits) {
-#if BVH_FEATURE(BVH_INSTANCING)
-#  if BVH_FEATURE(BVH_MOTION)
-                    float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
-#  else
-                    Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
-                    float t_fac = 1.0f / len(transform_direction(&itfm, dir));
-#  endif
-                    for (int i = 0; i < num_hits_in_instance; i++) {
-                      (isect_array - i - 1)->t *= t_fac;
-                    }
-#endif /* BVH_FEATURE(BVH_INSTANCING) */
-                    return num_hits;
-                  }
-                }
-              }
-              break;
-            }
-#if BVH_FEATURE(BVH_MOTION)
-            case PRIMITIVE_MOTION_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                hit = motion_triangle_intersect(
-                    kg, isect_array, P, dir, ray->time, visibility, object, prim_addr);
-                if (hit) {
-                  /* Move on to next entry in intersections array. */
-                  isect_array++;
-                  num_hits++;
-#  if BVH_FEATURE(BVH_INSTANCING)
-                  num_hits_in_instance++;
-#  endif
-                  isect_array->t = isect_t;
-                  if (num_hits == max_hits) {
-#  if BVH_FEATURE(BVH_INSTANCING)
-#    if BVH_FEATURE(BVH_MOTION)
-                    float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
-#    else
-                    Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
-                    float t_fac = 1.0f / len(transform_direction(&itfm, dir));
-#    endif
-                    for (int i = 0; i < num_hits_in_instance; i++) {
-                      (isect_array - i - 1)->t *= t_fac;
-                    }
-#  endif /* BVH_FEATURE(BVH_INSTANCING) */
-                    return num_hits;
-                  }
-                }
-              }
-              break;
-            }
-#endif
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-          int object_flag = kernel_tex_fetch(__object_flag, object);
-          if (object_flag & SD_OBJECT_HAS_VOLUME) {
-#  if BVH_FEATURE(BVH_MOTION)
-            isect_t = bvh_instance_motion_push(
-                kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm);
-#  else
-            isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t);
-#  endif
-
-            obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-            tfar = avxf(isect_t);
-            idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  if BVH_FEATURE(BVH_HAIR)
-            dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-#  ifdef __KERNEL_AVX2__
-            P_idir = P * idir;
-            P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-            org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-            num_hits_in_instance = 0;
-            isect_array->t = isect_t;
-
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_OSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-
-            node_addr = kernel_tex_fetch(__object_node, object);
-          }
-          else {
-            /* Pop. */
-            object = OBJECT_NONE;
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-          }
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-      if (num_hits_in_instance) {
-        float t_fac;
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
-#  else
-        bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
-#  endif
-        /* Scale isect->t to adjust for instancing. */
-        for (int i = 0; i < num_hits_in_instance; i++) {
-          (isect_array - i - 1)->t *= t_fac;
-        }
-      }
-      else {
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX, &ob_itfm);
-#  else
-        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX);
-#  endif
-      }
-
-      isect_t = tmax;
-      isect_array->t = isect_t;
-
-      obvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = avxf(isect_t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z));
-#  endif
-      idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return num_hits;
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/qbvh_local.h b/intern/cycles/kernel/bvh/qbvh_local.h
deleted file mode 100644 (file)
index b21f79b..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function for finding local intersections
- * around the shading point, for subsurface scattering and bevel. We disable
- * various features for performance, and for instanced objects avoid traversing
- * other parts of the scene.
- *
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT qbvh_node_intersect
-#else
-#  define NODE_INTERSECT qbvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             LocalIntersection *local_isect,
-                                             int local_object,
-                                             uint *lcg_state,
-                                             int max_hits)
-{
-  /* TODO(sergey):
-   * - Test if pushing distance on the stack helps (for non shadow rays).
-   * - Separate version for shadow rays.
-   * - Likely and unlikely for if() statements.
-   * - SSE for hair.
-   * - Test restrict attribute for pointers.
-   */
-
-  /* Traversal stack in CUDA thread-local memory. */
-  QBVHStackItem traversal_stack[BVH_QSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_tex_fetch(__object_node, local_object);
-
-  /* Ray parameters in registers. */
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-  float isect_t = ray->t;
-
-  if (local_isect != NULL) {
-    local_isect->num_hits = 0;
-  }
-  kernel_assert((local_isect == NULL) == (max_hits == 0));
-
-  const int object_flag = kernel_tex_fetch(__object_flag, local_object);
-  if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
-#if BVH_FEATURE(BVH_MOTION)
-    Transform ob_itfm;
-    isect_t = bvh_instance_motion_push(kg, local_object, ray, &P, &dir, &idir, isect_t, &ob_itfm);
-#else
-    isect_t = bvh_instance_push(kg, local_object, ray, &P, &dir, &idir, isect_t);
-#endif
-    object = local_object;
-  }
-
-  ssef tnear(0.0f), tfar(isect_t);
-#if BVH_FEATURE(BVH_HAIR)
-  sse3f dir4(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#endif
-  sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  sse3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  sse3f org4(ssef(P.x), ssef(P.y), ssef(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        ssef dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-          float4 cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 13);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 7);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            qbvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-          qbvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3]);
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-        int prim_addr = __float_as_int(leaf.x);
-
-        int prim_addr2 = __float_as_int(leaf.y);
-        const uint type = __float_as_int(leaf.w);
-
-        /* Pop. */
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-
-        /* Primitive intersection. */
-        switch (type & PRIMITIVE_ALL) {
-          case PRIMITIVE_TRIANGLE: {
-            /* Intersect ray against primitive, */
-            for (; prim_addr < prim_addr2; prim_addr++) {
-              kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-              if (triangle_intersect_local(kg,
-                                           local_isect,
-                                           P,
-                                           dir,
-                                           object,
-                                           local_object,
-                                           prim_addr,
-                                           isect_t,
-                                           lcg_state,
-                                           max_hits)) {
-                return true;
-              }
-            }
-            break;
-          }
-#if BVH_FEATURE(BVH_MOTION)
-          case PRIMITIVE_MOTION_TRIANGLE: {
-            /* Intersect ray against primitive. */
-            for (; prim_addr < prim_addr2; prim_addr++) {
-              kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-              if (motion_triangle_intersect_local(kg,
-                                                  local_isect,
-                                                  P,
-                                                  dir,
-                                                  ray->time,
-                                                  object,
-                                                  local_object,
-                                                  prim_addr,
-                                                  isect_t,
-                                                  lcg_state,
-                                                  max_hits)) {
-                return true;
-              }
-            }
-            break;
-          }
-#endif
-          default:
-            break;
-        }
-      }
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return false;
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/qbvh_nodes.h b/intern/cycles/kernel/bvh/qbvh_nodes.h
deleted file mode 100644 (file)
index 070406f..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright 2011-2014, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Aligned nodes intersection SSE code is adopted from Embree,
- */
-
-struct QBVHStackItem {
-  int addr;
-  float dist;
-};
-
-ccl_device_inline void qbvh_near_far_idx_calc(const float3 &idir,
-                                              int *ccl_restrict near_x,
-                                              int *ccl_restrict near_y,
-                                              int *ccl_restrict near_z,
-                                              int *ccl_restrict far_x,
-                                              int *ccl_restrict far_y,
-                                              int *ccl_restrict far_z)
-
-{
-#ifdef __KERNEL_SSE__
-  *near_x = 0;
-  *far_x = 1;
-  *near_y = 2;
-  *far_y = 3;
-  *near_z = 4;
-  *far_z = 5;
-
-  const size_t mask = movemask(ssef(idir.m128));
-
-  const int mask_x = mask & 1;
-  const int mask_y = (mask & 2) >> 1;
-  const int mask_z = (mask & 4) >> 2;
-
-  *near_x += mask_x;
-  *far_x -= mask_x;
-  *near_y += mask_y;
-  *far_y -= mask_y;
-  *near_z += mask_z;
-  *far_z -= mask_z;
-#else
-  if (idir.x >= 0.0f) {
-    *near_x = 0;
-    *far_x = 1;
-  }
-  else {
-    *near_x = 1;
-    *far_x = 0;
-  }
-  if (idir.y >= 0.0f) {
-    *near_y = 2;
-    *far_y = 3;
-  }
-  else {
-    *near_y = 3;
-    *far_y = 2;
-  }
-  if (idir.z >= 0.0f) {
-    *near_z = 4;
-    *far_z = 5;
-  }
-  else {
-    *near_z = 5;
-    *far_z = 4;
-  }
-#endif
-}
-
-/* TOOD(sergey): Investigate if using intrinsics helps for both
- * stack item swap and float comparison.
- */
-ccl_device_inline void qbvh_item_swap(QBVHStackItem *ccl_restrict a, QBVHStackItem *ccl_restrict b)
-{
-  QBVHStackItem tmp = *a;
-  *a = *b;
-  *b = tmp;
-}
-
-ccl_device_inline void qbvh_stack_sort(QBVHStackItem *ccl_restrict s1,
-                                       QBVHStackItem *ccl_restrict s2,
-                                       QBVHStackItem *ccl_restrict s3)
-{
-  if (s2->dist < s1->dist) {
-    qbvh_item_swap(s2, s1);
-  }
-  if (s3->dist < s2->dist) {
-    qbvh_item_swap(s3, s2);
-  }
-  if (s2->dist < s1->dist) {
-    qbvh_item_swap(s2, s1);
-  }
-}
-
-ccl_device_inline void qbvh_stack_sort(QBVHStackItem *ccl_restrict s1,
-                                       QBVHStackItem *ccl_restrict s2,
-                                       QBVHStackItem *ccl_restrict s3,
-                                       QBVHStackItem *ccl_restrict s4)
-{
-  if (s2->dist < s1->dist) {
-    qbvh_item_swap(s2, s1);
-  }
-  if (s4->dist < s3->dist) {
-    qbvh_item_swap(s4, s3);
-  }
-  if (s3->dist < s1->dist) {
-    qbvh_item_swap(s3, s1);
-  }
-  if (s4->dist < s2->dist) {
-    qbvh_item_swap(s4, s2);
-  }
-  if (s3->dist < s2->dist) {
-    qbvh_item_swap(s3, s2);
-  }
-}
-
-/* Axis-aligned nodes intersection */
-
-// ccl_device_inline int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
-static int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
-                                       const ssef &isect_near,
-                                       const ssef &isect_far,
-#ifdef __KERNEL_AVX2__
-                                       const sse3f &org_idir,
-#else
-                                       const sse3f &org,
-#endif
-                                       const sse3f &idir,
-                                       const int near_x,
-                                       const int near_y,
-                                       const int near_z,
-                                       const int far_x,
-                                       const int far_y,
-                                       const int far_z,
-                                       const int node_addr,
-                                       ssef *ccl_restrict dist)
-{
-  const int offset = node_addr + 1;
-#ifdef __KERNEL_AVX2__
-  const ssef tnear_x = msub(
-      kernel_tex_fetch_ssef(__bvh_nodes, offset + near_x), idir.x, org_idir.x);
-  const ssef tnear_y = msub(
-      kernel_tex_fetch_ssef(__bvh_nodes, offset + near_y), idir.y, org_idir.y);
-  const ssef tnear_z = msub(
-      kernel_tex_fetch_ssef(__bvh_nodes, offset + near_z), idir.z, org_idir.z);
-  const ssef tfar_x = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + far_x), idir.x, org_idir.x);
-  const ssef tfar_y = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + far_y), idir.y, org_idir.y);
-  const ssef tfar_z = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + far_z), idir.z, org_idir.z);
-#else
-  const ssef tnear_x = (kernel_tex_fetch_ssef(__bvh_nodes, offset + near_x) - org.x) * idir.x;
-  const ssef tnear_y = (kernel_tex_fetch_ssef(__bvh_nodes, offset + near_y) - org.y) * idir.y;
-  const ssef tnear_z = (kernel_tex_fetch_ssef(__bvh_nodes, offset + near_z) - org.z) * idir.z;
-  const ssef tfar_x = (kernel_tex_fetch_ssef(__bvh_nodes, offset + far_x) - org.x) * idir.x;
-  const ssef tfar_y = (kernel_tex_fetch_ssef(__bvh_nodes, offset + far_y) - org.y) * idir.y;
-  const ssef tfar_z = (kernel_tex_fetch_ssef(__bvh_nodes, offset + far_z) - org.z) * idir.z;
-#endif
-
-#ifdef __KERNEL_SSE41__
-  const ssef tnear = maxi(maxi(tnear_x, tnear_y), maxi(tnear_z, isect_near));
-  const ssef tfar = mini(mini(tfar_x, tfar_y), mini(tfar_z, isect_far));
-  const sseb vmask = cast(tnear) > cast(tfar);
-  int mask = (int)movemask(vmask) ^ 0xf;
-#else
-  const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
-  const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
-  const sseb vmask = tnear <= tfar;
-  int mask = (int)movemask(vmask);
-#endif
-  *dist = tnear;
-  return mask;
-}
-
-/* Unaligned nodes intersection */
-
-ccl_device_inline int qbvh_unaligned_node_intersect(KernelGlobals *ccl_restrict kg,
-                                                    const ssef &isect_near,
-                                                    const ssef &isect_far,
-#ifdef __KERNEL_AVX2__
-                                                    const sse3f &org_idir,
-#endif
-                                                    const sse3f &org,
-                                                    const sse3f &dir,
-                                                    const sse3f &idir,
-                                                    const int near_x,
-                                                    const int near_y,
-                                                    const int near_z,
-                                                    const int far_x,
-                                                    const int far_y,
-                                                    const int far_z,
-                                                    const int node_addr,
-                                                    ssef *ccl_restrict dist)
-{
-  const int offset = node_addr;
-  const ssef tfm_x_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 1);
-  const ssef tfm_x_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 2);
-  const ssef tfm_x_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 3);
-
-  const ssef tfm_y_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 4);
-  const ssef tfm_y_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 5);
-  const ssef tfm_y_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 6);
-
-  const ssef tfm_z_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 7);
-  const ssef tfm_z_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 8);
-  const ssef tfm_z_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 9);
-
-  const ssef tfm_t_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 10);
-  const ssef tfm_t_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 11);
-  const ssef tfm_t_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 12);
-
-  const ssef aligned_dir_x = dir.x * tfm_x_x + dir.y * tfm_x_y + dir.z * tfm_x_z,
-             aligned_dir_y = dir.x * tfm_y_x + dir.y * tfm_y_y + dir.z * tfm_y_z,
-             aligned_dir_z = dir.x * tfm_z_x + dir.y * tfm_z_y + dir.z * tfm_z_z;
-
-  const ssef aligned_P_x = org.x * tfm_x_x + org.y * tfm_x_y + org.z * tfm_x_z + tfm_t_x,
-             aligned_P_y = org.x * tfm_y_x + org.y * tfm_y_y + org.z * tfm_y_z + tfm_t_y,
-             aligned_P_z = org.x * tfm_z_x + org.y * tfm_z_y + org.z * tfm_z_z + tfm_t_z;
-
-  const ssef neg_one(-1.0f, -1.0f, -1.0f, -1.0f);
-  const ssef nrdir_x = neg_one / aligned_dir_x, nrdir_y = neg_one / aligned_dir_y,
-             nrdir_z = neg_one / aligned_dir_z;
-
-  const ssef tlower_x = aligned_P_x * nrdir_x, tlower_y = aligned_P_y * nrdir_y,
-             tlower_z = aligned_P_z * nrdir_z;
-
-  const ssef tupper_x = tlower_x - nrdir_x, tupper_y = tlower_y - nrdir_y,
-             tupper_z = tlower_z - nrdir_z;
-
-#ifdef __KERNEL_SSE41__
-  const ssef tnear_x = mini(tlower_x, tupper_x);
-  const ssef tnear_y = mini(tlower_y, tupper_y);
-  const ssef tnear_z = mini(tlower_z, tupper_z);
-  const ssef tfar_x = maxi(tlower_x, tupper_x);
-  const ssef tfar_y = maxi(tlower_y, tupper_y);
-  const ssef tfar_z = maxi(tlower_z, tupper_z);
-  const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
-  const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
-  const sseb vmask = tnear <= tfar;
-  *dist = tnear;
-  return movemask(vmask);
-#else
-  const ssef tnear_x = min(tlower_x, tupper_x);
-  const ssef tnear_y = min(tlower_y, tupper_y);
-  const ssef tnear_z = min(tlower_z, tupper_z);
-  const ssef tfar_x = max(tlower_x, tupper_x);
-  const ssef tfar_y = max(tlower_y, tupper_y);
-  const ssef tfar_z = max(tlower_z, tupper_z);
-  const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
-  const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
-  const sseb vmask = tnear <= tfar;
-  *dist = tnear;
-  return movemask(vmask);
-#endif
-}
-
-/* Intersectors wrappers.
- *
- * They'll check node type and call appropriate intersection code.
- */
-
-ccl_device_inline int qbvh_node_intersect(KernelGlobals *ccl_restrict kg,
-                                          const ssef &isect_near,
-                                          const ssef &isect_far,
-#ifdef __KERNEL_AVX2__
-                                          const sse3f &org_idir,
-#endif
-                                          const sse3f &org,
-                                          const sse3f &dir,
-                                          const sse3f &idir,
-                                          const int near_x,
-                                          const int near_y,
-                                          const int near_z,
-                                          const int far_x,
-                                          const int far_y,
-                                          const int far_z,
-                                          const int node_addr,
-                                          ssef *ccl_restrict dist)
-{
-  const int offset = node_addr;
-  const float4 node = kernel_tex_fetch(__bvh_nodes, offset);
-  if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
-    return qbvh_unaligned_node_intersect(kg,
-                                         isect_near,
-                                         isect_far,
-#ifdef __KERNEL_AVX2__
-                                         org_idir,
-#endif
-                                         org,
-                                         dir,
-                                         idir,
-                                         near_x,
-                                         near_y,
-                                         near_z,
-                                         far_x,
-                                         far_y,
-                                         far_z,
-                                         node_addr,
-                                         dist);
-  }
-  else {
-    return qbvh_aligned_node_intersect(kg,
-                                       isect_near,
-                                       isect_far,
-#ifdef __KERNEL_AVX2__
-                                       org_idir,
-#else
-                                       org,
-#endif
-                                       idir,
-                                       near_x,
-                                       near_y,
-                                       near_z,
-                                       far_x,
-                                       far_y,
-                                       far_z,
-                                       node_addr,
-                                       dist);
-  }
-}
diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
deleted file mode 100644 (file)
index 9d428c3..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function, where various features can be
- * enabled/disabled. This way we can compile optimized versions for each case
- * without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_HAIR: hair curve rendering
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT qbvh_node_intersect
-#else
-#  define NODE_INTERSECT qbvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect_array,
-                                             const uint visibility,
-                                             const uint max_hits,
-                                             uint *num_hits)
-{
-  /* TODO(sergey):
-   *  - Test if pushing distance on the stack helps.
-   * - Likely and unlikely for if() statements.
-   * - Test restrict attribute for pointers.
-   */
-
-  /* Traversal stack in CUDA thread-local memory. */
-  QBVHStackItem traversal_stack[BVH_QSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-
-  /* Ray parameters in registers. */
-  const float tmax = ray->t;
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-  float isect_t = tmax;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  *num_hits = 0;
-  isect_array->t = tmax;
-
-#if BVH_FEATURE(BVH_INSTANCING)
-  int num_hits_in_instance = 0;
-#endif
-
-  ssef tnear(0.0f), tfar(isect_t);
-#if BVH_FEATURE(BVH_HAIR)
-  sse3f dir4(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#endif
-  sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  sse3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  sse3f org4(ssef(P.x), ssef(P.y), ssef(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-        (void)inodes;
-
-        if (false
-#ifdef __VISIBILITY_FLAG__
-            || ((__float_as_uint(inodes.x) & visibility) == 0)
-#endif
-#if BVH_FEATURE(BVH_MOTION)
-            || UNLIKELY(ray->time < inodes.y) || UNLIKELY(ray->time > inodes.z)
-#endif
-        ) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        ssef dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          float4 cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 13);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 7);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            qbvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-          qbvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3]);
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-#ifdef __VISIBILITY_FLAG__
-        if ((__float_as_uint(leaf.z) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-#endif
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-          const uint p_type = type & PRIMITIVE_ALL;
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          while (prim_addr < prim_addr2) {
-            kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type);
-            bool hit;
-
-            /* todo: specialized intersect functions which don't fill in
-             * isect unless needed and check SD_HAS_TRANSPARENT_SHADOW?
-             * might give a few % performance improvement */
-
-            switch (p_type) {
-              case PRIMITIVE_TRIANGLE: {
-                hit = triangle_intersect(kg, isect_array, P, dir, visibility, object, prim_addr);
-                break;
-              }
-#if BVH_FEATURE(BVH_MOTION)
-              case PRIMITIVE_MOTION_TRIANGLE: {
-                hit = motion_triangle_intersect(
-                    kg, isect_array, P, dir, ray->time, visibility, object, prim_addr);
-                break;
-              }
-#endif
-#if BVH_FEATURE(BVH_HAIR)
-              case PRIMITIVE_CURVE:
-              case PRIMITIVE_MOTION_CURVE: {
-                const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
-                hit = curve_intersect(
-                    kg, isect_array, P, dir, visibility, object, prim_addr, ray->time, curve_type);
-                break;
-              }
-#endif
-              default: {
-                hit = false;
-                break;
-              }
-            }
-
-            /* Shadow ray early termination. */
-            if (hit) {
-              /* detect if this surface has a shader with transparent shadows */
-
-              /* todo: optimize so primitive visibility flag indicates if
-               * the primitive has a transparent shadow shader? */
-              int prim = kernel_tex_fetch(__prim_index, isect_array->prim);
-              int shader = 0;
-
-#ifdef __HAIR__
-              if (kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE)
-#endif
-              {
-                shader = kernel_tex_fetch(__tri_shader, prim);
-              }
-#ifdef __HAIR__
-              else {
-                float4 str = kernel_tex_fetch(__curves, prim);
-                shader = __float_as_int(str.z);
-              }
-#endif
-              int flag = kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags;
-
-              /* if no transparent shadows, all light is blocked */
-              if (!(flag & SD_HAS_TRANSPARENT_SHADOW)) {
-                return true;
-              }
-              /* if maximum number of hits reached, block all light */
-              else if (*num_hits == max_hits) {
-                return true;
-              }
-
-              /* move on to next entry in intersections array */
-              isect_array++;
-              (*num_hits)++;
-#if BVH_FEATURE(BVH_INSTANCING)
-              num_hits_in_instance++;
-#endif
-
-              isect_array->t = isect_t;
-            }
-
-            prim_addr++;
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-
-#  if BVH_FEATURE(BVH_MOTION)
-          isect_t = bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm);
-#  else
-          isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t);
-#  endif
-
-          num_hits_in_instance = 0;
-          isect_array->t = isect_t;
-
-          qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-          tfar = ssef(isect_t);
-#  if BVH_FEATURE(BVH_HAIR)
-          dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-          idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-          P_idir = P * idir;
-          P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-          org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-
-          node_addr = kernel_tex_fetch(__object_node, object);
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-      if (num_hits_in_instance) {
-        float t_fac;
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
-#  else
-        bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
-#  endif
-        /* Scale isect->t to adjust for instancing. */
-        for (int i = 0; i < num_hits_in_instance; i++) {
-          (isect_array - i - 1)->t *= t_fac;
-        }
-      }
-      else {
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX, &ob_itfm);
-#  else
-        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX);
-#  endif
-      }
-
-      isect_t = tmax;
-      isect_array->t = isect_t;
-
-      qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = ssef(isect_t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-      idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return false;
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h
deleted file mode 100644 (file)
index f68579b..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function, where various features can be
- * enabled/disabled. This way we can compile optimized versions for each case
- * without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_HAIR: hair curve rendering
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT qbvh_node_intersect
-#else
-#  define NODE_INTERSECT qbvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect,
-                                             const uint visibility)
-{
-  /* TODO(sergey):
-   * - Test if pushing distance on the stack helps (for non shadow rays).
-   * - Separate version for shadow rays.
-   * - Likely and unlikely for if() statements.
-   * - Test restrict attribute for pointers.
-   */
-
-  /* Traversal stack in CUDA thread-local memory. */
-  QBVHStackItem traversal_stack[BVH_QSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-  traversal_stack[0].dist = -FLT_MAX;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-  float node_dist = -FLT_MAX;
-
-  /* Ray parameters in registers. */
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  isect->t = ray->t;
-  isect->u = 0.0f;
-  isect->v = 0.0f;
-  isect->prim = PRIM_NONE;
-  isect->object = OBJECT_NONE;
-
-  BVH_DEBUG_INIT();
-
-  ssef tnear(0.0f), tfar(ray->t);
-#if BVH_FEATURE(BVH_HAIR)
-  sse3f dir4(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#endif
-  sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  sse3f P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  sse3f org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-        (void)inodes;
-
-        if (UNLIKELY(node_dist > isect->t)
-#if BVH_FEATURE(BVH_MOTION)
-            || UNLIKELY(ray->time < inodes.y) || UNLIKELY(ray->time > inodes.z)
-#endif
-#ifdef __VISIBILITY_FLAG__
-            || (__float_as_uint(inodes.x) & visibility) == 0
-#endif
-        ) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-          continue;
-        }
-
-        int child_mask;
-        ssef dist;
-
-        BVH_DEBUG_NEXT_NODE();
-
-        {
-          child_mask = NODE_INTERSECT(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,
-                                      &dist);
-        }
-
-        if (child_mask != 0) {
-          float4 cnodes;
-          /* TODO(sergey): Investigate whether moving cnodes upwards
-           * gives a speedup (will be different cache pattern but will
-           * avoid extra check here).
-           */
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 13);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 7);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          float d0 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            node_dist = d0;
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              node_dist = d1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              node_dist = d0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            qbvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            node_dist = traversal_stack[stack_ptr].dist;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-          qbvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3]);
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        node_dist = traversal_stack[stack_ptr].dist;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-
-#ifdef __VISIBILITY_FLAG__
-        if (UNLIKELY((node_dist > isect->t) || ((__float_as_uint(leaf.z) & visibility) == 0)))
-#else
-        if (UNLIKELY((node_dist > isect->t)))
-#endif
-        {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-          continue;
-        }
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          node_dist = traversal_stack[stack_ptr].dist;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          switch (type & PRIMITIVE_ALL) {
-            case PRIMITIVE_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                BVH_DEBUG_NEXT_INTERSECTION();
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                if (triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr)) {
-                  tfar = ssef(isect->t);
-                  /* Shadow ray early termination. */
-                  if (visibility & PATH_RAY_SHADOW_OPAQUE) {
-                    return true;
-                  }
-                }
-              }
-              break;
-            }
-#if BVH_FEATURE(BVH_MOTION)
-            case PRIMITIVE_MOTION_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                BVH_DEBUG_NEXT_INTERSECTION();
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                if (motion_triangle_intersect(
-                        kg, isect, P, dir, ray->time, visibility, object, prim_addr)) {
-                  tfar = ssef(isect->t);
-                  /* Shadow ray early termination. */
-                  if (visibility & PATH_RAY_SHADOW_OPAQUE) {
-                    return true;
-                  }
-                }
-              }
-              break;
-            }
-#endif /* BVH_FEATURE(BVH_MOTION) */
-#if BVH_FEATURE(BVH_HAIR)
-            case PRIMITIVE_CURVE:
-            case PRIMITIVE_MOTION_CURVE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                BVH_DEBUG_NEXT_INTERSECTION();
-                const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
-                kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
-                bool hit = curve_intersect(
-                    kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
-                if (hit) {
-                  tfar = ssef(isect->t);
-                  /* Shadow ray early termination. */
-                  if (visibility & PATH_RAY_SHADOW_OPAQUE) {
-                    return true;
-                  }
-                }
-              }
-              break;
-            }
-#endif /* BVH_FEATURE(BVH_HAIR) */
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-
-#  if BVH_FEATURE(BVH_MOTION)
-          qbvh_instance_motion_push(
-              kg, object, ray, &P, &dir, &idir, &isect->t, &node_dist, &ob_itfm);
-#  else
-          qbvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t, &node_dist);
-#  endif
-
-          qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-          tfar = ssef(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-          dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-          idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-          P_idir = P * idir;
-          P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-          org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-          traversal_stack[stack_ptr].dist = -FLT_MAX;
-
-          node_addr = kernel_tex_fetch(__object_node, object);
-
-          BVH_DEBUG_NEXT_INSTANCE();
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-#  if BVH_FEATURE(BVH_MOTION)
-      isect->t = bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm);
-#  else
-      isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t);
-#  endif
-
-      qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = ssef(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-      idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      node_dist = traversal_stack[stack_ptr].dist;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return (isect->prim != PRIM_NONE);
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/qbvh_volume.h b/intern/cycles/kernel/bvh/qbvh_volume.h
deleted file mode 100644 (file)
index e4eaed0..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function for volumes, where
- * various features can be enabled/disabled. This way we can compile optimized
- * versions for each case without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT qbvh_node_intersect
-#else
-#  define NODE_INTERSECT qbvh_aligned_node_intersect
-#endif
-
-ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect,
-                                             const uint visibility)
-{
-  /* TODO(sergey):
-   * - Test if pushing distance on the stack helps.
-   * - Likely and unlikely for if() statements.
-   * - Test restrict attribute for pointers.
-   */
-
-  /* Traversal stack in CUDA thread-local memory. */
-  QBVHStackItem traversal_stack[BVH_QSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-
-  /* Ray parameters in registers. */
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  isect->t = ray->t;
-  isect->u = 0.0f;
-  isect->v = 0.0f;
-  isect->prim = PRIM_NONE;
-  isect->object = OBJECT_NONE;
-
-  ssef tnear(0.0f), tfar(ray->t);
-#if BVH_FEATURE(BVH_HAIR)
-  sse3f dir4(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#endif
-  sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  sse3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  sse3f org4(ssef(P.x), ssef(P.y), ssef(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-
-#ifdef __VISIBILITY_FLAG__
-        if ((__float_as_uint(inodes.x) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-#endif
-
-        ssef dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          float4 cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 13);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 7);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            qbvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-          qbvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3]);
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-
-        if ((__float_as_uint(leaf.z) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-          const uint p_type = type & PRIMITIVE_ALL;
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          switch (p_type) {
-            case PRIMITIVE_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr);
-              }
-              break;
-            }
-#if BVH_FEATURE(BVH_MOTION)
-            case PRIMITIVE_MOTION_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                motion_triangle_intersect(
-                    kg, isect, P, dir, ray->time, visibility, object, prim_addr);
-              }
-              break;
-            }
-#endif
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-          int object_flag = kernel_tex_fetch(__object_flag, object);
-          if (object_flag & SD_OBJECT_HAS_VOLUME) {
-#  if BVH_FEATURE(BVH_MOTION)
-            isect->t = bvh_instance_motion_push(
-                kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm);
-#  else
-            isect->t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect->t);
-#  endif
-
-            qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-            tfar = ssef(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-            dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-            idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-            P_idir = P * idir;
-            P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-            org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-
-            node_addr = kernel_tex_fetch(__object_node, object);
-          }
-          else {
-            /* Pop. */
-            object = OBJECT_NONE;
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-          }
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-#  if BVH_FEATURE(BVH_MOTION)
-      isect->t = bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm);
-#  else
-      isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t);
-#  endif
-
-      qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = ssef(isect->t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-      idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return (isect->prim != PRIM_NONE);
-}
-
-#undef NODE_INTERSECT
diff --git a/intern/cycles/kernel/bvh/qbvh_volume_all.h b/intern/cycles/kernel/bvh/qbvh_volume_all.h
deleted file mode 100644 (file)
index eddc48c..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This is a template BVH traversal function for volumes, where
- * various features can be enabled/disabled. This way we can compile optimized
- * versions for each case without new features slowing things down.
- *
- * BVH_INSTANCING: object instancing
- * BVH_MOTION: motion blur rendering
- */
-
-#if BVH_FEATURE(BVH_HAIR)
-#  define NODE_INTERSECT qbvh_node_intersect
-#else
-#  define NODE_INTERSECT qbvh_aligned_node_intersect
-#endif
-
-ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
-                                             const Ray *ray,
-                                             Intersection *isect_array,
-                                             const uint max_hits,
-                                             const uint visibility)
-{
-  /* TODO(sergey):
-   * - Test if pushing distance on the stack helps.
-   * - Likely and unlikely for if() statements.
-   * - Test restrict attribute for pointers.
-   */
-
-  /* Traversal stack in CUDA thread-local memory. */
-  QBVHStackItem traversal_stack[BVH_QSTACK_SIZE];
-  traversal_stack[0].addr = ENTRYPOINT_SENTINEL;
-
-  /* Traversal variables in registers. */
-  int stack_ptr = 0;
-  int node_addr = kernel_data.bvh.root;
-
-  /* Ray parameters in registers. */
-  const float tmax = ray->t;
-  float3 P = ray->P;
-  float3 dir = bvh_clamp_direction(ray->D);
-  float3 idir = bvh_inverse_direction(dir);
-  int object = OBJECT_NONE;
-  float isect_t = tmax;
-
-#if BVH_FEATURE(BVH_MOTION)
-  Transform ob_itfm;
-#endif
-
-  uint num_hits = 0;
-  isect_array->t = tmax;
-
-#if BVH_FEATURE(BVH_INSTANCING)
-  int num_hits_in_instance = 0;
-#endif
-
-  ssef tnear(0.0f), tfar(isect_t);
-#if BVH_FEATURE(BVH_HAIR)
-  sse3f dir4(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#endif
-  sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-
-#ifdef __KERNEL_AVX2__
-  float3 P_idir = P * idir;
-  sse3f P_idir4(P_idir.x, P_idir.y, P_idir.z);
-#endif
-#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-  sse3f org4(ssef(P.x), ssef(P.y), ssef(P.z));
-#endif
-
-  /* Offsets to select the side that becomes the lower or upper bound. */
-  int near_x, near_y, near_z;
-  int far_x, far_y, far_z;
-  qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-
-  /* Traversal loop. */
-  do {
-    do {
-      /* Traverse internal nodes. */
-      while (node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) {
-        float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-
-#ifdef __VISIBILITY_FLAG__
-        if ((__float_as_uint(inodes.x) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-#endif
-
-        ssef dist;
-        int child_mask = NODE_INTERSECT(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,
-                                        &dist);
-
-        if (child_mask != 0) {
-          float4 cnodes;
-#if BVH_FEATURE(BVH_HAIR)
-          if (__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 13);
-          }
-          else
-#endif
-          {
-            cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 7);
-          }
-
-          /* One child is hit, continue with that child. */
-          int r = __bscf(child_mask);
-          if (child_mask == 0) {
-            node_addr = __float_as_int(cnodes[r]);
-            continue;
-          }
-
-          /* Two children are hit, push far child, and continue with
-           * closer child.
-           */
-          int c0 = __float_as_int(cnodes[r]);
-          float d0 = ((float *)&dist)[r];
-          r = __bscf(child_mask);
-          int c1 = __float_as_int(cnodes[r]);
-          float d1 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            if (d1 < d0) {
-              node_addr = c1;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c0;
-              traversal_stack[stack_ptr].dist = d0;
-              continue;
-            }
-            else {
-              node_addr = c0;
-              ++stack_ptr;
-              kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-              traversal_stack[stack_ptr].addr = c1;
-              traversal_stack[stack_ptr].dist = d1;
-              continue;
-            }
-          }
-
-          /* Here starts the slow path for 3 or 4 hit children. We push
-           * all nodes onto the stack to sort them there.
-           */
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c1;
-          traversal_stack[stack_ptr].dist = d1;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c0;
-          traversal_stack[stack_ptr].dist = d0;
-
-          /* Three children are hit, push all onto stack and sort 3
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c2 = __float_as_int(cnodes[r]);
-          float d2 = ((float *)&dist)[r];
-          if (child_mask == 0) {
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = c2;
-            traversal_stack[stack_ptr].dist = d2;
-            qbvh_stack_sort(&traversal_stack[stack_ptr],
-                            &traversal_stack[stack_ptr - 1],
-                            &traversal_stack[stack_ptr - 2]);
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-            continue;
-          }
-
-          /* Four children are hit, push all onto stack and sort 4
-           * stack items, continue with closest child.
-           */
-          r = __bscf(child_mask);
-          int c3 = __float_as_int(cnodes[r]);
-          float d3 = ((float *)&dist)[r];
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c3;
-          traversal_stack[stack_ptr].dist = d3;
-          ++stack_ptr;
-          kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-          traversal_stack[stack_ptr].addr = c2;
-          traversal_stack[stack_ptr].dist = d2;
-          qbvh_stack_sort(&traversal_stack[stack_ptr],
-                          &traversal_stack[stack_ptr - 1],
-                          &traversal_stack[stack_ptr - 2],
-                          &traversal_stack[stack_ptr - 3]);
-        }
-
-        node_addr = traversal_stack[stack_ptr].addr;
-        --stack_ptr;
-      }
-
-      /* If node is leaf, fetch triangle list. */
-      if (node_addr < 0) {
-        float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr - 1));
-
-        if ((__float_as_uint(leaf.z) & visibility) == 0) {
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-          continue;
-        }
-
-        int prim_addr = __float_as_int(leaf.x);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-        if (prim_addr >= 0) {
-#endif
-          int prim_addr2 = __float_as_int(leaf.y);
-          const uint type = __float_as_int(leaf.w);
-          const uint p_type = type & PRIMITIVE_ALL;
-          bool hit;
-
-          /* Pop. */
-          node_addr = traversal_stack[stack_ptr].addr;
-          --stack_ptr;
-
-          /* Primitive intersection. */
-          switch (p_type) {
-            case PRIMITIVE_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                hit = triangle_intersect(kg, isect_array, P, dir, visibility, object, prim_addr);
-                if (hit) {
-                  /* Move on to next entry in intersections array. */
-                  isect_array++;
-                  num_hits++;
-#if BVH_FEATURE(BVH_INSTANCING)
-                  num_hits_in_instance++;
-#endif
-                  isect_array->t = isect_t;
-                  if (num_hits == max_hits) {
-#if BVH_FEATURE(BVH_INSTANCING)
-                    if (object != OBJECT_NONE) {
-#  if BVH_FEATURE(BVH_MOTION)
-                      float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
-#  else
-                      Transform itfm = object_fetch_transform(
-                          kg, object, OBJECT_INVERSE_TRANSFORM);
-                      float t_fac = 1.0f / len(transform_direction(&itfm, dir));
-#  endif
-                      for (int i = 0; i < num_hits_in_instance; i++) {
-                        (isect_array - i - 1)->t *= t_fac;
-                      }
-                    }
-#endif /* BVH_FEATURE(BVH_INSTANCING) */
-                    return num_hits;
-                  }
-                }
-              }
-              break;
-            }
-#if BVH_FEATURE(BVH_MOTION)
-            case PRIMITIVE_MOTION_TRIANGLE: {
-              for (; prim_addr < prim_addr2; prim_addr++) {
-                kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-                /* Only primitives from volume object. */
-                uint tri_object = (object == OBJECT_NONE) ?
-                                      kernel_tex_fetch(__prim_object, prim_addr) :
-                                      object;
-                int object_flag = kernel_tex_fetch(__object_flag, tri_object);
-                if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
-                  continue;
-                }
-                /* Intersect ray against primitive. */
-                hit = motion_triangle_intersect(
-                    kg, isect_array, P, dir, ray->time, visibility, object, prim_addr);
-                if (hit) {
-                  /* Move on to next entry in intersections array. */
-                  isect_array++;
-                  num_hits++;
-#  if BVH_FEATURE(BVH_INSTANCING)
-                  num_hits_in_instance++;
-#  endif
-                  isect_array->t = isect_t;
-                  if (num_hits == max_hits) {
-#  if BVH_FEATURE(BVH_INSTANCING)
-                    if (object != OBJECT_NONE) {
-#    if BVH_FEATURE(BVH_MOTION)
-                      float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
-#    else
-                      Transform itfm = object_fetch_transform(
-                          kg, object, OBJECT_INVERSE_TRANSFORM);
-                      float t_fac = 1.0f / len(transform_direction(&itfm, dir));
-#    endif
-                      for (int i = 0; i < num_hits_in_instance; i++) {
-                        (isect_array - i - 1)->t *= t_fac;
-                      }
-                    }
-#  endif /* BVH_FEATURE(BVH_INSTANCING) */
-                    return num_hits;
-                  }
-                }
-              }
-              break;
-            }
-#endif
-          }
-        }
-#if BVH_FEATURE(BVH_INSTANCING)
-        else {
-          /* Instance push. */
-          object = kernel_tex_fetch(__prim_object, -prim_addr - 1);
-          int object_flag = kernel_tex_fetch(__object_flag, object);
-          if (object_flag & SD_OBJECT_HAS_VOLUME) {
-#  if BVH_FEATURE(BVH_MOTION)
-            isect_t = bvh_instance_motion_push(
-                kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm);
-#  else
-            isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t);
-#  endif
-
-            qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-            tfar = ssef(isect_t);
-            idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  if BVH_FEATURE(BVH_HAIR)
-            dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-#  ifdef __KERNEL_AVX2__
-            P_idir = P * idir;
-            P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-            org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-            num_hits_in_instance = 0;
-            isect_array->t = isect_t;
-
-            ++stack_ptr;
-            kernel_assert(stack_ptr < BVH_QSTACK_SIZE);
-            traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL;
-
-            node_addr = kernel_tex_fetch(__object_node, object);
-          }
-          else {
-            /* Pop. */
-            object = OBJECT_NONE;
-            node_addr = traversal_stack[stack_ptr].addr;
-            --stack_ptr;
-          }
-        }
-      }
-#endif /* FEATURE(BVH_INSTANCING) */
-    } while (node_addr != ENTRYPOINT_SENTINEL);
-
-#if BVH_FEATURE(BVH_INSTANCING)
-    if (stack_ptr >= 0) {
-      kernel_assert(object != OBJECT_NONE);
-
-      /* Instance pop. */
-      if (num_hits_in_instance) {
-        float t_fac;
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
-#  else
-        bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
-#  endif
-        /* Scale isect->t to adjust for instancing. */
-        for (int i = 0; i < num_hits_in_instance; i++) {
-          (isect_array - i - 1)->t *= t_fac;
-        }
-      }
-      else {
-#  if BVH_FEATURE(BVH_MOTION)
-        bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX, &ob_itfm);
-#  else
-        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX);
-#  endif
-      }
-
-      isect_t = tmax;
-      isect_array->t = isect_t;
-
-      qbvh_near_far_idx_calc(idir, &near_x, &near_y, &near_z, &far_x, &far_y, &far_z);
-      tfar = ssef(isect_t);
-#  if BVH_FEATURE(BVH_HAIR)
-      dir4 = sse3f(ssef(dir.x), ssef(dir.y), ssef(dir.z));
-#  endif
-      idir4 = sse3f(ssef(idir.x), ssef(idir.y), ssef(idir.z));
-#  ifdef __KERNEL_AVX2__
-      P_idir = P * idir;
-      P_idir4 = sse3f(P_idir.x, P_idir.y, P_idir.z);
-#  endif
-#  if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
-      org4 = sse3f(ssef(P.x), ssef(P.y), ssef(P.z));
-#  endif
-
-      object = OBJECT_NONE;
-      node_addr = traversal_stack[stack_ptr].addr;
-      --stack_ptr;
-    }
-#endif /* FEATURE(BVH_INSTANCING) */
-  } while (node_addr != ENTRYPOINT_SENTINEL);
-
-  return num_hits;
-}
-
-#undef NODE_INTERSECT
index 88963bea6ef0256fcc31da37e615f43cbd81cadc..87ed0bf201f37d3592d36b6df0fae8bcd00793a8 100644 (file)
@@ -18,13 +18,6 @@ CCL_NAMESPACE_BEGIN
 
 #ifdef __HAIR__
 
-#  ifdef __KERNEL_SSE2__
-ccl_device_inline ssef transform_point_T3(const ssef t[3], const ssef &a)
-{
-  return madd(shuffle<0>(a), t[0], madd(shuffle<1>(a), t[1], shuffle<2>(a) * t[2]));
-}
-#  endif
-
 /* On CPU pass P and dir by reference to aligned vector. */
 ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
                                             Intersection *isect,
@@ -55,108 +48,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
   int flags = kernel_data.curve.curveflags;
   int prim = kernel_tex_fetch(__prim_index, curveAddr);
 
-#  ifdef __KERNEL_SSE2__
-  ssef vdir = load4f(dir);
-  ssef vcurve_coef[4];
-  const float3 *curve_coef = (float3 *)vcurve_coef;
-
-  {
-    ssef dtmp = vdir * vdir;
-    ssef d_ss = mm_sqrt(dtmp + shuffle<2>(dtmp));
-    ssef rd_ss = load1f_first(1.0f) / d_ss;
-
-    ssei v00vec = load4i((ssei *)&kg->__curves.data[prim]);
-    int2 &v00 = (int2 &)v00vec;
-
-    int k0 = v00.x + segment;
-    int k1 = k0 + 1;
-    int ka = max(k0 - 1, v00.x);
-    int kb = min(k1 + 1, v00.x + v00.y - 1);
-
-#    if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && \
-        (!defined(_MSC_VER) || _MSC_VER > 1800)
-    avxf P_curve_0_1, P_curve_2_3;
-    if (is_curve_primitive) {
-      P_curve_0_1 = _mm256_loadu2_m128(&kg->__curve_keys.data[k0].x, &kg->__curve_keys.data[ka].x);
-      P_curve_2_3 = _mm256_loadu2_m128(&kg->__curve_keys.data[kb].x, &kg->__curve_keys.data[k1].x);
-    }
-    else {
-      int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, curveAddr) : object;
-      motion_curve_keys_avx(kg, fobject, prim, time, ka, k0, k1, kb, &P_curve_0_1, &P_curve_2_3);
-    }
-#    else  /* __KERNEL_AVX2__ */
-    ssef P_curve[4];
-
-    if (is_curve_primitive) {
-      P_curve[0] = load4f(&kg->__curve_keys.data[ka].x);
-      P_curve[1] = load4f(&kg->__curve_keys.data[k0].x);
-      P_curve[2] = load4f(&kg->__curve_keys.data[k1].x);
-      P_curve[3] = load4f(&kg->__curve_keys.data[kb].x);
-    }
-    else {
-      int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, curveAddr) : object;
-      motion_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, (float4 *)&P_curve);
-    }
-#    endif /* __KERNEL_AVX2__ */
-
-    ssef rd_sgn = set_sign_bit<0, 1, 1, 1>(shuffle<0>(rd_ss));
-    ssef mul_zxxy = shuffle<2, 0, 0, 1>(vdir) * rd_sgn;
-    ssef mul_yz = shuffle<1, 2, 1, 2>(vdir) * mul_zxxy;
-    ssef mul_shuf = shuffle<0, 1, 2, 3>(mul_zxxy, mul_yz);
-    ssef vdir0 = vdir & cast(ssei(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0));
-
-    ssef htfm0 = shuffle<0, 2, 0, 3>(mul_shuf, vdir0);
-    ssef htfm1 = shuffle<1, 0, 1, 3>(load1f_first(extract<0>(d_ss)), vdir0);
-    ssef htfm2 = shuffle<1, 3, 2, 3>(mul_shuf, vdir0);
-
-#    if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && \
-        (!defined(_MSC_VER) || _MSC_VER > 1800)
-    const avxf vPP = _mm256_broadcast_ps(&P.m128);
-    const avxf htfm00 = avxf(htfm0.m128, htfm0.m128);
-    const avxf htfm11 = avxf(htfm1.m128, htfm1.m128);
-    const avxf htfm22 = avxf(htfm2.m128, htfm2.m128);
-
-    const avxf p01 = madd(
-        shuffle<0>(P_curve_0_1 - vPP),
-        htfm00,
-        madd(shuffle<1>(P_curve_0_1 - vPP), htfm11, shuffle<2>(P_curve_0_1 - vPP) * htfm22));
-    const avxf p23 = madd(
-        shuffle<0>(P_curve_2_3 - vPP),
-        htfm00,
-        madd(shuffle<1>(P_curve_2_3 - vPP), htfm11, shuffle<2>(P_curve_2_3 - vPP) * htfm22));
-
-    const ssef p0 = _mm256_castps256_ps128(p01);
-    const ssef p1 = _mm256_extractf128_ps(p01, 1);
-    const ssef p2 = _mm256_castps256_ps128(p23);
-    const ssef p3 = _mm256_extractf128_ps(p23, 1);
-
-    const ssef P_curve_1 = _mm256_extractf128_ps(P_curve_0_1, 1);
-    r_st = ((float4 &)P_curve_1).w;
-    const ssef P_curve_2 = _mm256_castps256_ps128(P_curve_2_3);
-    r_en = ((float4 &)P_curve_2).w;
-#    else  /* __KERNEL_AVX2__ */
-    ssef htfm[] = {htfm0, htfm1, htfm2};
-    ssef vP = load4f(P);
-    ssef p0 = transform_point_T3(htfm, P_curve[0] - vP);
-    ssef p1 = transform_point_T3(htfm, P_curve[1] - vP);
-    ssef p2 = transform_point_T3(htfm, P_curve[2] - vP);
-    ssef p3 = transform_point_T3(htfm, P_curve[3] - vP);
-
-    r_st = ((float4 &)P_curve[1]).w;
-    r_en = ((float4 &)P_curve[2]).w;
-#    endif /* __KERNEL_AVX2__ */
-
-    float fc = 0.71f;
-    ssef vfc = ssef(fc);
-    ssef vfcxp3 = vfc * p3;
-
-    vcurve_coef[0] = p1;
-    vcurve_coef[1] = vfc * (p2 - p0);
-    vcurve_coef[2] = madd(
-        ssef(fc * 2.0f), p0, madd(ssef(fc - 3.0f), p1, msub(ssef(3.0f - 2.0f * fc), p2, vfcxp3)));
-    vcurve_coef[3] = msub(ssef(fc - 2.0f), p2 - p1, msub(vfc, p0, vfcxp3));
-  }
-#  else
   float3 curve_coef[4];
 
   /* curve Intersection check */
@@ -212,7 +103,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
     r_st = P_curve[1].w;
     r_en = P_curve[2].w;
   }
-#  endif
 
   float r_curr = max(r_st, r_en);
 
@@ -275,23 +165,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
     const float i_st = tree * resol;
     const float i_en = i_st + (level * resol);
 
-#  ifdef __KERNEL_SSE2__
-    ssef vi_st = ssef(i_st), vi_en = ssef(i_en);
-    ssef vp_st = madd(madd(madd(vcurve_coef[3], vi_st, vcurve_coef[2]), vi_st, vcurve_coef[1]),
-                      vi_st,
-                      vcurve_coef[0]);
-    ssef vp_en = madd(madd(madd(vcurve_coef[3], vi_en, vcurve_coef[2]), vi_en, vcurve_coef[1]),
-                      vi_en,
-                      vcurve_coef[0]);
-
-    ssef vbmin = min(vp_st, vp_en);
-    ssef vbmax = max(vp_st, vp_en);
-
-    float3 &bmin = (float3 &)vbmin, &bmax = (float3 &)vbmax;
-    float &bminx = bmin.x, &bminy = bmin.y, &bminz = bmin.z;
-    float &bmaxx = bmax.x, &bmaxy = bmax.y, &bmaxz = bmax.z;
-    float3 &p_st = (float3 &)vp_st, &p_en = (float3 &)vp_en;
-#  else
     float3 p_st = ((curve_coef[3] * i_st + curve_coef[2]) * i_st + curve_coef[1]) * i_st +
                   curve_coef[0];
     float3 p_en = ((curve_coef[3] * i_en + curve_coef[2]) * i_en + curve_coef[1]) * i_en +
@@ -303,7 +176,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
     float bmaxy = max(p_st.y, p_en.y);
     float bminz = min(p_st.z, p_en.z);
     float bmaxz = max(p_st.z, p_en.z);
-#  endif
 
     if (xextrem[0] >= i_st && xextrem[0] <= i_en) {
       bminx = min(bminx, xextrem[1]);
@@ -351,23 +223,13 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
 
       if (flags & CURVE_KN_RIBBONS) {
         float3 tg = (p_en - p_st);
-#  ifdef __KERNEL_SSE__
-        const float3 tg_sq = tg * tg;
-        float w = tg_sq.x + tg_sq.y;
-#  else
         float w = tg.x * tg.x + tg.y * tg.y;
-#  endif
         if (w == 0) {
           tree++;
           level = tree & -tree;
&nbs