Cleanup: Nuke most of G.main from GPU code.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 25 Jun 2018 10:32:48 +0000 (12:32 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 25 Jun 2018 10:32:48 +0000 (12:32 +0200)
16 files changed:
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_outliner/outliner_edit.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_draw.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

index cee7801a9cbb84ac784a44f719965b355b2d1253..2ada62b028b30d10377ee4e3c80f45a8f42f8b3a 100644 (file)
@@ -1024,6 +1024,7 @@ static int texture_paint_toggle_poll(bContext *C)
 
 static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
 {
 
 static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
 {
+       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;
        Scene *scene = CTX_data_scene(C);
        Object *ob = CTX_data_active_object(C);
        const int mode_flag = OB_MODE_TEXTURE_PAINT;
@@ -1039,14 +1040,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
                ob->mode &= ~mode_flag;
 
                if (U.glreslimit != 0)
                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;
 
                toggle_paint_cursor(C, 0);
        }
        else {
                bScreen *sc;
-               Main *bmain = CTX_data_main(C);
                Image *ima = NULL;
                ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
 
                Image *ima = NULL;
                ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
 
@@ -1089,8 +1089,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)
                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);
        }
 
                toggle_paint_cursor(C, 1);
        }
index 7d5ff560b28b3a27b17c56236f17d940f7ae03d3..d547b419d48e1343b4d234e2d71819d07b519969 100644 (file)
@@ -435,7 +435,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op)
        DAG_scene_relations_rebuild(bmain, scene);
 
        /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
        DAG_scene_relations_rebuild(bmain, scene);
 
        /* 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);
 
 
        WM_event_add_notifier(C, NC_WINDOW, NULL);
 
index bf92fcfff3314b193964ddc2685ad3b5d9f00dcf..fbf2bd33638589338188e58954f1aea44df771c7 100644 (file)
@@ -3021,7 +3021,7 @@ static void view3d_draw_objects(
        }
 
        if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
        }
 
        if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
-               GPU_free_images_old();
+               GPU_free_images_old(bmain);
        }
 }
 
        }
 }
 
@@ -3206,7 +3206,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 */
        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(bmain);
        }
 
        /* setup view matrices before fx or unbinding the offscreen buffers will cause issues */
        }
 
        /* setup view matrices before fx or unbinding the offscreen buffers will cause issues */
@@ -3260,7 +3260,7 @@ void ED_view3d_draw_offscreen(
                }
 
                /* freeing the images again here could be done after the operator runs, leaving for now */
                }
 
                /* freeing the images again here could be done after the operator runs, leaving for now */
-               GPU_free_images_anim();
+               GPU_free_images_anim(bmain);
        }
 
        /* restore size */
        }
 
        /* restore size */
index 608580c0a0828498c15ca799694ae14d0e100b01..0f09d7fefa29673f46fd5f49c5a97c9c39b0de3d 100644 (file)
@@ -1319,12 +1319,13 @@ void VIEW3D_OT_localview(wmOperatorType *ot)
 static ListBase queue_back;
 static void game_engine_save_state(bContext *C, wmWindow *win)
 {
 static ListBase queue_back;
 static void game_engine_save_state(bContext *C, wmWindow *win)
 {
+       Main *bmain = CTX_data_main(C);
        Object *obact = CTX_data_active_object(C);
 
        glPushAttrib(GL_ALL_ATTRIB_BITS);
 
        if (obact && obact->mode & OB_MODE_TEXTURE_PAINT)
        Object *obact = CTX_data_active_object(C);
 
        glPushAttrib(GL_ALL_ATTRIB_BITS);
 
        if (obact && obact->mode & OB_MODE_TEXTURE_PAINT)
-               GPU_paint_set_mipmap(1);
+               GPU_paint_set_mipmap(bmain, 1);
 
        queue_back = win->queue;
 
 
        queue_back = win->queue;
 
@@ -1333,10 +1334,11 @@ static void game_engine_save_state(bContext *C, wmWindow *win)
 
 static void game_engine_restore_state(bContext *C, wmWindow *win)
 {
 
 static void game_engine_restore_state(bContext *C, wmWindow *win)
 {
+       Main *bmain = CTX_data_main(C);
        Object *obact = CTX_data_active_object(C);
 
        if (obact && obact->mode & OB_MODE_TEXTURE_PAINT)
        Object *obact = CTX_data_active_object(C);
 
        if (obact && obact->mode & OB_MODE_TEXTURE_PAINT)
-               GPU_paint_set_mipmap(0);
+               GPU_paint_set_mipmap(bmain, 0);
 
        /* check because closing win can set to NULL */
        if (win) {
 
        /* check because closing win can set to NULL */
        if (win) {
@@ -1358,7 +1360,7 @@ static void game_set_commmandline_options(GameData *gm)
        if ((syshandle = SYS_GetSystem())) {
                /* User defined settings */
                test = (U.gameflags & USER_DISABLE_MIPMAP);
        if ((syshandle = SYS_GetSystem())) {
                /* User defined settings */
                test = (U.gameflags & USER_DISABLE_MIPMAP);
-               GPU_set_mipmap(!test);
+               GPU_set_mipmap(G_MAIN, !test);
                SYS_WriteCommandLineInt(syshandle, "nomipmap", test);
 
                /* File specific settings: */
                SYS_WriteCommandLineInt(syshandle, "nomipmap", test);
 
                /* File specific settings: */
index 245a10a38c2b5fe8680125d678ece924695651d1..82acca722b658ce133bc2cb79ccc0b86e8d4ac2e 100644 (file)
@@ -113,25 +113,25 @@ void GPU_render_text(
 /* Mipmap settings
  * - these will free textures on changes */
 
 /* 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);
 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 */
 
 /* 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 */
 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 */
 
 void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
 
 /* Image updates and free
  * - these deal with images bound as opengl textures */
 
 void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
-void GPU_update_images_framechange(void);
+void GPU_update_images_framechange(struct Main *bmain);
 int GPU_update_image_time(struct Image *ima, double time);
 int GPU_verify_image(
         struct Image *ima, struct ImageUser *iuser,
 int GPU_update_image_time(struct Image *ima, double time);
 int GPU_verify_image(
         struct Image *ima, struct ImageUser *iuser,
@@ -144,16 +144,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);
         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 */
 
 /* 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);
 
 #ifdef WITH_OPENSUBDIV
 struct DerivedMesh;
 
 #ifdef WITH_OPENSUBDIV
 struct DerivedMesh;
index e229afd3323b78b39281dbcb57b4d718b148db6b..c94d6429f5965a35810b27e3d24ce45a04350b04 100644 (file)
@@ -43,6 +43,7 @@ extern "C" {
 
 struct Image;
 struct ImageUser;
 
 struct Image;
 struct ImageUser;
+struct Main;
 struct Material;
 struct Object;
 struct Image;
 struct Material;
 struct Object;
 struct Image;
@@ -224,7 +225,7 @@ GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material *ma,
 GPUMaterial *GPU_material_matcap(struct Scene *scene, struct Material *ma, bool use_opensubdiv);
 void GPU_material_free(struct ListBase *gpumaterial);
 
 GPUMaterial *GPU_material_matcap(struct Scene *scene, struct Material *ma, bool use_opensubdiv);
 void GPU_material_free(struct ListBase *gpumaterial);
 
-void GPU_materials_free(void);
+void GPU_materials_free(struct Main *bmain);
 
 bool GPU_lamp_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
 void GPU_material_bind(
 
 bool GPU_lamp_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
 void GPU_material_bind(
index 947cd43d27b0e846b4494017771a2159d1b6af56..022de6c72fef98bd4ffb5600fab7d6bfe6596c30 100644 (file)
@@ -274,7 +274,7 @@ static struct GPUTextureState {
 
 /* Mipmap settings */
 
 
 /* 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;
 
 {
        int old_value = GTS.gpu_mipmap;
 
@@ -282,7 +282,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap)
        GTS.gpu_mipmap = gpu_mipmap && GLEW_EXT_framebuffer_object;
 
        if (old_value != GTS.gpu_mipmap) {
        GTS.gpu_mipmap = gpu_mipmap && GLEW_EXT_framebuffer_object;
 
        if (old_value != GTS.gpu_mipmap) {
-               GPU_free_images();
+               GPU_free_images(bmain);
        }
 }
 
        }
 }
 
@@ -309,10 +309,10 @@ static void gpu_generate_mipmap(GLenum target)
                glDisable(target);
 }
 
                glDisable(target);
 }
 
-void GPU_set_mipmap(bool mipmap)
+void GPU_set_mipmap(Main *bmain, bool mipmap)
 {
        if (GTS.domipmap != mipmap) {
 {
        if (GTS.domipmap != mipmap) {
-               GPU_free_images();
+               GPU_free_images(bmain);
                GTS.domipmap = mipmap;
        }
 }
                GTS.domipmap = mipmap;
        }
 }
@@ -360,10 +360,10 @@ static GLenum gpu_get_mipmap_filter(bool mag)
 }
 
 /* Anisotropic filtering settings */
 }
 
 /* Anisotropic filtering settings */
-void GPU_set_anisotropic(float value)
+void GPU_set_anisotropic(Main *bmain, float value)
 {
        if (GTS.anisotropic != 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();
 
                /* Clamp value to the maximum value the graphics card supports */
                const float max = GPU_max_texture_anisotropy();
@@ -1152,7 +1152,7 @@ int GPU_set_tpage(MTexPoly *mtexpoly, int mipmap, int alphablend)
  * 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 */
  * 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;
 {
        if (!GTS.domipmap)
                return;
@@ -1160,7 +1160,7 @@ void GPU_paint_set_mipmap(bool mipmap)
        GTS.texpaint = !mipmap;
 
        if (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_bindcode(ima)) {
                                if (ima->tpageflag & IMA_MIPMAP_COMPLETE) {
                                        if (ima->bindcode[TEXTARGET_TEXTURE_2D]) {
                        if (BKE_image_has_bindcode(ima)) {
                                if (ima->tpageflag & IMA_MIPMAP_COMPLETE) {
                                        if (ima->bindcode[TEXTARGET_TEXTURE_2D]) {
@@ -1183,7 +1183,7 @@ void GPU_paint_set_mipmap(bool mipmap)
 
        }
        else {
 
        }
        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_bindcode(ima)) {
                                if (ima->bindcode[TEXTARGET_TEXTURE_2D]) {
                                        glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
                        if (BKE_image_has_bindcode(ima)) {
                                if (ima->bindcode[TEXTARGET_TEXTURE_2D]) {
                                        glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
@@ -1355,9 +1355,9 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
        BKE_image_release_ibuf(ima, ibuf, NULL);
 }
 
        BKE_image_release_ibuf(ima, ibuf, NULL);
 }
 
-void GPU_update_images_framechange(void)
+void GPU_update_images_framechange(Main *bmain)
 {
 {
-       for (Image *ima = G.main->image.first; ima; ima = ima->id.next) {
+       for (Image *ima = bmain->image.first; ima; ima = ima->id.next) {
                if (ima->tpageflag & IMA_TWINANIM) {
                        if (ima->twend >= ima->xrep * ima->yrep)
                                ima->twend = ima->xrep * ima->yrep - 1;
                if (ima->tpageflag & IMA_TWINANIM) {
                        if (ima->twend >= ima->xrep * ima->yrep)
                                ima->twend = ima->xrep * ima->yrep - 1;
@@ -1480,7 +1480,7 @@ static void gpu_queue_image_for_free(Image *ima)
        BLI_thread_unlock(LOCK_OPENGL);
 }
 
        BLI_thread_unlock(LOCK_OPENGL);
 }
 
-void GPU_free_unused_buffers(void)
+void GPU_free_unused_buffers(Main *bmain)
 {
        if (!BLI_thread_is_main())
                return;
 {
        if (!BLI_thread_is_main())
                return;
@@ -1492,7 +1492,7 @@ void GPU_free_unused_buffers(void)
                Image *ima = node->link;
 
                /* check in case it was freed in the meantime */
                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);
        }
 
                        GPU_free_image(ima);
        }
 
@@ -1536,24 +1536,29 @@ void GPU_free_image(Image *ima)
        ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA);
 }
 
        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);
                        GPU_free_image(ima);
+               }
+       }
 }
 
 /* same as above but only free animated images */
 }
 
 /* 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);
                                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();
 {
        static int lasttime = 0;
        int ctime = (int)PIL_check_seconds_timer();
@@ -1571,7 +1576,7 @@ void GPU_free_images_old(void)
 
        lasttime = ctime;
 
 
        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
        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
index 2275537506139e9fa3dbcefd74ddb71c7166c9aa..9db9ed1f5e70820bd5ef02c09ed72c16586de92f 100644 (file)
@@ -2216,22 +2216,22 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, bool use_open
        return mat;
 }
 
        return mat;
 }
 
-void GPU_materials_free(void)
+void GPU_materials_free(Main *bmain)
 {
        Object *ob;
        Material *ma;
        World *wo;
        extern Material defmaterial;
 
 {
        Object *ob;
        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);
 
                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);
 
                GPU_material_free(&wo->gpumaterial);
 
        GPU_material_free(&defmaterial.gpumaterial);
 
-       for (ob = G.main->object.first; ob; ob = ob->id.next)
+       for (ob = bmain->object.first; ob; ob = ob->id.next)
                GPU_lamp_free(ob);
 }
 
                GPU_lamp_free(ob);
 }
 
index c5a74122b3bbd930967cb9396f47ded4c09d1cd7..617d44a8626c941f16852b7693c01fcb3ed4461d 100644 (file)
@@ -212,31 +212,31 @@ static void rna_userdef_load_ui_update(Main *UNUSED(bmain), Scene *UNUSED(scene)
 
 static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
 
 static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
-       GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
+       GPU_set_mipmap(bmain, !(U.gameflags & USER_DISABLE_MIPMAP));
        rna_userdef_update(bmain, scene, ptr);
 }
 
 static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        rna_userdef_update(bmain, scene, ptr);
 }
 
 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)
 {
        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)
 {
        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)
 {
        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);
 }
 
        rna_userdef_update(bmain, scene, ptr);
 }
 
index aa89cd6d1ef1986b36b6174be219e3170ded32ae..0f8c49c082d0fa5320c75f069ad25b8743f31358 100644 (file)
@@ -948,6 +948,7 @@ void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *ar)
 
 void wm_draw_update(bContext *C)
 {
 
 void wm_draw_update(bContext *C)
 {
+       Main *bmain = CTX_data_main(C);
        wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win;
 
        wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win;
 
@@ -955,7 +956,7 @@ void wm_draw_update(bContext *C)
        BKE_subsurf_free_unused_buffers();
 #endif
 
        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
 
        for (win = wm->windows.first; win; win = win->next) {
 #ifdef WIN32
index 5a92a3451176ae5eb4e47fa143a4bbf344a39e69..8e11e548aec9f08fdef7a5570171a8ade9270988 100644 (file)
@@ -455,7 +455,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
        }
 
        /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
        }
 
        /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
-       GPU_materials_free();
+       GPU_materials_free(bmain);
 
        /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
        BLI_strncpy(G.lib, root, FILE_MAX);
 
        /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
        BLI_strncpy(G.lib, root, FILE_MAX);
@@ -751,7 +751,7 @@ static void lib_relocate_do(
        DAG_scene_relations_rebuild(bmain, scene);
 
        /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
        DAG_scene_relations_rebuild(bmain, scene);
 
        /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
-       GPU_materials_free();
+       GPU_materials_free(bmain);
 }
 
 void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
 }
 
 void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
index 38aa18a029e41db9821b2e34292e7de7e6259a33..449a0a91a010c3b87d2e66bfb254654a4d13ba3e 100644 (file)
@@ -207,10 +207,10 @@ void WM_init(bContext *C, int argc, const char **argv)
 
                GPU_init();
 
 
                GPU_init();
 
-               GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
+               GPU_set_mipmap(G_MAIN, !(U.gameflags & USER_DISABLE_MIPMAP));
                GPU_set_linear_mipmap(true);
                GPU_set_linear_mipmap(true);
-               GPU_set_anisotropic(U.anisotropic_filter);
-               GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+               GPU_set_anisotropic(G_MAIN, U.anisotropic_filter);
+               GPU_set_gpu_mipmapping(G_MAIN, U.use_gpu_mipmap);
 
 #ifdef WITH_OPENSUBDIV
                BKE_subsurf_osd_init();
 
 #ifdef WITH_OPENSUBDIV
                BKE_subsurf_osd_init();
@@ -590,7 +590,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
 #endif
 
                GPU_global_buffer_pool_free();
 #endif
 
                GPU_global_buffer_pool_free();
-               GPU_free_unused_buffers();
+               GPU_free_unused_buffers(G_MAIN);
 
                GPU_exit();
        }
 
                GPU_exit();
        }
index 98147e45c4e6a11c5165b3101e9860dd33ab1a93..b78e76f6ba3b27392bc02030fd7e0355afe3ec95 100644 (file)
@@ -1474,11 +1474,11 @@ static int arg_handle_ge_parameters_set(int argc, const char **argv, void *data)
 #endif
                        /* doMipMap */
                        if (STREQ(argv[a], "nomipmap")) {
 #endif
                        /* doMipMap */
                        if (STREQ(argv[a], "nomipmap")) {
-                               GPU_set_mipmap(0); //doMipMap = 0;
+                               GPU_set_mipmap(G_MAIN, 0); //doMipMap = 0;
                        }
                        /* linearMipMap */
                        if (STREQ(argv[a], "linearmipmap")) {
                        }
                        /* linearMipMap */
                        if (STREQ(argv[a], "linearmipmap")) {
-                               GPU_set_mipmap(1);
+                               GPU_set_mipmap(G_MAIN, 1);
                                GPU_set_linear_mipmap(1); //linearMipMap = 1;
                        }
 
                                GPU_set_linear_mipmap(1); //linearMipMap = 1;
                        }
 
index 6c541758cb4f9374472a28e76c4de59f71190afa..42b603f8980ec82d9474fc6fe1cc42e1b3e97788 100644 (file)
@@ -1102,11 +1102,11 @@ int main(
                                                                                                stereoWindow, stereomode, alphaBackground, aasamples);
 
                                                                        if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) {
                                                                                                stereoWindow, stereomode, alphaBackground, aasamples);
 
                                                                        if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) {
-                                                                               GPU_set_mipmap(0);
+                                                                               GPU_set_mipmap(G_MAIN, 0);
                                                                        }
 
                                                                        }
 
-                                                                       GPU_set_anisotropic(U.anisotropic_filter);
-                                                                       GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+                                                                       GPU_set_anisotropic(G_MAIN, U.anisotropic_filter);
+                                                                       GPU_set_gpu_mipmapping(G_MAIN, U.use_gpu_mipmap);
                                                                }
                                                        }
                                                }
                                                                }
                                                        }
                                                }
index 35adbc2d720b6c4fe54239865f602cddcc56d14c..251273cf7a847f3a1b66e6f0ad77b91d4e420a61 100644 (file)
@@ -1185,7 +1185,7 @@ static PyObject *gPySetGLSLMaterialSetting(PyObject *,
 
        /* display lists and GLSL materials need to be remade */
        if (sceneflag != gs->glslflag) {
 
        /* display lists and GLSL materials need to be remade */
        if (sceneflag != gs->glslflag) {
-               GPU_materials_free();
+               GPU_materials_free(G_MAIN);
                if (gp_KetsjiEngine) {
                        KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes();
                        KX_SceneList::iterator it;
                if (gp_KetsjiEngine) {
                        KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes();
                        KX_SceneList::iterator it;
index fa24395a74e78c6a00372d3151063a56fd4318b3..659576df1c3ac0fa36456c39efaf82fb7e40f72c 100644 (file)
@@ -60,6 +60,7 @@
 extern "C"{
        #include "BLF_api.h"
        #include "BKE_DerivedMesh.h"
 extern "C"{
        #include "BLF_api.h"
        #include "BKE_DerivedMesh.h"
+       #include "BKE_global.h"
 }
 
 
 }
 
 
@@ -148,7 +149,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, RAS_STORAGE_TYPE
 RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer()
 {
        // Restore the previous AF value
 RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer()
 {
        // Restore the previous AF value
-       GPU_set_anisotropic(m_prevafvalue);
+       GPU_set_anisotropic(G_MAIN, m_prevafvalue);
 
        if (m_storage)
                delete m_storage;
 
        if (m_storage)
                delete m_storage;
@@ -1158,7 +1159,7 @@ void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)
 
 void RAS_OpenGLRasterizer::SetAnisotropicFiltering(short level)
 {
 
 void RAS_OpenGLRasterizer::SetAnisotropicFiltering(short level)
 {
-       GPU_set_anisotropic((float)level);
+       GPU_set_anisotropic(G_MAIN, (float)level);
 }
 
 short RAS_OpenGLRasterizer::GetAnisotropicFiltering()
 }
 
 short RAS_OpenGLRasterizer::GetAnisotropicFiltering()
@@ -1171,17 +1172,17 @@ void RAS_OpenGLRasterizer::SetMipmapping(MipmapOption val)
        if (val == RAS_IRasterizer::RAS_MIPMAP_LINEAR)
        {
                GPU_set_linear_mipmap(1);
        if (val == RAS_IRasterizer::RAS_MIPMAP_LINEAR)
        {
                GPU_set_linear_mipmap(1);
-               GPU_set_mipmap(1);
+               GPU_set_mipmap(G_MAIN, 1);
        }
        else if (val == RAS_IRasterizer::RAS_MIPMAP_NEAREST)
        {
                GPU_set_linear_mipmap(0);
        }
        else if (val == RAS_IRasterizer::RAS_MIPMAP_NEAREST)
        {
                GPU_set_linear_mipmap(0);
-               GPU_set_mipmap(1);
+               GPU_set_mipmap(G_MAIN, 1);
        }
        else
        {
                GPU_set_linear_mipmap(0);
        }
        else
        {
                GPU_set_linear_mipmap(0);
-               GPU_set_mipmap(0);
+               GPU_set_mipmap(G_MAIN, 0);
        }
 }
 
        }
 }