Page MenuHome

Cycles: Un-pause render when switching to rendered viewport
ClosedPublic

Authored by Sergey Sharybin (sergey) on Mar 4 2022, 10:51 AM.

Details

Summary

Consider switching to rendered shading type as a request to start
rendering, without requiring to un-pause.

This minimizes amount of clicks needed to start rendering after
viewport was paused once, and then shading mode got changed.

Diff Detail

Repository
rB Blender

Event Timeline

Sergey Sharybin (sergey) requested review of this revision.Mar 4 2022, 10:51 AM
Sergey Sharybin (sergey) created this revision.
Brecht Van Lommel (brecht) requested changes to this revision.Mar 4 2022, 12:11 PM

We call free_session() + create_session() when session or scene parameters change in BlenderSession::synchronize, and should not unpause in that case. Also I think this is modifying the CoW scene now, so the change will not be permanent.

Perhaps something like this works:

diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index 5578e83..2b7c79d 100644
--- a/intern/cycles/blender/addon/__init__.py
+++ b/intern/cycles/blender/addon/__init__.py
@@ -83,6 +83,12 @@ class CyclesRender(bpy.types.RenderEngine):
     # viewport render
     def view_update(self, context, depsgraph):
         if not self.session:
+            cscene = context.scene.cycles
+            cscene_eval = depsgraph.scene_eval.cycles
+            if cscene.preview_pause or cscene_eval.preview_pause:
+                cscene.preview_pause = False
+                cscene_eval.preview_pause = False
+
             engine.create(self, context.blend_data,
                           context.region, context.space_data, context.region_data)
This revision now requires changes to proceed.Mar 4 2022, 12:11 PM

@Brecht Van Lommel (brecht), Good point about Copy-on-Write!

And reset it seemed it doesn't happen in paused state. Oh well.

Here is an updated patch which follows your suggestion.

The remaining issue is that it doesnt refresh the interface immediately: changing property from Python doesn't geenrate a notifier for this.
Not sure we consider this a stoppor for this change, as the same issue would have happenned if someone added a shortcut to toggle the pause.

This revision is now accepted and ready to land.Mar 4 2022, 2:11 PM

Wow! Thank you @Sergey Sharybin (sergey) and @Brecht Van Lommel (brecht), that was fast, and genus solving the issue during render commencement, rather than post.

When you mention the interface not refreshing immediately; does that mean, just the icon remains in a paused state, while the viewport is rendering?

When you mention the interface not refreshing immediately; does that mean, just the icon remains in a paused state, while the viewport is rendering?

Yeah, that. Icon stays "old" until you mouse-hover.