[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56602] trunk/blender/intern/cycles/render : Cycles / Tile Rendering:

Thomas Dinges blender at dingto.org
Wed May 8 21:49:10 CEST 2013


Revision: 56602
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56602
Author:   dingto
Date:     2013-05-08 19:49:09 +0000 (Wed, 08 May 2013)
Log Message:
-----------
Cycles / Tile Rendering:
* Code refactor of tile ordering to simplify the code and avoid some branching. 
* Changed the Center method, so it really follows center -> corners, instead of the BI method, which was confusing sometimes.

Modified Paths:
--------------
    trunk/blender/intern/cycles/render/tile.cpp
    trunk/blender/intern/cycles/render/tile.h

Modified: trunk/blender/intern/cycles/render/tile.cpp
===================================================================
--- trunk/blender/intern/cycles/render/tile.cpp	2013-05-08 19:37:36 UTC (rev 56601)
+++ trunk/blender/intern/cycles/render/tile.cpp	2013-05-08 19:49:09 UTC (rev 56602)
@@ -180,76 +180,47 @@
 	return state.tiles.end();
 }
 
-list<Tile>::iterator TileManager::next_center_tile(int device)
+list<Tile>::iterator TileManager::next_background_tile(int device, int tile_order)
 {
 	list<Tile>::iterator iter, best = state.tiles.end();
 
 	int resolution = state.resolution_divider;
-	int image_w = max(1, params.width/resolution);
-	int image_h = max(1, params.height/resolution);
-
 	int logical_device = preserve_tile_device? device: 0;
 
-	int64_t centx = image_w / 2, centy = image_h / 2, tot = 1;
-	int64_t mindist = (int64_t) image_w * (int64_t) image_h;
-
-	/* find center of rendering tiles, image center counts for 1 too */
-	for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
-		if(iter->rendering) {
-			Tile &cur_tile = *iter;
-			centx += cur_tile.x + cur_tile.w / 2;
-			centy += cur_tile.y + cur_tile.h / 2;
-			tot++;
-		}
-	}
-
-	centx /= tot;
-	centy /= tot;
-
-	/* closest of the non-rendering tiles */
-	for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
-		if(iter->device == logical_device && iter->rendering == false) {
-			Tile &cur_tile = *iter;
-
-			int64_t distx = centx - (cur_tile.x + cur_tile.w / 2);
-			int64_t disty = centy - (cur_tile.y + cur_tile.h / 2);
-			distx = (int64_t) sqrt((double)distx * distx + disty * disty);
-
-			if(distx < mindist) {
-				best = iter;
-				mindist = distx;
-			}
-		}
-	}
-
-	return best;
-}
-
-list<Tile>::iterator TileManager::next_simple_tile(int device, int tile_order)
-{
-	list<Tile>::iterator iter, best = state.tiles.end();
-
-	int resolution = state.resolution_divider;
-	int logical_device = preserve_tile_device? device: 0;
-
 	int64_t cordx = max(1, params.width/resolution);
 	int64_t cordy = max(1, params.height/resolution);
 	int64_t mindist = cordx * cordy;
+	
+	int64_t centx = cordx / 2, centy = cordy / 2;
 
 	for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
 		if(iter->device == logical_device && iter->rendering == false) {
 			Tile &cur_tile = *iter;
 			
 			int64_t distx = cordx;
+			int64_t disty = cordy;
 			
-			if (tile_order == TileManager::RIGHT_TO_LEFT)
-				distx = cordx - cur_tile.x;
-			else if (tile_order == TileManager::LEFT_TO_RIGHT)
-				distx = cordx + cur_tile.x;
-			else if (tile_order == TileManager::TOP_TO_BOTTOM)
-				distx = cordx - cur_tile.y;
-			else /* TileManager::BOTTOM_TO_TOP */
-				distx = cordx + cur_tile.y;
+			switch (tile_order) {
+				case TileManager::CENTER:
+					distx = centx - (cur_tile.x + cur_tile.w);
+					disty = centy - (cur_tile.y + cur_tile.h);
+					distx = (int64_t) sqrt((double)distx * distx + disty * disty);
+					break;
+				case TileManager::RIGHT_TO_LEFT:
+					distx = cordx - cur_tile.x;
+					break;
+				case TileManager::LEFT_TO_RIGHT:
+					distx = cordx + cur_tile.x;	
+					break;
+				case TileManager::TOP_TO_BOTTOM:
+					distx = cordx - cur_tile.y;
+					break;
+				case TileManager::BOTTOM_TO_TOP:
+					distx = cordx + cur_tile.y;
+					break; 
+				default:
+					break;
+			}
 
 			if(distx < mindist) {
 				best = iter;
@@ -264,12 +235,9 @@
 bool TileManager::next_tile(Tile& tile, int device)
 {
 	list<Tile>::iterator tile_it;
-	if (background) {
-		if(tile_order == TileManager::CENTER)
-			tile_it = next_center_tile(device);
-		else
-			tile_it = next_simple_tile(device, tile_order);
-	}
+	
+	if (background)
+		tile_it = next_background_tile(device, tile_order);
 	else
 		tile_it = next_viewport_tile(device);
 

Modified: trunk/blender/intern/cycles/render/tile.h
===================================================================
--- trunk/blender/intern/cycles/render/tile.h	2013-05-08 19:37:36 UTC (rev 56601)
+++ trunk/blender/intern/cycles/render/tile.h	2013-05-08 19:49:09 UTC (rev 56602)
@@ -114,15 +114,10 @@
 	/* slices image into as much pieces as how many devices are rendering this image */
 	void gen_tiles_sliced();
 
-	/* returns closest tile to center of rendered tiles
-	 * mimics behavior of blender internal's tile order
-	 */
-	list<Tile>::iterator next_center_tile(int device);
-	
-	/* returns simple tile order */
-	list<Tile>::iterator next_simple_tile(int device, int tile_order);
+	/* returns tiles for background render */
+	list<Tile>::iterator next_background_tile(int device, int tile_order);
 
-	/* returns first unhandled tile (for viewport) */
+	/* returns first unhandled tile for viewport render */
 	list<Tile>::iterator next_viewport_tile(int device);
 };
 




More information about the Bf-blender-cvs mailing list