From 13261304a331b4cff37de477ddf19c915ed64b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 26 Feb 2018 19:41:17 +0100 Subject: DRW: Add new Draw Manager OpenGL Context. This separate context allows two things: - It allows viewports in multi-windows configuration. - F12 render can use this context in a separate thread and do a non-blocking render. The downside is that the context cannot be used while rendering so a request to refresh a viewport will lock the UI. This is something that will be adressed in the future. Under the hood what does that mean: - Not adding more mess with VAOs management in gawain. - Doing depth only draw for operators / selection needs to be done in an offscreen buffer. - The 3D cursor "autodis" operator is still reading the backbuffer so we need to copy the result to it. - All FBOs needed by the drawmanager must to be created/destroyed with its context active. - We cannot use batches created for UI in the DRW context and vice-versa. There is a clear separation of resources that enables the use of safe multi-threading. --- source/blender/editors/space_view3d/view3d_draw.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/editors/space_view3d/view3d_draw.c') diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6e3a0883489..68996cdf906 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2131,11 +2131,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( } const bool own_ofs = (ofs == NULL); + DRW_opengl_context_enable(); if (own_ofs) { /* bind */ ofs = GPU_offscreen_create(sizex, sizey, use_full_sample ? 0 : samples, true, false, err_out); if (ofs == NULL) { + DRW_opengl_context_disable(); return NULL; } } @@ -2267,6 +2269,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( GPU_offscreen_free(ofs); } + DRW_opengl_context_disable(); + if (ibuf->rect_float && ibuf->rect) IMB_rect_from_float(ibuf); -- cgit v1.2.3