diff options
author | Patrick Mours <pmours@nvidia.com> | 2020-12-10 16:18:25 +0300 |
---|---|---|
committer | Patrick Mours <pmours@nvidia.com> | 2020-12-11 15:24:29 +0300 |
commit | bfb6fce6594e9cf133bd18aee311c1e5e32dc799 (patch) | |
tree | 7c813e17ea87e9aae64221b3ac7a8d42ab894c85 /intern/cycles/render/hair.cpp | |
parent | d72ec16e70721408c875040325c984941687b4a2 (diff) |
Cycles: Add CPU+GPU rendering support with OptiX
Adds support for building multiple BVH types in order to support using both CPU and OptiX
devices for rendering simultaneously. Primitive packing for Embree and OptiX is now
standalone, so it only needs to be run once and can be shared between the two. Additionally,
BVH building was made a device call, so that each device backend can decide how to
perform the building. The multi-device for instance creates a special multi-BVH that holds
references to several sub-BVHs, one for each sub-device.
Reviewed By: brecht, kevindietrich
Differential Revision: https://developer.blender.org/D9718
Diffstat (limited to 'intern/cycles/render/hair.cpp')
-rw-r--r-- | intern/cycles/render/hair.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/intern/cycles/render/hair.cpp b/intern/cycles/render/hair.cpp index d67bd209142..a64b8242337 100644 --- a/intern/cycles/render/hair.cpp +++ b/intern/cycles/render/hair.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "bvh/bvh.h" + #include "render/hair.h" #include "render/curves.h" #include "render/scene.h" @@ -492,4 +494,35 @@ void Hair::pack_curves(Scene *scene, } } +void Hair::pack_primitives(PackedBVH &pack, int object, uint visibility) +{ + if (curve_first_key.empty()) + return; + + const size_t num_prims = num_segments(); + pack.prim_tri_index.reserve(pack.prim_tri_index.size() + num_prims); + pack.prim_type.reserve(pack.prim_type.size() + num_prims); + pack.prim_visibility.reserve(pack.prim_visibility.size() + num_prims); + pack.prim_index.reserve(pack.prim_index.size() + num_prims); + pack.prim_object.reserve(pack.prim_object.size() + num_prims); + // 'pack.prim_time' is unused by Embree and OptiX + + uint type = has_motion_blur() ? + ((curve_shape == CURVE_RIBBON) ? PRIMITIVE_MOTION_CURVE_RIBBON : + PRIMITIVE_MOTION_CURVE_THICK) : + ((curve_shape == CURVE_RIBBON) ? PRIMITIVE_CURVE_RIBBON : PRIMITIVE_CURVE_THICK); + + for (size_t j = 0; j < num_curves(); ++j) { + Curve curve = get_curve(j); + for (size_t k = 0; k < curve.num_segments(); ++k) { + pack.prim_tri_index.push_back_reserved(-1); + pack.prim_type.push_back_reserved(PRIMITIVE_PACK_SEGMENT(type, k)); + pack.prim_visibility.push_back_reserved(visibility); + // Each curve segment points back to its curve index + pack.prim_index.push_back_reserved(j + prim_offset); + pack.prim_object.push_back_reserved(object); + } + } +} + CCL_NAMESPACE_END |