Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/render_scheduler.h
| Show All 17 Lines | |||||
| #include "integrator/adaptive_sampling.h" | #include "integrator/adaptive_sampling.h" | ||||
| #include "integrator/denoiser.h" /* For DenoiseParams. */ | #include "integrator/denoiser.h" /* For DenoiseParams. */ | ||||
| #include "render/buffers.h" | #include "render/buffers.h" | ||||
| #include "util/util_string.h" | #include "util/util_string.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| class SessionParams; | |||||
| class TileManager; | |||||
| class RenderWork { | class RenderWork { | ||||
| public: | public: | ||||
| int resolution_divider = 1; | int resolution_divider = 1; | ||||
| /* Initialize render buffers. | /* Initialize render buffers. | ||||
| * Includes steps like zero-ing the buffer on the device, and optional reading of pixels from the | * Includes steps like zero-ing the buffer on the device, and optional reading of pixels from the | ||||
| * baking target. */ | * baking target. */ | ||||
| bool init_render_buffers = false; | bool init_render_buffers = false; | ||||
| Show All 13 Lines | struct { | ||||
| /* Reset convergency flag when filtering, forcing a re-check of whether pixel did converge. */ | /* Reset convergency flag when filtering, forcing a re-check of whether pixel did converge. */ | ||||
| bool reset = false; | bool reset = false; | ||||
| } adaptive_sampling; | } adaptive_sampling; | ||||
| struct { | struct { | ||||
| bool postprocess = false; | bool postprocess = false; | ||||
| } cryptomatte; | } cryptomatte; | ||||
| /* Work related on the current tile. */ | |||||
| struct { | |||||
| /* Write render buffers of the current tile. | |||||
| * | |||||
| * It is up to the path trace to decide whether writing should happen via user-provided | |||||
| * callback into the rendering software, or via tile manager into a partial file. */ | |||||
| bool write = false; | |||||
| bool denoise = false; | |||||
| } tile; | |||||
| /* Work related on the full-frame render buffer. */ | |||||
| struct { | |||||
| /* Write full render result. | |||||
| * Implies reading the partial file from disk. */ | |||||
| bool write; | |||||
| bool denoise = false; | bool denoise = false; | ||||
| } full; | |||||
| /* Display which is used to visualize render result is to be updated for the new render. */ | /* Display which is used to visualize render result is to be updated for the new render. */ | ||||
| bool update_display = false; | bool update_display = false; | ||||
| /* Re-balance multi-device scheduling after rendering this work. | /* Re-balance multi-device scheduling after rendering this work. | ||||
| * Note that the scheduler does not know anything abouce devices, so if there is only a single | * Note that the scheduler does not know anything abouce devices, so if there is only a single | ||||
| * device used, then it is up for the PathTracer to ignore the balancing. */ | * device used, then it is up for the PathTracer to ignore the balancing. */ | ||||
| bool rebalance = false; | bool rebalance = false; | ||||
| bool write_final_result = false; | |||||
| /* Conversion to bool, to simplify checks about whether there is anything to be done for this | /* Conversion to bool, to simplify checks about whether there is anything to be done for this | ||||
| * work. */ | * work. */ | ||||
| inline operator bool() const | inline operator bool() const | ||||
| { | { | ||||
| return path_trace.num_samples || adaptive_sampling.filter || denoise || update_display; | return path_trace.num_samples || adaptive_sampling.filter || update_display || tile.denoise || | ||||
| tile.write || full.write || full.denoise; | |||||
| } | } | ||||
| }; | }; | ||||
| class RenderScheduler { | class RenderScheduler { | ||||
| public: | public: | ||||
| RenderScheduler(bool headless, bool background, int pixel_size); | RenderScheduler(TileManager &tile_manager, const SessionParams ¶ms); | ||||
| /* Specify whether cryptomatte-related works are to be scheduled. */ | /* Specify whether cryptomatte-related works are to be scheduled. */ | ||||
| void set_need_schedule_cryptomatte(bool need_schedule_cryptomatte); | void set_need_schedule_cryptomatte(bool need_schedule_cryptomatte); | ||||
| /* Allows to disable work re-balancing works, allowing to schedule as much to a single device | /* Allows to disable work re-balancing works, allowing to schedule as much to a single device | ||||
| * as possible. */ | * as possible. */ | ||||
| void set_need_schedule_rebalance(bool need_schedule_rebalance); | void set_need_schedule_rebalance(bool need_schedule_rebalance); | ||||
| bool is_background() const; | bool is_background() const; | ||||
| void set_denoiser_params(const DenoiseParams ¶ms); | void set_denoiser_params(const DenoiseParams ¶ms); | ||||
| void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling); | void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling); | ||||
| bool is_adaptive_sampling_used() const; | |||||
| /* Start sample for path tracing. | /* Start sample for path tracing. | ||||
| * The scheduler will schedule work using this sample as the first one. */ | * The scheduler will schedule work using this sample as the first one. */ | ||||
| void set_start_sample(int start_sample); | void set_start_sample(int start_sample); | ||||
| int get_start_sample() const; | int get_start_sample() const; | ||||
| /* Number of samples to render, starting from start sample. | /* Number of samples to render, starting from start sample. | ||||
| * The scheduler will schedule work in the range of | * The scheduler will schedule work in the range of | ||||
| * [start_sample, start_sample + num_samples - 1], inclusively. */ | * [start_sample, start_sample + num_samples - 1], inclusively. */ | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | protected: | ||||
| /* Update scheduling state for a newely scheduled work. | /* Update scheduling state for a newely scheduled work. | ||||
| * Takes care of things like checking whether work was ever denoised, tile was written and states | * Takes care of things like checking whether work was ever denoised, tile was written and states | ||||
| * like that. */ | * like that. */ | ||||
| void update_state_for_render_work(const RenderWork &render_work); | void update_state_for_render_work(const RenderWork &render_work); | ||||
| /* Returns true if any work was scheduled. */ | /* Returns true if any work was scheduled. */ | ||||
| bool set_postprocess_render_work(RenderWork *render_work); | bool set_postprocess_render_work(RenderWork *render_work); | ||||
| /* Set work which is to be performed after all tiles has been rendered. */ | |||||
| void set_full_frame_render_work(RenderWork *render_work); | |||||
| /* Update start resolution divider based on the accumulated timing information, preserving nice | /* Update start resolution divider based on the accumulated timing information, preserving nice | ||||
| * feeling navigation feel. */ | * feeling navigation feel. */ | ||||
| void update_start_resolution_divider(); | void update_start_resolution_divider(); | ||||
| /* Calculate desired update interval in seconds based on the current timings and settings. | /* Calculate desired update interval in seconds based on the current timings and settings. | ||||
| * Will give an interval which provides good feeling updates during viewport navigation. */ | * Will give an interval which provides good feeling updates during viewport navigation. */ | ||||
| double guess_viewport_navigation_update_interval_in_seconds() const; | double guess_viewport_navigation_update_interval_in_seconds() const; | ||||
| ▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | struct { | ||||
| /* Denotes whether the latest performed rebalance work cause an actual rebalance of work across | /* Denotes whether the latest performed rebalance work cause an actual rebalance of work across | ||||
| * devices. */ | * devices. */ | ||||
| bool last_rebalance_changed = false; | bool last_rebalance_changed = false; | ||||
| /* Threshold for adaptive sampling which will be scheduled to work when not using progressive | /* Threshold for adaptive sampling which will be scheduled to work when not using progressive | ||||
| * noise floor. */ | * noise floor. */ | ||||
| float adaptive_sampling_threshold = 0.0f; | float adaptive_sampling_threshold = 0.0f; | ||||
| bool last_work_was_denoised = false; | bool last_work_tile_was_denoised = false; | ||||
| bool final_result_was_written = false; | bool tile_result_was_written = false; | ||||
| bool postprocess_work_scheduled = false; | bool postprocess_work_scheduled = false; | ||||
| bool full_frame_work_scheduled = false; | |||||
| bool full_frame_was_written = false; | |||||
| bool path_trace_finished = false; | bool path_trace_finished = false; | ||||
| bool time_limit_reached = false; | bool time_limit_reached = false; | ||||
| /* Time at which rendering started and finished. */ | /* Time at which rendering started and finished. */ | ||||
| double start_render_time = 0.0; | double start_render_time = 0.0; | ||||
| double end_render_time = 0.0; | double end_render_time = 0.0; | ||||
| } state_; | } state_; | ||||
| Show All 36 Lines | protected: | ||||
| /* Background (offline) rendering. */ | /* Background (offline) rendering. */ | ||||
| bool background_; | bool background_; | ||||
| /* Pixel size is used to force lower resolution render for final pass. Useful for retina or other | /* Pixel size is used to force lower resolution render for final pass. Useful for retina or other | ||||
| * types of hi-dpi displays. */ | * types of hi-dpi displays. */ | ||||
| int pixel_size_ = 1; | int pixel_size_ = 1; | ||||
| TileManager &tile_manager_; | |||||
| BufferParams buffer_params_; | BufferParams buffer_params_; | ||||
| DenoiseParams denoiser_params_; | DenoiseParams denoiser_params_; | ||||
| AdaptiveSampling adaptive_sampling_; | AdaptiveSampling adaptive_sampling_; | ||||
| /* Progressively lower adaptive sampling threshold level, keeping the image at a uniform noise | /* Progressively lower adaptive sampling threshold level, keeping the image at a uniform noise | ||||
| * level. */ | * level. */ | ||||
| bool use_progressive_noise_floor_ = false; | bool use_progressive_noise_floor_ = false; | ||||
| Show All 21 Lines | |||||