From 96b758f7b37033bf382ce40dd3310965d3ac3f76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Thu, 21 Apr 2011 22:36:11 +0200 Subject: [PATCH] d3d: Map D3DRS_ZBIAS to WINED3DRS_DEPTHBIAS. ZBIAS was removed in d3d9 and replaced with DEPTHBIAS. Currently wined3d implements both independently which will cause trouble if we want to set the depthbias value depending on the depth stencil format. --- dlls/d3d8/device.c | 32 ++++++++++++++++++++++++++++++-- dlls/ddraw/device.c | 28 ++++++++++++++++++++++++++++ dlls/wined3d/state.c | 32 +------------------------------- dlls/wined3d/stateblock.c | 1 - dlls/wined3d/utils.c | 1 - include/wine/wined3d.idl | 1 - 6 files changed, 59 insertions(+), 36 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 976e71f96f7..47a727d583f 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1373,11 +1373,25 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *ifac { IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); HRESULT hr; + union + { + DWORD d; + float f; + } wined3d_value; TRACE("iface %p, state %#x, value %#x.\n", iface, State, Value); wined3d_mutex_lock(); - hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value); + switch (State) + { + case D3DRS_ZBIAS: + wined3d_value.f = Value / -16.0f; + hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, wined3d_value.d); + break; + + default: + hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value); + } wined3d_mutex_unlock(); return hr; @@ -1388,11 +1402,25 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(IDirect3DDevice8 *ifac { IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); HRESULT hr; + union + { + DWORD d; + float f; + } wined3d_value; TRACE("iface %p, state %#x, value %p.\n", iface, State, pValue); wined3d_mutex_lock(); - hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue); + switch (State) + { + case D3DRS_ZBIAS: + hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, &wined3d_value.d); + if (SUCCEEDED(hr)) *pValue = -wined3d_value.f * 16.0f; + break; + + default: + hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue); + } wined3d_mutex_unlock(); return hr; diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index b1b4cf64da8..1c2b89cd7de 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2374,6 +2374,20 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface, hr = DDERR_INVALIDPARAMS; break; + case D3DRENDERSTATE_ZBIAS: + { + union + { + DWORD d; + float f; + } wined3d_value; + + hr = IWineD3DDevice_GetRenderState(This->wineD3DDevice, + WINED3DRS_DEPTHBIAS, + &wined3d_value.d); + if (SUCCEEDED(hr)) *Value = -wined3d_value.f * 16.0f; + } + default: if (RenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00 && RenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31) @@ -2688,6 +2702,20 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface, hr = DDERR_INVALIDPARAMS; break; + case D3DRENDERSTATE_ZBIAS: + { + union + { + DWORD d; + float f; + } wined3d_value; + wined3d_value.f = Value / -16.0; + hr = IWineD3DDevice_SetRenderState(This->wineD3DDevice, + WINED3DRS_DEPTHBIAS, + wined3d_value.d); + break; + } + default: if (RenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00 && RenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31) diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 9d54076cb27..88ccd1b4094 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1383,36 +1383,6 @@ static void state_linepattern(DWORD state, struct wined3d_stateblock *stateblock } } -static void state_zbias(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context) -{ - union { - DWORD d; - float f; - } tmpvalue; - - if (stateblock->state.render_states[WINED3DRS_ZBIAS]) - { - tmpvalue.d = stateblock->state.render_states[WINED3DRS_ZBIAS]; - TRACE("ZBias value %f\n", tmpvalue.f); - glPolygonOffset(0, -tmpvalue.f); - checkGLcall("glPolygonOffset(0, -Value)"); - glEnable(GL_POLYGON_OFFSET_FILL); - checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);"); - glEnable(GL_POLYGON_OFFSET_LINE); - checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);"); - glEnable(GL_POLYGON_OFFSET_POINT); - checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);"); - } else { - glDisable(GL_POLYGON_OFFSET_FILL); - checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);"); - glDisable(GL_POLYGON_OFFSET_LINE); - checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);"); - glDisable(GL_POLYGON_OFFSET_POINT); - checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);"); - } -} - - static void state_normalize(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context) { if(isStateDirty(context, STATE_VDECL)) { @@ -5061,7 +5031,6 @@ const struct StateEntryTemplate misc_state_template[] = { { STATE_RENDER(WINED3DRS_SUBPIXEL), { STATE_RENDER(WINED3DRS_SUBPIXEL), state_subpixel }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_SUBPIXELX), { STATE_RENDER(WINED3DRS_SUBPIXELX), state_subpixelx }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_STIPPLEDALPHA), { STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_stippledalpha }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3DRS_ZBIAS), { STATE_RENDER(WINED3DRS_ZBIAS), state_zbias }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_STIPPLEENABLE), { STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_stippleenable }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_mipmaplodbias }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_ANISOTROPY), { STATE_RENDER(WINED3DRS_ANISOTROPY), state_anisotropy }, WINED3D_GL_EXT_NONE }, @@ -5793,6 +5762,7 @@ static void validate_state_table(struct StateEntry *state_table) { 17, 18}, { 21, 21}, { 42, 45}, + { 47, 47}, { 61, 127}, {149, 150}, {169, 169}, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 79fbb2ed9fb..b1b823a91d4 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1141,7 +1141,6 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock) tmpfloat.f = 1.0f; state->render_states[WINED3DRS_FOGDENSITY] = tmpfloat.d; state->render_states[WINED3DRS_EDGEANTIALIAS] = FALSE; - state->render_states[WINED3DRS_ZBIAS] = 0; state->render_states[WINED3DRS_RANGEFOGENABLE] = FALSE; state->render_states[WINED3DRS_STENCILENABLE] = FALSE; state->render_states[WINED3DRS_STENCILFAIL] = WINED3DSTENCILOP_KEEP; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 00ef23a317b..096b483348e 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1962,7 +1962,6 @@ const char *debug_d3drenderstate(WINED3DRENDERSTATETYPE state) D3DSTATE_TO_STR(WINED3DRS_EDGEANTIALIAS); D3DSTATE_TO_STR(WINED3DRS_COLORKEYENABLE); D3DSTATE_TO_STR(WINED3DRS_MIPMAPLODBIAS); - D3DSTATE_TO_STR(WINED3DRS_ZBIAS); D3DSTATE_TO_STR(WINED3DRS_RANGEFOGENABLE); D3DSTATE_TO_STR(WINED3DRS_ANISOTROPY); D3DSTATE_TO_STR(WINED3DRS_FLUSHBATCH); diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index d536004bdde..240654092c1 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -319,7 +319,6 @@ typedef enum _WINED3DRENDERSTATETYPE WINED3DRS_EDGEANTIALIAS = 40, /* d3d7, d3d8 */ WINED3DRS_COLORKEYENABLE = 41, /* d3d7 */ WINED3DRS_MIPMAPLODBIAS = 46, /* d3d7 */ - WINED3DRS_ZBIAS = 47, /* d3d7, d3d8 */ WINED3DRS_RANGEFOGENABLE = 48, WINED3DRS_ANISOTROPY = 49, /* d3d7 */ WINED3DRS_FLUSHBATCH = 50, /* d3d7 */ -- 2.11.4.GIT