This is a sad and upsetting read. I'm really sorry that you're going through such a tough time.
You need to understand that you are not a failure. You may not have done well in your exams, but that doesn't make you a failure. What it actually does is give you feedback that you didn't reach your potential and that you are capable of much better results (especially considering your previous results). "It's not failure, it's feedback" is the motto to go by right now. Feedback in every sense of the word: you're clearly bright and intelligent, but your results don't reflect that. Why? That's a question for you to answer and have a really good think about. Once you figure it out, use the feedback to rectify the problem and not make the same mistake. If you deal with it this way, you not only get better results, but you also equip yourself with the ability to deal with similar situations you could face in the future. All it takes is a change in attitude: Life is 10% what happens to you and 90% how you respond to it - Lou Holtz.
Also, you're still young, only 21 - you have a whole life ahead of you!
As for possible solutions, a lot of users have already stated them. First seek advice from your university, have a look to see if there are PhDs that take your circumstances into consideration.
Personally, I think that a change would be good right now. Would you consider doing a year in an industrial placement related to your field? The change in environment would give you a 'fresh-start' and sometime to clear your head from academics a little, while keeping you busy enough to not feel too idle. If you want and if it's an option at your university, you might be able to retake one or two exams while on your placement, which is a bonus.
Avoiding flatmates and being in socially-isolated only makes your depression worse. I know you hear it a lot, and it get's annoying after a while, but it really, really does make a huge difference on how you feel. I was in a similar situation and ignored this advice thinking it wouldn't help, but when I finally tried it out, I saw that it was a big part of what was making me feel the crappy way I did. So do try to see if there's anyone you can talk to comfortably about things - even if it isn't about how you feel and it's just a general conversation, or just having a laugh. It will be helpful and it will make you feel less isolated. If you feel like there's nobody you can talk to, you can PM me and I'd be more than happy to lend an ear.
I hope this was helpful and I hope everything goes well for you. Remember, you're not a failure and life is all about attitude!