Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-02-26 21:41:17 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-02-26 21:41:17 +0300
commit13261304a331b4cff37de477ddf19c915ed64b2c (patch)
tree3660f94436af2e4d44d8310247280ab456243543 /source/blender/editors/render
parent0940e89e604d85d717f792b73e30e5e96a42e7c6 (diff)
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.
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/render_internal.c9
-rw-r--r--source/blender/editors/render/render_opengl.c8
2 files changed, 8 insertions, 9 deletions
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 0130b93babf..98d37eedb1b 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -869,15 +869,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
return OPERATOR_CANCELLED;
}
- /* XXX FIXME If engine is an OpenGL engine do not run modal.
- * This is a problem for animation rendering since you cannot abort them.
- * This also does not open an image editor space. */
- if (RE_engine_is_opengl(re_type)) {
- /* ensure at least 1 area shows result */
- render_view_open(C, event->x, event->y, op->reports);
- return screen_render_exec(C, op);
- }
-
/* only one render job at a time */
if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER))
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 8eb9283790b..1f9894b3b9f 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -57,6 +57,8 @@
#include "DEG_depsgraph.h"
+#include "DRW_engine.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -323,6 +325,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
unsigned char *gp_rect;
unsigned char *render_rect = (unsigned char *)RE_RenderViewGetById(rr, oglrender->view_id)->rect32;
+ DRW_opengl_context_enable();
GPU_offscreen_bind(oglrender->ofs, true);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -342,6 +345,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
blend_color_mix_byte(&render_rect[i], &render_rect[i], &gp_rect[i]);
}
GPU_offscreen_unbind(oglrender->ofs, true);
+ DRW_opengl_context_disable();
MEM_freeN(gp_rect);
}
@@ -652,7 +656,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
sizey = (scene->r.size * scene->r.ysch) / 100;
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
+ DRW_opengl_context_enable(); /* Offscreen creation needs to be done in DRW context. */
ofs = GPU_offscreen_create(sizex, sizey, full_samples ? 0 : samples, true, true, err_out);
+ DRW_opengl_context_disable();
if (!ofs) {
BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer, %s", err_out);
@@ -841,7 +847,9 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
if (oglrender->fx)
GPU_fx_compositor_destroy(oglrender->fx);
+ DRW_opengl_context_enable();
GPU_offscreen_free(oglrender->ofs);
+ DRW_opengl_context_disable();
if (oglrender->is_sequencer) {
MEM_freeN(oglrender->seq_data.ibufs_arr);