From 778999cbbf6d6430f6c8d75d8d9e2ea49fa8ace6 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 4 Jul 2012 11:39:28 +0000 Subject: Two pass execution: 1. first pass only fast nodes are calculated and only to the active viewer node 2. second pass all nodes to all outputs Temp disabled highlights because of random crashes. --- .../compositor/intern/COM_CompositorContext.cpp | 1 + .../blender/compositor/intern/COM_CompositorContext.h | 8 ++++++++ source/blender/compositor/intern/COM_Converter.cpp | 18 +++++++++++++++++- source/blender/compositor/intern/COM_Converter.h | 2 +- .../blender/compositor/intern/COM_ExecutionSystem.cpp | 9 ++++++--- source/blender/compositor/intern/COM_ExecutionSystem.h | 2 +- .../compositor/intern/COM_ExecutionSystemHelper.cpp | 6 +++--- .../compositor/intern/COM_ExecutionSystemHelper.h | 2 +- source/blender/compositor/intern/COM_compositor.cpp | 17 ++++++++++++++++- .../compositor/operations/COM_WriteBufferOperation.cpp | 8 ++++---- 10 files changed, 58 insertions(+), 15 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index 56335630b80..fbdb4cd6b28 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -30,6 +30,7 @@ CompositorContext::CompositorContext() this->m_quality = COM_QUALITY_HIGH; this->m_hasActiveOpenCLDevices = false; this->m_activegNode = NULL; + this->m_fastCalculation = false; } const int CompositorContext::getFramenumber() const diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 49acda811f1..2f6abf39985 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -73,6 +73,11 @@ private: * @brief does this system have active opencl devices? */ bool m_hasActiveOpenCLDevices; + + /** + * @brief Skip slow nodes + */ + bool m_fastCalculation; public: /** @@ -148,6 +153,9 @@ public: int getChunksize() { return this->getbNodeTree()->chunksize; } const int isColorManaged() const; + + void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;} + bool isFastCalculation() {return this->m_fastCalculation;} }; diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 38c514d8e99..05fcfb33c51 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -117,7 +117,7 @@ #include "COM_ViewerNode.h" #include "COM_ZCombineNode.h" -Node *Converter::convert(bNode *b_node) +Node *Converter::convert(bNode *b_node, bool fast) { Node *node; @@ -125,6 +125,22 @@ Node *Converter::convert(bNode *b_node) node = new MuteNode(b_node); return node; } + if (fast) { + if (b_node->type == CMP_NODE_BLUR || + b_node->type == CMP_NODE_VECBLUR || + b_node->type == CMP_NODE_BILATERALBLUR || + b_node->type == CMP_NODE_DEFOCUS || + b_node->type == CMP_NODE_BOKEHBLUR || + b_node->type == CMP_NODE_GLARE || + b_node->type == CMP_NODE_DBLUR || + b_node->type == CMP_NODE_MOVIEDISTORTION || + b_node->type == CMP_NODE_LENSDIST || + b_node->type == CMP_NODE_DOUBLEEDGEMASK || + b_node->type == CMP_NODE_DILATEERODE) + { + return new MuteNode(b_node); + } + } switch (b_node->type) { case CMP_NODE_COMPOSITE: diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h index dbe98871c50..15bda0839fa 100644 --- a/source/blender/compositor/intern/COM_Converter.h +++ b/source/blender/compositor/intern/COM_Converter.h @@ -42,7 +42,7 @@ public: * @see Node * @see MuteNode */ - static Node *convert(bNode *b_node); + static Node *convert(bNode *b_node, bool fast); /** * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type. diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 23e243187d5..ff841092848 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -44,9 +44,10 @@ #include "MEM_guardedalloc.h" #endif -ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering) +ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation) { this->m_context.setbNodeTree(editingtree); + this->m_context.setFastCalculation(fastcalculation); bNode *gnode; for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) { if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { @@ -137,8 +138,10 @@ void ExecutionSystem::execute() WorkScheduler::start(this->m_context); executeGroups(COM_PRIORITY_HIGH); - executeGroups(COM_PRIORITY_MEDIUM); - executeGroups(COM_PRIORITY_LOW); + if (!this->getContext().isFastCalculation()) { + executeGroups(COM_PRIORITY_MEDIUM); + executeGroups(COM_PRIORITY_LOW); + } WorkScheduler::finish(); WorkScheduler::stop(); diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index e51bd7f3026..209358ec786 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -156,7 +156,7 @@ public: * @param editingtree [bNodeTree*] * @param rendering [true false] */ - ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering); + ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation); /** * Destructor diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index 0f6ba1f4ac9..0abf7efdcfa 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -49,7 +49,7 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; while (node != NULL) { - addNode(nodes, node, isActiveGroup); + addNode(nodes, node, isActiveGroup, system.getContext().isFastCalculation()); node = (bNode *)node->next; } @@ -77,11 +77,11 @@ void ExecutionSystemHelper::addNode(vector& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector& nodes, bNode *b_node, bool inActiveGroup) +Node *ExecutionSystemHelper::addNode(vector& nodes, bNode *b_node, bool inActiveGroup, bool fast) { Converter converter; Node *node; - node = converter.convert(b_node); + node = converter.convert(b_node, fast); node->setIsInActiveGroup(inActiveGroup); if (node != NULL) { addNode(nodes, node); diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index 4b65ed15577..bd34fe8ab02 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -58,7 +58,7 @@ public: * @param bNode node to add * @return Node that represents the bNode or null when not able to convert. */ - static Node *addNode(vector& nodes, bNode *b_node, bool isInActiveGroup); + static Node *addNode(vector& nodes, bNode *b_node, bool isInActiveGroup, bool fast); /** * @brief Add a Node to a list diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 7282cf65bc3..9e48334bcca 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -57,8 +57,23 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) /* set progress bar to 0% and status to init compositing*/ editingtree->progress(editingtree->prh, 0.0); + bool twopass = (editingtree->flag&NTREE_TWO_PASS) > 0 || rendering; /* initialize execution system */ - ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering); + if (twopass) { + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass); + system->execute(); + delete system; + + if (editingtree->test_break(editingtree->tbh)) { + // during editing multiple calls to this method can be triggered. + // make sure one the last one will be doing the work. + BLI_mutex_unlock(&compositorMutex); + return; + } + } + + + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false); system->execute(); delete system; diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 1a319d67115..b23c1a02b9f 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -64,7 +64,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me float *buffer = memoryBuffer->getBuffer(); if (this->m_input->isComplex()) { bNode* bnode = this->m_input->getbNode(); - if (bnode&& bnode->new_node) bnode->new_node->highlight++; +// if (bnode&& bnode->new_node) bnode->new_node->highlight++; void *data = this->m_input->initializeTileData(rect, memoryBuffers); int x1 = rect->xmin; @@ -90,7 +90,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me this->m_input->deinitializeTileData(rect, memoryBuffers, data); data = NULL; } - if (bnode&& bnode->new_node) bnode->new_node->highlight++; +// if (bnode&& bnode->new_node) bnode->new_node->highlight++; } else { int x1 = rect->xmin; @@ -144,7 +144,7 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, clMemToCleanUp->push_back(clOutputBuffer); list *clKernelsToCleanUp = new list(); bNode* bnode = this->m_input->getbNode(); - if (bnode&& bnode->new_node) bnode->new_node->highlight++; +// if (bnode&& bnode->new_node) bnode->new_node->highlight++; this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); @@ -163,7 +163,7 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); - if (bnode&& bnode->new_node) bnode->new_node->highlight++; +// if (bnode&& bnode->new_node) bnode->new_node->highlight++; // STEP 4 -- cgit v1.2.3