Blender  V2.93
workbench_engine.c
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  * Copyright 2016, Blender Foundation.
17  */
18 
27 #include "DRW_render.h"
28 
29 #include "BLI_alloca.h"
30 
31 #include "BKE_modifier.h"
32 #include "BKE_object.h"
33 #include "BKE_paint.h"
34 #include "BKE_particle.h"
35 
36 #include "DNA_fluid_types.h"
37 #include "DNA_hair_types.h"
38 #include "DNA_image_types.h"
39 #include "DNA_mesh_types.h"
40 #include "DNA_modifier_types.h"
41 #include "DNA_node_types.h"
42 
43 #include "workbench_engine.h"
44 #include "workbench_private.h"
45 
46 #define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
47 
48 void workbench_engine_init(void *ved)
49 {
50  WORKBENCH_Data *vedata = ved;
51  WORKBENCH_StorageList *stl = vedata->stl;
52  WORKBENCH_TextureList *txl = vedata->txl;
53 
55 
57  WORKBENCH_PrivateData *wpd = stl->wpd;
60 
61  if (txl->dummy_image_tx == NULL) {
62  const float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f};
63  txl->dummy_image_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, 0, fpixel);
64  }
65  wpd->dummy_image_tx = txl->dummy_image_tx;
66 
67  if (OBJECT_ID_PASS_ENABLED(wpd)) {
69  }
70  else {
71  /* Don't free because it's a pool texture. */
72  wpd->object_id_tx = NULL;
73  }
74 
80 }
81 
82 void workbench_cache_init(void *ved)
83 {
84  WORKBENCH_Data *vedata = ved;
85 
94 }
95 
96 /* TODO(fclem): DRW_cache_object_surface_material_get needs a refactor to allow passing NULL
97  * instead of gpumat_array. Avoiding all this boilerplate code. */
99 {
100  const int materials_len = DRW_cache_object_material_count_get(ob);
101  struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
102  memset(gpumat_array, 0, sizeof(*gpumat_array) * materials_len);
103 
104  return DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len);
105 }
106 
108  Object *ob,
109  eV3DShadingColorType color_type)
110 {
111  const bool use_single_drawcall = !ELEM(color_type, V3D_SHADING_MATERIAL_COLOR);
112  BLI_assert(color_type != V3D_SHADING_TEXTURE_COLOR);
113 
114  if (use_single_drawcall) {
115  DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, NULL);
116  DRW_shgroup_call_sculpt(grp, ob, false, false);
117  }
118  else {
119  const int materials_len = DRW_cache_object_material_count_get(ob);
120  struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len);
121  for (int i = 0; i < materials_len; i++) {
122  shgrps[i] = workbench_material_setup(wpd, ob, i + 1, color_type, NULL);
123  }
124  DRW_shgroup_call_sculpt_with_materials(shgrps, materials_len, ob);
125  }
126 }
127 
129 {
130  if (ob->type == OB_POINTCLOUD) {
131  /* Draw range to avoid drawcall batching messing up the instance attrib. */
132  DRW_shgroup_call_instance_range(grp, ob, geom, 0, 0);
133  }
134  else {
135  DRW_shgroup_call(grp, geom, ob);
136  }
137 }
138 
140 {
141  const DRWContextState *draw_ctx = DRW_context_state_get();
142  const Scene *scene = draw_ctx->scene;
143  const ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
144  const bool use_single_drawcall = imapaint->mode == IMAGEPAINT_MODE_IMAGE;
145 
146  if (use_single_drawcall) {
148  if (geom) {
149  Image *ima = imapaint->canvas;
152 
153  DRWShadingGroup *grp = workbench_image_setup(wpd, ob, 0, ima, NULL, state);
154  workbench_object_drawcall(grp, geom, ob);
155  }
156  }
157  else {
158  struct GPUBatch **geoms = DRW_cache_mesh_surface_texpaint_get(ob);
159  if (geoms) {
160  const int materials_len = DRW_cache_object_material_count_get(ob);
161  for (int i = 0; i < materials_len; i++) {
162  if (geoms[i] == NULL) {
163  continue;
164  }
165  DRWShadingGroup *grp = workbench_image_setup(wpd, ob, i + 1, NULL, NULL, 0);
166  workbench_object_drawcall(grp, geoms[i], ob);
167  }
168  }
169  }
170 }
171 
173  Object *ob,
174  eV3DShadingColorType color_type,
175  bool *r_transp)
176 {
177  const bool use_tex = ELEM(color_type, V3D_SHADING_TEXTURE_COLOR);
178  const bool use_vcol = ELEM(color_type, V3D_SHADING_VERTEX_COLOR);
179  const bool use_single_drawcall = !ELEM(
181 
182  if (use_single_drawcall) {
183  struct GPUBatch *geom;
184  if (use_vcol) {
185  if (ob->mode & OB_MODE_VERTEX_PAINT) {
187  }
188  else {
189  if (U.experimental.use_sculpt_vertex_colors) {
191  }
192  else {
194  }
195  }
196  }
197  else {
198  geom = DRW_cache_object_surface_get(ob);
199  }
200 
201  if (geom) {
202  DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, r_transp);
203  workbench_object_drawcall(grp, geom, ob);
204  }
205  }
206  else {
207  struct GPUBatch **geoms = (use_tex) ? DRW_cache_mesh_surface_texpaint_get(ob) :
209  if (geoms) {
210  const int materials_len = DRW_cache_object_material_count_get(ob);
211  for (int i = 0; i < materials_len; i++) {
212  if (geoms[i] == NULL) {
213  continue;
214  }
215  DRWShadingGroup *grp = workbench_material_setup(wpd, ob, i + 1, color_type, r_transp);
216  workbench_object_drawcall(grp, geoms[i], ob);
217  }
218  }
219  }
220 }
221 
223  Object *ob,
224  ParticleSystem *psys,
225  ModifierData *md,
226  eV3DShadingColorType color_type,
227  bool use_texpaint_mode,
228  const int matnr)
229 {
230  const DRWContextState *draw_ctx = DRW_context_state_get();
231  const Scene *scene = draw_ctx->scene;
232 
233  const ImagePaintSettings *imapaint = use_texpaint_mode ? &scene->toolsettings->imapaint : NULL;
234  Image *ima = (imapaint && imapaint->mode == IMAGEPAINT_MODE_IMAGE) ? imapaint->canvas : NULL;
236  state |= (imapaint && imapaint->interp == IMAGEPAINT_INTERP_LINEAR) ? GPU_SAMPLER_FILTER : 0;
237  DRWShadingGroup *grp = (use_texpaint_mode) ?
238  workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, state) :
239  workbench_material_hair_setup(wpd, ob, matnr, color_type);
240 
241  DRW_shgroup_hair_create_sub(ob, psys, md, grp);
242 }
243 
249  Object *ob,
250  bool *r_sculpt_pbvh,
251  bool *r_texpaint_mode,
252  bool *r_draw_shadow)
253 {
254  eV3DShadingColorType color_type = wpd->shading.color_type;
255  const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
256 
257  const DRWContextState *draw_ctx = DRW_context_state_get();
258  const bool is_active = (ob == draw_ctx->obact);
259  const bool is_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) &&
261  const bool is_render = DRW_state_is_image_render() && (draw_ctx->v3d == NULL);
262  const bool is_texpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_TEXTURE);
263  const bool is_vertpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_VERTEX);
264 
265  if (color_type == V3D_SHADING_TEXTURE_COLOR) {
266  if (ob->dt < OB_TEXTURE) {
267  color_type = V3D_SHADING_MATERIAL_COLOR;
268  }
269  else if ((me == NULL) || (me->mloopuv == NULL)) {
270  /* Disable color mode if data layer is unavailable. */
271  color_type = V3D_SHADING_MATERIAL_COLOR;
272  }
273  }
274  else if (color_type == V3D_SHADING_VERTEX_COLOR) {
275  if (U.experimental.use_sculpt_vertex_colors) {
276  if ((me == NULL) || !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) {
277  color_type = V3D_SHADING_OBJECT_COLOR;
278  }
279  }
280  else {
281  if ((me == NULL) || !CustomData_has_layer(&me->ldata, CD_MLOOPCOL)) {
282  color_type = V3D_SHADING_OBJECT_COLOR;
283  }
284  }
285  }
286 
287  if (r_sculpt_pbvh) {
288  *r_sculpt_pbvh = is_sculpt_pbvh;
289  }
290  if (r_texpaint_mode) {
291  *r_texpaint_mode = false;
292  }
293 
294  if (!is_sculpt_pbvh && !is_render) {
295  /* Force texture or vertex mode if object is in paint mode. */
296  if (is_texpaint_mode && me && me->mloopuv) {
297  color_type = V3D_SHADING_TEXTURE_COLOR;
298  if (r_texpaint_mode) {
299  *r_texpaint_mode = true;
300  }
301  }
302  else if (is_vertpaint_mode && me && me->mloopcol) {
303  color_type = V3D_SHADING_VERTEX_COLOR;
304  }
305  }
306 
307  if (is_sculpt_pbvh && color_type == V3D_SHADING_TEXTURE_COLOR) {
308  /* Force use of material color for sculpt. */
309  color_type = V3D_SHADING_MATERIAL_COLOR;
310  }
311 
312  if (r_draw_shadow) {
313  *r_draw_shadow = (ob->dtx & OB_DRAW_NO_SHADOW_CAST) == 0 && SHADOW_ENABLED(wpd);
314  /* Currently unsupported in sculpt mode. We could revert to the slow
315  * method in this case but I'm not sure if it's a good idea given that
316  * sculpted meshes are heavy to begin with. */
317  if (is_sculpt_pbvh) {
318  *r_draw_shadow = false;
319  }
320 
321  if (is_active && DRW_object_use_hide_faces(ob)) {
322  *r_draw_shadow = false;
323  }
324  }
325 
326  return color_type;
327 }
328 
329 void workbench_cache_populate(void *ved, Object *ob)
330 {
331  WORKBENCH_Data *vedata = ved;
332  WORKBENCH_StorageList *stl = vedata->stl;
333  WORKBENCH_PrivateData *wpd = stl->wpd;
334 
335  if (!DRW_object_is_renderable(ob)) {
336  return;
337  }
338 
339  if (ob->type == OB_MESH && ob->modifiers.first != NULL) {
340  bool use_texpaint_mode;
341  int color_type = workbench_color_type_get(wpd, ob, NULL, &use_texpaint_mode, NULL);
342 
343  LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
344  if (md->type != eModifierType_ParticleSystem) {
345  continue;
346  }
347  ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
349  continue;
350  }
351  ParticleSettings *part = psys->part;
352  const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
353 
354  if (draw_as == PART_DRAW_PATH) {
356  wpd, ob, psys, md, color_type, use_texpaint_mode, part->omat);
357  }
358  }
359  }
360 
361  if (!(ob->base_flag & BASE_FROM_DUPLI)) {
365  if (fmd->domain) {
367  if (fmd->domain->type == FLUID_DOMAIN_TYPE_GAS) {
368  return; /* Do not draw solid in this case. */
369  }
370  }
371  }
372  }
373 
375  return;
376  }
377 
378  if ((ob->dt < OB_SOLID) && !DRW_state_is_scene_render()) {
379  return;
380  }
381 
383  bool use_sculpt_pbvh, use_texpaint_mode, draw_shadow, has_transp_mat = false;
385  wpd, ob, &use_sculpt_pbvh, &use_texpaint_mode, &draw_shadow);
386 
387  if (use_sculpt_pbvh) {
388  workbench_cache_sculpt_populate(wpd, ob, color_type);
389  }
390  else if (use_texpaint_mode) {
392  }
393  else {
394  workbench_cache_common_populate(wpd, ob, color_type, &has_transp_mat);
395  }
396 
397  if (draw_shadow) {
398  workbench_shadow_cache_populate(vedata, ob, has_transp_mat);
399  }
400  }
401  else if (ob->type == OB_HAIR) {
402  int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
403  workbench_cache_hair_populate(wpd, ob, NULL, NULL, color_type, false, HAIR_MATERIAL_NR);
404  }
405  else if (ob->type == OB_VOLUME) {
406  if (wpd->shading.type != OB_WIRE) {
407  int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
408  workbench_volume_cache_populate(vedata, wpd->scene, ob, NULL, color_type);
409  }
410  }
411 }
412 
413 void workbench_cache_finish(void *ved)
414 {
415  WORKBENCH_Data *vedata = ved;
416  WORKBENCH_StorageList *stl = vedata->stl;
417  WORKBENCH_FramebufferList *fbl = vedata->fbl;
418  WORKBENCH_PrivateData *wpd = stl->wpd;
419 
420  /* TODO(fclem): Only do this when really needed. */
421  {
422  /* HACK we allocate the in front depth here to avoid the overhead when if is not needed. */
425 
427 
428  GPU_framebuffer_ensure_config(&dfbl->in_front_fb,
429  {
430  GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
431  GPU_ATTACHMENT_TEXTURE(dtxl->color),
432  });
433 
434  GPU_framebuffer_ensure_config(&fbl->opaque_infront_fb,
435  {
436  GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
437  GPU_ATTACHMENT_TEXTURE(wpd->material_buffer_tx),
438  GPU_ATTACHMENT_TEXTURE(wpd->normal_buffer_tx),
439  GPU_ATTACHMENT_TEXTURE(wpd->object_id_tx),
440  });
441 
442  GPU_framebuffer_ensure_config(&fbl->transp_accum_infront_fb,
443  {
444  GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
445  GPU_ATTACHMENT_TEXTURE(wpd->accum_buffer_tx),
446  GPU_ATTACHMENT_TEXTURE(wpd->reveal_buffer_tx),
447  });
448  }
449 
450  if (wpd->object_id_tx) {
451  GPU_framebuffer_ensure_config(&fbl->id_clear_fb,
452  {
453  GPU_ATTACHMENT_NONE,
454  GPU_ATTACHMENT_TEXTURE(wpd->object_id_tx),
455  });
456  }
457  else {
459  }
460 
462 
463  /* TODO don't free reuse next redraw. */
464  for (int i = 0; i < 2; i++) {
465  for (int j = 0; j < 2; j++) {
466  for (int k = 0; k < WORKBENCH_DATATYPE_MAX; k++) {
467  if (wpd->prepass[i][j][k].material_hash) {
468  BLI_ghash_free(wpd->prepass[i][j][k].material_hash, NULL, NULL);
469  wpd->prepass[i][j][k].material_hash = NULL;
470  }
471  }
472  }
473  }
474 }
475 
476 /* Used by viewport rendering & final rendering.
477  * Do one render loop iteration (i.e: One TAA sample). */
478 void workbench_draw_sample(void *ved)
479 {
480  WORKBENCH_Data *vedata = ved;
481  WORKBENCH_FramebufferList *fbl = vedata->fbl;
482  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
483  WORKBENCH_PassList *psl = vedata->psl;
485  const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
486  const float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f};
487 
488  const bool do_render = workbench_antialiasing_setup(vedata);
489  const bool xray_is_visible = wpd->shading.xray_alpha > 0.0f;
490  const bool do_transparent_infront_pass = !DRW_pass_is_empty(psl->transp_accum_infront_ps);
491  const bool do_transparent_pass = !DRW_pass_is_empty(psl->transp_accum_ps);
492  const bool do_opaque_infront_pass = !DRW_pass_is_empty(psl->opaque_infront_ps);
493  const bool do_opaque_pass = !DRW_pass_is_empty(psl->opaque_ps) || do_opaque_infront_pass;
494 
495  if (dfbl->in_front_fb) {
497  GPU_framebuffer_clear_depth(dfbl->in_front_fb, 1.0f);
498  }
499 
500  if (do_render) {
502  GPU_framebuffer_clear_color_depth_stencil(dfbl->default_fb, wpd->background_color, 1.0f, 0x00);
503 
504  if (fbl->id_clear_fb) {
506  GPU_framebuffer_clear_color(fbl->id_clear_fb, clear_col);
507  }
508 
509  if (do_opaque_pass) {
511  DRW_draw_pass(psl->opaque_ps);
512 
513  if (psl->shadow_ps[0]) {
514  DRW_draw_pass(psl->shadow_ps[0]);
515  DRW_draw_pass(psl->shadow_ps[1]);
516  }
517 
518  if (do_opaque_infront_pass) {
521 
524  }
525 
528 
529  if (psl->cavity_ps) {
531  DRW_draw_pass(psl->cavity_ps);
532  }
533  }
534 
536 
537  if (xray_is_visible) {
538  if (do_transparent_pass) {
540  GPU_framebuffer_clear_color(fbl->transp_accum_fb, clear_col_with_alpha);
541 
543 
546  }
547 
548  if (do_transparent_infront_pass) {
550  GPU_framebuffer_clear_color(fbl->transp_accum_infront_fb, clear_col_with_alpha);
551 
553 
556  }
557  }
558 
560 
561  if (psl->outline_ps) {
564  }
565 
566  workbench_dof_draw_pass(vedata);
567  }
568 
570 }
571 
572 /* Viewport rendering. */
573 static void workbench_draw_scene(void *ved)
574 {
575  WORKBENCH_Data *vedata = ved;
576  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
577 
579  while (wpd->taa_sample < max_ii(1, wpd->taa_sample_len)) {
581 
582  workbench_draw_sample(vedata);
583  }
584  }
585  else {
586  workbench_draw_sample(vedata);
587  }
588 
589  workbench_draw_finish(vedata);
590 }
591 
592 void workbench_draw_finish(void *ved)
593 {
594  WORKBENCH_Data *vedata = ved;
596  /* Reset default view. */
598 }
599 
600 static void workbench_engine_free(void)
601 {
603 }
604 
605 static void workbench_view_update(void *vedata)
606 {
607  WORKBENCH_Data *data = vedata;
609 }
610 
611 static void workbench_id_update(void *UNUSED(vedata), struct ID *id)
612 {
613  if (GS(id->name) == ID_OB) {
616  if (oed != NULL && oed->dd.recalc != 0) {
617  oed->shadow_bbox_dirty = (oed->dd.recalc & ID_RECALC_ALL) != 0;
618  oed->dd.recalc = 0;
619  }
620  }
621 }
622 
624 
626  NULL,
627  NULL,
628  N_("Workbench"),
639  NULL,
640 };
641 
643  NULL,
644  NULL,
646  N_("Workbench"),
648  NULL,
650  NULL,
651  NULL,
652  NULL,
653  NULL,
656  {NULL, NULL, NULL},
657 };
658 
659 #undef WORKBENCH_ENGINE
@ CTX_MODE_PAINT_TEXTURE
Definition: BKE_context.h:126
@ CTX_MODE_PAINT_VERTEX
Definition: BKE_context.h:125
bool CustomData_has_layer(const struct CustomData *data, int type)
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
struct ModifierData * BKE_modifiers_findby_type(const struct Object *ob, ModifierType type)
General operations, lookup, etc. for blender objects.
@ OB_VISIBLE_SELF
Definition: BKE_object.h:125
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d)
#define BLI_array_alloca(arr, realsize)
Definition: BLI_alloca.h:36
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:1008
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
MINLINE int max_ii(int a, int b)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define N_(msgid)
@ ID_RECALC_ALL
Definition: DNA_ID.h:697
@ ID_OB
Definition: DNA_ID_enums.h:59
@ CD_PROP_COLOR
@ CD_MLOOPCOL
@ FLUID_DOMAIN_TYPE_GAS
#define HAIR_MATERIAL_NR
@ BASE_FROM_DUPLI
@ eModifierMode_Realtime
@ eModifierType_ParticleSystem
@ eModifierType_Fluid
@ OB_WIRE
@ OB_TEXTURE
@ OB_SOLID
@ OB_MODE_VERTEX_PAINT
@ OB_DRAW_NO_SHADOW_CAST
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_POINTCLOUD
@ OB_HAIR
@ OB_VOLUME
@ OB_CURVE
#define PART_DRAW_PATH
#define PART_DRAW_REND
@ IMAGEPAINT_MODE_IMAGE
@ IMAGEPAINT_INTERP_LINEAR
eV3DShadingColorType
@ V3D_SHADING_TEXTURE_COLOR
@ V3D_SHADING_VERTEX_COLOR
@ V3D_SHADING_MATERIAL_COLOR
@ V3D_SHADING_OBJECT_COLOR
@ V3D_SHADING_SINGLE_COLOR
#define DRW_VIEWPORT_DATA_SIZE(ty)
Definition: DRW_render.h:97
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:420
GPUBatch
Definition: GPU_batch.h:93
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
eGPUSamplerState
Definition: GPU_texture.h:40
@ GPU_SAMPLER_REPEAT
Definition: GPU_texture.h:52
@ GPU_SAMPLER_FILTER
Definition: GPU_texture.h:42
@ GPU_R16UI
Definition: GPU_texture.h:112
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:121
@ GPU_RGBA8
Definition: GPU_texture.h:88
#define RE_USE_STEREO_VIEWPORT
Definition: RE_engine.h:65
#define RE_INTERNAL
Definition: RE_engine.h:57
#define RE_USE_GPU_CONTEXT
Definition: RE_engine.h:66
unsigned int U
Definition: btGjkEpa3.h:78
Scene scene
GPUBatch * DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
Definition: draw_cache.c:2899
GPUBatch * DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
Definition: draw_cache.c:2887
GPUBatch ** DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:969
GPUBatch * DRW_cache_mesh_surface_vertpaint_get(Object *ob)
Definition: draw_cache.c:2893
GPUBatch ** DRW_cache_mesh_surface_texpaint_get(Object *ob)
Definition: draw_cache.c:2881
int DRW_cache_object_material_count_get(struct Object *ob)
Definition: draw_cache.c:936
GPUBatch * DRW_cache_object_surface_get(Object *ob)
Definition: draw_cache.c:886
struct DRWShadingGroup * DRW_shgroup_hair_create_sub(struct Object *object, struct ParticleSystem *psys, struct ModifierData *md, struct DRWShadingGroup *shgrp)
Definition: draw_hair.c:222
bool DRW_state_is_opengl_render(void)
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:697
bool DRW_object_is_renderable(const Object *ob)
Definition: draw_manager.c:183
int DRW_object_visibility_in_active_context(const Object *ob)
Definition: draw_manager.c:235
bool DRW_object_is_visible_psys_in_active_context(const Object *object, const ParticleSystem *psys)
Definition: draw_manager.c:271
const DRWContextState * DRW_context_state_get(void)
void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
DrawData * DRW_drawdata_get(ID *id, DrawEngineType *engine_type)
Definition: draw_manager.c:883
bool DRW_object_use_hide_faces(const struct Object *ob)
Definition: draw_manager.c:252
bool DRW_state_is_image_render(void)
bool DRW_state_is_scene_render(void)
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:702
void DRW_shgroup_call_instance_range(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint i_sta, uint i_ct)
bool DRW_pass_is_empty(DRWPass *pass)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask)
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, int num_shgroups, Object *ob)
void DRW_view_set_active(DRWView *view)
void DRW_draw_pass(DRWPass *pass)
void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags)
GPUTexture * DRW_texture_pool_query_fullscreen(eGPUTextureFormat format, DrawEngineType *engine_type)
GPUTexture * DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
#define GS(x)
Definition: iris.c:241
static ulong state[N]
struct Scene * scene
Definition: DRW_render.h:745
struct GPUFrameBuffer * in_front_fb
struct GPUFrameBuffer * default_fb
struct GPUFrameBuffer * color_only_fb
struct GPUTexture * depth_in_front
int recalc
Definition: DNA_ID.h:55
struct FluidDomainSettings * domain
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
struct Image * canvas
void * first
Definition: DNA_listBase.h:47
struct CustomData pdata ldata
struct MLoopCol * mloopcol
struct MLoopUV * mloopuv
short base_flag
ListBase modifiers
void * data
ParticleSettings * part
struct ToolSettings * toolsettings
struct ImagePaintSettings imapaint
WORKBENCH_FramebufferList * fbl
WORKBENCH_PassList * psl
WORKBENCH_StorageList * stl
WORKBENCH_TextureList * txl
struct GPUFrameBuffer * opaque_fb
struct GPUFrameBuffer * transp_accum_fb
struct GPUFrameBuffer * opaque_infront_fb
struct GPUFrameBuffer * id_clear_fb
struct GPUFrameBuffer * transp_accum_infront_fb
struct DRWPass * composite_ps
struct DRWPass * opaque_infront_ps
struct DRWPass * transp_accum_ps
struct DRWPass * shadow_ps[2]
struct DRWPass * merge_infront_ps
struct DRWPass * outline_ps
struct DRWPass * opaque_ps
struct DRWPass * transp_resolve_ps
struct DRWPass * transp_accum_infront_ps
struct DRWPass * cavity_ps
struct GHash * material_hash
struct GPUTexture * object_id_tx
eContextObjectMode ctx_mode
struct GPUTexture * dummy_image_tx
WORKBENCH_Prepass prepass[2][2][WORKBENCH_DATATYPE_MAX]
struct WORKBENCH_PrivateData * wpd
struct GPUTexture * dummy_image_tx
void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
void workbench_private_data_alloc(WORKBENCH_StorageList *stl)
void workbench_update_world_ubo(WORKBENCH_PrivateData *wpd)
void workbench_update_material_ubos(WORKBENCH_PrivateData *UNUSED(wpd))
void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata)
bool workbench_antialiasing_setup(WORKBENCH_Data *vedata)
void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata)
void workbench_antialiasing_cache_init(WORKBENCH_Data *vedata)
void workbench_antialiasing_view_updated(WORKBENCH_Data *vedata)
void workbench_cavity_cache_init(WORKBENCH_Data *data)
void workbench_dof_cache_init(WORKBENCH_Data *vedata)
void workbench_dof_draw_pass(WORKBENCH_Data *vedata)
void workbench_dof_engine_init(WORKBENCH_Data *vedata)
void workbench_outline_cache_init(WORKBENCH_Data *data)
#define WORKBENCH_ENGINE
static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd, Object *ob, bool *r_sculpt_pbvh, bool *r_texpaint_mode, bool *r_draw_shadow)
static void workbench_cache_texpaint_populate(WORKBENCH_PrivateData *wpd, Object *ob)
static void workbench_draw_scene(void *ved)
static struct GPUBatch ** workbench_object_surface_material_get(Object *ob)
DrawEngineType draw_engine_workbench
static void workbench_engine_free(void)
void workbench_cache_populate(void *ved, Object *ob)
static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd, Object *ob, eV3DShadingColorType color_type)
RenderEngineType DRW_engine_viewport_workbench_type
void workbench_cache_init(void *ved)
static void workbench_id_update(void *UNUSED(vedata), struct ID *id)
void workbench_engine_init(void *ved)
BLI_INLINE void workbench_object_drawcall(DRWShadingGroup *grp, struct GPUBatch *geom, Object *ob)
static void workbench_view_update(void *vedata)
static void workbench_cache_hair_populate(WORKBENCH_PrivateData *wpd, Object *ob, ParticleSystem *psys, ModifierData *md, eV3DShadingColorType color_type, bool use_texpaint_mode, const int matnr)
static void workbench_cache_common_populate(WORKBENCH_PrivateData *wpd, Object *ob, eV3DShadingColorType color_type, bool *r_transp)
void workbench_cache_finish(void *ved)
void workbench_draw_sample(void *ved)
void workbench_draw_finish(void *ved)
static const DrawEngineDataSize workbench_data_size
void workbench_opaque_cache_init(WORKBENCH_Data *vedata)
void workbench_opaque_engine_init(WORKBENCH_Data *data)
void workbench_shader_library_ensure(void)
void workbench_transparent_engine_init(WORKBENCH_Data *data)
void workbench_volume_cache_init(WORKBENCH_Data *vedata)
void workbench_volume_draw_pass(WORKBENCH_Data *vedata)
void workbench_shader_free(void)
void workbench_shadow_cache_populate(WORKBENCH_Data *data, Object *ob, const bool has_transp_mat)
void workbench_volume_draw_finish(WORKBENCH_Data *vedata)
void workbench_transparent_cache_init(WORKBENCH_Data *data)
#define workbench_material_setup(wpd, ob, mat_nr, color_type, r_transp)
#define workbench_image_hair_setup(wpd, ob, mat_nr, ima, iuser, interp)
#define workbench_material_hair_setup(wpd, ob, mat_nr, color_type)
void workbench_volume_engine_init(WORKBENCH_Data *vedata)
void workbench_render_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
@ WORKBENCH_DATATYPE_MAX
#define workbench_image_setup(wpd, ob, mat_nr, ima, iuser, interp)
void workbench_shadow_cache_init(WORKBENCH_Data *data)
#define OBJECT_ID_PASS_ENABLED(wpd)
void workbench_render(void *ved, struct RenderEngine *engine, struct RenderLayer *render_layer, const struct rcti *rect)
#define SHADOW_ENABLED(wpd)
void workbench_transparent_draw_depth_pass(WORKBENCH_Data *data)
void workbench_volume_cache_populate(WORKBENCH_Data *vedata, struct Scene *scene, struct Object *ob, struct ModifierData *md, eV3DShadingColorType color_type)