2012-09-04 13:29:07 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2012-09-04 13:29:07 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* 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
|
2012-09-04 13:29:07 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-09-04 13:29:07 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* 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
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2012-09-04 13:29:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DEVICE_TASK_H__
|
|
|
|
#define __DEVICE_TASK_H__
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "device/device_memory.h"
|
2012-09-04 13:29:07 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_function.h"
|
|
|
|
#include "util/util_list.h"
|
2012-09-04 13:29:07 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Device Task */
|
|
|
|
|
|
|
|
class Device;
|
|
|
|
class RenderBuffers;
|
|
|
|
class RenderTile;
|
2020-07-09 18:01:22 +00:00
|
|
|
class RenderTileNeighbors;
|
2012-09-04 13:29:07 +00:00
|
|
|
class Tile;
|
|
|
|
|
2020-05-31 21:49:10 +00:00
|
|
|
enum DenoiserType {
|
|
|
|
DENOISER_NLM = 1,
|
|
|
|
DENOISER_OPTIX = 2,
|
2020-05-31 22:11:17 +00:00
|
|
|
DENOISER_OPENIMAGEDENOISE = 4,
|
2020-05-31 21:49:10 +00:00
|
|
|
DENOISER_NUM,
|
|
|
|
|
|
|
|
DENOISER_NONE = 0,
|
|
|
|
DENOISER_ALL = ~0,
|
|
|
|
};
|
|
|
|
|
2020-07-13 14:45:15 +00:00
|
|
|
enum DenoiserInput {
|
|
|
|
DENOISER_INPUT_RGB = 1,
|
|
|
|
DENOISER_INPUT_RGB_ALBEDO = 2,
|
|
|
|
DENOISER_INPUT_RGB_ALBEDO_NORMAL = 3,
|
|
|
|
|
|
|
|
DENOISER_INPUT_NUM,
|
|
|
|
};
|
|
|
|
|
2020-05-31 21:49:10 +00:00
|
|
|
typedef int DenoiserTypeMask;
|
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
class DenoiseParams {
|
2019-04-17 04:17:24 +00:00
|
|
|
public:
|
2020-05-31 21:49:10 +00:00
|
|
|
/* Apply denoiser to image. */
|
|
|
|
bool use;
|
|
|
|
/* Output denoising data passes (possibly without applying the denoiser). */
|
|
|
|
bool store_passes;
|
|
|
|
|
|
|
|
/* Denoiser type. */
|
|
|
|
DenoiserType type;
|
|
|
|
|
|
|
|
/* Viewport start sample. */
|
|
|
|
int start_sample;
|
|
|
|
|
|
|
|
/** Native Denoiser **/
|
|
|
|
|
2019-07-07 05:38:41 +00:00
|
|
|
/* Pixel radius for neighboring pixels to take into account. */
|
2019-04-17 04:17:24 +00:00
|
|
|
int radius;
|
|
|
|
/* Controls neighbor pixel weighting for the denoising filter. */
|
|
|
|
float strength;
|
|
|
|
/* Preserve more or less detail based on feature passes. */
|
|
|
|
float feature_strength;
|
2019-05-01 11:14:11 +00:00
|
|
|
/* When removing pixels that don't carry information,
|
|
|
|
* use a relative threshold instead of an absolute one. */
|
2019-04-17 04:17:24 +00:00
|
|
|
bool relative_pca;
|
|
|
|
/* How many frames before and after the current center frame are included. */
|
|
|
|
int neighbor_frames;
|
|
|
|
/* Clamp the input to the range of +-1e8. Should be enough for any legitimate data. */
|
|
|
|
bool clamp_input;
|
2020-05-31 21:49:10 +00:00
|
|
|
|
2020-07-13 14:45:15 +00:00
|
|
|
/** OIDN/Optix Denoiser **/
|
2020-05-31 21:49:10 +00:00
|
|
|
|
2020-07-13 14:45:15 +00:00
|
|
|
/* Passes handed over to the OIDN/OptiX denoiser (default to color + albedo). */
|
|
|
|
DenoiserInput input_passes;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
|
|
|
DenoiseParams()
|
|
|
|
{
|
2020-05-31 21:49:10 +00:00
|
|
|
use = false;
|
|
|
|
store_passes = false;
|
|
|
|
|
|
|
|
type = DENOISER_NLM;
|
|
|
|
|
2019-04-17 04:17:24 +00:00
|
|
|
radius = 8;
|
|
|
|
strength = 0.5f;
|
|
|
|
feature_strength = 0.5f;
|
|
|
|
relative_pca = false;
|
|
|
|
neighbor_frames = 2;
|
|
|
|
clamp_input = true;
|
2020-05-31 21:49:10 +00:00
|
|
|
|
2020-07-13 14:45:15 +00:00
|
|
|
input_passes = DENOISER_INPUT_RGB_ALBEDO_NORMAL;
|
2020-05-31 21:49:10 +00:00
|
|
|
|
|
|
|
start_sample = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test if a denoising task needs to run, also to prefilter passes for the native
|
|
|
|
* denoiser when we are not applying denoising to the combined image. */
|
|
|
|
bool need_denoising_task() const
|
|
|
|
{
|
|
|
|
return (use || (store_passes && type == DENOISER_NLM));
|
2019-04-17 04:17:24 +00:00
|
|
|
}
|
2019-02-06 11:57:10 +00:00
|
|
|
};
|
|
|
|
|
2020-03-05 11:05:42 +00:00
|
|
|
class AdaptiveSampling {
|
|
|
|
public:
|
|
|
|
AdaptiveSampling();
|
|
|
|
|
|
|
|
int align_static_samples(int samples) const;
|
|
|
|
int align_dynamic_samples(int offset, int samples) const;
|
|
|
|
bool need_filter(int sample) const;
|
|
|
|
|
|
|
|
bool use;
|
|
|
|
int adaptive_step;
|
|
|
|
int min_samples;
|
|
|
|
};
|
|
|
|
|
2020-06-05 09:39:11 +00:00
|
|
|
class DeviceTask {
|
2019-04-17 04:17:24 +00:00
|
|
|
public:
|
2020-02-26 15:30:42 +00:00
|
|
|
typedef enum { RENDER, FILM_CONVERT, SHADER, DENOISE_BUFFER } Type;
|
2019-04-17 04:17:24 +00:00
|
|
|
Type type;
|
|
|
|
|
|
|
|
int x, y, w, h;
|
|
|
|
device_ptr rgba_byte;
|
|
|
|
device_ptr rgba_half;
|
|
|
|
device_ptr buffer;
|
|
|
|
int sample;
|
|
|
|
int num_samples;
|
|
|
|
int offset, stride;
|
|
|
|
|
|
|
|
device_ptr shader_input;
|
|
|
|
device_ptr shader_output;
|
|
|
|
int shader_eval_type;
|
|
|
|
int shader_filter;
|
|
|
|
int shader_x, shader_w;
|
|
|
|
|
2020-02-11 15:30:01 +00:00
|
|
|
RenderBuffers *buffers;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
|
|
|
explicit DeviceTask(Type type = RENDER);
|
|
|
|
|
2020-06-05 09:39:11 +00:00
|
|
|
int get_subtask_count(int num, int max_size = 0) const;
|
|
|
|
void split(list<DeviceTask> &tasks, int num, int max_size = 0) const;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
|
|
|
void update_progress(RenderTile *rtile, int pixel_samples = -1);
|
|
|
|
|
2020-02-26 15:30:42 +00:00
|
|
|
function<bool(Device *device, RenderTile &, uint)> acquire_tile;
|
2019-04-17 04:17:24 +00:00
|
|
|
function<void(long, int)> update_progress_sample;
|
|
|
|
function<void(RenderTile &)> update_tile_sample;
|
|
|
|
function<void(RenderTile &)> release_tile;
|
|
|
|
function<bool()> get_cancel;
|
2020-09-23 22:37:23 +00:00
|
|
|
function<bool()> get_tile_stolen;
|
2020-07-09 18:01:22 +00:00
|
|
|
function<void(RenderTileNeighbors &, Device *)> map_neighbor_tiles;
|
|
|
|
function<void(RenderTileNeighbors &, Device *)> unmap_neighbor_tiles;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-02-26 15:30:42 +00:00
|
|
|
uint tile_types;
|
2019-04-17 04:17:24 +00:00
|
|
|
DenoiseParams denoising;
|
|
|
|
bool denoising_from_render;
|
|
|
|
vector<int> denoising_frames;
|
|
|
|
|
|
|
|
int pass_stride;
|
|
|
|
int frame_stride;
|
|
|
|
int target_pass_stride;
|
|
|
|
int pass_denoising_data;
|
|
|
|
int pass_denoising_clean;
|
|
|
|
|
|
|
|
bool need_finish_queue;
|
|
|
|
bool integrator_branched;
|
2020-03-05 11:05:42 +00:00
|
|
|
AdaptiveSampling adaptive_sampling;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
double last_update_time;
|
2012-09-04 13:29:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
2019-04-17 04:17:24 +00:00
|
|
|
#endif /* __DEVICE_TASK_H__ */
|