Blender  V2.93
RE_engine.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2006 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "DNA_listBase.h"
27 #include "DNA_node_types.h"
28 #include "DNA_scene_types.h"
29 #include "RE_bake.h"
30 #include "RNA_types.h"
31 
32 #include "BLI_threads.h"
33 
34 struct BakePixel;
35 struct Depsgraph;
36 struct Main;
37 struct Object;
38 struct Render;
39 struct RenderData;
40 struct RenderEngine;
41 struct RenderEngineType;
42 struct RenderLayer;
43 struct RenderResult;
44 struct ReportList;
45 struct Scene;
46 struct ViewLayer;
47 struct bNode;
48 struct bNodeTree;
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /* External Engine */
55 
56 /* RenderEngineType.flag */
57 #define RE_INTERNAL 1
58 /* #define RE_FLAG_DEPRECATED 2 */
59 #define RE_USE_PREVIEW 4
60 #define RE_USE_POSTPROCESS 8
61 #define RE_USE_EEVEE_VIEWPORT 16
62 #define RE_USE_SAVE_BUFFERS 32
63 #define RE_USE_SHADING_NODES_CUSTOM 64
64 #define RE_USE_SPHERICAL_STEREO 128
65 #define RE_USE_STEREO_VIEWPORT 256
66 #define RE_USE_GPU_CONTEXT 512
67 #define RE_USE_CUSTOM_FREESTYLE 1024
68 
69 /* RenderEngine.flag */
70 #define RE_ENGINE_ANIMATION 1
71 #define RE_ENGINE_PREVIEW 2
72 #define RE_ENGINE_DO_DRAW 4
73 #define RE_ENGINE_DO_UPDATE 8
74 #define RE_ENGINE_RENDERING 16
75 #define RE_ENGINE_HIGHLIGHT_TILES 32
76 
77 extern ListBase R_engines;
78 
79 typedef struct RenderEngineType {
81 
82  /* type info */
83  char idname[64]; /* best keep the same size as BKE_ST_MAXNAME. */
84  char name[64];
85  int flag;
86 
87  void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Depsgraph *depsgraph);
88  void (*render)(struct RenderEngine *engine, struct Depsgraph *depsgraph);
89  void (*bake)(struct RenderEngine *engine,
90  struct Depsgraph *depsgraph,
91  struct Object *object,
92  const int pass_type,
93  const int pass_filter,
94  const int width,
95  const int height);
96 
97  void (*view_update)(struct RenderEngine *engine,
98  const struct bContext *context,
99  struct Depsgraph *depsgraph);
100  void (*view_draw)(struct RenderEngine *engine,
101  const struct bContext *context,
102  struct Depsgraph *depsgraph);
103 
104  void (*update_script_node)(struct RenderEngine *engine,
105  struct bNodeTree *ntree,
106  struct bNode *node);
107  void (*update_render_passes)(struct RenderEngine *engine,
108  struct Scene *scene,
109  struct ViewLayer *view_layer);
110 
112 
113  /* RNA integration */
116 
117 typedef void (*update_render_passes_cb_t)(void *userdata,
118  struct Scene *scene,
119  struct ViewLayer *view_layer,
120  const char *name,
121  int channels,
122  const char *chanid,
124 
125 typedef struct RenderEngine {
127  void *py_instance;
128 
129  int flag;
131  unsigned int layer_override;
132 
133  int tile_x;
134  int tile_y;
135 
136  struct Render *re;
138  char text[512]; /* IMA_MAX_RENDER_TEXT */
139 
141 
143 
144  struct {
145  const struct BakePixel *pixels;
146  float *result;
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 
170  struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y);
172  struct ReportList *reports,
173  const char *filename);
174 
176  RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname);
178 void RE_engine_add_pass(RenderEngine *engine,
179  const char *name,
180  int channels,
181  const char *chan_id,
182  const char *layername);
184  struct RenderResult *result,
185  bool cancel,
186  bool highlight,
187  bool merge_results);
188 struct RenderResult *RE_engine_get_result(struct RenderEngine *engine);
189 
190 const char *RE_engine_active_view_get(RenderEngine *engine);
191 void RE_engine_active_view_set(RenderEngine *engine, const char *viewname);
193  struct Object *camera,
194  bool use_spherical_stereo);
196  struct Object *camera,
197  bool use_spherical_stereo,
198  float *r_modelmat);
199 bool RE_engine_get_spherical_stereo(RenderEngine *engine, struct Object *camera);
200 
201 bool RE_engine_test_break(RenderEngine *engine);
202 void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
203 void RE_engine_update_progress(RenderEngine *engine, float progress);
204 void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak);
205 void RE_engine_report(RenderEngine *engine, int type, const char *msg);
206 void RE_engine_set_error_message(RenderEngine *engine, const char *msg);
207 
208 bool RE_engine_render(struct Render *re, bool do_all);
209 
210 bool RE_engine_is_external(const struct Render *re);
211 
212 void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe);
213 
214 void RE_engine_update_render_passes(struct RenderEngine *engine,
215  struct Scene *scene,
216  struct ViewLayer *view_layer,
218  void *callback_data);
219 void RE_engine_register_pass(struct RenderEngine *engine,
220  struct Scene *scene,
221  struct ViewLayer *view_layer,
222  const char *name,
223  int channels,
224  const char *chanid,
226 
227 bool RE_engine_use_persistent_data(struct RenderEngine *engine);
228 
229 /* Engine Types */
230 
231 void RE_engines_init(void);
232 void RE_engines_exit(void);
233 void RE_engines_register(RenderEngineType *render_type);
234 
235 bool RE_engine_is_opengl(RenderEngineType *render_type);
236 
237 RenderEngineType *RE_engines_find(const char *idname);
238 
239 rcti *RE_engine_get_current_tiles(struct Render *re, int *r_total_tiles, bool *r_needs_free);
240 struct RenderData *RE_engine_get_render_data(struct Render *re);
242  struct Main *bmain,
243  struct Scene *scene);
244 
246 
247 #ifdef __cplusplus
248 }
249 #endif
pthread_mutex_t ThreadMutex
Definition: BLI_threads.h:83
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
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 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
bool RE_engine_get_spherical_stereo(RenderEngine *engine, struct Object *camera)
Definition: engine.c:562
RenderEngine * RE_engine_create(RenderEngineType *type)
Definition: engine.c:133
RenderEngineType * RE_engines_find(const char *idname)
Definition: engine.c:108
bool RE_engine_is_opengl(RenderEngineType *render_type)
Definition: engine.c:125
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:1071
void RE_engine_free_blender_memory(struct RenderEngine *engine)
Definition: engine.c:1108
void RE_engine_add_pass(RenderEngine *engine, const char *name, int channels, const char *chan_id, const char *layername)
Definition: engine.c:359
void RE_engine_report(RenderEngine *engine, int type, const char *msg)
Definition: engine.c:495
rcti * RE_engine_get_current_tiles(struct Render *re, int *r_total_tiles, bool *r_needs_free)
Definition: engine.c:568
void RE_engine_active_view_set(RenderEngine *engine, const char *viewname)
Definition: engine.c:528
void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filename)
Definition: pipeline.c:2731
void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, bool cancel, bool highlight, bool merge_results)
Definition: engine.c:374
void RE_bake_engine_set_engine_parameters(struct Render *re, struct Main *bmain, struct Scene *scene)
Definition: engine.c:731
void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak)
Definition: engine.c:485
void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result)
Definition: engine.c:343
void RE_engines_init(void)
Definition: engine.c:74
struct RenderData * RE_engine_get_render_data(struct Render *re)
Definition: engine.c:616
bool RE_engine_test_break(RenderEngine *engine)
Definition: engine.c:435
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:1092
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info)
Definition: engine.c:448
void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y)
Definition: pipeline.c:2664
void RE_engines_exit(void)
Definition: engine.c:79
bool RE_engine_use_persistent_data(struct RenderEngine *engine)
Definition: engine.c:621
void RE_engines_register(RenderEngineType *render_type)
Definition: engine.c:100
bool RE_engine_render(struct Render *re, bool do_all)
Definition: engine.c:889
void RE_engine_free(RenderEngine *engine)
Definition: engine.c:161
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:117
struct RenderResult * RE_engine_get_result(struct RenderEngine *engine)
Definition: engine.c:428
struct RenderEngine RenderEngine
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
Definition: engine.c:507
const char * RE_engine_active_view_get(RenderEngine *engine)
Definition: engine.c:522
ListBase R_engines
Definition: engine.c:72
float RE_engine_get_camera_shift_x(RenderEngine *engine, struct Object *camera, bool use_spherical_stereo)
Definition: engine.c:534
void RE_engine_get_camera_model_matrix(RenderEngine *engine, struct Object *camera, bool use_spherical_stereo, float *r_modelmat)
Definition: engine.c:546
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:279
void RE_engine_update_progress(RenderEngine *engine, float progress)
Definition: engine.c:475
void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe)
Definition: engine.c:711
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
bNodeTree * ntree
struct SELECTID_Context context
Definition: select_engine.c:47
Definition: BKE_main.h:116
char engine[32]
void(* render)(struct RenderEngine *engine, struct Depsgraph *depsgraph)
Definition: RE_engine.h:88
void(* view_draw)(struct RenderEngine *engine, const struct bContext *context, struct Depsgraph *depsgraph)
Definition: RE_engine.h:100
void(* update)(struct RenderEngine *engine, struct Main *bmain, struct Depsgraph *depsgraph)
Definition: RE_engine.h:87
ExtensionRNA rna_ext
Definition: RE_engine.h:114
void(* view_update)(struct RenderEngine *engine, const struct bContext *context, struct Depsgraph *depsgraph)
Definition: RE_engine.h:97
char name[64]
Definition: RE_engine.h:84
struct RenderEngineType * next
Definition: RE_engine.h:80
struct DrawEngineType * draw_engine
Definition: RE_engine.h:111
void(* bake)(struct RenderEngine *engine, struct Depsgraph *depsgraph, struct Object *object, const int pass_type, const int pass_filter, const int width, const int height)
Definition: RE_engine.h:89
char idname[64]
Definition: RE_engine.h:83
void(* update_script_node)(struct RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node)
Definition: RE_engine.h:104
void(* update_render_passes)(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
Definition: RE_engine.h:107
struct RenderEngineType * prev
Definition: RE_engine.h:80
struct ReportList * reports
Definition: RE_engine.h:142
struct Depsgraph * depsgraph
Definition: RE_engine.h:152
RenderEngineType * type
Definition: RE_engine.h:126
unsigned int layer_override
Definition: RE_engine.h:131
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:138
bool has_grease_pencil
Definition: RE_engine.h:153
struct Render * re
Definition: RE_engine.h:136
void * update_render_passes_data
Definition: RE_engine.h:158
ListBase fullresult
Definition: RE_engine.h:137
float last_viewmat[4][4]
Definition: RE_engine.h:162
void * py_instance
Definition: RE_engine.h:127
struct RenderEngine::@1136 bake
int resolution_x
Definition: RE_engine.h:140
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:140
ThreadMutex update_render_passes_mutex
Definition: RE_engine.h:156
struct Object * camera_override
Definition: RE_engine.h:130
char name[64]