I once lost consciousness after a bad bike wreck that left me bleeding significantly from both knees. I lost consciousness while sitting on a bench waiting for my wife to arrive after walking my bike back to the trail head.
I remember having a very vivid and pleasant dream (riding in a car with some friends and laughing) while I was "out". I came-to when a bystander started beckoning to me ("Sir! Sir!"). Their calls bled into my dream first, then I awoke and realized I was laying face-down in the grass by the bench.
The pain was gone in the dream, but, of course, came back when I awoke. I sort of wished I could just pass out again.
Interestingly that dream has stuck with me in a way that typical sleeping dreams don't.