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.
This commit is contained in:
parent
f2b34dddfb
commit
96b758f7b3
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue