From b11a463e4fcd98f2fff6e05a03e97e71b93b8274 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 21 Jun 2021 16:25:53 -0300 Subject: Refactor: Do not keep a copy of depth buffer in RegionView3D The depth cache (located in `RegionView3D::depths`) is used for quick and simple occlusion testing in: - particle selection, - "Draw Curve" operator and - "Interactive Light Track to Cursor" operator, However, keeping a texture buffer in cache is not a recommended practice. For displays with high resolution like 8k this represents something around 132MB. Also, currently, each call to `ED_view3d_depth_override` invalidates the depth cache. So that depth is never reused in multiple calls from an operator (this was not the case in blender 2.79). This commit allows to create a depth cache and release it in the same operator. Thus, the buffer is kept in cache for a short time, freeing up space. No functional changes. --- source/blender/editors/space_view3d/view3d_edit.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'source/blender/editors/space_view3d/view3d_edit.c') diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 8b6d0e9ee04..ab0683644c3 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -953,7 +953,6 @@ static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_depth_tag_update(vod->rv3d); use_autokey = true; ret = OPERATOR_FINISHED; } @@ -1014,7 +1013,6 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event) } viewrotate_apply(vod, event_xy); - ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -1799,7 +1797,6 @@ static int viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_depth_tag_update(vod->rv3d); use_autokey = true; ret = OPERATOR_FINISHED; } @@ -1840,7 +1837,6 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (event->type == MOUSEPAN) { /* invert it, trackpad scroll follows same principle as 2d windows this way */ viewmove_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); - ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -2254,7 +2250,6 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_depth_tag_update(vod->rv3d); use_autokey = true; ret = OPERATOR_FINISHED; } @@ -2341,8 +2336,6 @@ static int viewzoom_exec(bContext *C, wmOperator *op) view3d_boxview_sync(area, region); } - ED_view3d_depth_tag_update(rv3d); - ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, true); @@ -2398,8 +2391,6 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS))); ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); - ED_view3d_depth_tag_update(vod->rv3d); - viewops_data_free(C, op); return OPERATOR_FINISHED; } @@ -2579,7 +2570,6 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_depth_tag_update(vod->rv3d); use_autokey = true; ret = OPERATOR_FINISHED; } @@ -2636,8 +2626,6 @@ static int viewdolly_exec(bContext *C, wmOperator *op) view3d_boxview_sync(area, region); } - ED_view3d_depth_tag_update(rv3d); - ED_view3d_camera_lock_sync(CTX_data_ensure_evaluated_depsgraph(C), v3d, rv3d); ED_region_tag_redraw(region); @@ -2718,7 +2706,6 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) event->prevx; } viewdolly_apply(vod, &event->prevx, (U.uiflag & USER_ZOOM_INVERT) == 0); - ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); return OPERATOR_FINISHED; @@ -3629,13 +3616,13 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) ED_view3d_dist_range_get(v3d, dist_range); ED_view3d_depth_override( - CTX_data_ensure_evaluated_depsgraph(C), region, v3d, NULL, V3D_DEPTH_NO_GPENCIL, false); + CTX_data_ensure_evaluated_depsgraph(C), region, v3d, NULL, V3D_DEPTH_NO_GPENCIL, NULL); { /* avoid allocating the whole depth buffer */ ViewDepths depth_temp = {0}; /* avoid view3d_update_depths() for speed. */ - view3d_update_depths_rect(region, &depth_temp, &rect); + view3d_depths_rect_create(region, &rect, &depth_temp); /* find the closest Z pixel */ depth_close = view3d_depth_near(&depth_temp); @@ -4433,7 +4420,6 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_depth_tag_update(vod->rv3d); use_autokey = true; ret = OPERATOR_FINISHED; } @@ -4541,7 +4527,6 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (event->type == MOUSEROTATE) { vod->init.event_xy[0] = vod->prev.event_xy[0] = event->x; viewroll_apply(vod, event->prevx, event->prevy); - ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); return OPERATOR_FINISHED; @@ -4638,7 +4623,6 @@ static int viewpan_invoke(bContext *C, wmOperator *op, const wmEvent *event) viewmove_apply(vod, vod->prev.event_xy[0] + x, vod->prev.event_xy[1] + y); - ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); return OPERATOR_FINISHED; -- cgit v1.2.3