Hello, As I have mentioned on irc some time ago, I have some Z order problems in a few d3d7 games. It seems to affect all games which mix transformed and untransformed vertices in one scene. The problem is that the transformed vertices show up in front of the untransformed, although the shouldn't.
See http://stud4.tuwien.ac.at/~e0526822/messiah-broken.png, this is a screenshot from the game Messiah, and the symptoms are that the flames and the beams can be seen through boxes, units and other objects. I can remember that a simmilar problem was reported for a d3d8 or d3d9 game. Other affected games are Gothic 2(fire can be seen though walls) and Anarchy Online(water level is too high). With Lionel Ulmer I found the problem in the glOrtho setup that wined3d does in drawprim.c(and in surface.c). The -minZ, -maxZ z range scales the vertices and disturbes the z order.
The old ddraw code uses a transform matrix which is equally to passing zmin = 1.0 and zmax = -1.0 to address this issue. Then the z coordinate are passed to gl unchanged and the z order is left intact. But as you undoubtately can guess, this breaks other games such as Prince of Persia 3D.
Some investigation showed that the current z setup in wined3d seems to be to avoid clipping. First I thought that rhw vertices aren't supposed to be clipped at all, but opengl does that and it's impossible to deactivate clipping in gl. So the vertices are scaled into the depth range to prevent them from beeing clipped. Lionel Ulmer mentioned a DONOTCLIP flag for d3d7 vertex drawing, which pop3d indeed passes. But we can't avoid clipping and disturbing the z setup at the same time :-(
The attached patch moves the glOrtho setup in a shared function for drawprim and unlockrect to avoid having double code. It also changes the default z range to 1.0, -1.0, with a dontclip flag which selects the old setup(but this is disabled for now, it will be activated for the DONOTCLIP flag and if ProcessVertices was supposed to clip the vertices).
Can you test the patch on some d3d8 and d3d9 games? I tested it on warcraft 3 and half-life 2 and didn't see any difference. Can you report negative and positive changes?
Thanks, Stefan