From be1b5f82cee09041fdee355697841ee92b31ef70 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 13 Jun 2012 12:34:56 +0000 Subject: * optimized threading * break out with glare node * Added OpenCL kernels compatible with AMD still need some testing. --- .../blender/compositor/intern/COM_NodeOperation.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'source/blender/compositor/intern/COM_NodeOperation.cpp') diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index 650e4af5ae0..148ad48ba3a 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -34,6 +34,7 @@ NodeOperation::NodeOperation() this->width = 0; this->height = 0; this->openCL = false; + this->btree = NULL; } void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -74,10 +75,22 @@ void NodeOperation::initMutex() { BLI_mutex_init(&mutex); } + +void NodeOperation::lockMutex() +{ + BLI_mutex_lock(&mutex); +} + +void NodeOperation::unlockMutex() +{ + BLI_mutex_unlock(&mutex); +} + void NodeOperation::deinitMutex() { BLI_mutex_end(&mutex); } + void NodeOperation::deinitExecution() { } @@ -196,14 +209,15 @@ void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, size_t size[2]; cl_int2 offset; - for (offsety = 0 ; offsety < height; offsety+=localSize) { + 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 ; offsetx+=localSize) { + for (offsetx = 0 ; offsetx < width && (!breaked) ; offsetx+=localSize) { if (offsetx+localSize < width) { size[0] = localSize; } else { @@ -216,6 +230,9 @@ void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, 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; + } } } } -- cgit v1.2.3