Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager.c
| Show First 20 Lines • Show All 1,415 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name View Update | /** \name View Update | ||||
| * \{ */ | * \{ */ | ||||
| void DRW_notify_view_update(const DRWUpdateContext *update_ctx) | void DRW_notify_view_update(const DRWUpdateContext *update_ctx) | ||||
| { | { | ||||
| RenderEngineType *engine_type = update_ctx->engine_type; | RenderEngineType *engine_type = update_ctx->engine_type; | ||||
| ARegion *ar = update_ctx->ar; | ARegion *ar = update_ctx->ar; | ||||
jbakker: !exclude_gpencil_rendering | |||||
| View3D *v3d = update_ctx->v3d; | View3D *v3d = update_ctx->v3d; | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| Depsgraph *depsgraph = update_ctx->depsgraph; | Depsgraph *depsgraph = update_ctx->depsgraph; | ||||
| Scene *scene = update_ctx->scene; | Scene *scene = update_ctx->scene; | ||||
| ViewLayer *view_layer = update_ctx->view_layer; | ViewLayer *view_layer = update_ctx->view_layer; | ||||
| /* Separate update for each stereo view. */ | /* Separate update for each stereo view. */ | ||||
| for (int view = 0; view < 2; view++) { | for (int view = 0; view < 2; view++) { | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | DST.draw_ctx = (DRWContextState){ | ||||
| .depsgraph = depsgraph, | .depsgraph = depsgraph, | ||||
| /* reuse if caller sets */ | /* reuse if caller sets */ | ||||
| .evil_C = DST.draw_ctx.evil_C, | .evil_C = DST.draw_ctx.evil_C, | ||||
| }; | }; | ||||
| drw_context_state_init(); | drw_context_state_init(); | ||||
| drw_viewport_var_init(); | drw_viewport_var_init(); | ||||
| const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; | |||||
| const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | | |||||
| DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | | |||||
| DEG_ITER_OBJECT_FLAG_DUPLI; | |||||
| /* Check if scene needs to perform the populate loop */ | |||||
| const bool internal_engine = (engine_type->flag & RE_INTERNAL) != 0; | |||||
| const bool draw_type_render = v3d->shading.type == OB_RENDER; | |||||
| const bool overlays_on = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0; | |||||
| bool do_populate_loop = internal_engine || overlays_on || !draw_type_render; | |||||
| if (!do_populate_loop && ((object_type_exclude_viewport & (1 << OB_GPENCIL)) == 0) && | |||||
| DEG_id_type_any_exist(depsgraph, ID_GD)) { | |||||
| /* Note: we only want this loop to be performed in exceptional cases, but | |||||
| * due to the current tooling we might have to in order to check wether we | |||||
| * need to draw a GPencil object. */ | |||||
| DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) { | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| do_populate_loop = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| DEG_OBJECT_ITER_END; | |||||
brechtUnsubmitted Done Inline ActionsI don't think we need to do this loop, just always set do_populate_loop = true if there is some grease pencil object in the depsgraph seems enough to avoid the common cases. Looping can be expensive in big scenes so would not want to slow down those cases. brecht: I don't think we need to do this loop, just always set `do_populate_loop = true` if there is… | |||||
| } | |||||
| /* Get list of enabled engines */ | /* Get list of enabled engines */ | ||||
| drw_engines_enable(view_layer, engine_type); | drw_engines_enable(view_layer, engine_type); | ||||
| drw_engines_data_validate(); | drw_engines_data_validate(); | ||||
| /* Update ubos */ | /* Update ubos */ | ||||
| DRW_globals_update(); | DRW_globals_update(); | ||||
| drw_debug_init(); | drw_debug_init(); | ||||
| DRW_hair_init(); | DRW_hair_init(); | ||||
| /* No framebuffer allowed before drawing. */ | /* No framebuffer allowed before drawing. */ | ||||
| BLI_assert(GPU_framebuffer_active_get() == NULL); | BLI_assert(GPU_framebuffer_active_get() == NULL); | ||||
| /* Init engines */ | /* Init engines */ | ||||
| drw_engines_init(); | drw_engines_init(); | ||||
| /* Cache filling */ | /* Cache filling */ | ||||
| { | { | ||||
| PROFILE_START(stime); | PROFILE_START(stime); | ||||
| drw_engines_cache_init(); | drw_engines_cache_init(); | ||||
| drw_engines_world_update(scene); | drw_engines_world_update(scene); | ||||
| /* Only iterate over objects for internal engines or when overlays are enabled */ | /* Only iterate over objects for internal engines or when overlays are enabled */ | ||||
| const bool internal_engine = (engine_type->flag & RE_INTERNAL) != 0; | if (do_populate_loop) { | ||||
| const bool draw_type_render = v3d->shading.type == OB_RENDER; | |||||
| const bool overlays_on = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0; | |||||
| if (internal_engine || overlays_on || !draw_type_render) { | |||||
| const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; | |||||
| const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | | |||||
| DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | | |||||
| DEG_ITER_OBJECT_FLAG_DUPLI; | |||||
| DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) { | DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) { | ||||
| if ((object_type_exclude_viewport & (1 << ob->type)) != 0) { | if ((object_type_exclude_viewport & (1 << ob->type)) != 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) { | if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| DST.dupli_parent = data_.dupli_parent; | DST.dupli_parent = data_.dupli_parent; | ||||
| ▲ Show 20 Lines • Show All 1,638 Lines • Show Last 20 Lines | |||||
!exclude_gpencil_rendering