[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43486] branches/tile/source/blender/ compositor: TileBranch

Jeroen Bakker j.bakker at atmind.nl
Wed Jan 18 11:39:12 CET 2012


Revision: 43486
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43486
Author:   jbakker
Date:     2012-01-18 10:39:07 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
TileBranch
 * Removed storage of tiles to disc. in order to support buffer caching
 * Cleaned up spaces/tabs

Jeroen

Modified Paths:
--------------
    branches/tile/source/blender/compositor/COM_defines.h
    branches/tile/source/blender/compositor/intern/COM_ExecutionGroup.cpp
    branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp
    branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h
    branches/tile/source/blender/compositor/intern/COM_MemoryManager.cpp
    branches/tile/source/blender/compositor/intern/COM_MemoryManager.h
    branches/tile/source/blender/compositor/operations/COM_WriteBufferOperation.cpp

Modified: branches/tile/source/blender/compositor/COM_defines.h
===================================================================
--- branches/tile/source/blender/compositor/COM_defines.h	2012-01-18 10:16:39 UTC (rev 43485)
+++ branches/tile/source/blender/compositor/COM_defines.h	2012-01-18 10:39:07 UTC (rev 43486)
@@ -94,10 +94,6 @@
 #define COM_MM_MAX_ALLOCATED_MEMORY 1*1024*1024*1024
 
 #define COM_NUMBER_OF_CHANNELS 4
-/**
-  * enable the balancing of memory (saving MemoryBuffer to disc) to free memory
-  */
-#define COM_MM_ENABLE FALSE
 
 #define COM_RM_NORMAL 0
 #define COM_RM_LINEAR 1

Modified: branches/tile/source/blender/compositor/intern/COM_ExecutionGroup.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_ExecutionGroup.cpp	2012-01-18 10:16:39 UTC (rev 43485)
+++ branches/tile/source/blender/compositor/intern/COM_ExecutionGroup.cpp	2012-01-18 10:39:07 UTC (rev 43486)
@@ -384,7 +384,7 @@
 
 	if (maxxchunk== minxchunk+1 && maxychunk == minychunk+1) {
 		const int chunkNumber = minxchunk+minychunk*numberOfXChunks;
-		MemoryBuffer *result = MemoryManager::getMemoryBuffer(memoryProxy, chunkNumber, true);
+		MemoryBuffer *result = MemoryManager::getMemoryBuffer(memoryProxy, chunkNumber);
 		return result;
 	}
 
@@ -404,9 +404,8 @@
 	for (indexx = max(minxchunk, 0); indexx<min((int)this->numberOfXChunks, maxxchunk) ; indexx++) {
 		for (indexy = max(minychunk, 0); indexy<min((int)this->numberOfYChunks, maxychunk) ; indexy++) {
 			int chunkNumber = indexx+indexy*this->numberOfXChunks;
-			MemoryBuffer *chunkBuffer = MemoryManager::getMemoryBuffer(memoryProxy, chunkNumber, true);
+			MemoryBuffer *chunkBuffer = MemoryManager::getMemoryBuffer(memoryProxy, chunkNumber);
 			result->copyContentFrom(chunkBuffer);
-			MemoryManager::releaseUser(chunkBuffer);
 		}
 	}
 
@@ -427,8 +426,6 @@
 				if (buffer->isTemporarily()) {
 					memoryBuffers[index] = NULL;
 					delete buffer;
-				} else {
-					buffer->removeUser();
 				}
 			}
 		}
@@ -460,7 +457,7 @@
 	NodeOperation * operation = this->getOutputNodeOperation();
 	if (operation->isWriteBufferOperation()) {
 		WriteBufferOperation* writeOperation = (WriteBufferOperation*)operation;
-		outputBuffer = MemoryManager::allocateMemoryBuffer(writeOperation->getMemoryProxy(), chunkNumber, rect, false);
+		outputBuffer = MemoryManager::allocateMemoryBuffer(writeOperation->getMemoryProxy(), chunkNumber, rect);
 	}
 	return outputBuffer;
 }

Modified: branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-01-18 10:16:39 UTC (rev 43485)
+++ branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-01-18 10:39:07 UTC (rev 43486)
@@ -38,25 +38,22 @@
 }
 
 MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, unsigned int chunkNumber, rcti* rect) {
-    BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+	BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
 	this->memoryProxy = memoryProxy;
 	this->chunkNumber = chunkNumber;
-    this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*4, "COM_MemoryBuffer");
-    this->state = COM_MB_ALLOCATED;
-    this->datatype = COM_DT_COLOR;
+	this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*4, "COM_MemoryBuffer");
+	this->state = COM_MB_ALLOCATED;
+	this->datatype = COM_DT_COLOR;
 	this->chunkWidth = this->rect.xmax - this->rect.xmin;
-    this->filename = "";
-    this->numberOfUsers = 0;
-    BLI_mutex_init(&this->mutex);
 }
 
 MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti* rect) {
-    BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+	BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
 	this->memoryProxy = memoryProxy;
 	this->chunkNumber = -1;
-    this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*4, "COM_MemoryBuffer");
-    this->state = COM_MB_TEMPORARILY;
-    this->datatype = COM_DT_COLOR;
+	this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*4, "COM_MemoryBuffer");
+	this->state = COM_MB_TEMPORARILY;
+	this->datatype = COM_DT_COLOR;
 	this->chunkWidth = this->rect.xmax - this->rect.xmin;
 }
 MemoryBuffer* MemoryBuffer::duplicate() {
@@ -66,58 +63,50 @@
 }
 
 MemoryBuffer::~MemoryBuffer() {
-    if (this->buffer) {
-        MEM_freeN(this->buffer);
-        this->buffer = NULL;
-    }
-    if (this->state != COM_MB_TEMPORARILY) {
-        BLI_mutex_end(&this->mutex);
-        if (this->filename.length() != 0) {
-            if (remove(this->filename.c_str()) != 0) {
-//                printf("ERROR: remove tempfile %s\n", this->filename);
-            }
-        }
-    }
+	if (this->buffer) {
+		MEM_freeN(this->buffer);
+		this->buffer = NULL;
+	}
 }
 
 void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) {
-    if (!otherBuffer) {
-        printf("no buffer to copy from\n");
-        return;
-    }
-    unsigned int otherY;
-    unsigned int minX = max(this->rect.xmin, otherBuffer->rect.xmin);
-    unsigned int maxX = min(this->rect.xmax, otherBuffer->rect.xmax);
-    unsigned int minY = max(this->rect.ymin, otherBuffer->rect.ymin);
-    unsigned int maxY = min(this->rect.ymax, otherBuffer->rect.ymax);
-    int offset;
-    int otherOffset;
+	if (!otherBuffer) {
+		printf("no buffer to copy from\n");
+		return;
+	}
+	unsigned int otherY;
+	unsigned int minX = max(this->rect.xmin, otherBuffer->rect.xmin);
+	unsigned int maxX = min(this->rect.xmax, otherBuffer->rect.xmax);
+	unsigned int minY = max(this->rect.ymin, otherBuffer->rect.ymin);
+	unsigned int maxY = min(this->rect.ymax, otherBuffer->rect.ymax);
+	int offset;
+	int otherOffset;
 
 
-    for (otherY = minY ; otherY<maxY ; otherY ++) {
+	for (otherY = minY ; otherY<maxY ; otherY ++) {
 		otherOffset = ((otherY-otherBuffer->rect.ymin) * otherBuffer->chunkWidth + minX-otherBuffer->rect.xmin)*4;
 		offset = ((otherY - this->rect.ymin) * this->chunkWidth + minX-this->rect.xmin)*4;
-        memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX-minX) * 4*sizeof(float));
-    }
+		memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX-minX) * 4*sizeof(float));
+	}
 }
 
 void MemoryBuffer::read(float* result, int x, int y) {
-    if (x>=this->rect.xmin && x < this->rect.xmax &&
-	        y>=this->rect.ymin && y < this->rect.ymax) {
-        int dx = x-this->rect.xmin;
-        int dy = y-this->rect.ymin;
+	if (x>=this->rect.xmin && x < this->rect.xmax &&
+			y>=this->rect.ymin && y < this->rect.ymax) {
+		int dx = x-this->rect.xmin;
+		int dy = y-this->rect.ymin;
 		int offset = (this->chunkWidth*dy+dx)*4;
-        result[0] = this->buffer[offset];
-        result[1] = this->buffer[offset+1];
-        result[2] = this->buffer[offset+2];
-        result[3] = this->buffer[offset+3];
-    }
-    else {
-        result[0] = 0.0f;
-        result[1] = 0.0f;
-        result[2] = 0.0f;
-        result[3] = 0.0f;
-    }
+		result[0] = this->buffer[offset];
+		result[1] = this->buffer[offset+1];
+		result[2] = this->buffer[offset+2];
+		result[3] = this->buffer[offset+3];
+	}
+	else {
+		result[0] = 0.0f;
+		result[1] = 0.0f;
+		result[2] = 0.0f;
+		result[3] = 0.0f;
+	}
 }
 void MemoryBuffer::writePixel(int x, int y, float color[4]) {
 	if (x>=this->rect.xmin && x < this->rect.xmax &&
@@ -131,41 +120,40 @@
 }
 
 void MemoryBuffer::readCubic(float* result, float x, float y) {
-    int x1 = floor(x);
-    int x2 = x1 + 1;
-    int y1 = floor(y);
-    int y2 = y1 + 1;
-
-    float valuex = x - x1;
-    float valuey = y - y1;
-    float mvaluex = 1.0 - valuex;
-    float mvaluey = 1.0 - valuey;
-
-    float color1[4];
-    float color2[4];
-    float color3[4];
-    float color4[4];
-
-    read(color1, x1, y1);
-    read(color2, x1, y2);
-    read(color3, x2, y1);
-    read(color4, x2, y2);
-
-    color1[0] = color1[0]*mvaluey + color2[0]*valuey;
-    color1[1] = color1[1]*mvaluey + color2[1]*valuey;
-    color1[2] = color1[2]*mvaluey + color2[2]*valuey;
-    color1[3] = color1[3]*mvaluey + color2[3]*valuey;
-
-    color3[0] = color3[0]*mvaluey + color4[0]*valuey;
-    color3[1] = color3[1]*mvaluey + color4[1]*valuey;
-    color3[2] = color3[2]*mvaluey + color4[2]*valuey;
-    color3[3] = color3[3]*mvaluey + color4[3]*valuey;
-
-    result[0] = color1[0]*mvaluex + color3[0]*valuex;
-    result[1] = color1[1]*mvaluex + color3[1]*valuex;
-    result[2] = color1[2]*mvaluex + color3[2]*valuex;
-    result[3] = color1[3]*mvaluex + color3[3]*valuex;
-
+	int x1 = floor(x);
+	int x2 = x1 + 1;
+	int y1 = floor(y);
+	int y2 = y1 + 1;
+	
+	float valuex = x - x1;
+	float valuey = y - y1;
+	float mvaluex = 1.0 - valuex;
+	float mvaluey = 1.0 - valuey;
+	
+	float color1[4];
+	float color2[4];
+	float color3[4];
+	float color4[4];
+	
+	read(color1, x1, y1);
+	read(color2, x1, y2);
+	read(color3, x2, y1);
+	read(color4, x2, y2);
+	
+	color1[0] = color1[0]*mvaluey + color2[0]*valuey;
+	color1[1] = color1[1]*mvaluey + color2[1]*valuey;
+	color1[2] = color1[2]*mvaluey + color2[2]*valuey;
+	color1[3] = color1[3]*mvaluey + color2[3]*valuey;
+	
+	color3[0] = color3[0]*mvaluey + color4[0]*valuey;
+	color3[1] = color3[1]*mvaluey + color4[1]*valuey;
+	color3[2] = color3[2]*mvaluey + color4[2]*valuey;
+	color3[3] = color3[3]*mvaluey + color4[3]*valuey;
+	
+	result[0] = color1[0]*mvaluex + color3[0]*valuex;
+	result[1] = color1[1]*mvaluex + color3[1]*valuex;
+	result[2] = color1[2]*mvaluex + color3[2]*valuex;
+	result[3] = color1[3]*mvaluex + color3[3]*valuex;
 }
 
 
@@ -335,98 +323,3 @@
 	// clipping can be ignored if alpha used, texr->ta already includes filtered edge
 	result[3] = result[3] ? result[3] *d : 1.f;
 }
-
-long MemoryBuffer::getAllocatedMemorySize() {
-    if (this->state == COM_MB_STORED) {
-        return 0l;
-    } else {
-        return sizeof(float)*determineBufferSize()*4;
-    }
-}
-
-bool MemoryBuffer::makeAvailable(bool addUser) {
-    bool result = false;
-    BLI_mutex_lock(&this->mutex);
-    if (this->state == COM_MB_STORED) {
-        result = true;
-        readFromDisc();
-    }
-    if (addUser) {
-        this->numberOfUsers++;
-    }
-    BLI_mutex_unlock(&this->mutex);
-    return result;
-}
-
-bool MemoryBuffer::isAvailable() {
-    return this->state == COM_MB_AVAILABLE;
-}
-
-bool MemoryBuffer::saveToDisc() {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list