[Bf-blender-cvs] [681fa53dcc7] cycles_path_guiding: Cycles-X: Path Guiding: Fixing crash when turning guiding on/off during rendering.
Sebastian Herholz
noreply at git.blender.org
Wed Jun 29 14:31:10 CEST 2022
Commit: 681fa53dcc7ac64c26769632e27119d54475ddf3
Author: Sebastian Herholz
Date: Tue Jun 28 14:06:34 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB681fa53dcc7ac64c26769632e27119d54475ddf3
Cycles-X: Path Guiding: Fixing crash when turning guiding on/off during rendering.
===================================================================
M intern/cycles/integrator/guiding.h
M intern/cycles/integrator/path_trace.cpp
M intern/cycles/integrator/path_trace_work_cpu.cpp
M intern/cycles/session/session.cpp
M intern/cycles/session/session.h
===================================================================
diff --git a/intern/cycles/integrator/guiding.h b/intern/cycles/integrator/guiding.h
index bd9dc84f794..621f5033de9 100644
--- a/intern/cycles/integrator/guiding.h
+++ b/intern/cycles/integrator/guiding.h
@@ -23,6 +23,8 @@ class GuidingParams {
public:
GuidingParams() = default;
+ // the subset of path guiding parameters that can
+ // trigger a creation/rebuild of the guiding field
bool use{false};
GuidingDistributionType type{GUIDING_TYPE_PAVMM};
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index 14553fe95ac..bcf098e0456 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -1238,7 +1238,9 @@ string PathTrace::full_report() const
#ifdef __PATH_GUIDING__
void PathTrace::set_guiding_params(ccl::Device *device, const GuidingParams &guiding)
{
- guiding_sample_data_storage_ = new openpgl::cpp::SampleStorage();
+ if (!guiding_sample_data_storage_) {
+ guiding_sample_data_storage_ = new openpgl::cpp::SampleStorage();
+ }
guiding_sample_data_storage_->Clear();
PGLFieldArguments guidingFieldArgs;
@@ -1269,6 +1271,10 @@ void PathTrace::set_guiding_params(ccl::Device *device, const GuidingParams &gui
break;
}
}
+
+ if (guiding_field_) {
+ delete guiding_field_;
+ }
guiding_field_ = static_cast<openpgl::cpp::Field *>(
device->create_guiding_field(&guidingFieldArgs));
}
@@ -1291,10 +1297,10 @@ void PathTrace::guiding_update_structures()
{
// TODO(sherholz): implement
# ifdef WITH_PATH_GUIDING_DEBUG_PRINT
- std::cout << "update guiding structures" << std::endl;
- std::cout << "SampleDataStrorage: #surface samples = "
+ VLOG_WORK << "Path Guiding: update guiding structures";
+ VLOG_WORK << "SampleDataStrorage: #surface samples = "
<< guiding_sample_data_storage_->GetSizeSurface()
- << "\t#volumesamples = " << guiding_sample_data_storage_->GetSizeVolume() << std::endl;
+ << "\t#volumesamples = " << guiding_sample_data_storage_->GetSizeVolume();
# endif
// int training_iteration = guiding_field_->GetIteration();
if (true) {
@@ -1320,7 +1326,9 @@ void PathTrace::guiding_update_structures()
const size_t num_samples = 1;
guiding_field_->Update(*guiding_sample_data_storage_, num_samples);
guiding_update_count++;
- std::cout << "Field: valid = " << guiding_field_->Validate() << std::endl;
+# ifdef WITH_PATH_GUIDING_DEBUG_PRINT
+ VLOG_WORK << "Field: valid = " << guiding_field_->Validate();
+# endif
// if(guiding_update_count<=1)
guiding_sample_data_storage_->Clear();
diff --git a/intern/cycles/integrator/path_trace_work_cpu.cpp b/intern/cycles/integrator/path_trace_work_cpu.cpp
index 8a53e3aeec0..1b21dcd0ffd 100644
--- a/intern/cycles/integrator/path_trace_work_cpu.cpp
+++ b/intern/cycles/integrator/path_trace_work_cpu.cpp
@@ -96,8 +96,8 @@ void PathTraceWorkCPU::render_samples(RenderStatistics &statistics,
int sample_offset)
{
#if defined(__PATH_GUIDING__) && defined(WITH_PATH_GUIDING_DEBUG_PRINT)
- std::cout << "render_samples: start_sample = " << start_sample
- << "\t samples_num = " << samples_num << std::endl;
+ VLOG_WORK << "render_samples: start_sample = " << start_sample
+ << "\t samples_num = " << samples_num;
#endif
const int64_t image_width = effective_buffer_params_.width;
const int64_t image_height = effective_buffer_params_.height;
diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp
index 323cbe6b575..7d851241000 100644
--- a/intern/cycles/session/session.cpp
+++ b/intern/cycles/session/session.cpp
@@ -146,9 +146,9 @@ void Session::run_main_render_loop()
/* guiding settings. */
// TODO: is this the right place
{
- const GuidingParams guiding_params = scene->integrator->get_guiding_params();
- if (guiding_params.use) {
- path_trace_->set_guiding_params(scene->device, guiding_params);
+ guiding_params_ = scene->integrator->get_guiding_params();
+ if (guiding_params_.use) {
+ path_trace_->set_guiding_params(scene->device, guiding_params_);
}
}
#endif
@@ -329,6 +329,18 @@ RenderWork Session::run_update_for_next_iteration()
path_trace_->set_adaptive_sampling(adaptive_sampling);
}
+#if defined(WITH_PATH_GUIDING)
+ /* Update path guiding. */
+ {
+ const GuidingParams guiding_params = scene->integrator->get_guiding_params();
+ // check if the path guiding parameters have changed since session started
+ if (guiding_params_.modified(guiding_params)) {
+ guiding_params_ = guiding_params;
+ path_trace_->set_guiding_params(scene->device, guiding_params_);
+ }
+ }
+#endif
+
render_scheduler_.set_num_samples(params.samples);
render_scheduler_.set_start_sample(params.sample_offset);
render_scheduler_.set_time_limit(params.time_limit);
diff --git a/intern/cycles/session/session.h b/intern/cycles/session/session.h
index d431c61a5fc..a0c4a9a4d11 100644
--- a/intern/cycles/session/session.h
+++ b/intern/cycles/session/session.h
@@ -6,6 +6,9 @@
#include "device/device.h"
#include "integrator/render_scheduler.h"
+#if defined(WITH_PATH_GUIDING)
+# include "integrator/guiding.h"
+#endif
#include "scene/shader.h"
#include "scene/stats.h"
#include "session/buffers.h"
@@ -224,6 +227,10 @@ class Session {
TileManager tile_manager_;
BufferParams buffer_params_;
+#if defined(WITH_PATH_GUIDING)
+ GuidingParams guiding_params_;
+#endif
+
/* Render scheduler is used to get work to be rendered with the current big tile. */
RenderScheduler render_scheduler_;
More information about the Bf-blender-cvs
mailing list