Module: wine Branch: master Commit: 7b1e0815153be160ace0b145ae16423f1bf1b7ae URL: http://source.winehq.org/git/wine.git/?a=commit;h=7b1e0815153be160ace0b145ae...
Author: Stefan Dösinger stefan@codeweavers.com Date: Sun May 8 17:21:15 2011 +0200
d3d8: Map ZBIAS values to a smaller depth range.
---
dlls/d3d8/device.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 6d0b247..2b99dd5 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1466,6 +1466,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(IDirect3DDevice8 *iface, return hr; }
+/* This factor is the result of a trial-and-error search. Both ZBIAS and DEPTHBIAS require + * guesswork by design. d3d9 apps usually use a DEPTHBIAS of -0.00002(Mass Effect 2, WoW). + * d3d8 apps(Final Fantasy XI) set ZBIAS to 15 and still expect the depth test to sort + * objects properly. */ +static const float zbias_factor = -0.000005f; + static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *iface, D3DRENDERSTATETYPE State, DWORD Value) { @@ -1483,7 +1489,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *ifac switch (State) { case D3DRS_ZBIAS: - wined3d_value.f = Value / -16.0f; + wined3d_value.f = Value * zbias_factor; hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, wined3d_value.d); break;
@@ -1513,7 +1519,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(IDirect3DDevice8 *ifac { case D3DRS_ZBIAS: hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, &wined3d_value.d); - if (SUCCEEDED(hr)) *pValue = -wined3d_value.f * 16.0f; + if (SUCCEEDED(hr)) *pValue = wined3d_value.f / zbias_factor; break;
default: