Commit 69861cf8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of the depth range hack.

parent ec03d3e4
...@@ -1411,15 +1411,15 @@ static void depth_clamp_test(IDirect3DDevice8 *device) ...@@ -1411,15 +1411,15 @@ static void depth_clamp_test(IDirect3DDevice8 *device)
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
color = getPixelColor(device, 75, 75); 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); 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); color = getPixelColor(device, 320, 240);
ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color); ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
color = getPixelColor(device, 320, 330); 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); 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); hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
......
...@@ -10685,15 +10685,15 @@ static void depth_clamp_test(IDirect3DDevice9 *device) ...@@ -10685,15 +10685,15 @@ static void depth_clamp_test(IDirect3DDevice9 *device)
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
color = getPixelColor(device, 75, 75); 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); 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); color = getPixelColor(device, 320, 240);
ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color); ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
color = getPixelColor(device, 320, 330); 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); 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); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
......
...@@ -2795,15 +2795,15 @@ static void depth_clamp_test(IDirect3DDevice7 *device) ...@@ -2795,15 +2795,15 @@ static void depth_clamp_test(IDirect3DDevice7 *device)
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
color = getPixelColor(device, 75, 75); 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); 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); color = getPixelColor(device, 320, 240);
ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color); ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
color = getPixelColor(device, 320, 330); 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); 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.dvMinZ = 0.0;
vp.dvMaxZ = 1.0; vp.dvMaxZ = 1.0;
......
...@@ -3884,62 +3884,18 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock ...@@ -3884,62 +3884,18 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
glLoadIdentity(); glLoadIdentity();
checkGLcall("glLoadIdentity"); checkGLcall("glLoadIdentity");
if(context->last_was_rhw) { if (context->last_was_rhw)
double X, Y, height, width, minZ, maxZ; {
double x = stateblock->viewport.X;
X = stateblock->viewport.X; double y = stateblock->viewport.Y;
Y = stateblock->viewport.Y; double w = stateblock->viewport.Width;
height = stateblock->viewport.Height; double h = stateblock->viewport.Height;
width = stateblock->viewport.Width;
minZ = stateblock->viewport.MinZ;
maxZ = stateblock->viewport.MaxZ;
if (!stateblock->device->untransformed) TRACE("Calling glOrtho with x %.8e, y %.8e, w %.8e, h %.8e.\n", x, y, w, h);
{ if (context->render_offscreen)
/* Transformed vertices are supposed to bypass the whole transform pipeline including glOrtho(x, x + w, -y, -y - h, 0.0, -1.0);
* frustum clipping. This can't be done in opengl, so this code adjusts the Z range to else
* suppress depth clipping. This can be done because it is an orthogonal projection and glOrtho(x, x + w, y + h, y, 0.0, -1.0);
* 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);
}
}
checkGLcall("glOrtho"); checkGLcall("glOrtho");
/* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */ /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment