Cycles: Add option to disable new Hair BVH
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Jul 2016 16:04:16 +0000 (18:04 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 15 Jul 2016 14:29:28 +0000 (16:29 +0200)
While it's an extra option added to the interface which might not be
fully obvious for artists, it allows to save up to 20% of memory in
hairy scenes.

This is high enough memory saver in my opinion which might become
handy for some production files where it's more important to make
scene to fit into memory rather than trying to use more optimal BVH
structure but go into swap or crash.

Reviewers: dingto, brecht

Reviewed By: dingto, brecht

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

intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/scene.h

index 140862721a8197c48cb3f4419799c26f56a1e469..193ef0cf505768524117ecd02a674efb7942c792 100644 (file)
@@ -503,6 +503,11 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                 description="Use BVH spatial splits: longer builder time, faster render",
                 default=False,
                 )
+        cls.debug_use_hair_bvh = BoolProperty(
+                name="Use Hair BVH",
+                description="Use special type BVH optimized for hair. Uses more ram but renders faster",
+                default=True,
+                )
         cls.tile_order = EnumProperty(
                 name="Tile Order",
                 description="Tile order for rendering",
index 120199479fefed0211f1166337a3b80b976f583e..10c8959172d9ce8329ba88d10f33389f6fa3994d 100644 (file)
@@ -401,6 +401,7 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
 
         col.label(text="Acceleration structure:")
         col.prop(cscene, "debug_use_spatial_splits")
+        col.prop(cscene, "debug_use_hair_bvh")
 
 
 class CyclesRender_PT_layer_options(CyclesButtonsPanel, Panel):
index 33084f1c16329eb272b551bbd73261c83b836cae..e7e57b2be36bd16a865518dd9b8f362532c14273 100644 (file)
@@ -492,6 +492,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
                        SceneParams::BVH_STATIC);
 
        params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
+       params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
 
        if(background && params.shadingsystem != SHADINGSYSTEM_OSL)
                params.persistent_data = r.use_persistent_data();
index 661719ed545fac6bd30f927db71b4e29eaa2bd9c..8b0ed9f77b22ebfda4f689e66812e062ebc5807a 100644 (file)
@@ -588,7 +588,8 @@ void Mesh::compute_bvh(DeviceScene *dscene,
                        BVHParams bparams;
                        bparams.use_spatial_split = params->use_bvh_spatial_split;
                        bparams.use_qbvh = params->use_qbvh;
-                       bparams.use_unaligned_nodes = dscene->data.bvh.have_curves;
+                       bparams.use_unaligned_nodes = dscene->data.bvh.have_curves &&
+                                                     params->use_bvh_unaligned_nodes;
 
                        delete bvh;
                        bvh = BVH::create(bparams, objects);
@@ -1222,7 +1223,8 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *
        bparams.top_level = true;
        bparams.use_qbvh = scene->params.use_qbvh;
        bparams.use_spatial_split = scene->params.use_bvh_spatial_split;
-       bparams.use_unaligned_nodes = dscene->data.bvh.have_curves;
+       bparams.use_unaligned_nodes = dscene->data.bvh.have_curves &&
+                                     scene->params.use_bvh_unaligned_nodes;
 
        delete bvh;
        bvh = BVH::create(bparams, scene->objects);
index 925e84ad96d77522e7043b260d72404ffec07a2e..5abcbfcdaad21a0919184e743cad91a678eea08e 100644 (file)
@@ -136,6 +136,7 @@ public:
                BVH_NUM_TYPES,
        } bvh_type;
        bool use_bvh_spatial_split;
+       bool use_bvh_unaligned_nodes;
        bool use_qbvh;
        bool persistent_data;
 
@@ -144,6 +145,7 @@ public:
                shadingsystem = SHADINGSYSTEM_SVM;
                bvh_type = BVH_DYNAMIC;
                use_bvh_spatial_split = false;
+               use_bvh_unaligned_nodes = true;
                use_qbvh = false;
                persistent_data = false;
        }
@@ -152,6 +154,7 @@ public:
        { return !(shadingsystem == params.shadingsystem
                && bvh_type == params.bvh_type
                && use_bvh_spatial_split == params.use_bvh_spatial_split
+               && use_bvh_unaligned_nodes == params.use_bvh_unaligned_nodes
                && use_qbvh == params.use_qbvh
                && persistent_data == params.persistent_data); }
 };