Henri Verbeet : wined3d: Get rid of the depth range hack.

Alexandre Julliard julliard at winehq.org
Wed Jan 27 12:27:22 CST 2010


Module: wine
Branch: master
Commit: 69861cf8730047a06ad898f9b45a4914a172745c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=69861cf8730047a06ad898f9b45a4914a172745c

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Jan 26 18:31:38 2010 +0100

wined3d: Get rid of the depth range hack.

---

 dlls/d3d8/tests/visual.c  |    8 +++---
 dlls/d3d9/tests/visual.c  |    8 +++---
 dlls/ddraw/tests/visual.c |    8 +++---
 dlls/wined3d/state.c      |   66 +++++++-------------------------------------
 4 files changed, 23 insertions(+), 67 deletions(-)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index f904475..0ea1bd2 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -1411,15 +1411,15 @@ static void depth_clamp_test(IDirect3DDevice8 *device)
     ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
 
     color = getPixelColor(device, 75, 75);
-    todo_wine ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 150, 150);
-    todo_wine ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 330);
-    todo_wine ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 330);
-    todo_wine ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
     ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 0d78271..875d2be 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -10685,15 +10685,15 @@ static void depth_clamp_test(IDirect3DDevice9 *device)
     ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
 
     color = getPixelColor(device, 75, 75);
-    todo_wine ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 150, 150);
-    todo_wine ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 330);
-    todo_wine ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 330);
-    todo_wine ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
     ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 00b0bb3..6d4cf2e 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -2795,15 +2795,15 @@ static void depth_clamp_test(IDirect3DDevice7 *device)
     ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
 
     color = getPixelColor(device, 75, 75);
-    todo_wine ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 150, 150);
-    todo_wine ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 330);
-    todo_wine ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 330);
-    todo_wine ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
 
     vp.dvMinZ = 0.0;
     vp.dvMaxZ = 1.0;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index d44dc2c..247710c 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3884,62 +3884,18 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
     glLoadIdentity();
     checkGLcall("glLoadIdentity");
 
-    if(context->last_was_rhw) {
-        double X, Y, height, width, minZ, maxZ;
-
-        X      = stateblock->viewport.X;
-        Y      = stateblock->viewport.Y;
-        height = stateblock->viewport.Height;
-        width  = stateblock->viewport.Width;
-        minZ   = stateblock->viewport.MinZ;
-        maxZ   = stateblock->viewport.MaxZ;
+    if (context->last_was_rhw)
+    {
+        double x = stateblock->viewport.X;
+        double y = stateblock->viewport.Y;
+        double w = stateblock->viewport.Width;
+        double h = stateblock->viewport.Height;
 
-        if (!stateblock->device->untransformed)
-        {
-            /* Transformed vertices are supposed to bypass the whole transform pipeline including
-             * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
-             * suppress depth clipping. This can be done because it is an orthogonal projection and
-             * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of
-             * Persia 3D need this.
-             *
-             * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum
-             * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor
-             * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close
-             * to the viewer.
-             *
-             * Also note that this breaks z comparison against z values filled in with clear,
-             * but no app depending on that and disabled clipping has been found yet. Comparing
-             * primitives against themselves works, so the Z buffer is still intact for normal hidden
-             * surface removal.
-             *
-             * We could disable clipping entirely by setting the near to infinity and far to -infinity,
-             * but this would break Z buffer operation. Raising the range to something less than
-             * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the
-             * problem either.
-             */
-            TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
-            if (context->render_offscreen)
-            {
-                glOrtho(X, X + width, -Y, -Y - height, -minZ, -maxZ);
-            } else {
-                glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
-            }
-        } else {
-            /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
-             * trick above because this would mess up transformed and untransformed Z order. Pass the z position
-             * unmodified to opengl.
-             *
-             * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
-             * replacement shader.
-             */
-            TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
-            if (context->render_offscreen)
-            {
-                glOrtho(X, X + width, -Y, -Y - height, 0.0, -1.0);
-            } else {
-                glOrtho(X, X + width, Y + height, Y, 0.0, -1.0);
-            }
-        }
+        TRACE("Calling glOrtho with x %.8e, y %.8e, w %.8e, h %.8e.\n", x, y, w, h);
+        if (context->render_offscreen)
+            glOrtho(x, x + w, -y, -y - h, 0.0, -1.0);
+        else
+            glOrtho(x, x + w, y + h, y, 0.0, -1.0);
         checkGLcall("glOrtho");
 
         /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */




More information about the wine-cvs mailing list