[Bf-blender-cvs] [0fee5d3fd44] cycles_path_guiding: Cleanup path: guiding #ifdefs

Brecht Van Lommel noreply at git.blender.org
Thu Aug 11 17:12:50 CEST 2022


Commit: 0fee5d3fd447ab0dd90f2418e3a035c65e710dba
Author: Brecht Van Lommel
Date:   Thu Aug 11 15:02:26 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB0fee5d3fd447ab0dd90f2418e3a035c65e710dba

Cleanup path: guiding #ifdefs

* Only use __PATH_GUIDING__ in the kernel, use WITH_PATH_GUIDING on the host side
* Reduce number of #ifdefs, should mainly be used for code that uses OpenPGL.

===================================================================

M	intern/cycles/blender/sync.cpp
M	intern/cycles/device/cpu/device_impl.cpp
M	intern/cycles/device/cpu/device_impl.h
M	intern/cycles/device/cpu/kernel_thread_globals.cpp
M	intern/cycles/device/device.h
M	intern/cycles/integrator/path_trace.cpp
M	intern/cycles/integrator/path_trace.h
M	intern/cycles/integrator/path_trace_work.h
M	intern/cycles/integrator/path_trace_work_cpu.cpp
M	intern/cycles/integrator/path_trace_work_cpu.h
M	intern/cycles/integrator/render_scheduler.cpp
M	intern/cycles/scene/integrator.cpp
M	intern/cycles/scene/integrator.h
M	intern/cycles/session/session.cpp
M	intern/cycles/session/session.h

===================================================================

diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index 6dcf57a0ca7..f7e3bde1820 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -412,7 +412,6 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
   integrator->set_direct_light_sampling_type(direct_light_sampling_type);
 #endif
 
-#ifdef __PATH_GUIDING__
   integrator->set_use_guiding(get_boolean(cscene, "use_guiding"));
   integrator->set_use_surface_guiding(get_boolean(cscene, "use_surface_guiding"));
   integrator->set_surface_guiding_probability(get_float(cscene, "surface_guiding_probability"));
@@ -423,7 +422,6 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
   GuidingDistributionType guiding_distribution_type = (GuidingDistributionType)get_enum(
       cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, GUIDING_TYPE_PAVMM);
   integrator->set_guiding_distribution_type(guiding_distribution_type);
-#endif
 
   DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
 
@@ -745,7 +743,7 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
     pass_add(scene, PASS_DENOISING_DEPTH, "Denoising Depth", PassMode::NOISY);
   }
 
-#if defined(__PATH_GUIDING__) && defined(PATH_GUIDING_DEBUG_PASS)
+#if defined(WITH_PATH_GUIDING) && defined(PATH_GUIDING_DEBUG_PASS)
   b_engine.add_pass("OpenPGL Color", 3, "RGB", b_view_layer.name().c_str());
   pass_add(scene, PASS_OPGL_COLOR, "OpenPGL Color", PassMode::NOISY);
 
diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp
index ebcb503cd55..b8beaf01a27 100644
--- a/intern/cycles/device/cpu/device_impl.cpp
+++ b/intern/cycles/device/cpu/device_impl.cpp
@@ -17,7 +17,7 @@
 #  include <embree3/rtcore.h>
 #endif
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
 #  include <openpgl/cpp/OpenPGL.h>
 #endif
 
@@ -74,7 +74,7 @@ CPUDevice::CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_
 #endif
   need_texture_info = false;
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   // TODO(sherholz): we need to replace this with PGL_DEVICE_TYPE_CPU_AUTO
   openpgl_device = new openpgl::cpp::Device(PGL_DEVICE_TYPE_CPU_4);
 #endif
@@ -86,9 +86,8 @@ CPUDevice::~CPUDevice()
   rtcReleaseDevice(embree_device);
 #endif
 
-#ifdef __PATH_GUIDING__
-  if (openpgl_device)
-    delete openpgl_device;
+#ifdef WITH_PATH_GUIDING
+  delete openpgl_device;
 #endif
 
   texture_info.free();
@@ -293,15 +292,17 @@ void CPUDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
     Device::build_bvh(bvh, progress, refit);
 }
 
-#if defined(__PATH_GUIDING__)
 void *CPUDevice::create_guiding_field(void *guiding_field_args_) const
 {
+#ifdef WITH_PATH_GUIDING
   PGLFieldArguments guiding_field_args = *(static_cast<PGLFieldArguments *>(guiding_field_args_));
   openpgl::cpp::Field *guiding_field_ptr = new openpgl::cpp::Field(openpgl_device,
                                                                    guiding_field_args);
   return static_cast<void *>(guiding_field_ptr);
-}
+#else
+  return NULL;
 #endif
+}
 
 void CPUDevice::get_cpu_kernel_thread_globals(
     vector<CPUKernelThreadGlobals> &kernel_thread_globals)
diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h
index 8611a49ff6b..3f75bef84c6 100644
--- a/intern/cycles/device/cpu/device_impl.h
+++ b/intern/cycles/device/cpu/device_impl.h
@@ -43,7 +43,7 @@ class CPUDevice : public Device {
   RTCScene embree_scene = NULL;
   RTCDevice embree_device;
 #endif
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   openpgl::cpp::Device *openpgl_device = NULL;
 #endif
 
@@ -76,9 +76,7 @@ class CPUDevice : public Device {
 
   void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
 
-#ifdef __PATH_GUIDING__
   void *create_guiding_field(void *guiding_field_args) const override;
-#endif
 
   virtual void get_cpu_kernel_thread_globals(
       vector<CPUKernelThreadGlobals> &kernel_thread_globals) override;
diff --git a/intern/cycles/device/cpu/kernel_thread_globals.cpp b/intern/cycles/device/cpu/kernel_thread_globals.cpp
index d1ea603dcfb..766c441d62c 100644
--- a/intern/cycles/device/cpu/kernel_thread_globals.cpp
+++ b/intern/cycles/device/cpu/kernel_thread_globals.cpp
@@ -25,7 +25,7 @@ CPUKernelThreadGlobals::CPUKernelThreadGlobals(const KernelGlobalsCPU &kernel_gl
   (void)osl_globals_memory;
 #endif
 
-#if defined(__PATH_GUIDING__)
+#if defined(WITH_PATH_GUIDING)
 #  if PATH_GUIDING_LEVEL >= 1
   opgl_path_segment_storage = new openpgl::cpp::PathSegmentStorage();
 #  endif
@@ -50,9 +50,8 @@ CPUKernelThreadGlobals::~CPUKernelThreadGlobals()
   OSLShader::thread_free(this);
 #endif
 
-#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
-  if (opgl_path_segment_storage)
-    delete opgl_path_segment_storage;
+#if defined(WITH_PATH_GUIDING) && PATH_GUIDING_LEVEL >= 1
+  delete opgl_path_segment_storage;
 #endif
 }
 
@@ -75,7 +74,7 @@ void CPUKernelThreadGlobals::reset_runtime_memory()
   osl = nullptr;
 #endif
 
-#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+#if defined(WITH_PATH_GUIDING) && PATH_GUIDING_LEVEL >= 1
   opgl_path_segment_storage = nullptr;
 #endif
 }
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 315cde0278a..2203372f690 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -217,7 +217,6 @@ class Device {
     return false;
   }
 
-#if defined(__PATH_GUIDING__)
   /* Guiding */
 
   /* Creating and returning a new, empty guiding field. */
@@ -226,7 +225,6 @@ class Device {
     LOG(ERROR) << "Request guiding field from a device which does not support it.";
     return nullptr;
   }
-#endif
 
   /* Buffer denoising. */
 
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index bc41ba73628..945a57ccb82 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -173,7 +173,7 @@ void PathTrace::render_pipeline(RenderWork render_work)
 
   rebalance(render_work);
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   /* Prepare all per-thread guiding structures before we start with the
    * next rendering iteration/progression. */
   const bool use_guiding = device_scene_->data.integrator.use_guiding;
@@ -187,7 +187,7 @@ void PathTrace::render_pipeline(RenderWork render_work)
     return;
   }
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   /* Update the guiding field using the training data/samples collected
    * during the rendering iteration/progression.
    * Note: we also should check if the guiding structure should be reseted due to scene changes
@@ -1237,7 +1237,7 @@ string PathTrace::full_report() const
   return result;
 }
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
 void PathTrace::set_guiding_params(ccl::Device *device, const GuidingParams &guiding)
 {
   if (!guiding_sample_data_storage_) {
diff --git a/intern/cycles/integrator/path_trace.h b/intern/cycles/integrator/path_trace.h
index 5e90043f763..a834422cfb1 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -13,7 +13,7 @@
 #include "util/unique_ptr.h"
 #include "util/vector.h"
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
 #  include "integrator/guiding.h"
 #  include <openpgl/cpp/OpenPGL.h>
 #endif
@@ -94,7 +94,7 @@ class PathTrace {
    * Use this to configure the adaptive sampler before rendering any samples. */
   void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling);
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   /* Set the parameters for guiding.
    * Use this to create/configure/activate the guiding structures before each rendering
    * iteration.*/
@@ -219,7 +219,7 @@ class PathTrace {
   void write_tile_buffer(const RenderWork &render_work);
   void finalize_full_buffer_on_disk(const RenderWork &render_work);
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   /* Updates/initializes the guiding structures after a rendering iteration.
    * The structures are updated using the training data/samples generated during the previous
    * rendering iteration */
@@ -285,7 +285,7 @@ class PathTrace {
   /* Denoiser which takes care of denoising the big tile. */
   unique_ptr<Denoiser> denoiser_;
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   /* Guiding related attributes */
 
   /* The guiding field which holds the representation of the incident radiance field for the
diff --git a/intern/cycles/integrator/path_trace_work.h b/intern/cycles/integrator/path_trace_work.h
index eb572f8e81c..db419330255 100644
--- a/intern/cycles/integrator/path_trace_work.h
+++ b/intern/cycles/integrator/path_trace_work.h
@@ -140,7 +140,7 @@ class PathTraceWork {
     return device_;
   }
 
-#ifdef __PATH_GUIDING__
+#ifdef WITH_PATH_GUIDING
   /* Intializes the per-thread guiding kernel data. The function sets the pointers to the
    * global guiding field and the sample data storage as well es initializes the per-thread
    * guided sampling distrubtions (e.g., SurfaceSamplingDistribution and
diff --git a/intern/cycles/integrator/path_trace_work_cpu.cpp b/intern/cycles/integrator/path_trace_work_cpu.cpp
index e79f26c4e07..2043049f958 100644
--- a/intern/cycles/integrator/path_trace_work_cpu.cpp
+++ b/intern/cycles/integrator/path_trace_work_cpu.cpp
@@ -57,7 +57,7 @@ void PathTraceWorkCPU::init_execution()
   device_->get_cpu_kernel_thread_globals(kernel_thread_globals_);
 }
 
-#if defined(__PATH_GUIDING__)
+#if defined(WITH_PATH_GUIDING)
 /* Note: It seems that this is called before every rendering iteration/progression and not once per
  * rendering. May be we find a way to call it only once per renderering. */
 void PathTraceWorkCPU::guiding_init_kernel_globals(void *guiding_field, void *sample_data_storage)
@@ -95,7 +95,7 @@ void PathTraceWorkCPU::render_samples(RenderStatistics &statistics,
                                       int samples_num,
                                       int sample_offset)
 {
-#if defined(__PATH_GUIDING__) && defined(WITH_PATH_GUIDING_DEBUG_PRINT)
+#if defined(WITH_PAT

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list