Fix #125380: Viewport compositor slows complex scenes
The viewport compositor slows down complex scenes even if it has very simple setups. That's because it internally computes previews which involves a fair bit of CPU computation, however, those previews are actually never written to the original tree, so previewers weren't really visible so it is effectively redundantly computations. To fix this, we double down on disabling previews for the viewport compositor and avoid any redundant computations in that case.
This commit is contained in:
@@ -54,6 +54,9 @@ class Context {
|
||||
/* True if the compositor should write file outputs, false otherwise. */
|
||||
virtual bool use_file_output() const = 0;
|
||||
|
||||
/* True if the compositor should compute node previews, false otherwise. */
|
||||
virtual bool should_compute_node_previews() const = 0;
|
||||
|
||||
/* True if the compositor should write the composite output, otherwise, the compositor is assumed
|
||||
* to not support the composite output and just displays its viewer output. In that case, the
|
||||
* composite output will be used as a fallback viewer if no other viewer exists */
|
||||
|
||||
@@ -60,7 +60,7 @@ void NodeOperation::evaluate()
|
||||
|
||||
void NodeOperation::compute_preview()
|
||||
{
|
||||
if (is_node_preview_needed(node())) {
|
||||
if (context().should_compute_node_previews() && is_node_preview_needed(node())) {
|
||||
compute_preview_from_result(context(), node(), *get_preview_result());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,11 @@ class Context : public realtime_compositor::Context {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool should_compute_node_previews() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The viewport compositor doesn't really support the composite output, it only displays the
|
||||
* viewer output in the viewport. Settings this to false will make the compositor use the
|
||||
* composite output as fallback viewer if no other viewer exists. */
|
||||
|
||||
@@ -198,6 +198,11 @@ class Context : public realtime_compositor::Context {
|
||||
return this->render_context() != nullptr;
|
||||
}
|
||||
|
||||
bool should_compute_node_previews() const override
|
||||
{
|
||||
return this->render_context() == nullptr;
|
||||
}
|
||||
|
||||
bool use_composite_output() const override
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user