Cycles / Tile Rendering:

* Added new option to chose the tile order.
In addition to the "Center" method, 4 new methods are available now, like Top -> Bottom and Right -> Left. 

Thanks to Sergey for code review and some tweaks!
This commit is contained in:
Thomas Dinges
2013-01-07 19:55:49 +00:00
parent 999aaa1a51
commit 41c588256b
7 changed files with 86 additions and 15 deletions

View File

@@ -95,6 +95,14 @@ enum_curves_interpolation = (
('CARDINAL', "Cardinal interpolation", "Use cardinal interpolation between segments"), ('CARDINAL', "Cardinal interpolation", "Use cardinal interpolation between segments"),
('BSPLINE', "B-spline interpolation", "Use b-spline interpolation between segments"), ('BSPLINE', "B-spline interpolation", "Use b-spline interpolation between segments"),
) )
enum_tile_order = (
('CENTER', "Center", "Render from center to the edges"),
('RIGHT_TO_LEFT', "Right to Left", "Render from right to left"),
('LEFT_TO_RIGHT', "Left to Right", "Render from left to right"),
('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
)
class CyclesRenderSettings(bpy.types.PropertyGroup): class CyclesRenderSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
@@ -352,6 +360,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Cache last built BVH to disk for faster re-render if no geometry changed", description="Cache last built BVH to disk for faster re-render if no geometry changed",
default=False, default=False,
) )
cls.tile_order = EnumProperty(
name="Tile Order",
description="Tile order for rendering",
items=enum_tile_order,
default='CENTER',
)
cls.use_progressive_refine = BoolProperty( cls.use_progressive_refine = BoolProperty(
name="Progressive Refine", name="Progressive Refine",
description="Instead of rendering each tile until it is finished, " description="Instead of rendering each tile until it is finished, "

View File

@@ -191,7 +191,8 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
sub.prop(rd, "threads") sub.prop(rd, "threads")
sub = col.column(align=True) sub = col.column(align=True)
sub.label(text="Tile Size:") sub.label(text="Tiles:")
sub.prop(cscene, "tile_order", text="")
sub.prop(rd, "tile_x", text="X") sub.prop(rd, "tile_x", text="X")
sub.prop(rd, "tile_y", text="Y") sub.prop(rd, "tile_y", text="Y")

View File

@@ -396,6 +396,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use
params.tile_size = make_int2(tile_x, tile_y); params.tile_size = make_int2(tile_x, tile_y);
} }
params.tile_order = RNA_enum_get(&cscene, "tile_order");
params.start_resolution = get_int(cscene, "preview_start_resolution"); params.start_resolution = get_int(cscene, "preview_start_resolution");

View File

@@ -41,7 +41,7 @@ CCL_NAMESPACE_BEGIN
Session::Session(const SessionParams& params_) Session::Session(const SessionParams& params_)
: params(params_), : params(params_),
tile_manager(params.progressive, params.samples, params.tile_size, params.start_resolution, tile_manager(params.progressive, params.samples, params.tile_size, params.start_resolution,
params.background == false || params.progressive_refine, params.background, params.background == false || params.progressive_refine, params.background, params.tile_order,
max(params.device.multi_devices.size(), 1)), max(params.device.multi_devices.size(), 1)),
stats() stats()
{ {

View File

@@ -51,6 +51,7 @@ public:
bool experimental; bool experimental;
int samples; int samples;
int2 tile_size; int2 tile_size;
int tile_order;
int start_resolution; int start_resolution;
int threads; int threads;

View File

@@ -24,10 +24,11 @@
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
TileManager::TileManager(bool progressive_, int num_samples_, int2 tile_size_, int start_resolution_, TileManager::TileManager(bool progressive_, int num_samples_, int2 tile_size_, int start_resolution_,
bool preserve_tile_device_, bool background_, int num_devices_) bool preserve_tile_device_, bool background_, int tile_order_, int num_devices_)
{ {
progressive = progressive_; progressive = progressive_;
tile_size = tile_size_; tile_size = tile_size_;
tile_order = tile_order_;
start_resolution = start_resolution_; start_resolution = start_resolution_;
num_devices = num_devices_; num_devices = num_devices_;
preserve_tile_device = preserve_tile_device_; preserve_tile_device = preserve_tile_device_;
@@ -165,6 +166,20 @@ void TileManager::set_tiles()
state.buffer.full_height = max(1, params.full_height/resolution); state.buffer.full_height = max(1, params.full_height/resolution);
} }
list<Tile>::iterator TileManager::next_viewport_tile(int device)
{
list<Tile>::iterator iter;
int logical_device = preserve_tile_device? device: 0;
for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
if(iter->device == logical_device && iter->rendering == false)
return iter;
}
return state.tiles.end();
}
list<Tile>::iterator TileManager::next_center_tile(int device) list<Tile>::iterator TileManager::next_center_tile(int device)
{ {
list<Tile>::iterator iter, best = state.tiles.end(); list<Tile>::iterator iter, best = state.tiles.end();
@@ -210,28 +225,53 @@ list<Tile>::iterator TileManager::next_center_tile(int device)
return best; return best;
} }
list<Tile>::iterator TileManager::next_simple_tile(int device) list<Tile>::iterator TileManager::next_simple_tile(int device, int tile_order)
{ {
list<Tile>::iterator iter; list<Tile>::iterator iter, best = state.tiles.end();
int resolution = state.resolution_divider;
int logical_device = preserve_tile_device? device: 0; 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;
for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) { for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
if(iter->device == logical_device && iter->rendering == false) if(iter->device == logical_device && iter->rendering == false) {
return iter; Tile &cur_tile = *iter;
int64_t distx = cordx;
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;
if(distx < mindist) {
best = iter;
mindist = distx;
}
}
} }
return state.tiles.end(); return best;
} }
bool TileManager::next_tile(Tile& tile, int device) bool TileManager::next_tile(Tile& tile, int device)
{ {
list<Tile>::iterator tile_it; list<Tile>::iterator tile_it;
if (background) {
if(background) if(tile_order == TileManager::CENTER)
tile_it = next_center_tile(device); tile_it = next_center_tile(device);
else
tile_it = next_simple_tile(device, tile_order);
}
else else
tile_it = next_simple_tile(device); tile_it = next_viewport_tile(device);
if(tile_it != state.tiles.end()) { if(tile_it != state.tiles.end()) {
tile_it->rendering = true; tile_it->rendering = true;

View File

@@ -59,7 +59,7 @@ public:
} state; } state;
TileManager(bool progressive, int num_samples, int2 tile_size, int start_resolution, TileManager(bool progressive, int num_samples, int2 tile_size, int start_resolution,
bool preserve_tile_device, bool background, int num_devices = 1); bool preserve_tile_device, bool background, int tile_order, int num_devices = 1);
~TileManager(); ~TileManager();
void reset(BufferParams& params, int num_samples); void reset(BufferParams& params, int num_samples);
@@ -69,11 +69,21 @@ public:
bool done(); bool done();
protected: protected:
/* Note: this should match enum_tile_order in properties.py */
enum {
CENTER = 0,
RIGHT_TO_LEFT = 1,
LEFT_TO_RIGHT = 2,
TOP_TO_BOTTOM = 3,
BOTTOM_TO_TOP = 4
} TileOrder;
void set_tiles(); void set_tiles();
bool progressive; bool progressive;
int num_samples; int num_samples;
int2 tile_size; int2 tile_size;
int tile_order;
int start_resolution; int start_resolution;
int num_devices; int num_devices;
@@ -106,9 +116,12 @@ protected:
* mimics behavior of blender internal's tile order * mimics behavior of blender internal's tile order
*/ */
list<Tile>::iterator next_center_tile(int device); list<Tile>::iterator next_center_tile(int device);
/* returns simple tile order */
list<Tile>::iterator next_simple_tile(int device, int tile_order);
/* returns first unhandled tile starting from left bottom corner of the image */ /* returns first unhandled tile (for viewport) */
list<Tile>::iterator next_simple_tile(int device); list<Tile>::iterator next_viewport_tile(int device);
}; };
CCL_NAMESPACE_END CCL_NAMESPACE_END