Blender
V3.3
intern
cycles
integrator
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
9
CCL_NAMESPACE_BEGIN
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. */
17
class
WorkTileScheduler
{
18
public
:
19
WorkTileScheduler
();
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? */
56
int
max_num_path_states_
= 0;
57
58
/* Offset in pixels within a global buffer. */
59
int2
image_full_offset_px_
=
make_int2
(0, 0);
60
61
/* dimensions of the currently rendering image in pixels. */
62
int2
image_size_px_
=
make_int2
(0, 0);
63
64
/* Offset and stride of the buffer within which scheduling is happening.
65
* Will be passed over to the KernelWorkTile. */
66
int
offset_
,
stride_
;
67
68
/* Scrambling Distance requires adapted tile size */
69
float
scrambling_distance_
;
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. */
79
TileSize
tile_size_
;
80
81
/* Number of tiles in X and Y axis of the image. */
82
int
num_tiles_x_
,
num_tiles_y_
;
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()`? */
89
int
total_tiles_num_
= 0;
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. */
93
int
num_tiles_per_sample_range_
= 0;
94
95
int
next_work_index_
= 0;
96
int
total_work_size_
= 0;
97
};
98
99
CCL_NAMESPACE_END
BufferParams
Definition:
buffers.h:66
WorkTileScheduler
Definition:
work_tile_scheduler.h:17
WorkTileScheduler::stride_
int stride_
Definition:
work_tile_scheduler.h:66
WorkTileScheduler::total_tiles_num_
int total_tiles_num_
Definition:
work_tile_scheduler.h:89
WorkTileScheduler::image_full_offset_px_
int2 image_full_offset_px_
Definition:
work_tile_scheduler.h:59
WorkTileScheduler::accelerated_rt_
bool accelerated_rt_
Definition:
work_tile_scheduler.h:49
WorkTileScheduler::num_tiles_per_sample_range_
int num_tiles_per_sample_range_
Definition:
work_tile_scheduler.h:93
WorkTileScheduler::total_work_size_
int total_work_size_
Definition:
work_tile_scheduler.h:96
WorkTileScheduler::max_num_path_states_
int max_num_path_states_
Definition:
work_tile_scheduler.h:56
WorkTileScheduler::image_size_px_
int2 image_size_px_
Definition:
work_tile_scheduler.h:62
WorkTileScheduler::next_work_index_
int next_work_index_
Definition:
work_tile_scheduler.h:95
WorkTileScheduler::num_tiles_y_
int num_tiles_y_
Definition:
work_tile_scheduler.h:82
WorkTileScheduler::WorkTileScheduler
WorkTileScheduler()
Definition:
work_tile_scheduler.cpp:14
WorkTileScheduler::get_work
bool get_work(KernelWorkTile *work_tile, const int max_work_size=0)
Definition:
work_tile_scheduler.cpp:88
WorkTileScheduler::offset_
int offset_
Definition:
work_tile_scheduler.h:66
WorkTileScheduler::samples_num_
int samples_num_
Definition:
work_tile_scheduler.h:75
WorkTileScheduler::reset_scheduler_state
void reset_scheduler_state()
Definition:
work_tile_scheduler.cpp:53
WorkTileScheduler::set_accelerated_rt
void set_accelerated_rt(bool state)
Definition:
work_tile_scheduler.cpp:18
WorkTileScheduler::tile_size_
TileSize tile_size_
Definition:
work_tile_scheduler.h:79
WorkTileScheduler::num_tiles_x_
int num_tiles_x_
Definition:
work_tile_scheduler.h:82
WorkTileScheduler::set_max_num_path_states
void set_max_num_path_states(int max_num_path_states)
Definition:
work_tile_scheduler.cpp:23
WorkTileScheduler::reset
void reset(const BufferParams &buffer_params, int sample_start, int samples_num, int sample_offset, float scrambling_distance)
Definition:
work_tile_scheduler.cpp:28
WorkTileScheduler::sample_offset_
int sample_offset_
Definition:
work_tile_scheduler.h:76
WorkTileScheduler::scrambling_distance_
float scrambling_distance_
Definition:
work_tile_scheduler.h:69
WorkTileScheduler::sample_start_
int sample_start_
Definition:
work_tile_scheduler.h:74
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition:
cuda/compat.h:9
tile.h
state
const int state
Definition:
kernel/device/gpu/kernel.h:89
make_int2
#define make_int2(x, y)
Definition:
metal/compat.h:206
CCL_NAMESPACE_BEGIN
Definition:
python.cpp:37
KernelWorkTile
Definition:
kernel/types.h:1340
TileSize
Definition:
integrator/tile.h:12
int2
Definition:
types_int2.h:14
types.h
Generated on Tue Oct 22 2024 13:18:25 for Blender by
doxygen
1.9.1