Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 8 -------- dlls/d3d11/state.c | 1 + dlls/wined3d/cs.c | 4 ++-- dlls/wined3d/device.c | 3 +++ dlls/wined3d/state.c | 27 ++++++++++++--------------- include/wine/wined3d.h | 1 + 6 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 0e46816246..59e3ab25af 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -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, diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 4d56f7dc75..c1aaa094e0 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -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; diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index ec17b59d71..ac518cae04 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -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)); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 7e727242f4..50a0a740bf 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -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; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 85bd1e24a3..4d5455e19b 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -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[] = diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 6fc3a1aaa8..85d7885f49 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -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;