Blender  V2.93
buffers.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 __BUFFERS_H__
18 #define __BUFFERS_H__
19 
20 #include "device/device_memory.h"
21 
22 #include "render/film.h"
23 
24 #include "kernel/kernel_types.h"
25 
26 #include "util/util_half.h"
27 #include "util/util_string.h"
28 #include "util/util_thread.h"
29 #include "util/util_types.h"
30 
32 
33 class Device;
34 struct DeviceDrawParams;
35 struct float4;
36 
37 /* Buffer Parameters
38  * Size of render buffer and how it fits in the full image (border render). */
39 
40 class BufferParams {
41  public:
42  /* width/height of the physical buffer */
43  int width;
44  int height;
45 
46  /* offset into and width/height of the full buffer */
47  int full_x;
48  int full_y;
51 
52  /* passes */
55  /* If only some light path types should be target, an additional pass is needed. */
57  /* When we're prefiltering the passes during rendering, we need to keep both the
58  * original and the prefiltered data around because neighboring tiles might still
59  * need the original data. */
61 
62  /* functions */
63  BufferParams();
64 
65  void get_offset_stride(int &offset, int &stride);
66  bool modified(const BufferParams &params);
67  int get_passes_size();
70 };
71 
72 /* Render Buffers */
73 
75  public:
76  /* buffer parameters */
78 
79  /* float buffer */
82  double render_time;
83 
84  explicit RenderBuffers(Device *device);
86 
87  void reset(BufferParams &params);
88  void zero();
89 
90  bool copy_from_device();
91  bool get_pass_rect(
92  const string &name, float exposure, int sample, int components, float *pixels);
94  int offset, float exposure, int sample, int components, float *pixels);
95  bool set_pass_rect(PassType type, int components, float *pixels, int samples);
96 };
97 
98 /* Display Buffer
99  *
100  * The buffer used for drawing during render, filled by converting the render
101  * buffers to byte of half float storage */
102 
104  public:
105  /* buffer parameters */
107  /* dimensions for how much of the buffer is actually ready for display.
108  * with progressive render we can be using only a subset of the buffer.
109  * if these are zero, it means nothing can be drawn yet */
111  /* draw alpha channel? */
113  /* use half float? */
115  /* byte buffer for converted result */
118 
119  DisplayBuffer(Device *device, bool linear = false);
120  ~DisplayBuffer();
121 
122  void reset(BufferParams &params);
123 
124  void draw_set(int width, int height);
125  void draw(Device *device, const DeviceDrawParams &draw_params);
126  bool draw_ready();
127 };
128 
129 /* Render Tile
130  * Rendering task on a buffer */
131 
132 class RenderTile {
133  public:
134  typedef enum { PATH_TRACE = (1 << 0), BAKE = (1 << 1), DENOISE = (1 << 2) } Task;
135 
137  int x, y, w, h;
140  int sample;
142  int offset;
143  int stride;
145 
148 
149  typedef enum { NO_STEALING = 0, CAN_BE_STOLEN = 1, WAS_STOLEN = 2 } StealingState;
151 
153 
154  RenderTile();
155 
156  int4 bounds() const
157  {
158  return make_int4(x, /* xmin */
159  y, /* ymin */
160  x + w, /* xmax */
161  y + h); /* ymax */
162  }
163 };
164 
165 /* Render Tile Neighbors
166  * Set of neighboring tiles used for denoising. Tile order:
167  * 0 1 2
168  * 3 4 5
169  * 6 7 8 */
170 
172  public:
173  static const int SIZE = 9;
174  static const int CENTER = 4;
175 
178 
180  {
181  tiles[CENTER] = center;
182  }
183 
184  int4 bounds() const
185  {
186  return make_int4(tiles[3].x, /* xmin */
187  tiles[1].y, /* ymin */
188  tiles[5].x + tiles[5].w, /* xmax */
189  tiles[7].y + tiles[7].h); /* ymax */
190  }
191 
193  {
194  tiles[3].x = tiles[CENTER].x;
195  tiles[1].y = tiles[CENTER].y;
196  tiles[5].x = tiles[CENTER].x + tiles[CENTER].w;
197  tiles[7].y = tiles[CENTER].y + tiles[CENTER].h;
198  }
199 };
200 
202 
203 #endif /* __BUFFERS_H__ */
NSNotificationCenter * center
_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 width
_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 type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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 y
_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 stride
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
int width
Definition: buffers.h:43
int full_x
Definition: buffers.h:47
vector< Pass > passes
Definition: buffers.h:53
int full_width
Definition: buffers.h:49
int height
Definition: buffers.h:44
bool modified(const BufferParams &params)
Definition: buffers.cpp:56
int get_denoising_prefiltered_offset()
Definition: buffers.cpp:94
void get_offset_stride(int &offset, int &stride)
Definition: buffers.cpp:50
int get_denoising_offset()
Definition: buffers.cpp:84
int get_passes_size()
Definition: buffers.cpp:66
bool denoising_prefiltered_pass
Definition: buffers.h:60
int full_height
Definition: buffers.h:50
bool denoising_clean_pass
Definition: buffers.h:56
int full_y
Definition: buffers.h:48
bool denoising_data_pass
Definition: buffers.h:54
Definition: device.h:293
int draw_width
Definition: buffers.h:110
bool half_float
Definition: buffers.h:114
bool transparent
Definition: buffers.h:112
bool draw_ready()
Definition: buffers.cpp:568
device_pixels< uchar4 > rgba_byte
Definition: buffers.h:116
BufferParams params
Definition: buffers.h:106
DisplayBuffer(Device *device, bool linear=false)
Definition: buffers.cpp:508
void draw_set(int width, int height)
Definition: buffers.cpp:540
void reset(BufferParams &params)
Definition: buffers.cpp:524
void draw(Device *device, const DeviceDrawParams &draw_params)
Definition: buffers.cpp:548
int draw_height
Definition: buffers.h:110
device_pixels< half4 > rgba_half
Definition: buffers.h:117
bool get_pass_rect(const string &name, float exposure, int sample, int components, float *pixels)
Definition: buffers.cpp:257
bool set_pass_rect(PassType type, int components, float *pixels, int samples)
Definition: buffers.cpp:463
bool get_denoising_pass_rect(int offset, float exposure, int sample, int components, float *pixels)
Definition: buffers.cpp:169
device_vector< float > buffer
Definition: buffers.h:80
void reset(BufferParams &params)
Definition: buffers.cpp:145
void zero()
Definition: buffers.cpp:154
BufferParams params
Definition: buffers.h:77
double render_time
Definition: buffers.h:82
bool copy_from_device()
Definition: buffers.cpp:159
bool map_neighbor_copied
Definition: buffers.h:81
RenderBuffers(Device *device)
Definition: buffers.cpp:133
static const int SIZE
Definition: buffers.h:173
RenderTile target
Definition: buffers.h:177
RenderTile tiles[SIZE]
Definition: buffers.h:176
int4 bounds() const
Definition: buffers.h:184
void set_bounds_from_center()
Definition: buffers.h:192
RenderTileNeighbors(const RenderTile &center)
Definition: buffers.h:179
static const int CENTER
Definition: buffers.h:174
int stride
Definition: buffers.h:143
int sample
Definition: buffers.h:140
@ NO_STEALING
Definition: buffers.h:149
@ WAS_STOLEN
Definition: buffers.h:149
@ CAN_BE_STOLEN
Definition: buffers.h:149
RenderBuffers * buffers
Definition: buffers.h:152
int num_samples
Definition: buffers.h:139
int device_size
Definition: buffers.h:147
@ PATH_TRACE
Definition: buffers.h:134
int tile_index
Definition: buffers.h:144
device_ptr buffer
Definition: buffers.h:146
Task task
Definition: buffers.h:136
StealingState stealing_state
Definition: buffers.h:150
int offset
Definition: buffers.h:142
int resolution
Definition: buffers.h:141
int start_sample
Definition: buffers.h:138
int4 bounds() const
Definition: buffers.h:156
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define CCL_NAMESPACE_END
#define make_int4(x, y, z, w)
PassType
Definition: kernel_types.h:347
static void sample(SocketReader *reader, int x, int y, float color[4])
uint64_t device_ptr
Definition: util_types.h:62