diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-25 13:50:32 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-25 13:50:32 +0300 |
commit | e97237892c804a0ea82fe430cf0e1f4d16039dc4 (patch) | |
tree | aea045588506e38ff44a6e04d37a02094a7fddeb /source/blender | |
parent | cdee53edfc4d249ce198965a35cefe32a813854d (diff) | |
parent | 8a7f317666caa41aad0428b5ed3f399cdfbbd816 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/gpu/GPU_draw.h
source/blender/gpu/GPU_material.h
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_material.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_files_link.c
source/blender/windowmanager/intern/wm_init_exit.c
source/creator/creator_args.c
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 8 | ||||
-rw-r--r-- | source/blender/freestyle/intern/system/PythonInterpreter.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 17 | ||||
-rw-r--r-- | source/blender/gpu/GPU_material.h | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 45 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 8 | ||||
-rw-r--r-- | source/blender/nodes/composite/node_composite_tree.c | 5 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_exec.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 12 |
15 files changed, 70 insertions, 57 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 7a6771ae058..002333e5d34 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1433,7 +1433,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) Render *render = engine->re; if (G.background && DST.gl_context == NULL) { - WM_init_opengl(); + WM_init_opengl(G_MAIN); } void *re_gl_context = RE_gl_context_get(render); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index cdb7a3bcce6..4342778a5d1 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1054,6 +1054,7 @@ static int texture_paint_toggle_poll(bContext *C) static int texture_paint_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_TEXTURE_PAINT; @@ -1069,14 +1070,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) ob->mode &= ~mode_flag; if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(1); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 1); toggle_paint_cursor(C, 0); } else { bScreen *sc; - Main *bmain = CTX_data_main(C); Image *ima = NULL; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -1121,8 +1121,8 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) BKE_paint_init(bmain, scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(0); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 0); toggle_paint_cursor(C, 1); } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index a0d0529086f..990d50ae42a 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -542,7 +542,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */ - GPU_materials_free(); + GPU_materials_free(bmain); WM_event_add_notifier(C, NC_WINDOW, NULL); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fd2f604651b..964317f695e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_scene.h" #include "BKE_object.h" #include "BKE_paint.h" @@ -1196,8 +1197,6 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) rcti rect; ED_region_visible_rect(ar, &rect); - /* Leave room for previously drawn info. */ - rect.ymax -= offset; view3d_draw_border(C, ar); view3d_draw_grease_pencil(C); @@ -1271,11 +1270,12 @@ RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype) void view3d_main_region_draw(const bContext *C, ARegion *ar) { + Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); view3d_draw_view(C, ar); - GPU_free_images_old(); + GPU_free_images_old(bmain); GPU_pass_cache_garbage_collect(); /* XXX This is in order to draw UI batches with the DRW @@ -1348,7 +1348,7 @@ void ED_view3d_draw_offscreen( if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) { /* free images which can have changed on frame-change * warning! can be slow so only free animated images - campbell */ - GPU_free_images_anim(); + GPU_free_images_anim(G.main); /* XXX :((( */ } gpuPushProjectionMatrix(); diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 79ba9421cda..4f5e94ef7a0 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -81,7 +81,7 @@ public: bool ok = BPY_execute_filepath(_context, fn, reports); #else bool ok; - Text *text = BKE_text_load(&_freestyle_bmain, fn, G.main->name); + Text *text = BKE_text_load(&_freestyle_bmain, fn, G_MAIN->name); if (text) { ok = BPY_execute_text(_context, text, reports, false); BKE_libblock_delete(&_freestyle_bmain, text); diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 613a07dc869..448945cd7ba 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -39,6 +39,7 @@ extern "C" { struct ImBuf; struct Image; struct ImageUser; +struct Main; struct Object; struct Scene; struct ViewLayer; @@ -68,19 +69,19 @@ void GPU_disable_program_point_size(void); /* Mipmap settings * - these will free textures on changes */ -void GPU_set_mipmap(bool mipmap); +void GPU_set_mipmap(struct Main *bmain, bool mipmap); bool GPU_get_mipmap(void); void GPU_set_linear_mipmap(bool linear); bool GPU_get_linear_mipmap(void); -void GPU_paint_set_mipmap(bool mipmap); +void GPU_paint_set_mipmap(struct Main *bmain, bool mipmap); /* Anisotropic filtering settings * - these will free textures on changes */ -void GPU_set_anisotropic(float value); +void GPU_set_anisotropic(struct Main *bmain, float value); float GPU_get_anisotropic(void); /* enable gpu mipmapping */ -void GPU_set_gpu_mipmapping(int gpu_mipmap); +void GPU_set_gpu_mipmapping(struct Main *bmain, int gpu_mipmap); /* Image updates and free * - these deal with images bound as opengl textures */ @@ -94,16 +95,16 @@ void GPU_create_gl_tex_compressed( int textarget, struct Image *ima, struct ImBuf *ibuf); bool GPU_upload_dxt_texture(struct ImBuf *ibuf); void GPU_free_image(struct Image *ima); -void GPU_free_images(void); -void GPU_free_images_anim(void); -void GPU_free_images_old(void); +void GPU_free_images(struct Main *bmain); +void GPU_free_images_anim(struct Main *bmain); +void GPU_free_images_old(struct Main *bmain); /* smoke drawing functions */ void GPU_free_smoke(struct SmokeModifierData *smd); void GPU_create_smoke(struct SmokeModifierData *smd, int highres); /* Delayed free of OpenGL buffers by main thread */ -void GPU_free_unused_buffers(void); +void GPU_free_unused_buffers(struct Main *bmain); /* utilities */ void GPU_select_index_set(int index); diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 0805cc25d04..a65c09152ee 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -44,6 +44,7 @@ extern "C" { struct Image; struct ImageUser; struct ListBase; +struct Main; struct Material; struct Object; struct Scene; @@ -251,7 +252,7 @@ GPUMaterial *GPU_material_from_nodetree( void GPU_material_compile(GPUMaterial *mat); void GPU_material_free(struct ListBase *gpumaterial); -void GPU_materials_free(void); +void GPU_materials_free(struct Main *bmain); void GPU_material_orphans_init(void); void GPU_material_orphans_exit(void); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 83fd689e3b7..7383868843d 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -140,7 +140,7 @@ static struct GPUTextureState { /* Mipmap settings */ -void GPU_set_gpu_mipmapping(int gpu_mipmap) +void GPU_set_gpu_mipmapping(Main *bmain, int gpu_mipmap) { int old_value = GTS.gpu_mipmap; @@ -148,14 +148,14 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap) GTS.gpu_mipmap = gpu_mipmap; if (old_value != GTS.gpu_mipmap) { - GPU_free_images(); + GPU_free_images(bmain); } } -void GPU_set_mipmap(bool mipmap) +void GPU_set_mipmap(Main *bmain, bool mipmap) { if (GTS.domipmap != mipmap) { - GPU_free_images(); + GPU_free_images(bmain); GTS.domipmap = mipmap; } } @@ -203,10 +203,10 @@ static GLenum gpu_get_mipmap_filter(bool mag) } /* Anisotropic filtering settings */ -void GPU_set_anisotropic(float value) +void GPU_set_anisotropic(Main *bmain, float value) { if (GTS.anisotropic != value) { - GPU_free_images(); + GPU_free_images(bmain); /* Clamp value to the maximum value the graphics card supports */ const float max = GPU_max_texture_anisotropy(); @@ -682,7 +682,7 @@ void GPU_create_gl_tex_compressed( * temporary disabling/enabling mipmapping on all images for quick texture * updates with glTexSubImage2D. images that didn't change don't have to be * re-uploaded to OpenGL */ -void GPU_paint_set_mipmap(bool mipmap) +void GPU_paint_set_mipmap(Main *bmain, bool mipmap) { if (!GTS.domipmap) return; @@ -690,7 +690,7 @@ void GPU_paint_set_mipmap(bool mipmap) GTS.texpaint = !mipmap; if (mipmap) { - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { if (BKE_image_has_opengl_texture(ima)) { if (ima->tpageflag & IMA_MIPMAP_COMPLETE) { if (ima->gputexture[TEXTARGET_TEXTURE_2D]) { @@ -709,7 +709,7 @@ void GPU_paint_set_mipmap(bool mipmap) } else { - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { if (BKE_image_has_opengl_texture(ima)) { if (ima->gputexture[TEXTARGET_TEXTURE_2D]) { GPU_texture_bind(ima->gputexture[TEXTARGET_TEXTURE_2D], 0); @@ -980,7 +980,7 @@ static void gpu_queue_image_for_free(Image *ima) BLI_thread_unlock(LOCK_OPENGL); } -void GPU_free_unused_buffers(void) +void GPU_free_unused_buffers(Main *bmain) { if (!BLI_thread_is_main()) return; @@ -992,7 +992,7 @@ void GPU_free_unused_buffers(void) Image *ima = node->link; /* check in case it was freed in the meantime */ - if (G.main && BLI_findindex(&G.main->image, ima) != -1) + if (bmain && BLI_findindex(&bmain->image, ima) != -1) GPU_free_image(ima); } @@ -1020,24 +1020,29 @@ void GPU_free_image(Image *ima) ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA); } -void GPU_free_images(void) +void GPU_free_images(Main *bmain) { - if (G.main) - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) + if (bmain) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { GPU_free_image(ima); + } + } } /* same as above but only free animated images */ -void GPU_free_images_anim(void) +void GPU_free_images_anim(Main *bmain) { - if (G.main) - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) - if (BKE_image_is_animated(ima)) + if (bmain) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { + if (BKE_image_is_animated(ima)) { GPU_free_image(ima); + } + } + } } -void GPU_free_images_old(void) +void GPU_free_images_old(Main *bmain) { static int lasttime = 0; int ctime = (int)PIL_check_seconds_timer(); @@ -1055,7 +1060,7 @@ void GPU_free_images_old(void) lasttime = ctime; - Image *ima = G.main->image.first; + Image *ima = bmain->image.first; while (ima) { if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) { /* If it's in GL memory, deallocate and set time tag to current time diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 302ddc62188..9c776e64ba0 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -723,16 +723,16 @@ void GPU_material_compile(GPUMaterial *mat) } } -void GPU_materials_free(void) +void GPU_materials_free(Main *bmain) { Material *ma; World *wo; extern Material defmaterial; - for (ma = G.main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) GPU_material_free(&ma->gpumaterial); - for (wo = G.main->world.first; wo; wo = wo->id.next) + for (wo = bmain->world.first; wo; wo = wo->id.next) GPU_material_free(&wo->gpumaterial); GPU_material_free(&defmaterial.gpumaterial); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 4190303beb9..809de3681dd 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -216,25 +216,25 @@ static void rna_userdef_load_ui_update(Main *UNUSED(bmain), Scene *UNUSED(scene) static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_set_anisotropic(U.anisotropic_filter); + GPU_set_anisotropic(bmain, U.anisotropic_filter); rna_userdef_update(bmain, scene, ptr); } static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_set_gpu_mipmapping(U.use_gpu_mipmap); + GPU_set_gpu_mipmapping(bmain, U.use_gpu_mipmap); rna_userdef_update(bmain, scene, ptr); } static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_free_images(); + GPU_free_images(bmain); rna_userdef_update(bmain, scene, ptr); } static void rna_userdef_gl_use_16bit_textures(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_free_images(); + GPU_free_images(bmain); rna_userdef_update(bmain, scene, ptr); } diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 43beb1656a2..4f796da58dc 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -280,7 +280,10 @@ void ntreeCompositTagRender(Scene *curscene) { Scene *sce; - for (sce = G.main->scene.first; sce; sce = sce->id.next) { + /* XXX Think using G_MAIN here is valid, since you want to update current file's scene nodes, + * not the ones in temp main generated for rendering? + * This is still rather weak though, ideally render struct would store own main AND original G_MAIN... */ + for (sce = G_MAIN->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c index 3708a7663ed..09c06e00382 100644 --- a/source/blender/nodes/intern/node_exec.c +++ b/source/blender/nodes/intern/node_exec.c @@ -163,6 +163,8 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo /* XXX texnodes have threading issues with muting, have to disable it there ... */ /* ensure all sock->link pointers and node levels are correct */ + /* Using global main here is likely totally wrong, not sure what to do about that one though... + * We cannot even check ntree is in global main, since most of the time it won't be (thanks to ntree design)!!! */ ntreeUpdateTree(G.main, ntree); /* get a dependency-sorted list of nodes */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a2142b2d569..6b1825edf3e 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -96,7 +96,7 @@ void WM_main (struct bContext *C) ATTR_NORETURN; void WM_init_splash (struct bContext *C); -void WM_init_opengl (void); +void WM_init_opengl (struct Main *bmain); void WM_check (struct bContext *C); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5efe9330f52..a7500a55bda 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -782,6 +782,7 @@ void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(ar)) void wm_draw_update(bContext *C) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; @@ -789,7 +790,7 @@ void wm_draw_update(bContext *C) BKE_subsurf_free_unused_buffers(); #endif - GPU_free_unused_buffers(); + GPU_free_unused_buffers(bmain); for (win = wm->windows.first; win; win = win->next) { #ifdef WIN32 diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index a14cbed6381..cae0bc06691 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -167,7 +167,7 @@ bool wm_start_with_console = false; /* used in creator.c */ **/ static bool opengl_is_init = false; -void WM_init_opengl(void) +void WM_init_opengl(Main *bmain) { /* must be called only once */ BLI_assert(opengl_is_init == false); @@ -181,10 +181,10 @@ void WM_init_opengl(void) DRW_opengl_context_create(); GPU_init(); - GPU_set_mipmap(true); + GPU_set_mipmap(bmain, true); GPU_set_linear_mipmap(true); - GPU_set_anisotropic(U.anisotropic_filter); - GPU_set_gpu_mipmapping(U.use_gpu_mipmap); + GPU_set_anisotropic(bmain, U.anisotropic_filter); + GPU_set_gpu_mipmapping(bmain, U.use_gpu_mipmap); GPU_pass_cache_init(); @@ -250,7 +250,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* sets 3D mouse deadzone */ WM_ndof_deadzone_set(U.ndof_deadzone); #endif - WM_init_opengl(); + WM_init_opengl(G_MAIN); UI_init(); BKE_studiolight_init(); @@ -491,7 +491,7 @@ void WM_exit_ext(bContext *C, const bool do_python) BKE_subsurf_osd_cleanup(); #endif - GPU_free_unused_buffers(); + GPU_free_unused_buffers(G_MAIN); GPU_exit(); } |