Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2019-01-29 20:08:12 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2019-01-30 12:51:06 +0300
commit7744203b7fde35a074faf232dda3595b78c5f14c (patch)
treecab842b5fe8176706e9e4b032bd94836f191e824 /intern
parentfbfe360cb13df5a6b47a86bf4cabd16e3bd92262 (diff)
Cycles: improved rounding of sample chunks for resumable renders
When using `--cycles-resumable-num-chunks N` to render a subset of the samples, having N close to the total number of samples causes rounding issues. For example, a file configured for 250 samples and 150 chunks should have 1.6666 sample per chunk. The old code rounded this to 2 samples per chunk, which would result in too many samples being rendered. When rendering a single chunk this doesn't matter much, but when larger chunk ranges are rendered with `--cycles-resumable-start-chunk` and `--cycles-resumable-end-chunk` the rounding errors start to add up. By multiplying with the number of chunks to render first, and only round to integers after that, this issue is solved. In the above example, rendering 3 chunks will correctly render 5 samples rather than 6. When the requested number of chunks is larger than the number of samples there will be duplicate samples (that is, sample N appearing both in chunk M and M+1). In this case a warning is printed to stderr. This is needed for T50977 Progressive render: use non-uniform sample chunks. Reviewed by: sergey Differential Revision: https://developer.blender.org/D4282
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/blender_session.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 9949660169f..7373d091ab7 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -30,6 +30,7 @@
#include "render/shader.h"
#include "render/stats.h"
+#include "util/util_algorithm.h"
#include "util/util_color.h"
#include "util/util_foreach.h"
#include "util/util_function.h"
@@ -1395,9 +1396,15 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
return;
}
- const int num_samples_per_chunk = (int)ceilf((float)num_samples / num_resumable_chunks);
+ if (num_resumable_chunks > num_samples) {
+ fprintf(stderr, "Cycles warning: more sample chunks (%d) than samples (%d), "
+ "this will cause some samples to be included in multiple chunks.\n",
+ num_resumable_chunks, num_samples);
+ }
+
+ const float num_samples_per_chunk = (float)num_samples / num_resumable_chunks;
- int range_start_sample, range_num_samples;
+ float range_start_sample, range_num_samples;
if(current_resumable_chunk != 0) {
/* Single chunk rendering. */
range_start_sample = num_samples_per_chunk * (current_resumable_chunk - 1);
@@ -1409,19 +1416,25 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
range_start_sample = num_samples_per_chunk * (start_resumable_chunk - 1);
range_num_samples = num_chunks * num_samples_per_chunk;
}
+
+ /* Round after doing the multiplications with num_chunks and num_samples_per_chunk
+ * to allow for many small chunks. */
+ int rounded_range_start_sample = (int)floor(range_start_sample + 0.5f);
+ int rounded_range_num_samples = max((int)floor(range_num_samples + 0.5f), 1);
+
/* Make sure we don't overshoot. */
- if(range_start_sample + range_num_samples > num_samples) {
- range_num_samples = num_samples - range_num_samples;
+ if(rounded_range_start_sample + rounded_range_num_samples > num_samples) {
+ rounded_range_num_samples = num_samples - rounded_range_num_samples;
}
VLOG(1) << "Samples range start is " << range_start_sample << ", "
<< "number of samples to render is " << range_num_samples;
- scene->integrator->start_sample = range_start_sample;
+ scene->integrator->start_sample = rounded_range_start_sample;
scene->integrator->tag_update(scene);
- session->tile_manager.range_start_sample = range_start_sample;
- session->tile_manager.range_num_samples = range_num_samples;
+ session->tile_manager.range_start_sample = rounded_range_start_sample;
+ session->tile_manager.range_num_samples = rounded_range_num_samples;
}
void BlenderSession::free_blender_memory_if_possible()