Moved highlight code to the workscheduler.
authorJeroen Bakker <j.bakker@atmind.nl>
Thu, 5 Jul 2012 06:34:31 +0000 (06:34 +0000)
committerJeroen Bakker <j.bakker@atmind.nl>
Thu, 5 Jul 2012 06:34:31 +0000 (06:34 +0000)
source/blender/compositor/intern/COM_WorkScheduler.cpp
source/blender/compositor/operations/COM_WriteBufferOperation.cpp
source/blender/compositor/operations/COM_WriteBufferOperation.h

index c49ac24e018f353f00833c5d39b91c1a77f97ccf..120b4d6d0f275ea378e1ea03ae954017e650d6c8 100644 (file)
@@ -30,6 +30,7 @@
 #include "COM_OpenCLDevice.h"
 #include "COM_OpenCLKernels.cl.h"
 #include "OCL_opencl.h"
 #include "COM_OpenCLDevice.h"
 #include "COM_OpenCLKernels.cl.h"
 #include "OCL_opencl.h"
+#include "COM_WriteBufferOperation.h"
 
 #include "PIL_time.h"
 #include "BLI_threads.h"
 
 #include "PIL_time.h"
 #include "BLI_threads.h"
@@ -65,6 +66,25 @@ static bool g_openclActive = false;
 #endif
 #endif
 
 #endif
 #endif
 
+#define HIGHLIGHT(wp) \
+{ \
+       ExecutionGroup* group = wp->getExecutionGroup(); \
+       if (group->isComplex()) { \
+               NodeOperation* operation = group->getOutputNodeOperation(); \
+               if (operation->isWriteBufferOperation()) {\
+                       WriteBufferOperation *writeOperation = (WriteBufferOperation*)operation;\
+                       NodeOperation *complexOperation = writeOperation->getInput(); \
+                       bNode *node = complexOperation->getbNode(); \
+                       if (node) { \
+                               if (node->original) { \
+                                       node->original->highlight = 1;\
+                               } else {\
+                                       node->highlight = 1; \
+                               }\
+                       } \
+               } \
+       } \
+}
 
 #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
 void *WorkScheduler::thread_execute_cpu(void *data)
 
 #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
 void *WorkScheduler::thread_execute_cpu(void *data)
@@ -73,6 +93,7 @@ void *WorkScheduler::thread_execute_cpu(void *data)
        WorkPackage *work;
        
        while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) {
        WorkPackage *work;
        
        while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) {
+               HIGHLIGHT(work);
                device->execute(work);
                delete work;
        }
                device->execute(work);
                delete work;
        }
@@ -86,6 +107,7 @@ void *WorkScheduler::thread_execute_gpu(void *data)
        WorkPackage *work;
        
        while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) {
        WorkPackage *work;
        
        while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) {
+               HIGHLIGHT(work);
                device->execute(work);
                delete work;
        }
                device->execute(work);
                delete work;
        }
index 191b21b921743173df486bb850312118ee252534..8decb73615b975f025c23f3812598f937d7863af 100644 (file)
@@ -63,9 +63,6 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
        MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
        float *buffer = memoryBuffer->getBuffer();
        if (this->m_input->isComplex()) {
        MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
        float *buffer = memoryBuffer->getBuffer();
        if (this->m_input->isComplex()) {
-               bNode* bnode = this->m_input->getbNode();
-               if (bnode && bnode->original) bnode->original->highlight++;
-
                void *data = this->m_input->initializeTileData(rect, memoryBuffers);
                int x1 = rect->xmin;
                int y1 = rect->ymin;
                void *data = this->m_input->initializeTileData(rect, memoryBuffers);
                int x1 = rect->xmin;
                int y1 = rect->ymin;
@@ -90,7 +87,6 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
                        this->m_input->deinitializeTileData(rect, memoryBuffers, data);
                        data = NULL;
                }
                        this->m_input->deinitializeTileData(rect, memoryBuffers, data);
                        data = NULL;
                }
-               if (bnode && bnode->original) bnode->original->highlight++;
        }
        else {
                int x1 = rect->xmin;
        }
        else {
                int x1 = rect->xmin;
@@ -143,8 +139,6 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
        list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
        clMemToCleanUp->push_back(clOutputBuffer);
        list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
        list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
        clMemToCleanUp->push_back(clOutputBuffer);
        list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
-       bNode* bnode = this->m_input->getbNode();
-       if (bnode && bnode->original) bnode->original->highlight++;
 
        this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp);
 
 
        this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp);
 
@@ -163,10 +157,7 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
        
        this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
 
        
        this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
 
-       if (bnode && bnode->original) bnode->original->highlight++;
        // STEP 4
        // STEP 4
-
-       
        while (clMemToCleanUp->size() > 0) {
                cl_mem mem = clMemToCleanUp->front();
                error = clReleaseMemObject(mem);
        while (clMemToCleanUp->size() > 0) {
                cl_mem mem = clMemToCleanUp->front();
                error = clReleaseMemObject(mem);
index 24bfdecd12456a8c05899aa2254617a88ff54d66..d77814a9dc4c9edb0958e3be5870f4bfcf9eba17 100644 (file)
@@ -46,6 +46,9 @@ public:
        void deinitExecution();
        void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer);
        void readResolutionFromInputSocket();
        void deinitExecution();
        void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer);
        void readResolutionFromInputSocket();
+       inline NodeOperation *getInput() {
+               return m_input;
+       }
 
 };
 #endif
 
 };
 #endif