I got to the bottom of my bug list today. And something evil and foreboding stared at me. The bug said ‘Make the game recover properly from DXGI_ERROR_DEVICE_REMOVED.’
About a month ago I was complaining about this hardware bug that I’ve been experiencing. Basically my video card is failing and stops rendering randomly in the middle of the game. Due to its annoying nature and unpredictability, I had put it on the bottom of my bug list as a low priority task. So with only this one bug left (well, only bug on my current list), I decided to make an attempt of fixing it.
Knowing that it was hard to reproduce reliably, I wrote code so that at a key press the graphics system would reset itself. It releases all graphics resources, resets the video device, and then reloads all resources from disc where possible, or it recreates any that are dynamic. Once I got this working by pressing a key, I hooked it into handling the failure case.
Happily and luckily, the hardware issue decided at that moment to start showing itself, making the testing of my fix fairly easy.
So after a few hours of coding I can now recover from a device removal. This process takes about two seconds, and while that’s quite a stutter, it will at least let players save their progress should should they start experiencing this problem.
This also means the game is able to continue running while installing new graphics drivers. Wonders will never cease!