Sign in to follow this  
lomateron

Using ID3D10Resource question

Recommended Posts

lomateron    491

I am doing this code:

 

ID3D10Resource* reSo;

shaderResourceA->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text1,reSo);

shaderResourceB->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text2,reSo);

 

My question is, Where do i have to call Release()?
IS it like THIS:
 
ID3D10Resource* reSo;

shaderResourceA->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text1,reSo);
reSo->Release();

shaderResourceB->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text2,reSo);
reSo->Release();

 

or like THIS:
 
ID3D10Resource* reSo;

shaderResourceA->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text1,reSo);

shaderResourceB->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text2,reSo);

reSo->Release();
reSo->Release();

 

 

Share this post


Link to post
Share on other sites
mhagain    13430

Do it the first way.  The pointer returned by GetResource is going to be different for each call (as GetResource is called on a different shader resource each time), so by doing it the second way you'll (1) leak the resource returned by your first GetResource call, (2) actually destroy the resource returned by your second, and (3) risk crashing when you come to clean up the second for real.

Edited by mhagain

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this