diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-06 11:55:11 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-13 15:17:32 +0300 |
commit | eec5d3a8a8a26256fbae39d4f1fb01de6a648eea (patch) | |
tree | 892d48df436e59d2895251df1699a5f8b5fe8b58 /source/blender/editors/space_view3d | |
parent | 340bfdef2e424c59e85785c1660db805b3255882 (diff) |
Depsgraph: remove engine type from evaluation context.
This was only used for viewport rendering, where we can just pass the engine
type directly. There is no technical reason why we can't draw the same depsgrpah
with different render engines.
It also led to some weird things like requiring a render engine for snapping
and raycast API functions.
Differential Revision: https://developer.blender.org/D3145
Diffstat (limited to 'source/blender/editors/space_view3d')
5 files changed, 28 insertions, 20 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f63bcb1571d..4a0ee31a2b7 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1957,9 +1957,12 @@ static void view3d_stereo3d_setup_offscreen( } } -void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d) +void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, + Scene *scene, + ViewLayer *view_layer, + RenderEngineType *engine_type, + View3D *v3d) { - RenderEngineType *engine_type = eval_ctx->engine_type; if (engine_type->flag & RE_USE_LEGACY_PIPELINE) { /* shadow buffers, before we setup matrices */ if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype)) { @@ -1987,7 +1990,8 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar) * stuff like shadow buffers */ void ED_view3d_draw_offscreen( - const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + const EvaluationContext *eval_ctx, Scene *scene, + ViewLayer *view_layer, RenderEngineType *engine_type, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[4][4], float winmat[4][4], bool do_bgpic, bool do_sky, bool UNUSED(is_persp), const char *viewname, @@ -2034,7 +2038,6 @@ void ED_view3d_draw_offscreen( Depsgraph *depsgraph = eval_ctx->depsgraph; /* main drawing call */ - RenderEngineType *engine_type = eval_ctx->engine_type; if (engine_type->flag & RE_USE_LEGACY_PIPELINE) { VP_deprecated_view3d_draw_objects(NULL, eval_ctx, scene, v3d, ar, NULL, do_bgpic, true); @@ -2053,7 +2056,7 @@ void ED_view3d_draw_offscreen( } else { DRW_draw_render_loop_offscreen( - depsgraph, eval_ctx->engine_type, ar, v3d, + depsgraph, engine_type, ar, v3d, do_sky, ofs, viewport); } @@ -2077,7 +2080,8 @@ void ED_view3d_draw_offscreen( * (avoids re-creating when doing multiple GL renders). */ ImBuf *ED_view3d_draw_offscreen_imbuf( - const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + const EvaluationContext *eval_ctx, Scene *scene, + ViewLayer *view_layer, RenderEngineType *engine_type, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag, unsigned int draw_flags, int alpha_mode, int samples, const char *viewname, @@ -2112,7 +2116,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( } } - ED_view3d_draw_offscreen_init(eval_ctx, scene, view_layer, v3d); + ED_view3d_draw_offscreen_init(eval_ctx, scene, view_layer, engine_type, v3d); GPU_offscreen_bind(ofs, true); @@ -2154,7 +2158,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( if ((samples && use_full_sample) == 0) { /* Single-pass render, common case */ ED_view3d_draw_offscreen( - eval_ctx, scene, view_layer, v3d, ar, sizex, sizey, NULL, winmat, + eval_ctx, scene, view_layer, engine_type, + v3d, ar, sizex, sizey, NULL, winmat, draw_background, draw_sky, !is_ortho, viewname, &fx_settings, ofs, NULL); @@ -2178,7 +2183,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( /* first sample buffer, also initializes 'rv3d->persmat' */ ED_view3d_draw_offscreen( - eval_ctx, scene, view_layer, v3d, ar, sizex, sizey, NULL, winmat, + eval_ctx, scene, view_layer, engine_type, + v3d, ar, sizex, sizey, NULL, winmat, draw_background, draw_sky, !is_ortho, viewname, &fx_settings, ofs, viewport); GPU_offscreen_read_pixels(ofs, GL_FLOAT, accum_buffer); @@ -2192,7 +2198,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( (jit_ofs[j][1] * 2.0f) / sizey); ED_view3d_draw_offscreen( - eval_ctx, scene, view_layer, v3d, ar, sizex, sizey, NULL, winmat_jitter, + eval_ctx, scene, view_layer, engine_type, + v3d, ar, sizex, sizey, NULL, winmat_jitter, draw_background, draw_sky, !is_ortho, viewname, &fx_settings, ofs, viewport); GPU_offscreen_read_pixels(ofs, GL_FLOAT, rect_temp); @@ -2255,7 +2262,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( * \note used by the sequencer */ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( - const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + const EvaluationContext *eval_ctx, Scene *scene, + ViewLayer *view_layer, RenderEngineType *engine_type, Object *camera, int width, int height, unsigned int flag, unsigned int draw_flags, int drawtype, int alpha_mode, int samples, const char *viewname, @@ -2317,7 +2325,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( invert_m4_m4(rv3d.persinv, rv3d.viewinv); return ED_view3d_draw_offscreen_imbuf( - eval_ctx, scene, view_layer, &v3d, &ar, width, height, flag, + eval_ctx, scene, view_layer, engine_type, + &v3d, &ar, width, height, flag, draw_flags, alpha_mode, samples, viewname, ofs, err_out); } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index f1c251891b0..7272fc6b408 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -1420,9 +1420,12 @@ static void gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Sc mul_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat); invert_m4_m4(rv3d.persinv, rv3d.viewinv); + RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id); + /* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */ ED_view3d_draw_offscreen( - eval_ctx, scene, eval_ctx->view_layer, v3d, &ar, winsize, winsize, viewmat, winmat, + eval_ctx, scene, eval_ctx->view_layer, engine_type, + v3d, &ar, winsize, winsize, viewmat, winmat, false, false, true, NULL, NULL, NULL, NULL); GPU_lamp_shadow_buffer_unbind(shadow->lamp); diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c index e8d540bcc9d..f9955f29774 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c @@ -277,7 +277,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) } else if (state == RULER_STATE_DRAG) { ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), CTX_data_engine_type(C), 0, + CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), 0, ruler_info->ar, CTX_wm_view3d(C)); } else { diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 093425fc3bc..f61aad2806e 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -282,7 +282,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) } else if (state == RULER_STATE_DRAG) { ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), CTX_data_engine_type(C), 0, + CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), 0, ruler_info->ar, CTX_wm_view3d(C)); } else { diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index e65f9abae27..3bf0e579bb3 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -58,8 +58,6 @@ #include "GPU_immediate.h" -#include "RE_engine.h" - #include "DEG_depsgraph.h" #include "view3d_intern.h" /* own include */ @@ -254,7 +252,6 @@ typedef struct WalkInfo { const struct Depsgraph *depsgraph; Scene *scene; ViewLayer *view_layer; - RenderEngineType *engine_type; wmTimer *timer; /* needed for redraws */ @@ -522,7 +519,6 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->depsgraph = CTX_data_depsgraph(C); walk->scene = CTX_data_scene(C); walk->view_layer = CTX_data_view_layer(C); - walk->engine_type = CTX_data_engine_type(C); #ifdef NDOF_WALK_DEBUG puts("\n-- walk begin --"); @@ -611,7 +607,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d->rflag |= RV3D_NAVIGATING; walk->snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), walk->scene, walk->view_layer, walk->engine_type, 0, + CTX_data_main(C), walk->scene, walk->view_layer, 0, walk->ar, walk->v3d); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( |