Blender V4.3
work_tile_scheduler.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
7#include "integrator/tile.h"
8#include "util/types.h"
9
11
12class BufferParams;
13
14struct KernelWorkTile;
15
16/* Scheduler of device work tiles.
17 * Takes care of feeding multiple devices running in parallel a work which needs to be done. */
19 public:
21
22 /* To indicate if there is accelerated RT support. */
23 void set_accelerated_rt(bool state);
24
25 /* MAximum path states which are allowed to be used by a single scheduled work tile.
26 *
27 * Affects the scheduled work size: the work size will be as big as possible, but will not exceed
28 * this number of states. */
29 void set_max_num_path_states(int max_num_path_states);
30
31 /* Scheduling will happen for pixels within a big tile denotes by its parameters. */
32 void reset(const BufferParams &buffer_params,
33 int sample_start,
34 int samples_num,
35 int sample_offset,
36 float scrambling_distance);
37
38 /* Get work for a device.
39 * Returns true if there is still work to be done and initialize the work tile to all
40 * parameters of this work. If there is nothing remaining to be done, returns false and the
41 * work tile is kept unchanged.
42 *
43 * Optionally pass max_work_size to do nothing if there is no tile small enough. */
44 bool get_work(KernelWorkTile *work_tile, const int max_work_size = 0);
45
46 protected:
48
49 /* Used to indicate if there is accelerated ray tracing. */
50 bool accelerated_rt_ = false;
51
52 /* Maximum allowed path states to be used.
53 *
54 * TODO(sergey): Naming can be improved. The fact that this is a limiting factor based on the
55 * number of path states is kind of a detail. Is there a more generic term from the scheduler
56 * point of view? */
58
59 /* Offset in pixels within a global buffer. */
61
62 /* dimensions of the currently rendering image in pixels. */
64
65 /* Offset and stride of the buffer within which scheduling is happening.
66 * Will be passed over to the KernelWorkTile. */
68
69 /* Scrambling Distance requires adapted tile size */
71
72 /* Start sample of index and number of samples which are to be rendered.
73 * The scheduler will cover samples range of [start, start + num] over the entire image
74 * (splitting into a smaller work tiles). */
76 int samples_num_ = 0;
78
79 /* Tile size which be scheduled for rendering. */
81
82 /* Number of tiles in X and Y axis of the image. */
84
85 /* Total number of tiles on the image.
86 * Pre-calculated as `num_tiles_x_ * num_tiles_y_` and re-used in the `get_work()`.
87 *
88 * TODO(sergey): Is this an over-optimization? Maybe it's unmeasurable to calculate the value
89 * in the `get_work()`? */
91
92 /* In the case when the number of samples in the `tile_size_` is lower than samples_num_ denotes
93 * how many tiles are to be "stacked" to cover the entire requested range of samples. */
95
98};
99
void reset()
clear internal cached data and reset random seed
bool get_work(KernelWorkTile *work_tile, const int max_work_size=0)
void set_accelerated_rt(bool state)
void set_max_num_path_states(int max_num_path_states)
#define CCL_NAMESPACE_END
ccl_device_forceinline int2 make_int2(const int x, const int y)
static ulong state[N]