I have a ID3DX10Font* that I want to have automatically destroyed when the ID3D10Device object is destroyed so I first tried to:
If my global GUID var isn't assigned, CoCreateGuid( &g_FontGuid )
Set the pDataSize to sizeof(IUnknown*) and attempt to GetPrivateData( g_FontGuid, &dwDataSize, pFont) for that object in case it already exists
If not, SetPrivateDataInterface( g_FontGuid, (ID3DX10Font*)pFont )
I found that if I also try SetPrivateData before or after the SetPrivateDataInterface call, the object will get overwritten and I see a debug notice from DX saying the object was destroyed. With the code above, I do see AddRef get called (I tested this with my own object inheriting from IUnknown to be sure). Later down the line in the DXUT samplke code that I'm testing with the DXUT code makes a check from pD3D10Device->Release and there are still references open and pops up a dialog saying that resources are not freed. I also never hit my breakpoint in the Release method of my own object so I know that Release() wasn't called.
Is there an order dependency on calling the Get/Set/SetInterface calls that needs to be done? I assumed based on the MSDN documentation that any object inheriting IUnknown will be OK so I assumed that this would apply to a ID3DX10Font object.
It looks like the old DX9/8/7 SetPrivateData and GetPrivateData calls no longer perform the IUnknown destruction so I decided to use SetPrivateDataInterface...any chance you can post some pseudo code that works on your end?
Regards,
LuxRGB