diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
commit | 1f7ae143a29b090ed97cdd7eb47a9c2dbd7f72a2 (patch) | |
tree | fff560080a8bbf37ee087653df1b8a30173537b1 /source/blender/compositor | |
parent | d38ba6b5d25ca42f76b6d1b746217a565f26228f (diff) | |
parent | 74c9c24d273863319a55c18234e03b7d27a43a87 (diff) |
Merged changes in the trunk up to revision 48227.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_file/filelist.c
Diffstat (limited to 'source/blender/compositor')
81 files changed, 1355 insertions, 616 deletions
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index fbe391a554d..d0093c58d23 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -288,6 +288,10 @@ set(SRC nodes/COM_BokehBlurNode.h nodes/COM_DirectionalBlurNode.cpp nodes/COM_DirectionalBlurNode.h + operations/COM_GaussianAlphaXBlurOperation.cpp + operations/COM_GaussianAlphaXBlurOperation.h + operations/COM_GaussianAlphaYBlurOperation.cpp + operations/COM_GaussianAlphaYBlurOperation.h operations/COM_GaussianXBlurOperation.cpp operations/COM_GaussianXBlurOperation.h operations/COM_GaussianYBlurOperation.cpp diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index 4789fed2efd..4d8c83a5b2d 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -297,7 +297,7 @@ extern "C" { * - output nodes can have different priorities in the WorkScheduler. * This is implemented in the COM_execute function. */ -void COM_execute(bNodeTree *editingtree, int rendering); +void COM_execute(RenderData* rd, bNodeTree *editingtree, int rendering); #ifdef __cplusplus } diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h index 57b73c836df..e11048b23f3 100644 --- a/source/blender/compositor/COM_defines.h +++ b/source/blender/compositor/COM_defines.h @@ -67,7 +67,7 @@ typedef enum CompositorPriority { // chunk size determination #define COM_PREVIEW_SIZE 140.0f -//#define COM_OPENCL_ENABLED +#define COM_OPENCL_ENABLED //#define COM_DEBUG // workscheduler threading models diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index bb8e7d9606d..c3470f0a16e 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -26,7 +26,7 @@ CompositorContext::CompositorContext() { - this->scene = NULL; + this->rd = NULL; this->quality = COM_QUALITY_HIGH; this->hasActiveOpenCLDevices = false; this->activegNode = NULL; @@ -34,8 +34,8 @@ CompositorContext::CompositorContext() const int CompositorContext::getFramenumber() const { - if (this->scene) { - return this->scene->r.cfra; + if (this->rd) { + return this->rd->cfra; } else { return -1; /* this should never happen */ @@ -44,8 +44,8 @@ const int CompositorContext::getFramenumber() const const int CompositorContext::isColorManaged() const { - if (this->scene) { - return this->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + if (this->rd) { + return this->rd->color_mgt_flag & R_COLOR_MANAGEMENT; } else { return 0; /* this should never happen */ diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 93872f4839f..81fd81b4117 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -51,11 +51,11 @@ private: CompositorQuality quality; /** - * @brief Reference to the scene that is being composited. + * @brief Reference to the render data that is being composited. * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - Scene *scene; + RenderData *rd; /** * @brief reference to the bNodeTree @@ -93,7 +93,7 @@ public: /** * @brief set the scene of the context */ - void setScene(Scene *scene) { this->scene = scene; } + void setRenderData(RenderData *rd) { this->rd = rd; } /** * @brief set the bnodetree of the context @@ -118,7 +118,7 @@ public: /** * @brief get the scene of the context */ - const Scene *getScene() const { return this->scene; } + const RenderData *getRenderData() const { return this->rd; } /** * @brief set the quality diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index fa30d965938..0a8862e4017 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -20,100 +20,102 @@ * Monique Dewanchand */ -#include "COM_Converter.h" +#include <string.h> + #include "BKE_node.h" -#include "COM_CompositorNode.h" -#include "COM_RenderLayersNode.h" + +#include "COM_AlphaOverNode.h" +#include "COM_BilateralBlurNode.h" +#include "COM_BlurNode.h" +#include "COM_BokehBlurNode.h" +#include "COM_BokehImageNode.h" +#include "COM_BoxMaskNode.h" +#include "COM_BrightnessNode.h" +#include "COM_ChannelMatteNode.h" +#include "COM_ChromaMatteNode.h" +#include "COM_ColorBalanceNode.h" +#include "COM_ColorCorrectionNode.h" +#include "COM_ColorCurveNode.h" +#include "COM_ColorMatteNode.h" +#include "COM_ColorNode.h" +#include "COM_ColorRampNode.h" +#include "COM_ColorSpillNode.h" #include "COM_ColorToBWNode.h" -#include "string.h" -#include "COM_SocketConnection.h" +#include "COM_CombineHSVANode.h" +#include "COM_CombineRGBANode.h" +#include "COM_CombineYCCANode.h" +#include "COM_CombineYUVANode.h" +#include "COM_CompositorNode.h" +#include "COM_ConvertAlphaNode.h" +#include "COM_ConvertColorToVectorOperation.h" #include "COM_ConvertColourToValueProg.h" #include "COM_ConvertValueToColourProg.h" -#include "COM_ConvertColorToVectorOperation.h" #include "COM_ConvertValueToVectorOperation.h" #include "COM_ConvertVectorToColorOperation.h" #include "COM_ConvertVectorToValueOperation.h" +#include "COM_Converter.h" +#include "COM_CropNode.h" +#include "COM_DefocusNode.h" +#include "COM_DifferenceMatteNode.h" +#include "COM_DilateErodeNode.h" +#include "COM_DirectionalBlurNode.h" +#include "COM_DisplaceNode.h" +#include "COM_DistanceMatteNode.h" +#include "COM_DoubleEdgeMaskNode.h" +#include "COM_EllipseMaskNode.h" #include "COM_ExecutionSystem.h" +#include "COM_ExecutionSystemHelper.h" +#include "COM_FilterNode.h" +#include "COM_FlipNode.h" +#include "COM_GammaNode.h" +#include "COM_GlareNode.h" +#include "COM_GroupNode.h" +#include "COM_HueSaturationValueCorrectNode.h" +#include "COM_HueSaturationValueNode.h" +#include "COM_IDMaskNode.h" +#include "COM_ImageNode.h" +#include "COM_InvertNode.h" +#include "COM_KeyingNode.h" +#include "COM_KeyingScreenNode.h" +#include "COM_LensDistortionNode.h" +#include "COM_LuminanceMatteNode.h" +#include "COM_MapUVNode.h" +#include "COM_MapValueNode.h" +#include "COM_MaskNode.h" +#include "COM_MathNode.h" #include "COM_MixNode.h" +#include "COM_MovieClipNode.h" +#include "COM_MovieDistortionNode.h" #include "COM_MuteNode.h" -#include "COM_TranslateNode.h" +#include "COM_NormalNode.h" +#include "COM_NormalizeNode.h" +#include "COM_OutputFileNode.h" +#include "COM_RenderLayersNode.h" #include "COM_RotateNode.h" #include "COM_ScaleNode.h" -#include "COM_FlipNode.h" -#include "COM_IDMaskNode.h" -#include "COM_FilterNode.h" -#include "COM_BrightnessNode.h" -#include "COM_SeparateRGBANode.h" -#include "COM_CombineRGBANode.h" +#include "COM_ScaleOperation.h" #include "COM_SeparateHSVANode.h" -#include "COM_CombineHSVANode.h" -#include "COM_SeparateYUVANode.h" -#include "COM_CombineYUVANode.h" +#include "COM_SeparateRGBANode.h" #include "COM_SeparateYCCANode.h" -#include "COM_CombineYCCANode.h" -#include "COM_AlphaOverNode.h" -#include "COM_ColorBalanceNode.h" -#include "COM_ViewerNode.h" -#include "COM_SplitViewerNode.h" -#include "COM_InvertNode.h" -#include "COM_GroupNode.h" -#include "COM_NormalNode.h" -#include "COM_NormalizeNode.h" -#include "COM_ImageNode.h" -#include "COM_BokehImageNode.h" -#include "COM_ColorCurveNode.h" -#include "COM_VectorCurveNode.h" +#include "COM_SeparateYUVANode.h" #include "COM_SetAlphaNode.h" -#include "COM_ConvertAlphaNode.h" -#include "COM_MapUVNode.h" -#include "COM_DisplaceNode.h" -#include "COM_MathNode.h" -#include "COM_HueSaturationValueNode.h" -#include "COM_HueSaturationValueCorrectNode.h" -#include "COM_ColorCorrectionNode.h" -#include "COM_BoxMaskNode.h" -#include "COM_EllipseMaskNode.h" -#include "COM_GammaNode.h" -#include "COM_ColorRampNode.h" -#include "COM_DifferenceMatteNode.h" -#include "COM_LuminanceMatteNode.h" -#include "COM_DistanceMatteNode.h" -#include "COM_ChromaMatteNode.h" -#include "COM_ColorMatteNode.h" -#include "COM_ChannelMatteNode.h" -#include "COM_BlurNode.h" -#include "COM_BokehBlurNode.h" -#include "COM_DilateErodeNode.h" -#include "COM_TranslateOperation.h" -#include "COM_LensDistortionNode.h" +#include "COM_SetValueOperation.h" +#include "COM_SocketConnection.h" +#include "COM_SplitViewerNode.h" +#include "COM_Stabilize2dNode.h" +#include "COM_SwitchNode.h" #include "COM_TextureNode.h" -#include "COM_ColorNode.h" -#include "COM_ValueNode.h" #include "COM_TimeNode.h" -#include "COM_DirectionalBlurNode.h" -#include "COM_ZCombineNode.h" -#include "COM_SetValueOperation.h" -#include "COM_ScaleOperation.h" -#include "COM_ExecutionSystemHelper.h" #include "COM_TonemapNode.h" -#include "COM_SwitchNode.h" -#include "COM_GlareNode.h" -#include "COM_MovieClipNode.h" -#include "COM_ColorSpillNode.h" -#include "COM_OutputFileNode.h" -#include "COM_MapValueNode.h" #include "COM_TransformNode.h" -#include "COM_Stabilize2dNode.h" -#include "COM_BilateralBlurNode.h" +#include "COM_TranslateNode.h" +#include "COM_TranslateOperation.h" +#include "COM_ValueNode.h" #include "COM_VectorBlurNode.h" -#include "COM_MovieDistortionNode.h" +#include "COM_VectorCurveNode.h" #include "COM_ViewLevelsNode.h" -#include "COM_DefocusNode.h" -#include "COM_DoubleEdgeMaskNode.h" -#include "COM_CropNode.h" -#include "COM_MaskNode.h" -#include "COM_KeyingScreenNode.h" -#include "COM_KeyingNode.h" +#include "COM_ViewerNode.h" +#include "COM_ZCombineNode.h" Node *Converter::convert(bNode *bNode) { diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h index 08fdb5bb578..2a86382a191 100644 --- a/source/blender/compositor/intern/COM_Device.h +++ b/source/blender/compositor/intern/COM_Device.h @@ -23,11 +23,7 @@ #ifndef _COM_Device_h #define _COM_Device_h -#include "COM_ExecutionSystem.h" #include "COM_WorkPackage.h" -#include "COM_NodeOperation.h" -#include "BLI_rect.h" -#include "COM_MemoryBuffer.h" /** * @brief Abstract class for device implementations to be used by the Compositor. diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 2a790da0354..4dfb9c7d26c 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -20,24 +20,25 @@ * Monique Dewanchand */ +#include <algorithm> +#include <math.h> +#include <sstream> +#include <stdlib.h> + +#include "BLI_math.h" +#include "PIL_time.h" + #include "COM_ExecutionGroup.h" #include "COM_InputSocket.h" #include "COM_SocketConnection.h" #include "COM_defines.h" -#include "math.h" #include "COM_ExecutionSystem.h" -#include <sstream> #include "COM_ReadBufferOperation.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" #include "COM_WorkScheduler.h" #include "COM_ViewerOperation.h" -#include <stdlib.h> -#include "BLI_math.h" -#include "PIL_time.h" #include "COM_ChunkOrder.h" -#include <algorithm> -#include "BLI_math.h" #include "COM_ExecutionSystemHelper.h" ExecutionGroup::ExecutionGroup() diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 7250a851f7b..7e09486fd0b 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -22,16 +22,18 @@ #include "COM_ExecutionSystem.h" +#include <sstream> +#include <stdio.h> + #include "PIL_time.h" #include "BKE_node.h" + #include "COM_Converter.h" -#include <sstream> #include "COM_NodeOperation.h" #include "COM_ExecutionGroup.h" #include "COM_NodeBase.h" #include "COM_WorkScheduler.h" #include "COM_ReadBufferOperation.h" -#include "stdio.h" #include "COM_GroupNode.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" @@ -39,7 +41,7 @@ #include "BKE_global.h" -ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) +ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering) { context.setbNodeTree(editingtree); bNode *gnode; @@ -60,22 +62,18 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) context.setRendering(rendering); context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL)); - Node *mainOutputNode = NULL; + ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); - mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); - - if (mainOutputNode) { - context.setScene((Scene *)mainOutputNode->getbNode()->id); - this->convertToOperations(); - this->groupOperations(); /* group operations in ExecutionGroups */ - unsigned int index; - unsigned int resolution[2]; - for (index = 0; index < this->groups.size(); index++) { - resolution[0] = 0; - resolution[1] = 0; - ExecutionGroup *executionGroup = groups[index]; - executionGroup->determineResolution(resolution); - } + context.setRenderData(rd); + this->convertToOperations(); + this->groupOperations(); /* group operations in ExecutionGroups */ + unsigned int index; + unsigned int resolution[2]; + for (index = 0; index < this->groups.size(); index++) { + resolution[0] = 0; + resolution[1] = 0; + ExecutionGroup *executionGroup = groups[index]; + executionGroup->determineResolution(resolution); } #ifdef COM_DEBUG diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 70fd94ca57f..48ff2ef6af9 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(bNodeTree *editingtree, bool rendering); + ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering); /** * Destructor diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index bcb606316ab..e5376567077 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -22,36 +22,34 @@ #include "COM_ExecutionSystemHelper.h" +#include <sstream> +#include <stdio.h> + #include "PIL_time.h" #include "BKE_node.h" + #include "COM_Converter.h" -#include <sstream> #include "COM_NodeOperation.h" #include "COM_ExecutionGroup.h" #include "COM_NodeBase.h" #include "COM_WorkScheduler.h" #include "COM_ReadBufferOperation.h" -#include "stdio.h" #include "COM_GroupNode.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" #include "COM_ViewerBaseOperation.h" -Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode) +void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode) { vector<Node *>& nodes = system.getNodes(); vector<SocketConnection *>& links = system.getConnections(); - Node *mainnode = NULL; const bNode *activeGroupNode = system.getContext().getActivegNode(); bool isActiveGroup = activeGroupNode == groupnode; /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; while (node != NULL) { - Node *execnode = addNode(nodes, node, isActiveGroup); - if (node->type == CMP_NODE_COMPOSITE) { - mainnode = execnode; - } + addNode(nodes, node, isActiveGroup); node = (bNode *)node->next; } @@ -72,8 +70,6 @@ Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_sta groupNode->ungroup(system); } } - - return mainnode; } void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index 99a05472075..8dbd308153b 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -48,7 +48,7 @@ public: * @param tree bNodeTree to add * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added */ - static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode); + static void addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode); /** * @brief add an editor node to the system. diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 62e030b777c..06b6164be3c 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -20,11 +20,12 @@ * Monique Dewanchand */ -#include "COM_Node.h" -#include "string.h" +#include <string.h> -#include "COM_NodeOperation.h" #include "BKE_node.h" + +#include "COM_Node.h" +#include "COM_NodeOperation.h" #include "COM_SetValueOperation.h" #include "COM_SetVectorOperation.h" #include "COM_SetColorOperation.h" @@ -35,7 +36,7 @@ #include "COM_SocketProxyNode.h" -//#include "stdio.h" +//#include <stdio.h> #include "COM_defines.h" Node::Node(bNode *editorNode, bool create_sockets) @@ -86,11 +87,15 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) { if (this->isInActiveGroup()) { - PreviewOperation *operation = new PreviewOperation(); - system->addOperation(operation); - operation->setbNode(this->getbNode()); - operation->setbNodeTree(system->getContext().getbNodeTree()); - this->addLink(system, outputSocket, operation->getInputSocket(0)); + if (!(this->getbNode()->flag & NODE_HIDDEN)) { // do not calculate previews of hidden nodes. + if (this->getbNode()->flag & NODE_PREVIEW) { + PreviewOperation *operation = new PreviewOperation(); + system->addOperation(operation); + operation->setbNode(this->getbNode()); + operation->setbNodeTree(system->getContext().getbNodeTree()); + this->addLink(system, outputSocket, operation->getInputSocket(0)); + } + } } } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 12baa26cd6e..090b1455440 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -29,6 +29,7 @@ #include "COM_CompositorContext.h" #include "DNA_node_types.h" #include "BKE_text.h" +#include "COM_ExecutionSystem.h" #include <vector> #include <string> diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp index 42946d7315e..1a895cf93b1 100644 --- a/source/blender/compositor/intern/COM_NodeBase.cpp +++ b/source/blender/compositor/intern/COM_NodeBase.cpp @@ -20,10 +20,12 @@ * Monique Dewanchand */ +#include <string.h> + +#include "BKE_node.h" + #include "COM_NodeBase.h" -#include "string.h" #include "COM_NodeOperation.h" -#include "BKE_node.h" #include "COM_SetValueOperation.h" #include "COM_SetColorOperation.h" #include "COM_SocketConnection.h" @@ -81,12 +83,14 @@ const bool NodeBase::isInputNode() const return this->inputsockets.size() == 0; } -OutputSocket *NodeBase::getOutputSocket(int index) +OutputSocket *NodeBase::getOutputSocket(unsigned int index) { + BLI_assert(index < this->outputsockets.size()); return this->outputsockets[index]; } -InputSocket *NodeBase::getInputSocket(int index) +InputSocket *NodeBase::getInputSocket(unsigned int index) { + BLI_assert(index < this->inputsockets.size()); return this->inputsockets[index]; } diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index 5e3a4fa5531..54f80926b84 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -103,7 +103,7 @@ public: * @param index * the index of the needed outputsocket */ - OutputSocket *getOutputSocket(const int index); + OutputSocket *getOutputSocket(const unsigned int index); /** * get the reference to the first outputsocket @@ -117,7 +117,7 @@ public: * @param index * the index of the needed inputsocket */ - InputSocket *getInputSocket(const int index); + InputSocket *getInputSocket(const unsigned int index); virtual bool isStatic() const { return false; } diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index 114d9f44cef..33989fa5787 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -20,12 +20,13 @@ * Monique Dewanchand */ -#include "COM_NodeOperation.h" #include <typeinfo> +#include <stdio.h> + +#include "COM_NodeOperation.h" #include "COM_InputSocket.h" #include "COM_SocketConnection.h" #include "COM_defines.h" -#include "stdio.h" NodeOperation::NodeOperation() { @@ -139,116 +140,3 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper return false; } } - -cl_mem NodeOperation::COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) -{ - cl_int error; - MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); - - const cl_image_format imageFormat = { - CL_RGBA, - CL_FLOAT - }; - - cl_mem clBuffer = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), - result->getHeight(), 0, result->getBuffer(), &error); - - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - if (error == CL_SUCCESS) cleanup->push_back(clBuffer); - - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); - return clBuffer; -} - -void NodeOperation::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer) -{ - if (offsetIndex != -1) { - cl_int error; - rcti *rect = memoryBuffer->getRect(); - cl_int2 offset = {rect->xmin, rect->ymin}; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - } -} - -void NodeOperation::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex) -{ - if (offsetIndex != -1) { - cl_int error; - cl_int2 offset = {this->getWidth(), this->getHeight()}; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - } -} - -void NodeOperation::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer) -{ - cl_int error; - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } -} - -void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) { - cl_int error; - const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; - - error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } -} - -void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex) { - cl_int error; - const int width = outputMemoryBuffer->getWidth(); - const int height = outputMemoryBuffer->getHeight(); - int offsetx; - int offsety; - const int localSize = 32; - size_t size[2]; - cl_int2 offset; - - bool breaked = false; - for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { - offset[1] = offsety; - if (offsety + localSize < height) { - size[1] = localSize; - } - else { - size[1] = height - offsety; - } - for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { - if (offsetx + localSize < width) { - size[0] = localSize; - } - else { - size[0] = width - offsetx; - } - offset[0] = offsetx; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - clFlush(queue); - if (isBreaked()) { - breaked = false; - } - } - } -} - -cl_kernel NodeOperation::COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) -{ - cl_int error; - cl_kernel kernel = clCreateKernel(program, kernelname, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - else { - if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); - } - return kernel; - -} diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 30731572712..f96b994685a 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -22,9 +22,7 @@ #ifndef _COM_NodeOperation_h #define _COM_NodeOperation_h - -class NodeOperation; - +class OpenCLDevice; #include "COM_Node.h" #include <string> #include <sstream> @@ -150,7 +148,7 @@ public: * @param memoryBuffers all input MemoryBuffer's needed * @param outputBuffer the outputbuffer to write to */ - virtual void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, + virtual void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer) {} /** @@ -165,7 +163,7 @@ public: * @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution * @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution */ - virtual void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {} + virtual void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {} virtual void deinitExecution(); bool isResolutionSet() { @@ -272,15 +270,6 @@ protected: * @brief set if this NodeOperation can be scheduled on a OpenCLDevice */ void setOpenCL(bool openCL) { this->openCL = openCL; } - - static cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); - static void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); - static void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); - void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex); - static void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); - void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex); - cl_kernel COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp); - }; #endif diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index 9d005804098..c9d27b8543c 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -23,13 +23,15 @@ #include "COM_OpenCLDevice.h" #include "COM_WorkScheduler.h" +typedef enum COM_VendorID {NVIDIA=0x10DE, AMD=0x1002} COM_VendorID; -OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program) +OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId) { this->device = device; this->context = context; this->program = program; this->queue = NULL; + this->vendorID = vendorId; } bool OpenCLDevice::initialize() @@ -56,10 +58,126 @@ void OpenCLDevice::execute(WorkPackage *work) MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect); - executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this->context, this->program, this->queue, &rect, + executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this, &rect, chunkNumber, inputBuffers, outputBuffer); delete outputBuffer; executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); } + +cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) +{ + cl_int error; + MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); + + const cl_image_format imageFormat = { + CL_RGBA, + CL_FLOAT + }; + + cl_mem clBuffer = clCreateImage2D(this->context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), + result->getHeight(), 0, result->getBuffer(), &error); + + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + if (error == CL_SUCCESS) cleanup->push_back(clBuffer); + + error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + + COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); + return clBuffer; +} + +void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer) +{ + if (offsetIndex != -1) { + cl_int error; + rcti *rect = memoryBuffer->getRect(); + cl_int2 offset = {rect->xmin, rect->ymin}; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + } +} + +void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation) +{ + if (offsetIndex != -1) { + cl_int error; + cl_int2 offset = {operation->getWidth(), operation->getHeight()}; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + } +} + +void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer) +{ + cl_int error; + error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } +} + +void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) +{ + cl_int error; + const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; + + error = clEnqueueNDRangeKernel(this->queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } +} + +void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation* operation) +{ + cl_int error; + const int width = outputMemoryBuffer->getWidth(); + const int height = outputMemoryBuffer->getHeight(); + int offsetx; + int offsety; + int localSize = 1024; + size_t size[2]; + cl_int2 offset; + + if (this->vendorID == NVIDIA){localSize = 32;} + bool breaked = false; + for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { + offset[1] = offsety; + if (offsety + localSize < height) { + size[1] = localSize; + } + else { + size[1] = height - offsety; + } + for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { + if (offsetx + localSize < width) { + size[0] = localSize; + } + else { + size[0] = width - offsetx; + } + offset[0] = offsetx; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + error = clEnqueueNDRangeKernel(this->queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + clFlush(this->queue); + if (operation->isBreaked()) { + breaked = false; + } + } + } +} + +cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) +{ + cl_int error; + cl_kernel kernel = clCreateKernel(this->program, kernelname, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + else { + if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); + } + return kernel; + +} diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index 83ce8cec811..d132f330651 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -29,7 +29,6 @@ class OpenCLDevice; #include "OCL_opencl.h" #include "COM_WorkScheduler.h" - /** * @brief device representing an GPU OpenCL device. * an instance of this class represents a single cl_device @@ -55,13 +54,21 @@ private: * @brief opencl command queue */ cl_command_queue queue; + + /** + * @brief opencl vendor ID + */ + cl_int vendorID; + public: /** * @brief constructor with opencl device * @param context * @param device + * @param program + * @param vendorID */ - OpenCLDevice(cl_context context, cl_device_id device, cl_program program); + OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId); /** @@ -83,6 +90,18 @@ public: * @param work the WorkPackage to execute */ void execute(WorkPackage *work); + + cl_context getContext(){return this->context;} + + cl_command_queue getQueue(){return this->queue;} + + cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); + void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); + void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); + void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation); + void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); + void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation* operation); + cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp); }; #endif diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h index 18d83cc151c..fed87186d20 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.h +++ b/source/blender/compositor/intern/COM_WorkPackage.h @@ -24,7 +24,7 @@ class WorkPackage; #ifndef _COM_WorkPackage_h_ #define _COM_WorkPackage_h_ - +class ExecutionGroup; #include "COM_ExecutionGroup.h" /** diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index fb7a8f8a764..619c5bea71e 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -21,15 +21,18 @@ */ #include <list> +#include <stdio.h> + +#include "BKE_global.h" + #include "COM_WorkScheduler.h" -#include "PIL_time.h" -#include "BLI_threads.h" #include "COM_CPUDevice.h" #include "COM_OpenCLDevice.h" -#include "OCL_opencl.h" -#include "stdio.h" #include "COM_OpenCLKernels.cl.h" -#include "BKE_global.h" +#include "OCL_opencl.h" + +#include "PIL_time.h" +#include "BLI_threads.h" #if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD #warning COM_CURRENT_THREADING_MODEL COM_TM_NOTHREAD is activated. Use only for debugging. @@ -214,60 +217,46 @@ void WorkScheduler::initialize() cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms]; error = clGetPlatformIDs(numberOfPlatforms, platforms, 0); unsigned int indexPlatform; - cl_uint totalNumberOfDevices = 0; for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices; + cl_uint numberOfDevices = 0; clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - totalNumberOfDevices += numberOfDevices; - } + if (numberOfDevices>0) { + cl_device_id *cldevices = new cl_device_id[numberOfDevices]; + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0); - cl_device_id *cldevices = new cl_device_id[totalNumberOfDevices]; - unsigned int numberOfDevicesReceived = 0; - for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { - cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices; - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices + numberOfDevicesReceived * sizeof (cl_device_id), 0); - numberOfDevicesReceived += numberOfDevices; - } - if (totalNumberOfDevices > 0) { - context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); - error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0); - if (error != CL_SUCCESS) { - cl_int error2; - size_t ret_val_size = 0; - printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - char *build_log = new char[ret_val_size + 1]; - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - build_log[ret_val_size] = '\0'; - printf("%s", build_log); - delete build_log; - - } - else { - unsigned int indexDevices; - for (indexDevices = 0; indexDevices < totalNumberOfDevices; indexDevices++) { - cl_device_id device = cldevices[indexDevices]; - OpenCLDevice *clDevice = new OpenCLDevice(context, device, program); - clDevice->initialize(), - gpudevices.push_back(clDevice); - if (G.f & G_DEBUG) { - char resultString[32]; - error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0); - printf("OPENCL_DEVICE: %s, ", resultString); - error = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 32, resultString, 0); - printf("%s\n", resultString); + context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); + error = clBuildProgram(program, numberOfDevices, cldevices, 0, 0, 0); + if (error != CL_SUCCESS) { + cl_int error2; + size_t ret_val_size = 0; + printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); + error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + char *build_log = new char[ret_val_size + 1]; + error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + build_log[ret_val_size] = '\0'; + printf("%s", build_log); + delete build_log; + } + else { + unsigned int indexDevices; + for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) { + cl_device_id device = cldevices[indexDevices]; + cl_int vendorID = 0; + cl_int error = clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL); + if (error!= CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + OpenCLDevice *clDevice = new OpenCLDevice(context, device, program, vendorID); + clDevice->initialize(); + gpudevices.push_back(clDevice); } } + delete cldevices; } } - delete[] cldevices; delete[] platforms; } #endif diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 2bbfd18e7c5..bec9ff95eed 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -25,6 +25,8 @@ extern "C" { #include "BLI_threads.h" } +#include "BKE_main.h" +#include "BKE_global.h" #include "COM_compositor.h" #include "COM_ExecutionSystem.h" @@ -32,7 +34,7 @@ extern "C" { #include "OCL_opencl.h" static ThreadMutex *compositorMutex; -void COM_execute(bNodeTree *editingtree, int rendering) +void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) { if (compositorMutex == NULL) { /// TODO: move to blender startup phase compositorMutex = new ThreadMutex(); @@ -41,7 +43,7 @@ void COM_execute(bNodeTree *editingtree, int rendering) WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere } BLI_mutex_lock(compositorMutex); - if (editingtree->test_break && editingtree->test_break(editingtree->tbh)) { + 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); @@ -49,11 +51,12 @@ void COM_execute(bNodeTree *editingtree, int rendering) } + /* set progress bar to 0% and status to init compositing*/ editingtree->progress(editingtree->prh, 0.0); /* initialize execution system */ - ExecutionSystem *system = new ExecutionSystem(editingtree, rendering); + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering); system->execute(); delete system; diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp index 296056b6c48..59ec9525fa6 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp @@ -37,24 +37,24 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode) void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - Object *camob = context->getScene()->camera; +// Object *camob = context->getScene()->camera; - if (this->getInputSocket(2)->isConnected()) { - VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); - ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); - converter->setfStop(this->getbNode()->custom3); - converter->setCameraObject(camob); - operation->setMaxBlur((int)this->getbNode()->custom4); - operation->setQuality(context->getQuality()); - this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); - this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph); - addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2)); - graph->addOperation(operation); - graph->addOperation(converter); - this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - } - else { +// if (this->getInputSocket(2)->isConnected()) { +// VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); +// ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); +// converter->setfStop(this->getbNode()->custom3); +// converter->setCameraObject(camob); +// operation->setMaxBlur((int)this->getbNode()->custom4); +// operation->setQuality(context->getQuality()); +// this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); +// this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); +// this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph); +// addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2)); +// graph->addOperation(operation); +// graph->addOperation(converter); +// this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); +// } +// else { BokehBlurOperation *operation = new BokehBlurOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); @@ -63,5 +63,5 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex operation->setQuality(context->getQuality()); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - } +// } } diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index fccb92ddd8b..6a6f2d1b4ff 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -35,7 +35,7 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte InputSocket *alphaSocket = this->getInputSocket(1); if (imageSocket->isConnected()) { CompositorOperation *colourAlphaProg = new CompositorOperation(); - colourAlphaProg->setScene(context->getScene()); + colourAlphaProg->setRenderData(context->getRenderData()); colourAlphaProg->setbNodeTree(context->getbNodeTree()); imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0)); alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1)); diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index d1f90b490ad..461505871c6 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -91,11 +91,16 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext graph->addOperation(bokeh); VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); - operation->setQuality(context->getQuality()); + if (data->preview) { + operation->setQuality(COM_QUALITY_LOW); + } else { + operation->setQuality(context->getQuality()); + } operation->setMaxBlur(data->maxblur); operation->setThreshold(data->bthresh); addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); + addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3)); if (data->gamco) { GammaCorrectOperation *correct = new GammaCorrectOperation(); GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index 6ee5b2a2b0d..285bfa0470e 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -25,6 +25,8 @@ #include "COM_ExecutionSystem.h" #include "COM_DilateErodeOperation.h" #include "COM_AntiAliasOperation.h" +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" #include "BLI_math.h" DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode) @@ -70,6 +72,58 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont graph->addOperation(operation); } } + else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_FEATHER) { + /* this uses a modified gaussian blur function otherwise its far too slow */ + CompositorQuality quality = context->getQuality(); + + /* initialize node data */ + NodeBlurData *data = (NodeBlurData *)&this->alpha_blur; + memset(data, 0, sizeof(*data)); + data->filtertype = R_FILTER_GAUSS; + + if (editorNode->custom2 > 0) { + data->sizex = data->sizey = editorNode->custom2; + } + else { + data->sizex = data->sizey = -editorNode->custom2; + + } + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); + // this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); // no size input yet + graph->addOperation(operationx); + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); + graph->addOperation(operationy); + addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); + // addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); // no size input yet + addPreviewOperation(graph, operationy->getOutputSocket()); + + /* TODO? */ + /* see gaussian blue node for original usage */ +#if 0 + if (!connectedSizeSocket) { + operationx->setSize(size); + operationy->setSize(size); + } +#else + operationx->setSize(1.0f); + operationy->setSize(1.0f); +#endif + operationx->setSubtract(editorNode->custom2 < 0); + operationy->setSubtract(editorNode->custom2 < 0); + + if (editorNode->storage) { + NodeDilateErode *data = (NodeDilateErode *)editorNode->storage; + operationx->setFalloff(data->falloff); + operationy->setFalloff(data->falloff); + } + } else { if (editorNode->custom2 > 0) { DilateStepOperation *operation = new DilateStepOperation(); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h index fa4e368e00d..ac374d7375b 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.h +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h @@ -30,6 +30,7 @@ * @ingroup Node */ class DilateErodeNode : public Node { + NodeBlurData alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ public: DilateErodeNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp index e5255b6bb87..6ad58caf17b 100644 --- a/source/blender/compositor/nodes/COM_GroupNode.cpp +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -37,6 +37,7 @@ void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c void GroupNode::ungroup(ExecutionSystem &system) { bNode *bnode = this->getbNode(); + bNodeTree *subtree = (bNodeTree *)bnode->id; vector<InputSocket *> &inputsockets = this->getInputSockets(); vector<OutputSocket *> &outputsockets = this->getOutputSockets(); unsigned int index; @@ -44,6 +45,10 @@ void GroupNode::ungroup(ExecutionSystem &system) /* get the node list size _before_ adding proxy nodes, so they are available for linking */ int nodes_start = system.getNodes().size(); + /* missing node group datablock can happen with library linking */ + if (!subtree) + return; + for (index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; bNodeSocket *editorInput = inputSocket->getbNodeSocket(); @@ -64,6 +69,5 @@ void GroupNode::ungroup(ExecutionSystem &system) } } - bNodeTree *subtree = (bNodeTree *)bnode->id; ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, bnode); } diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp index 6057a7f0e6c..df125403f98 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp @@ -46,27 +46,25 @@ void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, bNode *editorsnode = getbNode(); CurveMapping *storage = (CurveMapping *)editorsnode->storage; - if (colourSocket->isConnected() && outputSocket->isConnected()) { - ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); - ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); - HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); - MixBlendOperation *blend = new MixBlendOperation(); - - colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); - addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); - addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); - addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); - addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); - valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph); - outputSocket->relinkConnections(blend->getOutputSocket()); - - changeHSV->setCurveMapping(storage); - - blend->setResolutionInputSocketIndex(1); - - graph->addOperation(rgbToHSV); - graph->addOperation(hsvToRGB); - graph->addOperation(changeHSV); - graph->addOperation(blend); - } + ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); + ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); + HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); + MixBlendOperation *blend = new MixBlendOperation(); + + colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); + addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); + valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph); + outputSocket->relinkConnections(blend->getOutputSocket()); + + changeHSV->setCurveMapping(storage); + + blend->setResolutionInputSocketIndex(1); + + graph->addOperation(rgbToHSV); + graph->addOperation(hsvToRGB); + graph->addOperation(changeHSV); + graph->addOperation(blend); } diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp index 4005e5d2900..31d2ccb391e 100644 --- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp +++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp @@ -38,7 +38,7 @@ void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * operation->setObjectIndex(bnode->custom1); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - if (bnode->custom2 == 0 || context->getScene()->r.scemode & R_FULL_SAMPLE) { + if (bnode->custom2 == 0 || context->getRenderData()->scemode & R_FULL_SAMPLE) { this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); } else { diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp index 03034e34eb7..0319e66ee22 100644 --- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp @@ -39,7 +39,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); operation->setData(data); @@ -50,8 +50,8 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]); - operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); operation->setData(data); diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index ed07e41a649..13037b61a56 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -36,7 +36,7 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - const RenderData *data = &context->getScene()->r; + const RenderData *data = context->getRenderData(); OutputSocket *outputMask = this->getOutputSocket(0); @@ -55,7 +55,8 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setMask(mask); operation->setFramenumber(context->getFramenumber()); - operation->setSmooth((bool)editorNode->custom1); + operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0); + operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp index ccf7721b989..f52b7216cca 100644 --- a/source/blender/compositor/nodes/COM_MuteNode.cpp +++ b/source/blender/compositor/nodes/COM_MuteNode.cpp @@ -20,9 +20,10 @@ * Monique Dewanchand */ +#include <stdio.h> + #include "COM_MuteNode.h" #include "COM_SocketConnection.h" -#include "stdio.h" #include "COM_SetValueOperation.h" #include "COM_SetVectorOperation.h" #include "COM_SetColorOperation.h" diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp index 402529b9186..e85f521def0 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -37,15 +37,17 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage; if (!context->isRendering()) { - /* XXX TODO as in previous implementation? - * add dummy operations and exit, to prevent file writing on each compo update. + /* only output files when rendering a sequence - + * otherwise, it overwrites the output files just + * scrubbing through the timeline when the compositor updates. */ + return; } if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) { /* single output operation for the multilayer file */ OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation( - context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); + context->getRenderData(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); int num_inputs = getNumberOfInputSockets(); bool hasConnections = false; @@ -78,7 +80,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path); OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation( - context->getScene(), context->getbNodeTree(), input->getDataType(), format, path); + context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path); input->relinkConnections(outputOperation->getInputSocket(0)); graph->addOperation(outputOperation); if (!previewAdded) { diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp index 17b521c589d..95b048b6cad 100644 --- a/source/blender/compositor/nodes/COM_ScaleNode.cpp +++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp @@ -52,7 +52,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; case CMP_SCALE_SCENEPERCENT: { SetValueOperation *scaleFactorOperation = new SetValueOperation(); - scaleFactorOperation->setValue(context->getScene()->r.size / 100.0f); + scaleFactorOperation->setValue(context->getRenderData()->size / 100.0f); ScaleOperation *operation = new ScaleOperation(); inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1)); @@ -64,7 +64,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; case CMP_SCALE_RENDERPERCENT: { - const RenderData *data = &context->getScene()->r; + const RenderData *data = context->getRenderData(); ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation(); /* framing options */ diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp index 22a00410384..388466cee3c 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -39,8 +39,8 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont ImageUser *imageUser = (ImageUser *) this->getbNode()->storage; if (image1Socket->isConnected() && image2Socket->isConnected()) { SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); - splitViewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); - splitViewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + splitViewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); + splitViewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); splitViewerOperation->setImage(image); splitViewerOperation->setImageUser(imageUser); splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp index a3526e3c1a1..b035e0a392c 100644 --- a/source/blender/compositor/nodes/COM_TextureNode.cpp +++ b/source/blender/compositor/nodes/COM_TextureNode.cpp @@ -38,7 +38,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system); operation->setTexture(texture); - operation->setScene(context->getScene()); + operation->setRenderData(context->getRenderData()); system->addOperation(operation); addPreviewOperation(system, operation->getOutputSocket()); @@ -48,7 +48,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0)); addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1)); alphaOperation->setTexture(texture); - alphaOperation->setScene(context->getScene()); + alphaOperation->setRenderData(context->getRenderData()); system->addOperation(alphaOperation); } } diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index 9228fdbef85..1205767cb28 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -40,8 +40,8 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * bNode *editorNode = this->getbNode(); if (imageSocket->isConnected()) { ViewerOperation *viewerOperation = new ViewerOperation(); - viewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); - viewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + viewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); + viewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); viewerOperation->setbNodeTree(context->getbNodeTree()); viewerOperation->setImage(image); viewerOperation->setImageUser(imageUser); diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index bb915fec590..df64b7c8ddc 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -27,11 +27,11 @@ extern "C" { #include "RE_pipeline.h" } -BlurBaseOperation::BlurBaseOperation() : NodeOperation() +BlurBaseOperation::BlurBaseOperation(DataType data_type=COM_DT_COLOR) : NodeOperation() { - this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(data_type); this->addInputSocket(COM_DT_VALUE); - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(data_type); this->setComplex(true); this->inputProgram = NULL; this->data = NULL; @@ -89,6 +89,46 @@ float *BlurBaseOperation::make_gausstab(int rad) return gausstab; } +/* normalized distance from the current (inverted so 1.0 is close and 0.0 is far) + * 'ease' is applied after, looks nicer */ +float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff) +{ + float *dist_fac_invert, val; + int i, n; + + n = 2 * rad + 1; + + dist_fac_invert = new float[n]; + + for (i = -rad; i <= rad; i++) { + val = 1.0f - fabsf(((float)i / (float)rad)); + + /* keep in sync with proportional_falloff_curve_only_items */ + switch (falloff) { + case PROP_SMOOTH: + /* ease - gives less hard lines for dilate/erode feather */ + val = (3.0f * val * val - 2.0f * val * val * val); + break; + case PROP_SPHERE: + val = sqrtf(2.0f * val - val * val); + break; + case PROP_ROOT: + val = sqrtf(val); + break; + case PROP_SHARP: + val = val * val; + break; + case PROP_LIN: + default: + /* nothing */ + break; + } + dist_fac_invert[i + rad] = val; + } + + return dist_fac_invert; +} + void BlurBaseOperation::deinitExecution() { this->inputProgram = NULL; diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h index 84fc243a5af..8f7208274db 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.h +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h @@ -35,8 +35,9 @@ protected: SocketReader *inputProgram; SocketReader *inputSize; NodeBlurData *data; - BlurBaseOperation(); + BlurBaseOperation(DataType data_type); float *make_gausstab(int rad); + float *make_dist_fac_inverse(int rad, int falloff); float size; bool deleteData; bool sizeavailable; diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index dca087bb587..9fe5abcb075 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -22,6 +22,7 @@ #include "COM_BokehBlurOperation.h" #include "BLI_math.h" +#include "COM_OpenCLDevice.h" extern "C" { #include "RE_pipeline.h" @@ -73,13 +74,13 @@ void BokehBlurOperation::initExecution() void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; + float color_accum[4]; float tempBoundingBox[4]; float bokeh[4]; inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); if (tempBoundingBox[0] > 0.0f) { - float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -96,7 +97,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - zero_v4(tempColor); + zero_v4(color_accum); int step = getStep(); int offsetadd = getOffsetAdd(); @@ -108,15 +109,15 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * float u = this->bokehMidX - (nx - x) * m; float v = this->bokehMidY - (ny - y) * m; inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(tempColor, bokeh, &buffer[bufferindex]); - add_v4_v4(overallmultiplyer, bokeh); + madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); + add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; } } - color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]); - color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]); - color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]); - color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]); + color[0] = color_accum[0] * (1.0f / multiplier_accum[0]); + color[1] = color_accum[1] * (1.0f / multiplier_accum[1]); + color[2] = color_accum[2] * (1.0f / multiplier_accum[2]); + color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); @@ -160,25 +161,25 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe } static cl_kernel kernel = 0; -void BokehBlurOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!kernel) { - kernel = COM_clCreateKernel(program, "bokehBlurKernel", NULL); + kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); } cl_int radius = this->getWidth() * this->size / 100.0f; cl_int step = this->getStep(); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBokehProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBokehProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); clSetKernelArg(kernel, 6, sizeof(cl_int), &radius); clSetKernelArg(kernel, 7, sizeof(cl_int), &step); - COM_clAttachSizeToKernelParameter(kernel, 8); + device->COM_clAttachSizeToKernelParameter(kernel, 8, this); - COM_clEnqueueRange(queue, kernel, outputMemoryBuffer, 9); + device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this); } diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h index 3ec61c5ce01..853855d5c34 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h @@ -57,6 +57,6 @@ public: void setSize(float size) { this->size = size; } - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); }; #endif diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp index 3f9003b8c48..fe6be55e237 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp @@ -88,7 +88,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; - float sum; + float sum = 0.0f; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { pixels++; @@ -97,7 +97,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) { case 1: { - sum += buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f; + sum += rgb_to_bw(&buffer[offset]); break; } case 2: diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp index b0739cd7567..811975c5e13 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp @@ -46,7 +46,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; - float sum; + float sum = 0.0f; float mean = this->result; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { @@ -56,7 +56,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory { case 1: { - float value = buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f; + float value = rgb_to_bw(&buffer[offset]); sum += (value - mean) * (value - mean); break; } diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp index dff8ccf7e73..fb4e6f03e76 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp @@ -21,7 +21,7 @@ */ #include "COM_CombineChannelsOperation.h" -#include <stdio.h> +#include "BLI_utildefines.h" CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() { @@ -36,6 +36,31 @@ CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() this->inputChannel3Operation = NULL; this->inputChannel4Operation = NULL; } + +bool CombineChannelsOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti tempOutput; + bool first = true; + for (int i = 0 ; i < 4 ; i ++) { + NodeOperation * inputOperation = this->getInputOperation(i); + if (inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { + if (first) { + output->xmin = tempOutput.xmin; + output->ymin = tempOutput.ymin; + output->xmax = tempOutput.xmax; + output->ymax = tempOutput.ymax; + first = false; + } else { + output->xmin = MIN2(output->xmin, tempOutput.xmin); + output->ymin = MIN2(output->ymin, tempOutput.ymin); + output->xmax = MAX2(output->xmax, tempOutput.xmax); + output->ymax = MAX2(output->ymax, tempOutput.ymax); + } + } + } + return !first; +} + void CombineChannelsOperation::initExecution() { this->inputChannel1Operation = this->getInputSocketReader(0); diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h index d2977155e14..cc71f44b4f5 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.h +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h @@ -37,6 +37,8 @@ public: void initExecution(); void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 2b1a804b432..936cbaadd84 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -41,7 +41,7 @@ CompositorOperation::CompositorOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); - this->setScene(NULL); + this->setRenderData(NULL); this->outputBuffer = NULL; this->imageInput = NULL; this->alphaInput = NULL; @@ -60,11 +60,11 @@ void CompositorOperation::initExecution() void CompositorOperation::deinitExecution() { if (!isBreaked()) { - const Scene *scene = this->scene; - Render *re = RE_GetRender(scene->id.name); + const RenderData *rd = this->rd; + Render *re = RE_GetRender_FromData(rd); RenderResult *rr = RE_AcquireResultWrite(re); if (rr) { - if (rr->rectf != NULL) { + if (rr->rectf != NULL) { MEM_freeN(rr->rectf); } rr->rectf = outputBuffer; @@ -127,12 +127,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - int width = this->scene->r.xsch * this->scene->r.size / 100; - int height = this->scene->r.ysch * this->scene->r.size / 100; + int width = this->rd->xsch * this->rd->size / 100; + int height = this->rd->ysch * this->rd->size / 100; // check actual render resolution with cropping it may differ with cropped border.rendering // FIX for: [31777] Border Crop gives black (easy) - Render *re = RE_GetRender(this->scene->id.name); + Render *re = RE_GetRender_FromData(this->rd); if (re) { RenderResult *rr = RE_AcquireResultRead(re); if (rr) { diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index 0129c953946..280f39b7729 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -34,7 +34,7 @@ private: /** * @brief local reference to the scene */ - const Scene *scene; + const RenderData *rd; /** * @brief reference to the output float buffer @@ -53,7 +53,7 @@ private: public: CompositorOperation(); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); - void setScene(const Scene *scene) { this->scene = scene; } + void setRenderData(const RenderData *rd) { this->rd = rd; } bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp index c66cb8df9be..0e2c1e29a1d 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp @@ -38,7 +38,7 @@ void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float { float inputColor[4]; inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); - outputValue[0] = inputColor[0] * 0.35f + inputColor[1] * 0.45f + inputColor[2] * 0.2f; + outputValue[0] = rgb_to_bw(inputColor); } void ConvertColorToBWOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 306a2d96985..80d1c6444eb 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -22,6 +22,7 @@ #include "COM_DilateErodeOperation.h" #include "BLI_math.h" +#include "COM_OpenCLDevice.h" // DilateErode Distance Threshold DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() @@ -234,24 +235,24 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, Read } static cl_kernel dilateKernel = 0; -void DilateDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void DilateDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!dilateKernel) { - dilateKernel = COM_clCreateKernel(program, "dilateKernel", NULL); + dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); } cl_int distanceSquared = this->distance * this->distance; cl_int scope = this->scope; - COM_clAttachMemoryBufferToKernelParameter(context, dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope); clSetKernelArg(dilateKernel, 5, sizeof(cl_int), &distanceSquared); - COM_clAttachSizeToKernelParameter(dilateKernel, 6); - COM_clEnqueueRange(queue, dilateKernel, outputMemoryBuffer, 7); + device->COM_clAttachSizeToKernelParameter(dilateKernel, 6, this); + device->COM_clEnqueueRange(dilateKernel, outputMemoryBuffer, 7, this); } // Erode Distance @@ -293,24 +294,24 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff } static cl_kernel erodeKernel = 0; -void ErodeDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void ErodeDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!erodeKernel) { - erodeKernel = COM_clCreateKernel(program, "erodeKernel", NULL); + erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); } cl_int distanceSquared = this->distance * this->distance; cl_int scope = this->scope; - COM_clAttachMemoryBufferToKernelParameter(context, erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope); clSetKernelArg(erodeKernel, 5, sizeof(cl_int), &distanceSquared); - COM_clAttachSizeToKernelParameter(erodeKernel, 6); - COM_clEnqueueRange(queue, erodeKernel, outputMemoryBuffer, 7); + device->COM_clAttachSizeToKernelParameter(erodeKernel, 6, this); + device->COM_clEnqueueRange(erodeKernel, outputMemoryBuffer, 7, this); } // Dilate step diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h index b11356129b4..4d0bf9de0ec 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.h +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h @@ -99,7 +99,7 @@ public: void setDistance(float distance) { this->distance = distance; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); @@ -113,7 +113,7 @@ public: */ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index ba54c8ad9d6..8344a4d248b 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1216,7 +1216,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float gsz = rsize[2]; // by the do_*EdgeDetection() function. fsz = gsz + isz + osz; // calculate size of pixel index buffer needed - gbuf = (unsigned short *)MEM_callocN(sizeof (unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer + gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer do_createEdgeLocationBuffer(t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz); do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset); diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 7830eef829c..7491b0f30dd 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -20,11 +20,13 @@ * Monique Dewanchand */ +#include <limits.h> + #include "COM_FastGaussianBlurOperation.h" #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" -FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation() +FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->iirgaus = NULL; } @@ -74,7 +76,7 @@ void FastGaussianBlurOperation::deinitExecution() delete this->iirgaus; this->iirgaus = NULL; } - BlurBaseOperation::deinitMutex(); + BlurBaseOperation::deinitMutex(); } void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -84,7 +86,7 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **m MemoryBuffer *newBuf = (MemoryBuffer *)this->inputProgram->initializeTileData(rect, memoryBuffers); MemoryBuffer *copy = newBuf->duplicate(); updateSize(memoryBuffers); - + int c; sx = data->sizex * this->size / 2.0f; sy = data->sizey * this->size / 2.0f; @@ -109,11 +111,14 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **m return iirgaus; } -void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int chan, int xy) +void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy) { double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3]; double *X, *Y, *W; - int i, x, y, sz; + const unsigned int src_width = src->getWidth(); + const unsigned int src_height = src->getHeight(); + unsigned int x, y, sz; + unsigned int i; float *buffer = src->getBuffer(); // <0.5 not valid, though can have a possibly useful sort of sharpening effect @@ -123,8 +128,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels, // so just skiping blur along faulty direction if src's def is below that limit! - if (src->getWidth() < 3) xy &= ~(int) 1; - if (src->getHeight() < 3) xy &= ~(int) 2; + if (src_width < 3) xy &= ~(int) 1; + if (src_height < 3) xy &= ~(int) 2; if (xy < 1) return; // see "Recursive Gabor Filtering" by Young/VanVliet @@ -178,33 +183,34 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \ Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \ Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \ - for (i = L - 4; i >= 0; i--) { \ + /* 'i != UINT_MAX' is really 'i >= 0', but necessary for unsigned int wrapping */ \ + for (i = L - 4; i != UINT_MAX; i--) { \ Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \ } \ } (void)0 // intermediate buffers - sz = MAX2(src->getWidth(), src->getHeight()); + sz = MAX2(src_width, src_height); X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); if (xy & 1) { // H - for (y = 0; y < src->getHeight(); ++y) { - const int yx = y * src->getWidth(); - for (x = 0; x < src->getWidth(); ++x) + for (y = 0; y < src_height; ++y) { + const int yx = y * src_width; + for (x = 0; x < src_width; ++x) X[x] = buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan]; - YVV(src->getWidth()); - for (x = 0; x < src->getWidth(); ++x) + YVV(src_width); + for (x = 0; x < src_width; ++x) buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan] = Y[x]; } } if (xy & 2) { // V - for (x = 0; x < src->getWidth(); ++x) { - for (y = 0; y < src->getHeight(); ++y) - X[y] = buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan]; - YVV(src->getHeight()); - for (y = 0; y < src->getHeight(); ++y) - buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan] = Y[y]; + for (x = 0; x < src_width; ++x) { + for (y = 0; y < src_height; ++y) + X[y] = buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan]; + YVV(src_height); + for (y = 0; y < src_height; ++y) + buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan] = Y[y]; } } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index f92e3dc68a5..0f3929f052c 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -36,7 +36,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); - static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy); + static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); void deinitExecution(); void initExecution(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp new file mode 100644 index 00000000000..954aef7b916 --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -0,0 +1,190 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#include "COM_GaussianAlphaXBlurOperation.h" +#include "BLI_math.h" + +extern "C" { + #include "RE_pipeline.h" +} + +GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE) +{ + this->gausstab = NULL; + this->rad = 0; +} + +void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + if (!this->sizeavailable) { + updateGauss(memoryBuffers); + } + void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + return buffer; +} + +void GaussianAlphaXBlurOperation::initExecution() +{ + /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ + + if (this->sizeavailable) { + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +{ + if (this->gausstab == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + } + + if (this->distbuf_inv == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +BLI_INLINE float finv_test(const float f, const bool test) +{ + return (LIKELY(test == false)) ? f : 1.0f - f; +} + +void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + const bool do_invert = this->do_subtract; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; + float *buffer = inputBuffer->getBuffer(); + int bufferwidth = inputBuffer->getWidth(); + int bufferstartx = inputBuffer->getRect()->xmin; + int bufferstarty = inputBuffer->getRect()->ymin; + + int miny = y; + int maxy = y; + int minx = x - this->rad; + int maxx = x + this->rad; + miny = max(miny, inputBuffer->getRect()->ymin); + minx = max(minx, inputBuffer->getRect()->xmin); + maxy = min(maxy, inputBuffer->getRect()->ymax); + maxx = min(maxx, inputBuffer->getRect()->xmax); + + /* *** this is the main part which is different to 'GaussianXBlurOperation' *** */ + int step = getStep(); + int offsetadd = getOffsetAdd(); + int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); + + /* gauss */ + float alpha_accum = 0.0f; + float multiplier_accum = 0.0f; + + /* dilate */ + float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ + float distfacinv_max = 1.0f; /* 0 to 1 */ + + for (int nx = minx; nx < maxx; nx += step) { + const int index = (nx - x) + this->rad; + float value = finv_test(buffer[bufferindex], do_invert); + float multiplier; + + /* gauss */ + { + multiplier = gausstab[index]; + alpha_accum += value * multiplier; + multiplier_accum += multiplier; + } + + /* dilate - find most extreme color */ + if (value > value_max) { + multiplier = distbuf_inv[index]; + value *= multiplier; + if (value > value_max) { + value_max = value; + distfacinv_max = multiplier; + } + } + bufferindex += offsetadd; + } + + /* blend between the max value and gauss blue - gives nice feather */ + const float value_blur = alpha_accum / multiplier_accum; + const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max)); + color[0] = finv_test(value_final, do_invert); +} + +void GaussianAlphaXBlurOperation::deinitExecution() +{ + BlurBaseOperation::deinitExecution(); + delete [] this->gausstab; + this->gausstab = NULL; + delete [] this->distbuf_inv; + this->distbuf_inv = NULL; +} + +bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; +#if 0 /* until we add size input */ + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } + else +#endif + { + if (this->sizeavailable && this->gausstab != NULL) { + newInput.xmax = input->xmax + rad; + newInput.xmin = input->xmin - rad; + newInput.ymax = input->ymax; + newInput.ymin = input->ymin; + } + else { + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + } + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + } +} diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h new file mode 100644 index 00000000000..38817ebef1d --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h @@ -0,0 +1,64 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#ifndef _COM_GaussianAlphaXBlurOperation_h +#define _COM_GaussianAlphaXBlurOperation_h +#include "COM_NodeOperation.h" +#include "COM_BlurBaseOperation.h" + +class GaussianAlphaXBlurOperation : public BlurBaseOperation { +private: + float *gausstab; + float *distbuf_inv; + int falloff; /* falloff for distbuf_inv */ + bool do_subtract; + int rad; + void updateGauss(MemoryBuffer **memoryBuffers); +public: + GaussianAlphaXBlurOperation(); + + /** + * @brief the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * @brief initialize the execution + */ + void initExecution(); + + /** + * @brief Deinitialize the execution + */ + void deinitExecution(); + + void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + + /** + * Set subtract for Dilate/Erode functionality + */ + void setSubtract(bool subtract) { this->do_subtract = subtract; } + void setFalloff(int falloff) { this->falloff = falloff; } +}; +#endif diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp new file mode 100644 index 00000000000..e1105cf94b1 --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -0,0 +1,190 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#include "COM_GaussianAlphaYBlurOperation.h" +#include "BLI_math.h" + +extern "C" { + #include "RE_pipeline.h" +} + +GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE) +{ + this->gausstab = NULL; + this->rad = 0; +} + +void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + if (!this->sizeavailable) { + updateGauss(memoryBuffers); + } + void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + return buffer; +} + +void GaussianAlphaYBlurOperation::initExecution() +{ + /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ + + if (this->sizeavailable) { + float rad = size * this->data->sizey; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +{ + if (this->gausstab == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizey; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + } + + if (this->distbuf_inv == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +BLI_INLINE float finv_test(const float f, const bool test) +{ + return (LIKELY(test == false)) ? f : 1.0f - f; +} + +void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + const bool do_invert = this->do_subtract; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; + float *buffer = inputBuffer->getBuffer(); + int bufferwidth = inputBuffer->getWidth(); + int bufferstartx = inputBuffer->getRect()->xmin; + int bufferstarty = inputBuffer->getRect()->ymin; + + int miny = y - this->rad; + int maxy = y + this->rad; + int minx = x; + int maxx = x; + miny = max(miny, inputBuffer->getRect()->ymin); + minx = max(minx, inputBuffer->getRect()->xmin); + maxy = min(maxy, inputBuffer->getRect()->ymax); + maxx = min(maxx, inputBuffer->getRect()->xmax); + + /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */ + int step = getStep(); + + /* gauss */ + float alpha_accum = 0.0f; + float multiplier_accum = 0.0f; + + /* dilate */ + float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ + float distfacinv_max = 1.0f; /* 0 to 1 */ + + for (int ny = miny; ny < maxy; ny += step) { + int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); + + const int index = (ny - y) + this->rad; + float value = finv_test(buffer[bufferindex], do_invert); + float multiplier; + + /* gauss */ + { + multiplier = gausstab[index]; + alpha_accum += value * multiplier; + multiplier_accum += multiplier; + } + + /* dilate - find most extreme color */ + if (value > value_max) { + multiplier = distbuf_inv[index]; + value *= multiplier; + if (value > value_max) { + value_max = value; + distfacinv_max = multiplier; + } + } + + } + + /* blend between the max value and gauss blue - gives nice feather */ + const float value_blur = alpha_accum / multiplier_accum; + const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max)); + color[0] = finv_test(value_final, do_invert); +} + +void GaussianAlphaYBlurOperation::deinitExecution() +{ + BlurBaseOperation::deinitExecution(); + delete [] this->gausstab; + this->gausstab = NULL; + delete [] this->distbuf_inv; + this->distbuf_inv = NULL; +} + +bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; +#if 0 /* until we add size input */ + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } + else +#endif + { + if (this->sizeavailable && this->gausstab != NULL) { + newInput.xmax = input->xmax; + newInput.xmin = input->xmin; + newInput.ymax = input->ymax + rad; + newInput.ymin = input->ymin - rad; + } + else { + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + } + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + } +} diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h new file mode 100644 index 00000000000..67166be8241 --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h @@ -0,0 +1,64 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#ifndef _COM_GaussianAlphaYBlurOperation_h +#define _COM_GaussianAlphaYBlurOperation_h +#include "COM_NodeOperation.h" +#include "COM_BlurBaseOperation.h" + +class GaussianAlphaYBlurOperation : public BlurBaseOperation { +private: + float *gausstab; + float *distbuf_inv; + bool do_subtract; + int falloff; + int rad; + void updateGauss(MemoryBuffer **memoryBuffers); +public: + GaussianAlphaYBlurOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * @brief initialize the execution + */ + void initExecution(); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + + /** + * Set subtract for Dilate/Erode functionality + */ + void setSubtract(bool subtract) { this->do_subtract = subtract; } + void setFalloff(int falloff) { this->falloff = falloff; } +}; +#endif diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index b38ed28cd6a..dc9e354b124 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "RE_pipeline.h" } -GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation() +GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->gausstab = NULL; } @@ -115,7 +115,7 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory tempColor[1] = 0; tempColor[2] = 0; tempColor[3] = 0; - float overallmultiplyer = 0; + float multiplier_accum = 0; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -138,15 +138,15 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx); int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - const float multiplyer = gausstab[index]; - madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer); - overallmultiplyer += multiplyer; + const float multiplier = gausstab[index]; + madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; index += step; bufferindex += offsetadd; } } - mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); + mul_v4_v4fl(color, tempColor, 1.0f / multiplier_accum); } void GaussianBokehBlurOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 09a2a70ead3..7a1964a4a63 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "RE_pipeline.h" } -GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation() +GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->gausstab = NULL; this->rad = 0; @@ -72,12 +72,8 @@ void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; - tempColor[0] = 0; - tempColor[1] = 0; - tempColor[2] = 0; - tempColor[3] = 0; - float overallmultiplyer = 0.0f; + float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float multiplier_accum = 0.0f; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -99,12 +95,12 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { index = (nx - x) + this->rad; - const float multiplyer = gausstab[index]; - madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer); - overallmultiplyer += multiplyer; + const float multiplier = gausstab[index]; + madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; bufferindex += offsetadd; } - mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); + mul_v4_v4fl(color, color_accum, 1.0f / multiplier_accum); } void GaussianXBlurOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index ace817194f3..06c1c78d85a 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "RE_pipeline.h" } -GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation() +GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->gausstab = NULL; this->rad = 0; @@ -69,12 +69,8 @@ void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; - tempColor[0] = 0; - tempColor[1] = 0; - tempColor[2] = 0; - tempColor[3] = 0; - float overallmultiplyer = 0; + float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float multiplier_accum = 0.0f; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -95,11 +91,11 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff for (int ny = miny; ny < maxy; ny += step) { index = (ny - y) + this->rad; int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); - const float multiplyer = gausstab[index]; - madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer); - overallmultiplyer += multiplyer; + const float multiplier = gausstab[index]; + madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; } - mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); + mul_v4_v4fl(color, color_accum, 1.0f / multiplier_accum); } void GaussianYBlurOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index 0a450cc3bf8..ae2913350f9 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -98,23 +98,42 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler int primary_channel = get_pixel_primary_channel(screenColor); - float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel); - - if (saturation < 0) { + if (pixelColor[primary_channel] > 1.0f) { + /* overexposure doesn't happen on screen itself and usually happens + * on light sources in the shot, this need to be checked separately + * because saturation and falloff calculation is based on the fact + * that pixels are not overexposured + */ color[0] = 1.0f; } - else if (saturation >= screen_saturation) { - color[0] = 0.0f; - } else { - float distance = 1.0f - saturation / screen_saturation; - - color[0] = distance; + float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel); + + if (saturation < 0) { + /* means main channel of pixel is different from screen, + * assume this is completely a foreground + */ + color[0] = 1.0f; + } + else if (saturation >= screen_saturation) { + /* matched main channels and higher saturation on pixel + * is treated as completely background + */ + color[0] = 0.0f; + } + else { + /* nice alpha falloff on edges */ + float distance = 1.0f - saturation / screen_saturation; + + color[0] = distance; + } } - color[0] *= (1.0f - garbageValue[0]); + /* apply garbage matte */ + color[0] = MIN2(color[0], 1.0f - garbageValue[0]); + /* apply core matte */ color[0] = MAX2(color[0], coreValue[0]); } diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index b728f6c5cca..9f7b69636ab 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -85,6 +85,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri int i; int width = this->getWidth(); int height = this->getHeight(); + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); if (this->trackingObject[0]) { MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject); @@ -102,7 +103,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri if (!sites_total) return NULL; - BKE_movieclip_user_set_frame(&user, framenumber); + BKE_movieclip_user_set_frame(&user, clip_frame); ibuf = BKE_movieclip_get_ibuf(movieClip, &user); if (!ibuf) @@ -115,7 +116,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri i = 0; while (track) { VoronoiSite *site = &sites[i]; - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenumber); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); int j; @@ -182,8 +183,9 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsig if (this->movieClip) { MovieClipUser user = {0}; int width, height; + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); - BKE_movieclip_user_set_frame(&user, framenumber); + BKE_movieclip_user_set_frame(&user, clip_frame); BKE_movieclip_get_size(this->movieClip, &user, &width, &height); resolution[0] = width; diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 0493bdee12c..3b7e98433e4 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -75,8 +75,8 @@ void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers float *buffer; buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->smooth); - if (this->smooth) { + BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->do_smooth, this->do_feather); + if (this->do_smooth) { PLX_antialias_buffer(buffer, width, height); } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 8507cb994c0..6b6d9aa9eeb 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -40,7 +40,8 @@ protected: int maskWidth; int maskHeight; int framenumber; - bool smooth; + bool do_smooth; + bool do_feather; float *rasterizedMask; /** @@ -60,7 +61,8 @@ public: void setMaskWidth(int width) { this->maskWidth = width; } void setMaskHeight(int height) { this->maskHeight = height; } void setFramenumber(int framenumber) { this->framenumber = framenumber; } - void setSmooth(bool smooth) { this->smooth = smooth; } + void setSmooth(bool smooth) { this->do_smooth = smooth; } + void setFeather(bool feather) { this->do_feather = feather; } void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); }; diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h index ef8668f6f21..e064b7511cb 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h @@ -16,7 +16,7 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " coords += offset;\n" \ " float tempBoundingBox;\n" \ " float4 color = {0.0f,0.0f,0.0f,0.0f};\n" \ -" float4 multiplyer = {0.0f,0.0f,0.0f,0.0f};\n" \ +" float4 multiplier = {0.0f,0.0f,0.0f,0.0f};\n" \ " float4 bokeh;\n" \ " const float radius2 = radius*2.0f;\n" \ " const int2 realCoordinate = coords + offsetOutput;\n" \ @@ -40,10 +40,10 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " uv.x = ((realCoordinate.x-nx)/radius2)*bokehImageDim.x+bokehImageCenter.x;\n" \ " bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ " color += bokeh * read_imagef(inputImage, SAMPLER_NEAREST, inputXy);\n" \ -" multiplyer += bokeh;\n" \ +" multiplier += bokeh;\n" \ " }\n" \ " }\n" \ -" color /= multiplyer;\n" \ +" color /= multiplier;\n" \ "\n" \ " } else {\n" \ " int2 imageCoordinates = realCoordinate - offsetInput;\n" \ diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index e71178a811d..c0aa139b032 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -92,9 +92,9 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN OutputSingleLayerOperation::OutputSingleLayerOperation( - const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) + const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) { - this->scene = scene; + this->rd = rd; this->tree = tree; this->addInputSocket(datatype); @@ -130,13 +130,13 @@ void OutputSingleLayerOperation::deinitExecution() ibuf->channels = size; ibuf->rect_float = this->outputBuffer; ibuf->mall |= IB_rectfloat; - ibuf->dither = scene->r.dither_intensity; + ibuf->dither = this->rd->dither_intensity; - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + if (this->rd->color_mgt_flag & R_COLOR_MANAGEMENT) ibuf->profile = IB_PROFILE_LINEAR_RGB; - BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, this->format->imtype, - (this->scene->r.scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, this->format->imtype, + (this->rd->scemode & R_EXTENSION), true); if (0 == BKE_imbuf_write(ibuf, filename, this->format)) printf("Cannot save Node File Output to %s\n", filename); @@ -160,9 +160,9 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype) } OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation( - const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec) + const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec) { - this->scene = scene; + this->rd = rd; this->tree = tree; BLI_strncpy(this->path, path, sizeof(this->path)); @@ -199,8 +199,8 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() char filename[FILE_MAX]; void *exrhandle = IMB_exr_get_handle(); - BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, R_IMF_IMTYPE_MULTILAYER, - (this->scene->r.scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, R_IMF_IMTYPE_MULTILAYER, + (this->rd->scemode & R_EXTENSION), true); BLI_make_existing_file(filename); for (unsigned int i = 0; i < layers.size(); ++i) { diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index cfc5f7e41f2..25ee5b31ec0 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -32,7 +32,7 @@ /* Writes the image to a single-layer file. */ class OutputSingleLayerOperation : public NodeOperation { private: - const Scene *scene; + const RenderData *rd; const bNodeTree *tree; ImageFormatData *format; @@ -43,7 +43,7 @@ private: SocketReader *imageInput; public: - OutputSingleLayerOperation(const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); + OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); bool isOutputOperation(bool rendering) const { return true; } @@ -67,7 +67,7 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation { private: typedef std::vector<OutputOpenExrLayer> LayerList; - const Scene *scene; + const RenderData *rd; const bNodeTree *tree; char path[FILE_MAX]; @@ -75,7 +75,7 @@ private: LayerList layers; public: - OutputOpenExrMultiLayerOperation(const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec); + OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec); void add_layer(const char *name, DataType datatype); diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index 77f2a06b29b..b337e435df4 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -27,19 +27,21 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->inputProgram = NULL; + this->dispersionAvailable = false; + this->dispersion = 0.0f; } void ProjectorLensDistortionOperation::initExecution() { this->inputProgram = this->getInputSocketReader(0); - kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr2 = kr * 20; } void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { + updateDispersion(memoryBuffers); void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } @@ -69,9 +71,28 @@ void ProjectorLensDistortionOperation::deinitExecution() bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.ymax = input->ymax; - newInput.ymin = input->ymin; - newInput.xmin = input->xmin - kr2 - 2; - newInput.xmax = input->xmax + kr2 + 2; + if (dispersionAvailable) { + newInput.ymax = input->ymax; + newInput.ymin = input->ymin; + newInput.xmin = input->xmin - kr2 - 2; + newInput.xmax = input->xmax + kr2 + 2; + } else { + newInput.xmin = 0; + newInput.ymin = input->ymin; + newInput.ymax = input->ymax; + newInput.xmax = inputProgram->getWidth(); + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } + +void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers) +{ + if (!dispersionAvailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + dispersion = result[0]; + kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); + kr2 = kr * 20; + dispersionAvailable = true; + } +} diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h index 2e188617ab5..5023a5df507 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -35,6 +35,8 @@ private: NodeLensDist *data; float dispersion; + bool dispersionAvailable; + float kr, kr2; public: ProjectorLensDistortionOperation(); @@ -56,9 +58,10 @@ public: void deinitExecution(); void setData(NodeLensDist *data) { this->data = data; } - void setDispertion(float dispersion) { this->dispersion = dispersion; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void updateDispersion(MemoryBuffer** inputBuffers); + }; #endif diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index fa1f0280207..857131950dd 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -48,14 +48,21 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigne } void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - MemoryBuffer *inputBuffer = inputBuffers[this->offset]; - if (inputBuffer) { - if (sampler == COM_PS_NEAREST) { - inputBuffer->read(color, x, y); - } - else { - inputBuffer->readCubic(color, x, y); + if (inputBuffers) { + MemoryBuffer *inputBuffer = inputBuffers[this->offset]; + if (inputBuffer) { + if (sampler == COM_PS_NEAREST) { + inputBuffer->read(color, x, y); + } + else { + inputBuffer->readCubic(color, x, y); + } } + } else { + color[0] = 0.0f; + color[1] = 0.0f; + color[2] = 0.0f; + color[3] = 0.0f; } } @@ -76,7 +83,8 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff return false; } -void ReadBufferOperation::readResolutionFromWriteBuffer() { +void ReadBufferOperation::readResolutionFromWriteBuffer() +{ if (this->memoryProxy != NULL) { WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation(); this->setWidth(operation->getWidth()); diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index ac06048faf3..456dc5d1d0f 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -48,7 +48,8 @@ void RotateOperation::deinitExecution() this->degreeSocket = NULL; } -inline void RotateOperation::ensureDegree() { +inline void RotateOperation::ensureDegree() +{ if (!isDegreeSet) { float degree[4]; this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index 3299434a02e..da3504de971 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -30,34 +30,24 @@ extern "C" { ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->inputProgram = NULL; + this->valuesAvailable = false; + this->dispersion = 0.0f; + this->distortion = 0.0f; } void ScreenLensDistortionOperation::initExecution() { this->inputProgram = this->getInputSocketReader(0); - kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); - // smaller dispersion range for somewhat more control - const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr = MAX2(MIN2((kg + d), 1.f), -0.999f); - kb = MAX2(MIN2((kg - d), 1.f), -0.999f); - maxk = MAX3(kr, kg, kb); - sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); - drg = 4.f * (kg - kr); - dgb = 4.f * (kb - kg); - - kr4 = kr * 4; - kg4 = kg * 4.f; - kb4 *= kb * 4.f; - cx = 0.5f * (float)getWidth(); - cy = 0.5f * (float)getHeight(); - } void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + updateDispersionAndDistortion(memoryBuffers); return buffer; } @@ -72,19 +62,20 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int float tc[4] = {0, 0, 0, 0}; const float v = sc * ((y + 0.5f) - cy) / cy; const float u = sc * ((x + 0.5f) - cx) / cx; + const float uv_dot = u * u + v * v; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - kr4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; sta = 1; } - if ((t = 1.f - kg4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - kg4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; mid = 1; } - if ((t = 1.f - kb4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - kb4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; end = 1; @@ -103,10 +94,10 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kr4 + tz * drg) * (u * u + v * v); + t = 1.f - (kr4 + tz * drg) * uv_dot; d = 1.f / (1.f + sqrtf(t)); - const float nx = (u * d + 0.5f) * getWidth() - 0.5f; - const float ny = (v * d + 0.5f) * getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; buffer->readCubic(color, nx, ny); tc[0] += (1.f - tz) * color[0], tc[1] += tz * color[1]; dr++, dg++; @@ -121,10 +112,10 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kg4 + tz * dgb) * (u * u + v * v); + t = 1.f - (kg4 + tz * dgb) * uv_dot; d = 1.f / (1.f + sqrtf(t)); - const float nx = (u * d + 0.5f) * getWidth() - 0.5f; - const float ny = (v * d + 0.5f) * getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; buffer->readCubic(color, nx, ny); tc[1] += (1.f - tz) * color[1], tc[2] += tz * color[2]; dg++, db++; @@ -170,3 +161,30 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input newInput.xmax = inputProgram->getWidth(); return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } + +void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) +{ + if (!valuesAvailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->distortion = result[0]; + this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->dispersion = result[0]; + kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); + // smaller dispersion range for somewhat more control + const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); + kr = MAX2(MIN2((kg + d), 1.f), -0.999f); + kb = MAX2(MIN2((kg - d), 1.f), -0.999f); + maxk = MAX3(kr, kg, kb); + sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); + drg = 4.f * (kg - kr); + dgb = 4.f * (kb - kg); + + kr4 = kr * 4.f; + kg4 = kg * 4.f; + kb4 = kb * 4.f; + cx = 0.5f * (float)getWidth(); + cy = 0.5f * (float)getHeight(); + valuesAvailable = true; + } +} diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index 34656f38a09..21babd11295 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -36,6 +36,7 @@ private: float dispersion; float distortion; + bool valuesAvailable; float kr, kg, kb; float kr4, kg4, kb4; float maxk; @@ -62,13 +63,12 @@ public: void deinitExecution(); void setData(NodeLensDist *data) { this->data = data; } - void setDispertion(float dispersion) { this->dispersion = dispersion; } - void setDistortion(float distortion) { this->distortion = distortion; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); private: void determineUV(float *result, float x, float y) const; + void updateDispersionAndDistortion(MemoryBuffer** inputBuffers); }; #endif diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index 072528f3fc6..dbdd17adbe4 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -32,7 +32,7 @@ TextureBaseOperation::TextureBaseOperation() : NodeOperation() this->texture = NULL; this->inputSize = NULL; this->inputOffset = NULL; - this->scene = NULL; + this->rd = NULL; } TextureOperation::TextureOperation() : TextureBaseOperation() { @@ -57,8 +57,8 @@ void TextureBaseOperation::deinitExecution() void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { if (preferredResolution[0] == 0 || preferredResolution[1] == 0) { - int width = this->scene->r.xsch * this->scene->r.size / 100; - int height = this->scene->r.ysch * this->scene->r.size / 100; + int width = this->rd->xsch * this->rd->size / 100; + int height = this->rd->ysch * this->rd->size / 100; resolution[0] = width; resolution[1] = height; } diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h index e862a1f1910..14714242511 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.h +++ b/source/blender/compositor/operations/COM_TextureOperation.h @@ -43,7 +43,7 @@ extern "C" { class TextureBaseOperation : public NodeOperation { private: Tex *texture; - const Scene *scene; + const RenderData *rd; SocketReader *inputSize; SocketReader *inputOffset; @@ -65,7 +65,7 @@ public: void setTexture(Tex *texture) { this->texture = texture; } void initExecution(); void deinitExecution(); - void setScene(const Scene *scene) { this->scene = scene; } + void setRenderData(const RenderData *rd) { this->rd = rd; } }; class TextureOperation : public TextureBaseOperation { diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 7c9b0c75518..c17e51e6391 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -31,15 +31,17 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image. - this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); // radius + this->addInputSocket(COM_DT_VALUE); // depth this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->inputProgram = NULL; this->inputBokehProgram = NULL; this->inputSizeProgram = NULL; + this->inputDepthProgram = NULL; this->maxBlur = 32.0f; - this->threshold = 0.0f; + this->threshold = 1.0f; } @@ -48,61 +50,62 @@ void VariableSizeBokehBlurOperation::initExecution() this->inputProgram = getInputSocketReader(0); this->inputBokehProgram = getInputSocketReader(1); this->inputSizeProgram = getInputSocketReader(2); + this->inputDepthProgram = getInputSocketReader(3); QualityStepHelper::initExecution(COM_QH_INCREASE); } void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; float readColor[4]; float bokeh[4]; - tempColor[0] = 0; - tempColor[1] = 0; - tempColor[2] = 0; - tempColor[3] = 0; float tempSize[4]; - float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float tempDepth[4]; + float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; int miny = y - maxBlur; int maxy = y + maxBlur; int minx = x - maxBlur; int maxx = x + maxBlur; { + inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); + inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); - tempColor[0] += readColor[0]; - tempColor[1] += readColor[1]; - tempColor[2] += readColor[2]; - tempColor[3] += readColor[3]; - add_v4_v4(tempColor, readColor); - add_v3_fl(overallmultiplyer, 1.0f); + add_v4_v4(color_accum, readColor); + add_v4_fl(multiplier_accum, 1.0f); + float sizeCenter = tempSize[0]; + float centerDepth = tempDepth[0]+threshold; for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { + inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); float size = tempSize[0]; -// size += this->threshold; - float dx = nx - x; - float dy = ny - y; - if (nx == x && ny == y) { - /* pass */ - } - else if (size >= fabsf(dx) && size >= fabsf(dy)) { - float u = 256 + dx * 256 / size; - float v = 256 + dy * 256 / size; - inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(tempColor, bokeh, readColor); - add_v4_v4(overallmultiplyer, bokeh); + if (tempDepth[0] < centerDepth) { + if ((sizeCenter > threshold && size > threshold) || size <= threshold) { + float dx = nx - x; + float dy = ny - y; + if (nx == x && ny == y) { + } + else if (size >= fabsf(dx) && size >= fabsf(dy)) { + float u = 256 + dx * 256 / size; + float v = 256 + dy * 256 / size; + inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); + madd_v4_v4v4(color_accum, bokeh, readColor); + add_v4_v4(multiplier_accum, bokeh); + } + } } } } } - color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]); - color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]); - color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]); - color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]); + color[0] = color_accum[0] * (1.0f / multiplier_accum[0]); + color[1] = color_accum[1] * (1.0f / multiplier_accum[1]); + color[2] = color_accum[2] * (1.0f / multiplier_accum[2]); + color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } } @@ -136,6 +139,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) { return true; } + operation = getInputOperation(3); + if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { + return true; + } operation = getInputOperation(0); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index ede8f0333b4..d04bf08405f 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -32,6 +32,7 @@ private: SocketReader *inputProgram; SocketReader *inputBokehProgram; SocketReader *inputSizeProgram; + SocketReader *inputDepthProgram; public: VariableSizeBokehBlurOperation(); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index e1018e0d037..356ba452185 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -23,6 +23,7 @@ #include "COM_WriteBufferOperation.h" #include "COM_defines.h" #include <stdio.h> +#include "COM_OpenCLDevice.h" WriteBufferOperation::WriteBufferOperation() : NodeOperation() { @@ -110,7 +111,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me memoryBuffer->setCreatedState(); } -void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer) +void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer) { float *outputFloatBuffer = outputBuffer->getBuffer(); cl_int error; @@ -131,7 +132,7 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr CL_FLOAT }; - cl_mem clOutputBuffer = clCreateImage2D(context, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error); + cl_mem clOutputBuffer = clCreateImage2D(device->getContext(), CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } // STEP 2 @@ -139,7 +140,7 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr clMemToCleanUp->push_back(clOutputBuffer); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); - this->input->executeOpenCL(context, program, queue, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); + this->input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); // STEP 3 @@ -149,9 +150,9 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr // clFlush(queue); // clFinish(queue); - error = clEnqueueBarrier(queue); + error = clEnqueueBarrier(device->getQueue()); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueReadImage(queue, clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL); + error = clEnqueueReadImage(device->getQueue(), clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); @@ -175,7 +176,8 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr delete clKernelsToCleanUp; } -void WriteBufferOperation::readResolutionFromInputSocket() { +void WriteBufferOperation::readResolutionFromInputSocket() +{ NodeOperation *inputOperation = this->getInputOperation(0); this->setWidth(inputOperation->getWidth()); this->setHeight(inputOperation->getHeight()); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index 321eed7240a..ccc20584186 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -44,7 +44,7 @@ public: void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void initExecution(); void deinitExecution(); - void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); + void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); void readResolutionFromInputSocket(); }; |