diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-01 20:35:14 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-01 20:38:05 +0300 |
commit | baca8611e5fe4b3dcd6f5065fb125bc0a9d65934 (patch) | |
tree | bb1230387cd53b15f9621f10c4d0e5e2050b5580 /source/blender/windowmanager | |
parent | 31705201dddebf7e3be5c4533b89f380aad1ede1 (diff) | |
parent | 2930d4fcea405985f2212c5f28c061af7c4849f8 (diff) |
Merge branch 'master' into active-fcurve-keyframeactive-fcurve-keyframe
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/WM_gizmo_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 29 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 20 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 17 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_surface.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 30 | ||||
-rw-r--r-- | source/blender/windowmanager/xr/intern/wm_xr_draw.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/xr/intern/wm_xr_session.c | 13 |
16 files changed, 100 insertions, 95 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index efe600a846a..48f8c9b6fb3 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -329,7 +329,10 @@ typedef struct wmNotifier { #define ND_RENDER_OPTIONS (4 << 16) #define ND_NODES (5 << 16) #define ND_SEQUENCER (6 << 16) +/* Note: If an object was added, removed, merged/joined, ..., it is not enough to notify with + * this. This affects the layer so also send a layer change notifier (e.g. ND_LAYER_CONTENT)! */ #define ND_OB_ACTIVE (7 << 16) +/* See comment on ND_OB_ACTIVE. */ #define ND_OB_SELECT (8 << 16) #define ND_OB_VISIBLE (9 << 16) #define ND_OB_RENDER (10 << 16) @@ -438,7 +441,10 @@ typedef struct wmNotifier { /* subtype 3d view editing */ #define NS_VIEW3D_GPU (16 << 8) -#define NS_VIEW3D_SHADING (16 << 9) +#define NS_VIEW3D_SHADING (17 << 8) + +/* subtype layer editing */ +#define NS_LAYER_COLLECTION (24 << 8) /* action classification */ #define NOTE_ACTION (0x000000FF) @@ -448,7 +454,8 @@ typedef struct wmNotifier { #define NA_REMOVED 4 #define NA_RENAME 5 #define NA_SELECTED 6 -#define NA_PAINTING 7 +#define NA_ACTIVATED 7 +#define NA_PAINTING 8 /* ************** Gesture Manager data ************** */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index bddf54b846f..8e2b5e04e42 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -244,7 +244,7 @@ struct wmGizmo { int drag_part; /** Distance to bias this gizmo above others when picking - * (in worldspace, scaled by the gizmo scale - when used). */ + * (in world-space, scaled by the gizmo scale - when used). */ float select_bias; /** diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index cecd324ff28..479768c3536 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -470,10 +470,10 @@ static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBas } else { if (is_depth) { - GPU_depth_test(true); + GPU_depth_test(GPU_DEPTH_LESS_EQUAL); } else { - GPU_depth_test(false); + GPU_depth_test(GPU_DEPTH_NONE); } is_depth_prev = is_depth; } @@ -492,7 +492,7 @@ static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBas } if (is_depth_prev) { - GPU_depth_test(false); + GPU_depth_test(GPU_DEPTH_NONE); } } @@ -534,10 +534,10 @@ static void gizmo_draw_select_3d_loop(const bContext *C, } else { if (is_depth) { - GPU_depth_test(true); + GPU_depth_test(GPU_DEPTH_LESS_EQUAL); } else { - GPU_depth_test(false); + GPU_depth_test(GPU_DEPTH_NONE); } is_depth_prev = is_depth; } @@ -560,7 +560,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C, } if (is_depth_prev) { - GPU_depth_test(false); + GPU_depth_test(GPU_DEPTH_NONE); } if (is_depth_skip_prev) { GPU_depth_mask(true); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 43c08a2b980..a14ccfa104c 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -66,6 +66,7 @@ #ifdef WITH_PYTHON # include "BPY_extern.h" +# include "BPY_extern_run.h" #endif /* ****************************************************** */ @@ -112,6 +113,12 @@ IDTypeInfo IDType_ID_WM = { .free_data = window_manager_free_data, .make_local = NULL, .foreach_id = window_manager_foreach_id, + .foreach_cache = NULL, + + .blend_write = NULL, + .blend_read_data = NULL, + .blend_read_lib = NULL, + .blend_read_expand = NULL, }; #define MAX_OP_REGISTERED 32 @@ -270,7 +277,7 @@ void WM_keyconfig_reload(bContext *C) { if (CTX_py_init_get(C) && !G.background) { #ifdef WITH_PYTHON - BPY_execute_string(C, (const char *[]){"bpy", NULL}, "bpy.utils.keyconfig_init()"); + BPY_run_string_eval(C, (const char *[]){"bpy", NULL}, "bpy.utils.keyconfig_init()"); #endif } } diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index ec18a401fa4..37ed9f89bc7 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -401,7 +401,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) } /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); for (drag = wm->drags.first; drag; drag = drag->next) { const uchar text_col[] = {255, 255, 255, 255}; int iconsize = UI_DPI_ICON_SIZE; @@ -495,5 +495,5 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) } } } - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index b8cb5432a49..c0de86a599c 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -51,6 +51,7 @@ #include "ED_screen.h" #include "ED_view3d.h" +#include "GPU_batch_presets.h" #include "GPU_context.h" #include "GPU_framebuffer.h" #include "GPU_immediate.h" @@ -307,7 +308,9 @@ static void wm_region_test_xr_do_draw(const wmWindowManager *wm, static bool wm_region_use_viewport_by_type(short space_type, short region_type) { - return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE) && region_type == RGN_TYPE_WINDOW); + return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE) && + region_type == RGN_TYPE_WINDOW) || + ((space_type == SPACE_SEQ) && ELEM(region_type, RGN_TYPE_PREVIEW, RGN_TYPE_WINDOW)); } bool WM_region_use_viewport(ScrArea *area, ARegion *region) @@ -574,9 +577,8 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend) const float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax}; if (blend) { - /* GL_ONE because regions drawn offscreen have premultiplied alpha. */ - GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - GPU_blend(true); + /* Regions drawn offscreen have premultiplied alpha. */ + GPU_blend(GPU_BLEND_ALPHA_PREMULT); } /* setup actual texture */ @@ -596,13 +598,14 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend) GPU_shader_uniform_vector(shader, rect_geo_loc, 4, 1, rectg); GPU_shader_uniform_vector(shader, color_loc, 4, 1, (const float[4]){1, 1, 1, 1}); - GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); + GPUBatch *quad = GPU_batch_preset_quad(); + GPU_batch_set_shader(quad, shader); + GPU_batch_draw(quad); GPU_texture_unbind(texture); if (blend) { - GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } } @@ -720,8 +723,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) wm_draw_region_buffer_create(region, false, false); wm_draw_region_bind(region, 0); - GPU_clear_color(0, 0, 0, 0); - GPU_clear(GPU_COLOR_BIT); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); ED_region_do_draw(C, region); wm_draw_region_unbind(region); @@ -744,7 +746,6 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) * If it becomes a problem we should clear only when window size changes. */ #if 0 GPU_clear_color(0, 0, 0, 0); - GPU_clear(GPU_COLOR_BIT); #endif /* Blit non-overlapping area regions. */ @@ -828,13 +829,11 @@ static void wm_draw_window(bContext *C, wmWindow *win) } else if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) { /* For pageflip we simply draw to both back buffers. */ - GPU_backbuffer_bind(GPU_BACKBUFFER_LEFT); - wm_draw_window_onscreen(C, win, 0); - GPU_backbuffer_bind(GPU_BACKBUFFER_RIGHT); wm_draw_window_onscreen(C, win, 1); - GPU_backbuffer_bind(GPU_BACKBUFFER); + GPU_backbuffer_bind(GPU_BACKBUFFER_LEFT); + wm_draw_window_onscreen(C, win, 0); } else if (ELEM(win->stereo3d_format->display_mode, S3D_DISPLAY_ANAGLYPH, S3D_DISPLAY_INTERLACE)) { /* For anaglyph and interlace, we draw individual regions with @@ -910,7 +909,7 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win) const wmWindowManager *wm = CTX_wm_manager(C); Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true); + struct Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); bScreen *screen = WM_window_get_active_screen(win); ARegion *region; bool do_draw = false; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index bea4faa779a..6f7c074c704 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -350,9 +350,9 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file) * and for until then we have to accept ambiguities when object is shared * across visible view layers and has overrides on it. */ - Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true); + Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); if (is_after_open_file) { - DEG_graph_relations_update(depsgraph, bmain, scene, view_layer); + DEG_graph_relations_update(depsgraph); DEG_graph_on_visible_update(bmain, depsgraph, true); } DEG_make_active(depsgraph); @@ -390,6 +390,9 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) static void wm_event_execute_timers(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); + if (UNLIKELY(wm == NULL)) { + return; + } /* Set the first window as context, so that there is some minimal context. This avoids crashes * when calling code that assumes that there is always a window in the context (which many @@ -402,16 +405,17 @@ static void wm_event_execute_timers(bContext *C) /* called in mainloop */ void wm_event_do_notifiers(bContext *C) { - wmWindowManager *wm = CTX_wm_manager(C); wmNotifier *note, *next; wmWindow *win; + /* Run the timer before assigning 'wm' in the unlikely case a timer loads a file, see T80028. */ + wm_event_execute_timers(C); + + wmWindowManager *wm = CTX_wm_manager(C); if (wm == NULL) { return; } - wm_event_execute_timers(C); - /* disable? - keep for now since its used for window level notifiers. */ #if 1 /* cache & catch WM level notifiers, such as frame change, scene/screen set */ @@ -1363,8 +1367,7 @@ static int wm_operator_invoke(bContext *C, ScrArea *area = CTX_wm_area(C); /* Wrap only in X for header. */ - if (region && - ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER)) { + if (region && RGN_TYPE_IS_HEADER_ANY(region->regiontype)) { wrap = WM_CURSOR_WRAP_X; } @@ -3190,10 +3193,9 @@ void wm_event_do_handlers(bContext *C) wm_event_free_all(win); } else { - Main *bmain = CTX_data_main(C); Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false); + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer); Scene *scene_eval = (depsgraph != NULL) ? DEG_get_evaluated_scene(depsgraph) : NULL; if (scene_eval != NULL) { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ef4f2b4a62a..f53a3d6bf35 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -121,7 +121,8 @@ #include "RE_engine.h" #ifdef WITH_PYTHON -# include "BPY_extern.h" +# include "BPY_extern_python.h" +# include "BPY_extern_run.h" #endif #include "DEG_depsgraph.h" @@ -579,14 +580,14 @@ static void wm_file_read_post(bContext *C, if (use_userdef || reset_app_template) { /* Only run when we have a template path found. */ if (BKE_appdir_app_template_any()) { - BPY_execute_string( + BPY_run_string_eval( C, (const char *[]){"bl_app_template_utils", NULL}, "bl_app_template_utils.reset()"); reset_all = true; } } if (reset_all) { /* sync addons, these may have changed from the defaults */ - BPY_execute_string(C, (const char *[]){"addon_utils", NULL}, "addon_utils.reset_all()"); + BPY_run_string_eval(C, (const char *[]){"addon_utils", NULL}, "addon_utils.reset_all()"); } if (use_data) { BPY_python_reset(C); @@ -923,7 +924,7 @@ void wm_homefile_read(bContext *C, * * Note that this fits into 'wm_file_read_pre' function but gets messy * since we need to know if 'reset_app_template' is true. */ - BPY_execute_string(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()"); + BPY_run_string_eval(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()"); } #endif /* WITH_PYTHON */ } @@ -1575,7 +1576,7 @@ void wm_autosave_location(char *filepath) * Blender installed on D:\ drive, D:\ drive has D:\tmp\ * Now, BLI_exists() will find '/tmp/' exists, but * BLI_make_file_string will create string that has it most likely on C:\ - * through get_default_root(). + * through BLI_windows_get_default_root_dir(). * If there is no C:\tmp autosave fails. */ if (!BLI_exists(BKE_tempdir_base())) { savedir = BKE_appdir_folder_id_create(BLENDER_USER_AUTOSAVE, NULL); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 55233168ab2..b245bbe054d 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -236,7 +236,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) uint shdr_pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.05f); @@ -245,7 +245,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -274,7 +274,7 @@ static void wm_gesture_draw_circle(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); const uint shdr_pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -286,7 +286,7 @@ static void wm_gesture_draw_circle(wmGesture *gt) immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -353,9 +353,7 @@ static void draw_filled_lasso(wmGesture *gt) draw_filled_lasso_px_cb, &lasso_fill_data); - /* Additive Blending */ - GPU_blend(true); - GPU_blend_set_func(GPU_ONE, GPU_ONE); + GPU_blend(GPU_BLEND_ADDITIVE_PREMULT); IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_bind(state.shader); @@ -363,14 +361,13 @@ static void draw_filled_lasso(wmGesture *gt) state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); immDrawPixelsTex( - &state, rect.xmin, rect.ymin, w, h, GL_R8, false, pixel_buf, 1.0f, 1.0f, NULL); + &state, rect.xmin, rect.ymin, w, h, GPU_R8, false, pixel_buf, 1.0f, 1.0f, NULL); GPU_shader_unbind(); MEM_freeN(pixel_buf); - GPU_blend(false); - GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_NONE); } MEM_freeN(mcoords); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 03e84f098c0..b85bf8cb323 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -85,6 +85,7 @@ #ifdef WITH_PYTHON # include "BPY_extern.h" +# include "BPY_extern_python.h" #endif #include "GHOST_C-api.h" @@ -209,7 +210,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, double time) continue; } ViewLayer *view_layer = WM_window_get_active_view_layer(window); - Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false); + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer); if (depsgraph == NULL) { continue; } @@ -349,8 +350,6 @@ void WM_init(bContext *C, int argc, const char **argv) BKE_material_copybuf_clear(); ED_render_clear_mtex_copybuf(); - // GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - wm_history_file_read(); /* allow a path of "", this is what happens when making a new file */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1964813fff9..9b25d660ff6 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2393,7 +2393,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void } GPU_matrix_translate_2f((float)x, (float)y); - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); GPU_line_smooth(true); /* apply zoom if available */ @@ -2472,7 +2472,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f); BLF_draw(fontid, str, strdrawlen); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); GPU_line_smooth(false); } @@ -3151,7 +3151,6 @@ static const EnumPropertyItem redraw_timer_type_items[] = { }; static void redraw_timer_step(bContext *C, - Main *bmain, Scene *scene, struct Depsgraph *depsgraph, wmWindow *win, @@ -3202,7 +3201,7 @@ static void redraw_timer_step(bContext *C, } else if (type == eRTAnimationStep) { scene->r.cfra += (cfra == scene->r.cfra) ? 1 : -1; - BKE_scene_graph_update_for_newframe(depsgraph, bmain); + BKE_scene_graph_update_for_newframe(depsgraph); } else if (type == eRTAnimationPlay) { /* play anim, return on same frame as started with */ @@ -3215,7 +3214,7 @@ static void redraw_timer_step(bContext *C, scene->r.cfra = scene->r.sfra; } - BKE_scene_graph_update_for_newframe(depsgraph, bmain); + BKE_scene_graph_update_for_newframe(depsgraph); redraw_timer_window_swap(C); } } @@ -3231,7 +3230,6 @@ static void redraw_timer_step(bContext *C, static int redraw_timer_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); wmWindow *win = CTX_wm_window(C); ScrArea *area = CTX_wm_area(C); @@ -3256,7 +3254,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) wm_window_make_drawable(wm, win); for (a = 0; a < iter; a++) { - redraw_timer_step(C, bmain, scene, depsgraph, win, area, region, type, cfra); + redraw_timer_step(C, scene, depsgraph, win, area, region, type, cfra); iter_steps += 1; if (time_limit != 0.0) { diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index a0a21fadbbb..86d3f7f35dc 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -310,14 +310,11 @@ static void playanim_toscreen( CLAMP(offs_x, 0.0f, 1.0f); CLAMP(offs_y, 0.0f, 1.0f); - GPU_clear_color(0.1, 0.1, 0.1, 0.0); - GPU_clear(GPU_COLOR_BIT); + GPU_clear_color(0.1f, 0.1f, 0.1f, 0.0f); /* checkerboard for case alpha */ if (ibuf->planes == 32) { - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_ALPHA); imm_draw_box_checker_2d_ex(offs_x, offs_y, @@ -342,7 +339,7 @@ static void playanim_toscreen( ((ps->draw_flip[1] ? -1.0f : 1.0f)) * (ps->zoom / (float)ps->win_y), NULL); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); pupdate_time(); @@ -1315,8 +1312,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y)); } - GPU_clear_color(0.1, 0.1, 0.1, 0.0); - GPU_clear(GPU_COLOR_BIT); + GPU_clear_color(0.1f, 0.1f, 0.1f, 0.0f); int win_x, win_y; playanim_window_get_size(&win_x, &win_y); diff --git a/source/blender/windowmanager/intern/wm_surface.c b/source/blender/windowmanager/intern/wm_surface.c index 12e55790259..e8cb5d9cd7d 100644 --- a/source/blender/windowmanager/intern/wm_surface.c +++ b/source/blender/windowmanager/intern/wm_surface.c @@ -56,8 +56,6 @@ void wm_surface_clear_drawable(void) WM_opengl_context_release(g_drawable->ghost_ctx); GPU_context_active_set(NULL); - BLF_batch_reset(); - gpu_batch_presets_reset(); immDeactivate(); if (g_drawable->deactivate) { @@ -86,7 +84,7 @@ void wm_surface_set_drawable(wmSurface *surface, bool activate) void wm_surface_make_drawable(wmSurface *surface) { - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); if (surface != g_drawable) { wm_surface_clear_drawable(); @@ -97,7 +95,7 @@ void wm_surface_make_drawable(wmSurface *surface) void wm_surface_reset_drawable(void) { BLI_assert(BLI_thread_is_main()); - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); if (g_drawable) { wm_surface_clear_drawable(); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 47afa343394..0e19f79e659 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -646,11 +646,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, } #endif /* until screens get drawn, make it nice gray */ - GPU_clear_color(0.55, 0.55, 0.55, 1.0f); - /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ - if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { - GPU_clear(GPU_COLOR_BIT); - } + GPU_clear_color(0.55f, 0.55f, 0.55f, 1.0f); /* needed here, because it's used before it reads userdef */ WM_window_set_dpi(win); @@ -658,9 +654,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, wm_window_swap_buffers(win); // GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); - - /* standard state vars for window */ - GPU_state_init(); } else { wm_window_set_drawable(wm, prev_windrawable, false); @@ -1112,8 +1105,6 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti void wm_window_clear_drawable(wmWindowManager *wm) { if (wm->windrawable) { - BLF_batch_reset(); - gpu_batch_presets_reset(); immDeactivate(); wm->windrawable = NULL; } @@ -1121,7 +1112,7 @@ void wm_window_clear_drawable(wmWindowManager *wm) void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) { - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); if (win != wm->windrawable && win->ghostwin) { // win->lmbut = 0; /* keeps hanging when mousepressed while other window opened */ @@ -1142,7 +1133,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) void wm_window_reset_drawable(void) { BLI_assert(BLI_thread_is_main()); - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); wmWindowManager *wm = G_MAIN->wm.first; if (wm == NULL) { @@ -2493,25 +2484,30 @@ void *WM_opengl_context_create(void) * So we should call this function only on the main thread. */ BLI_assert(BLI_thread_is_main()); - BLI_assert(GPU_framebuffer_active_get() == NULL); - return GHOST_CreateOpenGLContext(g_system); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); + + GHOST_GLSettings glSettings = {0}; + if (G.debug & G_DEBUG_GPU) { + glSettings.flags |= GHOST_glDebugContext; + } + return GHOST_CreateOpenGLContext(g_system, glSettings); } void WM_opengl_context_dispose(void *context) { - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); GHOST_DisposeOpenGLContext(g_system, (GHOST_ContextHandle)context); } void WM_opengl_context_activate(void *context) { - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); GHOST_ActivateOpenGLContext((GHOST_ContextHandle)context); } void WM_opengl_context_release(void *context) { - BLI_assert(GPU_framebuffer_active_get() == NULL); + BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); GHOST_ReleaseOpenGLContext((GHOST_ContextHandle)context); } diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.c b/source/blender/windowmanager/xr/intern/wm_xr_draw.c index 6f96d2ea6a0..5630d294e8d 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_draw.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.c @@ -126,7 +126,7 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata) /* In case a framebuffer is still bound from drawing the last eye. */ GPU_framebuffer_restore(); /* Some systems have drawing glitches without this. */ - GPU_clear(GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); /* Draws the view into the surface_data->viewport's framebuffers */ ED_view3d_draw_offscreen_simple(draw_data->depsgraph, diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index f3ce7be993f..b9ef40e3398 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -195,7 +195,7 @@ static void wm_xr_session_scene_and_evaluated_depsgraph_get(Main *bmain, Scene *scene = WM_window_get_active_scene(root_win); ViewLayer *view_layer = WM_window_get_active_view_layer(root_win); - Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false); + 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; @@ -250,9 +250,14 @@ void wm_xr_session_draw_data_update(const wmXrSessionState *state, switch (event) { case SESSION_STATE_EVENT_START: - /* We want to start the session exactly at landmark position. - * Run-times may have a non-[0,0,0] starting position that we have to subtract for that. */ - copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position); + if (use_position_tracking) { + /* We want to start the session exactly at landmark position. + * Run-times may have a non-[0,0,0] starting position that we have to subtract for that. */ + copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position); + } + else { + copy_v3_fl(draw_data->eye_position_ofs, 0.0f); + } break; /* This should be triggered by the VR add-on if a landmark changes. */ case SESSION_STATE_EVENT_RESET_TO_BASE_POSE: |