[Bf-blender-cvs] [edb873364d5] cycles_path_guiding: Guiding: Cleanup: Removed some unnecessary code/TODOs/snippets and added some comments
Sebastian Herholz
noreply at git.blender.org
Mon Sep 5 20:14:29 CEST 2022
Commit: edb873364d5b2e93d9d6ad2e7b930b98118a9a77
Author: Sebastian Herholz
Date: Mon Sep 5 20:14:15 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBedb873364d5b2e93d9d6ad2e7b930b98118a9a77
Guiding: Cleanup: Removed some unnecessary code/TODOs/snippets and added some comments
===================================================================
M intern/cycles/CMakeLists.txt
M intern/cycles/integrator/path_trace.cpp
M intern/cycles/integrator/path_trace.h
M intern/cycles/integrator/path_trace_work_cpu.cpp
M intern/cycles/kernel/closure/bsdf.h
M intern/cycles/kernel/closure/bsdf_microfacet_multi.h
M intern/cycles/kernel/closure/bsdf_refraction.h
M intern/cycles/kernel/device/cpu/globals.h
M intern/cycles/kernel/integrator/guiding.h
M intern/cycles/kernel/integrator/shade_shadow.h
M intern/cycles/kernel/integrator/subsurface_disk.h
M intern/cycles/kernel/integrator/subsurface_random_walk.h
M intern/cycles/kernel/integrator/volume_shader.h
M intern/cycles/kernel/svm/closure.h
M intern/cycles/kernel/types.h
===================================================================
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index c3a3bae1007..0a32a9dde0f 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -349,10 +349,23 @@ endif()
if(WITH_CYCLES_PATH_GUIDING)
add_definitions(-DWITH_PATH_GUIDING)
- add_definitions(-DWITH_PATH_GUIDING_DEBUG_PRINT)
+ # The level of the guiding integration.
+ # Different levels can be selected to measure the overhead of
+ # different stages.
+ # 1 = recording the path segments
+ # 2 = 1 + generating (not storing) sample data from the segments
+ # 3 = 2 + storing the generates sample data
+ # 4 = 3 + training the guiding fields
+ # 5 = 4 + querying the trained guiding for sampling (full path guiding)
add_definitions(-DPATH_GUIDING_LEVEL=5)
- add_definitions(-DPATH_GUIDING_PHASE_FUNCTION_PRODUCT)
- add_definitions(-DPATH_GUIDING_DEBUG_VALIDATE)
+ if(WITH_CYCLES_DEBUG)
+ # Validates each generated guiding data structure
+ # (e.g., PathSegments, SampleData) during rendering.
+ # This mode comes with a computational overhead.
+ add_definitions(-DPATH_GUIDING_DEBUG_VALIDATE)
+ # Prints some guiding information (e.g., num. training samples per iteration)
+ add_definitions(-DWITH_PATH_GUIDING_DEBUG_PRINT)
+ endif()
include_directories(
SYSTEM
${OPENPGL_INCLUDE_DIR}
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index f43885b6076..524bb814829 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -197,8 +197,7 @@ void PathTrace::render_pipeline(RenderWork render_work)
}
/* Update the guiding field using the training data/samples collected during the rendering
- * iteration/progression. TODO: we also should check if the guiding structure should be reset
- * due to scene changes. */
+ * iteration/progression. */
if (use_guiding) {
guiding_update_structures();
}
@@ -1351,7 +1350,7 @@ void PathTrace::guiding_update_structures()
const size_t num_samples = 1;
guiding_field_->Update(*guiding_sample_data_storage_, num_samples);
guiding_update_count++;
-# ifdef WITH_PATH_GUIDING_DEBUG_PRINT
+# ifdef WITH_PATH_GUIDING_DEBUG_PRINT && PATH_GUIDING_DEBUG_VALIDATE
VLOG_WORK << "Field: valid = " << guiding_field_->Validate();
# endif
// if(guiding_update_count<=1)
diff --git a/intern/cycles/integrator/path_trace.h b/intern/cycles/integrator/path_trace.h
index 2efd6ecf61f..fe823d73612 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -221,7 +221,8 @@ class PathTrace {
* rendering iteration */
void guiding_update_structures();
- /* Prepares the per-kernel thread related guiding structures (e.g., )*/
+ /* Prepares the per-kernel thread related guiding structures (e.g., PathSegmentStorage,
+ * pointers to the global Field and SegmentStorage)*/
void guiding_prepare_structures();
/* Get number of samples in the current state of the render buffers. */
diff --git a/intern/cycles/integrator/path_trace_work_cpu.cpp b/intern/cycles/integrator/path_trace_work_cpu.cpp
index 13eafdeeb4a..83fea8ff193 100644
--- a/intern/cycles/integrator/path_trace_work_cpu.cpp
+++ b/intern/cycles/integrator/path_trace_work_cpu.cpp
@@ -59,11 +59,11 @@ void PathTraceWorkCPU::init_execution()
#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. */
+ * rendering. May be we find a way to call it only once per rendering. */
void PathTraceWorkCPU::guiding_init_kernel_globals(void *guiding_field, void *sample_data_storage)
{
- /* Cache per-thread kernel globals. */
- // device_->get_cpu_kernel_thread_globals(kernel_thread_globals_);
+ /* Linking the global guiding structures (e.g., Field and SampleStorage) to the per-thread
+ * kernel globals. */
# if PATH_GUIDING_LEVEL >= 4
openpgl::cpp::Field *field = (openpgl::cpp::Field *)guiding_field;
# endif
@@ -76,7 +76,6 @@ void PathTraceWorkCPU::guiding_init_kernel_globals(void *guiding_field, void *sa
# if PATH_GUIDING_LEVEL >= 4
kernel_thread_globals_[thread_index].opgl_guiding_field = field;
- /* We might be able to just create a new Sampling distribution if the pointer is NULL */
if (kernel_thread_globals_[thread_index].opgl_surface_sampling_distribution)
delete kernel_thread_globals_[thread_index].opgl_surface_sampling_distribution;
kernel_thread_globals_[thread_index].opgl_surface_sampling_distribution =
@@ -95,10 +94,6 @@ void PathTraceWorkCPU::render_samples(RenderStatistics &statistics,
int samples_num,
int sample_offset)
{
-#if defined(WITH_PATH_GUIDING) && defined(WITH_PATH_GUIDING_DEBUG_PRINT)
- 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;
const int64_t total_pixels_num = image_width * image_height;
@@ -356,14 +351,13 @@ void PathTraceWorkCPU::guiding_push_sample_data_to_global_storage(
{
# if defined(PATH_GUIDING_DEBUG_VALIDATE) && PATH_GUIDING_LEVEL >= 5
- /* we can guard this check with a debug flag/define */
+ /* Checks if the generated path segments contain valid values */
bool validSegments = state->guiding.path_segment_storage->ValidateSegments();
if (!validSegments)
- std::cout << "!!! validSegments = " << validSegments << " !!!" << std::endl;
+ VLOG_WORK << "Guiding: Invalid path segments!" << std::endl;
# endif
# if defined(WITH_CYCLES_DEBUG) && PATH_GUIDING_LEVEL >= 5
- // guiding_write_pixel_estimate_buffer(kg, state, render_buffer);
pgl_vec3f pgl_final_color = state->guiding.path_segment_storage->CalculatePixelEstimate(false);
const uint32_t render_pixel_index = INTEGRATOR_STATE(state, path, render_pixel_index);
@@ -371,8 +365,8 @@ void PathTraceWorkCPU::guiding_push_sample_data_to_global_storage(
kernel_data.film.pass_stride;
ccl_global float *buffer = render_buffer + render_buffer_offset;
float3 final_color = make_float3(pgl_final_color.x, pgl_final_color.y, pgl_final_color.z);
- if (kernel_data.film.pass_opgl_color != PASS_UNUSED) {
- kernel_write_pass_float3(buffer + kernel_data.film.pass_opgl_color, final_color);
+ if (kernel_data.film.pass_guiding_color != PASS_UNUSED) {
+ film_write_pass_float3(buffer + kernel_data.film.pass_guiding_color, final_color);
}
# else
(void)render_buffer;
@@ -386,13 +380,14 @@ void PathTraceWorkCPU::guiding_push_sample_data_to_global_storage(
# endif
# if defined(PATH_GUIDING_DEBUG_VALIDATE) && PATH_GUIDING_LEVEL >= 5
+ /* Checking if the training/radiance samples generated py the path segment storage are valid.*/
bool validSamples = state->guiding.path_segment_storage->ValidateSamples();
if (!validSamples)
- std::cout << "!!! validSamples = " << validSamples << " !!!" << std::endl;
+ VLOG_WORK << "Guiding: Path segment storage generated/contains invalid radiance/training samples!" << std::endl;
# endif
# if PATH_GUIDING_LEVEL >= 3
- /* Pushing the radiance data/samples from the current random walk/path to the global sample
+ /* Pushing the radiance samples from the current random walk/path to the global sample
* stoarge. */
size_t nSamples = 0;
const openpgl::cpp::SampleData *samples = state->guiding.path_segment_storage->GetSamples(
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index ed03d1617d8..e298d638a95 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -117,13 +117,13 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
switch (sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
label = bsdf_diffuse_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
- *sampled_roughness = make_float2(1.0f, 1.0f);
+ *sampled_roughness = one_float2();
*eta = 1.0f;
break;
#ifdef __SVM__
case CLOSURE_BSDF_OREN_NAYAR_ID:
label = bsdf_oren_nayar_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
- *sampled_roughness = make_float2(1.0f, 1.0f);
+ *sampled_roughness = one_float2();
*eta = 1.0f;
break;
# ifdef __OSL__
@@ -134,26 +134,26 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
break;
case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
label = bsdf_diffuse_ramp_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
- *sampled_roughness = make_float2(1.0f, 1.0f);
+ *sampled_roughness = one_float2();
*eta = 1.0f;
break;
# endif
case CLOSURE_BSDF_TRANSLUCENT_ID:
label = bsdf_translucent_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
- *sampled_roughness = make_float2(1.0f, 1.0f);
+ *sampled_roughness = one_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_REFLECTION_ID:
label = bsdf_reflection_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, eta);
- *sampled_roughness = make_float2(0.0f, 0.0f);
+ *sampled_roughness = zero_float2();
break;
case CLOSURE_BSDF_REFRACTION_ID:
label = bsdf_refraction_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, eta);
- *sampled_roughness = make_float2(0.0f, 0.0f);
+ *sampled_roughness = zero_float2();
break;
case CLOSURE_BSDF_TRANSPARENT_ID:
label = bsdf_transparent_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
- *sampled_roughness = make_float2(0.0f, 0.0f);
+ *sampled_roughness = zero_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_MICROFACET_GGX_ID:
@@ -205,18 +205,18 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
break;
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
label = bsdf_ashikhmin_velvet_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
- *sampled_roughness =
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list