Advertisement

ID3DUserDefinedAnnotation always leaving behind live objects

Started by March 14, 2020 03:55 PM
3 comments, last by MJP 4 years, 10 months ago

I am attempting to use ID3DUserDefinedAnnotation to visualize regions of calls in RenderDoc. When I use it though I will always get resource leaks at the application. The call to QueryInterface always succeeds but according to the documentation BeginEvent will return -1 when not running under a Direct3D profiling tool. When I run in RenderDoc I see my regions so I believe it is working, although I am not sure how to view the output log from RenderDoc so I do not know if I am leaking resources there. I verified that when I create my device I am using D3D_FEATURE_LEVEL_11_1 and D3D11_CREATE_DEVICE_DEBUG

How could I have my running application not always report live objects when using ID3DUserDefinedAnnotation? Do applications such as RenderDoc set a special configuration flag that I can set?

Even a simple example such as this will trigger reporting live objects

ID3DUserDefinedAnnotation* Annotation;

HRESULT hr = m_pD3D11DeviceContext->QueryInterface(__uuidof(ID3DUserDefinedAnnotation), (void **)&Annotation);
//HRESULT hr = m_pD3D11DeviceContext->QueryInterface(IID_PPV_ARGS(&Annotation));
if(FAILED(hr))
    return -1;

UINT code = Annotation->BeginEvent(L"TestEvent");
if(code == -1)
    return -1;

code = Annotation->EndEvent();
if(code == -1)
    return -1;

return 0;

My output log will have this, where I think 146 is the number of frames that has been called with this running. When I remove the code mentioned above then there are no resources still in use

D3D11 WARNING: Process is terminating. Using simple reporting. Please call ReportLiveObjects() at runtime for standard reporting. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: Live Producer at 0x04EF42D4, Refcount: 2. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x04E92BF8, Refcount: 146. [ STATE_CREATION WARNING #0: UNKNOWN]

You aren't querying that interface every frame, are you?

When terminating your application and releasing the device context, you should also release the annotation.

Advertisement

@pcmaster I am querying it every frame. Am I suppose to store the annotation once then use it for every BeginEvent and EndEvent?

QueryInterface will increment the reference count on the underyling object for the interface, so you need to call Release whenever you're done with the new interface that you've queried. It's probably fast enough to call QueryInterface every time you need it, but you would need to call Release every time you call it if you want to avoid leaks.

This topic is closed to new replies.

Advertisement