Realtime Compositor: Allow inputs to skip realization

This patch adds support for the skip realization option of the input
descriptor. Inputs that request skip realization will not be realized on
the operation domain of the operation and will not contribute to its
computation, and consequently, they can't be a domain input.

An example is the bokeh input of the Bokeh Blur node, which is actually
a resource that is decoupled from the rest of the inputs and should not
affect or be affected by their domain.

Differential Revision: https://developer.blender.org/D15767

Reviewed By: Clement Foucault
This commit is contained in:
Omar Emara 2022-09-09 14:22:03 +02:00
parent 0fd39da3a9
commit 03f33a6f23
4 changed files with 29 additions and 0 deletions

View File

@ -149,6 +149,11 @@ Domain CompileState::compute_shader_node_domain(DNode node)
continue;
}
/* An input that skips realization can't be a domain input. */
if (input_descriptor.skip_realization) {
continue;
}
/* Notice that the lower the domain priority value is, the higher the priority is, hence the
* less than comparison. */
if (input_descriptor.domain_priority < current_domain_priority) {

View File

@ -66,6 +66,11 @@ Domain Operation::compute_domain()
continue;
}
/* An input that skips realization can't be a domain input. */
if (descriptor.skip_realization) {
continue;
}
/* Notice that the lower the domain priority value is, the higher the priority is, hence the
* less than comparison. */
if (descriptor.domain_priority < current_domain_priority) {

View File

@ -116,6 +116,7 @@ InputDescriptor input_descriptor_from_input_socket(const bNodeSocket *socket)
}
const SocketDeclarationPtr &socket_declaration = node_declaration->inputs()[socket->index()];
input_descriptor.domain_priority = socket_declaration->compositor_domain_priority();
input_descriptor.skip_realization = socket_declaration->compositor_skip_realization();
input_descriptor.expects_single_value = socket_declaration->compositor_expects_single_value();
return input_descriptor;
}

View File

@ -92,6 +92,10 @@ class SocketDeclaration {
* realtime_compositor::InputDescriptor for more information. */
int compositor_domain_priority_ = 0;
/** This input shouldn't be realized on the operation domain of the node. See
* realtime_compositor::InputDescriptor for more information. */
bool compositor_skip_realization_ = false;
/** This input expects a single value and can't operate on non-single values. See
* realtime_compositor::InputDescriptor for more information. */
bool compositor_expects_single_value_ = false;
@ -133,6 +137,7 @@ class SocketDeclaration {
const OutputFieldDependency &output_field_dependency() const;
int compositor_domain_priority() const;
bool compositor_skip_realization() const;
bool compositor_expects_single_value() const;
protected:
@ -257,6 +262,14 @@ class SocketDeclarationBuilder : public BaseSocketDeclarationBuilder {
return *(Self *)this;
}
/** This input shouldn't be realized on the operation domain of the node. See
* realtime_compositor::InputDescriptor for more information. */
Self &compositor_skip_realization(bool value = true)
{
decl_->compositor_skip_realization_ = value;
return *(Self *)this;
}
/** This input expects a single value and can't operate on non-single values. See
* realtime_compositor::InputDescriptor for more information. */
Self &compositor_expects_single_value(bool value = true)
@ -460,6 +473,11 @@ inline int SocketDeclaration::compositor_domain_priority() const
return compositor_domain_priority_;
}
inline bool SocketDeclaration::compositor_skip_realization() const
{
return compositor_skip_realization_;
}
inline bool SocketDeclaration::compositor_expects_single_value() const
{
return compositor_expects_single_value_;