Blender V5.0
path_trace_work_cpu.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
9
10#include "device/queue.h"
11
13
14#include "util/vector.h"
15
17
18struct KernelWorkTile;
21
22class CPUKernels;
23
24/* Implementation of PathTraceWork which schedules work on to queues pixel-by-pixel,
25 * for CPU devices.
26 *
27 * NOTE: For the CPU rendering there are assumptions about TBB arena size and number of concurrent
28 * queues on the render device which makes this work be only usable on CPU. */
30 public:
32 Film *film,
33 DeviceScene *device_scene,
34 const bool *cancel_requested_flag);
35
36 void init_execution() override;
37
38 void render_samples(RenderStatistics &statistics,
39 const int start_sample,
40 const int samples_num,
41 const int sample_offset) override;
42
44 PassMode pass_mode,
45 const int num_samples) override;
46 void destroy_gpu_resources(PathTraceDisplay *display) override;
47
48 bool copy_render_buffers_from_device() override;
49 bool copy_render_buffers_to_device() override;
50 bool zero_render_buffers() override;
51
52 int adaptive_sampling_converge_filter_count_active(const float threshold, bool reset) override;
53 void cryptomatte_postproces() override;
54 void denoise_volume_guiding_buffers() override;
55
56#if defined(WITH_PATH_GUIDING)
57 /* Initializes the per-thread guiding kernel data. The function sets the pointers to the
58 * global guiding field and the sample data storage as well es initializes the per-thread
59 * guided sampling distributions (e.g., SurfaceSamplingDistribution and
60 * VolumeSamplingDistribution). */
61 void guiding_init_kernel_globals(void *guiding_field,
62 void *sample_data_storage,
63 const bool train) override;
64
65 /* Pushes the collected training data/samples of a path to the global sample storage.
66 * This function is called at the end of a random walk/path generation. */
67 void guiding_push_sample_data_to_global_storage(ThreadKernelGlobalsCPU *kg,
70#endif
71
72 protected:
73 /* Core path tracing routine. Renders given work time on the given queue. */
75 const KernelWorkTile &work_tile,
76 const int samples_num);
77
78 /* CPU kernels. */
80
81 /* Copy of kernel globals which is suitable for concurrent access from multiple threads.
82 *
83 * More specifically, the `kernel_globals_` is local to each threads and nobody else is
84 * accessing it, but some "localization" is required to decouple from kernel globals stored
85 * on the device level. */
87};
88
void reset()
clear internal cached data and reset random seed
Definition film.h:29
bool copy_render_buffers_to_device() override
vector< ThreadKernelGlobalsCPU > kernel_thread_globals_
void render_samples(RenderStatistics &statistics, const int start_sample, const int samples_num, const int sample_offset) override
void init_execution() override
bool copy_render_buffers_from_device() override
int adaptive_sampling_converge_filter_count_active(const float threshold, bool reset) override
void copy_to_display(PathTraceDisplay *display, PassMode pass_mode, const int num_samples) override
void destroy_gpu_resources(PathTraceDisplay *display) override
void cryptomatte_postproces() override
const CPUKernels & kernels_
void render_samples_full_pipeline(ThreadKernelGlobalsCPU *kernel_globals, const KernelWorkTile &work_tile, const int samples_num)
PathTraceWorkCPU(Device *device, Film *film, DeviceScene *device_scene, const bool *cancel_requested_flag)
bool zero_render_buffers() override
void denoise_volume_guiding_buffers() override
PathTraceWork(Device *device, Film *film, DeviceScene *device_scene, const bool *cancel_requested_flag)
#define ccl_restrict
#define ccl_global
#define CCL_NAMESPACE_END
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int ccl_global float * render_buffer
static ulong state[N]
PassMode
Definition pass.h:20