Commit 327d1792 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Move the constant depth bias to wined3d_rasterizer_state.

parent ae6fdbea
......@@ -929,11 +929,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface);
struct d3d_rasterizer_state *rasterizer_state_impl;
const D3D11_RASTERIZER_DESC *desc;
union
{
DWORD d;
float f;
} const_bias;
TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
......@@ -941,7 +936,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
if (!(rasterizer_state_impl = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state)))
{
wined3d_device_set_rasterizer_state(device->wined3d_device, NULL);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
......@@ -952,8 +946,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
wined3d_device_set_rasterizer_state(device->wined3d_device, rasterizer_state_impl->wined3d_state);
desc = &rasterizer_state_impl->desc;
const_bias.f = desc->DepthBias;
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, const_bias.d);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
wined3d_device_set_render_state(device->wined3d_device,
......
......@@ -1079,6 +1079,7 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str
wined3d_desc.fill_mode = desc->FillMode;
wined3d_desc.cull_mode = desc->CullMode;
wined3d_desc.front_ccw = desc->FrontCounterClockwise;
wined3d_desc.depth_bias = desc->DepthBias;
wined3d_desc.depth_bias_clamp = desc->DepthBiasClamp;
wined3d_desc.scale_bias = desc->SlopeScaledDepthBias;
wined3d_desc.depth_clip = desc->DepthClipEnable;
......
......@@ -1150,12 +1150,12 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_ZENABLE));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILENABLE));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
device_invalidate_state(device, STATE_RASTERIZER);
}
else if (prev)
{
if (prev->format->depth_bias_scale != op->view->format->depth_bias_scale)
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
device_invalidate_state(device, STATE_RASTERIZER);
if (prev->format->stencil_size != op->view->format->stencil_size)
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILREF));
}
......
......@@ -3601,6 +3601,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
case WINED3D_RS_FILLMODE:
case WINED3D_RS_CULLMODE:
case WINED3D_RS_SLOPESCALEDEPTHBIAS:
case WINED3D_RS_DEPTHBIAS:
set_rasterizer_state = TRUE;
break;
......@@ -3625,6 +3626,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
memset(&desc, 0, sizeof(desc));
desc.fill_mode = state->rs[WINED3D_RS_FILLMODE];
desc.cull_mode = state->rs[WINED3D_RS_CULLMODE];
bias.d = state->rs[WINED3D_RS_DEPTHBIAS];
desc.depth_bias = bias.f;
bias.d = state->rs[WINED3D_RS_SLOPESCALEDEPTHBIAS];
desc.scale_bias = bias.f;
desc.depth_clip = TRUE;
......
......@@ -1752,25 +1752,25 @@ static void state_scissor(struct wined3d_context *context, const struct wined3d_
*
* Note that SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and
* doesn't need to be scaled to account for GL vs D3D differences. */
static void state_depthbias(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static void depthbias(struct wined3d_context *context, const struct wined3d_state *state)
{
const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
const struct wined3d_rasterizer_state *r = state->rasterizer_state;
float scale_bias = r ? r->desc.scale_bias : 0.0f;
union
{
DWORD d;
float f;
} const_bias;
if (scale_bias || state->render_states[WINED3D_RS_DEPTHBIAS])
const_bias.f = r ? r->desc.depth_bias : 0.0f;
if (scale_bias || const_bias.f)
{
const struct wined3d_rendertarget_view *depth = state->fb->depth_stencil;
float factor, units, scale, clamp;
union
{
DWORD d;
float f;
} const_bias;
clamp = r ? r->desc.depth_bias_clamp : 0.0f;
const_bias.d = state->render_states[WINED3D_RS_DEPTHBIAS];
if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_DEPTH_BIAS)
{
......@@ -4331,8 +4331,7 @@ static void rasterizer(struct wined3d_context *context, const struct wined3d_sta
gl_info->gl_ops.gl.p_glFrontFace(mode);
checkGLcall("glFrontFace");
if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_DEPTHBIAS)))
state_depthbias(context, state, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
depthbias(context, state);
fillmode(r, gl_info);
cullmode(r, gl_info);
depth_clip(r, gl_info);
......@@ -4348,8 +4347,7 @@ static void rasterizer_cc(struct wined3d_context *context, const struct wined3d_
gl_info->gl_ops.gl.p_glFrontFace(mode);
checkGLcall("glFrontFace");
if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_DEPTHBIAS)))
state_depthbias(context, state, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
depthbias(context, state);
fillmode(r, gl_info);
cullmode(r, gl_info);
depth_clip(r, gl_info);
......@@ -4669,7 +4667,6 @@ const struct wined3d_state_entry_template misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), state_colorwrite3 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), state_depthbias }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ZVISIBLE), { STATE_RENDER(WINED3D_RS_ZVISIBLE), state_zvisible }, WINED3D_GL_EXT_NONE },
/* Samplers */
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler }, WINED3D_GL_EXT_NONE },
......@@ -5438,7 +5435,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table)
{175, 175},
{177, 177},
{193, 193},
{196, 197},
{195, 197},
{ 0, 0},
};
static const DWORD simple_states[] =
......
......@@ -2036,6 +2036,7 @@ struct wined3d_rasterizer_state_desc
enum wined3d_fill_mode fill_mode;
enum wined3d_cull cull_mode;
BOOL front_ccw;
float depth_bias;
float depth_bias_clamp;
float scale_bias;
BOOL depth_clip;
......
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