2.5: Update GPU module to deal with removed G_TEXTUREPAINT
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 16 Aug 2009 20:14:49 +0000 (20:14 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 16 Aug 2009 20:14:49 +0000 (20:14 +0000)
global, passing along enable/disable mipmap setting through
various functions instead.

13 files changed:
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/gpu/GPU_draw.h
source/blender/gpu/GPU_extensions.h
source/blender/gpu/GPU_material.h
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_codegen.h
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_material.c
source/gameengine/Ketsji/BL_BlenderShader.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_PolygonMaterial.cpp

index 565ccb2b9035c8e0401ef13373d0b7bbd578c65f..4ff658b51cf8bf8323d37c5e0629b3baaec7e5fc 100644 (file)
@@ -4023,7 +4023,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s
        if(texpaint || (sima && sima->lock)) {
                int w = imapaintpartial.x2 - imapaintpartial.x1;
                int h = imapaintpartial.y2 - imapaintpartial.y1;
-               GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h);
+               GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, !texpaint);
        }
 }
 
index 78ff84906d204edcb26ef3c21dc191cf3681b9ba..da67bd8707e504916b92423988051f68b7042c54 100644 (file)
@@ -298,9 +298,9 @@ static int set_draw_settings_cached(int clearcache, int textured, MTFace *texfac
 
        if (textured!=c_textured || texface!=c_texface) {
                if (textured ) {
-                       c_badtex= !GPU_set_tpage(texface);
+                       c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT));
                } else {
-                       GPU_set_tpage(0);
+                       GPU_set_tpage(NULL, 0);
                        c_badtex= 0;
                }
                c_textured= textured;
@@ -378,7 +378,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
 static void draw_textured_end()
 {
        /* switch off textures */
-       GPU_set_tpage(0);
+       GPU_set_tpage(NULL, 0);
 
        glShadeModel(GL_FLAT);
        glDisable(GL_CULL_FACE);
index 802f30506f8e1f4f65e275f84257e19e84940d3e..82ff51dc5ce098f8ba900323b8f64d08af359108 100644 (file)
@@ -78,7 +78,7 @@ int GPU_get_material_blend_mode(void);
  *   be drawn using one or the other
  * - passing NULL clears the state again */
 
-int GPU_set_tpage(struct MTFace *tface);
+int GPU_set_tpage(struct MTFace *tface, int mipmap);
 
 /* Lights
  * - returns how many lights were enabled
@@ -105,10 +105,10 @@ void GPU_paint_set_mipmap(int mipmap);
 /* Image updates and free
  * - these deal with images bound as opengl textures */
 
-void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h);
+void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int mipmap);
 void GPU_update_images_framechange(void);
 int GPU_update_image_time(struct Image *ima, double time);
-int GPU_verify_image(struct Image *ima, int tftile, int tfmode, int compare);
+int GPU_verify_image(struct Image *ima, int tftile, int tfmode, int compare, int mipmap);
 void GPU_free_image(struct Image *ima);
 void GPU_free_images(void);
 
index 7218b6b1328961b3e752b4f6fa2e441fca8f02ed..eba585e8838b2144a107eb67f68c868b127e09ae 100644 (file)
@@ -75,7 +75,7 @@ GPUTexture *GPU_texture_create_1D(int w, float *pixels);
 GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels);
 GPUTexture *GPU_texture_create_depth(int w, int h);
 GPUTexture *GPU_texture_from_blender(struct Image *ima,
-       struct ImageUser *iuser, double time);
+       struct ImageUser *iuser, double time, int mipmap);
 void GPU_texture_free(GPUTexture *tex);
 
 void GPU_texture_ref(GPUTexture *tex);
index 49c0dc166c19af25e5d6f681e73b465f7921e554..f7318869fb337f1e36ae8526070982f08640f150 100644 (file)
@@ -124,7 +124,7 @@ void GPU_material_free(struct Material *ma);
 
 void GPU_materials_free();
 
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time);
+void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap);
 void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]);
 void GPU_material_unbind(GPUMaterial *material);
 int GPU_material_bound(GPUMaterial *material);
index 94c1910e3bc4494aabfbedb10b03bd0a0b60924a..c8a2d55368505afa6f88014c0aaa1831ecc41261 100644 (file)
@@ -824,7 +824,7 @@ void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes)
        GPU_shader_unbind(shader);
 }
 
-void GPU_pass_bind(GPUPass *pass, double time)
+void GPU_pass_bind(GPUPass *pass, double time, int mipmap)
 {
        GPUInput *input;
        GPUShader *shader = pass->shader;
@@ -838,7 +838,7 @@ void GPU_pass_bind(GPUPass *pass, double time)
        /* now bind the textures */
        for (input=inputs->first; input; input=input->next) {
                if (input->ima)
-                       input->tex = GPU_texture_from_blender(input->ima, input->iuser, time);
+                       input->tex = GPU_texture_from_blender(input->ima, input->iuser, time, mipmap);
 
                if(input->tex && input->bindtex) {
                        GPU_texture_bind(input->tex, input->texid);
index 53b52f24f160930b0ba722c7f01cf06a2820aff9..f5dd956d176847e0bbbfe28ac61209d103b90e43 100644 (file)
@@ -71,7 +71,7 @@ GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink,
 
 struct GPUShader *GPU_pass_shader(GPUPass *pass);
 
-void GPU_pass_bind(GPUPass *pass, double time);
+void GPU_pass_bind(GPUPass *pass, double time, int mipmap);
 void GPU_pass_update_uniforms(GPUPass *pass);
 void GPU_pass_unbind(GPUPass *pass);
 
index 86b39dd483b979f72b1fa6b3892fc329c803177a..e7846a239056394f793b49868c24e17d92b345a0 100644 (file)
@@ -253,9 +253,7 @@ void GPU_set_linear_mipmap(int linear)
 
 static int gpu_get_mipmap(void)
 {
-       return GTS.domipmap 
-               /* XXX: texturepaint not global!
-                  && (!(G.f & G_TEXTUREPAINT))*/;
+       return GTS.domipmap;
 }
 
 static GLenum gpu_get_mipmap_filter(int mag)
@@ -388,7 +386,7 @@ static void gpu_verify_reflection(Image *ima)
        }
 }
 
-int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare)
+int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare, int mipmap)
 {
        ImBuf *ibuf = NULL;
        unsigned int *bind = NULL;
@@ -513,7 +511,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare)
        }
 
        /* scale if not a power of two */
-       if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) {
+       if (!mipmap && (!is_pow2_limit(rectw) || !is_pow2_limit(recth))) {
                rectw= smaller_pow2_limit(rectw);
                recth= smaller_pow2_limit(recth);
                
@@ -526,7 +524,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare)
        glGenTextures(1, (GLuint *)bind);
        glBindTexture( GL_TEXTURE_2D, *bind);
 
-       if (!gpu_get_mipmap()) {
+       if (!(gpu_get_mipmap() && mipmap)) {
                glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA,  rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
@@ -565,7 +563,7 @@ static void gpu_verify_repeat(Image *ima)
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 }
 
-int GPU_set_tpage(MTFace *tface)
+int GPU_set_tpage(MTFace *tface, int mipmap)
 {
        Image *ima;
        
@@ -581,7 +579,7 @@ int GPU_set_tpage(MTFace *tface)
        gpu_verify_alpha_mode(tface);
        gpu_verify_reflection(ima);
 
-       if(GPU_verify_image(ima, tface->tile, tface->mode, 1)) {
+       if(GPU_verify_image(ima, tface->tile, tface->mode, 1, mipmap)) {
                GTS.curtile= GTS.tile;
                GTS.curima= GTS.ima;
                GTS.curtilemode= GTS.tilemode;
@@ -646,13 +644,13 @@ void GPU_paint_set_mipmap(int mipmap)
        }
 }
 
-void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
+void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
 {
        ImBuf *ibuf;
        
        ibuf = BKE_image_get_ibuf(ima, NULL);
        
-       if (ima->repbind || gpu_get_mipmap() || !ima->bindcode || !ibuf ||
+       if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
                (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) ||
                (w == 0) || (h == 0)) {
                /* these cases require full reload still */
@@ -994,7 +992,7 @@ int GPU_enable_material(int nr, void *attribs)
 
                        gpumat = GPU_material_from_blender(GMS.gscene, mat);
                        GPU_material_vertex_attributes(gpumat, gattribs);
-                       GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0);
+                       GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT));
                        GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col);
                        GMS.gboundmat= mat;
 
index 4984e043031f12cc25c96fac95a36114ae62a50a..467b2c4a7f4e130b705ee739ac383d24ba26281a 100644 (file)
@@ -312,7 +312,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
        return tex;
 }
 
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time)
+GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time, int mipmap)
 {
        GPUTexture *tex;
        GLint w, h, border, lastbindcode, bindcode;
@@ -320,7 +320,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time)
        glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode);
 
        GPU_update_image_time(ima, time);
-       bindcode = GPU_verify_image(ima, 0, 0, 0);
+       bindcode = GPU_verify_image(ima, 0, 0, 0, mipmap);
 
        if(ima->gputexture) {
                ima->gputexture->bindcode = bindcode;
index 067f4d8021de2148ea2a0318022f51cc83877c26..c85e2b5a7f134e551663d2c10bc00b8c46f873ed 100644 (file)
@@ -246,7 +246,7 @@ void GPU_material_free(Material *ma)
        BLI_freelistN(&ma->gpumaterial);
 }
 
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time)
+void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap)
 {
        if(material->pass) {
                LinkData *nlink;
@@ -266,7 +266,7 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
                        }
                }
 
-               GPU_pass_bind(material->pass, time);
+               GPU_pass_bind(material->pass, time, mipmap);
                material->bound = 1;
        }
 }
index a0a61d01bb29a158ac5f06fd4c2dbcf854d45639..109a693ec6d2333bea120fdf32374f0354b3c6d9 100644 (file)
@@ -44,7 +44,7 @@ void BL_BlenderShader::SetProg(bool enable, double time)
 {
        if(VerifyShader()) {
                if(enable)
-                       GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time);
+                       GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1);
                else
                        GPU_material_unbind(mGPUMat);
        }
index e2baf8afab000ababe20ab073b89e2a6babe5cc1..be3d49067610ac71a3035b82982cb1ab24215e51 100644 (file)
@@ -235,7 +235,7 @@ void KX_BlenderMaterial::OnExit()
        }
 
        if( mMaterial->tface ) 
-               GPU_set_tpage(mMaterial->tface);
+               GPU_set_tpage(mMaterial->tface, 1);
 }
 
 
index 0590656eae54e24eb5fa0b0a274dd61f94afefab..5b4322ae4cdb91ddabca1a4c65f122a6f1a9090c 100644 (file)
@@ -148,7 +148,7 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c
        if (GetCachingInfo() != cachingInfo)
        {
                if (!cachingInfo)
-                       GPU_set_tpage(NULL);
+                       GPU_set_tpage(NULL, 0);
 
                cachingInfo = GetCachingInfo();
 
@@ -156,10 +156,10 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c
                {
                        Image *ima = (Image*)m_tface->tpage;
                        GPU_update_image_time(ima, rasty->GetTime());
-                       GPU_set_tpage(m_tface);
+                       GPU_set_tpage(m_tface, 1);
                }
                else
-                       GPU_set_tpage(NULL);
+                       GPU_set_tpage(NULL, 0);
                
                if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE)
                        rasty->SetCullFace(false);
@@ -297,7 +297,7 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setTexture, "setTexture(tface)")
        if (PyArg_ParseTuple(args, "O!:setTexture", &PyCObject_Type, &pytface))
        {
                MTFace *tface = (MTFace*) PyCObject_AsVoidPtr(pytface);
-               GPU_set_tpage(tface);
+               GPU_set_tpage(tface, 1);
                Py_RETURN_NONE;
        }