Jump to content

  • Log In with Google      Sign In   
  • Create Account

Texture release problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 borso   Members   -  Reputation: 100

Like
0Likes
Like

Posted 15 February 2012 - 05:01 AM

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!

Sponsor:

#2 borso   Members   -  Reputation: 100

Like
0Likes
Like

Posted 15 February 2012 - 05:06 AM

I forgot to mention that the texture is a render target. I've the same problem with normal 2D textures and cube maps.

#3 Evil Steve   Members   -  Reputation: 1982

Like
2Likes
Like

Posted 15 February 2012 - 05:13 AM

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.

Steve Macpherson
Systems Programmer

Rockstar North


#4 mhagain   Crossbones+   -  Reputation: 7970

Like
1Likes
Like

Posted 15 February 2012 - 05:36 AM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS