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.
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.
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.
16 * Copyright 2016, Blender Foundation.
19 /** \file DRW_engine.h
23 #ifndef __DRW_ENGINE_H__
24 #define __DRW_ENGINE_H__
26 #include "BLI_sys_types.h" /* for bool */
29 struct DRWInstanceDataList;
32 struct DrawEngineType;
42 struct RenderEngineType;
47 struct ViewportEngineData;
52 #include "DNA_object_enums.h"
54 /* Buffer and textures used by the viewport by default */
55 typedef struct DefaultFramebufferList {
56 struct GPUFrameBuffer *default_fb;
57 struct GPUFrameBuffer *color_only_fb;
58 struct GPUFrameBuffer *depth_only_fb;
59 struct GPUFrameBuffer *multisample_fb;
60 } DefaultFramebufferList;
62 typedef struct DefaultTextureList {
63 struct GPUTexture *color;
64 struct GPUTexture *depth;
65 struct GPUTexture *multisample_color;
66 struct GPUTexture *multisample_depth;
69 void DRW_engines_register(void);
70 void DRW_engines_free(void);
72 bool DRW_engine_render_support(struct DrawEngineType *draw_engine_type);
73 void DRW_engine_register(struct DrawEngineType *draw_engine_type);
74 void DRW_engine_viewport_data_size_get(
75 const void *engine_type,
76 int *r_fbl_len, int *r_txl_len, int *r_psl_len, int *r_stl_len);
78 typedef struct DRWUpdateContext {
80 struct Depsgraph *depsgraph;
82 struct ViewLayer *view_layer;
85 struct RenderEngineType *engine_type;
87 void DRW_notify_view_update(const DRWUpdateContext *update_ctx);
90 typedef enum eDRWSelectStage { DRW_SELECT_PASS_PRE = 1, DRW_SELECT_PASS_POST, } eDRWSelectStage;
91 typedef bool (*DRW_SelectPassFn)(
92 eDRWSelectStage stage, void *user_data);
93 typedef bool (*DRW_ObjectFilterFn)(
94 struct Object *ob, void *user_data);
96 void DRW_draw_view(const struct bContext *C);
97 void DRW_draw_region_engine_info(int xoffset, int yoffset);
99 void DRW_draw_render_loop_ex(
100 struct Depsgraph *depsgraph,
101 struct RenderEngineType *engine_type,
102 struct ARegion *ar, struct View3D *v3d,
103 struct GPUViewport *viewport,
104 const struct bContext *evil_C);
105 void DRW_draw_render_loop(
106 struct Depsgraph *depsgraph,
107 struct ARegion *ar, struct View3D *v3d,
108 struct GPUViewport *viewport);
109 void DRW_draw_render_loop_offscreen(
110 struct Depsgraph *depsgraph,
111 struct RenderEngineType *engine_type,
112 struct ARegion *ar, struct View3D *v3d,
113 const bool draw_background,
114 struct GPUOffScreen *ofs,
115 struct GPUViewport *viewport);
116 void DRW_draw_select_loop(
117 struct Depsgraph *depsgraph,
118 struct ARegion *ar, struct View3D *v3d,
119 bool use_obedit_skip, bool draw_surface, bool use_nearest, const struct rcti *rect,
120 DRW_SelectPassFn select_pass_fn, void *select_pass_user_data,
121 DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data);
122 void DRW_draw_depth_loop(
123 struct Depsgraph *depsgraph,
124 struct ARegion *ar, struct View3D *v3d);
126 /* grease pencil render */
127 bool DRW_render_check_grease_pencil(struct Depsgraph *depsgraph);
128 void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph);
129 void DRW_gpencil_freecache(struct Object *ob);
131 /* This is here because GPUViewport needs it */
132 void DRW_pass_free(struct DRWPass *pass);
133 struct DRWInstanceDataList *DRW_instance_data_list_create(void);
134 void DRW_instance_data_list_free(struct DRWInstanceDataList *idatalist);
136 void DRW_opengl_context_create(void);
137 void DRW_opengl_context_destroy(void);
138 void DRW_opengl_context_enable(void);
139 void DRW_opengl_context_disable(void);
141 /* Never use this. Only for closing blender. */
142 void DRW_opengl_context_enable_ex(bool restore);
143 void DRW_opengl_context_disable_ex(bool restore);
145 void DRW_opengl_render_context_enable(void *re_gl_context);
146 void DRW_opengl_render_context_disable(void *re_gl_context);
147 void DRW_gawain_render_context_enable(void *re_gpu_context);
148 void DRW_gawain_render_context_disable(void *re_gpu_context);
150 void DRW_deferred_shader_remove(struct GPUMaterial *mat);
152 struct DrawDataList *DRW_drawdatalist_from_id(struct ID *id);
153 void DRW_drawdata_free(struct ID *id);
155 #endif /* __DRW_ENGINE_H__ */