Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/tile.cpp
| Show All 19 Lines | |||||
| #include "util/util_types.h" | #include "util/util_types.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| namespace { | namespace { | ||||
| class TileComparator { | class TileComparator { | ||||
| public: | public: | ||||
| TileComparator(TileOrder order, int2 center) | TileComparator(TileOrder order_, int2 center_, Tile *tiles_) | ||||
| : order_(order), | : order(order_), | ||||
| center_(center) | center(center_), | ||||
| tiles(tiles_) | |||||
| {} | {} | ||||
| bool operator()(Tile &a, Tile &b) | bool operator()(int a, int b) | ||||
| { | { | ||||
| switch(order_) { | switch(order) { | ||||
| case TILE_CENTER: | case TILE_CENTER: | ||||
| { | { | ||||
| float2 dist_a = make_float2(center_.x - (a.x + a.w/2), | float2 dist_a = make_float2(center.x - (tiles[a].x + tiles[a].w/2), | ||||
| center_.y - (a.y + a.h/2)); | center.y - (tiles[a].y + tiles[a].h/2)); | ||||
| float2 dist_b = make_float2(center_.x - (b.x + b.w/2), | float2 dist_b = make_float2(center.x - (tiles[b].x + tiles[b].w/2), | ||||
| center_.y - (b.y + b.h/2)); | center.y - (tiles[b].y + tiles[b].h/2)); | ||||
| return dot(dist_a, dist_a) < dot(dist_b, dist_b); | return dot(dist_a, dist_a) < dot(dist_b, dist_b); | ||||
| } | } | ||||
| case TILE_LEFT_TO_RIGHT: | case TILE_LEFT_TO_RIGHT: | ||||
| return (a.x == b.x)? (a.y < b.y): (a.x < b.x); | return (tiles[a].x == tiles[b].x)? (tiles[a].y < tiles[b].y): (tiles[a].x < tiles[b].x); | ||||
| case TILE_RIGHT_TO_LEFT: | case TILE_RIGHT_TO_LEFT: | ||||
| return (a.x == b.x)? (a.y < b.y): (a.x > b.x); | return (tiles[a].x == tiles[b].x)? (tiles[a].y < tiles[b].y): (tiles[a].x > tiles[b].x); | ||||
| case TILE_TOP_TO_BOTTOM: | case TILE_TOP_TO_BOTTOM: | ||||
| return (a.y == b.y)? (a.x < b.x): (a.y > b.y); | return (tiles[a].y == tiles[b].y)? (tiles[a].x < tiles[b].x): (tiles[a].y > tiles[b].y); | ||||
| case TILE_BOTTOM_TO_TOP: | case TILE_BOTTOM_TO_TOP: | ||||
| default: | default: | ||||
| return (a.y == b.y)? (a.x < b.x): (a.y < b.y); | return (tiles[a].y == tiles[b].y)? (tiles[a].x < tiles[b].x): (tiles[a].y < tiles[b].y); | ||||
| } | } | ||||
| } | } | ||||
| protected: | protected: | ||||
| TileOrder order_; | TileOrder order; | ||||
| int2 center_; | int2 center; | ||||
| Tile *tiles; | |||||
| }; | }; | ||||
| inline int2 hilbert_index_to_pos(int n, int d) | inline int2 hilbert_index_to_pos(int n, int d) | ||||
| { | { | ||||
| int2 r, xy = make_int2(0, 0); | int2 r, xy = make_int2(0, 0); | ||||
| for(int s = 1; s < n; s *= 2) { | for(int s = 1; s < n; s *= 2) { | ||||
| r.x = (d >> 1) & 1; | r.x = (d >> 1) & 1; | ||||
| r.y = (d ^ r.x) & 1; | r.y = (d ^ r.x) & 1; | ||||
| Show All 24 Lines | TileManager::TileManager(bool progressive_, int num_samples_, int2 tile_size_, int start_resolution_, | ||||
| progressive = progressive_; | progressive = progressive_; | ||||
| tile_size = tile_size_; | tile_size = tile_size_; | ||||
| tile_order = tile_order_; | tile_order = tile_order_; | ||||
| start_resolution = start_resolution_; | start_resolution = start_resolution_; | ||||
| num_samples = num_samples_; | num_samples = num_samples_; | ||||
| num_devices = num_devices_; | num_devices = num_devices_; | ||||
| preserve_tile_device = preserve_tile_device_; | preserve_tile_device = preserve_tile_device_; | ||||
| background = background_; | background = background_; | ||||
| schedule_denoising = false; | |||||
| range_start_sample = 0; | range_start_sample = 0; | ||||
| range_num_samples = -1; | range_num_samples = -1; | ||||
| BufferParams buffer_params; | BufferParams buffer_params; | ||||
| reset(buffer_params, 0); | reset(buffer_params, 0); | ||||
| } | } | ||||
| TileManager::~TileManager() | TileManager::~TileManager() | ||||
| { | { | ||||
| } | } | ||||
| void TileManager::free_device() | |||||
| { | |||||
| if(schedule_denoising) { | |||||
| for(int i = 0; i < state.tiles.size(); i++) { | |||||
| delete state.tiles[i].buffers; | |||||
| state.tiles[i].buffers = NULL; | |||||
| } | |||||
| } | |||||
| } | |||||
| static int get_divider(int w, int h, int start_resolution) | static int get_divider(int w, int h, int start_resolution) | ||||
| { | { | ||||
| int divider = 1; | int divider = 1; | ||||
| if(start_resolution != INT_MAX) { | if(start_resolution != INT_MAX) { | ||||
| while(w*h > start_resolution*start_resolution) { | while(w*h > start_resolution*start_resolution) { | ||||
| w = max(1, w/2); | w = max(1, w/2); | ||||
| h = max(1, h/2); | h = max(1, h/2); | ||||
| divider <<= 1; | divider <<= 1; | ||||
| } | } | ||||
| } | } | ||||
| return divider; | return divider; | ||||
| } | } | ||||
| void TileManager::reset(BufferParams& params_, int num_samples_) | void TileManager::reset(BufferParams& params_, int num_samples_) | ||||
| { | { | ||||
| params = params_; | params = params_; | ||||
| set_samples(num_samples_); | set_samples(num_samples_); | ||||
| state.buffer = BufferParams(); | state.buffer = BufferParams(); | ||||
| state.global_buffers = NULL; | |||||
| state.sample = range_start_sample - 1; | state.sample = range_start_sample - 1; | ||||
| state.num_tiles = 0; | state.num_tiles = 0; | ||||
| state.num_samples = 0; | state.num_samples = 0; | ||||
| state.resolution_divider = get_divider(params.width, params.height, start_resolution); | state.resolution_divider = get_divider(params.width, params.height, start_resolution); | ||||
| state.render_tiles.clear(); | |||||
| state.denoising_tiles.clear(); | |||||
| state.tiles.clear(); | state.tiles.clear(); | ||||
| } | } | ||||
| void TileManager::set_samples(int num_samples_) | void TileManager::set_samples(int num_samples_) | ||||
| { | { | ||||
| num_samples = num_samples_; | num_samples = num_samples_; | ||||
| /* No real progress indication is possible when using unlimited samples. */ | /* No real progress indication is possible when using unlimited samples. */ | ||||
| if(num_samples == INT_MAX) { | if(num_samples == INT_MAX) { | ||||
| state.total_pixel_samples = 0; | state.total_pixel_samples = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| uint64_t pixel_samples = 0; | uint64_t pixel_samples = 0; | ||||
| /* While rendering in the viewport, the initial preview resolution is increased to the native resolution | /* While rendering in the viewport, the initial preview resolution is increased to the native resolution | ||||
| * before the actual rendering begins. Therefore, additional pixel samples will be rendered. */ | * before the actual rendering begins. Therefore, additional pixel samples will be rendered. */ | ||||
| int divider = get_divider(params.width, params.height, start_resolution) / 2; | int divider = get_divider(params.width, params.height, start_resolution) / 2; | ||||
| while(divider > 1) { | while(divider > 1) { | ||||
| int image_w = max(1, params.width/divider); | int image_w = max(1, params.width/divider); | ||||
| int image_h = max(1, params.height/divider); | int image_h = max(1, params.height/divider); | ||||
| pixel_samples += image_w * image_h; | pixel_samples += image_w * image_h; | ||||
| divider >>= 1; | divider >>= 1; | ||||
| } | } | ||||
| state.total_pixel_samples = pixel_samples + (uint64_t)get_num_effective_samples() * params.width*params.height; | state.total_pixel_samples = pixel_samples + (uint64_t)get_num_effective_samples() * params.width*params.height; | ||||
| if(schedule_denoising) { | |||||
| state.total_pixel_samples += params.width*params.height; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| /* If sliced is false, splits image into tiles and assigns equal amount of tiles to every render device. | /* If sliced is false, splits image into tiles and assigns equal amount of tiles to every render device. | ||||
| * If sliced is true, slice image into as much pieces as how many devices are rendering this image. */ | * If sliced is true, slice image into as much pieces as how many devices are rendering this image. */ | ||||
| int TileManager::gen_tiles(bool sliced) | int TileManager::gen_tiles(bool sliced) | ||||
| { | { | ||||
| int resolution = state.resolution_divider; | int resolution = state.resolution_divider; | ||||
| int image_w = max(1, params.width/resolution); | int image_w = max(1, params.width/resolution); | ||||
| int image_h = max(1, params.height/resolution); | int image_h = max(1, params.height/resolution); | ||||
| int2 center = make_int2(image_w/2, image_h/2); | int2 center = make_int2(image_w/2, image_h/2); | ||||
| state.tiles.clear(); | |||||
| int num_logical_devices = preserve_tile_device? num_devices: 1; | int num_logical_devices = preserve_tile_device? num_devices: 1; | ||||
| int num = min(image_h, num_logical_devices); | int num = min(image_h, num_logical_devices); | ||||
| int slice_num = sliced? num: 1; | int slice_num = sliced? num: 1; | ||||
| int tile_index = 0; | int tile_w = (tile_size.x >= image_w) ? 1 : (image_w + tile_size.x - 1) / tile_size.x; | ||||
| state.tiles.clear(); | state.tiles.clear(); | ||||
| state.tiles.resize(num); | state.render_tiles.clear(); | ||||
| vector<list<Tile> >::iterator tile_list = state.tiles.begin(); | state.denoising_tiles.clear(); | ||||
| state.render_tiles.resize(num); | |||||
| state.denoising_tiles.resize(num); | |||||
| state.tile_stride = tile_w; | |||||
| vector<list<int> >::iterator tile_list; | |||||
| tile_list = state.render_tiles.begin(); | |||||
| if(tile_order == TILE_HILBERT_SPIRAL) { | if(tile_order == TILE_HILBERT_SPIRAL) { | ||||
| assert(!sliced); | assert(!sliced); | ||||
| int tile_h = (tile_size.y >= image_h) ? 1 : (image_h + tile_size.y - 1) / tile_size.y; | |||||
| state.tiles.resize(tile_w*tile_h); | |||||
| /* Size of blocks in tiles, must be a power of 2 */ | /* Size of blocks in tiles, must be a power of 2 */ | ||||
| const int hilbert_size = (max(tile_size.x, tile_size.y) <= 12)? 8: 4; | const int hilbert_size = (max(tile_size.x, tile_size.y) <= 12)? 8: 4; | ||||
| int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x; | |||||
| int tile_h = (tile_size.y >= image_h)? 1: (image_h + tile_size.y - 1)/tile_size.y; | |||||
| int tiles_per_device = (tile_w * tile_h + num - 1) / num; | int tiles_per_device = (tile_w * tile_h + num - 1) / num; | ||||
| int cur_device = 0, cur_tiles = 0; | int cur_device = 0, cur_tiles = 0; | ||||
| int2 block_size = tile_size * make_int2(hilbert_size, hilbert_size); | int2 block_size = tile_size * make_int2(hilbert_size, hilbert_size); | ||||
| /* Number of blocks to fill the image */ | /* Number of blocks to fill the image */ | ||||
| int blocks_x = (block_size.x >= image_w)? 1: (image_w + block_size.x - 1)/block_size.x; | int blocks_x = (block_size.x >= image_w)? 1: (image_w + block_size.x - 1)/block_size.x; | ||||
| int blocks_y = (block_size.y >= image_h)? 1: (image_h + block_size.y - 1)/block_size.y; | int blocks_y = (block_size.y >= image_h)? 1: (image_h + block_size.y - 1)/block_size.y; | ||||
| int n = max(blocks_x, blocks_y) | 0x1; /* Side length of the spiral (must be odd) */ | int n = max(blocks_x, blocks_y) | 0x1; /* Side length of the spiral (must be odd) */ | ||||
| Show All 21 Lines | for(int i = 0;;) { | ||||
| tile = make_int2(hilbert_size-1-hilbert_pos.x, hilbert_size-1-hilbert_pos.y); | tile = make_int2(hilbert_size-1-hilbert_pos.x, hilbert_size-1-hilbert_pos.y); | ||||
| } | } | ||||
| int2 pos = block*block_size + tile*tile_size + offset; | int2 pos = block*block_size + tile*tile_size + offset; | ||||
| /* Only add tiles which are in the image (tiles outside of the image can be generated since the spiral is always square). */ | /* Only add tiles which are in the image (tiles outside of the image can be generated since the spiral is always square). */ | ||||
| if(pos.x >= 0 && pos.y >= 0 && pos.x < image_w && pos.y < image_h) { | if(pos.x >= 0 && pos.y >= 0 && pos.x < image_w && pos.y < image_h) { | ||||
| int w = min(tile_size.x, image_w - pos.x); | int w = min(tile_size.x, image_w - pos.x); | ||||
| int h = min(tile_size.y, image_h - pos.y); | int h = min(tile_size.y, image_h - pos.y); | ||||
| tile_list->push_front(Tile(tile_index, pos.x, pos.y, w, h, cur_device)); | int2 ipos = pos / tile_size; | ||||
| int idx = ipos.y*tile_w + ipos.x; | |||||
| state.tiles[idx] = Tile(idx, pos.x, pos.y, w, h, cur_device, Tile::RENDER, state.global_buffers); | |||||
| tile_list->push_front(idx); | |||||
| cur_tiles++; | cur_tiles++; | ||||
| tile_index++; | |||||
| if(cur_tiles == tiles_per_device) { | if(cur_tiles == tiles_per_device) { | ||||
| tile_list++; | tile_list++; | ||||
| cur_tiles = 0; | cur_tiles = 0; | ||||
| cur_device++; | cur_device++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 27 Lines | for(int i = 0;;) { | ||||
| block.x--; | block.x--; | ||||
| if(block.x == i+1) { | if(block.x == i+1) { | ||||
| dir = DIRECTION_UP; | dir = DIRECTION_UP; | ||||
| i++; | i++; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return tile_index; | return tile_w*tile_h; | ||||
| } | } | ||||
| int idx = 0; | |||||
| for(int slice = 0; slice < slice_num; slice++) { | for(int slice = 0; slice < slice_num; slice++) { | ||||
| int slice_y = (image_h/slice_num)*slice; | int slice_y = (image_h/slice_num)*slice; | ||||
| int slice_h = (slice == slice_num-1)? image_h - slice*(image_h/slice_num): image_h/slice_num; | int slice_h = (slice == slice_num-1)? image_h - slice*(image_h/slice_num): image_h/slice_num; | ||||
| int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x; | |||||
| int tile_h = (tile_size.y >= slice_h)? 1: (slice_h + tile_size.y - 1)/tile_size.y; | int tile_h = (tile_size.y >= slice_h)? 1: (slice_h + tile_size.y - 1)/tile_size.y; | ||||
| int tiles_per_device = (tile_w * tile_h + num - 1) / num; | int tiles_per_device = (tile_w * tile_h + num - 1) / num; | ||||
| int cur_device = 0, cur_tiles = 0; | int cur_device = 0, cur_tiles = 0; | ||||
| for(int tile_y = 0; tile_y < tile_h; tile_y++) { | for(int tile_y = 0; tile_y < tile_h; tile_y++) { | ||||
| for(int tile_x = 0; tile_x < tile_w; tile_x++, tile_index++) { | for(int tile_x = 0; tile_x < tile_w; tile_x++, idx++) { | ||||
| int x = tile_x * tile_size.x; | int x = tile_x * tile_size.x; | ||||
| int y = tile_y * tile_size.y; | int y = tile_y * tile_size.y; | ||||
| int w = (tile_x == tile_w-1)? image_w - x: tile_size.x; | int w = (tile_x == tile_w-1)? image_w - x: tile_size.x; | ||||
| int h = (tile_y == tile_h-1)? slice_h - y: tile_size.y; | int h = (tile_y == tile_h-1)? slice_h - y: tile_size.y; | ||||
| tile_list->push_back(Tile(tile_index, x, y + slice_y, w, h, sliced? slice: cur_device)); | state.tiles.push_back(Tile(idx, x, y + slice_y, w, h, sliced? slice: cur_device, Tile::RENDER, state.global_buffers)); | ||||
| tile_list->push_back(idx); | |||||
| if(!sliced) { | if(!sliced) { | ||||
| cur_tiles++; | cur_tiles++; | ||||
| if(cur_tiles == tiles_per_device) { | if(cur_tiles == tiles_per_device) { | ||||
| /* Tiles are already generated in Bottom-to-Top order, so no sort is necessary in that case. */ | /* Tiles are already generated in Bottom-to-Top order, so no sort is necessary in that case. */ | ||||
| if(tile_order != TILE_BOTTOM_TO_TOP) { | if(tile_order != TILE_BOTTOM_TO_TOP) { | ||||
| tile_list->sort(TileComparator(tile_order, center)); | tile_list->sort(TileComparator(tile_order, center, &state.tiles[0])); | ||||
| } | } | ||||
| tile_list++; | tile_list++; | ||||
| cur_tiles = 0; | cur_tiles = 0; | ||||
| cur_device++; | cur_device++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if(sliced) { | if(sliced) { | ||||
| tile_list++; | tile_list++; | ||||
| } | } | ||||
| } | } | ||||
| return tile_index; | return idx; | ||||
| } | } | ||||
| void TileManager::set_tiles() | void TileManager::set_tiles() | ||||
| { | { | ||||
| int resolution = state.resolution_divider; | int resolution = state.resolution_divider; | ||||
| int image_w = max(1, params.width/resolution); | int image_w = max(1, params.width/resolution); | ||||
| int image_h = max(1, params.height/resolution); | int image_h = max(1, params.height/resolution); | ||||
| state.num_tiles = gen_tiles(!background); | state.num_tiles = gen_tiles(!background); | ||||
| state.buffer.width = image_w; | state.buffer.width = image_w; | ||||
| state.buffer.height = image_h; | state.buffer.height = image_h; | ||||
| state.buffer.full_x = params.full_x/resolution; | state.buffer.full_x = params.full_x/resolution; | ||||
| state.buffer.full_y = params.full_y/resolution; | state.buffer.full_y = params.full_y/resolution; | ||||
| state.buffer.full_width = max(1, params.full_width/resolution); | state.buffer.full_width = max(1, params.full_width/resolution); | ||||
| state.buffer.full_height = max(1, params.full_height/resolution); | state.buffer.full_height = max(1, params.full_height/resolution); | ||||
| } | } | ||||
| bool TileManager::next_tile(Tile& tile, int device) | /* Returns whether the tile should be written (and freed if no denoising is used) instead of updating. */ | ||||
| bool TileManager::return_tile(int index, bool &delete_tile) | |||||
brecht: Maybe rename to `finish_tile`? Seems a bit more clear to me. | |||||
| { | |||||
| int resolution = state.resolution_divider; | |||||
| int image_w = max(1, params.width/resolution); | |||||
| int image_h = max(1, params.height/resolution); | |||||
| int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x; | |||||
| int tile_h = (tile_size.y >= image_h)? 1: (image_h + tile_size.y - 1)/tile_size.y; | |||||
| int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1, 0}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1, 0}; | |||||
| delete_tile = false; | |||||
| switch(state.tiles[index].state) { | |||||
| case Tile::RENDER: | |||||
| { | |||||
| if(!schedule_denoising) { | |||||
| state.tiles[index].state = Tile::DONE; | |||||
| delete_tile = true; | |||||
| return true; | |||||
| } | |||||
| state.tiles[index].state = Tile::RENDERED; | |||||
| /* For each neighbor and the tile itself, check whether all of its neighbors have been rendered. If yes, it can be denoised. */ | |||||
| for(int n = 0; n < 9; n++) { | |||||
| int nx = state.tiles[index].x/tile_size.x + dx[n], ny = state.tiles[index].y/tile_size.y + dy[n]; | |||||
brechtUnsubmitted Done Inline ActionsWould prefer to split this and similar code in this function over two lines. brecht: Would prefer to split this and similar code in this function over two lines. | |||||
| if(nx < 0 || ny < 0 || nx >= tile_w || ny >= tile_h) | |||||
| continue; | |||||
| int nindex = ny*state.tile_stride + nx; | |||||
| if(state.tiles[nindex].state != Tile::RENDERED) | |||||
| continue; | |||||
| bool can_be_denoised = true; | |||||
| for(int nn = 0; nn < 8; nn++) { | |||||
| int nnx = state.tiles[nindex].x/tile_size.x + dx[nn], nny = state.tiles[nindex].y/tile_size.y + dy[nn]; | |||||
| if(nnx < 0 || nny < 0 || nnx >= tile_w || nny >= tile_h) | |||||
| continue; | |||||
| int nnindex = nny*state.tile_stride + nnx; | |||||
| if(state.tiles[nnindex].state < Tile::RENDERED) { | |||||
| can_be_denoised = false; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if(can_be_denoised) { | |||||
| state.tiles[nindex].state = Tile::DENOISE; | |||||
| state.denoising_tiles[state.tiles[nindex].device].push_back(nindex); | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| case Tile::DENOISE: | |||||
| { | |||||
| state.tiles[index].state = Tile::DENOISED; | |||||
| /* For each neighbor and the tile itself, check whether all of its neighbors have been denoised. If yes, it can be freed. */ | |||||
| for(int n = 0; n < 9; n++) { | |||||
| int nx = state.tiles[index].x/tile_size.x + dx[n], ny = state.tiles[index].y/tile_size.y + dy[n]; | |||||
| if(nx < 0 || ny < 0 || nx >= tile_w || ny >= tile_h) | |||||
| continue; | |||||
| int nindex = ny*state.tile_stride + nx; | |||||
| if(state.tiles[nindex].state != Tile::DENOISED) | |||||
| continue; | |||||
| bool can_be_freed = true; | |||||
| for(int nn = 0; nn < 8; nn++) { | |||||
| int nnx = state.tiles[nindex].x/tile_size.x + dx[nn], nny = state.tiles[nindex].y/tile_size.y + dy[nn]; | |||||
| if(nnx < 0 || nny < 0 || nnx >= tile_w || nny >= tile_h) | |||||
| continue; | |||||
| int nnindex = nny*state.tile_stride + nnx; | |||||
| if(state.tiles[nnindex].state < Tile::DENOISED) { | |||||
| can_be_freed = false; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if(can_be_freed) { | |||||
| state.tiles[nindex].state = Tile::DONE; | |||||
| /* It can happen that the tile just finished denoising and already can be freed here. | |||||
| * However, in that case it still has to be written before deleting, so we can't delete it here. */ | |||||
| if(n == 8) { | |||||
| delete_tile = true; | |||||
| } | |||||
| else { | |||||
| delete state.tiles[nindex].buffers; | |||||
| state.tiles[nindex].buffers = NULL; | |||||
| } | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| default: | |||||
| assert(false); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| bool TileManager::next_tile(Tile* &tile, int device) | |||||
| { | { | ||||
| int logical_device = preserve_tile_device? device: 0; | int logical_device = preserve_tile_device? device: 0; | ||||
| if((logical_device >= state.tiles.size()) || state.tiles[logical_device].empty()) | if(logical_device >= state.render_tiles.size()) | ||||
| return false; | |||||
| if(!state.denoising_tiles[logical_device].empty()) { | |||||
| int idx = state.denoising_tiles[logical_device].front(); | |||||
| state.denoising_tiles[logical_device].pop_front(); | |||||
| tile = &state.tiles[idx]; | |||||
| return true; | |||||
| } | |||||
| if(state.render_tiles[logical_device].empty()) | |||||
| return false; | return false; | ||||
| tile = Tile(state.tiles[logical_device].front()); | int idx = state.render_tiles[logical_device].front(); | ||||
| state.tiles[logical_device].pop_front(); | state.render_tiles[logical_device].pop_front(); | ||||
| tile = &state.tiles[idx]; | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool TileManager::done() | bool TileManager::done() | ||||
| { | { | ||||
| int end_sample = (range_num_samples == -1) | int end_sample = (range_num_samples == -1) | ||||
| ? num_samples | ? num_samples | ||||
| : range_start_sample + range_num_samples; | : range_start_sample + range_num_samples; | ||||
| Show All 40 Lines | |||||
Maybe rename to finish_tile? Seems a bit more clear to me.