diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2012-07-04 15:39:28 +0400 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2012-07-04 15:39:28 +0400 |
commit | 778999cbbf6d6430f6c8d75d8d9e2ea49fa8ace6 (patch) | |
tree | 0ece147a79e1e2249fa22ec28dcd60abf2d49b03 | |
parent | 33e12a298350d9aa684381a71a639864bf9bee3c (diff) |
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.
13 files changed, 65 insertions, 16 deletions
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index e29500858ee..40c7b632247 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -233,8 +233,9 @@ class NODE_PT_quality(bpy.types.Panel): layout.prop(tree, "edit_quality", text="Edit") layout.prop(tree, "chunk_size") layout.prop(tree, "use_opencl") + layout.prop(tree, "two_pass") layout.prop(snode, "show_highlight") - + class NODE_MT_node_color_presets(Menu): """Predefined node color""" 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<Node *>& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup) +Node *ExecutionSystemHelper::addNode(vector<Node *>& 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<Node *>& nodes, bNode *b_node, bool isInActiveGroup); + static Node *addNode(vector<Node *>& 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<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); 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 diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 79be4d0842d..21cf142d1cd 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -303,6 +303,7 @@ typedef struct bNodeTree { /* ntree->flag */ #define NTREE_DS_EXPAND 1 /* for animation editors */ #define NTREE_COM_OPENCL 2 /* use opencl */ +#define NTREE_TWO_PASS 4 /* two pass */ /* XXX not nice, but needed as a temporary flags * for group updates after library linking. */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index cb1a45ed971..1a70745b92a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4267,6 +4267,10 @@ static void rna_def_composite_nodetree(BlenderRNA *brna) prop = RNA_def_property(srna, "use_opencl", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_COM_OPENCL); RNA_def_property_ui_text(prop, "OpenCL", "Enable GPU calculations"); + + prop = RNA_def_property(srna, "two_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_TWO_PASS); + RNA_def_property_ui_text(prop, "Two Pass", "Use two pass execution during editing; First calculate fast nodes, second pass calculate all nodes."); } static void rna_def_shader_nodetree(BlenderRNA *brna) |