Dxgi factory is still alive after disposal? #359
-
Edit: I think the second example below is clearer. I can't seem to get rid of some live objects. After calling factory6.Dispose() and then reporting live objects. I get the following output:
The code through the first and second call to ReportLiveObjects method is: public static Device3d CreateDevice(in DeviceDescriptor descriptor)
{
Debug.LogMessage("Device3dFactory.CreateDevice | I");
ReportLiveObjects();
DeviceDescriptor = descriptor;
using IDXGIFactory2 factory = CreateDXGIFactory2<IDXGIFactory2>(descriptor.ValidationMode != ValidationMode.Disabled);
factory.DebugName = "Device3d.factory";
IDXGIFactory6 factory6 = factory.QueryInterfaceOrNull<IDXGIFactory6>();
factory6.DebugName = "Device3dFactory.factory6";
if (factory6 != null)
{
GpuPreference gpuPreference = ToDXGI(descriptor.PowerPreference);
for (int adapterIndex = 0; factory6!.EnumAdapterByGpuPreference(adapterIndex, gpuPreference, out Adapter).Success; adapterIndex++)
{
AdapterDescription1 desc = Adapter!.Description1;
// Don't select the Basic Render Driver adapter.
if ((desc.Flags & AdapterFlags.Software) != AdapterFlags.None)
{
Adapter.Dispose();
continue;
}
if (IsSupportedFeatureLevel(Adapter, Vortice.Direct3D.FeatureLevel.Level_11_1, DeviceCreationFlags.BgraSupport))
{
break;
}
}
factory6.Dispose(); // dispose calls release behind the scenes.
Debug.LogMessage("Device3dFactory.CreateDevice | O");
ReportLiveObjects();
} The report live objects method: private static void ReportLiveObjects()
{
if (DXGI.DXGIGetDebugInterface1(out IDXGIDebug1 dxgiDebug).Success)
{
dxgiDebug!.ReportLiveObjects(DXGI.DebugAll, ReportLiveObjectFlags.Detail | ReportLiveObjectFlags.IgnoreInternal);
dxgiDebug!.Dispose();
}
} I just don't see how factory6 can still be live. Can anyone see something wrong, or explain why I don't understand the output? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Alright, I've reworked my graphics setup code and I have another example of live factory, this is a function that gets the adapter matching a given descriptor (which doesn't make sense to me, but that's a different issue). Here I create a factory to get the adapter. Then before returning the adapter I dispose the factory. But the DXGI warning implies that there are still 2 live factory references. public static IDXGIAdapter1 GetAdapter(in DeviceDescriptor descriptor)
{
Debug.LogMessage("[1]----------");
DirectXTools.ReportLiveDxgiObjects();
IDXGIFactory2 factory = CreateDXGIFactory2<IDXGIFactory2>(descriptor.ValidationMode != ValidationMode.Disabled);
factory.DebugName = "DirectXTools.factory";
factory.EnumAdapters1(0, out IDXGIAdapter1 adapter);
adapter.DebugName = "DirectXTools.adapter";
factory.Dispose();
Debug.LogMessage("[2]----------");
DirectXTools.ReportLiveDxgiObjects();
return adapter;
} Output:
|
Beta Was this translation helpful? Give feedback.
-
It's 2 steps forward, 2 steps back. There is no lasting solution to finding live objects. This comment on gamedev.net suggests that I can get more information..
This implies that there is some way to get the name of objects, instead of Live Object. And sometimes I get postive ref counts but no debug output.
|
Beta Was this translation helpful? Give feedback.
-
This is the code that destroys things in order and gives the expected nil output. #if DEBUG
ReportLiveD3d11Objects(DxDevice);
#endif
DxDevice.Dispose();
DxFactory.Release();
DxAdapter.Release();
DxAdapter.Dispose();
#if DEBUG
ReportLiveDxgiObjects(); |
Beta Was this translation helpful? Give feedback.
This is the code that destroys things in order and gives the expected nil output.