diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-08-17 00:14:49 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-08-17 00:14:49 +0400 |
commit | 5765b1bfa46b76ba93494d074460a6e0471cc3c9 (patch) | |
tree | 8ed560c0bbcea7af0975bcf9d964d4d9912b6dfa | |
parent | afa0fa5e29de94b093f4eda2f8105faa59ba5573 (diff) |
2.5: Update GPU module to deal with removed G_TEXTUREPAINT
global, passing along enable/disable mipmap setting through
various functions instead.
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 6 | ||||
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_material.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 20 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_BlenderShader.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 8 |
13 files changed, 31 insertions, 33 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 565ccb2b903..4ff658b51cf 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -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); } } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 78ff84906d2..da67bd8707e 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -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); diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 802f30506f8..82ff51dc5ce 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -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); diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 7218b6b1328..eba585e8838 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -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); diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 49c0dc166c1..f7318869fb3 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -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); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 94c1910e3bc..c8a2d553685 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -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); diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h index 53b52f24f16..f5dd956d176 100644 --- a/source/blender/gpu/intern/gpu_codegen.h +++ b/source/blender/gpu/intern/gpu_codegen.h @@ -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); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 86b39dd483b..e7846a23905 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -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; diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 4984e043031..467b2c4a7f4 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -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; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 067f4d8021d..c85e2b5a7f1 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -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; } } diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index a0a61d01bb2..109a693ec6d 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index e2baf8afab0..be3d4906761 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -235,7 +235,7 @@ void KX_BlenderMaterial::OnExit() } if( mMaterial->tface ) - GPU_set_tpage(mMaterial->tface); + GPU_set_tpage(mMaterial->tface, 1); } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 0590656eae5..5b4322ae4cd 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -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; } |