locked
ID3D11DeviceContext::OMSetRenderTargets doesn't increase refcount on depthstencil ?

    General discussion

  • I'm currently checking refcount on resource view before and after a OMSetRenderTargets. But in contradiction of the documentation which explicitly say that OMSetRenderTargets hold a reference on D3D11 :

    The method will hold a reference to the interfaces passed in. This differs from the device state behavior in Direct3D 10. 

    I don't see any refcount modification after the call.

    uint32 refcountbefore = GetRefCount(pViewDS);
    m_pImmediateContext->OMSetRenderTargets(_numRT,&ppView[0],pViewDS);
    uint32 refcountafter = GetRefCount(pViewDS);
    ASSERT(refcountafter==refcountbefore+1,"RefCount reference problem");

    GetRefCount use AddRef/Release method to get the internal com reference counter.

    Do I forgot something ?

    Tuesday, January 15, 2013 9:16 AM

All replies

  • Hi,

    How do you get the reference count of a COM interface?

    As far as I know, the ComPtr Class in WRL does not have a directly way to get reference count.
    http://msdn.microsoft.com/en-us/library/br244983.aspx

    If we call the Release function to get the reference count. This function should reduce the reference count first. Maybe the increate value is reduced after we call release function.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 16, 2013 6:12 AM
    Moderator
  • Hello,

    I would like to change this thread type as discussion, because I think there may be no exact answer for this question.

    Thanks for your understanding,

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 21, 2013 2:14 AM
    Moderator
  • Due to some implementation details, there's a difference between the 'external' refcount as reported by COM and the 'internal' ref count in the Direct3D implementation. Remember that all DeviceChild objects are destroyed when the parent ID3D11Device is released no matter what the COM refcount may be.

    Generally the best way to get 'clean exit' / 'resource leak' information for Direct3D 11 is to make use of the SDK Debug Layer.

    http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx

    Monday, January 21, 2013 10:29 PM