From 285a24b3e07b3441e98a0a502c42af50b9738f3a Mon Sep 17 00:00:00 2001 From: Monique Dewanchand Date: Fri, 1 Jun 2012 10:20:24 +0000 Subject: Replaced tile based memory manager with a single aligned buffer - should increase speed with large node setups - enables caching of buffers in the node editor (in the future) - OpenCL part still needs some work --- .../operations/COM_WriteBufferOperation.cpp | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'source/blender/compositor/operations/COM_WriteBufferOperation.cpp') diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 3af914f8d0e..498add2fc87 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -22,10 +22,8 @@ #include "COM_WriteBufferOperation.h" #include "COM_defines.h" -#include "COM_MemoryManager.h" #include -/// @TODO: writebuffers don't have an actual data type set. WriteBufferOperation::WriteBufferOperation() :NodeOperation() { this->addInputSocket(COM_DT_COLOR); @@ -46,20 +44,23 @@ void WriteBufferOperation::executePixel(float *color, float x, float y, PixelSam { input->read(color, x, y, sampler, inputBuffers); } + void WriteBufferOperation::initExecution() { - this->input = this->getInputOperation(0); - MemoryManager::addMemoryProxy(this->memoryProxy); + this->input = this->getInputOperation(0); + this->memoryProxy->allocate(this->width, this->height); } + void WriteBufferOperation::deinitExecution() { this->input = NULL; + this->memoryProxy->free(); } - void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers) { - MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber); + //MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber); + MemoryBuffer *memoryBuffer = this->memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); if (this->input->isComplex()) { void *data = this->input->initializeTileData(rect, memoryBuffers); @@ -67,14 +68,14 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me int y1 = rect->ymin; int x2 = rect->xmax; int y2 = rect->ymax; - int offset4 = 0; int x; int y; bool breaked = false; for (y = y1 ; y < y2 && (!breaked) ; y++) { + int offset4 = (y*memoryBuffer->getWidth()+x1)*COM_NUMBER_OF_CHANNELS; for (x = x1 ; x < x2; x++) { input->read(&(buffer[offset4]), x, y, memoryBuffers, data); - offset4 +=4; + offset4 +=COM_NUMBER_OF_CHANNELS; } if (tree->test_break && tree->test_break(tree->tbh)) { @@ -92,14 +93,15 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me int y1 = rect->ymin; int x2 = rect->xmax; int y2 = rect->ymax; - int offset4 = 0; + int x; int y; bool breaked = false; for (y = y1 ; y < y2 && (!breaked) ; y++) { + int offset4 = (y*memoryBuffer->getWidth()+x1)*COM_NUMBER_OF_CHANNELS; for (x = x1 ; x < x2 ; x++) { input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); - offset4 +=4; + offset4 +=COM_NUMBER_OF_CHANNELS; } if (tree->test_break && tree->test_break(tree->tbh)) { breaked = true; @@ -111,7 +113,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** inputMemoryBuffers) { - MemoryBuffer *outputMemoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), chunkNumber); + MemoryBuffer *outputMemoryBuffer = this->getMemoryProxy()->getBuffer();// @todo wrong implementation needs revision float *outputFloatBuffer = outputMemoryBuffer->getBuffer(); cl_int error; /* -- cgit v1.2.3