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/bvh/bvh.h | |
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/bvh/bvh.h')
-rw-r--r-- | intern/cycles/bvh/bvh.h | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index 033b1fd8e04..94935c26f10 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -25,17 +25,16 @@ CCL_NAMESPACE_BEGIN -class Stats; -class Device; -class DeviceScene; +class BoundBox; class BVHNode; -struct BVHStackEntry; class BVHParams; -class BoundBox; -class LeafNode; +class Device; +class DeviceScene; class Geometry; +class LeafNode; class Object; class Progress; +class Stats; #define BVH_ALIGN 4096 #define TRI_NODE_SIZE 3 @@ -76,13 +75,10 @@ struct PackedBVH { } }; -enum BVH_TYPE { bvh2 }; - /* BVH */ class BVH { public: - PackedBVH pack; BVHParams params; vector<Geometry *> geometry; vector<Object *> objects; @@ -90,47 +86,15 @@ class BVH { static BVH *create(const BVHParams ¶ms, const vector<Geometry *> &geometry, const vector<Object *> &objects, - const Device *device); + Device *device); virtual ~BVH() { } - virtual void build(Progress &progress, Stats *stats = NULL); - virtual void copy_to_device(Progress & /*progress*/, DeviceScene * /*dscene*/) - { - } - - void refit(Progress &progress); - protected: BVH(const BVHParams ¶ms, const vector<Geometry *> &geometry, const vector<Object *> &objects); - - /* Refit range of primitives. */ - void refit_primitives(int start, int end, BoundBox &bbox, uint &visibility); - - /* triangles and strands */ - void pack_primitives(); - void pack_triangle(int idx, float4 storage[3]); - - /* merge instance BVH's */ - void pack_instances(size_t nodes_size, size_t leaf_nodes_size); - - /* for subclasses to implement */ - virtual void pack_nodes(const BVHNode *root) = 0; - virtual void refit_nodes() = 0; - - virtual BVHNode *widen_children_nodes(const BVHNode *root) = 0; -}; - -/* Pack Utility */ -struct BVHStackEntry { - const BVHNode *node; - int idx; - - BVHStackEntry(const BVHNode *n = 0, int i = 0); - int encodeIdx() const; }; CCL_NAMESPACE_END |