Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-06-25 13:32:48 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-06-25 13:32:48 +0300
commit8a7f317666caa41aad0428b5ed3f399cdfbbd816 (patch)
tree7e6ba6c6a1ab952cc175d4e08b39aebc2286cb4a /source/blender/gpu
parentf33cb522dd5793c685dcd681f7c7e13ff60f920a (diff)
Cleanup: Nuke most of G.main from GPU code.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_draw.h18
-rw-r--r--source/blender/gpu/GPU_material.h3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c49
-rw-r--r--source/blender/gpu/intern/gpu_material.c8
4 files changed, 42 insertions, 36 deletions
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 *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;
@@ -1480,7 +1480,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;
@@ -1492,7 +1492,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);
}
@@ -1536,24 +1536,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();
@@ -1571,7 +1576,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 22755375061..9db9ed1f5e7 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -2216,22 +2216,22 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, bool use_open
return mat;
}
-void GPU_materials_free(void)
+void GPU_materials_free(Main *bmain)
{
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);
- 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);
- 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);
}