diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-01-29 17:55:41 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-01-29 18:06:11 +0300 |
commit | c7d75a66163635ec7629eda2d4aa39b9e197ef6a (patch) | |
tree | 0adf3a02e1d6d8762f8e62f81eccca7d4044c32f /source/blender/editors | |
parent | bc94036a76b63254181788ce5814fb946f52a287 (diff) | |
parent | b3fc88554468eb91fac3c2afb9387e599e6db507 (diff) |
Merge branch 'blender-v2.92-release'
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_render.h | 14 | ||||
-rw-r--r-- | source/blender/editors/render/render_update.c | 133 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 12 |
3 files changed, 90 insertions, 69 deletions
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index d580e36d0ce..9cdecc444c8 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -29,15 +29,17 @@ extern "C" { #endif +struct bContext; +struct bScreen; struct DEGEditorUpdateContext; +struct Depsgraph; struct ID; -struct MTex; struct Main; +struct MTex; struct Render; struct Scene; struct ScrArea; -struct bContext; -struct bScreen; +struct wmWindow; struct wmWindowManager; /* render_ops.c */ @@ -53,7 +55,11 @@ void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *screen); /* Callbacks handling data update events coming from depsgraph. */ void ED_render_id_flush_update(const struct DEGEditorUpdateContext *update_ctx, struct ID *id); -void ED_render_scene_update(const struct DEGEditorUpdateContext *update_ctx, int updated); +void ED_render_scene_update(const struct DEGEditorUpdateContext *update_ctx, const bool updated); +void ED_render_view3d_update(struct Depsgraph *depsgraph, + struct wmWindow *window, + struct ScrArea *area, + const bool updated); struct Scene *ED_render_job_get_scene(const struct bContext *C); struct Scene *ED_render_job_get_current_scene(const struct bContext *C); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 0968560678b..499ffac6028 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -61,23 +61,79 @@ #include "ED_view3d.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "WM_api.h" #include "render_intern.h" /* own include */ +#include <stdio.h> + /***************************** Render Engines ********************************/ -void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int updated) +/* Update 3D viewport render or draw engine on changes to the scene or view settings . */ +void ED_render_view3d_update(Depsgraph *depsgraph, + wmWindow *window, + ScrArea *area, + const bool updated) +{ + Main *bmain = DEG_get_bmain(depsgraph); + Scene *scene = DEG_get_input_scene(depsgraph); + ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); + + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + if (region->regiontype != RGN_TYPE_WINDOW) { + continue; + } + + View3D *v3d = area->spacedata.first; + RegionView3D *rv3d = region->regiondata; + RenderEngine *engine = rv3d->render_engine; + + /* call update if the scene changed, or if the render engine + * tagged itself for update (e.g. because it was busy at the + * time of the last update) */ + if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { + /* Create temporary context to execute callback in. */ + bContext *C = CTX_create(); + CTX_data_main_set(C, bmain); + CTX_data_scene_set(C, scene); + CTX_wm_manager_set(C, bmain->wm.first); + CTX_wm_window_set(C, window); + CTX_wm_screen_set(C, WM_window_get_active_screen(window)); + CTX_wm_area_set(C, area); + CTX_wm_region_set(C, region); + + engine->flag &= ~RE_ENGINE_DO_UPDATE; + /* NOTE: Important to pass non-updated depsgraph, This is because this function is called + * from inside dependency graph evaluation. Additionally, if we pass fully evaluated one + * we will lose updates stored in the graph. */ + engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C)); + + CTX_free(C); + } + else { + RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); + if (updated) { + DRW_notify_view_update((&(DRWUpdateContext){ + .bmain = bmain, + .depsgraph = depsgraph, + .scene = scene, + .view_layer = view_layer, + .region = region, + .v3d = v3d, + .engine_type = engine_type, + })); + } + } + } +} + +/* Update all 3D viewport render and draw engines on changes to the scene. + * This is called by the dependency graph when it detects changes. */ +void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, const bool updated) { - /* viewport rendering update on data changes, happens after depsgraph - * updates if there was any change. context is set to the 3d view */ Main *bmain = update_ctx->bmain; - Scene *scene = update_ctx->scene; - ViewLayer *view_layer = update_ctx->view_layer; - bContext *C; - wmWindowManager *wm; - wmWindow *win; static bool recursive_check = false; /* don't do this render engine update if we're updating the scene from @@ -98,66 +154,17 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update recursive_check = true; - C = CTX_create(); - CTX_data_main_set(C, bmain); - CTX_data_scene_set(C, scene); - - CTX_wm_manager_set(C, bmain->wm.first); - wm = bmain->wm.first; - - for (win = wm->windows.first; win; win = win->next) { - bScreen *screen = WM_window_get_active_screen(win); - ScrArea *area; - ARegion *region; - - CTX_wm_window_set(C, win); + wmWindowManager *wm = bmain->wm.first; + LISTBASE_FOREACH (wmWindow *, window, &wm->windows) { + bScreen *screen = WM_window_get_active_screen(window); - for (area = screen->areabase.first; area; area = area->next) { - if (area->spacetype != SPACE_VIEW3D) { - continue; - } - View3D *v3d = area->spacedata.first; - for (region = area->regionbase.first; region; region = region->next) { - if (region->regiontype != RGN_TYPE_WINDOW) { - continue; - } - RegionView3D *rv3d = region->regiondata; - RenderEngine *engine = rv3d->render_engine; - /* call update if the scene changed, or if the render engine - * tagged itself for update (e.g. because it was busy at the - * time of the last update) */ - if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { - - CTX_wm_screen_set(C, screen); - CTX_wm_area_set(C, area); - CTX_wm_region_set(C, region); - - engine->flag &= ~RE_ENGINE_DO_UPDATE; - /* NOTE: Important to pass non-updated depsgraph, This is because this function is called - * from inside dependency graph evaluation. Additionally, if we pass fully evaluated one - * we will lose updates stored in the graph. */ - engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C)); - } - else { - RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); - if (updated) { - DRW_notify_view_update((&(DRWUpdateContext){ - .bmain = bmain, - .depsgraph = update_ctx->depsgraph, - .scene = scene, - .view_layer = view_layer, - .region = region, - .v3d = (View3D *)area->spacedata.first, - .engine_type = engine_type, - })); - } - } + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype == SPACE_VIEW3D) { + ED_render_view3d_update(update_ctx->depsgraph, window, area, updated); } } } - CTX_free(C); - recursive_check = false; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 215166a6158..82cc499c729 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -53,6 +53,7 @@ #include "BKE_screen.h" #include "BKE_workspace.h" +#include "ED_render.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_transform.h" @@ -799,6 +800,7 @@ static void *view3d_main_region_duplicate(void *poin) static void view3d_main_region_listener(const wmRegionListenerParams *params) { + wmWindow *window = params->window; ScrArea *area = params->area; ARegion *region = params->region; wmNotifier *wmn = params->notifier; @@ -1018,11 +1020,17 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params) if (wmn->subtype == NS_VIEW3D_GPU) { rv3d->rflag |= RV3D_GPULIGHT_UPDATE; } -#ifdef WITH_XR_OPENXR else if (wmn->subtype == NS_VIEW3D_SHADING) { +#ifdef WITH_XR_OPENXR ED_view3d_xr_shading_update(G_MAIN->wm.first, v3d, scene); - } #endif + + ViewLayer *view_layer = WM_window_get_active_view_layer(window); + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer); + if (depsgraph) { + ED_render_view3d_update(depsgraph, window, area, true); + } + } ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); } |