[Bf-blender-cvs] [8a7f317666c] master: Cleanup: Nuke most of G.main from GPU code.
Bastien Montagne
noreply at git.blender.org
Mon Jun 25 12:33:22 CEST 2018
Commit: 8a7f317666caa41aad0428b5ed3f399cdfbbd816
Author: Bastien Montagne
Date: Mon Jun 25 12:32:48 2018 +0200
Branches: master
https://developer.blender.org/rB8a7f317666caa41aad0428b5ed3f399cdfbbd816
Cleanup: Nuke most of G.main from GPU code.
===================================================================
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/space_outliner/outliner_edit.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/editors/space_view3d/view3d_view.c
M source/blender/gpu/GPU_draw.h
M source/blender/gpu/GPU_material.h
M source/blender/gpu/intern/gpu_draw.c
M source/blender/gpu/intern/gpu_material.c
M source/blender/makesrna/intern/rna_userdef.c
M source/blender/windowmanager/intern/wm_draw.c
M source/blender/windowmanager/intern/wm_files_link.c
M source/blender/windowmanager/intern/wm_init_exit.c
M source/creator/creator_args.c
M source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
M source/gameengine/Ketsji/KX_PythonInit.cpp
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index cee7801a9cb..2ada62b028b 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1024,6 +1024,7 @@ static int texture_paint_toggle_poll(bContext *C)
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;
@@ -1039,14 +1040,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;
@@ -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)
- 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 7d5ff560b28..d547b419d48 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -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 */
- 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 bf92fcfff33..fbf2bd33638 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3021,7 +3021,7 @@ static void view3d_draw_objects(
}
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 */
- GPU_free_images_anim();
+ GPU_free_images_anim(bmain);
}
/* 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 */
- GPU_free_images_anim();
+ GPU_free_images_anim(bmain);
}
/* restore size */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 608580c0a08..0f09d7fefa2 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1319,12 +1319,13 @@ void VIEW3D_OT_localview(wmOperatorType *ot)
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)
- GPU_paint_set_mipmap(1);
+ GPU_paint_set_mipmap(bmain, 1);
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)
{
+ Main *bmain = CTX_data_main(C);
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) {
@@ -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);
- GPU_set_mipmap(!test);
+ GPU_set_mipmap(G_MAIN, !test);
SYS_WriteCommandLineInt(syshandle, "nomipmap", test);
/* File specific settings: */
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 245a10a38c2..82acca722b6 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -113,25 +113,25 @@ void GPU_render_text(
/* 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 */
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,
@@ -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);
-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);
#ifdef WITH_OPENSUBDIV
struct DerivedMesh;
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index e229afd3323..c94d6429f59 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -43,6 +43,7 @@ extern "C" {
struct Image;
struct ImageUser;
+struct Main;
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);
-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(
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 947cd43d27b..022de6c72fe 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -274,7 +274,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;
@@ -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) {
- GPU_free_images();
+ GPU_free_images(bmain);
}
}
@@ -309,10 +309,10 @@ static void gpu_generate_mipmap(GLenum target)
glDisable(target);
}
-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;
}
}
@@ -360,10 +360,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();
@@ -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 */
-void GPU_paint_set_mipmap(bool mipmap)
+void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
{
if (!GTS.domipmap)
return;
@@ -1160,7 +1160,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_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 {
- 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]);
@@ -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);
}
-void GPU_update_images_framechange(void)
+void GPU_update_images_framechange(Main *bmain)
{
- for (Image *im
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list