From d875e5d4cb25ad3526204826e083b5e8a89f1e8e Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Thu, 18 Jan 2024 11:31:59 +0200 Subject: [PATCH] Fix: Wrong GPU compositor assert in background mode An assert that ensures the GPU compositor executes in a non main thread wrongly fires in background mode, that's because in background mode, rendering happens in the main thread. So add a condition for background mode. --- source/blender/render/intern/compositor.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/render/intern/compositor.cc b/source/blender/render/intern/compositor.cc index ac723f7e5e7..6b7d0871335 100644 --- a/source/blender/render/intern/compositor.cc +++ b/source/blender/render/intern/compositor.cc @@ -465,7 +465,9 @@ class RealtimeCompositor { public: RealtimeCompositor(Render &render, const ContextInputData &input_data) : render_(render) { - BLI_assert(!BLI_thread_is_main()); + /* Ensure that in foreground mode we are using different contexts for main and render threads, + * to avoid them blocking each other. */ + BLI_assert(!BLI_thread_is_main() || G.background); /* Create resources with GPU context enabled. */ DRW_render_context_enable(&render_); @@ -499,7 +501,9 @@ class RealtimeCompositor { /* Evaluate the compositor and output to the scene render result. */ void execute(const ContextInputData &input_data) { - BLI_assert(!BLI_thread_is_main()); + /* Ensure that in foreground mode we are using different contexts for main and render threads, + * to avoid them blocking each other. */ + BLI_assert(!BLI_thread_is_main() || G.background); DRW_render_context_enable(&render_); context_->update_input_data(input_data);