Commit: c0e3d2c10304a6eda455f1664abe4847dfce83b6 Author: Omar Emara Date: Wed Mar 30 11:09:42 2022 +0200 Branches: temp-viewport-compositor-compiler https://developer.blender.org/rBc0e3d2c10304a6eda455f1664abe4847dfce83b6
Viewport Compositor: Introduce input domain priority Inputs now declare a domain priority value instead of declaring themselves as domain inputs. This allows multiple inputs to assume domain inference role, and the best option is chosen based on the priority and other factors. =================================================================== M source/blender/nodes/NOD_compositor_execute.hh M source/blender/nodes/NOD_node_declaration.hh M source/blender/nodes/composite/nodes/node_composite_transform.cc M source/blender/nodes/intern/node_compositor_execute.cc =================================================================== diff --git a/source/blender/nodes/NOD_compositor_execute.hh b/source/blender/nodes/NOD_compositor_execute.hh index 3d107a7f24d..6171f859c33 100644 --- a/source/blender/nodes/NOD_compositor_execute.hh +++ b/source/blender/nodes/NOD_compositor_execute.hh @@ -137,11 +137,11 @@ class Context { * operation domain. To abstract away the different domains of the inputs, any input that have a * different domain than the operation domain is realized on the operation domain through a * RealizeOnDomainProcessorOperation, except inputs whose descriptor sets skip_realization or - * is_domain, see InputDescriptor. The realization process simply projects the input domain on the - * operation domain, copies the area of input that intersects the operation domain, and fill the - * rest with zeros. This process is illustrated below. It follows that operations should expect all - * their inputs to have the same domain and consequently size, except possibly for inputs that skip - * realization. + * expects_single_value, see InputDescriptor for more information. The realization process simply + * projects the input domain on the operation domain, copies the area of input that intersects the + * operation domain, and fill the rest with zeros. This process is illustrated below. It follows + * that operations should expect all their inputs to have the same domain and consequently size, + * except for inputs that explicitly skip realization. * * Realized Result * +-------------+ +-------------+ @@ -151,18 +151,16 @@ class Context { * +-----------+ | |-----+ | * | | C | | | C | | * | +-----|-------+ +-----|-------+ - * | Input | - * | Domain | + * | Domain Of | + * | Input | * +-----------+ * * Each operation can define an arbitrary operation domain, but in most cases, the operation domain * is inferred from the inputs. By default, the operation domain is computed as follows. Typically, - * one input of the operation is said to be a domain input and it defines the operation domain. So - * if the operation have an input whose descriptor sets is_domain and is not a single value input, - * then the operation domain will be the same domain as the first such input. See the - * InputDescriptor class. Otherwise, if no domain inputs exists or all are single value inputs, - * then the first non single value input is used to define the operation domain. If all inputs are - * single values, then the operation domain is irrelevant and an identity domain is set. See + * one input of the operation is said to be the domain input and the operation domain is inferred + * from it. The domain input is determined to be the non-single value input that have the highest + * domain priority, a zero value being the highest priority. If all inputs are single values, then + * the operation domain is irrelevant and an identity domain is set. See * NodeOperation::compute_domain. * * The aforementioned logic for operation domain computation is only a default that works for most @@ -171,15 +169,17 @@ class Context { * identity transformation, their operation domain doesn't depend on the inputs at all. * * For instance, a filter operation have two inputs, a factor and a color, the latter of which - * is a domain input. If the color input is not a single value, then the domain of this operation - * is computed to be the same size and transformation as the color input. And if the factor input + * has a domain priority of 0 and the former has a domain priority of 1. If the color input is not + * a single value, then the domain of this operation is computed to be the same size and + * transformation as the color input, because it has the highest priority. And if the factor input * have a different size and/or transformation from the computed domain of the operation, it will * be projected and realized on it to have the same size as described above. It follows that the - * color input, which is a domain input, will not need to be realized because it already has the - * same size and transformation as the domain of the operation, because the operation domain is - * derived from it. On the other hand, if the color input is a single value input, then the - * operation domain will be the same as the domain of the factor input. Finally, if both inputs are - * single value inputs, the operation domain will be an identity and is irrelevant. */ + * color input, will not need to be realized because it already has the same size and + * transformation as the domain of the operation, because the operation domain is inferred from it. + * On the other hand, if the color input is a single value input, then the operation domain will be + * the same as the domain of the factor input, because it has the second highest domain priority. + * Finally, if both inputs are single value inputs, the operation domain will be an identity and is + * irrelevant. */ class Domain { public: /* The size of the domain in pixels. */ @@ -220,8 +220,8 @@ class Result { private: /* The base type of the texture or the type of the single value. */ ResultType type_; - /* If true, the result is a texture, otherwise, the result is a single value. */ - bool is_texture_; + /* If true, the result is a single value, otherwise, the result is a texture. */ + bool is_single_value_; /* A GPU texture storing the result data. This will be a 1x1 texture if the result is a single * value, the value of which will be identical to that of the value member. See class description * for more information. */ @@ -375,10 +375,16 @@ class InputDescriptor { /* If true, then the input does not need to be realized on the domain of the operation before its * execution. See the Domain class for more information. */ bool skip_realization = false; - /* If true, then the input is considered to be a domain input that is used by default to define - * the domain of the operation, this is typically the main input of the operation. See the Domain - * class for more information. */ - bool is_domain = false; + /* The priority of the input for determining the operation domain. The non-single value input + * with the highest priority will be used to infer the operation domain, the highest priority + * being zero. See the Domain class for more information. */ + int domain_priority = 0; + /* If true, the input expects a single value, and if a non-single value is provided, a default + * single value will be used instead, see the get_*_value_default methods in the Result + * class. It follows that this also imply skip_realization, because we don't need to realize a + * result that will be discarded anyways. If false, the input can work with both single and + * non-single values. */ + bool expects_single_value = false; }; /* -------------------------------------------------------------------- diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh index 8fef760a1f1..afc507752f9 100644 --- a/source/blender/nodes/NOD_node_declaration.hh +++ b/source/blender/nodes/NOD_node_declaration.hh @@ -102,8 +102,13 @@ class SocketDeclaration { InputSocketFieldType input_field_type_ = InputSocketFieldType::None; OutputFieldDependency output_field_dependency_; - /** This input is a domain input. See viewport_compositor::InputDescriptor. */ - bool is_compositor_domain_input_ = false; + /** The priority of the input for determining the domain of the node. See + * viewport_compositor::InputDescriptor for more information. */ + int compositor_domain_priority_ = 0; + + /** This input expects a single value and can't operate on non-single values. See + * viewport_compositor::InputDescriptor for more information. */ + bool compositor_expects_single_value_ = false; /** Utility method to make the socket available if there is a straightforward way to do so. */ std::function<void(bNode &)> make_available_fn_; @@ -141,7 +146,8 @@ class SocketDeclaration { InputSocketFieldType input_field_type() const; const OutputFieldDependency &output_field_dependency() const; - bool is_compositor_domain_input() const; + int compositor_domain_priority() const; + bool compositor_expects_single_value() const; protected: void set_common_flags(bNodeSocket &socket) const; @@ -257,10 +263,19 @@ class SocketDeclarationBuilder : public BaseSocketDeclarationBuilder { return *(Self *)this; } - /** This input is a domain input. See viewport_compositor::InputDescriptor. */ - Self &is_compositor_domain_input(bool value = true) + /** The priority of the input for determining the domain of the node. See + * viewport_compositor::InputDescriptor for more information. */ + Self &compositor_domain_priority(int priority) + { + decl_->compositor_domain_priority_ = priority; + return *(Self *)this; + } + + /** This input expects a single value and can't operate on non-single values. See + * viewport_compositor::InputDescriptor for more information. */ + Self &compositor_expects_single_value(bool value = true) { - decl_->is_compositor_domain_input_ = value; + decl_->compositor_expects_single_value_ = value; return *(Self *)this; } @@ -454,9 +469,14 @@ inline const OutputFieldDependency &SocketDeclaration::output_field_dependency() return output_field_dependency_; } -inline bool SocketDeclaration::is_compositor_domain_input() const +inline int SocketDeclaration::compositor_domain_priority() const +{ + return compositor_domain_priority_; +} + +inline bool SocketDeclaration::compositor_expects_single_value() const { - return is_compositor_domain_input_; + return compositor_expects_single_value_; } inline void SocketDeclaration::make_available(bNode &node) const diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.cc b/source/blender/nodes/composite/nodes/node_composite_transform.cc index aaaac45333b..d6f2734b54d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_transform.cc +++ b/source/blender/nodes/composi @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs