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