Blender  V3.3
workbench_engine.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2016 Blender Foundation. */
3 
12 #include "DRW_render.h"
13 
14 #include "BLI_alloca.h"
15 
16 #include "BKE_editmesh.h"
17 #include "BKE_modifier.h"
18 #include "BKE_object.h"
19 #include "BKE_paint.h"
20 #include "BKE_particle.h"
21 #include "BKE_pbvh.h"
22 
23 #include "DNA_curves_types.h"
24 #include "DNA_fluid_types.h"
25 #include "DNA_image_types.h"
26 #include "DNA_mesh_types.h"
27 #include "DNA_modifier_types.h"
28 #include "DNA_node_types.h"
29 
30 #include "ED_paint.h"
31 
32 #include "workbench_engine.h"
33 #include "workbench_private.h"
34 
35 #define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
36 
37 void workbench_engine_init(void *ved)
38 {
39  WORKBENCH_Data *vedata = ved;
40  WORKBENCH_StorageList *stl = vedata->stl;
41  WORKBENCH_TextureList *txl = vedata->txl;
42 
44  WORKBENCH_PrivateData *wpd = stl->wpd;
47 
48  if (txl->dummy_image_tx == NULL) {
49  const float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f};
50  txl->dummy_image_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, 0, fpixel);
51  }
52  wpd->dummy_image_tx = txl->dummy_image_tx;
53 
54  if (OBJECT_ID_PASS_ENABLED(wpd)) {
56  }
57  else {
58  /* Don't free because it's a pool texture. */
59  wpd->object_id_tx = NULL;
60  }
61 
67 }
68 
69 void workbench_cache_init(void *ved)
70 {
71  WORKBENCH_Data *vedata = ved;
72 
81 }
82 
83 /* TODO(fclem): DRW_cache_object_surface_material_get needs a refactor to allow passing NULL
84  * instead of gpumat_array. Avoiding all this boilerplate code. */
86 {
87  const int materials_len = DRW_cache_object_material_count_get(ob);
88  struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
89  memset(gpumat_array, 0, sizeof(*gpumat_array) * materials_len);
90 
91  return DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len);
92 }
93 
95  Object *ob,
96  eV3DShadingColorType color_type)
97 {
98  const bool use_single_drawcall = !ELEM(color_type, V3D_SHADING_MATERIAL_COLOR);
99  if (use_single_drawcall) {
100  DRWShadingGroup *grp = workbench_material_setup(wpd, ob, ob->actcol, color_type, NULL);
101  DRW_shgroup_call_sculpt(grp, ob, false, false);
102  }
103  else {
104  const int materials_len = DRW_cache_object_material_count_get(ob);
105  struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len);
106  for (int i = 0; i < materials_len; i++) {
107  shgrps[i] = workbench_material_setup(wpd, ob, i + 1, color_type, NULL);
108  }
109  DRW_shgroup_call_sculpt_with_materials(shgrps, materials_len, ob);
110  }
111 }
112 
114 {
115  if (ob->type == OB_POINTCLOUD) {
116  /* Draw range to avoid drawcall batching messing up the instance attribute. */
117  DRW_shgroup_call_instance_range(grp, ob, geom, 0, 0);
118  }
119  else {
120  DRW_shgroup_call(grp, geom, ob);
121  }
122 }
123 
125 {
126  const DRWContextState *draw_ctx = DRW_context_state_get();
127  const Scene *scene = draw_ctx->scene;
128  const ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
129  const bool use_single_drawcall = imapaint->mode == IMAGEPAINT_MODE_IMAGE;
130 
131  if (use_single_drawcall) {
133  if (geom) {
134  Image *ima = imapaint->canvas;
137 
138  DRWShadingGroup *grp = workbench_image_setup(wpd, ob, 0, ima, NULL, state);
139  workbench_object_drawcall(grp, geom, ob);
140  }
141  }
142  else {
143  struct GPUBatch **geoms = DRW_cache_mesh_surface_texpaint_get(ob);
144  if (geoms) {
145  const int materials_len = DRW_cache_object_material_count_get(ob);
146  for (int i = 0; i < materials_len; i++) {
147  if (geoms[i] == NULL) {
148  continue;
149  }
150  DRWShadingGroup *grp = workbench_image_setup(wpd, ob, i + 1, NULL, NULL, 0);
151  workbench_object_drawcall(grp, geoms[i], ob);
152  }
153  }
154  }
155 }
156 
158  Object *ob,
159  eV3DShadingColorType color_type,
160  bool *r_transp)
161 {
162  const bool use_tex = ELEM(color_type, V3D_SHADING_TEXTURE_COLOR);
163  const bool use_vcol = ELEM(color_type, V3D_SHADING_VERTEX_COLOR);
164  const bool use_single_drawcall = !ELEM(
166 
167  if (use_single_drawcall) {
168  struct GPUBatch *geom;
169  if (use_vcol) {
170  if (ob->mode & OB_MODE_VERTEX_PAINT) {
172  }
173  else {
175  }
176  }
177  else {
178  geom = DRW_cache_object_surface_get(ob);
179  }
180 
181  if (geom) {
182  DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, r_transp);
183  workbench_object_drawcall(grp, geom, ob);
184  }
185  }
186  else {
187  struct GPUBatch **geoms = (use_tex) ? DRW_cache_mesh_surface_texpaint_get(ob) :
189  if (geoms) {
190  const int materials_len = DRW_cache_object_material_count_get(ob);
191  for (int i = 0; i < materials_len; i++) {
192  if (geoms[i] == NULL) {
193  continue;
194  }
195  DRWShadingGroup *grp = workbench_material_setup(wpd, ob, i + 1, color_type, r_transp);
196  workbench_object_drawcall(grp, geoms[i], ob);
197  }
198  }
199  }
200 }
201 
203  Object *ob,
204  ParticleSystem *psys,
205  ModifierData *md,
206  eV3DShadingColorType color_type,
207  bool use_texpaint_mode,
208  const int matnr)
209 {
210  const DRWContextState *draw_ctx = DRW_context_state_get();
211  const Scene *scene = draw_ctx->scene;
212 
213  const ImagePaintSettings *imapaint = use_texpaint_mode ? &scene->toolsettings->imapaint : NULL;
214  Image *ima = (imapaint && imapaint->mode == IMAGEPAINT_MODE_IMAGE) ? imapaint->canvas : NULL;
216  state |= (imapaint && imapaint->interp == IMAGEPAINT_INTERP_LINEAR) ? GPU_SAMPLER_FILTER : 0;
217  DRWShadingGroup *grp = (use_texpaint_mode) ?
218  workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, state) :
219  workbench_material_hair_setup(wpd, ob, matnr, color_type);
220 
221  DRW_shgroup_hair_create_sub(ob, psys, md, grp, NULL);
222 }
223 
225 {
229  return &mesh->edit_mesh->bm->ldata;
230  }
231  return &mesh->ldata;
232 }
233 
235 {
239  return &mesh->edit_mesh->bm->vdata;
240  }
241  return &mesh->vdata;
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  const CustomData *ldata = (me == NULL) ? NULL : workbench_mesh_get_loop_custom_data(me);
257 
258  const DRWContextState *draw_ctx = DRW_context_state_get();
259  const bool is_active = (ob == draw_ctx->obact);
260  const bool is_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d) &&
262  const bool is_render = DRW_state_is_image_render() && (draw_ctx->v3d == NULL);
263  const bool is_texpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_TEXTURE);
264  const bool is_vertpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_VERTEX);
265 
266  /* Needed for mesh cache validation, to prevent two copies of
267  * of vertex color arrays from being sent to the GPU (e.g.
268  * when switching from eevee to workbench).
269  */
270  if (ob->sculpt && ob->sculpt->pbvh) {
271  BKE_pbvh_is_drawing_set(ob->sculpt->pbvh, is_sculpt_pbvh);
272  }
273 
274  bool has_color = false;
275 
276  if (me) {
277  const CustomData *cd_vdata = workbench_mesh_get_vert_custom_data(me);
278  const CustomData *cd_ldata = workbench_mesh_get_loop_custom_data(me);
279 
280  has_color = (CustomData_has_layer(cd_vdata, CD_PROP_COLOR) ||
282  CustomData_has_layer(cd_ldata, CD_PROP_COLOR) ||
284  }
285 
286  if (color_type == V3D_SHADING_TEXTURE_COLOR) {
287  if (ob->dt < OB_TEXTURE) {
288  color_type = V3D_SHADING_MATERIAL_COLOR;
289  }
290  else if ((me == NULL) || !CustomData_has_layer(ldata, CD_MLOOPUV)) {
291  /* Disable color mode if data layer is unavailable. */
292  color_type = V3D_SHADING_MATERIAL_COLOR;
293  }
294  }
295  else if (color_type == V3D_SHADING_VERTEX_COLOR) {
296  if (!me) {
297  color_type = V3D_SHADING_OBJECT_COLOR;
298  }
299  else {
300  if (!has_color) {
301  color_type = V3D_SHADING_OBJECT_COLOR;
302  }
303  }
304  }
305 
306  if (r_sculpt_pbvh) {
307  *r_sculpt_pbvh = is_sculpt_pbvh;
308  }
309  if (r_texpaint_mode) {
310  *r_texpaint_mode = false;
311  }
312 
313  if (!is_sculpt_pbvh && !is_render) {
314  /* Force texture or vertex mode if object is in paint mode. */
315  if (is_texpaint_mode && me && CustomData_has_layer(ldata, CD_MLOOPUV)) {
316  color_type = V3D_SHADING_TEXTURE_COLOR;
317  if (r_texpaint_mode) {
318  *r_texpaint_mode = true;
319  }
320  }
321  else if (is_vertpaint_mode && me && has_color) {
322  color_type = V3D_SHADING_VERTEX_COLOR;
323  }
324  }
325 
326  if (is_sculpt_pbvh && color_type == V3D_SHADING_TEXTURE_COLOR &&
327  BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES) {
328  /* Force use of material color for sculpt. */
329  color_type = V3D_SHADING_MATERIAL_COLOR;
330  }
331 
332  if (is_sculpt_pbvh) {
333  /* Bad call C is required to access the tool system that is context aware. Cast to non-const
334  * due to current API. */
336  if (C != NULL) {
337  color_type = ED_paint_shading_color_override(
338  C, &wpd->scene->toolsettings->paint_mode, ob, color_type);
339  }
340  }
341 
342  if (r_draw_shadow) {
343  *r_draw_shadow = (ob->dtx & OB_DRAW_NO_SHADOW_CAST) == 0 && SHADOW_ENABLED(wpd);
344  /* Currently unsupported in sculpt mode. We could revert to the slow
345  * method in this case but I'm not sure if it's a good idea given that
346  * sculpted meshes are heavy to begin with. */
347  if (is_sculpt_pbvh) {
348  *r_draw_shadow = false;
349  }
350 
351  if (is_active && DRW_object_use_hide_faces(ob)) {
352  *r_draw_shadow = false;
353  }
354  }
355 
356  return color_type;
357 }
358 
359 void workbench_cache_populate(void *ved, Object *ob)
360 {
361  WORKBENCH_Data *vedata = ved;
362  WORKBENCH_StorageList *stl = vedata->stl;
363  WORKBENCH_PrivateData *wpd = stl->wpd;
364 
365  if (!DRW_object_is_renderable(ob)) {
366  return;
367  }
368 
369  if (ob->type == OB_MESH && ob->modifiers.first != NULL) {
370  bool use_texpaint_mode;
371  int color_type = workbench_color_type_get(wpd, ob, NULL, &use_texpaint_mode, NULL);
372 
373  LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
374  if (md->type != eModifierType_ParticleSystem) {
375  continue;
376  }
377  ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
379  continue;
380  }
381  ParticleSettings *part = psys->part;
382  const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
383 
384  if (draw_as == PART_DRAW_PATH) {
386  wpd, ob, psys, md, color_type, use_texpaint_mode, part->omat);
387  }
388  }
389  }
390 
391  if (!(ob->base_flag & BASE_FROM_DUPLI)) {
395  if (fmd->domain) {
397  if (fmd->domain->type == FLUID_DOMAIN_TYPE_GAS) {
398  return; /* Do not draw solid in this case. */
399  }
400  }
401  }
402  }
403 
405  return;
406  }
407 
408  if ((ob->dt < OB_SOLID) && !DRW_state_is_scene_render()) {
409  return;
410  }
411 
413  bool use_sculpt_pbvh, use_texpaint_mode, draw_shadow, has_transp_mat = false;
415  wpd, ob, &use_sculpt_pbvh, &use_texpaint_mode, &draw_shadow);
416 
417  if (use_sculpt_pbvh) {
418  workbench_cache_sculpt_populate(wpd, ob, color_type);
419  }
420  else if (use_texpaint_mode) {
422  }
423  else {
424  workbench_cache_common_populate(wpd, ob, color_type, &has_transp_mat);
425  }
426 
427  if (draw_shadow) {
428  workbench_shadow_cache_populate(vedata, ob, has_transp_mat);
429  }
430  }
431  else if (ob->type == OB_CURVES) {
432  int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
435  }
436  else if (ob->type == OB_VOLUME) {
437  if (wpd->shading.type != OB_WIRE) {
438  int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
439  workbench_volume_cache_populate(vedata, wpd->scene, ob, NULL, color_type);
440  }
441  }
442 }
443 
444 void workbench_cache_finish(void *ved)
445 {
446  WORKBENCH_Data *vedata = ved;
447  WORKBENCH_StorageList *stl = vedata->stl;
448  WORKBENCH_FramebufferList *fbl = vedata->fbl;
449  WORKBENCH_PrivateData *wpd = stl->wpd;
450 
451  /* TODO(fclem): Only do this when really needed. */
452  {
453  /* HACK we allocate the in front depth here to avoid the overhead when if is not needed. */
456 
458 
459  GPU_framebuffer_ensure_config(&dfbl->in_front_fb,
460  {
461  GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
462  GPU_ATTACHMENT_TEXTURE(dtxl->color),
463  });
464 
465  GPU_framebuffer_ensure_config(&fbl->opaque_infront_fb,
466  {
467  GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
468  GPU_ATTACHMENT_TEXTURE(wpd->material_buffer_tx),
469  GPU_ATTACHMENT_TEXTURE(wpd->normal_buffer_tx),
470  GPU_ATTACHMENT_TEXTURE(wpd->object_id_tx),
471  });
472 
473  GPU_framebuffer_ensure_config(&fbl->transp_accum_infront_fb,
474  {
475  GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
476  GPU_ATTACHMENT_TEXTURE(wpd->accum_buffer_tx),
477  GPU_ATTACHMENT_TEXTURE(wpd->reveal_buffer_tx),
478  });
479  }
480 
481  if (wpd->object_id_tx) {
482  GPU_framebuffer_ensure_config(&fbl->id_clear_fb,
483  {
484  GPU_ATTACHMENT_NONE,
485  GPU_ATTACHMENT_TEXTURE(wpd->object_id_tx),
486  });
487  }
488  else {
489  GPU_FRAMEBUFFER_FREE_SAFE(fbl->id_clear_fb);
490  }
491 
493 
494  /* TODO: don't free reuse next redraw. */
495  for (int i = 0; i < 2; i++) {
496  for (int j = 0; j < 2; j++) {
497  for (int k = 0; k < WORKBENCH_DATATYPE_MAX; k++) {
498  if (wpd->prepass[i][j][k].material_hash) {
499  BLI_ghash_free(wpd->prepass[i][j][k].material_hash, NULL, NULL);
500  wpd->prepass[i][j][k].material_hash = NULL;
501  }
502  }
503  }
504  }
505 }
506 
507 void workbench_draw_sample(void *ved)
508 {
509  WORKBENCH_Data *vedata = ved;
510  WORKBENCH_FramebufferList *fbl = vedata->fbl;
511  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
512  WORKBENCH_PassList *psl = vedata->psl;
514  const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
515  const float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f};
516 
517  const bool do_render = workbench_antialiasing_setup(vedata);
518  const bool xray_is_visible = wpd->shading.xray_alpha > 0.0f;
519  const bool do_transparent_infront_pass = !DRW_pass_is_empty(psl->transp_accum_infront_ps);
520  const bool do_transparent_pass = !DRW_pass_is_empty(psl->transp_accum_ps);
521  const bool do_opaque_infront_pass = !DRW_pass_is_empty(psl->opaque_infront_ps);
522  const bool do_opaque_pass = !DRW_pass_is_empty(psl->opaque_ps) || do_opaque_infront_pass;
523 
524  if (dfbl->in_front_fb) {
526  GPU_framebuffer_clear_depth(dfbl->in_front_fb, 1.0f);
527  }
528 
529  if (do_render) {
531  GPU_framebuffer_clear_color_depth_stencil(dfbl->default_fb, wpd->background_color, 1.0f, 0x00);
532 
533  if (fbl->id_clear_fb) {
535  GPU_framebuffer_clear_color(fbl->id_clear_fb, clear_col);
536  }
537 
538  if (do_opaque_pass) {
540  DRW_draw_pass(psl->opaque_ps);
541 
542  if (psl->shadow_ps[0]) {
543  DRW_draw_pass(psl->shadow_ps[0]);
544  DRW_draw_pass(psl->shadow_ps[1]);
545  }
546 
547  if (do_opaque_infront_pass) {
550 
553  }
554 
557 
558  if (psl->cavity_ps) {
560  DRW_draw_pass(psl->cavity_ps);
561  }
562  }
563 
565 
566  if (xray_is_visible) {
567  if (do_transparent_pass) {
569  GPU_framebuffer_clear_color(fbl->transp_accum_fb, clear_col_with_alpha);
570 
572 
575  }
576 
577  if (do_transparent_infront_pass) {
579  GPU_framebuffer_clear_color(fbl->transp_accum_infront_fb, clear_col_with_alpha);
580 
582 
585  }
586  }
587 
589 
590  if (psl->outline_ps) {
593  }
594 
595  workbench_dof_draw_pass(vedata);
596  }
597 
599 }
600 
601 /* Viewport rendering. */
602 static void workbench_draw_scene(void *ved)
603 {
604  WORKBENCH_Data *vedata = ved;
605  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
606 
608  while (wpd->taa_sample < max_ii(1, wpd->taa_sample_len)) {
610 
611  workbench_draw_sample(vedata);
612  }
613  }
614  else {
615  workbench_draw_sample(vedata);
616  }
617 
618  workbench_draw_finish(vedata);
619 }
620 
622 {
623  /* Reset default view. */
625 }
626 
627 static void workbench_engine_free(void)
628 {
630 }
631 
632 static void workbench_view_update(void *vedata)
633 {
634  WORKBENCH_Data *data = vedata;
636 }
637 
638 static void workbench_id_update(void *UNUSED(vedata), struct ID *id)
639 {
640  if (GS(id->name) == ID_OB) {
643  if (oed != NULL && oed->dd.recalc != 0) {
644  oed->shadow_bbox_dirty = (oed->dd.recalc & ID_RECALC_ALL) != 0;
645  oed->dd.recalc = 0;
646  }
647  }
648 }
649 
651 
653  NULL,
654  NULL,
655  N_("Workbench"),
659  NULL, /* instance_free */
667  NULL,
668 };
669 
671  NULL,
672  NULL,
674  N_("Workbench"),
676  NULL,
678  NULL,
679  NULL,
680  NULL,
681  NULL,
682  NULL,
683  NULL,
686  {NULL, NULL, NULL},
687 };
688 
689 #undef WORKBENCH_ENGINE
@ CTX_MODE_PAINT_TEXTURE
Definition: BKE_context.h:116
@ CTX_MODE_PAINT_VERTEX
Definition: BKE_context.h:115
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:150
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct RegionView3D *rv3d)
A BVH for high poly meshes.
void BKE_pbvh_is_drawing_set(PBVH *pbvh, bool val)
Definition: pbvh.c:3255
PBVHType BKE_pbvh_type(const PBVH *pbvh)
Definition: pbvh.c:1798
@ PBVH_FACES
Definition: BKE_pbvh.h:234
#define BLI_array_alloca(arr, realsize)
Definition: BLI_alloca.h:22
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_INLINE
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
MINLINE int max_ii(int a, int b)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
@ ID_RECALC_ALL
Definition: DNA_ID.h:891
@ ID_OB
Definition: DNA_ID_enums.h:47
#define CURVES_MATERIAL_NR
@ CD_PROP_BYTE_COLOR
@ CD_PROP_COLOR
@ CD_MLOOPUV
@ FLUID_DOMAIN_TYPE_GAS
@ BASE_FROM_DUPLI
@ ME_WRAPPER_TYPE_BMESH
@ eModifierMode_Realtime
@ eModifierType_ParticleSystem
@ eModifierType_Fluid
@ OB_WIRE
@ OB_TEXTURE
@ OB_SOLID
@ OB_MODE_VERTEX_PAINT
@ OB_MBALL
@ OB_SURF
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES
@ OB_DRAW_NO_SHADOW_CAST
#define PART_DRAW_PATH
#define PART_DRAW_REND
@ IMAGEPAINT_INTERP_LINEAR
#define IMAGEPAINT_MODE_IMAGE
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:96
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:414
eV3DShadingColorType ED_paint_shading_color_override(struct bContext *C, const struct PaintModeSettings *settings, struct Object *ob, eV3DShadingColorType orig_color_type)
GPUBatch
Definition: GPU_batch.h:78
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
eGPUSamplerState
Definition: GPU_texture.h:25
@ GPU_SAMPLER_REPEAT
Definition: GPU_texture.h:37
@ GPU_SAMPLER_FILTER
Definition: GPU_texture.h:27
@ GPU_R16UI
Definition: GPU_texture.h:111
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_RGBA8
Definition: GPU_texture.h:87
#define RE_USE_STEREO_VIEWPORT
Definition: RE_engine.h:51
#define RE_INTERNAL
Definition: RE_engine.h:43
#define RE_USE_GPU_CONTEXT
Definition: RE_engine.h:52
#define C
Definition: RandGen.cpp:25
Scene scene
GPUBatch * DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
Definition: draw_cache.c:2896
GPUBatch * DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
Definition: draw_cache.c:2884
GPUBatch ** DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:971
GPUBatch * DRW_cache_mesh_surface_vertpaint_get(Object *ob)
Definition: draw_cache.c:2890
GPUBatch ** DRW_cache_mesh_surface_texpaint_get(Object *ob)
Definition: draw_cache.c:2878
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:887
struct DRWShadingGroup * DRW_shgroup_curves_create_sub(struct Object *object, struct DRWShadingGroup *shgrp, struct GPUMaterial *gpu_material)
Definition: draw_curves.cc:303
struct DRWShadingGroup * DRW_shgroup_hair_create_sub(struct Object *object, struct ParticleSystem *psys, struct ModifierData *md, struct DRWShadingGroup *shgrp, struct GPUMaterial *gpu_material)
Definition: draw_hair.cc:235
bool DRW_state_is_opengl_render(void)
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:633
bool DRW_object_is_renderable(const Object *ob)
Definition: draw_manager.c:180
int DRW_object_visibility_in_active_context(const Object *ob)
Definition: draw_manager.c:209
bool DRW_object_is_visible_psys_in_active_context(const Object *object, const ParticleSystem *psys)
Definition: draw_manager.c:234
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:850
bool DRW_object_use_hide_faces(const struct Object *ob)
Definition: draw_manager.c:215
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:638
void DRW_shgroup_call_instance_range(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint i_sta, uint i_num)
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_draw_pass(DRWPass *pass)
void DRW_view_set_active(const DRWView *view)
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:225
const int state
struct BMesh * bm
Definition: BKE_editmesh.h:40
CustomData vdata
Definition: bmesh_class.h:337
CustomData ldata
Definition: bmesh_class.h:337
struct Object * obact
Definition: DRW_render.h:983
struct Scene * scene
Definition: DRW_render.h:979
const struct bContext * evil_C
Definition: DRW_render.h:997
struct View3D * v3d
Definition: DRW_render.h:976
struct RegionView3D * rv3d
Definition: DRW_render.h:975
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:40
struct FluidDomainSettings * domain
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
struct Image * canvas
void * first
Definition: DNA_listBase.h:31
struct BMEditMesh * edit_mesh
CustomData vdata
Mesh_Runtime runtime
CustomData ldata
short base_flag
ListBase modifiers
struct SculptSession * sculpt
void * data
ParticleSettings * part
struct ToolSettings * toolsettings
struct PBVH * pbvh
Definition: BKE_paint.h:550
struct ImagePaintSettings imapaint
struct PaintModeSettings paint_mode
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
#define N_(msgid)
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
void workbench_draw_finish(void *UNUSED(ved))
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)
static const CustomData * workbench_mesh_get_vert_custom_data(const Mesh *mesh)
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)
static const CustomData * workbench_mesh_get_loop_custom_data(const Mesh *mesh)
void workbench_cache_finish(void *ved)
void workbench_draw_sample(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_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, bool has_transp_mat)
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)