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
diff options
context:
space:
mode:
authorChris Clyne <lateasusual>2022-08-05 17:43:17 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-08-05 17:45:50 +0300
commite4379971746c8b7fadb7c0c0f0933533e15376a3 (patch)
tree7e8c1bf31541af5c4348685c2e8c3334995e335d /source/blender/render
parent43a124bc1c4a2e096a6a81224fc318ac8f9180a4 (diff)
Fix: compositor stats in background mode subject to race conditions
Evaluating a compositor node tree in background mode causes the stats callback to be called from multiple threads, leading to garbled output. This was causing major problems with render-farm scripts. Differential Revision: https://developer.blender.org/D15633
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/pipeline.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/render/intern/pipeline.c b/source/blender/render/intern/pipeline.c
index 1c42467bc3d..30e8cfa5c17 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -199,14 +199,20 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
megs_used_memory = (mem_in_use) / (1024.0 * 1024.0);
megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
+ BLI_timecode_string_from_time_simple(
+ info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
+
+ /* Compositor calls this from multiple threads, mutex lock to ensure we don't
+ * get garbled output. */
+ static ThreadMutex mutex = BLI_MUTEX_INITIALIZER;
+ BLI_mutex_lock(&mutex);
+
fprintf(stdout,
TIP_("Fra:%d Mem:%.2fM (Peak %.2fM) "),
rs->cfra,
megs_used_memory,
megs_peak_memory);
- BLI_timecode_string_from_time_simple(
- info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
fprintf(stdout, TIP_("| Time:%s | "), info_time_str);
fprintf(stdout, "%s", rs->infostr);
@@ -220,6 +226,8 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
fputc('\n', stdout);
fflush(stdout);
+
+ BLI_mutex_unlock(&mutex);
}
void RE_FreeRenderResult(RenderResult *rr)