Using ID3D10Resource question

Started by
0 comments, last by 21st Century Moose 11 years ago

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();

Advertisement

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement