diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-27 11:22:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-27 13:14:14 +0300 |
commit | e01cadd657c76267266546781703df107c55f83a (patch) | |
tree | af6685123707af7cce17c74d681dcce378d4bc72 /source/blender/editors/screen/area.c | |
parent | 868c9ac408f75634c75bf4bc0b17c87b79d7af73 (diff) |
WM: new offscreen window draw method to replace all existing methods.
For Blender 2.8 we had to be compatible with very old OpenGL versions, and
triple buffer was designed to work without offscreen rendering, by copying
the the backbuffer to a texture right before swapping. This way we could
avoid redrawing unchanged regions by copying them from this texture on the
next redraws. Triple buffer used to suffer from poor performance and driver
bugs on specific cards, so alternative draw methods remained available.
Now that we require newer OpenGL, we can have just a single draw method
that draw each region into an offscreen buffer, and then draws those to
the screen. This has some advantages:
* Poor 3D view performance when using Region Overlap should be solved now,
since we can also cache overlapping regions in offscreen buffers.
* Page flip, anaglyph and interlace stereo drawing can be a little faster
by avoiding a copy to an intermediate texture.
* The new 3D view drawing already writes to an offscreen buffer, which we
can draw from directly instead of duplicating it to another buffer.
* Eventually we will be able to remove depth and stencil buffers from the
window and save memory, though at the moment there are still some tools
using it so it's not possible yet.
* This also fixes a bug with Eevee sampling not progressing with stereo
drawing in the 3D viewport.
Differential Revision: https://developer.blender.org/D3061
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 0f9378d0a41..a17f7ec6255 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1075,18 +1075,16 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar) } /* overlapping regions only in the following restricted cases */ -static bool region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar) +static bool region_is_overlap(ScrArea *sa, ARegion *ar) { if (U.uiflag2 & USER_REGION_OVERLAP) { - if (WM_is_draw_triple(win)) { - if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_SEQ)) { - if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS)) - return 1; - } - else if (sa->spacetype == SPACE_IMAGE) { - if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS, RGN_TYPE_PREVIEW)) - return 1; - } + if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_SEQ)) { + if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS)) + return 1; + } + else if (sa->spacetype == SPACE_IMAGE) { + if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS, RGN_TYPE_PREVIEW)) + return 1; } } @@ -1113,7 +1111,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti alignment = ar->alignment & ~RGN_SPLIT_PREV; /* set here, assuming userpref switching forces to call this again */ - ar->overlap = region_is_overlap(win, sa, ar); + ar->overlap = region_is_overlap(sa, ar); /* clear state flags first */ ar->flag &= ~RGN_FLAG_TOO_SMALL; @@ -2062,14 +2060,11 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c if (ar->overlap) { /* view should be in pixelspace */ UI_view2d_view_restore(C); - glEnable(GL_BLEND); - Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformThemeColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); - immRecti(pos, 0, 0, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct) + 1); - immUnbindProgram(); - glDisable(GL_BLEND); + + float back[4]; + UI_GetThemeColor4fv((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK, back); + glClearColor(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]); + glClear(GL_COLOR_BUFFER_BIT); } else { UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); @@ -2278,7 +2273,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float /* setup scissor */ glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, + glScissor(rect.xmin, rect.ymin, BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1); glEnable(GL_BLEND); |