void NodeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) { unsigned int temp[2]; unsigned int temp2[2]; for (unsigned int index = 0; index < m_inputs.size(); index++) { NodeOperationInput *input = m_inputs[index]; if (input->isConnected()) { if (index == this->m_resolutionInputSocketIndex) { input->determineResolution(resolution, preferredResolution); temp2[0] = resolution[0]; temp2[1] = resolution[1]; break; } } } for (unsigned int index = 0; index < m_inputs.size(); index++) { NodeOperationInput *input = m_inputs[index]; if (input->isConnected()) { if (index != this->m_resolutionInputSocketIndex) { input->determineResolution(temp, temp2); } } } }
NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex) { NodeOperationInput *input = getInputSocket(inputSocketIndex); if (input && input->isConnected()) return &input->getLink()->getOperation(); else return NULL; }
void NodeOperation::getConnectedInputSockets(Inputs *sockets) { for (Inputs::const_iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) { NodeOperationInput *input = *it; if (input->isConnected()) { sockets->push_back(input); } } }
/* topological (depth-first) sorting of operations */ static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted, Tags &visited, NodeOperation *op) { if (visited.find(op) != visited.end()) return; visited.insert(op); for (int i = 0; i < op->getNumberOfInputSockets(); ++i) { NodeOperationInput *input = op->getInputSocket(i); if (input->isConnected()) sort_operations_recursive(sorted, visited, &input->getLink()->getOperation()); } sorted.push_back(op); }
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group) { if (visited.find(op) != visited.end()) return; visited.insert(op); if (!group->addOperation(op)) return; /* add all eligible input ops to the group */ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) { NodeOperationInput *input = op->getInputSocket(i); if (input->isConnected()) add_group_operations_recursive(visited, &input->getLink()->getOperation(), group); } }
static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op) { if (reachable.find(op) != reachable.end()) return; reachable.insert(op); for (int i = 0; i < op->getNumberOfInputSockets(); ++i) { NodeOperationInput *input = op->getInputSocket(i); if (input->isConnected()) find_reachable_operations_recursive(reachable, &input->getLink()->getOperation()); } /* associated write-buffer operations are executed as well */ if (op->isReadBufferOperation()) { ReadBufferOperation *read_op = (ReadBufferOperation *)op; MemoryProxy *memproxy = read_op->getMemoryProxy(); find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation()); } }
void NodeOperationBuilder::add_operation_input_constants() { /* Note: unconnected inputs cached first to avoid modifying * m_operations while iterating over it */ typedef std::vector<NodeOperationInput*> Inputs; Inputs pending_inputs; for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) { NodeOperation *op = *it; for (int k = 0; k < op->getNumberOfInputSockets(); ++k) { NodeOperationInput *input = op->getInputSocket(k); if (!input->isConnected()) pending_inputs.push_back(input); } } for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) { NodeOperationInput *input = *it; add_input_constant_value(input, find_node_input(m_input_map, input)); } }