Blender  V2.93
device_task.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __DEVICE_TASK_H__
18 #define __DEVICE_TASK_H__
19 
20 #include "device/device_memory.h"
21 
22 #include "util/util_function.h"
23 #include "util/util_list.h"
24 
26 
27 /* Device Task */
28 
29 class Device;
30 class RenderBuffers;
31 class RenderTile;
33 class Tile;
34 
40 
43 };
44 
49 
51 };
52 
53 typedef int DenoiserTypeMask;
54 
56  public:
57  /* Apply denoiser to image. */
58  bool use;
59  /* Output denoising data passes (possibly without applying the denoiser). */
61 
62  /* Denoiser type. */
64 
65  /* Viewport start sample. */
67 
70  /* Pixel radius for neighboring pixels to take into account. */
71  int radius;
72  /* Controls neighbor pixel weighting for the denoising filter. */
73  float strength;
74  /* Preserve more or less detail based on feature passes. */
76  /* When removing pixels that don't carry information,
77  * use a relative threshold instead of an absolute one. */
79  /* How many frames before and after the current center frame are included. */
81  /* Clamp the input to the range of +-1e8. Should be enough for any legitimate data. */
83 
86  /* Passes handed over to the OIDN/OptiX denoiser (default to color + albedo). */
88 
90  {
91  use = false;
92  store_passes = false;
93 
95 
96  radius = 8;
97  strength = 0.5f;
98  feature_strength = 0.5f;
99  relative_pca = false;
100  neighbor_frames = 2;
101  clamp_input = true;
102 
103  /* Default to color + albedo only, since normal input does not always have the desired effect
104  * when denoising with OptiX. */
106 
107  start_sample = 0;
108  }
109 
110  /* Test if a denoising task needs to run, also to prefilter passes for the native
111  * denoiser when we are not applying denoising to the combined image. */
112  bool need_denoising_task() const
113  {
114  return (use || (store_passes && type == DENOISER_NLM));
115  }
116 };
117 
119  public:
121 
122  int align_samples(int sample, int num_samples) const;
123  bool need_filter(int sample) const;
124 
125  bool use;
128 };
129 
130 class DeviceTask {
131  public:
134 
135  int x, y, w, h;
139  int sample;
142 
148 
150 
151  explicit DeviceTask(Type type = RENDER);
152 
153  int get_subtask_count(int num, int max_size = 0) const;
154  void split(list<DeviceTask> &tasks, int num, int max_size = 0) const;
155 
156  void update_progress(RenderTile *rtile, int pixel_samples = -1);
157 
158  function<bool(Device *device, RenderTile &, uint)> acquire_tile;
159  function<void(long, int)> update_progress_sample;
160  function<void(RenderTile &)> update_tile_sample;
161  function<void(RenderTile &)> release_tile;
162  function<bool()> get_cancel;
163  function<bool()> get_tile_stolen;
166 
171 
177 
181 
182  protected:
184 };
185 
187 
188 #endif /* __DEVICE_TASK_H__ */
unsigned int uint
Definition: BLI_sys_types.h:83
int align_samples(int sample, int num_samples) const
bool need_filter(int sample) const
bool relative_pca
Definition: device_task.h:78
DenoiserType type
Definition: device_task.h:63
float feature_strength
Definition: device_task.h:75
bool store_passes
Definition: device_task.h:60
DenoiserInput input_passes
Definition: device_task.h:87
float strength
Definition: device_task.h:73
int neighbor_frames
Definition: device_task.h:80
bool clamp_input
Definition: device_task.h:82
bool need_denoising_task() const
Definition: device_task.h:112
function< bool()> get_tile_stolen
Definition: device_task.h:163
device_ptr rgba_byte
Definition: device_task.h:136
device_ptr rgba_half
Definition: device_task.h:137
function< void(RenderTileNeighbors &, Device *)> map_neighbor_tiles
Definition: device_task.h:164
function< void(RenderTile &)> release_tile
Definition: device_task.h:161
void update_progress(RenderTile *rtile, int pixel_samples=-1)
int pass_denoising_data
Definition: device_task.h:175
function< void(long, int)> update_progress_sample
Definition: device_task.h:159
int pass_denoising_clean
Definition: device_task.h:176
function< bool(Device *device, RenderTile &, uint)> acquire_tile
Definition: device_task.h:158
DeviceTask(Type type=RENDER)
Definition: device_task.cpp:31
int shader_eval_type
Definition: device_task.h:145
int shader_filter
Definition: device_task.h:146
function< void(RenderTile &)> update_tile_sample
Definition: device_task.h:160
bool denoising_from_render
Definition: device_task.h:169
void split(list< DeviceTask > &tasks, int num, int max_size=0) const
Definition: device_task.cpp:90
int frame_stride
Definition: device_task.h:173
device_ptr shader_output
Definition: device_task.h:144
device_ptr shader_input
Definition: device_task.h:143
double last_update_time
Definition: device_task.h:183
device_ptr buffer
Definition: device_task.h:138
RenderBuffers * buffers
Definition: device_task.h:149
bool integrator_branched
Definition: device_task.h:179
function< void(RenderTileNeighbors &, Device *)> unmap_neighbor_tiles
Definition: device_task.h:165
bool need_finish_queue
Definition: device_task.h:178
int pass_stride
Definition: device_task.h:172
function< bool()> get_cancel
Definition: device_task.h:162
vector< int > denoising_frames
Definition: device_task.h:170
int num_samples
Definition: device_task.h:140
int target_pass_stride
Definition: device_task.h:174
int get_subtask_count(int num, int max_size=0) const
Definition: device_task.cpp:62
DenoiseParams denoising
Definition: device_task.h:168
uint tile_types
Definition: device_task.h:167
AdaptiveSampling adaptive_sampling
Definition: device_task.h:180
Definition: device.h:293
Definition: tile.h:29
int DenoiserTypeMask
Definition: device_task.h:53
DenoiserType
Definition: device_task.h:35
@ DENOISER_NONE
Definition: device_task.h:41
@ DENOISER_OPTIX
Definition: device_task.h:37
@ DENOISER_NLM
Definition: device_task.h:36
@ DENOISER_OPENIMAGEDENOISE
Definition: device_task.h:38
@ DENOISER_ALL
Definition: device_task.h:42
@ DENOISER_NUM
Definition: device_task.h:39
DenoiserInput
Definition: device_task.h:45
@ DENOISER_INPUT_NUM
Definition: device_task.h:50
@ DENOISER_INPUT_RGB
Definition: device_task.h:46
@ DENOISER_INPUT_RGB_ALBEDO
Definition: device_task.h:47
@ DENOISER_INPUT_RGB_ALBEDO_NORMAL
Definition: device_task.h:48
#define CCL_NAMESPACE_END
static void sample(SocketReader *reader, int x, int y, float color[4])
uint64_t device_ptr
Definition: util_types.h:62