diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp index da7336afc07..76ee5b2c2a1 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp @@ -22,7 +22,7 @@ #include "COM_DirectionalBlurOperation.h" #include "BLI_math.h" - +#include "COM_OpenCLDevice.h" extern "C" { #include "RE_pipeline.h" } @@ -33,6 +33,7 @@ DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); + this->setOpenCL(true); this->m_inputProgram = NULL; } @@ -97,9 +98,35 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu lsc += this->m_sc; } - mul_v4_v4fl(color, col2, 1.0f / iterations); + mul_v4_v4fl(color, col2, 1.0f / (iterations+1)); } +void DirectionalBlurOperation::executeOpenCL(OpenCLDevice* device, + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, + list<cl_kernel> *clKernelsToCleanUp) +{ + cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL); + + cl_int iterations = pow(2.0f, this->m_data->iter); + cl_float2 ltxy = {this->m_tx, this->m_ty}; + cl_float2 centerpix = {this->m_center_x_pix, this->m_center_y_pix}; + cl_float lsc = this->m_sc; + cl_float lrot = this->m_rot; + + device->COM_clAttachMemoryBufferToKernelParameter(directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(directionalBlurKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(directionalBlurKernel, 2, outputMemoryBuffer); + clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations); + clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc); + clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot); + clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), <xy); + clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), ¢erpix); + + device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this); +} + + void DirectionalBlurOperation::deinitExecution() { this->m_inputProgram = NULL; |