Blender V4.3
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
8
10#include "device/queue.h"
11
13
14#include "util/vector.h"
15
17
18struct KernelWorkTile;
19struct KernelGlobalsCPU;
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 bool *cancel_requested_flag);
35
36 virtual void init_execution() override;
37
38 virtual void render_samples(RenderStatistics &statistics,
39 int start_sample,
40 int samples_num,
41 int sample_offset) override;
42
43 virtual void copy_to_display(PathTraceDisplay *display,
44 PassMode pass_mode,
45 int num_samples) override;
46 virtual void destroy_gpu_resources(PathTraceDisplay *display) override;
47
48 virtual bool copy_render_buffers_from_device() override;
49 virtual bool copy_render_buffers_to_device() override;
50 virtual bool zero_render_buffers() override;
51
52 virtual int adaptive_sampling_converge_filter_count_active(float threshold, bool reset) override;
53 virtual void cryptomatte_postproces() override;
54
55#ifdef WITH_PATH_GUIDING
56 /* Initializes the per-thread guiding kernel data. The function sets the pointers to the
57 * global guiding field and the sample data storage as well es initializes the per-thread
58 * guided sampling distributions (e.g., SurfaceSamplingDistribution and
59 * VolumeSamplingDistribution). */
60 void guiding_init_kernel_globals(void *guiding_field,
61 void *sample_data_storage,
62 const bool train) override;
63
64 /* Pushes the collected training data/samples of a path to the global sample storage.
65 * This function is called at the end of a random walk/path generation. */
66 void guiding_push_sample_data_to_global_storage(KernelGlobalsCPU *kernel_globals,
69#endif
70
71 protected:
72 /* Core path tracing routine. Renders given work time on the given queue. */
74 const KernelWorkTile &work_tile,
75 const int samples_num);
76
77 /* CPU kernels. */
79
80 /* Copy of kernel globals which is suitable for concurrent access from multiple threads.
81 *
82 * More specifically, the `kernel_globals_` is local to each threads and nobody else is
83 * accessing it, but some "localization" is required to decouple from kernel globals stored
84 * on the device level. */
86};
87
void reset()
clear internal cached data and reset random seed
Definition film.h:30
virtual bool copy_render_buffers_to_device() override
virtual void render_samples(RenderStatistics &statistics, int start_sample, int samples_num, int sample_offset) override
vector< CPUKernelThreadGlobals > kernel_thread_globals_
virtual void init_execution() override
virtual void copy_to_display(PathTraceDisplay *display, PassMode pass_mode, int num_samples) override
virtual bool copy_render_buffers_from_device() override
virtual void destroy_gpu_resources(PathTraceDisplay *display) override
virtual int adaptive_sampling_converge_filter_count_active(float threshold, bool reset) override
virtual void cryptomatte_postproces() override
const CPUKernels & kernels_
PathTraceWorkCPU(Device *device, Film *film, DeviceScene *device_scene, bool *cancel_requested_flag)
void render_samples_full_pipeline(KernelGlobalsCPU *kernel_globals, const KernelWorkTile &work_tile, const int samples_num)
virtual bool zero_render_buffers() override
#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