Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/denoising.cpp
| Show All 10 Lines | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "render/denoising.h" | #include "render/denoising.h" | ||||
| #if 0 | |||||
| #include "kernel/filter/filter_defines.h" | # include "kernel/filter/filter_defines.h" | ||||
| #include "util/util_foreach.h" | # include "util/util_foreach.h" | ||||
| #include "util/util_map.h" | # include "util/util_map.h" | ||||
| #include "util/util_system.h" | # include "util/util_system.h" | ||||
| #include "util/util_task.h" | # include "util/util_task.h" | ||||
| #include "util/util_time.h" | # include "util/util_time.h" | ||||
| #include <OpenImageIO/filesystem.h> | # include <OpenImageIO/filesystem.h> | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Utility Functions */ | /* Utility Functions */ | ||||
| static void print_progress(int num, int total, int frame, int num_frames) | static void print_progress(int num, int total, int frame, int num_frames) | ||||
| { | { | ||||
| const char *label = "Denoise Frame "; | const char *label = "Denoise Frame "; | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | bool DenoiseImageLayer::match_channels(int neighbor, | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* Denoise Task */ | /* Denoise Task */ | ||||
| DenoiseTask::DenoiseTask(Device *device, | DenoiseTask::DenoiseTask(Device *device, | ||||
| Denoiser *denoiser, | DenoiserPipeline *denoiser, | ||||
| int frame, | int frame, | ||||
| const vector<int> &neighbor_frames) | const vector<int> &neighbor_frames) | ||||
| : denoiser(denoiser), | : denoiser(denoiser), | ||||
| device(device), | device(device), | ||||
| frame(frame), | frame(frame), | ||||
| neighbor_frames(neighbor_frames), | neighbor_frames(neighbor_frames), | ||||
| current_layer(0), | current_layer(0), | ||||
| input_pixels(device, "filter input buffer", MEM_READ_ONLY), | input_pixels(device, "filter input buffer", MEM_READ_ONLY), | ||||
| ▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | void DenoiseTask::create_task(DeviceTask &task) | ||||
| task.unmap_neighbor_tiles = function_bind(&DenoiseTask::unmap_neighboring_tiles, this, _1); | task.unmap_neighbor_tiles = function_bind(&DenoiseTask::unmap_neighboring_tiles, this, _1); | ||||
| task.release_tile = function_bind(&DenoiseTask::release_tile, this); | task.release_tile = function_bind(&DenoiseTask::release_tile, this); | ||||
| task.get_cancel = function_bind(&DenoiseTask::get_cancel, this); | task.get_cancel = function_bind(&DenoiseTask::get_cancel, this); | ||||
| /* Denoising parameters. */ | /* Denoising parameters. */ | ||||
| task.denoising = denoiser->params; | task.denoising = denoiser->params; | ||||
| task.denoising.type = DENOISER_NLM; | task.denoising.type = DENOISER_NLM; | ||||
| task.denoising.use = true; | task.denoising.use = true; | ||||
| task.denoising.store_passes = false; | |||||
| task.denoising_from_render = false; | task.denoising_from_render = false; | ||||
| task.denoising_frames.resize(neighbor_frames.size()); | task.denoising_frames.resize(neighbor_frames.size()); | ||||
| for (int i = 0; i < neighbor_frames.size(); i++) { | for (int i = 0; i < neighbor_frames.size(); i++) { | ||||
| task.denoising_frames[i] = neighbor_frames[i] - frame; | task.denoising_frames[i] = neighbor_frames[i] - frame; | ||||
| } | } | ||||
| /* Buffer parameters. */ | /* Buffer parameters. */ | ||||
| ▲ Show 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | if (!ok) { | ||||
| OIIO::Filesystem::remove(tmp_filepath); | OIIO::Filesystem::remove(tmp_filepath); | ||||
| } | } | ||||
| return ok; | return ok; | ||||
| } | } | ||||
| /* File pattern handling and outer loop over frames */ | /* File pattern handling and outer loop over frames */ | ||||
| Denoiser::Denoiser(DeviceInfo &device_info) | DenoiserPipeline::DenoiserPipeline(DeviceInfo &device_info) | ||||
| { | { | ||||
| samples_override = 0; | samples_override = 0; | ||||
| tile_size = make_int2(64, 64); | tile_size = make_int2(64, 64); | ||||
| num_frames = 0; | num_frames = 0; | ||||
| /* Initialize task scheduler. */ | /* Initialize task scheduler. */ | ||||
| TaskScheduler::init(); | TaskScheduler::init(); | ||||
| /* Initialize device. */ | /* Initialize device. */ | ||||
| device = Device::create(device_info, stats, profiler, true); | device = Device::create(device_info, stats, profiler, true); | ||||
| DeviceRequestedFeatures req; | device->load_kernels(KERNEL_FEATURE_DENOISING); | ||||
| req.use_denoising = true; | |||||
| device->load_kernels(req); | |||||
| } | } | ||||
| Denoiser::~Denoiser() | DenoiserPipeline::~DenoiserPipeline() | ||||
| { | { | ||||
| delete device; | delete device; | ||||
| TaskScheduler::exit(); | TaskScheduler::exit(); | ||||
| } | } | ||||
| bool Denoiser::run() | bool DenoiserPipeline::run() | ||||
| { | { | ||||
| assert(input.size() == output.size()); | assert(input.size() == output.size()); | ||||
| num_frames = output.size(); | num_frames = output.size(); | ||||
| for (int frame = 0; frame < num_frames; frame++) { | for (int frame = 0; frame < num_frames; frame++) { | ||||
| /* Skip empty output paths. */ | /* Skip empty output paths. */ | ||||
| if (output[frame].empty()) { | if (output[frame].empty()) { | ||||
| Show All 27 Lines | for (int frame = 0; frame < num_frames; frame++) { | ||||
| task.free(); | task.free(); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| #endif | |||||