diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_surface.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_surface.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/xr/intern/wm_xr_session.c | 30 |
4 files changed, 43 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 3e9bf413c9f..1b6df9fb0db 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -84,6 +84,7 @@ #include "wm.h" #include "wm_event_system.h" #include "wm_event_types.h" +#include "wm_surface.h" #include "wm_window.h" #include "DEG_depsgraph.h" @@ -382,6 +383,8 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file) DEG_make_active(depsgraph); BKE_scene_graph_update_tagged(depsgraph, bmain); } + + wm_surfaces_do_depsgraph(C); } void wm_event_do_refresh_wm_and_depsgraph(bContext *C) diff --git a/source/blender/windowmanager/intern/wm_surface.c b/source/blender/windowmanager/intern/wm_surface.c index 715f72d70cf..72b68788e79 100644 --- a/source/blender/windowmanager/intern/wm_surface.c +++ b/source/blender/windowmanager/intern/wm_surface.c @@ -50,6 +50,18 @@ void wm_surfaces_iter(bContext *C, void (*cb)(bContext *C, wmSurface *)) } } +static void wm_surface_do_depsgraph_fn(bContext *C, wmSurface *surface) +{ + if (surface->do_depsgraph) { + surface->do_depsgraph(C); + } +} + +void wm_surfaces_do_depsgraph(bContext *C) +{ + wm_surfaces_iter(C, wm_surface_do_depsgraph_fn); +} + void wm_surface_clear_drawable(void) { if (g_drawable) { diff --git a/source/blender/windowmanager/wm_surface.h b/source/blender/windowmanager/wm_surface.h index a2483d38154..e924b1e47ad 100644 --- a/source/blender/windowmanager/wm_surface.h +++ b/source/blender/windowmanager/wm_surface.h @@ -39,6 +39,8 @@ typedef struct wmSurface { void *customdata; void (*draw)(struct bContext *); + /* To evaluate the surface's depsgraph. Called as part of the main loop. */ + void (*do_depsgraph)(struct bContext *C); /** Free customdata, not the surface itself (done by wm_surface API) */ void (*free_data)(struct wmSurface *); @@ -56,6 +58,9 @@ void wm_surfaces_free(void); /* Utils */ void wm_surfaces_iter(struct bContext *C, void (*cb)(struct bContext *, wmSurface *)); +/* Evaluation. */ +void wm_surfaces_do_depsgraph(struct bContext *C); + /* Drawing */ void wm_surface_make_drawable(wmSurface *surface); void wm_surface_clear_drawable(void); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index 3fbf923e7a6..24d697d9444 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -30,6 +30,7 @@ #include "BLI_math.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "DNA_camera_types.h" #include "DNA_space_types.h" @@ -243,10 +244,9 @@ wmWindow *wm_xr_session_root_window_or_fallback_get(const wmWindowManager *wm, * It's important that the VR session follows some existing window, otherwise it would need to have * an own depsgraph, which is an expense we should avoid. */ -static void wm_xr_session_scene_and_evaluated_depsgraph_get(Main *bmain, - const wmWindowManager *wm, - Scene **r_scene, - Depsgraph **r_depsgraph) +static void wm_xr_session_scene_and_depsgraph_get(const wmWindowManager *wm, + Scene **r_scene, + Depsgraph **r_depsgraph) { const wmWindow *root_win = wm_xr_session_root_window_or_fallback_get(wm, wm->xr.runtime); @@ -256,7 +256,6 @@ static void wm_xr_session_scene_and_evaluated_depsgraph_get(Main *bmain, Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer); BLI_assert(scene && view_layer && depsgraph); - BKE_scene_graph_evaluated_ensure(depsgraph, bmain); *r_scene = scene; *r_depsgraph = depsgraph; } @@ -1302,7 +1301,6 @@ void wm_xr_session_controller_data_clear(wmXrSessionState *state) static void wm_xr_session_surface_draw(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); - Main *bmain = CTX_data_main(C); wmXrDrawData draw_data; if (!WM_xr_session_is_ready(&wm->xr)) { @@ -1311,7 +1309,10 @@ static void wm_xr_session_surface_draw(bContext *C) Scene *scene; Depsgraph *depsgraph; - wm_xr_session_scene_and_evaluated_depsgraph_get(bmain, wm, &scene, &depsgraph); + wm_xr_session_scene_and_depsgraph_get(wm, &scene, &depsgraph); + /* Might fail when force-redrawing windows with #WM_redraw_windows(), which is done on file + * writing for example. */ + // BLI_assert(DEG_is_fully_evaluated(depsgraph)); wm_xr_session_draw_data_populate(&wm->xr, scene, depsgraph, &draw_data); GHOST_XrSessionDrawViews(wm->xr.runtime->context, &draw_data); @@ -1319,6 +1320,20 @@ static void wm_xr_session_surface_draw(bContext *C) GPU_framebuffer_restore(); } +static void wm_xr_session_do_depsgraph(bContext *C) +{ + wmWindowManager *wm = CTX_wm_manager(C); + + if (!WM_xr_session_is_ready(&wm->xr)) { + return; + } + + Scene *scene; + Depsgraph *depsgraph; + wm_xr_session_scene_and_depsgraph_get(wm, &scene, &depsgraph); + BKE_scene_graph_evaluated_ensure(depsgraph, CTX_data_main(C)); +} + bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data, const GHOST_XrDrawViewInfo *draw_view) { @@ -1427,6 +1442,7 @@ static wmSurface *wm_xr_session_surface_create(void) data->controller_art = MEM_callocN(sizeof(*(data->controller_art)), "XrControllerRegionType"); surface->draw = wm_xr_session_surface_draw; + surface->do_depsgraph = wm_xr_session_do_depsgraph; surface->free_data = wm_xr_session_surface_free_data; surface->activate = DRW_xr_drawing_begin; surface->deactivate = DRW_xr_drawing_end; |