44 : m_context(
context), m_current_node(nullptr), m_active_viewer(nullptr)
55 m_current_node =
node;
58 node->convertToOperations(converter, *m_context);
61 m_current_node =
nullptr;
69 inverse_input_map.
add(item.value, item.key);
79 if (!op_from || op_to_list.
is_empty()) {
123 operation->
set_id(m_operations.size());
124 m_operations.append(operation);
125 if (m_current_node) {
140 m_input_map.add_new(operation_socket, node_socket);
149 m_output_map.add_new(node_socket, operation_socket);
167 for (
Link &link : m_links) {
168 if (link.to() == to) {
172 m_links.remove(index);
197 PreviewOperation *operation =
new PreviewOperation(m_context->
getViewSettings(),
202 operation->verifyPreview(previews, m_current_node->
getInstanceKey());
231 if (m_active_viewer) {
236 m_active_viewer = viewer;
242 m_active_viewer = viewer;
255 for (
const Link &link : m_links) {
264 if (link.from()->getDataType() != link.to()->getDataType()) {
265 convert_links.
append(link);
268 for (
const Link &link : convert_links) {
287 for (
int k = 0; k < op->getNumberOfInputSockets(); ++k) {
290 pending_inputs.
append(input);
354 for (
const Link &link : m_links) {
356 if (link.from()->getOperation().get_flags().is_proxy_operation &&
357 !link.to()->getOperation().get_flags().is_proxy_operation) {
362 for (
const Link &link : proxy_links) {
367 from =
from->getOperation().getInputSocket(0)->getLink();
368 }
while (
from &&
from->getOperation().get_flags().is_proxy_operation);
384 if (op->isOutputOperation(m_context->
isRendering()) && !op->get_flags().is_preview_operation) {
385 unsigned int resolution[2] = {0, 0};
386 unsigned int preferredResolution[2] = {0, 0};
387 op->determineResolution(resolution, preferredResolution);
388 op->setResolution(resolution);
393 if (op->isOutputOperation(m_context->
isRendering()) && op->get_flags().is_preview_operation) {
394 unsigned int resolution[2] = {0, 0};
395 unsigned int preferredResolution[2] = {0, 0};
396 op->determineResolution(resolution, preferredResolution);
397 op->setResolution(resolution);
404 for (
const Link &link : m_links) {
409 convert_links.
append(link);
413 for (
const Link &link : convert_links) {
423 for (
const Link &link : m_links) {
424 if (link.from() ==
output) {
434 for (
const Link &link : m_links) {
435 if (link.from() ==
output) {
453 if (
output->getOperation().get_flags().is_read_buffer_operation) {
463 if (!writeoperation) {
495 if (target->getOperation().get_flags().is_write_buffer_operation) {
506 if (!writeOperation) {
518 if (&target->getOperation() == writeOperation) {
540 if (operation->get_flags().complex) {
541 complex_ops.
append(operation);
548 for (
int index = 0; index < op->getNumberOfInputSockets(); index++) {
552 for (
int index = 0; index < op->getNumberOfOutputSockets(); index++) {
558 using Tags = std::set<NodeOperation *>;
562 if (reachable.find(op) != reachable.end()) {
565 reachable.insert(op);
587 if (op->isOutputOperation(m_context->
isRendering())) {
595 if (reachable.find(op) != reachable.end()) {
603 m_operations = reachable_ops;
629 sorted.
reserve(m_operations.size());
636 m_operations = sorted;
662 m_groups.append(group);
673 if (op->isOutputOperation(m_context->
isRendering())) {
679 if (op->get_flags().is_read_buffer_operation) {
694 os <<
"# Builder start\n";
695 os <<
"digraph G {\n";
696 os <<
" rankdir=LR;\n";
697 os <<
" node [shape=box];\n";
699 os <<
" op" << operation->get_id() <<
" [label=\"" << *operation <<
"\"];\n";
704 os <<
" op" << link.from()->getOperation().get_id() <<
" -> op"
705 << link.to()->getOperation().get_id() <<
";\n";
708 if (operation->get_flags().is_read_buffer_operation) {
713 os <<
" op" << write_operation.
get_id() <<
" -> op" << read_operation.
get_id() <<
";\n";
718 os <<
"# Builder end\n";
MINLINE void zero_v4(float r[4])
MINLINE void zero_v3(float r[3])
Span< Value > lookup(const Key &key) const
void add(const Key &key, const Value &value)
constexpr bool is_empty() const
void append(const T &value)
void reserve(const int64_t min_capacity)
Overall context of the compositor.
bNodeInstanceHash * getPreviewHash() const
get the preview image hash table
bool isRendering() const
get the rendering field of the context
const bNodeTree * getbNodeTree() const
get the bnodetree of the context
const ColorManagedDisplaySettings * getDisplaySettings() const
get display settings of color color management
const ColorManagedViewSettings * getViewSettings() const
get view settings of color color management
static void operation_read_write_buffer(const NodeOperation *operation)
static void node_to_operations(const Node *node)
Class ExecutionGroup is a group of Operations that are executed as one. This grouping is used to comb...
void setOutputExecutionGroup(bool is_output)
set whether this ExecutionGroup is an output
bool addOperation(NodeOperation *operation)
add an operation to this ExecutionGroup
the ExecutionSystem contains the whole compositor tree.
void set_operations(const Vector< NodeOperation * > &operations, const Vector< ExecutionGroup * > &groups)
A MemoryProxy is a unique identifier for a memory buffer. A single MemoryProxy is used among all chun...
void setExecutor(ExecutionGroup *executor)
set the ExecutionGroup that can be scheduled to calculate a certain chunk.
ExecutionGroup * getExecutor() const
get the ExecutionGroup that can be scheduled to calculate a certain chunk.
WriteBufferOperation * getWriteBufferOperation() const
get the WriteBufferOperation that is responsible for writing to this MemoryProxy
void from_bNodeTree(const CompositorContext &context, bNodeTree *tree)
const Vector< Node * > & nodes() const
const Vector< Link > & links() const
NodeOperationOutput * from() const
NodeOperationInput * to() const
void addNodeInputPreview(NodeInput *input)
WriteBufferOperation * find_attached_write_buffer_operation(NodeOperationOutput *output) const
void convertToOperations(ExecutionSystem *system)
void removeInputLink(NodeOperationInput *to)
void add_datatype_conversions()
void addOperation(NodeOperation *operation)
void addPreview(NodeOperationOutput *output)
void add_input_constant_value(NodeOperationInput *input, const NodeInput *node_input)
void registerViewer(ViewerOperation *viewer)
void add_output_buffers(NodeOperation *operation, NodeOperationOutput *output)
Vector< NodeOperationInput * > cache_output_links(NodeOperationOutput *output) const
void add_input_buffers(NodeOperation *operation, NodeOperationInput *input)
const Vector< Link > & get_links() const
void determineResolutions()
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
void addLink(NodeOperationOutput *from, NodeOperationInput *to)
ExecutionGroup * make_group(NodeOperation *op)
const Vector< NodeOperation * > & get_operations() const
const CompositorContext & context() const
NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree)
void add_operation_input_constants()
void add_complex_operation_buffers()
DataType getDataType() const
NodeOperation & getOperation() const
NodeOperation contains calculation logic.
void set_name(const std::string name)
void set_id(const int id)
NodeOperationInput * getInputSocket(unsigned int index)
unsigned int getHeight() const
const NodeOperationFlags get_flags() const
unsigned int getNumberOfInputSockets() const
unsigned int getWidth() const
NodeOperationOutput * getOutputSocket(unsigned int index=0)
void setbNodeTree(const bNodeTree *tree)
NodeOutput are sockets that can send data/input.
bNode * getbNode() const
get the reference to the SDNA bNode struct
bNodeInstanceKey getInstanceKey() const
bNodeTree * getbNodeTree() const
get the reference to the SDNA bNodeTree struct
bool isInActiveGroup() const
Is this node part of the active group the active group is the group that is currently being edited....
void setMemoryProxy(MemoryProxy *memoryProxy)
MemoryProxy * getMemoryProxy() const
void readResolutionFromWriteBuffer()
void setChannels(const float value[4])
void setValue(float value)
void setVector(const float vector[3])
void setActive(bool active)
NodeOperation to write to a tile.
void readResolutionFromInputSocket()
MemoryProxy * getMemoryProxy()
Set< ComponentNode * > visited
@ Vector
Vector data type.
@ None
The bottom left of the input image is the bottom left of the working area of the node,...
static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op)
NodeOperation * COM_convert_data_type(const NodeOperationOutput &from, const NodeOperationInput &to)
This function will add a datetype conversion rule when the to-socket does not support the from-socket...
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
void COM_convert_resolution(NodeOperationBuilder &builder, NodeOperationOutput *fromSocket, NodeOperationInput *toSocket)
This function will add a resolution rule based on the settings of the NodeInput.
std::set< NodeOperation * > Tags
static void sort_operations_recursive(Vector< NodeOperation * > &sorted, Tags &visited, NodeOperation *op)
std::ostream & operator<<(std::ostream &os, const eCompositorPriority &priority)
static bNodeSocketTemplate inputs[]
bool is_write_buffer_operation
bool use_datatype_conversion
bool is_read_buffer_operation