From 7028a11db9ec3d29282739f7ad9a0343711ebc24 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 13 Feb 2018 19:15:34 +0100 Subject: GPU: don't use multisample for entire window, only for offscreen 3D viewport. Now that the new 3D viewport draws to a multisample offscreen buffer, there is no good reason anymore to create an entire multisample window and pay the performance/memory cost for other regions that don't need it. GL_MULTISAMPLE now only gets enabled for offscreen buffers, so we don't need to check for it throughout the UI code anymore. Differential Revision: https://developer.blender.org/D3062 --- .../editors/space_view3d/view3d_draw_legacy.c | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'source/blender/editors/space_view3d/view3d_draw_legacy.c') diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 1c6916d3820..5c3a76aa73b 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -213,11 +213,10 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect) static void backdrawview3d( const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, - wmWindow *win, ARegion *ar, View3D *v3d) + ARegion *ar, View3D *v3d) { RegionView3D *rv3d = ar->regiondata; struct Base *base = view_layer->basact; - int multisample_enabled; BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); @@ -264,14 +263,13 @@ static void backdrawview3d( /* dithering and AA break color coding, so disable */ glDisable(GL_DITHER); - multisample_enabled = glIsEnabled(GL_MULTISAMPLE); - if (multisample_enabled) - glDisable(GL_MULTISAMPLE); - - if (win->multisamples != USER_MULTISAMPLE_NONE) { + if (false) { /* for multisample we use an offscreen FBO. multisample drawing can fail * with color coded selection drawing, and reading back depths from such - * a buffer can also cause a few seconds freeze on OS X / NVidia. */ + * a buffer can also cause a few seconds freeze on OS X / NVidia. + * + * NOTE: code is no longer used now, but offscreen drawing is likely + * what we will always want to do for the new viewport. */ int w = BLI_rcti_size_x(&ar->winrct); int h = BLI_rcti_size_y(&ar->winrct); char error[256]; @@ -327,8 +325,6 @@ static void backdrawview3d( v3d->zbuf = false; glDisable(GL_DEPTH_TEST); glEnable(GL_DITHER); - if (multisample_enabled) - glEnable(GL_MULTISAMPLE); if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); @@ -358,7 +354,7 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h, void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, ViewContext *vc) { if (vc->v3d->flag & V3D_INVALID_BACKBUF) { - backdrawview3d(eval_ctx, vc->scene, vc->view_layer, vc->win, vc->ar, vc->v3d); + backdrawview3d(eval_ctx, vc->scene, vc->view_layer, vc->ar, vc->v3d); } } @@ -2007,11 +2003,6 @@ static void view3d_main_region_draw_objects( do_compositing = GPU_fx_compositor_initialize_passes(rv3d->compositor, &ar->winrct, &ar->drawrct, &fx_settings); } - /* enables anti-aliasing for 3D view drawing */ - if (win->multisamples != USER_MULTISAMPLE_NONE) { - glEnable(GL_MULTISAMPLE); - } - /* main drawing call */ view3d_draw_objects(C, &eval_ctx, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL); @@ -2020,11 +2011,6 @@ static void view3d_main_region_draw_objects( GPU_fx_do_composite_pass(rv3d->compositor, rv3d->winmat, rv3d->is_persp, scene, NULL); } - /* Disable back anti-aliasing */ - if (win->multisamples != USER_MULTISAMPLE_NONE) { - glDisable(GL_MULTISAMPLE); - } - if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */ /* find header and force tag redraw */ ScrArea *sa = CTX_wm_area(C); -- cgit v1.2.3