Jump to content
  • Advertisement
Sign in to follow this  
borso

Texture release problem

This topic is 2497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

I'm writing a directx 9 renderer and I've run into this problem: when a IDirect3D9Texture9 object is bound to an ID3DXEffect with SetTexture and the context is lost after a device reset, I can't release the texture successfully. Some unreleased memory block still stay and I can't reset the device. However, if I set the texture to NULL, I'm able to release it and everything works fine.

Is this a known thing, or I'm doing something horrible?

Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I forgot to mention that the texture is a render target. I've the same problem with normal 2D textures and cube maps.

Share this post


Link to post
Share on other sites
ID3DXEffect::SetTexture() increases the reference count of any texture set on it, so yes - you'll need to set the texture to NULL if you want to Release() it.

EDIT: You should also be calling ID3DXEffect::OnLostDevice() and ID3DXEffect::OnResetDevice(), which probably internally sets the textures to NULL anyway.

Share this post


Link to post
Share on other sites
With render targets there is a second thing to be careful of - if you ever call GetSurfaceLevel on the texture (e.g. to use the texture in a SetRenderTarget call) you also need to Release the obtained surface interface when done otherwise that too will leak.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!