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.
This commit is contained in:
Jeroen Bakker 2012-07-04 11:39:28 +00:00
parent 33e12a2983
commit 778999cbbf
13 changed files with 65 additions and 16 deletions

@ -233,8 +233,9 @@ class NODE_PT_quality(bpy.types.Panel):
layout.prop(tree, "edit_quality", text="Edit") layout.prop(tree, "edit_quality", text="Edit")
layout.prop(tree, "chunk_size") layout.prop(tree, "chunk_size")
layout.prop(tree, "use_opencl") layout.prop(tree, "use_opencl")
layout.prop(tree, "two_pass")
layout.prop(snode, "show_highlight") layout.prop(snode, "show_highlight")
class NODE_MT_node_color_presets(Menu): class NODE_MT_node_color_presets(Menu):
"""Predefined node color""" """Predefined node color"""

@ -30,6 +30,7 @@ CompositorContext::CompositorContext()
this->m_quality = COM_QUALITY_HIGH; this->m_quality = COM_QUALITY_HIGH;
this->m_hasActiveOpenCLDevices = false; this->m_hasActiveOpenCLDevices = false;
this->m_activegNode = NULL; this->m_activegNode = NULL;
this->m_fastCalculation = false;
} }
const int CompositorContext::getFramenumber() const const int CompositorContext::getFramenumber() const

@ -73,6 +73,11 @@ private:
* @brief does this system have active opencl devices? * @brief does this system have active opencl devices?
*/ */
bool m_hasActiveOpenCLDevices; bool m_hasActiveOpenCLDevices;
/**
* @brief Skip slow nodes
*/
bool m_fastCalculation;
public: public:
/** /**
@ -148,6 +153,9 @@ public:
int getChunksize() { return this->getbNodeTree()->chunksize; } int getChunksize() { return this->getbNodeTree()->chunksize; }
const int isColorManaged() const; const int isColorManaged() const;
void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;}
bool isFastCalculation() {return this->m_fastCalculation;}
}; };

@ -117,7 +117,7 @@
#include "COM_ViewerNode.h" #include "COM_ViewerNode.h"
#include "COM_ZCombineNode.h" #include "COM_ZCombineNode.h"
Node *Converter::convert(bNode *b_node) Node *Converter::convert(bNode *b_node, bool fast)
{ {
Node *node; Node *node;
@ -125,6 +125,22 @@ Node *Converter::convert(bNode *b_node)
node = new MuteNode(b_node); node = new MuteNode(b_node);
return 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) { switch (b_node->type) {
case CMP_NODE_COMPOSITE: case CMP_NODE_COMPOSITE:

@ -42,7 +42,7 @@ public:
* @see Node * @see Node
* @see MuteNode * @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. * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.

@ -44,9 +44,10 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#endif #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.setbNodeTree(editingtree);
this->m_context.setFastCalculation(fastcalculation);
bNode *gnode; bNode *gnode;
for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) { for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) {
if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) {
@ -137,8 +138,10 @@ void ExecutionSystem::execute()
WorkScheduler::start(this->m_context); WorkScheduler::start(this->m_context);
executeGroups(COM_PRIORITY_HIGH); executeGroups(COM_PRIORITY_HIGH);
executeGroups(COM_PRIORITY_MEDIUM); if (!this->getContext().isFastCalculation()) {
executeGroups(COM_PRIORITY_LOW); executeGroups(COM_PRIORITY_MEDIUM);
executeGroups(COM_PRIORITY_LOW);
}
WorkScheduler::finish(); WorkScheduler::finish();
WorkScheduler::stop(); WorkScheduler::stop();

@ -156,7 +156,7 @@ public:
* @param editingtree [bNodeTree*] * @param editingtree [bNodeTree*]
* @param rendering [true false] * @param rendering [true false]
*/ */
ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering); ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation);
/** /**
* Destructor * Destructor

@ -49,7 +49,7 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star
/* add all nodes of the tree to the node list */ /* add all nodes of the tree to the node list */
bNode *node = (bNode *)tree->nodes.first; bNode *node = (bNode *)tree->nodes.first;
while (node != NULL) { while (node != NULL) {
addNode(nodes, node, isActiveGroup); addNode(nodes, node, isActiveGroup, system.getContext().isFastCalculation());
node = (bNode *)node->next; node = (bNode *)node->next;
} }
@ -77,11 +77,11 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node)
nodes.push_back(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; Converter converter;
Node *node; Node *node;
node = converter.convert(b_node); node = converter.convert(b_node, fast);
node->setIsInActiveGroup(inActiveGroup); node->setIsInActiveGroup(inActiveGroup);
if (node != NULL) { if (node != NULL) {
addNode(nodes, node); addNode(nodes, node);

@ -58,7 +58,7 @@ public:
* @param bNode node to add * @param bNode node to add
* @return Node that represents the bNode or null when not able to convert. * @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 * @brief Add a Node to a list

@ -57,8 +57,23 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
/* set progress bar to 0% and status to init compositing*/ /* set progress bar to 0% and status to init compositing*/
editingtree->progress(editingtree->prh, 0.0); editingtree->progress(editingtree->prh, 0.0);
bool twopass = (editingtree->flag&NTREE_TWO_PASS) > 0 || rendering;
/* initialize execution system */ /* 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(); system->execute();
delete system; delete system;

@ -64,7 +64,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
float *buffer = memoryBuffer->getBuffer(); float *buffer = memoryBuffer->getBuffer();
if (this->m_input->isComplex()) { if (this->m_input->isComplex()) {
bNode* bnode = this->m_input->getbNode(); 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); void *data = this->m_input->initializeTileData(rect, memoryBuffers);
int x1 = rect->xmin; int x1 = rect->xmin;
@ -90,7 +90,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
this->m_input->deinitializeTileData(rect, memoryBuffers, data); this->m_input->deinitializeTileData(rect, memoryBuffers, data);
data = NULL; data = NULL;
} }
if (bnode&& bnode->new_node) bnode->new_node->highlight++; // if (bnode&& bnode->new_node) bnode->new_node->highlight++;
} }
else { else {
int x1 = rect->xmin; int x1 = rect->xmin;
@ -144,7 +144,7 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
clMemToCleanUp->push_back(clOutputBuffer); clMemToCleanUp->push_back(clOutputBuffer);
list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
bNode* bnode = this->m_input->getbNode(); 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); 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); 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 // STEP 4

@ -303,6 +303,7 @@ typedef struct bNodeTree {
/* ntree->flag */ /* ntree->flag */
#define NTREE_DS_EXPAND 1 /* for animation editors */ #define NTREE_DS_EXPAND 1 /* for animation editors */
#define NTREE_COM_OPENCL 2 /* use opencl */ #define NTREE_COM_OPENCL 2 /* use opencl */
#define NTREE_TWO_PASS 4 /* two pass */
/* XXX not nice, but needed as a temporary flags /* XXX not nice, but needed as a temporary flags
* for group updates after library linking. * for group updates after library linking.
*/ */

@ -4267,6 +4267,10 @@ static void rna_def_composite_nodetree(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_opencl", PROP_BOOLEAN, PROP_NONE); 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_boolean_sdna(prop, NULL, "flag", NTREE_COM_OPENCL);
RNA_def_property_ui_text(prop, "OpenCL", "Enable GPU calculations"); 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) static void rna_def_shader_nodetree(BlenderRNA *brna)