diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 1d901657a5e..c2b1d3ffdc2 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -684,20 +684,24 @@ void RE_FreeUnusedGPUResources() for (Render *re : RenderGlobal.render_list) { bool do_free = true; + const Scene *scene = RE_GetScene(re); + /* Don't free scenes being rendered or composited. Note there is no + * race condition here because we are on the main thread and new jobs can only + * be started from the main thread. */ + if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER) || + WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) + { + do_free = false; + } + LISTBASE_FOREACH (const wmWindow *, win, &wm->windows) { - const Scene *scene = WM_window_get_active_scene(win); - if (re != RE_GetSceneRender(scene)) { - continue; + if (!do_free) { + /* No need to do further checks. */ + break; } - /* Don't free if this scene is being rendered or composited. Note there is no - * race condition here because we are on the main thread and new jobs can only - * be started from the main thread. */ - if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER) || - WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) - { - do_free = false; - break; + if (WM_window_get_active_scene(win) != scene) { + continue; } /* Detect if scene is using GPU compositing, and if either a node editor is