Blender V5.3
draw_context.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdio>
10
11#include "CLG_log.h"
12
13#include "BLI_enum_flags.hh"
14#include "BLI_function_ref.hh"
15#include "BLI_listbase.hh"
16#include "BLI_map.hh"
17#include "BLI_math_matrix_c.hh"
19#include "BLI_math_vector_c.hh"
20#include "BLI_rect.hh"
21#include "BLI_string.hh"
22#include "BLI_sys_types.hh"
23#include "BLI_task_c.hh"
24#include "BLI_threads.hh"
25
26#include "BLF_api.hh"
27
28#include "BLT_translation.hh"
29
30#include "BKE_camera.h"
31#include "BKE_compositor.hh"
32#include "BKE_context.hh"
33#include "BKE_curve.hh"
34#include "BKE_curves.h"
35#include "BKE_duplilist.hh"
36#include "BKE_editmesh.hh"
37#include "BKE_global.hh"
38#include "BKE_grease_pencil.h"
39#include "BKE_idprop.hh"
40#include "BKE_lattice.hh"
41#include "BKE_layer.hh"
42#include "BKE_main.hh"
43#include "BKE_mball.hh"
44#include "BKE_mesh.hh"
45#include "BKE_mesh_wrapper.hh"
46#include "BKE_modifier.hh"
47#include "BKE_object.hh"
48#include "BKE_object_types.hh"
49#include "BKE_paint.hh"
50#include "BKE_particle.h"
51#include "BKE_pointcache.h"
52#include "BKE_pointcloud.hh"
53#include "BKE_scene.hh"
54#include "BKE_screen.hh"
56#include "BKE_volume.hh"
57
58#include "DNA_camera_types.h"
59#include "DNA_mesh_types.h"
60#include "DNA_userdef_types.h"
61#include "DNA_view3d_types.h"
62#include "DNA_world_types.h"
63
64#include "ED_gpencil_legacy.hh"
65#include "ED_screen.hh"
66#include "ED_space_api.hh"
67#include "ED_view3d.hh"
68
69#include "GPU_capabilities.hh"
70#include "GPU_framebuffer.hh"
71#include "GPU_immediate.hh"
72#include "GPU_matrix.hh"
73#include "GPU_platform.hh"
74#include "GPU_shader_shared.hh"
75#include "GPU_state.hh"
76#include "GPU_uniform_buffer.hh"
77#include "GPU_viewport.hh"
78
79#include "UI_resources.hh"
80#include "UI_view2d.hh"
81
82#include "WM_api.hh"
83#include "WM_toolsystem.hh"
84
85#include "DRW_render.hh"
86#include "draw_cache.hh"
88#include "draw_common_c.hh"
90#include "draw_handle.hh"
91#include "draw_manager_text.hh"
92#include "draw_shader.hh"
93#include "draw_subdivision.hh"
94#include "draw_view_c.hh"
95#include "draw_view_data.hh"
96
97/* only for callbacks */
98#include "draw_cache_impl.hh"
99
108
109#include "GPU_context.hh"
110
111#include "DEG_depsgraph.hh"
112#include "DEG_depsgraph_query.hh"
113
114#include "BLI_time.hh"
115
116#include "DRW_select_buffer.hh"
117
118namespace blender {
119
120thread_local DRWContext *DRWContext::g_context = nullptr;
121
123 Depsgraph *depsgraph,
124 const int2 size,
125 const bContext *C,
127 View3D *v3d)
128 : mode(mode_)
129{
130 BLI_assert(size.x > 0 && size.y > 0);
131
132 this->size = float2(size);
133 this->inv_size = 1.0f / this->size;
134
135 this->depsgraph = depsgraph;
138
139 this->evil_C = C;
140
141 this->region = (region) ? region : ((C) ? CTX_wm_region(C) : nullptr);
142 this->space_data = (C) ? CTX_wm_space_data(C) : nullptr;
143 this->v3d = (v3d) ? v3d : ((C) ? CTX_wm_view3d(C) : nullptr);
144 if (this->v3d != nullptr && this->region != nullptr) {
145 this->rv3d = static_cast<RegionView3D *>(this->region->regiondata);
146 }
147 /* Active object. Set to nullptr for render (when region is nullptr). */
148 this->obact = (this->region) ? BKE_view_layer_active_object_get(this->view_layer) : nullptr;
149 /* Object mode. */
150 this->object_mode = (this->obact) ? this->obact->mode : OB_MODE_OBJECT;
151 /* Edit object. */
152 this->object_edit = (this->object_mode & OB_MODE_EDIT) ? this->obact : nullptr;
153 /* Pose object. */
154 if (this->object_mode & OB_MODE_POSE) {
155 this->object_pose = this->obact;
156 }
157 else if (this->object_mode & OB_MODE_ALL_WEIGHT_PAINT) {
159 }
160 else {
161 this->object_pose = nullptr;
162 }
163
164 if (C != nullptr) {
166 }
167
168 /* View layer can be lazily synced. */
170
171 /* fclem: Is this still needed ? */
172 if (this->object_edit && rv3d) {
174 }
175
176 BLI_assert(g_context == nullptr);
177 g_context = this;
178}
179
198
200{
201 BLI_assert(g_context == this);
202 g_context = nullptr;
203}
204
209
214
219
221{
222 DRWContext &draw_ctx = drw_get();
223 SpaceLink *space_data = draw_ctx.space_data;
224 View3D *v3d = draw_ctx.v3d;
225
226 if (space_data != nullptr) {
227 switch (space_data->spacetype) {
228 case SPACE_IMAGE: {
229 SpaceImage *sima = reinterpret_cast<SpaceImage *>(space_data);
230 return (sima->flag & SI_SHOW_GPENCIL) != 0;
231 }
232 case SPACE_NODE:
233 /* Don't draw the annotation for the node editor. Annotations are handled by space_image as
234 * the draw manager is only used to draw the background. */
235 return false;
236 default:
237 break;
238 }
239 }
240 return (v3d && ((v3d->flag2 & V3D_SHOW_ANNOTATION) != 0) &&
241 ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0));
242}
243
244/* -------------------------------------------------------------------- */
247
249 public:
251
253 {
254 BLI_assert_msg(graph == nullptr, "Missing call to work_and_wait");
255 }
256
258 {
259 BLI_assert_msg(graph, "Trying to submit more than once");
260
263 graph = nullptr;
264 }
265};
266
268
269/* -------------------------------------------------------------------- */
272
274{
276
277 if (ob->type == OB_MESH) {
278 DRWContext &draw_ctx = drw_get();
279 /* The evaluated object might be a mesh even though the original object has a different type.
280 * Also make sure the original object is a mesh (see #140762). */
281 if (draw_ctx.object_edit && draw_ctx.object_edit->type != OB_MESH) {
282 /* Noop. */
283 }
284 else if ((ob == draw_ctx.object_edit) || ob->mode == OB_MODE_EDIT) {
285 View3D *v3d = draw_ctx.v3d;
286 if (v3d && ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && RETOPOLOGY_ENABLED(v3d)) {
287 return false;
288 }
289 }
290 }
291
292 return true;
293}
294
296{
298 if (ELEM(ob->type, OB_MESH, OB_CURVES)) {
299 if ((ob->mode & OB_MODE_EDIT) == 0) {
300 return false;
301 }
302 }
303 return true;
304 }
305 return false;
306}
307
314
316{
317 if (ob->type == OB_MESH) {
318 switch (ob->mode) {
319 case OB_MODE_SCULPT:
323 return true;
324 default:
325 break;
326 }
327 }
328
329 return false;
330}
331
333{
334 const bool for_render = DRW_context_get()->is_image_render();
335 /* NOTE: psys_check_enabled is using object and particle system for only
336 * reading, but is using some other functions which are more generic and
337 * which are hard to make const-pointer. */
339 const_cast<Object *>(object), const_cast<ParticleSystem *>(psys), for_render))
340 {
341 return false;
342 }
343 const DRWContext *draw_ctx = DRW_context_get();
344 const Scene *scene = draw_ctx->scene;
345 if (object == draw_ctx->object_edit) {
346 return false;
347 }
348 const ParticleSettings *part = psys->part;
349 const ParticleEditSettings *pset = &scene->toolsettings->particle;
350 if (object->mode == OB_MODE_PARTICLE_EDIT) {
351 if (psys_in_edit_mode(draw_ctx->depsgraph, psys)) {
352 if ((pset->flag & PE_DRAW_PART) == 0) {
353 return false;
354 }
355 if ((part->childtype == 0) &&
356 (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0)
357 {
358 return false;
359 }
360 }
361 }
362 return true;
363}
364
366{
367 /* Same as DRW_object_get_data_for_drawing, but for the cage mesh. */
368 BLI_assert(object.type == OB_MESH);
369 const Mesh *cage_mesh = BKE_object_get_editmesh_eval_cage(&object);
370 if (cage_mesh == nullptr) {
371 return nullptr;
372 }
373
375 return cage_mesh;
376 }
377 return BKE_mesh_wrapper_ensure_subdivision(cage_mesh);
378}
379
381
382/* -------------------------------------------------------------------- */
385
387{
388 DRWData *drw_data = MEM_new_zeroed<DRWData>("DRWData");
389
390 drw_data->default_view = new draw::View("DrawDefaultView");
391
392 for (int i = 0; i < 2; i++) {
393 drw_data->view_data[i] = new DRWViewData();
394 }
395 return drw_data;
396}
397
399{
400 using namespace blender::draw;
402 DRW_gsplat_init(this);
403 DRW_curves_init(this);
404 DRW_volume_init(this);
405}
406
408{
409 using namespace blender::draw;
413}
414
416{
417 DRW_smoke_exit(this);
418}
419
421{
422 for (int i = 0; i < 2; i++) {
423 delete drw_data->view_data[i];
424 }
429 delete drw_data->default_view;
430 MEM_delete(drw_data);
431}
432
434{
435 DRWData **data_p = GPU_viewport_data_get(viewport);
436 DRWData *data = *data_p;
437
438 if (data == nullptr) {
439 *data_p = data = DRW_viewport_data_create();
440 }
441 return data;
442}
443
445{
447
449
450 {
451 /* Acquire DRWData. */
452 if (!this->viewport && this->data) {
453 /* Manager was init first without a viewport, created DRWData, but is being re-init.
454 * In this case, keep the old data. */
455 }
456 else if (this->viewport) {
457 /* Use viewport's persistent DRWData. */
459 }
460 else {
461 /* Create temporary DRWData. Freed in drw_manager_exit(). */
463 }
464 int view = (this->viewport) ? GPU_viewport_active_view_get(this->viewport) : 0;
465 this->view_data_active = this->data->view_data[view];
466
468
469 if (this->viewport) {
471 }
472 }
473 {
474 /* Create the default view. */
475 if (this->rv3d != nullptr) {
477 }
478 else if (this->region) {
479 /* Assume that if rv3d is nullptr, we are drawing for a 2D area. */
480 View2D *v2d = &this->region->v2d;
481 rctf region_space = {0.0f, 1.0f, 0.0f, 1.0f};
482
483 float4x4 viewmat;
484 BLI_rctf_transform_calc_m4_pivot_min(&v2d->cur, &region_space, viewmat.ptr());
485
486 float4x4 winmat = float4x4::identity();
487 winmat[0][0] = winmat[1][1] = 2.0f;
488 winmat[3][0] = winmat[3][1] = -1.0f;
489
490 draw::View::default_set(viewmat, winmat);
491 }
492 else {
493 /* Assume that this is the render mode or custom mode and
494 * that the default view will be set appropriately or not used. */
496 }
497 }
498
499 /* Init modules ahead of time because the begin_sync happens before DRW_render_object_iter. */
500 this->data->modules_init();
501}
502
504{
506
507 this->data->modules_exit();
508
509 /* Reset drawing state to avoid to side-effects. */
511
513
514 if (this->data != nullptr && this->viewport == nullptr) {
516 }
517 this->data = nullptr;
518 this->viewport = nullptr;
519}
520
522{
523 return *drw_get().view_data_active->viewport_compositor_passes.lookup_or_add_cb(
524 pass_name, [&]() { return std::make_unique<draw::TextureFromPool>(pass_name); });
525}
526
527bool DRW_viewport_pass_texture_exists(const char *pass_name)
528{
529 return drw_get().view_data_active->viewport_compositor_passes.contains(pass_name);
530}
531
533{
534 if (drw_get().viewport) {
536 }
537}
538
540
541/* -------------------------------------------------------------------- */
544
545/* The Dupli systems generate a lot of transient objects that share the batch caches.
546 * So we ensure to only clear and generate the cache once per source instance type using this
547 * set. */
548/* TODO(fclem): This should be reconsidered as this has some unneeded overhead and complexity.
549 * Maybe it isn't needed at all. */
551 private:
552 /* Key identifying a single instance source. */
553 struct DupliKey {
554 Object *ob = nullptr;
555 ID *ob_data = nullptr;
556
557 DupliKey() = default;
558 DupliKey(const DupliObject *ob_dupli) : ob(ob_dupli->ob), ob_data(ob_dupli->ob_data) {}
559
560 uint64_t hash() const
561 {
562 return get_default_hash(this->ob, this->ob_data);
563 }
564
565 friend bool operator==(const DupliKey &a, const DupliKey &b)
566 {
567 return a.ob == b.ob && a.ob_data == b.ob_data;
568 }
569 };
570
571 /* Last key used. Allows to avoid the overhead of polling the `dupli_set` for each instance.
572 * This helps when a Dupli system generates a lot of similar geometry consecutively. */
573 DupliKey last_key_ = {};
574
575 /* Set containing all visited Dupli source object. */
576 Set<DupliKey> *dupli_set_ = nullptr;
577
578 public:
579 void try_add(draw::ObjectRef &ob_ref);
580 void extract_all(ExtractionGraph &extraction);
581};
582
584{
585 if (ob_ref.is_dupli() == false) {
586 return;
587 }
588 if (last_key_ == ob_ref.dupli_object_) {
589 /* Same data as previous iteration. No need to perform the check again. */
590 return;
591 }
592
593 last_key_ = ob_ref.dupli_object_;
594
595 if (dupli_set_ == nullptr) {
596 dupli_set_ = MEM_new<Set<DupliKey>>("DupliCacheManager::dupli_set_");
597 }
598
599 if (dupli_set_->add(last_key_)) {
600 /* Key is newly added. It is the first time we sync this object. */
601 /* TODO: Meh a bit out of place but this is nice as it is
602 * only done once per instance type. */
603 /* Note that this can happen for geometry data whose type is different from the original
604 * object (e.g. Text evaluated as Mesh, Geometry node instance etc...).
605 * In this case, key.ob is not going to have the same data type as ob_ref.object nor the same
606 * data at all. */
608 }
609}
610
612{
613 /* Reset for next iter. */
614 last_key_ = {};
615
616 if (dupli_set_ == nullptr) {
617 return;
618 }
619
620 /* Note these can referenced by the temporary object pointer `Object *ob` and needs to have at
621 * least the same lifetime. */
622 bke::ObjectRuntime tmp_runtime;
623 Object tmp_object;
624
625 using Iter = Set<DupliKey>::Iterator;
626 Iter begin = dupli_set_->begin();
627 Iter end = dupli_set_->end();
628 for (Iter iter = begin; iter != end; ++iter) {
629 const DupliKey &key = *iter;
630 Object *ob = iter->ob;
631
632 if (key.ob_data != ob->data) {
633 /* Copy both object data and runtime. */
634 tmp_runtime = *ob->runtime;
635 tmp_object = dna::shallow_copy(*ob);
636 tmp_object.runtime = &tmp_runtime;
637 /* Geometry instances shouldn't be rendered with edit mode overlays. */
638 tmp_object.mode = OB_MODE_OBJECT;
639 /* Do not modify the original bound-box. */
640 BKE_object_replace_data_on_shallow_copy(&tmp_object, key.ob_data);
641
642 ob = &tmp_object;
643 }
644
646 }
647
648 /* TODO(fclem): Could eventually keep the set allocated. */
649 MEM_SAFE_DELETE(dupli_set_);
650}
651
653
654/* -------------------------------------------------------------------- */
657
658namespace draw {
659
660ObjectRef::ObjectRef(Object *ob, Object *dupli_parent, DupliObject *dupli_object)
661 : dupli_object_(dupli_object), dupli_parent_(dupli_parent), object(ob)
662{
663}
664
666 : dupli_object_(duplis[0]), dupli_parent_(dupli_parent), duplis_(&duplis), object(&ob)
667{
668}
669
670} // namespace draw
671
673
674/* -------------------------------------------------------------------- */
720
721namespace draw {
722
723static bool supports_handle_ranges(DupliObject *dupli, Object *parent, const DRWContext &draw_ctx)
724{
725 int ob_type = dupli->ob_data ? BKE_object_obdata_to_type(dupli->ob_data) : OB_EMPTY;
727 /* TODO: Add Grease Pencil support. */
728 return false;
729 }
730
731 Object *ob = dupli->ob;
732 if (eDrawType(min(int(ob->dt), int(parent->dt))) == OB_BOUNDBOX) {
733 return false;
734 }
735
736 if (BKE_sculptsession_use_pbvh_draw(ob, draw_ctx.rv3d)) {
737 return false;
738 }
739
740 if (ob_type == OB_MESH) {
741 for (ParticleSystem &psys : ob->particlesystem) {
742 const int draw_as = (psys.part->draw_as == PART_DRAW_REND) ? psys.part->ren_as :
743 psys.part->draw_as;
744 if (!ELEM(draw_as, PART_DRAW_NOT, PART_DRAW_OB, PART_DRAW_GR) &&
746 {
747 /* Particles don't support handle ranges.
748 * Objects and Group particles are the only exceptions,
749 * since they're generated as regular instances by the Depsgraph. */
750 return false;
751 }
752 }
753 /* Smoke drawing doesn't support handle ranges. */
755 }
756
757 return true;
758}
759
762};
764
767
773
791
793 {
794 return hash_value;
795 }
796
797 bool operator==(const InstancesKey &k) const
798 {
799 if (hash_value != k.hash_value) {
800 return false;
801 }
802 if (object != k.object) {
803 return false;
804 }
805 if (ob_data != k.ob_data) {
806 return false;
807 }
808 if (flags != k.flags) {
809 return false;
810 }
812 return false;
813 }
815 return false;
816 }
817 return true;
818 }
819};
820
821namespace {
827enum class DrawFilter {
832 Draw,
837 Skip,
844 SkipRecursive,
845};
846
853bool is_object_instancer(const Object &ob)
854{
855 return (ob.transflag & OB_DUPLI) || (ob.runtime->geometry_set_eval != nullptr);
856}
857
876DrawFilter draw_filter_from_viewport_object_impl(const DRWContext &draw_ctx,
877 Object &ob,
878 const DupliObject *dupli,
879 const DRW_ObjectFilterFn object_filter_fn,
880 void *object_filter_user_data,
881 const bool check_select)
882{
883 const View3D &v3d = *draw_ctx.v3d;
884
885 /* The temporary object for a dupli takes its type from its data (a text's evaluated mesh is
886 * `OB_MESH`), use the type of the object it instances so generated geometry follows its
887 * object's toggles. For what else it copies from that object and the instancer,
888 * see #DEG_iterator_temp_object_from_dupli. */
889 const ObjectType ob_type = (dupli != nullptr) ? dupli->ob->type : ob.type;
890
891 /* NOTE: checks returning `SkipRecursive` must run before those returning `Skip`,
892 * an object rejected by both would otherwise walk its duplis.
893 * The element select branch can `Skip` first, an object hits either it or the select-ability
894 * check, never both. */
895
896 /* Duplis skip the caller's filter, it already ran on their instancer. */
897 if ((dupli == nullptr) && (object_filter_fn != nullptr)) {
898 if (object_filter_fn(&ob, object_filter_user_data) == false) {
899 return DrawFilter::SkipRecursive;
900 }
901 }
902
903 if (check_select) {
904 /* When selecting elements (pose-bones, edit-mode bones & meta-ball elements),
905 * check for visibility not select-ability as the elements have their own selection
906 * restriction flags.
907 *
908 * NOTE: this also ignores the object type & outliner select-ability for the object
909 * (also when weight painting an object an armature in pose mode deforms).
910 * What should happen here isn't well defined, keep as-is. */
911 const bool use_element_select = ((draw_ctx.object_pose != nullptr) &&
912 (ob.mode & OB_MODE_POSE)) ||
913 (ob.mode & OB_MODE_EDIT);
914 if (use_element_select) {
915 if ((ob.base_flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) == 0) {
916 return DrawFilter::Skip;
917 }
918 }
919 else if (((ob.base_flag & BASE_SELECTABLE) == 0) ||
920 ((dupli == nullptr) && ((v3d.object_type_exclude_select & (1 << ob_type)) != 0)))
921 {
922 /* Picking a dupli selects its instancer (they share a `select_id`),
923 * so the duplis of an unselectable instancer are skipped too,
924 * otherwise they block clicks on objects behind them.
925 * A dupli's own type isn't checked as it's the instancer that's selected. */
926 return DrawFilter::SkipRecursive;
927 }
928 }
929
930 /* Only skips the object itself, a dupli may be visible when its instancer is not. */
931 if (!BKE_object_is_visible_in_viewport_ex(&v3d, &ob, ob_type)) {
932 return DrawFilter::Skip;
933 }
934
935 return DrawFilter::Draw;
936}
937
939DrawFilter draw_filter_from_viewport_object_for_draw(const DRWContext &draw_ctx,
940 Object &ob,
941 const DupliObject *dupli)
942{
943 return draw_filter_from_viewport_object_impl(draw_ctx, ob, dupli, nullptr, nullptr, false);
944}
945
947DrawFilter draw_filter_from_viewport_object_for_select(const DRWContext &draw_ctx,
948 Object &ob,
949 const DupliObject *dupli,
950 const DRW_ObjectFilterFn object_filter_fn,
951 void *object_filter_user_data)
952{
953 return draw_filter_from_viewport_object_impl(
954 draw_ctx, ob, dupli, object_filter_fn, object_filter_user_data, true);
955}
956} // namespace
957
983 DRWContext &draw_ctx,
984 FunctionRef<DrawFilter(Object &, const DupliObject *dupli)> should_draw_object_cb,
985 FunctionRef<void(ObjectRef &)> draw_object_cb)
986{
987 DupliList duplilist;
989
990 Object tmp_object;
991 bke::ObjectRuntime tmp_runtime;
992
993 Depsgraph *depsgraph = draw_ctx.depsgraph;
994 eEvaluationMode eval_mode = DEG_get_mode(depsgraph);
995 View3D *v3d = draw_ctx.v3d;
996
997 DEGObjectIterSettings deg_iter_settings = {nullptr};
998 deg_iter_settings.depsgraph = depsgraph;
999 deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
1001 if (v3d && v3d->flag2 & V3D_SHOW_VIEWER) {
1002 deg_iter_settings.viewer_path = &v3d->viewer_path;
1003 }
1004
1005 DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
1006
1007 if (!DEG_iterator_object_is_visible(eval_mode, ob)) {
1008 continue;
1009 }
1010
1011 const int visibility = BKE_object_visibility(ob, eval_mode);
1012 const bool ob_visible = visibility & (OB_VISIBLE_SELF | OB_VISIBLE_PARTICLES);
1013 const bool instances_visible = (visibility & OB_VISIBLE_INSTANCES) && is_object_instancer(*ob);
1014 /* Don't create duplis from temporary preview objects, object_duplilist_preview already takes
1015 * care of everything. (See #146194, #146211) */
1016 const bool is_preview_dupli = data_.dupli_parent && data_.dupli_object_current;
1017 const bool process_duplis = instances_visible && !is_preview_dupli;
1018
1019 /* Fully hidden non-instancers don't need a predicate call: the iterator has nothing
1020 * to do with them. Skip them before invoking the predicate. */
1021 if (!ob_visible && !process_duplis) {
1022 continue;
1023 }
1024
1025 /* Decide drawability for the top-level object, then fall through to the dupli path. */
1026 const DrawFilter parent_filter = should_draw_object_cb(*ob, data_.dupli_object_current);
1027
1028 if (parent_filter == DrawFilter::Draw && ob_visible) {
1029 /* NOTE: object_duplilist_preview is still handled by DEG_OBJECT_ITER,
1030 * dupli_parent and dupli_object_current won't be null for these. */
1031 ObjectRef ob_ref(ob, data_.dupli_parent, data_.dupli_object_current);
1032 draw_object_cb(ob_ref);
1033 }
1034
1035 if (!process_duplis) {
1036 continue;
1037 }
1038
1039 if (parent_filter == DrawFilter::SkipRecursive) {
1040 /* Filter rejected this instancer; skip its duplis entirely. */
1041 continue;
1042 }
1043
1044 /* Generate and walk this instancer's duplis. */
1045 duplilist.clear();
1046 object_duplilist(draw_ctx.depsgraph, ob, deg_iter_settings.included_objects, duplilist);
1047
1048 if (duplilist.is_empty()) {
1049 continue;
1050 }
1051
1052 dupli_map.clear();
1053 for (DupliObject &dupli : duplilist) {
1054
1055 if (!DEG_iterator_dupli_is_visible(&dupli, eval_mode)) {
1056 continue;
1057 }
1058
1059 /* TODO: Optimize.
1060 * We can't check the dupli.ob since visibility may be different than the dupli itself.
1061 * But we should be able to check the dupli visibility without creating a temp object. */
1062#if 0
1063 if (should_draw_object_cb(*dupli.ob, &dupli) != DrawFilter::Draw) {
1064 continue;
1065 }
1066#endif
1067
1068 if (!supports_handle_ranges(&dupli, ob, draw_ctx)) {
1069 /* Sync the dupli as a single object. */
1071 ob, &dupli, eval_mode, false, &tmp_object, &tmp_runtime) ||
1072 should_draw_object_cb(tmp_object, &dupli) != DrawFilter::Draw)
1073 {
1075 continue;
1076 }
1077
1078 tmp_object.light_linking = dupli.ob->light_linking;
1080 tmp_object.runtime->object_to_world = float4x4(dupli.mat);
1081 tmp_object.runtime->world_to_object = invert(tmp_object.runtime->object_to_world);
1082
1083 draw::ObjectRef ob_ref(&tmp_object, ob, &dupli);
1084 draw_object_cb(ob_ref);
1085
1087 continue;
1088 }
1089
1090 InstancesFlags flags = InstancesFlags(0);
1091 {
1093 }
1094 InstancesKey key(dupli.ob,
1095 dupli.ob_data,
1096 flags,
1099
1100 dupli_map.lookup_or_add_default(key).append(&dupli);
1101 }
1102
1103 for (const auto &[key, instances] : dupli_map.items()) {
1104 DupliObject *first_dupli = instances.first();
1106 ob, first_dupli, eval_mode, false, &tmp_object, &tmp_runtime) ||
1107 should_draw_object_cb(tmp_object, first_dupli) != DrawFilter::Draw)
1108 {
1109 evil::DEG_iterator_temp_object_free_properties(first_dupli, &tmp_object);
1110 continue;
1111 }
1112
1113 tmp_object.light_linking = first_dupli->ob->light_linking;
1114 SET_FLAG_FROM_TEST(tmp_object.transflag,
1115 flag_is_set(key.flags, InstancesFlags::IsNegativeScale),
1116 OB_NEG_SCALE);
1117 /* Should use DrawInstances data instead. */
1118 tmp_object.runtime->object_to_world = float4x4();
1119 tmp_object.runtime->world_to_object = float4x4();
1120#ifndef NDEBUG
1122#endif
1123
1124 draw::ObjectRef ob_ref(tmp_object, ob, instances);
1125 draw_object_cb(ob_ref);
1126
1127 evil::DEG_iterator_temp_object_free_properties(first_dupli, &tmp_object);
1128 }
1129 }
1131}
1132
1133} // namespace draw
1134
1136
1137/* -------------------------------------------------------------------- */
1140
1142{
1143 using namespace blender::draw;
1144 Scene *scene;
1145 static int lasttime = 0;
1146 int ctime = int(BLI_time_now_seconds());
1147
1148 if (U.vbotimeout == 0 || (ctime - lasttime) < U.vbocollectrate || ctime == lasttime) {
1149 return;
1150 }
1151
1152 lasttime = ctime;
1153
1154 for (scene = bmain->scenes.first(); scene; scene = static_cast<Scene *>(scene->id.next)) {
1155 for (ViewLayer &view_layer : scene->view_layers) {
1156 Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, &view_layer);
1157 if (depsgraph == nullptr) {
1158 continue;
1159 }
1160 /* Skip depsgraphs that may still hold dangling IDs from before their last rebuild
1161 * (e.g. an inactive view layer), to avoid dereferencing freed data below. */
1162 if (!DEG_is_fully_evaluated(depsgraph)) {
1163 continue;
1164 }
1165
1166 /* TODO(fclem): This is not optimal since it iter over all dupli instances.
1167 * In this case only the source object should be tagged. */
1168 DEGObjectIterSettings deg_iter_settings = {nullptr};
1169 deg_iter_settings.depsgraph = depsgraph;
1171 DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
1172 DRW_batch_cache_free_old(ob, ctime);
1173 }
1175 }
1176 }
1177}
1178
1180
1181/* -------------------------------------------------------------------- */
1184
1186 DupliCacheManager &dupli_cache,
1187 ExtractionGraph &extraction)
1188{
1189 if (ref.is_dupli() == false) {
1191 }
1192 else {
1193 dupli_cache.try_add(ref);
1194 }
1195
1196 DRWContext &ctx = drw_get();
1198 [&](DrawEngine &instance) { instance.object_sync(ref, *DRW_manager_get()); });
1199
1200 /* TODO: in the future it would be nice to generate once for all viewports.
1201 * But we need threaded DRW manager first. */
1202 if (ref.is_dupli() == false) {
1204 }
1205 /* Batch generation for duplis happens after iter_callback. */
1206}
1207
1209{
1210 /* Enable modules and init for next sync. */
1212
1213 DupliCacheManager dupli_handler;
1214 ExtractionGraph extraction;
1215
1216 /* Custom callback defines the set of object to sync. */
1217 iter_callback(dupli_handler, extraction);
1218
1219 dupli_handler.extract_all(extraction);
1220 for (Object *object : this->delayed_extraction) {
1222 }
1223 this->delayed_extraction.clear();
1224
1225 extraction.work_and_wait();
1226
1228}
1229
1231{
1232 double start_time = BLI_time_now_seconds();
1233
1234 view_data_active->foreach_enabled_engine([&](DrawEngine &instance) { instance.init(); });
1235
1237
1238 view_data_active->foreach_enabled_engine([&](DrawEngine &instance) { instance.begin_sync(); });
1239
1240 sync(iter_callback);
1241
1242 view_data_active->foreach_enabled_engine([&](DrawEngine &instance) { instance.end_sync(); });
1243
1245
1246 last_sync_time_ = float(BLI_time_now_seconds() - start_time);
1247}
1248
1254static void drw_render_border_mask(const DRWContext &ctx)
1255{
1256 const View3D *v3d = ctx.v3d;
1257 const RegionView3D *rv3d = ctx.rv3d;
1258
1259 /* Check if we need to do any render border masking. */
1260 if (v3d == nullptr || rv3d == nullptr || rv3d->persp != RV3D_CAMOB || v3d->camera == nullptr ||
1261 rv3d->camroll == 0.0f)
1262 {
1263 return;
1264 }
1265
1266 bool uses_render_border = false;
1268 [&](DrawEngine &instance) { uses_render_border |= instance.uses_render_border(); });
1269 if (!uses_render_border) {
1270 return;
1271 }
1272
1273 rctf border, unrolled_border;
1275 ctx.depsgraph,
1276 v3d,
1277 rv3d,
1278 int(ctx.size.x),
1279 int(ctx.size.y),
1280 &border,
1281 &unrolled_border))
1282 {
1283 return;
1284 }
1285
1286 float roll_angle = rv3d->camroll;
1287 if ((rv3d->rflag & RV3D_FLIP_X) != 0) {
1288 roll_angle = -roll_angle;
1289 }
1290
1291 /* Compute corners of the render border. */
1292 const float2 pivot = ctx.size * 0.5f;
1294 const float2 corner[4] = {
1295 pivot + roll * (float2(unrolled_border.xmin, unrolled_border.ymin) - pivot),
1296 pivot + roll * (float2(unrolled_border.xmax, unrolled_border.ymin) - pivot),
1297 pivot + roll * (float2(unrolled_border.xmax, unrolled_border.ymax) - pivot),
1298 pivot + roll * (float2(unrolled_border.xmin, unrolled_border.ymax) - pivot),
1299 };
1300
1301 GPU_debug_group_begin("RenderBorderMask");
1302
1304
1308
1312 GPU_matrix_ortho_set(0.0f, ctx.size.x, 0.0f, ctx.size.y, -1.0f, 1.0f);
1313
1314 /* Replace the RGBA and depth pixels without blending. */
1317 GPU_depth_mask(true);
1318 GPU_color_mask(true, true, true, true);
1319
1320 /* Scissor set to the expanded render border bounds. */
1321 rcti scissor;
1322 const rcti viewport_rect = {0, int(ctx.size.x), 0, int(ctx.size.y)};
1323 BLI_rcti_rctf_copy_floor(&scissor, &border);
1324 BLI_rcti_isect(&scissor, &viewport_rect, &scissor);
1325 GPU_scissor_test(true);
1326 GPU_scissor(scissor.xmin, scissor.ymin, BLI_rcti_size_x(&scissor), BLI_rcti_size_y(&scissor));
1327
1329
1330 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
1332 immUniformColor4f(0.0f, 0.0f, 0.0f, 0.0f);
1333
1334 /* Draw 4 quads to mask out the area outside the rotated border. */
1335 const float extend = 2.0f * (ctx.size.x + ctx.size.y);
1336 /* View space forward is -Z, and we have set the far plane at unit length. */
1337 const float far_z = -1.0f;
1338
1339 immBegin(GPU_PRIM_TRIS, 6 * 4);
1340 for (const int i : IndexRange(4)) {
1341 const float2 v0 = corner[i];
1342 const float2 v1 = corner[(i + 1) % 4];
1343 const float2 tangent = math::normalize(v1 - v0);
1344 const float2 normal = float2(tangent.y, -tangent.x);
1345 const float2 quad[4] = {
1346 v0 - tangent * extend,
1347 v1 + tangent * extend,
1348 v1 + tangent * extend + normal * extend,
1349 v0 - tangent * extend + normal * extend,
1350 };
1351 for (const int j : {0, 1, 2, 0, 2, 3}) {
1352 immVertex3f(pos, quad[j].x, quad[j].y, far_z);
1353 }
1354 }
1355 immEnd();
1356
1358
1359 GPU_scissor_test(false);
1360
1363
1365 GPU_framebuffer_bind(previous_fb);
1366
1368}
1369
1371{
1372 double start_time = BLI_time_now_seconds();
1373 /* Start Drawing */
1375
1376 bool render_border_masked = false;
1377
1379#ifdef __APPLE__
1380 if (G.debug & G_DEBUG_GPU) {
1381 /* Put each engine inside their own command buffers. */
1382 GPU_flush();
1383 }
1384#endif
1385
1386 if (&instance == view_data_active->overlay.instance && this->mode == DRWContext::VIEWPORT) {
1387 /* Mask the render result before the overlay engine. */
1389 render_border_masked = true;
1390 }
1391
1392 GPU_debug_group_begin(instance.name_get().c_str());
1393 instance.draw(*DRW_manager_get());
1395 });
1396
1397 if (!render_border_masked && this->mode == DRWContext::VIEWPORT) {
1399 }
1400
1401 /* Reset state after drawing */
1403
1404 /* Fix 3D view "lagging" on APPLE and WIN32+NVIDIA. (See #56996, #61474) */
1406 GPU_flush();
1407 }
1408
1409 last_submission_time_ = float(BLI_time_now_seconds() - start_time);
1410}
1411
1412void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height)
1413{
1414 DRWContext &ctx = drw_get();
1416 if (instance.info[0] != '\0') {
1417 const char *buf_step = IFACE_(instance.info);
1418 do {
1419 const char *buf = buf_step;
1420 buf_step = BLI_strchr_or_end(buf, '\n');
1421 const int buf_len = buf_step - buf;
1422 *yoffset -= line_height;
1423 BLF_draw_default(xoffset, *yoffset, 0.0f, buf, buf_len);
1424 } while (*buf_step ? ((void)buf_step++, true) : false);
1425 }
1426 });
1427}
1428
1429void DRWContext::enable_engines(bool gpencil_engine_needed, RenderEngineType *render_engine_type)
1430{
1431 DRWViewData &view_data = *this->view_data_active;
1432
1433 SpaceLink *space_data = this->space_data;
1436 view_data.external.set_used(true);
1437 }
1438 else {
1439 view_data.image.set_used(true);
1440 }
1441 view_data.overlay.set_used(true);
1442 return;
1443 }
1444
1446 /* Only enable when drawing the space image backdrop. */
1447 SpaceNode *snode = reinterpret_cast<SpaceNode *>(space_data);
1448 if ((snode->flag & SNODE_BACKDRAW) != 0) {
1449 view_data.image.set_used(true);
1450 view_data.overlay.set_used(true);
1451 }
1452 return;
1453 }
1454
1456 view_data.grease_pencil.set_used(gpencil_engine_needed);
1457 view_data.object_select.set_used(true);
1458 return;
1459 }
1460
1462 view_data.edit_select.set_used(true);
1463 return;
1464 }
1465
1467 view_data.grease_pencil.set_used(gpencil_engine_needed);
1468 view_data.overlay.set_used(true);
1469 return;
1470 }
1471
1472 /* Regular V3D drawing. */
1473 {
1474 const eDrawType drawtype = eDrawType(this->v3d->shading.type);
1475 const bool use_xray = XRAY_ENABLED(this->v3d);
1476
1477 /* Base engine. */
1478 switch (drawtype) {
1479 case OB_WIRE:
1480 case OB_SOLID:
1481 view_data.workbench.set_used(true);
1482 break;
1483 case OB_MATERIAL:
1484 case OB_RENDER:
1485 default:
1486 if (render_engine_type == &DRW_engine_viewport_eevee_type) {
1487 view_data.eevee.set_used(true);
1488 }
1489 else if (render_engine_type == &DRW_engine_viewport_workbench_type) {
1490 view_data.workbench.set_used(true);
1491 }
1492 else if ((render_engine_type->flag & RE_INTERNAL) == 0) {
1493 view_data.external.set_used(true);
1494 }
1495 else {
1497 }
1498 break;
1499 }
1500
1501 if ((drawtype >= OB_SOLID) || !use_xray) {
1502 view_data.grease_pencil.set_used(gpencil_engine_needed);
1503 }
1504
1506
1507 view_data.overlay.set_used(true);
1508
1509#ifdef WITH_DRAW_DEBUG
1510 if (G.debug_value == 31) {
1511 view_data.edit_select_debug.set_used(true);
1512 }
1513#endif
1514 }
1515}
1516
1521
1523{
1524 if (v3d) {
1525 return ((v3d->object_type_exclude_viewport & (1 << OB_GREASE_PENCIL)) != 0);
1526 }
1527 return false;
1528}
1529
1530static bool gpencil_any_exists(Depsgraph *depsgraph)
1531{
1532 return (DEG_id_type_any_exists(depsgraph, ID_GD_LEGACY) ||
1533 DEG_id_type_any_exists(depsgraph, ID_GP));
1534}
1535
1537
1538/* -------------------------------------------------------------------- */
1541
1542#ifdef WITH_XR_OPENXR
1543static void drw_callbacks_xr(DRWContext &draw_ctx, const int cb_type)
1544{
1545 /* XR-specific callbacks (controllers and custom draw functions). */
1546 const View3D *v3d = draw_ctx.v3d;
1547
1548 if ((v3d->flag2 & V3D_XR_SHOW_CONTROLLERS) != 0) {
1550 if (art) {
1551 ED_region_surface_draw_cb_draw(draw_ctx.evil_C, art, cb_type);
1552 }
1553 }
1554 if ((v3d->flag2 & V3D_XR_SHOW_CUSTOM_OVERLAYS) != 0) {
1556 if (st) {
1558 if (art) {
1559 ED_region_surface_draw_cb_draw(draw_ctx.evil_C, art, cb_type);
1560 }
1561 }
1562 }
1563}
1564#endif
1565
1567{
1568 if (draw_ctx.evil_C == nullptr) {
1569 return;
1570 }
1571
1572 const RegionView3D *rv3d = draw_ctx.rv3d;
1573
1575 GPU_matrix_set(rv3d->viewmat);
1576
1579
1580 if (draw_ctx.mode != DRWContext::VIEWPORT_XR) {
1581 /* Regular View3D region pre-view callbacks. */
1583
1584 /* View3D XR session mirror pre-view callbacks. */
1585#ifdef WITH_XR_OPENXR
1586 if ((draw_ctx.v3d->flag & V3D_XR_SESSION_MIRROR) != 0) {
1587 drw_callbacks_xr(draw_ctx, REGION_DRAW_PRE_VIEW);
1588 }
1589#endif
1590 }
1591#ifdef WITH_XR_OPENXR
1592 else {
1593 /* XR surface pre-view callbacks. */
1594 drw_callbacks_xr(draw_ctx, REGION_DRAW_PRE_VIEW);
1595 }
1596#endif
1597
1599
1600 /* State is reset later at the beginning of `draw_ctx.engines_draw_scene()`. */
1601}
1602
1604{
1605 Depsgraph *depsgraph = draw_ctx.depsgraph;
1606 ARegion *region = draw_ctx.region;
1607 RegionView3D *rv3d = draw_ctx.rv3d;
1608 View3D *v3d = draw_ctx.v3d;
1609
1610 const bool do_annotations = draw_show_annotation();
1611
1613
1615
1617 GPU_matrix_set(rv3d->viewmat);
1618
1619 /* annotations - temporary drawing buffer (3d space) */
1620 /* XXX: Or should we use a proper draw/overlay engine for this case? */
1621 if (do_annotations) {
1623 /* XXX: as `scene->gpd` is not copied for copy-on-eval yet. */
1624 ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, region, true);
1626 }
1627
1628 if (draw_ctx.evil_C) {
1630 /* Apply state for callbacks. */
1632
1634
1635 /* View3D XR mirror view. */
1636#ifdef WITH_XR_OPENXR
1637 if ((v3d->flag & V3D_XR_SESSION_MIRROR) != 0) {
1638 drw_callbacks_xr(draw_ctx, REGION_DRAW_POST_VIEW);
1639 }
1640#endif
1641
1642 /* Callback can be nasty and do whatever they want with the state.
1643 * Don't trust them! */
1645
1646 /* Needed so gizmo isn't occluded. */
1647 if ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) {
1649 DRW_draw_gizmo_3d(draw_ctx.evil_C, region);
1650 }
1651
1653 DRW_draw_region_info(draw_ctx.evil_C, region);
1654
1655 /* Annotations - temporary drawing buffer (screen-space). */
1656 /* XXX: Or should we use a proper draw/overlay engine for this case? */
1657 if (((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && (do_annotations)) {
1659 /* XXX: as `scene->gpd` is not copied for copy-on-eval yet */
1660 ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, region, false);
1661 }
1662
1663 if ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) {
1664 /* Draw 2D after region info so we can draw on top of the camera passepartout overlay.
1665 * 'DRW_draw_region_info' sets the projection in pixel-space. */
1667 DRW_draw_gizmo_2d(draw_ctx.evil_C, region);
1668 }
1669
1671 }
1672}
1673
1674#ifdef WITH_XR_OPENXR
1675static void drw_callbacks_post_scene_xr_surface(DRWContext &draw_ctx)
1676{
1677 Depsgraph *depsgraph = draw_ctx.depsgraph;
1678 ARegion *region = draw_ctx.region;
1679 RegionView3D *rv3d = draw_ctx.rv3d;
1680 View3D *v3d = draw_ctx.v3d;
1681
1682 if (v3d && ((v3d->flag2 & V3D_SHOW_ANNOTATION) != 0)) {
1684 /* XXX: as `scene->gpd` is not copied for copy-on-eval yet */
1685 ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, region, true);
1687 }
1688
1690
1692
1694
1696 GPU_matrix_set(rv3d->viewmat);
1697
1698 if (((v3d->flag2 & V3D_XR_SHOW_CONTROLLERS) != 0) ||
1699 ((v3d->flag2 & V3D_XR_SHOW_CUSTOM_OVERLAYS) != 0))
1700 {
1703
1704 drw_callbacks_xr(draw_ctx, REGION_DRAW_POST_VIEW);
1705
1707 }
1708
1710}
1711#endif
1712
1714{
1715
1716 /* State has been reset at the end `draw_ctx.engines_draw_scene()`. */
1718
1719 if (draw_ctx.mode != DRWContext::VIEWPORT_XR) {
1720 /* Regular View3D post-view callbacks. */
1722 }
1723#ifdef WITH_XR_OPENXR
1724 else {
1725 /* XR surface post-view callbacks. */
1726 drw_callbacks_post_scene_xr_surface(draw_ctx);
1727 }
1728#endif
1729
1731
1733}
1734
1736{
1737 if (draw_ctx.evil_C) {
1742 }
1743
1744 /* State is reset later at the beginning of `draw_ctx.engines_draw_scene()`. */
1745}
1746
1748{
1749 const bool do_annotations = draw_show_annotation();
1750 const bool do_draw_gizmos = (draw_ctx.space_data->spacetype != SPACE_IMAGE);
1751
1752 /* State has been reset at the end `draw_ctx.engines_draw_scene()`. */
1753
1755 if (draw_ctx.evil_C) {
1757
1759
1762
1763 wmOrtho2(v2d.cur.xmin, v2d.cur.xmax, v2d.cur.ymin, v2d.cur.ymax);
1764
1765 if (do_annotations) {
1766 ED_annotation_draw_view2d(draw_ctx.evil_C, true);
1767 }
1768
1770
1772
1774 /* Callback can be nasty and do whatever they want with the state.
1775 * Don't trust them! */
1777
1779
1780 if (do_annotations) {
1781 ED_annotation_draw_view2d(draw_ctx.evil_C, false);
1782 }
1783 }
1784
1785 ED_region_pixelspace(draw_ctx.region);
1786
1787 if (do_draw_gizmos) {
1789 DRW_draw_gizmo_2d(draw_ctx.evil_C, draw_ctx.region);
1790 }
1791
1793
1795}
1796
1798{
1799 DRWContext &draw_ctx = drw_get();
1800 BLI_assert(draw_ctx.text_store_p);
1801 if (*draw_ctx.text_store_p == nullptr) {
1802 *draw_ctx.text_store_p = DRW_text_cache_create();
1803 }
1804 return *draw_ctx.text_store_p;
1805}
1806
1808
1809/* -------------------------------------------------------------------- */
1812
1817static void drw_draw_render_loop_3d(DRWContext &draw_ctx, RenderEngineType *engine_type)
1818{
1819 using namespace blender::draw;
1820 Depsgraph *depsgraph = draw_ctx.depsgraph;
1821 View3D *v3d = draw_ctx.v3d;
1822
1823 /* Check if scene needs to perform the populate loop */
1824 const bool internal_engine = (engine_type->flag & RE_INTERNAL) != 0;
1825 const bool draw_type_render = v3d->shading.type == OB_RENDER;
1826 const bool overlays_on = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
1827 const bool gpencil_engine_needed = DRW_render_check_grease_pencil(depsgraph, v3d);
1828 const bool do_populate_loop = internal_engine || overlays_on || !draw_type_render ||
1829 gpencil_engine_needed;
1830
1831 auto should_draw_object = [&](Object &ob, const DupliObject *dupli) -> DrawFilter {
1832 return draw_filter_from_viewport_object_for_draw(draw_ctx, ob, dupli);
1833 };
1834
1835 draw_ctx.enable_engines(gpencil_engine_needed, engine_type);
1836 draw_ctx.engines_data_validate();
1837 draw_ctx.engines_init_and_sync([&](DupliCacheManager &duplis, ExtractionGraph &extraction) {
1838 /* Only iterate over objects for internal engines or when overlays are enabled */
1839 if (do_populate_loop) {
1840 foreach_obref_in_scene(draw_ctx, should_draw_object, [&](ObjectRef &ob_ref) {
1841 drw_engines_cache_populate(ob_ref, duplis, extraction);
1842 });
1843 }
1844 });
1845
1846 /* No frame-buffer allowed before drawing. */
1850
1851 drw_callbacks_pre_scene(draw_ctx);
1852 draw_ctx.engines_draw_scene();
1853 drw_callbacks_post_scene(draw_ctx);
1854
1856 /* Don't unbind the frame-buffer yet in this case and let
1857 * GPU_viewport_unbind do it, so that we can still do further
1858 * drawing of action zones on top. */
1859 }
1860 else {
1862 }
1863}
1864
1866{
1867 Depsgraph *depsgraph = draw_ctx.depsgraph;
1868 ARegion *region = draw_ctx.region;
1869
1870 /* TODO(jbakker): Only populate when editor needs to draw object.
1871 * for the image editor this is when showing UVs. */
1872 const bool do_populate_loop = (draw_ctx.space_data->spacetype == SPACE_IMAGE);
1873
1874 draw_ctx.enable_engines();
1875 draw_ctx.engines_data_validate();
1876 draw_ctx.engines_init_and_sync([&](DupliCacheManager &duplis, ExtractionGraph &extraction) {
1877 /* Only iterate over objects when overlay uses object data. */
1878 if (do_populate_loop) {
1879 DEGObjectIterSettings deg_iter_settings = {nullptr};
1880 deg_iter_settings.depsgraph = depsgraph;
1882 DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
1883 draw::ObjectRef ob_ref(ob);
1884 drw_engines_cache_populate(ob_ref, duplis, extraction);
1885 }
1887 }
1888 });
1889
1890 /* No frame-buffer allowed before drawing. */
1894
1896 draw_ctx.engines_draw_scene();
1897 drw_callbacks_post_scene_2D(draw_ctx, region->v2d);
1898
1900 /* Don't unbind the frame-buffer yet in this case and let
1901 * GPU_viewport_unbind do it, so that we can still do further
1902 * drawing of action zones on top. */
1903 }
1904 else {
1906 }
1907}
1908
1910{
1911 Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
1912 ARegion *region = CTX_wm_region(C);
1913 View3D *v3d = CTX_wm_view3d(C);
1915
1916 DRWContext draw_ctx(DRWContext::VIEWPORT, depsgraph, viewport, C);
1917 draw_ctx.acquire_data();
1918
1919 if (draw_ctx.v3d) {
1920 Scene *scene = DEG_get_evaluated_scene(depsgraph);
1921 RenderEngineType *engine_type = ED_view3d_engine_type(scene, draw_ctx.v3d->shading.type);
1922
1923 draw_ctx.options.draw_background = (scene->r.alphamode == R_ADDSKY) ||
1924 (draw_ctx.v3d->shading.type != OB_RENDER);
1925
1926 drw_draw_render_loop_3d(draw_ctx, engine_type);
1927 }
1928 else {
1929 drw_draw_render_loop_2d(draw_ctx);
1930 }
1931 if (v3d) {
1932 v3d->runtime.last_sync_time = draw_ctx.last_sync_time();
1934 }
1935 draw_ctx.release_data();
1936}
1937
1938void DRW_draw_render_loop_offscreen(Depsgraph *depsgraph,
1939 RenderEngineType *engine_type,
1940 ARegion *region,
1941 View3D *v3d,
1942 bContext *context,
1943 const bool is_image_render,
1944 const bool draw_background,
1945 const bool do_color_management,
1946 GPUOffScreen *ofs,
1947 GPUViewport *viewport)
1948{
1949 const bool is_xr_surface = ((v3d->flag & V3D_XR_SESSION_SURFACE) != 0);
1950
1951 /* Create temporary viewport if needed or update the existing viewport. */
1952 GPUViewport *render_viewport = viewport;
1953 if (viewport == nullptr) {
1954 render_viewport = GPU_viewport_create();
1955 }
1956
1957 GPU_viewport_bind_from_offscreen(render_viewport, ofs, is_xr_surface);
1958
1959 /* Just here to avoid an assert but shouldn't be required in practice. */
1961
1962 /* TODO(fclem): We might want to differentiate between render preview and offscreen render in the
1963 * future. The later can do progressive rendering. */
1964 BLI_assert(is_xr_surface == !is_image_render);
1965 UNUSED_VARS_NDEBUG(is_image_render);
1967
1968 DRWContext draw_ctx(mode, depsgraph, render_viewport, context, region, v3d);
1969 draw_ctx.acquire_data();
1970 draw_ctx.options.draw_background = draw_background;
1971
1972 drw_draw_render_loop_3d(draw_ctx, engine_type);
1973
1974 draw_ctx.release_data();
1975
1976 if (draw_background) {
1977 /* HACK(@fclem): In this case we need to make sure the final alpha is 1.
1978 * We use the blend mode to ensure that. A better way to fix that would
1979 * be to do that in the color-management shader. */
1980 GPU_offscreen_bind(ofs, false);
1981 GPU_clear_color(0.0f, 0.0f, 0.0f, 1.0f);
1982 /* Pre-multiply alpha over black background. */
1984 }
1985
1988 const bool do_overlays = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 ||
1989 ELEM(v3d->shading.type, OB_WIRE, OB_SOLID) ||
1990 (ELEM(v3d->shading.type, OB_MATERIAL) &&
1991 (v3d->shading.flag & V3D_SHADING_SCENE_WORLD) == 0) ||
1992 (ELEM(v3d->shading.type, OB_RENDER) &&
1994 GPU_viewport_unbind_from_offscreen(render_viewport, ofs, do_color_management, do_overlays);
1995
1996 if (draw_background) {
1997 /* Reset default. */
1999 }
2000
2001 /* Free temporary viewport. */
2002 if (viewport == nullptr) {
2003 GPU_viewport_free(render_viewport);
2004 }
2005}
2006
2008 Depsgraph *depsgraph, const bool skip_grease_pencil_objects)
2009{
2010 using namespace blender::bke;
2011 bool found = false;
2012 DEG_foreach_ID(depsgraph, [&](const ID *id) {
2013 const ID *id_eval = DEG_get_evaluated_id(depsgraph, id);
2014 if (found) {
2015 return;
2016 }
2017 if (id_eval->id_type() == ID_OB) {
2018 const Object *ob = reinterpret_cast<const Object *>(id_eval);
2019 if (skip_grease_pencil_objects && ob->type == OB_GREASE_PENCIL) {
2020 return;
2021 }
2022 const bool is_self_visible = BKE_object_visibility(ob, DAG_EVAL_RENDER) & OB_VISIBLE_SELF;
2023 const bool contains_grease_pencil_geometry =
2026 if (is_self_visible && contains_grease_pencil_geometry) {
2027 found = true;
2028 }
2029 }
2030 });
2031 return found;
2032}
2033
2034bool DRW_render_check_grease_pencil(Depsgraph *depsgraph, View3D *v3d)
2035{
2036 if (v3d && gpencil_object_is_excluded(v3d)) {
2037 /* Grease pencil generated by other object types follows the visibility of their type,
2038 * the grease pencil objects themselves are hidden by the per object filter. */
2040 }
2041
2042 if (gpencil_any_exists(depsgraph)) {
2043 return true;
2044 }
2045
2047}
2048
2049void DRW_render_gpencil(RenderEngine *engine, Depsgraph *depsgraph)
2050{
2051 using namespace blender::draw;
2052 /* This function should only be called if there are grease pencil objects,
2053 * especially important to avoid failing in background renders without GPU context. */
2055
2056 Scene *scene = DEG_get_evaluated_scene(depsgraph);
2057 ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
2058 RenderResult *render_result = RE_engine_get_result(engine);
2059 RenderLayer *render_layer = RE_GetRenderLayer(render_result, view_layer->name);
2060 if (render_layer == nullptr) {
2061 return;
2062 }
2063
2064 Render *render = engine->re;
2065
2067
2068 DRWContext draw_ctx(DRWContext::RENDER, depsgraph, {engine->resolution_x, engine->resolution_y});
2069 draw_ctx.acquire_data();
2070 draw_ctx.options.draw_background = scene->r.alphamode == R_ADDSKY;
2071
2072 /* Main rendering. */
2073 rctf view_rect;
2074 rcti render_rect;
2075 RE_GetViewPlane(render, &view_rect, &render_rect);
2076 if (BLI_rcti_is_empty(&render_rect)) {
2077 BLI_rcti_init(&render_rect, 0, draw_ctx.size[0], 0, draw_ctx.size[1]);
2078 }
2079
2080 for (RenderView *render_view = render_result->views.first(); render_view != nullptr;
2081 render_view = render_view->next)
2082 {
2083 RE_SetActiveRenderView(render, render_view->name);
2084 gpencil::Engine::render_to_image(engine, render_layer, render_rect);
2085 }
2086
2088
2090
2092
2093 draw_ctx.release_data();
2094
2095 /* Restore Drawing area. */
2097
2099}
2100
2102 RenderEngine *engine,
2103 Depsgraph *depsgraph,
2104 std::function<void(RenderEngine *, RenderLayer *, const rcti)> render_view_cb,
2105 std::function<void(RenderResult *)> store_metadata_cb)
2106{
2107 using namespace blender::draw;
2108 Scene *scene = DEG_get_evaluated_scene(depsgraph);
2109 ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
2110 Render *render = engine->re;
2111
2112 /* IMPORTANT: We don't support immediate mode in render mode!
2113 * This shall remain in effect until immediate mode supports
2114 * multiple threads. */
2115
2116 /* Begin GPU workload Boundary */
2118
2119 DRWContext draw_ctx(DRWContext::RENDER, depsgraph, {engine->resolution_x, engine->resolution_y});
2120 draw_ctx.acquire_data();
2121 draw_ctx.options.draw_background = scene->r.alphamode == R_ADDSKY;
2122
2123 /* Main rendering. */
2124 rctf view_rect;
2125 rcti render_rect;
2126 RE_GetViewPlane(render, &view_rect, &render_rect);
2127 if (BLI_rcti_is_empty(&render_rect)) {
2128 BLI_rcti_init(&render_rect, 0, draw_ctx.size[0], 0, draw_ctx.size[1]);
2129 }
2130
2131 /* Reset state before drawing */
2133
2134 /* set default viewport */
2135 GPU_viewport(0, 0, draw_ctx.size[0], draw_ctx.size[1]);
2136
2137 /* Init render result. */
2138 RenderResult *render_result = RE_engine_begin_result(engine,
2139 0,
2140 0,
2141 draw_ctx.size[0],
2142 draw_ctx.size[1],
2143 view_layer->name,
2144 /*RR_ALL_VIEWS*/ nullptr);
2145 RenderLayer *render_layer = render_result->layers.first();
2146 for (RenderView *render_view = render_result->views.first(); render_view != nullptr;
2147 render_view = render_view->next)
2148 {
2149 RE_SetActiveRenderView(render, render_view->name);
2150 render_view_cb(engine, render_layer, render_rect);
2151 }
2152
2153 RE_engine_end_result(engine, render_result, false, false, false);
2154
2155 store_metadata_cb(RE_engine_get_result(engine));
2156
2158
2160
2161 draw_ctx.release_data();
2163
2164 /* End GPU workload Boundary */
2166}
2167
2169 RenderEngine *engine,
2170 Depsgraph *depsgraph,
2171 std::function<void(draw::ObjectRef &, RenderEngine *, Depsgraph *)> callback)
2172{
2173 using namespace blender::draw;
2174
2175 DRWContext &draw_ctx = drw_get();
2176
2177 /* Without a viewport there are no viewport settings to hide objects, draw everything. */
2178 auto should_draw_object_all = [](Object & /*ob*/, const DupliObject * /*dupli*/) -> DrawFilter {
2179 return DrawFilter::Draw;
2180 };
2181 auto should_draw_object_viewport = [&](Object &ob, const DupliObject *dupli) -> DrawFilter {
2182 return draw_filter_from_viewport_object_for_draw(draw_ctx, ob, dupli);
2183 };
2184 FunctionRef<DrawFilter(Object &, const DupliObject *)> should_draw_object =
2185 should_draw_object_viewport;
2186 if (draw_ctx.v3d == nullptr) {
2187 should_draw_object = should_draw_object_all;
2188 }
2189
2190 draw_ctx.sync([&](DupliCacheManager &duplis, ExtractionGraph &extraction) {
2191 foreach_obref_in_scene(draw_ctx, should_draw_object, [&](ObjectRef &ob_ref) {
2192 if (ob_ref.is_dupli() == false) {
2194 }
2195 else {
2196 duplis.try_add(ob_ref);
2197 }
2198 callback(ob_ref, engine, depsgraph);
2199 if (ob_ref.is_dupli() == false) {
2201 }
2202 /* Batch generation for duplis happens after iter_callback. */
2203 });
2204 });
2205}
2206
2207void DRW_custom_pipeline_begin(DRWContext &draw_ctx, Depsgraph * /*depsgraph*/)
2208{
2209 draw_ctx.acquire_data();
2210 draw_ctx.data->modules_begin_sync();
2211}
2212
2214{
2216
2217 /* The use of custom pipeline in other thread using the same
2218 * resources as the main thread (viewport) may lead to data
2219 * races and undefined behavior on certain drivers. Using
2220 * GPU_finish to sync seems to fix the issue. (see #62997) */
2222 if (type == GPU_BACKEND_OPENGL) {
2223 GPU_finish();
2224 }
2225
2227 draw_ctx.release_data();
2228}
2229
2231{
2232 using namespace blender::draw;
2233 DRWContext &draw_ctx = drw_get();
2234 draw_ctx.data->modules_exit();
2235 draw_ctx.acquire_data();
2236 draw_ctx.data->modules_begin_sync();
2237}
2238
2239void DRW_render_set_time(RenderEngine *engine, Depsgraph *depsgraph, int frame, float subframe)
2240{
2241 DRWContext &draw_ctx = drw_get();
2242 RE_engine_frame_set(engine, frame, subframe);
2243 draw_ctx.scene = DEG_get_evaluated_scene(depsgraph);
2244 draw_ctx.view_layer = DEG_get_evaluated_view_layer(depsgraph);
2245}
2246
2251
2252static void draw_select_framebuffer_depth_only_setup(const int size[2])
2253{
2254 if (g_select_buffer.framebuffer_depth_only == nullptr) {
2256 }
2257
2258 if ((g_select_buffer.texture_depth != nullptr) &&
2261 {
2264 }
2265
2266 if (g_select_buffer.texture_depth == nullptr) {
2269 "select_depth", size[0], size[1], 1, gpu::TextureFormat::SFLOAT_32_DEPTH, usage, nullptr);
2270
2273
2275 }
2276}
2277
2278void DRW_draw_select_loop(Depsgraph *depsgraph,
2279 ARegion *region,
2280 View3D *v3d,
2281 bool draw_surface,
2282 bool /*use_nearest*/,
2283 const bool do_material_sub_selection,
2284 const rcti *rect,
2285 DRW_SelectPassFn select_pass_fn,
2286 void *select_pass_user_data,
2287 DRW_ObjectFilterFn object_filter_fn,
2288 void *object_filter_user_data)
2289{
2290 using namespace blender::draw;
2291 const int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)};
2292
2293 const bool use_gpencil = !draw_surface && DRW_render_check_grease_pencil(depsgraph, v3d);
2294
2295 DRWContext::Mode mode = do_material_sub_selection ? DRWContext::SELECT_OBJECT_MATERIAL :
2297
2298 DRWContext draw_ctx(mode, depsgraph, viewport_size, nullptr, region, v3d);
2299 draw_ctx.acquire_data();
2300 draw_ctx.enable_engines(use_gpencil);
2301 draw_ctx.engines_data_validate();
2302 draw_ctx.engines_init_and_sync([&](DupliCacheManager &duplis, ExtractionGraph &extraction) {
2303 auto should_draw_object = [&](Object &ob, const DupliObject *dupli) -> DrawFilter {
2304 return draw_filter_from_viewport_object_for_select(
2305 draw_ctx, ob, dupli, object_filter_fn, object_filter_user_data);
2306 };
2307
2308 foreach_obref_in_scene(draw_ctx, should_draw_object, [&](ObjectRef &ob_ref) {
2309 drw_engines_cache_populate(ob_ref, duplis, extraction);
2310 });
2311 });
2312
2313 /* Setup frame-buffer. */
2317
2318 /* WORKAROUND: Needed for Select-Next for keeping the same code-flow as Overlay-Next. */
2319 /* TODO(pragma37): Some engines retrieve the depth texture before this point (See #132922).
2320 * Check with @fclem. */
2321 BLI_assert(DRW_context_get()->viewport_texture_list_get()->depth == nullptr);
2323
2324 drw_callbacks_pre_scene(draw_ctx);
2325 /* Only 1-2 passes. */
2326 while (true) {
2327 if (!select_pass_fn(DRW_SELECT_PASS_PRE, select_pass_user_data)) {
2328 break;
2329 }
2330 draw_ctx.engines_draw_scene();
2331 if (!select_pass_fn(DRW_SELECT_PASS_POST, select_pass_user_data)) {
2332 break;
2333 }
2334 }
2335
2336 /* WORKAROUND: Do not leave ownership to the viewport list. */
2338
2339 draw_ctx.release_data();
2340
2342}
2343
2344void DRW_draw_depth_loop(Depsgraph *depsgraph,
2345 ARegion *region,
2346 View3D *v3d,
2347 GPUViewport *viewport,
2348 const bool use_gpencil,
2349 const bool use_only_selected,
2350 const bool use_only_active_object)
2351{
2352 using namespace blender::draw;
2353
2354 DRWContext draw_ctx(use_only_active_object ? DRWContext::DEPTH_ACTIVE_OBJECT : DRWContext::DEPTH,
2355 depsgraph,
2356 viewport,
2357 nullptr,
2358 region,
2359 v3d);
2360 draw_ctx.acquire_data();
2361 draw_ctx.enable_engines(use_gpencil);
2362 draw_ctx.engines_init_and_sync([&](DupliCacheManager &duplis, ExtractionGraph &extraction) {
2363 auto should_draw_object = [&](Object &ob, const DupliObject *dupli) -> DrawFilter {
2364 if (const DrawFilter filter = draw_filter_from_viewport_object_for_draw(draw_ctx, ob, dupli);
2365 filter != DrawFilter::Draw)
2366 {
2367 return filter;
2368 }
2369 if (use_only_selected && !(ob.base_flag & BASE_SELECTED)) {
2370 return DrawFilter::Skip;
2371 }
2372 return DrawFilter::Draw;
2373 };
2374
2375 if (use_only_active_object) {
2376 draw::ObjectRef ob_ref(draw_ctx.obact);
2377 drw_engines_cache_populate(ob_ref, duplis, extraction);
2378 }
2379 else {
2380 foreach_obref_in_scene(draw_ctx, should_draw_object, [&](ObjectRef &ob_ref) {
2381 drw_engines_cache_populate(ob_ref, duplis, extraction);
2382 });
2383 }
2384 });
2385
2386 /* Setup frame-buffer. */
2387 gpu::Texture *depth_tx = GPU_viewport_depth_texture(viewport);
2388 gpu::FrameBuffer *depth_fb = nullptr;
2390 {
2391 GPU_ATTACHMENT_TEXTURE(depth_tx),
2393 });
2394 GPU_framebuffer_bind(depth_fb);
2395 GPU_framebuffer_clear_depth(depth_fb, 1.0f);
2396
2397 draw_ctx.engines_draw_scene();
2398
2399 /* TODO: Reading depth for operators should be done here. */
2400
2402 GPU_framebuffer_free(depth_fb);
2403
2404 draw_ctx.release_data();
2405}
2406
2407void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d)
2408{
2410 GPUViewport *viewport = WM_draw_region_get_viewport(region);
2411 if (!viewport) {
2412 /* Selection engine requires a viewport.
2413 * TODO(@germano): This should be done internally in the engine. */
2414 sel_ctx->max_index_drawn_len = 1;
2415 return;
2416 }
2417
2418 using namespace blender::draw;
2419
2420 /* Make sure select engine gets the correct vertex size. */
2422
2423 DRWContext draw_ctx(DRWContext::SELECT_EDIT_MESH, depsgraph, viewport, nullptr, region, v3d);
2424 draw_ctx.acquire_data();
2425 draw_ctx.enable_engines();
2426 draw_ctx.engines_init_and_sync([&](DupliCacheManager &duplis, ExtractionGraph &extraction) {
2427 for (Object *obj_eval : sel_ctx->objects) {
2428 draw::ObjectRef ob_ref(obj_eval);
2429 drw_engines_cache_populate(ob_ref, duplis, extraction);
2430 }
2431
2432 if (RETOPOLOGY_ENABLED(v3d) && !XRAY_ENABLED(v3d)) {
2433 auto should_draw_object = [&](Object &ob, const DupliObject *dupli) -> DrawFilter {
2434 if (const DrawFilter filter = draw_filter_from_viewport_object_for_draw(
2435 draw_ctx, ob, dupli);
2436 filter != DrawFilter::Draw)
2437 {
2438 return filter;
2439 }
2440 if (ob.type != OB_MESH) {
2441 /* The iterator has evaluated meshes for all solid objects.
2442 * It also has non-mesh objects however, which are not supported here. */
2443 return DrawFilter::Skip;
2444 }
2445 if (DRW_object_is_in_edit_mode(&ob)) {
2446 /* Only background (non-edit) objects are used for occlusion. */
2447 return DrawFilter::Skip;
2448 }
2449 return DrawFilter::Draw;
2450 };
2451
2452 foreach_obref_in_scene(draw_ctx, should_draw_object, [&](ObjectRef &ob_ref) {
2453 drw_engines_cache_populate(ob_ref, duplis, extraction);
2454 });
2455 }
2456 });
2457
2458 draw_ctx.engines_draw_scene();
2459
2460 draw_ctx.release_data();
2461}
2462
2464{
2465 return DRWContext::is_active();
2466}
2467
2469
2470/* -------------------------------------------------------------------- */
2473
2475{
2476 return &drw_get();
2477}
2478
2480{
2481 if (this->evil_C != nullptr) {
2483 return ED_screen_animation_playing(wm) != nullptr;
2484 }
2485 return false;
2486}
2487
2489{
2490 return (rv3d) && (rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING));
2491}
2492
2494{
2495 return (rv3d) && (rv3d->rflag & (RV3D_PAINTING));
2496}
2497
2499{
2500 return (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) != 0;
2501}
2502
2504{
2505 if (!this->v3d || !this->rv3d) {
2506 return false;
2507 }
2508
2509 return bke::compositor::is_viewport_compositor_enabled(*this->v3d, *this->rv3d) &&
2511}
2512
2514
2515/* -------------------------------------------------------------------- */
2518
2524
2526{
2533#ifdef WITH_DRAW_DEBUG
2534 draw::edit_select_debug::Engine::free_static();
2535#endif
2536}
2537
2539
2540/* -------------------------------------------------------------------- */
2543
2545{
2546 using namespace blender::draw;
2547 /* setup callbacks */
2550
2553
2556
2559
2562
2565
2568
2571
2574
2576}
2577
2585
2587
2588} // namespace blender
Camera data-block and utility functions.
Low-level operations for curves that cannot be defined in the C++ header yet.
Low-level operations for grease pencil that cannot be defined in the C++ header yet.
General operations, lookup, etc. for blender objects.
General operations for point clouds.
Volume data-block.
Platform independent time functions.
#define IFACE_(msgid)
#define DEG_OBJECT_ITER_BEGIN(settings_, instance_)
#define DEG_OBJECT_ITER_END
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS
#define OB_MODE_ALL_WEIGHT_PAINT
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_PRE_VIEW
#define XRAY_ENABLED(v3d)
#define RETOPOLOGY_ENABLED(v3d)
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
#define GPU_framebuffer_ensure_config(_fb,...)
#define GPU_TEXTURE_FREE_SAFE(texture)
#define C
Definition RandGen.cpp:29
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
constexpr IndexRange()=default
void clear()
Definition BLI_map.hh:1038
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
ItemIterator items() const &
Definition BLI_map.hh:902
constexpr const char * c_str() const
void begin_sync(Object *object_active=nullptr)
ObjectRef(Object *ob, Object *dupli_parent=nullptr, DupliObject *dupli_object=nullptr)
static void default_set(const float4x4 &view_mat, const float4x4 &win_mat)
Definition draw_view.cc:322
virtual void reset(bool force_free=false)=0
static TexturePool & get()
float2x2 invert(float2x2 mat)
bool is_viewport_compositor_enabled(const View3D &view_3d, const RegionView3D &region_view_3d)
bool is_enabled(const Scene &scene, ExecutionMode mode)
bool operator==(const Error &left, const Error &right)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
Definition DNA_defs.h:147
void viewport_color_management_set(GPUViewport &viewport, DRWContext &draw_ctx)
void DRW_curves_module_free(draw::CurvesModule *module)
static void foreach_obref_in_scene(DRWContext &draw_ctx, FunctionRef< DrawFilter(Object &, const DupliObject *dupli)> should_draw_object_cb, FunctionRef< void(ObjectRef &)> draw_object_cb)
static bool supports_handle_ranges(DupliObject *dupli, Object *parent, const DRWContext &draw_ctx)
void DRW_particle_batch_cache_free(ParticleSystem *psys)
void DRW_pointcloud_module_free(draw::PointCloudModule *module)
void DRW_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
void DRW_gsplat_module_free(draw::GSplatModule *module)
void DRW_mesh_batch_cache_free(draw::MeshBatchCache *batch_cache)
void DRW_lattice_batch_cache_free(Lattice *lt)
ENUM_OPERATORS(DRWBatchFlag)
void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil)
void drw_batch_cache_generate_requested_evaluated_mesh_or_curve(Object *ob, TaskGraph &task_graph)
void DRW_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
void DRW_curves_init(DRWData *drw_data=nullptr)
void drw_batch_cache_validate(Object *ob)
void DRW_subdiv_cache_free(bke::subdiv::Subdiv *subdiv)
void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode)
void DRW_volume_batch_cache_free(Volume *volume)
void DRW_curves_update(draw::Manager &manager)
void DRW_gsplat_init(DRWData *drw_data=nullptr)
void DRW_volume_init(DRWData *drw_data=nullptr)
void DRW_volume_batch_cache_dirty_tag(Volume *volume, int mode)
void DRW_curve_batch_cache_free(Curve *cu)
void DRW_curves_begin_sync(DRWData *drw_data)
void drw_batch_cache_generate_requested(Object *ob, TaskGraph &task_graph)
void DRW_curves_batch_cache_dirty_tag(Curves *curves, int mode)
void DRW_pointcloud_init(DRWData *drw_data=nullptr)
void DRW_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
void DRW_particle_batch_cache_dirty_tag(ParticleSystem *psys, int mode)
void DRW_gsplat_batch_cache_free(PointCloud *pointcloud)
void DRW_pointcloud_batch_cache_free(PointCloud *pointcloud)
void DRW_batch_cache_free_old(Object *ob, int ctime)
void DRW_gsplat_begin_sync()
void DRW_volume_module_free(draw::VolumeModule *module)
void DRW_curves_batch_cache_free(Curves *curves)
void DRW_curve_batch_cache_dirty_tag(Curve *cu, int mode)
void DRW_gsplat_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
bool DEG_iterator_temp_object_from_dupli(const Object *dupli_parent, const DupliObject *dupli, eEvaluationMode eval_mode, bool do_matrix_setup, Object *r_temp_object, bke::ObjectRuntime *r_temp_runtime)
void DEG_iterator_temp_object_free_properties(const DupliObject *dupli, Object *temp_object)
AngleRadianBase< float > AngleRadian
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
MatT from_rotation(const RotationT &rotation)
void theme_set(int spacetype, int regionid)
BMesh Iterators.
struct TaskGraph * BLI_task_graph_create()
Definition task_graph.cc:98
void RE_SetActiveRenderView(Render *re, const char *viewname)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void DRW_render_to_image(RenderEngine *engine, Depsgraph *depsgraph, std::function< void(RenderEngine *, RenderLayer *, const rcti)> render_view_cb, std::function< void(RenderResult *)> store_metadata_cb)
void DRW_custom_pipeline_end(DRWContext &draw_ctx)
void DRW_draw_select_loop(Depsgraph *depsgraph, ARegion *region, View3D *v3d, bool draw_surface, bool use_nearest, bool do_material_sub_selection, const rcti *rect, DRW_SelectPassFn select_pass_fn, void *select_pass_user_data, DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data)
gpu::Texture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
const Mesh * BKE_object_get_editmesh_eval_cage(const Object *object)
Definition object.cc:4492
void GPU_scissor_test(bool enable)
Definition gpu_state.cc:173
unsigned __int64 uint64_t
Definition BKE_text.h:91
gpu::FrameBuffer * GPU_framebuffer_active_get()
void ED_region_surface_draw_cb_draw(const bContext *C, ARegionType *art, int type)
void DRW_draw_view(const bContext *C)
void DRW_render_context_enable(Render *render)
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
static void drw_render_border_mask(const DRWContext &ctx)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
bool GPU_type_matches_ex(GPUDeviceType device, GPUOSType os, GPUDriverType driver, GPUBackendType backend)
DRWData * DRW_viewport_data_create()
bool DEG_iterator_object_is_visible(eEvaluationMode eval_mode, const Object *ob)
void immEnd()
draw::TextureFromPool & DRW_viewport_pass_texture_get(const char *pass_name)
RenderEngineType DRW_engine_viewport_workbench_type
void GPU_framebuffer_restore()
void DRW_render_context_disable(Render *render)
unsigned int uint
Definition BKE_text.h:55
bool DEG_is_fully_evaluated(const Depsgraph *depsgraph)
void GPU_clear_color(float red, float green, float blue, float alpha)
Depsgraph * BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_layer)
Definition scene.cc:3631
bool GPU_framebuffer_check_valid(gpu::FrameBuffer *fb, char err_out[256])
bool BKE_subsurf_modifier_has_gpu_subdiv(const Mesh *mesh)
void GPU_framebuffer_free(gpu::FrameBuffer *fb)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
void(*) BKE_grease_pencil_batch_cache_dirty_tag_cb(GreasePencil *grease_pencil, int mode)
DRWTextStore * DRW_text_cache_ensure()
@ BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT
@ BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT
void GPU_matrix_identity_set()
void GPU_viewport_tag_update(GPUViewport *viewport)
bool(*)(Object *ob, void *user_data) DRW_ObjectFilterFn
Definition DRW_engine.hh:54
void GPU_framebuffer_clear_depth_stencil(gpu::FrameBuffer *fb, float clear_depth, uint clear_stencil)
GPUVertFormat * immVertexFormat()
bool DRW_object_is_renderable(const Object *ob)
void ED_annotation_draw_view3d(Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, bool only3d)
bool BKE_camera_view_render_border(const struct Scene *scene, const struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d, int winx, int winy, rctf *r_border, rctf *r_unrolled_border)
void(*) BKE_curves_batch_cache_free_cb(struct Curves *curves)
void DRW_engines_free()
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
GPUBackendType GPU_backend_get_type()
void DRW_cache_restart()
void DRW_draw_gizmo_2d(const bContext *C, ARegion *region)
MatBase< float, 2, 2 > float2x2
void BLI_task_graph_free(struct TaskGraph *task_graph)
@ RE_INTERNAL
Definition RE_engine.h:45
void immBegin(GPUPrimType, uint vertex_len)
void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool is_xr_surface)
bool(*)(eDRWSelectStage stage, void *user_data) DRW_SelectPassFn
Definition DRW_engine.hh:53
void GPU_depth_mask(bool depth)
Definition gpu_state.cc:107
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
bool is_negative_m4(const float mat[4][4])
DRWContext & drw_get()
@ V3D_XR_SESSION_SURFACE
@ V3D_XR_SESSION_MIRROR
RenderEngineType * ED_view3d_engine_type(const Scene *scene, int drawtype)
void GPU_matrix_identity_projection_set()
void GPU_render_begin()
void DRW_draw_region_info(const bContext *C, ARegion *region)
void DRW_view_data_default_lists_from_viewport(DRWViewData *view_data, GPUViewport *viewport)
void(*) BKE_pointcloud_batch_cache_dirty_tag_cb(PointCloud *pointcloud, int mode)
MatBase< float, 4, 4 > float4x4
void(*) BKE_lattice_batch_cache_dirty_tag_cb(Lattice *lt, int mode)
Definition lattice.cc:715
@ V3D_SHADING_SCENE_WORLD
@ V3D_SHADING_SCENE_WORLD_RENDER
void(*) BKE_curve_batch_cache_free_cb(Curve *cu)
Definition curve.cc:5534
int DRW_object_visibility_in_active_context(const Object *ob)
void immUnbindProgram()
void DRW_render_object_iter(RenderEngine *engine, Depsgraph *depsgraph, std::function< void(draw::ObjectRef &, RenderEngine *, Depsgraph *)> callback)
void DRW_module_init()
@ V3D_XR_SHOW_CONTROLLERS
@ V3D_XR_SHOW_CUSTOM_OVERLAYS
void DRW_cache_free_old_batches(Main *bmain)
RenderResult * RE_engine_get_result(RenderEngine *engine)
void DRW_viewport_data_free(DRWData *drw_data)
RenderEngineType DRW_engine_viewport_eevee_type
void GPU_apply_state()
Definition gpu_state.cc:294
void DRW_render_set_time(RenderEngine *engine, Depsgraph *depsgraph, int frame, float subframe)
void BLI_task_graph_work_and_wait(struct TaskGraph *task_graph)
void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:91
bool BKE_object_is_visible_in_viewport_ex(const View3D *v3d, const Object *ob, ObjectType ob_type)
DRWData ** GPU_viewport_data_get(GPUViewport *viewport)
Global G
Definition blender.cc:57
void wmOrtho2(float x1, float x2, float y1, float y2)
unsigned short uint16_t
Definition BKE_text.h:80
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
bool psys_in_edit_mode(struct Depsgraph *depsgraph, const struct ParticleSystem *psys)
void(*) BKE_particle_batch_cache_dirty_tag_cb(struct ParticleSystem *psys, int mode)
Definition particle.cc:5577
void DRW_draw_gizmo_3d(const bContext *C, ARegion *region)
void(*) BKE_particle_batch_cache_free_cb(struct ParticleSystem *psys)
Definition particle.cc:5578
bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type)
static bool draw_show_annotation()
void RE_engine_end_result(RenderEngine *engine, RenderResult *result, bool cancel, bool highlight, bool merge_results)
void(*) BKE_lattice_batch_cache_free_cb(Lattice *lt)
Definition lattice.cc:716
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void(*) BKE_pointcloud_batch_cache_free_cb(PointCloud *pointcloud)
bool DRW_draw_in_progress()
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
@ GPU_DEPTH_NONE
Definition GPU_state.hh:132
@ GPU_DEPTH_LESS_EQUAL
Definition GPU_state.hh:135
@ GPU_DEPTH_ALWAYS
Definition GPU_state.hh:133
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void(*) BKE_curves_batch_cache_dirty_tag_cb(struct Curves *curves, int mode)
void DRW_shaders_free()
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
void GPU_render_end()
void RE_engines_register(RenderEngineType *render_type)
static void drw_callbacks_pre_scene_2D(DRWContext &draw_ctx)
static void draw_select_framebuffer_depth_only_setup(const int size[2])
Main * DEG_get_bmain(const Depsgraph *graph)
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_PARTICLE_EDIT
BMesh const char void * data
void(*) BKE_volume_batch_cache_free_cb(Volume *volume)
Object * BKE_object_pose_armature_get(Object *ob)
Definition object.cc:2507
static void drw_callbacks_post_scene_view3d(DRWContext &draw_ctx)
void object_duplilist(Depsgraph *depsgraph, Object *ob, Set< const Object * > *include_objects, DupliList &r_duplilist)
int BKE_object_visibility(const Object *ob, int dag_eval_mode)
Definition object.cc:2063
wmWindowManager * CTX_wm_manager(const bContext *C)
gpu::FrameBuffer * GPU_framebuffer_back_get()
void(*) BKE_volume_batch_cache_dirty_tag_cb(Volume *volume, int mode)
void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d)
unsigned char uint8_t
Definition BKE_text.h:79
void(*) BKE_grease_pencil_batch_cache_free_cb(GreasePencil *grease_pencil)
void DRW_draw_depth_loop(Depsgraph *depsgraph, ARegion *region, View3D *v3d, GPUViewport *viewport, const bool use_gpencil, const bool use_only_selected, const bool use_only_active_object)
bool DRW_engine_external_acquire_for_image_editor(const DRWContext *draw_ctx)
bool DRW_object_is_visible_psys_in_active_context(const Object *object, const ParticleSystem *psys)
static bool gpencil_object_is_excluded(View3D *v3d)
void DRW_module_exit()
void GPU_color_mask(bool r, bool g, bool b, bool a)
Definition gpu_state.cc:95
static void drw_draw_render_loop_3d(DRWContext &draw_ctx, RenderEngineType *engine_type)
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
int GPU_texture_width(const gpu::Texture *texture)
void GPU_framebuffer_viewport_reset(gpu::FrameBuffer *fb)
void DRW_draw_render_loop_offscreen(Depsgraph *depsgraph, RenderEngineType *engine_type, ARegion *region, View3D *v3d, bContext *context, bool is_image_render, bool draw_background, bool do_color_management, GPUOffScreen *ofs, GPUViewport *viewport)
bool DRW_object_use_hide_faces(const Object *ob)
void immUniformColor4f(float r, float g, float b, float a)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
VectorList< DupliObject > DupliList
void DRW_view_data_reset(DRWViewData *view_data)
@ DAG_EVAL_VIEWPORT
static bool gpencil_any_exists(Depsgraph *depsgraph)
void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height)
static DRWData * drw_viewport_data_ensure(GPUViewport *viewport)
ARegionType * WM_xr_surface_controller_region_type_get()
@ DRW_SELECT_PASS_PRE
Definition DRW_engine.hh:50
@ DRW_SELECT_PASS_POST
Definition DRW_engine.hh:51
ViewLayer * DEG_get_evaluated_view_layer(const Depsgraph *graph)
static void drw_draw_render_loop_2d(DRWContext &draw_ctx)
ARegionType * BKE_regiontype_from_id(const SpaceType *st, int regionid)
Definition screen.cc:364
void DRW_custom_pipeline_begin(DRWContext &draw_ctx, Depsgraph *)
SpaceType * BKE_spacetype_from_id(int spaceid)
Definition screen.cc:354
static void drw_callbacks_post_scene(DRWContext &draw_ctx)
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
void DRW_submission_end()
bool BLI_rcti_is_empty(const struct rcti *rect)
void ED_view3d_init_mats_rv3d(const Object *ob, RegionView3D *rv3d)
void(*) BKE_subsurf_modifier_free_gpu_cache_cb(bke::subdiv::Subdiv *subdiv)
const DRWContext * DRW_context_get()
void GPU_matrix_projection_set(const float m[4][4])
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
Definition particle.cc:739
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
bool DRW_render_check_grease_pencil(Depsgraph *depsgraph, View3D *v3d=nullptr)
gpu::FrameBuffer * GPU_framebuffer_create(const char *name)
void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe)
void GPU_framebuffer_clear_depth(gpu::FrameBuffer *fb, float clear_depth)
int BKE_object_obdata_to_type(const ID *id) ATTR_NONNULL(1)
Definition object.cc:2230
static void drw_callbacks_post_scene_2D(DRWContext &draw_ctx, View2D &v2d)
void GPU_debug_group_end()
Definition gpu_debug.cc:34
static void drw_engines_cache_populate(draw::ObjectRef &ref, DupliCacheManager &dupli_cache, ExtractionGraph &extraction)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:428
bool BKE_object_is_in_editmode(const Object *ob)
Definition object.cc:1898
static struct blender::DRWSelectBuffer g_select_buffer
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
SpaceLink * CTX_wm_space_data(const bContext *C)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
void GPU_scissor(int x, int y, int width, int height)
Definition gpu_state.cc:178
bool DEG_iterator_dupli_is_visible(const DupliObject *dupli, eEvaluationMode eval_mode)
void GPU_viewport_free(GPUViewport *viewport)
void DRW_smoke_exit(DRWData *drw_data)
void ED_region_pixelspace(const ARegion *region)
Definition area.cc:96
void GPU_framebuffer_texture_attach(gpu::FrameBuffer *fb, gpu::Texture *texture, int slot, int mip)
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
void GPU_flush()
Definition gpu_state.cc:284
void DRW_render_gpencil(RenderEngine *engine, Depsgraph *depsgraph)
void BKE_object_replace_data_on_shallow_copy(Object *ob, ID *new_data)
Definition object.cc:5748
bToolRef * WM_toolsystem_ref_from_context(const bContext *C)
gpu::Texture * GPU_viewport_depth_texture(GPUViewport *viewport)
void GPU_matrix_pop_projection()
iter begin(iter)
int GPU_texture_height(const gpu::Texture *texture)
void GPU_texture_free(gpu::Texture *texture)
static bool depsgraph_contains_visible_grease_pencil_geometry(Depsgraph *depsgraph, const bool skip_grease_pencil_objects)
void GPU_viewport(int x, int y, int width, int height)
Definition gpu_state.cc:184
void(*) BKE_curve_batch_cache_dirty_tag_cb(Curve *cu, int mode)
Definition curve.cc:5533
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
Definition rct.cc:565
Scene * DEG_get_input_scene(const Depsgraph *graph)
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
void DRW_submission_start()
draw::Manager * DRW_manager_get()
const Mesh * DRW_object_get_editmesh_cage_for_drawing(const Object &object)
@ G_TRANSFORM_OBJ
@ G_TRANSFORM_EDIT
double BLI_time_now_seconds()
Definition time.cc:30
DRWTextStore * DRW_text_cache_create()
void(*) BKE_gsplat_batch_cache_free_cb(PointCloud *pointcloud)
void RE_GetViewPlane(Render *re, rctf *r_viewplane, rcti *r_disprect)
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
void immVertex3f(uint attr_id, float x, float y, float z)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void DRW_view_data_free_unused(DRWViewData *view_data)
SELECTID_Context * DRW_select_engine_context_get()
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
void(*) BKE_mesh_batch_cache_free_cb(draw::MeshBatchCache *batch_cache)
void GPU_matrix_pop()
bool DRW_object_is_in_edit_mode(const Object *ob)
bool DRW_viewport_pass_texture_exists(const char *pass_name)
void GPU_matrix_push_projection()
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
Definition wm_draw.cc:954
void GPU_finish()
Definition gpu_state.cc:289
void DRW_engines_register()
void GPU_depth_test(GPUDepthTest test)
Definition gpu_state.cc:70
GPUViewport * WM_draw_region_get_bound_viewport(ARegion *region)
Definition wm_draw.cc:964
Mesh * BKE_mesh_wrapper_ensure_subdivision(Mesh *mesh)
int GPU_viewport_active_view_get(GPUViewport *viewport)
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:252
ARegion * CTX_wm_region(const bContext *C)
void GPU_matrix_set(const float m[4][4])
void(*) BKE_gsplat_batch_cache_dirty_tag_cb(PointCloud *pointcloud, int mode)
@ OB_VISIBLE_PARTICLES
@ OB_VISIBLE_SELF
@ OB_VISIBLE_INSTANCES
void DRW_viewport_request_redraw()
View3D * CTX_wm_view3d(const bContext *C)
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_matrix_push()
GPUContext * GPU_context_active_get()
void DRW_smoke_begin_sync(DRWData *drw_data)
static void drw_callbacks_pre_scene(DRWContext &draw_ctx)
void GPU_debug_group_begin(const char *name)
Definition gpu_debug.cc:23
GPUViewport * GPU_viewport_create()
void GPU_viewport_unbind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool display_colorspace, bool do_overlay_merge)
char char size_t char const char * BLI_strchr_or_end(const char *str, char ch) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void(*) BKE_mesh_batch_cache_dirty_tag_cb(Mesh *mesh, eMeshBatchDirtyMode mode)
RenderResult * RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname)
void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src)
#define hash
Definition noise_c.cc:156
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
Set< const Object * > * included_objects
bool is_transforming() const
void sync(iter_callback_t iter_callback)
DefaultTextureList * viewport_texture_list_get() const
RegionView3D * rv3d
gpu::FrameBuffer * default_framebuffer()
Set< Object * > delayed_extraction
struct blender::DRWContext::@231153257105305272346150064304121064225151163351 options
bool is_navigating() const
ViewLayer * view_layer
DRWContext(Mode mode, Depsgraph *depsgraph, GPUViewport *viewport, const bContext *C=nullptr, ARegion *region=nullptr, View3D *v3d=nullptr)
GPUViewport * viewport
bool is_painting() const
const bContext * evil_C
void engines_init_and_sync(iter_callback_t iter_callback)
Depsgraph * depsgraph
DRWTextStore ** text_store_p
bool is_playback() const
::std::function< void(struct DupliCacheManager &, struct ExtractionGraph &)> iter_callback_t
bool is_image_render() const
eObjectMode object_mode
bToolRef * active_tool
float last_submission_time() const
float last_sync_time() const
DefaultFramebufferList * viewport_framebuffer_list_get() const
bool is_viewport_compositor_used() const
enum blender::DRWContext::Mode mode
void enable_engines(bool gpencil_engine_needed=false, RenderEngineType *render_engine_type=nullptr)
bool is_scene_render() const
DRWViewData * view_data_active
static bool is_active()
SpaceLink * space_data
draw::CurvesModule * curves_module
DRWViewData * view_data[2]
draw::GSplatModule * gsplat_module
draw::PointCloudModule * pointcloud_module
draw::VolumeModule * volume_module
gpu::FrameBuffer * framebuffer_depth_only
DefaultFramebufferList dfbl
workbench::Engine workbench
void texture_list_size_validate(const int2 &size)
draw::Manager * manager
draw::compositor_engine::Engine compositor
Map< std::string, std::unique_ptr< draw::TextureFromPool > > viewport_compositor_passes
draw::external::Engine external
draw::select::Engine object_select
draw::overlay::Engine overlay
void foreach_enabled_engine(CallbackT callback)
image_engine::Engine image
draw::gpencil::Engine grease_pencil
draw::edit_select::Engine edit_select
DefaultTextureList dtxl
char info[GPU_INFO_SIZE]
Definition DRW_render.hh:74
virtual void object_sync(draw::ObjectRef &ob_ref, draw::Manager &manager)=0
virtual void init()=0
virtual StringRefNull name_get()=0
virtual bool uses_render_border() const
Definition DRW_render.hh:83
virtual void draw(draw::Manager &manager)=0
virtual void end_sync()=0
virtual void begin_sync()=0
void try_add(draw::ObjectRef &ob_ref)
void extract_all(ExtractionGraph &extraction)
const bke::GeometrySet * preview_base_geometry
void * next
Definition DNA_ID.h:418
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
const c_style_mat & ptr() const
bke::ObjectRuntime * runtime
LightLinking * light_linking
ListBaseT< struct ParticleSystem > particlesystem
eObject_TransFlag transflag
eParticleSystem_Flag flag
struct PointCache * pointcache
eRegionView3D_Flag rflag
eRegionView3D_Persp persp
struct Render * re
Definition RE_engine.h:148
ListBaseT< RenderView > views
ListBaseT< RenderLayer > layers
ListBaseT< ViewLayer > view_layers
struct RenderData r
struct ToolSettings * toolsettings
eSpaceImage_Flag flag
eSpaceNode_Flag flag
struct ParticleEditSettings particle
eView3DShading_Flag flag
eView3D_Flag2 flag2
struct Object * camera
View3DShading shading
View3D_Runtime runtime
eView3D_GizmoFlag gizmo_flag
bool operator==(const InstancesKey &k) const
InstancesKey(Object *object, ID *ob_data, InstancesFlags flags, const bke::GeometrySet *preview_base_geometry, int preview_instance_index)
const bke::GeometrySet * preview_base_geometry
static void set(DRWState state=DRW_STATE_DEFAULT)
static void render_to_image(RenderEngine *engine, RenderLayer *render_layer, const rcti rect)
static void free_static()