Cycles: Selectively include denoising in kernel
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 9 Jun 2017 07:11:54 +0000 (03:11 -0400)
committerMai Lavelle <mai.lavelle@gmail.com>
Sat, 10 Jun 2017 08:45:13 +0000 (04:45 -0400)
intern/cycles/device/device.cpp
intern/cycles/device/device.h
intern/cycles/kernel/kernel_path_state.h
intern/cycles/kernel/kernel_types.h
intern/cycles/render/session.cpp

index 0603ecb..a54bb77 100644 (file)
@@ -68,6 +68,8 @@ std::ostream& operator <<(std::ostream &os,
           << string_from_bool(requested_features.use_transparent) << std::endl;
        os << "Use Principled BSDF: "
           << string_from_bool(requested_features.use_principled) << std::endl;
+       os << "Use Denoising: "
+          << string_from_bool(requested_features.use_denoising) << std::endl;
        return os;
 }
 
index 527940e..b3b693c 100644 (file)
@@ -127,6 +127,9 @@ public:
        /* Per-uber shader usage flags. */
        bool use_principled;
 
+       /* Denoising features. */
+       bool use_denoising;
+
        DeviceRequestedFeatures()
        {
                /* TODO(sergey): Find more meaningful defaults. */
@@ -145,6 +148,7 @@ public:
                use_transparent = false;
                use_shadow_tricks = false;
                use_principled = false;
+               use_denoising = false;
        }
 
        bool modified(const DeviceRequestedFeatures& requested_features)
@@ -163,7 +167,8 @@ public:
                         use_patch_evaluation == requested_features.use_patch_evaluation &&
                         use_transparent == requested_features.use_transparent &&
                         use_shadow_tricks == requested_features.use_shadow_tricks &&
-                        use_principled == requested_features.use_principled);
+                        use_principled == requested_features.use_principled &&
+                        use_denoising == requested_features.use_denoising);
        }
 
        /* Convert the requested features structure to a build options,
@@ -213,6 +218,9 @@ public:
                if(!use_principled) {
                        build_options += " -D__NO_PRINCIPLED__";
                }
+               if(!use_denoising) {
+                       build_options += " -D__NO_DENOISING__";
+               }
                return build_options;
        }
 };
index 0fa77d9..5d92fd1 100644 (file)
@@ -139,9 +139,11 @@ ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathSta
        /* random number generator next bounce */
        state->rng_offset += PRNG_BOUNCE_NUM;
 
+#ifdef __DENOISING_FEATURES__
        if((state->denoising_feature_weight == 0.0f) && !(state->flag & PATH_RAY_SHADOW_CATCHER)) {
                state->flag &= ~PATH_RAY_STORE_SHADOW_INFO;
        }
+#endif
 }
 
 ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
index 2c3859b..31e47e8 100644 (file)
@@ -236,6 +236,9 @@ CCL_NAMESPACE_BEGIN
 #ifdef __NO_PRINCIPLED__
 #  undef __PRINCIPLED__
 #endif
+#ifdef __NO_DENOISING__
+#  undef __DENOISING_FEATURES__
+#endif
 
 /* Random Numbers */
 
index 0890994..ae462a1 100644 (file)
@@ -722,6 +722,7 @@ DeviceRequestedFeatures Session::get_requested_device_features()
        requested_features.use_baking = bake_manager->get_baking();
        requested_features.use_integrator_branched = (scene->integrator->method == Integrator::BRANCHED_PATH);
        requested_features.use_transparent &= scene->integrator->transparent_shadows;
+       requested_features.use_denoising = params.use_denoising;
 
        return requested_features;
 }