Blender  V3.3
RE_engine.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2006 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "DNA_listBase.h"
11 #include "DNA_node_types.h"
12 #include "DNA_scene_types.h"
13 #include "RE_bake.h"
14 #include "RNA_types.h"
15 
16 #include "BLI_threads.h"
17 
18 struct BakeTargets;
19 struct BakePixel;
20 struct Depsgraph;
21 struct Main;
22 struct Object;
23 struct Render;
24 struct RenderData;
25 struct RenderEngine;
26 struct RenderEngineType;
27 struct RenderLayer;
28 struct RenderPass;
29 struct RenderResult;
30 struct ReportList;
31 struct Scene;
32 struct ViewLayer;
33 struct bNode;
34 struct bNodeTree;
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* External Engine */
41 
43 #define RE_INTERNAL 1
44 /* #define RE_FLAG_DEPRECATED 2 */
45 #define RE_USE_PREVIEW 4
46 #define RE_USE_POSTPROCESS 8
47 #define RE_USE_EEVEE_VIEWPORT 16
48 /* #define RE_USE_SAVE_BUFFERS_DEPRECATED 32 */
49 #define RE_USE_SHADING_NODES_CUSTOM 64
50 #define RE_USE_SPHERICAL_STEREO 128
51 #define RE_USE_STEREO_VIEWPORT 256
52 #define RE_USE_GPU_CONTEXT 512
53 #define RE_USE_CUSTOM_FREESTYLE 1024
54 #define RE_USE_NO_IMAGE_SAVE 2048
55 #define RE_USE_ALEMBIC_PROCEDURAL 4096
56 
58 #define RE_ENGINE_ANIMATION 1
59 #define RE_ENGINE_PREVIEW 2
60 #define RE_ENGINE_DO_DRAW 4
61 #define RE_ENGINE_DO_UPDATE 8
62 #define RE_ENGINE_RENDERING 16
63 #define RE_ENGINE_HIGHLIGHT_TILES 32
64 #define RE_ENGINE_CAN_DRAW 64
65 
66 extern ListBase R_engines;
67 
68 typedef struct RenderEngineType {
70 
71  /* type info */
72  char idname[64]; /* best keep the same size as BKE_ST_MAXNAME. */
73  char name[64];
74  int flag;
75 
76  void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Depsgraph *depsgraph);
77 
78  void (*render)(struct RenderEngine *engine, struct Depsgraph *depsgraph);
79 
80  /* Offline rendering is finished - no more view layers will be rendered.
81  *
82  * All the pending data is to be communicated from the engine back to Blender. In a possibly
83  * most memory-efficient manner (engine might free its database before making Blender to allocate
84  * full-frame render result). */
86 
87  void (*draw)(struct RenderEngine *engine,
88  const struct bContext *context,
89  struct Depsgraph *depsgraph);
90 
91  void (*bake)(struct RenderEngine *engine,
92  struct Depsgraph *depsgraph,
93  struct Object *object,
94  int pass_type,
95  int pass_filter,
96  int width,
97  int height);
98 
99  void (*view_update)(struct RenderEngine *engine,
100  const struct bContext *context,
101  struct Depsgraph *depsgraph);
102  void (*view_draw)(struct RenderEngine *engine,
103  const struct bContext *context,
104  struct Depsgraph *depsgraph);
105 
107  struct bNodeTree *ntree,
108  struct bNode *node);
110  struct Scene *scene,
111  struct ViewLayer *view_layer);
112 
114 
115  /* RNA integration */
118 
119 typedef void (*update_render_passes_cb_t)(void *userdata,
120  struct Scene *scene,
121  struct ViewLayer *view_layer,
122  const char *name,
123  int channels,
124  const char *chanid,
126 
127 typedef struct RenderEngine {
129  void *py_instance;
130 
131  int flag;
133  unsigned int layer_override;
134 
135  struct Render *re;
137  char text[512]; /* IMA_MAX_RENDER_TEXT */
138 
140 
142 
143  struct {
144  const struct BakeTargets *targets;
145  const struct BakePixel *pixels;
146  float *result;
147  int image_id;
149  } bake;
150 
151  /* Depsgraph */
154 
155  /* callback for render pass query */
159 
162  float last_viewmat[4][4];
165 
167 void RE_engine_free(RenderEngine *engine);
168 
174  struct RenderLayer *layer, struct ReportList *reports, const char *filepath, int x, int y);
176  struct ReportList *reports,
177  const char *filepath);
178 
180  RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname);
182 void RE_engine_add_pass(RenderEngine *engine,
183  const char *name,
184  int channels,
185  const char *chan_id,
186  const char *layername);
188  struct RenderResult *result,
189  bool cancel,
190  bool highlight,
191  bool merge_results);
192 struct RenderResult *RE_engine_get_result(struct RenderEngine *engine);
193 
195  const char *layer_name,
196  int index);
197 
198 const char *RE_engine_active_view_get(RenderEngine *engine);
199 void RE_engine_active_view_set(RenderEngine *engine, const char *viewname);
201  struct Object *camera,
202  bool use_spherical_stereo);
204  struct Object *camera,
205  bool use_spherical_stereo,
206  float r_modelmat[16]);
208 
209 bool RE_engine_test_break(RenderEngine *engine);
210 void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
211 void RE_engine_update_progress(RenderEngine *engine, float progress);
212 void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak);
213 void RE_engine_report(RenderEngine *engine, int type, const char *msg);
214 void RE_engine_set_error_message(RenderEngine *engine, const char *msg);
215 
216 bool RE_engine_render(struct Render *re, bool do_all);
217 
218 bool RE_engine_is_external(const struct Render *re);
219 
220 void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe);
221 
222 void RE_engine_update_render_passes(struct RenderEngine *engine,
223  struct Scene *scene,
224  struct ViewLayer *view_layer,
226  void *callback_data);
227 void RE_engine_register_pass(struct RenderEngine *engine,
228  struct Scene *scene,
229  struct ViewLayer *view_layer,
230  const char *name,
231  int channels,
232  const char *chanid,
234 
235 bool RE_engine_use_persistent_data(struct RenderEngine *engine);
236 
237 struct RenderEngine *RE_engine_get(const struct Render *re);
238 
239 /* Acquire render engine for drawing via its `draw()` callback.
240  *
241  * If drawing is not possible false is returned. If drawing is possible then the engine is
242  * "acquired" so that it can not be freed by the render pipeline.
243  *
244  * Drawing is possible if the engine has the `draw()` callback and it is in its `render()`
245  * callback. */
246 bool RE_engine_draw_acquire(struct Render *re);
247 void RE_engine_draw_release(struct Render *re);
248 
249 /* NOTE: Only used for Cycles's BLenderGPUDisplay integration with the draw manager. A subject
250  * for re-consideration. Do not use this functionality. */
251 bool RE_engine_has_render_context(struct RenderEngine *engine);
252 void RE_engine_render_context_enable(struct RenderEngine *engine);
254 
255 /* Engine Types */
256 
257 void RE_engines_init(void);
259 void RE_engines_exit(void);
260 void RE_engines_register(RenderEngineType *render_type);
261 
262 bool RE_engine_is_opengl(RenderEngineType *render_type);
263 
269 
270 RenderEngineType *RE_engines_find(const char *idname);
271 
272 rcti *RE_engine_get_current_tiles(struct Render *re, int *r_total_tiles, bool *r_needs_free);
273 struct RenderData *RE_engine_get_render_data(struct Render *re);
275  struct Main *bmain,
276  struct Scene *scene);
277 
279 
281  struct RenderEngine *engine, int x, int y, int width, int height, bool highlight);
283 
284 #ifdef __cplusplus
285 }
286 #endif
pthread_mutex_t ThreadMutex
Definition: BLI_threads.h:82
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
These structs are the foundation for all linked lists in the library system.
eNodeSocketDatatype
_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 type
_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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
bool RE_engine_draw_acquire(struct Render *re)
Definition: engine.c:1204
bool RE_engine_get_spherical_stereo(RenderEngine *engine, struct Object *camera)
Definition: engine.c:636
RenderEngine * RE_engine_create(RenderEngineType *type)
Definition: engine.c:136
RenderEngineType * RE_engines_find(const char *idname)
Definition: engine.c:98
void RE_engine_draw_release(struct Render *re)
Definition: engine.c:1218
void RE_engine_tile_highlight_set(struct RenderEngine *engine, int x, int y, int width, int height, bool highlight)
Definition: engine.c:1223
bool RE_engine_is_opengl(RenderEngineType *render_type)
Definition: engine.c:115
void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filepath)
Definition: pipeline.c:2559
void RE_engine_update_render_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer, update_render_passes_cb_t callback, void *callback_data)
Definition: engine.c:1150
void RE_engine_free_blender_memory(struct RenderEngine *engine)
Definition: engine.c:1187
bool RE_engine_supports_alembic_procedural(const RenderEngineType *render_type, Scene *scene)
Definition: engine.c:121
void RE_engine_add_pass(RenderEngine *engine, const char *name, int channels, const char *chan_id, const char *layername)
Definition: engine.c:424
void RE_engine_report(RenderEngine *engine, int type, const char *msg)
Definition: engine.c:548
rcti * RE_engine_get_current_tiles(struct Render *re, int *r_total_tiles, bool *r_needs_free)
Definition: engine.c:642
void RE_engine_active_view_set(RenderEngine *engine, const char *viewname)
Definition: engine.c:602
void RE_engine_render_context_enable(struct RenderEngine *engine)
Definition: engine.c:1265
void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, bool cancel, bool highlight, bool merge_results)
Definition: engine.c:439
void RE_bake_engine_set_engine_parameters(struct Render *re, struct Main *bmain, struct Scene *scene)
Definition: engine.c:806
void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filepath, int x, int y)
Definition: pipeline.c:2492
void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak)
Definition: engine.c:538
void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result)
Definition: engine.c:407
void RE_engine_render_context_disable(struct RenderEngine *engine)
Definition: engine.c:1270
void RE_engines_init(void)
Definition: engine.c:59
struct RenderData * RE_engine_get_render_data(struct Render *re)
Definition: engine.c:690
bool RE_engine_test_break(RenderEngine *engine)
Definition: engine.c:488
void RE_engines_init_experimental(void)
Definition: engine.c:64
void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer, const char *name, int channels, const char *chanid, eNodeSocketDatatype type)
Definition: engine.c:1171
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info)
Definition: engine.c:501
void RE_engines_exit(void)
Definition: engine.c:69
void RE_engine_tile_highlight_clear_all(struct RenderEngine *engine)
Definition: engine.c:1232
bool RE_engine_use_persistent_data(struct RenderEngine *engine)
Definition: engine.c:695
void RE_engines_register(RenderEngineType *render_type)
Definition: engine.c:90
bool RE_engine_render(struct Render *re, bool do_all)
Definition: engine.c:988
void RE_engine_free(RenderEngine *engine)
Definition: engine.c:164
struct RenderEngine * RE_engine_get(const struct Render *re)
void(* update_render_passes_cb_t)(void *userdata, struct Scene *scene, struct ViewLayer *view_layer, const char *name, int channels, const char *chanid, eNodeSocketDatatype type)
Definition: RE_engine.h:119
struct RenderResult * RE_engine_get_result(struct RenderEngine *engine)
Definition: engine.c:481
struct RenderEngine RenderEngine
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
Definition: engine.c:560
const char * RE_engine_active_view_get(RenderEngine *engine)
Definition: engine.c:596
ListBase R_engines
Definition: engine.c:57
float RE_engine_get_camera_shift_x(RenderEngine *engine, struct Object *camera, bool use_spherical_stereo)
Definition: engine.c:608
bool RE_engine_has_render_context(struct RenderEngine *engine)
Definition: engine.c:1256
struct RenderEngineType RenderEngineType
struct RenderResult * RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname)
Definition: engine.c:344
struct RenderPass * RE_engine_pass_by_index_get(struct RenderEngine *engine, const char *layer_name, int index)
Definition: engine.c:575
void RE_engine_update_progress(RenderEngine *engine, float progress)
Definition: engine.c:528
void RE_engine_get_camera_model_matrix(RenderEngine *engine, struct Object *camera, bool use_spherical_stereo, float r_modelmat[16])
Definition: engine.c:620
void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe)
Definition: engine.c:785
bool RE_engine_is_external(const struct Render *re)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
OperationNode * node
Scene scene
const Depsgraph * depsgraph
DEGForeachIDComponentCallback callback
SyclQueue void void size_t num_bytes void
bNodeTree * ntree
Definition: BKE_main.h:121
char engine[32]
void(* render)(struct RenderEngine *engine, struct Depsgraph *depsgraph)
Definition: RE_engine.h:78
void(* view_draw)(struct RenderEngine *engine, const struct bContext *context, struct Depsgraph *depsgraph)
Definition: RE_engine.h:102
void(* update)(struct RenderEngine *engine, struct Main *bmain, struct Depsgraph *depsgraph)
Definition: RE_engine.h:76
ExtensionRNA rna_ext
Definition: RE_engine.h:116
void(* view_update)(struct RenderEngine *engine, const struct bContext *context, struct Depsgraph *depsgraph)
Definition: RE_engine.h:99
char name[64]
Definition: RE_engine.h:73
struct RenderEngineType * next
Definition: RE_engine.h:69
struct DrawEngineType * draw_engine
Definition: RE_engine.h:113
void(* draw)(struct RenderEngine *engine, const struct bContext *context, struct Depsgraph *depsgraph)
Definition: RE_engine.h:87
char idname[64]
Definition: RE_engine.h:72
void(* render_frame_finish)(struct RenderEngine *engine)
Definition: RE_engine.h:85
void(* update_script_node)(struct RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node)
Definition: RE_engine.h:106
void(* update_render_passes)(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
Definition: RE_engine.h:109
void(* bake)(struct RenderEngine *engine, struct Depsgraph *depsgraph, struct Object *object, int pass_type, int pass_filter, int width, int height)
Definition: RE_engine.h:91
struct RenderEngineType * prev
Definition: RE_engine.h:69
struct ReportList * reports
Definition: RE_engine.h:141
struct Depsgraph * depsgraph
Definition: RE_engine.h:152
RenderEngineType * type
Definition: RE_engine.h:128
unsigned int layer_override
Definition: RE_engine.h:133
const struct BakePixel * pixels
Definition: RE_engine.h:145
rcti last_disprect
Definition: RE_engine.h:161
float * result
Definition: RE_engine.h:146
char text[512]
Definition: RE_engine.h:137
bool has_grease_pencil
Definition: RE_engine.h:153
struct Render * re
Definition: RE_engine.h:135
void * update_render_passes_data
Definition: RE_engine.h:158
ListBase fullresult
Definition: RE_engine.h:136
float last_viewmat[4][4]
Definition: RE_engine.h:162
void * py_instance
Definition: RE_engine.h:129
int resolution_x
Definition: RE_engine.h:139
struct RenderEngine::@1172 bake
rctf last_viewplane
Definition: RE_engine.h:160
update_render_passes_cb_t update_render_passes_cb
Definition: RE_engine.h:157
int resolution_y
Definition: RE_engine.h:139
ThreadMutex update_render_passes_mutex
Definition: RE_engine.h:156
const struct BakeTargets * targets
Definition: RE_engine.h:144
struct Object * camera_override
Definition: RE_engine.h:132
char name[64]
Definition: RE_pipeline.h:65
char name[64]