Blender  V2.93
device_denoising.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2017 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_DENOISING_H__
18 #define __DEVICE_DENOISING_H__
19 
20 #include "device/device.h"
21 
22 #include "render/buffers.h"
23 
25 
26 #include "util/util_profiling.h"
27 
29 
31  public:
32  /* Parameters of the denoising algorithm. */
33  int radius;
34  float nlm_k_2;
36 
37  /* Parameters of the RenderBuffers. */
38  struct RenderBuffers {
39  int offset;
42  int samples;
44 
45  /* Pointer and parameters of the target buffer. */
46  struct TargetBuffer {
47  int offset;
48  int stride;
54 
57 
59 
62 
64  bool do_filter;
65 
66  struct DeviceFunctions {
67  function<bool(
68  device_ptr image_ptr, /* Contains the values that are smoothed. */
69  device_ptr guide_ptr, /* Contains the values that are used to calculate weights. */
70  device_ptr variance_ptr, /* Contains the variance of the guide image. */
71  device_ptr out_ptr /* The filtered output is written into this image. */
72  )>
74  function<bool(
75  device_ptr color_ptr, device_ptr color_variance_ptr, device_ptr scale_ptr, int frame)>
77  function<bool(device_ptr output_ptr)> solve;
78  function<bool()> construct_transform;
79 
80  function<bool(device_ptr a_ptr,
81  device_ptr b_ptr,
82  device_ptr mean_ptr,
83  device_ptr variance_ptr,
84  int r,
85  int4 rect)>
87  function<bool(device_ptr a_ptr,
88  device_ptr b_ptr,
89  device_ptr sample_variance_ptr,
90  device_ptr sv_variance_ptr,
91  device_ptr buffer_variance_ptr)>
93  function<bool(int mean_offset,
94  int variance_offset,
95  device_ptr mean_ptr,
96  device_ptr variance_ptr,
97  float scale)>
99  function<bool(device_ptr image_ptr,
100  device_ptr variance_ptr,
101  device_ptr depth_ptr,
102  device_ptr output_ptr)>
104  function<bool(int out_offset, device_ptr frop_ptr, device_ptr buffer_ptr)> write_feature;
105  function<void(RenderTileNeighbors &neighbors)> map_neighbor_tiles;
106  function<void(RenderTileNeighbors &neighbors)> unmap_neighbor_tiles;
108 
109  /* Stores state of the current Reconstruction operation,
110  * which is accessed by the device in order to perform the operation. */
114 
115  int source_w;
116  int source_h;
118 
119  /* Stores state of the current NLM operation,
120  * which is accessed by the device in order to perform the operation. */
121  struct NLMState {
122  int r; /* Search radius of the filter. */
123  int f; /* Patch size of the filter. */
124  float a; /* Variance compensation factor in the MSE estimation. */
125  float k_2; /* Squared value of the k parameter of the filter. */
126  bool is_color;
127 
128  void set_parameters(int r_, int f_, float a_, float k_2_, bool is_color_)
129  {
130  r = r_;
131  f = f_;
132  a = a_, k_2 = k_2_;
133  is_color = is_color_;
134  }
136 
137  struct Storage {
142  int w;
143  int h;
144 
146  : transform(device, "denoising transform"),
147  rank(device, "denoising rank"),
148  XtWX(device, "denoising XtWX"),
149  XtWY(device, "denoising XtWY")
150  {
151  }
153 
155  ~DenoisingTask();
156 
157  void run_denoising(RenderTile &tile);
158 
159  struct DenoiseBuffers {
161  int passes;
162  int stride;
163  int h;
164  int width;
168  bool use_time;
170 
172 
174  : mem(device, "denoising pixel buffer"),
175  temporary_mem(device, "denoising temporary mem", true)
176  {
177  }
179 
180  protected:
182 
183  void set_render_buffer(RenderTileNeighbors &neighbors);
184  void setup_denoising_buffer();
185  void prefilter_shadowing();
186  void prefilter_features();
187  void prefilter_color();
188  void construct_transform();
189  void reconstruct();
190 
191  void load_buffer();
192  void write_buffer();
193 };
194 
196 
197 #endif /* __DEVICE_DENOISING_H__ */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
void set_render_buffer(RenderTileNeighbors &neighbors)
struct DenoisingTask::Storage storage
void setup_denoising_buffer()
void run_denoising(RenderTile &tile)
struct DenoisingTask::NLMState nlm_state
struct DenoisingTask::RenderBuffers render_buffer
struct DenoisingTask::TargetBuffer target_buffer
device_vector< int > tile_info_mem
struct DenoisingTask::DeviceFunctions functions
struct DenoisingTask::DenoiseBuffers buffer
DenoisingTask(Device *device, const DeviceTask &task)
ProfilingState * profiler
struct DenoisingTask::ReconstructionState reconstruction_state
TileInfo * tile_info
Definition: device.h:293
#define CCL_NAMESPACE_END
struct blender::compositor::@172::@174 task
device_only_memory< float > mem
device_only_memory< float > temporary_mem
function< bool(device_ptr a_ptr, device_ptr b_ptr, device_ptr mean_ptr, device_ptr variance_ptr, int r, int4 rect)> combine_halves
function< bool(device_ptr image_ptr, device_ptr variance_ptr, device_ptr depth_ptr, device_ptr output_ptr)> detect_outliers
function< void(RenderTileNeighbors &neighbors)> map_neighbor_tiles
function< bool(int out_offset, device_ptr frop_ptr, device_ptr buffer_ptr)> write_feature
function< bool(device_ptr output_ptr)> solve
function< bool(device_ptr a_ptr, device_ptr b_ptr, device_ptr sample_variance_ptr, device_ptr sv_variance_ptr, device_ptr buffer_variance_ptr)> divide_shadow
function< void(RenderTileNeighbors &neighbors)> unmap_neighbor_tiles
function< bool()> construct_transform
function< bool(int mean_offset, int variance_offset, device_ptr mean_ptr, device_ptr variance_ptr, float scale)> get_feature
function< bool(device_ptr color_ptr, device_ptr color_variance_ptr, device_ptr scale_ptr, int frame)> accumulate
function< bool(device_ptr image_ptr, device_ptr guide_ptr, device_ptr variance_ptr, device_ptr out_ptr)> non_local_means
void set_parameters(int r_, int f_, float a_, float k_2_, bool is_color_)
device_only_memory< float > XtWX
device_only_memory< float3 > XtWY
device_only_memory< float > transform
device_only_memory< int > rank
uint64_t device_ptr
Definition: util_types.h:62