Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2012-07-06 15:31:40 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2012-07-06 15:31:40 +0400
commit28f7bfa8dfd691a1af7966ed3f8358479f069adf (patch)
treeed840647be5df4c32910d70e8557200804b1f850 /source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
parent27da686aece8940aedcd99ac9f8a08f63af7f539 (diff)
* Added OpenCL implementation of the Defocus node
* Always disable two phase compositing during rendering - At Mind -
Diffstat (limited to 'source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 1368476e9b4..7ddcb78b61f 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -22,6 +22,7 @@
#include "COM_VariableSizeBokehBlurOperation.h"
#include "BLI_math.h"
+#include "COM_OpenCLDevice.h"
extern "C" {
#include "RE_pipeline.h"
@@ -38,6 +39,7 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
#endif
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
+ this->setOpenCL(true);
this->m_inputProgram = NULL;
this->m_inputBokehProgram = NULL;
@@ -128,6 +130,33 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
}
+static cl_kernel defocusKernel = 0;
+void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice* device,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp)
+{
+ if (!defocusKernel) {
+ defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL);
+ }
+ cl_int step = this->getStep();
+ cl_int maxBlur = this->m_maxBlur;
+ cl_float threshold = this->m_threshold;
+
+ device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
+ device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 2, 5, clMemToCleanUp, inputMemoryBuffers, this->m_inputDepthProgram);
+ device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 3, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 4, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 6, outputMemoryBuffer);
+ clSetKernelArg(defocusKernel, 7, sizeof(cl_int), &step);
+ clSetKernelArg(defocusKernel, 8, sizeof(cl_int), &maxBlur);
+ clSetKernelArg(defocusKernel, 9, sizeof(cl_float), &threshold);
+ device->COM_clAttachSizeToKernelParameter(defocusKernel, 10, this);
+
+ device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 11, this);
+}
+
void VariableSizeBokehBlurOperation::deinitExecution()
{
this->m_inputProgram = NULL;