Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/path_trace.h
| Show All 31 Lines | |||||
| class Device; | class Device; | ||||
| class DeviceScene; | class DeviceScene; | ||||
| class Film; | class Film; | ||||
| class RenderBuffers; | class RenderBuffers; | ||||
| class RenderScheduler; | class RenderScheduler; | ||||
| class RenderWork; | class RenderWork; | ||||
| class Progress; | class Progress; | ||||
| class GPUDisplay; | class GPUDisplay; | ||||
| class TileManager; | |||||
| /* PathTrace class takes care of kernel graph and scheduling on a (multi)device. It takes care of | /* PathTrace class takes care of kernel graph and scheduling on a (multi)device. It takes care of | ||||
| * all the common steps of path tracing which are not device-specific. The list of tasks includes | * all the common steps of path tracing which are not device-specific. The list of tasks includes | ||||
| * but is not limited to: | * but is not limited to: | ||||
| * - Kernel graph. | * - Kernel graph. | ||||
| * - Scheduling logic. | * - Scheduling logic. | ||||
| * - Queues management. | * - Queues management. | ||||
| * - Adaptive stopping. */ | * - Adaptive stopping. */ | ||||
| class PathTrace { | class PathTrace { | ||||
| public: | public: | ||||
| /* Render scheduler is used to report timing information and access things like start/finish | /* Render scheduler is used to report timing information and access things like start/finish | ||||
| * sample. */ | * sample. */ | ||||
| PathTrace(Device *device, | PathTrace(Device *device, | ||||
| Film *film, | Film *film, | ||||
| DeviceScene *device_scene, | DeviceScene *device_scene, | ||||
| RenderScheduler &render_scheduler); | RenderScheduler &render_scheduler, | ||||
| TileManager &tile_manager); | |||||
| /* Create devices and load kernels which are created on-demand (for example, denoising devices). | /* Create devices and load kernels which are created on-demand (for example, denoising devices). | ||||
| * The progress is reported to the currently configure progress object (via `set_progress`). */ | * The progress is reported to the currently configure progress object (via `set_progress`). */ | ||||
| void load_kernels(); | void load_kernels(); | ||||
| /* Allocate working memory. This runs before allocating scene memory so that we can estimate | /* Allocate working memory. This runs before allocating scene memory so that we can estimate | ||||
| * more accurately which scene device memory may need to allocated on the host. */ | * more accurately which scene device memory may need to allocated on the host. */ | ||||
| void alloc_work_memory(); | void alloc_work_memory(); | ||||
| Show All 37 Lines | public: | ||||
| /* Cancel rendering process as soon as possible, without waiting for full tile to be sampled. | /* Cancel rendering process as soon as possible, without waiting for full tile to be sampled. | ||||
| * Used in cases like reset of render session. | * Used in cases like reset of render session. | ||||
| * | * | ||||
| * This is a blockign call, which returns as soon as there is no running `render_samples()` call. | * This is a blockign call, which returns as soon as there is no running `render_samples()` call. | ||||
| */ | */ | ||||
| void cancel(); | void cancel(); | ||||
| /* Copy an entire render buffer to/from the oath trace. */ | /* Copy an entire render buffer to/from the path trace. */ | ||||
| /* Copy happens via CPU side buffer: data will be copied from every device of the path trace, and | /* Copy happens via CPU side buffer: data will be copied from every device of the path trace, and | ||||
| * the data will be copied to the device of the given render buffers. */ | * the data will be copied to the device of the given render buffers. */ | ||||
| void copy_to_render_buffers(RenderBuffers *render_buffers); | void copy_to_render_buffers(RenderBuffers *render_buffers); | ||||
| /* Copy happens via CPU side buffer: data will be copied from the device of the given rendetr | /* Copy happens via CPU side buffer: data will be copied from the device of the given rendetr | ||||
| * buffers and will be copied to all devices of the path trace. */ | * buffers and will be copied to all devices of the path trace. */ | ||||
| void copy_from_render_buffers(RenderBuffers *render_buffers); | void copy_from_render_buffers(RenderBuffers *render_buffers); | ||||
| /* Copy render buffers of the big tile from the device to hsot. | /* Copy render buffers of the big tile from the device to hsot. | ||||
| * Return true if all copies are successful. */ | * Return true if all copies are successful. */ | ||||
| bool copy_render_tile_from_device(); | bool copy_render_tile_from_device(); | ||||
| /* Get number of samples in the current big tile render buffers. */ | |||||
| int get_num_render_tile_samples() const; | |||||
| /* Get pass data of the entire big tile. | /* Get pass data of the entire big tile. | ||||
| * This call puts pass render result from all devices into the final pixels storage. | * This call puts pass render result from all devices into the final pixels storage. | ||||
| * | * | ||||
| * NOTE: Expects buffers to be copied to the host using `copy_render_tile_from_device()`. | * NOTE: Expects buffers to be copied to the host using `copy_render_tile_from_device()`. | ||||
| * | * | ||||
| * Returns false if any of the accessor's `get_render_tile_pixels()` returned false. */ | * Returns false if any of the accessor's `get_render_tile_pixels()` returned false. */ | ||||
| bool get_render_tile_pixels(const PassAccessor &pass_accessor, | bool get_render_tile_pixels(const PassAccessor &pass_accessor, | ||||
| const PassAccessor::Destination &destination); | const PassAccessor::Destination &destination); | ||||
| /* Set pass data for baking. */ | /* Set pass data for baking. */ | ||||
| bool set_render_tile_pixels(PassAccessor &pass_accessor, const PassAccessor::Source &source); | bool set_render_tile_pixels(PassAccessor &pass_accessor, const PassAccessor::Source &source); | ||||
| /* Check whether denoiser was run and denoised passes are available. */ | /* Check whether denoiser was run and denoised passes are available. */ | ||||
| bool has_denoised_result() const; | bool has_denoised_result() const; | ||||
| /* Get size and offset (relative to the buffer's full x/y) of the currently rendering tile. | |||||
| * In the case of tiled rendering this will return full-frame after all tiles has been rendered. | |||||
| */ | |||||
| int2 get_render_tile_size() const; | |||||
| int2 get_render_tile_offset() const; | |||||
| /* Generate full multi-line report of the rendering process, including rendering parameters, | /* Generate full multi-line report of the rendering process, including rendering parameters, | ||||
| * times, and so on. */ | * times, and so on. */ | ||||
| string full_report() const; | string full_report() const; | ||||
| /* Callback which communicates an updates state of the render buffer. | /* Callback which communicates an updates state of the render buffer of the current big tile. | ||||
| * Is called during path tracing to communicate work-in-progress state of the final buffer. | * Is called during path tracing to communicate work-in-progress state of the final buffer. */ | ||||
| * | function<void(void)> tile_buffer_update_cb; | ||||
| * The samples indicates how many samples the buffer contains. */ | |||||
| function<void(void)> buffer_update_cb; | |||||
| /* Callback which communicates final rendered buffer. Is called after pathtracing is done. | /* Callback which communicates final rendered buffer. Is called after pathtracing is done. */ | ||||
| * | function<void(void)> tile_buffer_write_cb; | ||||
| * The samples indicates how many samples the buffer contains. */ | |||||
| function<void(void)> buffer_write_cb; | |||||
| /* Callback which initializes rendered buffer. Is called before pathtracing starts. | /* Callback which initializes rendered buffer. Is called before pathtracing starts. | ||||
| * | * | ||||
| * This is used for baking. */ | * This is used for baking. */ | ||||
| function<bool(void)> buffer_read_cb; | function<bool(void)> tile_buffer_read_cb; | ||||
| /* Callback which is called to report current rendering progress. | /* Callback which is called to report current rendering progress. | ||||
| * | * | ||||
| * It is supposed to be cheaper than buffer update/write, hence can be called more often. | * It is supposed to be cheaper than buffer update/write, hence can be called more often. | ||||
| * Additionally, it might be called form the middle of wavefront (meaning, it is not guaranteed | * Additionally, it might be called form the middle of wavefront (meaning, it is not guaranteed | ||||
| * that the buffer is "uniformly" sampled at the moment of this callback). */ | * that the buffer is "uniformly" sampled at the moment of this callback). */ | ||||
| function<void(void)> progress_update_cb; | function<void(void)> progress_update_cb; | ||||
| Show All 17 Lines | protected: | ||||
| /* Perform various steps of the render work. | /* Perform various steps of the render work. | ||||
| * | * | ||||
| * Note that some steps might modify the work, forcing some steps to happen within this iteration | * Note that some steps might modify the work, forcing some steps to happen within this iteration | ||||
| * of rendering. */ | * of rendering. */ | ||||
| void init_render_buffers(const RenderWork &render_work); | void init_render_buffers(const RenderWork &render_work); | ||||
| void path_trace(RenderWork &render_work); | void path_trace(RenderWork &render_work); | ||||
| void adaptive_sample(RenderWork &render_work); | void adaptive_sample(RenderWork &render_work); | ||||
| void denoise(const RenderWork &render_work); | void denoise_tile(const RenderWork &render_work); | ||||
brecht: Not sure why this one gets the `_tile` postfix while other functions don't. | |||||
sergeyAuthorUnsubmitted Done Inline ActionsGot confusing at some point during development, so had to disambiguate. sergey: Got confusing at some point during development, so had to disambiguate.
But happy with the… | |||||
| void cryptomatte_postprocess(const RenderWork &render_work); | void cryptomatte_postprocess(const RenderWork &render_work); | ||||
| void update_display(const RenderWork &render_work); | void update_display(const RenderWork &render_work); | ||||
| void rebalance(const RenderWork &render_work); | void rebalance(const RenderWork &render_work); | ||||
| void write_tile_result(const RenderWork &render_work); | |||||
brechtUnsubmitted Done Inline ActionsWould prefer a name like write_tile_buffer_to_disk. Since writing can mean multiple things, some indication that this is about writing to disk helps. Also we generally use "buffer" instead of "result" in Cycles. brecht: Would prefer a name like `write_tile_buffer_to_disk`.
Since writing can mean multiple things… | |||||
| void handle_full_buffer(const RenderWork &render_work); | |||||
brechtUnsubmitted Done Inline ActionsI suggest process_full_buffer_from_disk. brecht: I suggest `process_full_buffer_from_disk`. | |||||
| /* Get number of samples in the current state of the render buffers. */ | /* Get number of samples in the current state of the render buffers. */ | ||||
| int get_num_samples_in_buffer(); | int get_num_samples_in_buffer(); | ||||
| /* Check whether user requested to cancel rendering, so that path tracing is to be finished as | /* Check whether user requested to cancel rendering, so that path tracing is to be finished as | ||||
| * soon as possible. */ | * soon as possible. */ | ||||
| bool is_cancel_requested(); | bool is_cancel_requested(); | ||||
| /* Write the big tile render buffer via the write callback. */ | /* Write the big tile render buffer via the write callback. */ | ||||
| void buffer_write(); | void tile_buffer_write(); | ||||
| /* Read the big tile render buffer via the read callback. */ | /* Read the big tile render buffer via the read callback. */ | ||||
| void buffer_read(); | void tile_buffer_read(); | ||||
| /* Write current tile into the partial tile file. */ | |||||
| void write_partial_tile(); | |||||
| /* Read full-frame render buffer from the partial file. */ | |||||
| void read_partial_full_buffer(); | |||||
| /* Run the progress_update_cb callback if it is needed. */ | /* Run the progress_update_cb callback if it is needed. */ | ||||
| void progress_update_if_needed(); | void progress_update_if_needed(); | ||||
| /* Pointer to a device which is configured to be used for path tracing. If multiple devices | /* Pointer to a device which is configured to be used for path tracing. If multiple devices | ||||
| * are configured this is a `MultiDevice`. */ | * are configured this is a `MultiDevice`. */ | ||||
| Device *device_ = nullptr; | Device *device_ = nullptr; | ||||
| /* CPU device for creating temporary render buffers on the CPU side. */ | |||||
| unique_ptr<Device> cpu_device_; | |||||
| DeviceScene *device_scene_; | DeviceScene *device_scene_; | ||||
| RenderScheduler &render_scheduler_; | RenderScheduler &render_scheduler_; | ||||
| TileManager &tile_manager_; | |||||
| unique_ptr<GPUDisplay> gpu_display_; | unique_ptr<GPUDisplay> gpu_display_; | ||||
| /* Per-compute device descriptors of work which is responsible for path tracing on its configured | /* Per-compute device descriptors of work which is responsible for path tracing on its configured | ||||
| * device. */ | * device. */ | ||||
| vector<unique_ptr<PathTraceWork>> path_trace_works_; | vector<unique_ptr<PathTraceWork>> path_trace_works_; | ||||
| /* Per-path trace work information needed for multi-device balancing. */ | /* Per-path trace work information needed for multi-device balancing. */ | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | struct { | ||||
| * `cancel()`. */ | * `cancel()`. */ | ||||
| thread_mutex mutex; | thread_mutex mutex; | ||||
| thread_condition_variable condition; | thread_condition_variable condition; | ||||
| } render_cancel_; | } render_cancel_; | ||||
| /* Indicates whether a render result was drawn after latest session reset. | /* Indicates whether a render result was drawn after latest session reset. | ||||
| * Used by `ready_to_reset()` to implement logic which feels the most interactive. */ | * Used by `ready_to_reset()` to implement logic which feels the most interactive. */ | ||||
| bool did_draw_after_reset_ = true; | bool did_draw_after_reset_ = true; | ||||
| unique_ptr<RenderBuffers> full_frame_buffers_; | |||||
| }; | }; | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
Not sure why this one gets the _tile postfix while other functions don't.