From bfe776cd1d1e9036bd389469d74984d6f5ce81fb Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 9 Jul 2012 15:21:43 +0000 Subject: removed depth aware defocus add blur to radius buffer --- .../blender/compositor/nodes/COM_DefocusNode.cpp | 12 ++-- .../COM_ConvertDepthToRadiusOperation.cpp | 7 ++- .../operations/COM_ConvertDepthToRadiusOperation.h | 6 +- .../operations/COM_FastGaussianBlurOperation.cpp | 63 ++++++++++++++++++++ .../operations/COM_FastGaussianBlurOperation.h | 16 +++++ .../compositor/operations/COM_OpenCLKernels.cl | 30 ++++------ .../compositor/operations/COM_OpenCLKernels.cl.h | 30 ++++------ .../COM_VariableSizeBokehBlurOperation.cpp | 68 +++++++++------------- .../COM_VariableSizeBokehBlurOperation.h | 1 - 9 files changed, 148 insertions(+), 85 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index 4c6b3ad137b..05bf907af5a 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -32,6 +32,7 @@ #include "COM_MathBaseOperation.h" #include "COM_SetValueOperation.h" #include "COM_GammaCorrectOperation.h" +#include "COM_FastGaussianBlurOperation.h" DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode) { @@ -46,7 +47,6 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext NodeDefocus *data = (NodeDefocus *)node->storage; NodeOperation *radiusOperation; - OutputSocket * depthOperation; if (data->no_zbuf) { MathMultiplyOperation *multiply = new MathMultiplyOperation(); SetValueOperation *multiplier = new SetValueOperation(); @@ -64,7 +64,6 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext graph->addOperation(maxRadius); graph->addOperation(minimize); radiusOperation = minimize; - depthOperation = minimize->getOutputSocket(0); } else { ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); @@ -73,8 +72,12 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext converter->setMaxRadius(data->maxblur); this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph); graph->addOperation(converter); - radiusOperation = converter; - depthOperation = converter->getInputSocket(0)->getConnection()->getFromSocket(); + + FastGaussianBlurValueOperation * blur = new FastGaussianBlurValueOperation(); + addLink(graph, converter->getOutputSocket(0), blur->getInputSocket(0)); + graph->addOperation(blur); + radiusOperation = blur; + converter->setPostBlur(blur); } BokehImageOperation *bokeh = new BokehImageOperation(); @@ -112,7 +115,6 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext operation->setThreshold(data->bthresh); addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); - addLink(graph, depthOperation, operation->getInputSocket(3)); #ifdef COM_DEFOCUS_SEARCH addLink(graph, search->getOutputSocket(), operation->getInputSocket(4)); #endif diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index 91b68a90126..b4319d25d13 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -32,6 +32,7 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation() this->m_fStop = 128.0f; this->m_cameraObject = NULL; this->m_maxRadius = 32.0f; + this->m_blurPostOperation = NULL; } float ConvertDepthToRadiusOperation::determineFocalDistance() @@ -68,6 +69,10 @@ void ConvertDepthToRadiusOperation::initExecution() this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * 32.0f)) / this->m_fStop; float minsz = MIN2(getWidth(), getHeight()); this->m_dof_sp = (float)minsz / (16.f / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); + + if (this->m_blurPostOperation) { + m_blurPostOperation->setSigma(m_aperture*128.0f); + } } void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -88,7 +93,7 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl #endif radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.f)); // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem - if (radius < 0.5f) radius = 0.5f; + if (radius < 0.0f) radius = 0.0f; if (radius > this->m_maxRadius) { radius = this->m_maxRadius; } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index 415befea168..f0e905db9c2 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -24,7 +24,7 @@ #define _COM_ConvertDepthToRadiusOperation_h #include "COM_NodeOperation.h" #include "DNA_object_types.h" - +#include "COM_FastGaussianBlurOperation.h" /** * this program converts an input color to an output value. * it assumes we are in sRGB color space. @@ -43,6 +43,8 @@ private: float m_cam_lens; float m_dof_sp; Object *m_cameraObject; + + FastGaussianBlurValueOperation *m_blurPostOperation; public: /** * Default constructor @@ -68,5 +70,7 @@ public: void setMaxRadius(float maxRadius) { this->m_maxRadius = maxRadius; } void setCameraObject(Object *camera) { this->m_cameraObject = camera; } float determineFocalDistance(); + void setPostBlur(FastGaussianBlurValueOperation *operation) {this->m_blurPostOperation = operation;} + }; #endif diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 8f0ebd9b8d2..6d9c980ea58 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -220,3 +220,66 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign #undef YVV } + + +/// +FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(COM_DT_VALUE); + this->m_iirgaus = NULL; + this->m_inputprogram = NULL; + this->m_sigma = 1.0f; + setComplex(true); +} + +void FastGaussianBlurValueOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + MemoryBuffer *newData = (MemoryBuffer *)data; + newData->read(color, x, y); +} + +bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; + + if (this->m_iirgaus) { + return false; + } + else { + newInput.xmin = 0; + newInput.ymin = 0; + newInput.xmax = this->getWidth(); + newInput.ymax = this->getHeight(); + } + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); +} + +void FastGaussianBlurValueOperation::initExecution() +{ + this->m_inputprogram = getInputSocketReader(0); + initMutex(); +} + +void FastGaussianBlurValueOperation::deinitExecution() +{ + if (this->m_iirgaus) { + delete this->m_iirgaus; + this->m_iirgaus = NULL; + } + deinitMutex(); +} + +void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + lockMutex(); + if (!this->m_iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *copy = newBuf->duplicate(); + FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3); + this->m_iirgaus = copy; + } + unlockMutex(); + return this->m_iirgaus; +} + diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index 1e303b23869..5f76490473f 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -40,7 +40,23 @@ public: void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); void deinitExecution(); void initExecution(); +}; + +class FastGaussianBlurValueOperation : public NodeOperation { +private: + float m_sigma; + MemoryBuffer *m_iirgaus; + SocketReader *m_inputprogram; +public: + FastGaussianBlurValueOperation(); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void deinitExecution(); + void initExecution(); + void setSigma(float sigma) { this->m_sigma = sigma; } }; + #endif diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index ce197915360..1f3b28f15d3 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -53,7 +53,7 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima //KERNEL --- DEFOCUS /VARIABLESIZEBOKEHBLUR --- __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2d_t bokehImage, - __read_only image2d_t inputDepth, __read_only image2d_t inputSize, + __read_only image2d_t inputSize, __write_only image2d_t output, int2 offsetInput, int2 offsetOutput, int step, int maxBlur, float threshold, int2 dimension, int2 offset) { @@ -65,7 +65,6 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 float4 readColor; float4 bokeh; float tempSize; - float tempDepth; float4 multiplier_accum = {1.0f, 1.0f, 1.0f, 1.0f}; float4 color_accum; @@ -77,7 +76,6 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 { int2 inputCoordinate = realCoordinate - offsetInput; float size = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; - float depth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0 + threshold; color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); for (int ny = miny; ny < maxy; ny += step) { @@ -85,21 +83,17 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 if (nx >= 0 && nx < dimension.s0 && ny >= 0 && ny < dimension.s1) { inputCoordinate.s0 = nx - offsetInput.s0; inputCoordinate.s1 = ny - offsetInput.s1; - tempDepth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0; - if (tempDepth < depth) { - tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; - - if ((size > threshold && tempSize > threshold) || tempSize <= threshold) { - float dx = nx - realCoordinate.s0; - float dy = ny - realCoordinate.s1; - if (dx != 0 || dy != 0) { - if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) { - float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize}; - bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv); - readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); - color_accum += bokeh*readColor; - multiplier_accum += bokeh; - } + tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; + if (size > threshold && tempSize > threshold) { + float dx = nx - realCoordinate.s0; + float dy = ny - realCoordinate.s1; + if (dx != 0 || dy != 0) { + if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) { + float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize}; + bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv); + readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); + color_accum += bokeh*readColor; + multiplier_accum += bokeh; } } } diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h index ca66ab85802..1c223a527ca 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h @@ -55,7 +55,7 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope "\n" \ "//KERNEL --- DEFOCUS /VARIABLESIZEBOKEHBLUR ---\n" \ "__kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2d_t bokehImage,\n" \ -" __read_only image2d_t inputDepth, __read_only image2d_t inputSize,\n" \ +" __read_only image2d_t inputSize,\n" \ " __write_only image2d_t output, int2 offsetInput, int2 offsetOutput,\n" \ " int step, int maxBlur, float threshold, int2 dimension, int2 offset)\n" \ "{\n" \ @@ -67,7 +67,6 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " float4 readColor;\n" \ " float4 bokeh;\n" \ " float tempSize;\n" \ -" float tempDepth;\n" \ " float4 multiplier_accum = {1.0f, 1.0f, 1.0f, 1.0f};\n" \ " float4 color_accum;\n" \ "\n" \ @@ -79,7 +78,6 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " {\n" \ " int2 inputCoordinate = realCoordinate - offsetInput;\n" \ " float size = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -" float depth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0 + threshold;\n" \ " color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ "\n" \ " for (int ny = miny; ny < maxy; ny += step) {\n" \ @@ -87,21 +85,17 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " if (nx >= 0 && nx < dimension.s0 && ny >= 0 && ny < dimension.s1) {\n" \ " inputCoordinate.s0 = nx - offsetInput.s0;\n" \ " inputCoordinate.s1 = ny - offsetInput.s1;\n" \ -" tempDepth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -" if (tempDepth < depth) {\n" \ -" tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -"\n" \ -" if ((size > threshold && tempSize > threshold) || tempSize <= threshold) {\n" \ -" float dx = nx - realCoordinate.s0;\n" \ -" float dy = ny - realCoordinate.s1;\n" \ -" if (dx != 0 || dy != 0) {\n" \ -" if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) {\n" \ -" float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize};\n" \ -" bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ -" readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ -" color_accum += bokeh*readColor;\n" \ -" multiplier_accum += bokeh;\n" \ -" }\n" \ +" tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ +" if (size > threshold && tempSize > threshold) {\n" \ +" float dx = nx - realCoordinate.s0;\n" \ +" float dy = ny - realCoordinate.s1;\n" \ +" if (dx != 0 || dy != 0) {\n" \ +" if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) {\n" \ +" float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize};\n" \ +" bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ +" readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ +" color_accum += bokeh*readColor;\n" \ +" multiplier_accum += bokeh;\n" \ " }\n" \ " }\n" \ " }\n" \ diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 90fd0f04ea4..61538fde258 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -33,7 +33,6 @@ 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); // radius - this->addInputSocket(COM_DT_VALUE); // depth #ifdef COM_DEFOCUS_SEARCH this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure. #endif @@ -44,7 +43,6 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputSizeProgram = NULL; - this->m_inputDepthProgram = NULL; this->m_maxBlur = 32.0f; this->m_threshold = 1.0f; #ifdef COM_DEFOCUS_SEARCH @@ -58,7 +56,6 @@ void VariableSizeBokehBlurOperation::initExecution() this->m_inputProgram = getInputSocketReader(0); this->m_inputBokehProgram = getInputSocketReader(1); this->m_inputSizeProgram = getInputSocketReader(2); - this->m_inputDepthProgram = getInputSocketReader(3); #ifdef COM_DEFOCUS_SEARCH this->m_inputSearchProgram = getInputSocketReader(4); #endif @@ -70,7 +67,6 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me float readColor[4]; float bokeh[4]; float tempSize[4]; - 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}; @@ -89,43 +85,39 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me #endif { this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); - this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); this->m_inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); add_v4_v4(color_accum, readColor); add_v4_fl(multiplier_accum, 1.0f); float sizeCenter = tempSize[0]; - float centerDepth = tempDepth[0] + this->m_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()) { - this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); - if (tempDepth[0] < centerDepth) { - this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); - float size = tempSize[0]; - if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_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; - this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - this->m_inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(color_accum, bokeh, readColor); - add_v4_v4(multiplier_accum, bokeh); - } + this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); + float size = tempSize[0]; + float fsize = fabsf(size); + if (sizeCenter > this->m_threshold && size > this->m_threshold) { + float dx = nx - x; + float dy = ny - y; + if (nx == x && ny == y) { + } + else if (fsize > fabsf(dx) && fsize > fabsf(dy)) { + float u = (256 + (dx/size) * 256); + float v = (256 + (dy/size) * 256); + this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); + madd_v4_v4v4(color_accum, bokeh, readColor); + add_v4_v4(multiplier_accum, bokeh); } } } } } - 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]); + color[0] = color_accum[0] / multiplier_accum[0]; + color[1] = color_accum[1] / multiplier_accum[1]; + color[2] = color_accum[2] / multiplier_accum[2]; + color[3] = color_accum[3] / multiplier_accum[3]; } } @@ -143,16 +135,15 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice* device, 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_clAttachMemoryBufferToKernelParameter(defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 3, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 5, outputMemoryBuffer); + clSetKernelArg(defocusKernel, 6, sizeof(cl_int), &step); + clSetKernelArg(defocusKernel, 7, sizeof(cl_int), &maxBlur); + clSetKernelArg(defocusKernel, 8, sizeof(cl_float), &threshold); + device->COM_clAttachSizeToKernelParameter(defocusKernel, 9, this); - device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 11, this); + device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 10, this); } void VariableSizeBokehBlurOperation::deinitExecution() @@ -160,7 +151,6 @@ void VariableSizeBokehBlurOperation::deinitExecution() this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputSizeProgram = NULL; - this->m_inputDepthProgram = NULL; #ifdef COM_DEFOCUS_SEARCH this->m_inputSearchProgram = NULL; #endif @@ -189,10 +179,6 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) { return true; } - operation = getInputOperation(3); - if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { - return true; - } #ifdef COM_DEFOCUS_SEARCH rcti searchInput; searchInput.xmax = (input->xmax / InverseSearchRadiusOperation::DIVIDER) + 1; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index 8e5589fafec..6c9196c3eab 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -33,7 +33,6 @@ private: SocketReader *m_inputProgram; SocketReader *m_inputBokehProgram; SocketReader *m_inputSizeProgram; - SocketReader *m_inputDepthProgram; #ifdef COM_DEFOCUS_SEARCH SocketReader *inputSearchProgram; #endif -- cgit v1.2.3