[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11171] branches/soc-2007-joeedh/source/ blender: Commit before returning back home to flagstaff (yay!).

Joseph Eagar joeedh at gmail.com
Thu Jul 5 09:05:16 CEST 2007


Revision: 11171
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11171
Author:   joeedh
Date:     2007-07-05 09:05:16 +0200 (Thu, 05 Jul 2007)

Log Message:
-----------
Commit before returning back home to flagstaff (yay!).

BTW in the system and opengl user conf section you can
now set the max mem used by DSM maps before caching.
Note that theres still some bug where it doesn't quite
always cache enough, and sometimes it'll get really
messed up and the cache system won't do anything at all. :/

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h
    branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
    branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
    branches/soc-2007-joeedh/source/blender/blenlib/BLI_memarena.h
    branches/soc-2007-joeedh/source/blender/blenlib/intern/BLI_memarena.c
    branches/soc-2007-joeedh/source/blender/makesdna/DNA_userdef_types.h
    branches/soc-2007-joeedh/source/blender/render/intern/include/zbuf.h
    branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/rendercore.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
    branches/soc-2007-joeedh/source/blender/src/space.c
    branches/soc-2007-joeedh/source/blender/src/usiblender.c

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h	2007-07-05 01:38:21 UTC (rev 11170)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h	2007-07-05 07:05:16 UTC (rev 11171)
@@ -44,7 +44,7 @@
 struct MemFile;
 
 #define BLENDER_VERSION			244
-#define BLENDER_SUBVERSION		1
+#define BLENDER_SUBVERSION		6
 
 #define BLENDER_MINVERSION		240
 #define BLENDER_MINSUBVERSION	0

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h	2007-07-05 01:38:21 UTC (rev 11170)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h	2007-07-05 07:05:16 UTC (rev 11171)
@@ -221,4 +221,6 @@
 
 #define BASSERT(eval)	if (!(eval)) printf("\nassert \"%s\" in file:\n%s\n on line %d failed.\n\n", #eval, __FILE__, __LINE__)
 
+//#define TCSDEBUG
+
 #endif /* BKE_TILE_H */

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c	2007-07-05 01:38:21 UTC (rev 11170)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c	2007-07-05 07:05:16 UTC (rev 11171)
@@ -48,11 +48,11 @@
 {
 	TCS_TilePool *pool = MEM_callocN(sizeof(TCS_TilePool), "tilepool");
 	
-	pool->max_file_len = 2<<29;
+	pool->max_file_len = 512*1024*1024;
 	pool->maxmem = max_mem_bytes;
 	
 	/*this is to group cache runs so they process no less then 5 megs at a time.*/
-	pool->grace_period = 1024*1024*8; 
+	pool->grace_period = 1024*1024*2; 
 	
 	return pool;
 }
@@ -139,7 +139,7 @@
 	TCS_File *memfile2 = TCS_openmemfile((float)file->length*1.1+12);
 	int r;
 
-	r = compress2(memfile2->ptr, &memfile2->length, file->ptr, file->length, 2);
+	r = compress2(memfile2->ptr, &memfile2->length, file->ptr, file->length, 1);
 	if (r == Z_MEM_ERROR) printf("cz mem error\n");
 	else if (r == Z_BUF_ERROR) printf("cz buf error\n");
 	else if (r == Z_STREAM_ERROR) printf("cz stream error\n");
@@ -185,7 +185,6 @@
 	TCS_TileBuffer *buf = vbuf;
 	TCS_Tile *tile = NULL;
 	TCS_TilePool *pool = NULL;
-	TCS_File *file = NULL;
 	
 	BASSERT(vbuf);
 	tile = buf->getTile(buf, x, y, z);
@@ -200,17 +199,14 @@
 	if (pool->memused > pool->maxmem) TCS_RunCacher(pool);
 	
 	if (tile->is_compressed != 0) {
-		if (tile->is_compressed && !tile->is_written) file = tile->compressed_memfile;
-		else file = tile->file;
-		BASSERT(file);
+		//printf("comp: %p, file: %p, tile->compressed_memfile, tile->file);
 		
-		printf("comp: %p, tfile: %p, file: %p\n", tile->compressed_memfile, tile->file, file);
-		
 		if (tile->is_written) {
 			TCS_File *memfile;
 			unsigned long len;
 			void *mem;
 
+			/*
 			printf("loading a disk tile\n");
 
 			{
@@ -222,17 +218,30 @@
 
 				printf("id: %s \n", s);
 			}
-			
+			*/
+
 			TCS_fseek(tile->file, tile->filepos, SEEK_SET);
 			TCS_fread(&len, sizeof(unsigned long), 1, tile->file);
 			
 			#define BLEH
 			#if defined(USE_COMPRESSION) || defined(BLEH)
 			
-			printf("gettile len: %lud\n", len);
+			#ifdef TCSDEBUG
+				printf("gettile len: %lud\n", len);
+			#endif
 			mem = MEM_callocN(len, "temp array for tcs");
 			
-			TCS_fread(mem, len, 1, file);
+			TCS_fread(mem, len, 1, tile->file);
+			if (tile->file->error_occured) {
+				//error("Error in loading a tile from disk!\n");
+			#ifdef TCSDEBUG
+				printf("Error in loading a tile from disk!\n");
+			#endif
+				G.afbreek = 1;
+				if (mem) MEM_freeN(mem);
+				return NULL;
+			}
+
 			//TCS_fwrite(mem, len, 1, memfile);
 			memfile = TCS_openmemfile(0);
 			memfile->ptr = mem; memfile->length = len; memfile->cursor = 0; memfile->totallocated = len;
@@ -240,37 +249,33 @@
 			TCS_DecompressMemFile(memfile, tile->len);
 			tile->loadFromCache(tile, memfile);
 			TCS_fclose(memfile);			
+
 			#else
 			mem = NULL;
 			memfile = NULL;
 
-			tile->loadFromCache(tile, file);
+			tile->loadFromCache(tile, tile->file);
 			#endif
 			
 			pool->memused += tile->mem_used;
 			//tile->loadFromCache(tile, file);
 			BASSERT(tile->compressed_memfile == NULL);
 		} else {
-			printf("loading a compressed memory tile\n");
+			#ifdef TCSDEBUG
+				printf("loading a compressed memory tile\n");
+			#endif
 			pool->memused -= tile->compressed_memfile->length;			
 			pool->memused += tile->mem_used;
 			
-			TCS_fseek(file, 0, SEEK_SET);
-			TCS_DecompressMemFile(file, tile->len);
-			tile->loadFromCache(tile, file);
+			TCS_fseek(tile->compressed_memfile, 0, SEEK_SET);
+			TCS_DecompressMemFile(tile->compressed_memfile, tile->len);
+			tile->loadFromCache(tile, tile->compressed_memfile);
 
 			BLI_remlink(&pool->compressed_tiles, tile);
 			TCS_fclose(tile->compressed_memfile);
 			tile->compressed_memfile = NULL;
 		}
 		
-		if (file->error_occured) {
-			//error("Error in loading a tile from disk!\n");
-			printf("Error in loading a tile from disk!\n");
-			G.afbreek = 1;
-			return NULL;
-		}
-		
 		tile->is_written = 0;
 		tile->is_compressed = 0;
 		
@@ -309,7 +314,9 @@
 			BASSERT(file);
 			
 			BLI_addtail(&pool->open_files, file);
-			printf("new file->length: %lud\n", file->length);
+			#ifdef TCSDEBUG
+				printf("new file->length: %lud\n", file->length);
+			#endif
 		}
 		BASSERT(file);
 		if (file == NULL) return;
@@ -330,14 +337,17 @@
 	TCS_Tile *tile, *prev;
 	unsigned long mem, memconfirm, i=0;
 	
+	//return;
 	BASSERT(pool);
 	if (!pool) return;
 	
-	printf("running memcacher!\n");
+	#ifdef TCSDEBUG
+		printf("running memcacher!\n");
+	#endif
 	
 	if (pool->memused <= pool->maxmem) return;
 	
-	mem = pool->memused;
+/*
 	for (tile=pool->tiles.first; tile; tile=tile->next) i++;
 	
 	memconfirm = 0;
@@ -349,8 +359,9 @@
 	}
 	
 	printf("memused: %lud, memconfirm (should be a bit smaller): %lud", pool->memused, memconfirm);
-	
+*/	
 	/*first mark tiles to be cached.*/
+	mem = pool->memused;
 	for (tile=pool->tiles.last; tile; i--, tile=tile->prev) {
 		if (tile->prev == pool->tiles.first) {
 			printf("mem in use: %lu\n", pool->memused);
@@ -361,7 +372,9 @@
 		if (tile->len == 0) tile->len = tile->getTileMem(tile);
 		mem -= tile->mem_used;
 
-		printf("marking a tile!\n");
+		#ifdef TCSDEBUG
+			printf("marking a tile!\n");
+		#endif
 		tile->is_compressed = 1;
 		if (mem <= pool->maxmem - pool->grace_period) break;
 	}
@@ -372,13 +385,15 @@
 		if (tile->is_compressed) {
 			int len = tile->len;
 			
-			printf("len: %d\n", len);
+			#ifdef TCSDEBUG
+				printf("len: %d\n", len);
+				printf("compressing a tile\n");
+			#endif
 			tile->compressed_memfile = TCS_openmemfile(len);
 			tile->compressed_memfile->length = 0;
 			
-			printf("compressing a tile\n");
 			tile->saveToCache(tile, tile->compressed_memfile, 0);
-			{
+			if (0) {
 				char s[5];
 				s[4] = 0;
 				//memcpy(s, tile->compressed_memfile->ptr, 4);
@@ -390,13 +405,15 @@
 			}
 			/*paranoia check*/
 			BASSERT(tile->len == tile->compressed_memfile->length);
-			if (tile->len != tile->compressed_memfile->length) printf("bleh %d %d\n", (int)tile->len, (int)tile->compressed_memfile->length);
+			if (tile->len != tile->compressed_memfile->length) printf("dsm tile size calculation function gave bad results! %d %d\n", (int)tile->len, (int)tile->compressed_memfile->length);
 			//tile->len = tile->compressed_memfile->length;
 			
 			TCS_CompressMemFile(tile->compressed_memfile);
 			//BASSERT(tile->compressed_memfile->length != tile->len);
-			printf("compressed tile length: %lud, uncompressed length: %d\n", tile->compressed_memfile->length, tile->len);
-	
+			#ifdef TCSDEBUG
+				printf("compressed tile length: %lud, uncompressed length: %d\n", tile->compressed_memfile->length, tile->len);
+			#endif
+			
 			pool->memused -= tile->mem_used;
 			pool->memused += tile->compressed_memfile->length;
 			
@@ -409,7 +426,9 @@
 	for (tile=pool->compressed_tiles.last; tile; tile=prev) {
 		prev = tile->prev;
 
-		printf("caching a tile to disk\n");
+		#ifdef TCSDEBUG
+			printf("caching a tile to disk\n");
+		#endif
 		
 		if (tile->file == NULL || (tile->buffer->flag & TCS_READONLY)==0) {
 			seek_to_tile_pos(tile, pool);

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c	2007-07-05 01:38:21 UTC (rev 11170)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c	2007-07-05 07:05:16 UTC (rev 11171)
@@ -65,6 +65,7 @@
 	BASSERT(tself && file);
 
 	self->arena = BLI_memarena_new(1<<18);
+	BLI_memarena_use_mapalloc(self->arena);
 	self->sample_rect = BLI_memarena_alloc(self->arena, sizeof(void*)*self->sizex*self->sizey);
 	
 	memset(self->sample_rect, 0, sizeof(void*)*self->sizex*self->sizey);
@@ -172,10 +173,16 @@
 	TCS_fwrite(&tot, sizeof(int), 1, file);
 	BASSERT(file->error_occured == 0);
 	
-	printf("pre read tot: %d\n", tot);
+	#ifdef TCSDEBUG
+		printf("pre read tot: %d\n", tot);
+	#endif
+	
 	TCS_fseek(file, curpos+sizeof(int), SEEK_SET);
 	TCS_fread(&tot, sizeof(int), 1, file);
-	printf("curpos: %d, tot: %d\n", (int)curpos, (int)tot);
+
+	#ifdef TCSDEBUG
+		printf("curpos: %d, tot: %d\n", (int)curpos, (int)tot);
+	#endif
 	
 	/*seek back to tile end position*/
 	TCS_fseek(file, fend, SEEK_SET);
@@ -185,7 +192,9 @@
 	self->arena = NULL;
 	self->sample_rect = NULL;
 	
-	printf("----tile len of doom: %d------\n", (int)(fend - curpos));
+	#ifdef TCSDEBUG
+		printf("----tile len of doom: %d------\n", (int)(fend - curpos));
+	#endif
 	return fend - curpos;
 }
 

Modified: branches/soc-2007-joeedh/source/blender/blenlib/BLI_memarena.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenlib/BLI_memarena.h	2007-07-05 01:38:21 UTC (rev 11170)
+++ branches/soc-2007-joeedh/source/blender/blenlib/BLI_memarena.h	2007-07-05 07:05:16 UTC (rev 11171)
@@ -58,6 +58,7 @@
 struct MemArena*	BLI_memarena_new	(int bufsize);
 void				BLI_memarena_free	(struct MemArena *ma);
 
+void				BLI_memarena_use_mapalloc(struct MemArena *ma);
 void				BLI_memarena_use_calloc (struct MemArena *ma);
 
 void*				BLI_memarena_alloc	(struct MemArena *ma, int size);

Modified: branches/soc-2007-joeedh/source/blender/blenlib/intern/BLI_memarena.c

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list