Whoa, this brings up memories. And reminds me how lucky I am that I didn't have to deal with d3d fog in years.
Is there a particular game that is motivating this patch? Any changes we should make to the implementation?
I'll add a few stylistic comments as I read the test, then test it on my windows box and then try to actually understand what is going on and how it differs from my old understanding.