Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 11 ----------- dlls/d3d11/state.c | 1 + dlls/wined3d/adapter_vk.c | 3 +-- dlls/wined3d/context_vk.c | 2 +- dlls/wined3d/device.c | 2 ++ dlls/wined3d/state.c | 23 ++++++++++------------- include/wine/wined3d.h | 1 + 7 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 1a3f3e5a1b2..dd0a67ebc80 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -724,11 +724,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi wined3d_mutex_unlock(); }
-static void set_default_depth_stencil_state(struct wined3d_device *wined3d_device) -{ - wined3d_device_set_render_state(wined3d_device, WINED3D_RS_ZFUNC, WINED3D_CMP_LESS); -} - static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext1 *iface, ID3D11DepthStencilState *depth_stencil_state, UINT stencil_ref) { @@ -744,7 +739,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3 if (!(state_impl = unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state))) { wined3d_device_set_depth_stencil_state(device->wined3d_device, NULL); - set_default_depth_stencil_state(device->wined3d_device); wined3d_mutex_unlock(); return; } @@ -752,9 +746,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3 wined3d_device_set_depth_stencil_state(device->wined3d_device, state_impl->wined3d_state); desc = &state_impl->desc;
- if (desc->DepthEnable) - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZFUNC, desc->DepthFunc); - if (desc->StencilEnable) { wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILREF, stencil_ref); @@ -6114,8 +6105,6 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par device->wined3d_device = wined3d_device;
device->feature_level = d3d_feature_level_from_wined3d(wined3d_device_get_feature_level(wined3d_device)); - - set_default_depth_stencil_state(wined3d_device); }
static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent) diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 9ed812da1ed..737dae93848 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -796,6 +796,7 @@ HRESULT d3d_depthstencil_state_create(struct d3d_device *device, const D3D11_DEP
wined3d_desc.depth = desc->DepthEnable; wined3d_desc.depth_write = desc->DepthWriteMask; + wined3d_desc.depth_func = desc->DepthFunc; wined3d_desc.stencil = desc->StencilEnable; wined3d_desc.stencil_read_mask = desc->StencilReadMask; wined3d_desc.stencil_write_mask = desc->StencilWriteMask; diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index debfa2218bc..799ec2601e6 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -107,7 +107,6 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] = {STATE_RENDER(WINED3D_RS_ROP2), {STATE_RENDER(WINED3D_RS_ROP2), state_nop}}, {STATE_RENDER(WINED3D_RS_PLANEMASK), {STATE_RENDER(WINED3D_RS_PLANEMASK), state_nop}}, {STATE_RENDER(WINED3D_RS_LASTPIXEL), {STATE_RENDER(WINED3D_RS_LASTPIXEL), state_nop}}, - {STATE_RENDER(WINED3D_RS_ZFUNC), {STATE_RENDER(WINED3D_RS_ZFUNC), state_nop}}, {STATE_RENDER(WINED3D_RS_DITHERENABLE), {STATE_RENDER(WINED3D_RS_DITHERENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_SUBPIXEL), {STATE_RENDER(WINED3D_RS_SUBPIXEL), state_nop}}, {STATE_RENDER(WINED3D_RS_SUBPIXELX), {STATE_RENDER(WINED3D_RS_SUBPIXELX), state_nop}}, @@ -117,7 +116,7 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] = {STATE_RENDER(WINED3D_RS_ANISOTROPY), {STATE_RENDER(WINED3D_RS_ANISOTROPY), state_nop}}, {STATE_RENDER(WINED3D_RS_FLUSHBATCH), {STATE_RENDER(WINED3D_RS_FLUSHBATCH), state_nop}}, {STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT), {STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT), state_nop}}, - {STATE_RENDER(WINED3D_RS_STENCILREF), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILREF), {STATE_RENDER(WINED3D_RS_STENCILREF), state_nop}}, {STATE_RENDER(WINED3D_RS_WRAP0), {STATE_RENDER(WINED3D_RS_WRAP0), state_nop}}, {STATE_RENDER(WINED3D_RS_WRAP1), {STATE_RENDER(WINED3D_RS_WRAP0)}}, {STATE_RENDER(WINED3D_RS_WRAP2), {STATE_RENDER(WINED3D_RS_WRAP0)}}, diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index f2a124eb9d8..aeb505ebfc6 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -2071,7 +2071,7 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte key->ds_desc.depthWriteEnable = VK_TRUE; key->ds_desc.stencilTestEnable = VK_FALSE; } - key->ds_desc.depthCompareOp = vk_compare_op_from_wined3d(state->render_states[WINED3D_RS_ZFUNC]); + key->ds_desc.depthCompareOp = vk_compare_op_from_wined3d(d->desc.depth_func);
update = true; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5ab3bf38501..b077d5317db 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3698,6 +3698,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, case WINED3D_RS_STENCILZFAIL: case WINED3D_RS_TWOSIDEDSTENCILMODE: case WINED3D_RS_ZENABLE: + case WINED3D_RS_ZFUNC: case WINED3D_RS_ZWRITEENABLE: set_depth_stencil_state = TRUE; break; @@ -3853,6 +3854,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, FIXME("Unrecognized depth buffer type %#x.\n", state->rs[WINED3D_RS_ZENABLE]); } desc.depth_write = state->rs[WINED3D_RS_ZWRITEENABLE]; + desc.depth_func = state->rs[WINED3D_RS_ZFUNC]; desc.stencil = state->rs[WINED3D_RS_STENCILENABLE]; desc.stencil_read_mask = state->rs[WINED3D_RS_STENCILMASK]; desc.stencil_write_mask = state->rs[WINED3D_RS_STENCILWRITEMASK]; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 3199da09180..71f7ac53a2f 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -388,17 +388,6 @@ GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) } }
-static void state_zfunc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) -{ - GLenum depth_func = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ZFUNC]); - const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - - if (!depth_func) return; - - gl_info->gl_ops.gl.p_glDepthFunc(depth_func); - checkGLcall("glDepthFunc"); -} - static void state_ambient(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; @@ -1161,6 +1150,7 @@ static void depth(struct wined3d_context *context, const struct wined3d_state *s const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; const struct wined3d_depth_stencil_state *d = state->depth_stencil_state; BOOL enable_depth = d ? d->desc.depth : TRUE; + GLenum depth_func = GL_LESS;
if (!state->fb.depth_stencil) { @@ -1190,6 +1180,14 @@ static void depth(struct wined3d_context *context, const struct wined3d_state *s checkGLcall("glDepthMask(GL_FALSE)"); }
+ if (d) + depth_func = wined3d_gl_compare_func(d->desc.depth_func); + if (depth_func) + { + gl_info->gl_ops.gl.p_glDepthFunc(depth_func); + checkGLcall("glDepthFunc"); + } + if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); } @@ -4754,7 +4752,6 @@ const struct wined3d_state_entry_template misc_state_template_gl[] = { STATE_RENDER(WINED3D_RS_ROP2), { STATE_RENDER(WINED3D_RS_ROP2), state_rop2 }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_PLANEMASK), { STATE_RENDER(WINED3D_RS_PLANEMASK), state_planemask }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_LASTPIXEL), { STATE_RENDER(WINED3D_RS_LASTPIXEL), state_lastpixel }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_ZFUNC), { STATE_RENDER(WINED3D_RS_ZFUNC), state_zfunc }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_DITHERENABLE), { STATE_RENDER(WINED3D_RS_DITHERENABLE), state_ditherenable }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_SUBPIXEL), { STATE_RENDER(WINED3D_RS_SUBPIXEL), state_subpixel }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_SUBPIXELX), { STATE_RENDER(WINED3D_RS_SUBPIXELX), state_subpixelx }, WINED3D_GL_EXT_NONE }, @@ -5558,7 +5555,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 3, 3}, { 7, 8}, { 14, 14}, - { 17, 22}, + { 17, 23}, { 27, 27}, { 40, 40}, { 42, 45}, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 225ce14e70b..3535a69bacb 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2048,6 +2048,7 @@ struct wined3d_depth_stencil_state_desc { BOOL depth; BOOL depth_write; + enum wined3d_cmp_func depth_func; BOOL stencil; unsigned int stencil_read_mask; unsigned int stencil_write_mask;