3

I randomly get this error (D2DERR_RECREATE_TARGET) many times an hour and after reading on that error, it seems I can't avoid it. I am using SharpDX which is "an open-source project delivering the full DirectX API under the .Net platform".

According to the microsoft's documentation: "Direct2D signals a lost device by returning the error code D2DERR_RECREATE_TARGET from the EndDraw method. If you receive this error code, you must re-create the render target and all device-dependent resources."

Does that really mean I need to keep track of every device-dependent resources my render target creates (There are a lot!) and stops using or am I getting it wrong? Or perhaps someone here knows a way around this error?

Mickael Bergeron Néron
  • 1,472
  • 1
  • 18
  • 31
  • 2
    Yes, if you want your application to properly handle it. You shouldn't be getting that error so frequently though - it usually just happens when a driver is updated or a remote desktop session starts, or if there's an issue with your driver that's causing a crash. One relatively easy way to handle this is to basically restart the application, assuming you don't have anything that you can't regenerate from disk. – MooseBoys Oct 17 '14 at 01:10

1 Answers1

6

Objects created by the render target that fails with D2DERR_RECREATE_TARGET can't be used for drawing anymore.

So: yes, you either need to keep track of objects you need and recreate them or don't use them.

It is strange that you get the error very often. Maybe your complex rendering triggers a bug in the video driver or uses too much memory.

Sometimes the bug can be as simple as drawing outside of bitmap boundaries on a specific video card.

Enabling D2D and D3D debug layers might help finding the cause of the error.

vt.
  • 1,325
  • 12
  • 27