Search code examples
direct2d

Direct2D Sharable Resources


I saw an answer to this question: Do I need to recreate Direct2D sharable resources? , but I have some don't understand : the shared resource A was created by RT1 and used by RT2, what should I do to A and RT1 if RT2's EndDraw return D2DERR_RECREATE_TARGET?


Solution

  • A Direct2D shared resource is one that is allocated by and stored on the same hardware device. Such resources are created by render targets that share the same underlying device and are created with the same D2D1_RENDER_TARGET_USAGE flags.

    The D2DERR_RECREATE_TARGET error code indicates that the underlying device is no longer available. Any Direct3D, DXGI, Direct2D devices, device contexts, swap chains, render targets, bitmap, etc. need to be released and recreated.

    In your example, it doesn’t matter which render target returns the error. Once received, both render targets must be released as well as any shared resources they may have created.