0

I'm trying to name every COM object instantiated by DXGI or D3D11 in my application so they can be viewed nicely in debuggers.

I'm stuck on the ID3DUserDefinedAnnotation interface, queried from the ID3D11DeviceContext. I cannot find an interface exposing SetPrivateData for this object.

What's the way to set the debugger name of this object?

1 Answers1

1

QueryInterface only returns interfaces to the same object as the one being queried. That means in order to set the debugger name of the object referred to by an ID3DUserDefinedAnnotation interface, you need to use ID3D11DeviceContext::SetPrivateData. If necessary, you can use ID3DUserDefinedAnnotation::QueryInterface to obtain an ID3D11DeviceContext interface to the object.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • This is what I'm currently doing and why I'm a bit puzzled. The debugger displays the ID3D11DeviceContext object with the name provided to SetPrivateData yet the ID3D11UserDefinedAnnotation object is named "obj:18" with type "D3D User-Defined Annotation". – Jeremie Pelletier Jun 15 '15 at 22:16
  • In this particular case, QueryInterface is actually creating a new COM object and returning it. The debugger also shows QueryInterface made a call to ::CreateObject. – Jeremie Pelletier Jun 15 '15 at 22:23
  • If they are being treated as different COM objects then they're breaking a pretty fundamental rule of COM. Both interfaces are required to have the same IUnknown interface and the same reference count. It's possible though that the two different objects shown by the debugger have been implemented in a way that makes them one single COM object. – Ross Ridge Jun 16 '15 at 00:43