diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index 375a0b17bb..bced5ccc61 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -3980,35 +3980,38 @@ apply_texture(TextureContext *tc) { int dirty = dtc->get_dirty_flags(); - if( _pCurTexContext == dtc && dirty == 0) { - return; // tex already set (and possible problem in state-sorting?) - } + if (dirty) { + // If the texture image has changed, or if its use of mipmaps has + // changed, we need to re-create the image. Ignore other types of + // changes, which arent significant for dx - // If the texture image has changed, or if its use of mipmaps has - // changed, we need to re-create the image. - if ((dirty & (Texture::DF_image | Texture::DF_mipmap)) != 0) { - // If this is *only* because of a mipmap change, issue a - // warning--it is likely that this change is the result of an - // error or oversight. - if ((dirty & Texture::DF_image) == 0) { - dxgsg_cat.warning() - << "Texture " << *dtc->_texture << " has changed mipmap state.\n"; - } - - dtc->DeleteTexture(); - if (dtc->CreateTexture(_d3dDevice,_cNumTexPixFmts,_pTexPixFmts) == NULL) { - // Oops, we can't re-create the texture for some reason. - dxgsg_cat.error() - << "Unable to re-create texture " << *dtc->_texture << endl; - - release_texture(dtc); - enable_texturing(false); - return; + if((dirty & (Texture::DF_image | Texture::DF_mipmap)) != 0) { + // If this is *only* because of a mipmap change, issue a + // warning--it is likely that this change is the result of an + // error or oversight. + if ((dirty & Texture::DF_image) == 0) { + dxgsg_cat.warning() + << "Texture " << *dtc->_texture << " has changed mipmap state.\n"; + } + + dtc->DeleteTexture(); + if (dtc->CreateTexture(_d3dDevice,_cNumTexPixFmts,_pTexPixFmts) == NULL) { + // Oops, we can't re-create the texture for some reason. + dxgsg_cat.error() + << "Unable to re-create texture " << *dtc->_texture << endl; + + release_texture(dtc); + enable_texturing(false); + return; + } } + dtc->clear_dirty_flags(); + } else { + if(_pCurTexContext == dtc) { + return; // tex already set (and possible problem in state-sorting?) + } } - dtc->clear_dirty_flags(); - Texture *tex = tc->_texture; Texture::WrapMode wrapU,wrapV; wrapU=tex->get_wrapu(); @@ -4023,16 +4026,6 @@ apply_texture(TextureContext *tc) { _CurTexWrapModeV = wrapV; } -/* -#ifdef _DEBUG - Texture::WrapMode wrapval; - _d3dDevice->GetTextureStageState(0,D3DTSS_ADDRESSU,(DWORD*)&wrapval); - assert(get_texture_wrap_mode(wrapU) == wrapval); - _d3dDevice->GetTextureStageState(0,D3DTSS_ADDRESSV,(DWORD*)&wrapval); - assert(get_texture_wrap_mode(wrapV) == wrapval); -#endif -*/ - uint aniso_degree=tex->get_anisotropic_degree(); Texture::FilterType ft=tex->get_magfilter(); diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.h b/panda/src/dxgsg/dxGraphicsStateGuardian.h index 643f0968e4..49154c9bdc 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.h +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.h @@ -241,8 +241,6 @@ protected: void set_draw_buffer(const RenderBuffer &rb); void set_read_buffer(const RenderBuffer &rb); - void bind_texture(TextureContext *tc); - // for storage of the flexible vertex format char *_pCurFvfBufPtr,*_pFvfBufBasePtr; INLINE void add_to_FVFBuf(void *data, size_t bytes) ;