Reputation: 1507
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?
Upvotes: 3
Views: 2018
Reputation: 1375
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.
Upvotes: 6