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