Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/engine.cc
| Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void engine_depsgraph_free(RenderEngine *engine) | static void engine_depsgraph_free(RenderEngine *engine) | ||||
| { | { | ||||
| if (engine->depsgraph) { | if (engine->depsgraph) { | ||||
| /* Need GPU context since this might free GPU buffers. */ | /* Need GPU context since this might free GPU buffers. */ | ||||
| const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT); | const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT); | ||||
| if (use_gpu_context) { | if (use_gpu_context) { | ||||
| GPU_render_begin(); | |||||
| DRW_render_context_enable(engine->re); | DRW_render_context_enable(engine->re); | ||||
| } | } | ||||
| DEG_graph_free(engine->depsgraph); | DEG_graph_free(engine->depsgraph); | ||||
| engine->depsgraph = nullptr; | engine->depsgraph = nullptr; | ||||
| if (use_gpu_context) { | if (use_gpu_context) { | ||||
| DRW_render_context_disable(engine->re); | DRW_render_context_disable(engine->re); | ||||
| GPU_render_end(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void RE_engine_free(RenderEngine *engine) | void RE_engine_free(RenderEngine *engine) | ||||
| { | { | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| if (engine->py_instance) { | if (engine->py_instance) { | ||||
| ▲ Show 20 Lines • Show All 580 Lines • ▼ Show 20 Lines | static void engine_depsgraph_init(RenderEngine *engine, ViewLayer *view_layer) | ||||
| if (engine->re->r.scemode & R_BUTS_PREVIEW) { | if (engine->re->r.scemode & R_BUTS_PREVIEW) { | ||||
| /* Update for preview render. */ | /* Update for preview render. */ | ||||
| Depsgraph *depsgraph = engine->depsgraph; | Depsgraph *depsgraph = engine->depsgraph; | ||||
| DEG_graph_relations_update(depsgraph); | DEG_graph_relations_update(depsgraph); | ||||
| /* Need GPU context since this might free GPU buffers. */ | /* Need GPU context since this might free GPU buffers. */ | ||||
| const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT) && reuse_depsgraph; | const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT) && reuse_depsgraph; | ||||
| if (use_gpu_context) { | if (use_gpu_context) { | ||||
| GPU_render_begin(); | |||||
| DRW_render_context_enable(engine->re); | DRW_render_context_enable(engine->re); | ||||
| } | } | ||||
| DEG_evaluate_on_framechange(depsgraph, BKE_scene_frame_get(scene)); | DEG_evaluate_on_framechange(depsgraph, BKE_scene_frame_get(scene)); | ||||
| if (use_gpu_context) { | if (use_gpu_context) { | ||||
| DRW_render_context_disable(engine->re); | DRW_render_context_disable(engine->re); | ||||
| GPU_render_end(); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Go through update with full Python callbacks for regular render. */ | /* Go through update with full Python callbacks for regular render. */ | ||||
| BKE_scene_graph_update_for_newframe_ex(engine->depsgraph, false); | BKE_scene_graph_update_for_newframe_ex(engine->depsgraph, false); | ||||
| } | } | ||||
| engine->has_grease_pencil = DRW_render_check_grease_pencil(engine->depsgraph); | engine->has_grease_pencil = DRW_render_check_grease_pencil(engine->depsgraph); | ||||
| ▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | static void engine_render_view_layer(Render *re, | ||||
| if (re->draw_lock) { | if (re->draw_lock) { | ||||
| re->draw_lock(re->dlh, false); | re->draw_lock(re->dlh, false); | ||||
| } | } | ||||
| /* Perform render with engine. */ | /* Perform render with engine. */ | ||||
| if (use_engine) { | if (use_engine) { | ||||
| const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT); | const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT); | ||||
| if (use_gpu_context) { | if (use_gpu_context) { | ||||
| GPU_render_begin(); | |||||
| DRW_render_context_enable(engine->re); | DRW_render_context_enable(engine->re); | ||||
| } | } | ||||
| BLI_mutex_lock(&engine->re->engine_draw_mutex); | BLI_mutex_lock(&engine->re->engine_draw_mutex); | ||||
| re->engine->flag |= RE_ENGINE_CAN_DRAW; | re->engine->flag |= RE_ENGINE_CAN_DRAW; | ||||
| BLI_mutex_unlock(&engine->re->engine_draw_mutex); | BLI_mutex_unlock(&engine->re->engine_draw_mutex); | ||||
| engine->type->render(engine, engine->depsgraph); | engine->type->render(engine, engine->depsgraph); | ||||
| BLI_mutex_lock(&engine->re->engine_draw_mutex); | BLI_mutex_lock(&engine->re->engine_draw_mutex); | ||||
| re->engine->flag &= ~RE_ENGINE_CAN_DRAW; | re->engine->flag &= ~RE_ENGINE_CAN_DRAW; | ||||
| BLI_mutex_unlock(&engine->re->engine_draw_mutex); | BLI_mutex_unlock(&engine->re->engine_draw_mutex); | ||||
| if (use_gpu_context) { | if (use_gpu_context) { | ||||
| DRW_render_context_disable(engine->re); | DRW_render_context_disable(engine->re); | ||||
| GPU_render_end(); | |||||
| } | } | ||||
| } | } | ||||
| /* Optionally composite grease pencil over render result. | /* Optionally composite grease pencil over render result. | ||||
| * Only do it if the passes are allocated (and the engine will not override the grease pencil | * Only do it if the passes are allocated (and the engine will not override the grease pencil | ||||
| * when reading its result from EXR file and writing to the Blender side. */ | * when reading its result from EXR file and writing to the Blender side. */ | ||||
| if (engine->has_grease_pencil && use_grease_pencil && re->result->passes_allocated) { | if (engine->has_grease_pencil && use_grease_pencil && re->result->passes_allocated) { | ||||
| /* NOTE: External engine might have been requested to free its | /* NOTE: External engine might have been requested to free its | ||||
| ▲ Show 20 Lines • Show All 378 Lines • Show Last 20 Lines | |||||