AnsweredAssumed Answered

Weird WGL_NV_DX_interop2 DirectX reference leaks

Question asked by lrn on Jul 21, 2018
Latest reply on Jul 24, 2018 by xhuang

I'm currently trying to do GL rendering on DX surfaces, and stumbled upon an issue with references.

I've put multiple IDXGIDebug_ReportLiveObjects() calls around my test application to monitor reference counting, and there's an extra report at the end of the process. According to that process-termination report, my test application leaks:

warning: D3D11 WARNING: Live Producer at 0x0084D09C, Refcount: 5. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x0084F558, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x00865B08, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x0086BABC, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x0086BC34, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x0086BDAC, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x0086C004, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x0086C284, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x08A480A4, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING:         Live Object at 0x08A4839C, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
warning: D3D11 WARNING: Live                         Object :      9 [ STATE_CREATION WARNING #0: UNKNOWN]
warning: DXGI WARNING: Live Producer at 0x0083675C, Refcount: 2. [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING:  Live Object at 0x00839980, Refcount: 2. [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING: Live                         Object :      1 [ STATE_CREATION WARNING #0: ]

0x0084F558 is ID3D11Context, and that reference can be eliminated by forcing another (unbalanced) ID3D11Context_Release() call.

The other two objects are more difficult though. According to live reports, they are buffers. Here's a live report before exiting from WinMain():

warning: DXGI WARNING: Live IDXGIFactory at 0x008366F8, Refcount: 2 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING:  Live IDXGIAdapter at 0x00839980, Refcount: 2 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING: Live                   IDXGIAdapter :      1 [ STATE_CREATION WARNING #0: ]
warning: D3D11 WARNING: Live ID3D11Device at 0x0084D024, Refcount: 5 [ STATE_CREATION WARNING #441: LIVE_DEVICE]
warning: D3D11 WARNING:         Live ID3D11Context at 0x0084F558, Refcount: 1, IntRef: 1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT]
warning: D3D11 WARNING:         Live ID3D11Buffer at 0x08A480A4, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #423: LIVE_BUFFER]
warning: D3D11 WARNING:         Live ID3D11Buffer at 0x08A4839C, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #423: LIVE_BUFFER]
warning: D3D11 WARNING: Live                  ID3D11Context :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                   ID3D11Buffer :      2 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]

These two buffers appear after a call to wglDXLockObjectsNV. Here's a report before that call:

warning: DXGI WARNING: Live IDXGIFactory at 0x00686630, Refcount: 4 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING:  Live IDXGIAdapter at 0x0068B4E0, Refcount: 4 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING:  Live IDXGIOutput at 0x006BE438, Refcount: 1 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING: Live                   IDXGIAdapter :      1 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING: Live                    IDXGIOutput :      1 [ STATE_CREATION WARNING #0: ]
warning: D3D11 WARNING: Live ID3D11Device at 0x0069D044, Refcount: 15 [ STATE_CREATION WARNING #441: LIVE_DEVICE]
warning: D3D11 WARNING:         Live ID3D11Context at 0x0069F578, Refcount: 2, IntRef: 1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT]
warning: D3D11 WARNING:         Live IDXGISwapChain at 0x006BC430, Refcount: 2 [ STATE_CREATION WARNING #442: LIVE_SWAPCHAIN]
warning: D3D11 WARNING:         Live ID3DDeviceContextState at 0x006C21B8, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145742: LIVE_DEVICECONTEXTSTATE]
warning: D3D11 WARNING:         Live ID3D11Query at 0x089A8084, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #438: LIVE_QUERY]
warning: D3D11 WARNING:         Live ID3D11Texture2D at 0x088EEE3C, Refcount: 1, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
warning: D3D11 WARNING:         Live ID3D11DepthStencilView at 0x08933A6C, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #429: LIVE_DEPTHSTENCILVIEW]
warning: D3D11 WARNING:         Live ID3D11Texture2D at 0x08B20134, Refcount: 1, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
warning: D3D11 WARNING:         Live ID3D11RenderTargetView at 0x088E8EA4, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #428: LIVE_RENDERTARGETVIEW]
warning: D3D11 WARNING: Live                  ID3D11Context :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                 IDXGISwapChain :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live         ID3DDeviceContextState :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                    ID3D11Query :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                ID3D11Texture2D :      2 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live         ID3D11DepthStencilView :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live         ID3D11RenderTargetView :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]

 

and after:

warning: DXGI WARNING: Live IDXGIFactory at 0x00686630, Refcount: 4 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING:  Live IDXGIAdapter at 0x0068B4E0, Refcount: 4 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING:  Live IDXGIOutput at 0x006BE438, Refcount: 1 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING: Live                   IDXGIAdapter :      1 [ STATE_CREATION WARNING #0: ]
warning: DXGI WARNING: Live                    IDXGIOutput :      1 [ STATE_CREATION WARNING #0: ]
warning: D3D11 WARNING: Live ID3D11Device at 0x0069D044, Refcount: 18 [ STATE_CREATION WARNING #441: LIVE_DEVICE]
warning: D3D11 WARNING:         Live ID3D11Context at 0x0069F578, Refcount: 3, IntRef: 1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT]
warning: D3D11 WARNING:         Live IDXGISwapChain at 0x006BC430, Refcount: 2 [ STATE_CREATION WARNING #442: LIVE_SWAPCHAIN]
warning: D3D11 WARNING:         Live ID3DDeviceContextState at 0x006C21B8, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145742: LIVE_DEVICECONTEXTSTATE]
warning: D3D11 WARNING:         Live ID3D11Query at 0x089A8084, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #438: LIVE_QUERY]
warning: D3D11 WARNING:         Live ID3D11Texture2D at 0x088EEE3C, Refcount: 1, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
warning: D3D11 WARNING:         Live ID3D11DepthStencilView at 0x08933A6C, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #429: LIVE_DEPTHSTENCILVIEW]
warning: D3D11 WARNING:         Live ID3D11Texture2D at 0x08B20134, Refcount: 1, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
warning: D3D11 WARNING:         Live ID3D11RenderTargetView at 0x088E8EA4, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #428: LIVE_RENDERTARGETVIEW]
warning: D3D11 WARNING:         Live ID3D11Buffer at 0x088E68DC, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #423: LIVE_BUFFER]
warning: D3D11 WARNING:         Live ID3D11Buffer at 0x088E6C34, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #423: LIVE_BUFFER]
warning: D3D11 WARNING: Live                  ID3D11Context :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                 IDXGISwapChain :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live         ID3DDeviceContextState :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                    ID3D11Query :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                ID3D11Texture2D :      2 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live         ID3D11DepthStencilView :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live         ID3D11RenderTargetView :      1 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]
warning: D3D11 WARNING: Live                   ID3D11Buffer :      2 [ STATE_CREATION WARNING #422: LIVE_OBJECT_SUMMARY]

As you can see, two buffers just appear out of thin air and D3D11DeviceContext refcount also increases. Note that the call looks like this: wglDXLockObjectsNV(directx_gl_device, 0, NULL); - that is, i do not provide any objects to be locked (this is not a normal way of using that API, i'm just making a point here) and it is made immediately after wglDXOpenDeviceNV. Neither wglDXUnlockObjectsNV nor wglDXCloseDeviceNV release the references to the device context and two unknown buffers.

 

I don't know any way of getting the references to these two buffers (which would have allowed me to clean up after [presumably broken] AMD DirectX/GL driver, at least), so i'm stuck.

 

Oh, right, the driver info. Here it is:

Radeon Settings Version - 2018.0711.1421.24002
Driver Packaging Version - 18.20.19.01-180711a-330897E-RadeonSoftwareAdrenalin
Provider - Advanced Micro Devices, Inc.
2D Driver Version - 8.1.1.1634
Direct3D® Version - 9.14.10.01350
OpenGL® Version - 24.20.11000.14523
OpenCL™ Version - 24.20.12019.1010
AMD Mantle Version - 9.1.10.0268
AMD Mantle API Version - 102400
AMD Audio Driver Version - 10.0.1.7
Vulkan™ Driver Version - 2.0.33
Vulkan™ API Version - 1.1.73

Outcomes