Skip to content

Commit

Permalink
create checkpoint settings in the frame
Browse files Browse the repository at this point in the history
  • Loading branch information
oktomus committed Aug 1, 2018
1 parent 06de357 commit 89a342f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/appleseed.cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,23 +336,25 @@ namespace
apply_visibility_command_line_options(assembly, show_filter, hide_filter);
}

bool apply_checkpoint_command_line_option(ParamArray& params)
bool apply_checkpoint_command_line_option(Project& project)
{
if (g_cl.m_checkpoint.is_set())
{
if (!g_cl.m_output.is_set())
{
LOG_ERROR(g_logger, "ouput path must be specified when using checkpoints");
set_frame_parameter(project, "checkpoint", "off");
return false;
}

const char* file_path = g_cl.m_output.value().c_str();
LOG_DEBUG(g_logger, "will save checkpoint to %s", file_path);

params.insert_path("generic_frame_renderer.checkpoint", true);
params.insert_path("generic_frame_renderer.checkpoint_path", file_path);
set_frame_parameter(project, "checkpoint", "on");
set_frame_parameter(project, "checkpoint_path", file_path);
}

set_frame_parameter(project, "checkpoint", "off");

return true;
}

Expand Down Expand Up @@ -418,7 +420,7 @@ namespace
}

// Apply --checkpoint option.
if (!apply_checkpoint_command_line_option(params))
if (!apply_checkpoint_command_line_option(project))
return false;

// Apply --parameter options.
Expand Down
33 changes: 31 additions & 2 deletions src/appleseed/renderer/modeling/frame/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ struct Frame::Impl
AABB2u m_crop_window;
ParamArray m_render_info;
DenoisingMode m_denoising_mode;
bool m_checkpoint;
string m_checkpoint_path;

// Child entities.
AOVContainer m_aovs;
Expand Down Expand Up @@ -216,7 +218,8 @@ void Frame::print_settings()
" filter %s\n"
" filter size %f\n"
" crop window (%s, %s)-(%s, %s)\n"
" denoising mode %s",
" denoising mode %s\n"
" checkpoint %s",
get_path().c_str(),
camera_name ? camera_name : "none",
pretty_uint(impl->m_frame_width).c_str(),
Expand All @@ -230,7 +233,8 @@ void Frame::print_settings()
pretty_uint(impl->m_crop_window.max[0]).c_str(),
pretty_uint(impl->m_crop_window.max[1]).c_str(),
impl->m_denoising_mode == DenoisingMode::Off ? "off" :
impl->m_denoising_mode == DenoisingMode::WriteOutputs ? "write outputs" : "denoise");
impl->m_denoising_mode == DenoisingMode::WriteOutputs ? "write outputs" : "denoise",
impl->m_checkpoint ? impl->m_checkpoint_path.c_str() : "off");
}

AOVContainer& Frame::aovs() const
Expand Down Expand Up @@ -922,6 +926,31 @@ void Frame::extract_parameters()
impl->m_denoising_mode = DenoisingMode::Off;
}
}

// Retrieve checkpoint parameters.
{
const string checkpoint = m_params.get_optional<string>("checkpoint", "off");
const string checkpoint_path = m_params.get_optional<string>("checkpoint_path", "");

if (checkpoint == "off")
{
impl->m_checkpoint = false;
}
else if (checkpoint == "on")
{
impl->m_checkpoint = true;
impl->m_checkpoint_path = checkpoint_path;
}
else
{
RENDERER_LOG_ERROR(
"invalid value \"%s\" for parameter \"%s\", using default value \"%s\".",
checkpoint.c_str(),
"checkpoint",
"off");
impl->m_checkpoint = false;
}
}
}


Expand Down

0 comments on commit 89a342f

Please sign in to comment.