Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/tile.cpp
| Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | void TileManager::reset(BufferParams ¶ms_, int num_samples_) | ||||
| params = params_; | params = params_; | ||||
| set_samples(num_samples_); | set_samples(num_samples_); | ||||
| state.buffer = BufferParams(); | state.buffer = BufferParams(); | ||||
| 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.get_width(), params.get_height(), start_resolution); | |||||
| state.render_tiles.clear(); | state.render_tiles.clear(); | ||||
| state.denoising_tiles.clear(); | state.denoising_tiles.clear(); | ||||
| device_free(); | device_free(); | ||||
| } | } | ||||
| 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 | /* 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 | * resolution before the actual rendering begins. Therefore, additional pixel samples will be | ||||
| * rendered. */ | * rendered. */ | ||||
| int divider = max(get_divider(params.width, params.height, start_resolution) / 2, pixel_size); | int divider = max(get_divider(params.get_width(), params.get_height(), start_resolution) / 2, | ||||
| pixel_size); | |||||
| while (divider > pixel_size) { | while (divider > pixel_size) { | ||||
| int image_w = max(1, params.width / divider); | int image_w = max(1, params.get_width() / divider); | ||||
| int image_h = max(1, params.height / divider); | int image_h = max(1, params.get_height() / divider); | ||||
| pixel_samples += image_w * image_h; | pixel_samples += image_w * image_h; | ||||
| divider >>= 1; | divider >>= 1; | ||||
| } | } | ||||
| int image_w = max(1, params.width / divider); | int image_w = max(1, params.get_width() / divider); | ||||
| int image_h = max(1, params.height / divider); | int image_h = max(1, params.get_height() / divider); | ||||
| state.total_pixel_samples = pixel_samples + | state.total_pixel_samples = pixel_samples + | ||||
| (uint64_t)get_num_effective_samples() * image_w * image_h; | (uint64_t)get_num_effective_samples() * image_w * image_h; | ||||
| if (schedule_denoising) { | if (schedule_denoising) { | ||||
| state.total_pixel_samples += params.width * params.height; | state.total_pixel_samples += params.get_width() * params.get_height(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* If sliced is false, splits image into tiles and assigns equal amount of tiles to every render | /* 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 | * device. If sliced is true, slice image into as much pieces as how many devices are rendering | ||||
| * this image. */ | * 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.get_width() / resolution); | ||||
| int image_h = max(1, params.height / resolution); | int image_h = max(1, params.get_height() / resolution); | ||||
| int2 center = make_int2(image_w / 2, image_h / 2); | int2 center = make_int2(image_w / 2, image_h / 2); | ||||
| int num = preserve_tile_device || sliced ? min(image_h, num_devices) : 1; | int num = preserve_tile_device || sliced ? min(image_h, num_devices) : 1; | ||||
| int slice_num = sliced ? num : 1; | int slice_num = sliced ? num : 1; | ||||
| int tile_w = (tile_size.x >= image_w) ? 1 : divide_up(image_w, tile_size.x); | int tile_w = (tile_size.x >= image_w) ? 1 : divide_up(image_w, tile_size.x); | ||||
| device_free(); | device_free(); | ||||
| state.render_tiles.clear(); | state.render_tiles.clear(); | ||||
| ▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | foreach (Tile &tile, state.tiles) { | ||||
| tile.state = Tile::RENDER; | tile.state = Tile::RENDER; | ||||
| state.render_tiles[tile.device].push_back(tile.index); | state.render_tiles[tile.device].push_back(tile.index); | ||||
| } | } | ||||
| } | } | ||||
| 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.get_width() / resolution); | ||||
| int image_h = max(1, params.height / resolution); | int image_h = max(1, params.get_height() / resolution); | ||||
| state.num_tiles = gen_tiles(!background); | state.num_tiles = gen_tiles(!background); | ||||
| state.buffer.width = image_w; | state.buffer.set_width(image_w); | ||||
| state.buffer.height = image_h; | state.buffer.set_height(image_h); | ||||
| state.buffer.full_x = params.full_x / resolution; | state.buffer.set_full_x(params.get_full_x() / resolution); | ||||
| state.buffer.full_y = params.full_y / resolution; | state.buffer.set_full_y(params.get_full_y() / resolution); | ||||
| state.buffer.full_width = max(1, params.full_width / resolution); | state.buffer.set_full_width(max(1, params.get_full_width() / resolution)); | ||||
| state.buffer.full_height = max(1, params.full_height / resolution); | state.buffer.set_full_height(max(1, params.get_full_height() / resolution)); | ||||
| } | } | ||||
| int TileManager::get_neighbor_index(int index, int neighbor) | int TileManager::get_neighbor_index(int index, int neighbor) | ||||
| { | { | ||||
| /* Neighbor indices: | /* Neighbor indices: | ||||
| * 0 1 2 | * 0 1 2 | ||||
| * 3 4 5 | * 3 4 5 | ||||
| * 6 7 8 | * 6 7 8 | ||||
| */ | */ | ||||
| static const int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; | static const int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; | ||||
| static const int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; | static const int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; | ||||
| int resolution = state.resolution_divider; | int resolution = state.resolution_divider; | ||||
| int image_w = max(1, params.width / resolution); | int image_w = max(1, params.get_width() / resolution); | ||||
| int image_h = max(1, params.height / resolution); | int image_h = max(1, params.get_height() / resolution); | ||||
| int num = min(image_h, num_devices); | int num = min(image_h, num_devices); | ||||
| int slice_num = !background ? num : 1; | int slice_num = !background ? num : 1; | ||||
| int slice_h = image_h / slice_num; | int slice_h = image_h / slice_num; | ||||
| int tile_w = (tile_size.x >= image_w) ? 1 : divide_up(image_w, tile_size.x); | int tile_w = (tile_size.x >= image_w) ? 1 : divide_up(image_w, tile_size.x); | ||||
| int tile_h = (tile_size.y >= slice_h) ? 1 : divide_up(slice_h, tile_size.y); | int tile_h = (tile_size.y >= slice_h) ? 1 : divide_up(slice_h, tile_size.y); | ||||
| ▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines | |||||