Draw manager: Make evaluation context a part of context state

This way we don't have to re-initialize the full evaluation
context in every area we need it.
This commit is contained in:
2018-03-29 12:18:07 +02:00
parent 3177023104
commit 0cbf747ffa
4 changed files with 19 additions and 18 deletions

View File

@@ -59,7 +59,6 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
float time,
float r_mat[4][4])
{
EvaluationContext eval_ctx;
float obmat[4][4];
/* HACK */
@@ -68,19 +67,9 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
memcpy(&camdata_cpy, camera->data, sizeof(camdata_cpy));
cam_cpy.data = &camdata_cpy;
/* NOTE: Mode corresponds to old usage of eval_ctx from viewport (which was
* actually coming from bmain). It was always DAG_EVAL_VIEWPORT. For F12
* render this should be DAG_EVAL_RENDER, but the whole hack is to be
* reconsidered first anyway.
*/
const DRWContextState *draw_ctx = DRW_context_state_get();
DEG_evaluation_context_init_from_scene(
&eval_ctx,
scene,
draw_ctx->view_layer,
draw_ctx->engine_type,
draw_ctx->object_mode,
DAG_EVAL_VIEWPORT);
/* We will be modifying time, so we create copy of eval_ctx. */
EvaluationContext eval_ctx = draw_ctx->eval_ctx;
eval_ctx.ctime = time;
/* Past matrix */

View File

@@ -57,6 +57,8 @@
#include "RE_engine.h"
#include "DEG_depsgraph.h"
struct rcti;
struct bContext;
struct GPUFrameBuffer;
@@ -504,6 +506,7 @@ typedef struct DRWContextState {
struct RenderEngineType *engine_type;
EvaluationContext eval_ctx;
struct Depsgraph *depsgraph;
eObjectMode object_mode;

View File

@@ -346,6 +346,17 @@ static void drw_viewport_cache_resize(void)
DRW_instance_data_list_resize(DST.idatalist);
}
static void drw_state_eval_ctx_init(DRWManager *dst)
{
DRWContextState *draw_ctx = &dst->draw_ctx;
DEG_evaluation_context_init_from_scene(
&draw_ctx->eval_ctx,
draw_ctx->scene,
draw_ctx->view_layer,
draw_ctx->engine_type,
draw_ctx->object_mode,
DST.options.is_scene_render ? DAG_EVAL_RENDER : DAG_EVAL_VIEWPORT);
}
/* Not a viewport variable, we could split this out. */
static void drw_context_state_init(void)
@@ -368,6 +379,8 @@ static void drw_context_state_init(void)
else {
DST.draw_ctx.object_pose = NULL;
}
drw_state_eval_ctx_init(&DST);
}
/* It also stores viewport variable to an immutable place: DST

View File

@@ -193,12 +193,8 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
if (ob->type == OB_MESH) {
const DRWContextState *draw_ctx = DRW_context_state_get();
EvaluationContext eval_ctx;
CTX_data_eval_ctx(draw_ctx->evil_C, &eval_ctx);
if (ob->sculpt && (ob == draw_ctx->obact)) {
/* XXX, needed for dyntopo-undo (which clears).
* probably depsgraph should handlle? in 2.7x getting derived-mesh does this (mesh_build_data) */
if (ob->sculpt->pbvh == NULL) {
@@ -206,7 +202,7 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
* but this avoids waiting on first stroke) */
Scene *scene = draw_ctx->scene;
BKE_sculpt_update_mesh_elements(&eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
BKE_sculpt_update_mesh_elements(&draw_ctx->eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
}
PBVH *pbvh = ob->sculpt->pbvh;