Jump to content
  • Advertisement
Sign in to follow this  
deffer

SetRenderTarget and reference count

This topic is 4848 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

Ok, this is pretty straightforward. Does SetRenderTarget(..) internally call AddRef() and/or Release() on incoming and previous surfaces? It is not mentioned in the documentation of the function, but I recall it being said in some other place (also in the documentation). Or am I just being paranoid? ~def

Share this post


Link to post
Share on other sites
Advertisement
Functions that increase the reference count of an object are ones that create the object, not ones that use it, in most cases.

So no this probably wouldn't alter the ref count.

ace

Share this post


Link to post
Share on other sites
My guess would be otherwise. It's not about who creates the resource, rather who owns and uses it.

More detailed:
If we got a device with a render target, I suppose it has ref_cout 1. Now, GetRenderTarget() increases the ref_count, it is clearly said in the documentation. If overwriting RT with SetRT did not call Release(), after:

surface *other = ...;
surface *previous = pDev->GetRenderTarget(0);
pDev->SetRenderTarget(0, other);


we would have previous with ref_count 2 and other with 1. While my intuition says it should be otherwise.

But it's nowhere said explicitly! Simply guessing is not gonna help too much.
~def

Share this post


Link to post
Share on other sites
I think you could see the REF count on an object in D3DSPY. Now, I started PIX and was looking for it, but I couldn't find anything. Wierd.

Share this post


Link to post
Share on other sites
Take a look at the IUnknown documentation - the AddRef() and Release() functions return the new reference count. If you just call this pair before and after the SetRT() call, you can determine if it actually increases the count.

Like:


beforeCount = surf->AddRef() - 1;
surf->Release();

SetRenderTarget( surf );

afterCount = surf->AddRef() - 1;
surf->Release();


You have to call both AddRef() and Release() because you want to maintain the correct ref count. Unfortunately, there is no GetRefCount().

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!