Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2021 Blender Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "integrator/tile.h"
|
2021-10-24 12:19:19 +00:00
|
|
|
#include "util/types.h"
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class BufferParams;
|
|
|
|
|
|
|
|
struct KernelWorkTile;
|
|
|
|
|
|
|
|
/* Scheduler of device work tiles.
|
|
|
|
* Takes care of feeding multiple devices running in parallel a work which needs to be done. */
|
|
|
|
class WorkTileScheduler {
|
|
|
|
public:
|
|
|
|
WorkTileScheduler();
|
|
|
|
|
2021-11-25 08:20:28 +00:00
|
|
|
/* To indicate if there is accelerated RT support. */
|
|
|
|
void set_accelerated_rt(bool state);
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
/* MAximum path states which are allowed to be used by a single scheduled work tile.
|
|
|
|
*
|
|
|
|
* Affects the scheduled work size: the work size will be as big as possible, but will not exceed
|
|
|
|
* this number of states. */
|
|
|
|
void set_max_num_path_states(int max_num_path_states);
|
|
|
|
|
|
|
|
/* Scheduling will happen for pixels within a big tile denotes by its parameters. */
|
2021-10-26 06:30:15 +00:00
|
|
|
void reset(const BufferParams &buffer_params,
|
|
|
|
int sample_start,
|
|
|
|
int samples_num,
|
2021-11-11 07:57:35 +00:00
|
|
|
int sample_offset,
|
2021-10-26 06:30:15 +00:00
|
|
|
float scrambling_distance);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
|
|
|
|
/* Get work for a device.
|
|
|
|
* Returns true if there is still work to be done and initialize the work tile to all
|
|
|
|
* parameters of this work. If there is nothing remaining to be done, returns false and the
|
|
|
|
* work tile is kept unchanged.
|
|
|
|
*
|
|
|
|
* Optionally pass max_work_size to do nothing if there is no tile small enough. */
|
|
|
|
bool get_work(KernelWorkTile *work_tile, const int max_work_size = 0);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void reset_scheduler_state();
|
|
|
|
|
2021-11-25 08:20:28 +00:00
|
|
|
/* Used to indicate if there is accelerated ray tracing. */
|
|
|
|
bool accelerated_rt_ = false;
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
/* Maximum allowed path states to be used.
|
|
|
|
*
|
|
|
|
* TODO(sergey): Naming can be improved. The fact that this is a limiting factor based on the
|
|
|
|
* number of path states is kind of a detail. Is there a more generic term from the scheduler
|
|
|
|
* point of view? */
|
|
|
|
int max_num_path_states_ = 0;
|
|
|
|
|
|
|
|
/* Offset in pixels within a global buffer. */
|
|
|
|
int2 image_full_offset_px_ = make_int2(0, 0);
|
|
|
|
|
|
|
|
/* dimensions of the currently rendering image in pixels. */
|
|
|
|
int2 image_size_px_ = make_int2(0, 0);
|
|
|
|
|
2021-09-22 04:48:01 +00:00
|
|
|
/* Offset and stride of the buffer within which scheduling is happening.
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
* Will be passed over to the KernelWorkTile. */
|
|
|
|
int offset_, stride_;
|
2021-10-26 06:30:15 +00:00
|
|
|
|
|
|
|
/* Scrambling Distance requires adapted tile size */
|
|
|
|
float scrambling_distance_;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
|
|
|
|
/* Start sample of index and number of samples which are to be rendered.
|
|
|
|
* The scheduler will cover samples range of [start, start + num] over the entire image
|
|
|
|
* (splitting into a smaller work tiles). */
|
|
|
|
int sample_start_ = 0;
|
|
|
|
int samples_num_ = 0;
|
2021-11-11 07:57:35 +00:00
|
|
|
int sample_offset_ = 0;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
|
|
|
|
/* Tile size which be scheduled for rendering. */
|
|
|
|
TileSize tile_size_;
|
|
|
|
|
|
|
|
/* Number of tiles in X and Y axis of the image. */
|
|
|
|
int num_tiles_x_, num_tiles_y_;
|
|
|
|
|
|
|
|
/* Total number of tiles on the image.
|
|
|
|
* Pre-calculated as `num_tiles_x_ * num_tiles_y_` and re-used in the `get_work()`.
|
|
|
|
*
|
|
|
|
* TODO(sergey): Is this an over-optimization? Maybe it's unmeasurable to calculate the value
|
|
|
|
* in the `get_work()`? */
|
|
|
|
int total_tiles_num_ = 0;
|
|
|
|
|
2021-09-22 04:48:01 +00:00
|
|
|
/* In the case when the number of samples in the `tile_size_` is lower than samples_num_ denotes
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
* how many tiles are to be "stacked" to cover the entire requested range of samples. */
|
|
|
|
int num_tiles_per_sample_range_ = 0;
|
|
|
|
|
|
|
|
int next_work_index_ = 0;
|
|
|
|
int total_work_size_ = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|