Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/d3d11_private.h | 2 +- dlls/d3d11/device.c | 23 +++++++++--- dlls/d3d11/state.c | 75 ++++++++++++++++++++++++-------------- 3 files changed, 66 insertions(+), 34 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index cb2b9c3aedc..3248285fcda 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -440,6 +440,7 @@ struct d3d_depthstencil_state LONG refcount;
struct wined3d_private_store private_store; + struct wined3d_depth_stencil_state *wined3d_state; D3D11_DEPTH_STENCIL_DESC desc; struct wine_rb_entry entry; ID3D11Device2 *device; @@ -549,7 +550,6 @@ struct d3d_device struct wine_rb_tree rasterizer_states; struct wine_rb_tree sampler_states;
- struct d3d_depthstencil_state *depth_stencil_state; UINT stencil_ref; };
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 2a68e025852..055e243a439 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -737,6 +737,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3 { struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); const D3D11_DEPTH_STENCILOP_DESC *front, *back; + struct d3d_depthstencil_state *state_impl; const D3D11_DEPTH_STENCIL_DESC *desc;
TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n", @@ -744,14 +745,16 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3
wined3d_mutex_lock(); device->stencil_ref = stencil_ref; - if (!(device->depth_stencil_state = unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state))) + 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; }
- desc = &device->depth_stencil_state->desc; + wined3d_device_set_depth_stencil_state(device->wined3d_device, state_impl->wined3d_state); + desc = &state_impl->desc;
front = &desc->FrontFace; back = &desc->BackFace; @@ -1904,14 +1907,24 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3 ID3D11DepthStencilState **depth_stencil_state, UINT *stencil_ref) { struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct wined3d_depth_stencil_state *wined3d_state; + struct d3d_depthstencil_state *state_impl;
TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n", iface, depth_stencil_state, stencil_ref);
- if ((*depth_stencil_state = device->depth_stencil_state - ? &device->depth_stencil_state->ID3D11DepthStencilState_iface : NULL)) - ID3D11DepthStencilState_AddRef(*depth_stencil_state); + wined3d_mutex_lock(); + if ((wined3d_state = wined3d_device_get_depth_stencil_state(device->wined3d_device))) + { + state_impl = wined3d_depth_stencil_state_get_parent(wined3d_state); + ID3D11DepthStencilState_AddRef(*depth_stencil_state = &state_impl->ID3D11DepthStencilState_iface); + } + else + { + *depth_stencil_state = NULL; + } *stencil_ref = device->stencil_ref; + wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext1 *iface, diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 32ef44091c4..5d4c3526595 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -493,13 +493,15 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_AddRef(ID3D11DepthStenci
TRACE("%p increasing refcount to %u.\n", state, refcount);
- return refcount; -} + if (refcount == 1) + { + ID3D11Device2_AddRef(state->device); + wined3d_mutex_lock(); + wined3d_depth_stencil_state_incref(state->wined3d_state); + wined3d_mutex_unlock(); + }
-static void d3d_depthstencil_state_cleanup(struct d3d_depthstencil_state *state) -{ - wined3d_private_store_cleanup(&state->private_store); - ID3D11Device2_Release(state->device); + return refcount; }
static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_Release(ID3D11DepthStencilState *iface) @@ -511,12 +513,12 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_Release(ID3D11DepthStenc
if (!refcount) { - struct d3d_device *device = impl_from_ID3D11Device2(state->device); + ID3D11Device2 *device = state->device; + wined3d_mutex_lock(); - wine_rb_remove(&device->depthstencil_states, &state->entry); - d3d_depthstencil_state_cleanup(state); + wined3d_depth_stencil_state_decref(state->wined3d_state); wined3d_mutex_unlock(); - heap_free(state); + ID3D11Device2_Release(device); }
return refcount; @@ -695,23 +697,25 @@ static const struct ID3D10DepthStencilStateVtbl d3d10_depthstencil_state_vtbl = d3d10_depthstencil_state_GetDesc, };
-static HRESULT d3d_depthstencil_state_init(struct d3d_depthstencil_state *state, struct d3d_device *device, - const D3D11_DEPTH_STENCIL_DESC *desc) +static void STDMETHODCALLTYPE d3d_depthstencil_state_wined3d_object_destroyed(void *parent) { - state->ID3D11DepthStencilState_iface.lpVtbl = &d3d11_depthstencil_state_vtbl; - state->ID3D10DepthStencilState_iface.lpVtbl = &d3d10_depthstencil_state_vtbl; - state->refcount = 1; - wined3d_private_store_init(&state->private_store); - state->desc = *desc; - - ID3D11Device2_AddRef(state->device = &device->ID3D11Device2_iface); + struct d3d_depthstencil_state *state = parent; + struct d3d_device *device = impl_from_ID3D11Device2(state->device);
- return S_OK; + wine_rb_remove(&device->depthstencil_states, &state->entry); + wined3d_private_store_cleanup(&state->private_store); + heap_free(parent); }
+static const struct wined3d_parent_ops d3d_depthstencil_state_wined3d_parent_ops = +{ + d3d_depthstencil_state_wined3d_object_destroyed, +}; + HRESULT d3d_depthstencil_state_create(struct d3d_device *device, const D3D11_DEPTH_STENCIL_DESC *desc, struct d3d_depthstencil_state **state) { + struct wined3d_depth_stencil_state_desc wined3d_desc; struct d3d_depthstencil_state *object; D3D11_DEPTH_STENCIL_DESC tmp_desc; struct wine_rb_entry *entry; @@ -775,25 +779,40 @@ HRESULT d3d_depthstencil_state_create(struct d3d_device *device, const D3D11_DEP return E_OUTOFMEMORY; }
- if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc))) + object->ID3D11DepthStencilState_iface.lpVtbl = &d3d11_depthstencil_state_vtbl; + object->ID3D10DepthStencilState_iface.lpVtbl = &d3d10_depthstencil_state_vtbl; + object->refcount = 1; + wined3d_private_store_init(&object->private_store); + object->desc = tmp_desc; + + if (wine_rb_put(&device->depthstencil_states, &tmp_desc, &object->entry) == -1) { - WARN("Failed to initialize depthstencil state, hr %#x.\n", hr); + ERR("Failed to insert depth/stencil state entry.\n"); + wined3d_private_store_cleanup(&object->private_store); heap_free(object); wined3d_mutex_unlock(); - return hr; + return E_FAIL; }
- if (wine_rb_put(&device->depthstencil_states, &tmp_desc, &object->entry) == -1) + wined3d_desc.depth = desc->DepthEnable; + + /* We cannot fail after creating a wined3d_depth_stencil_state object. It + * would lead to double free. */ + if (FAILED(hr = wined3d_depth_stencil_state_create(device->wined3d_device, &wined3d_desc, + object, &d3d_depthstencil_state_wined3d_parent_ops, &object->wined3d_state))) { - ERR("Failed to insert depthstencil state entry.\n"); - d3d_depthstencil_state_cleanup(object); + WARN("Failed to create wined3d depth/stencil state, hr %#x.\n", hr); + wined3d_private_store_cleanup(&object->private_store); + wine_rb_remove(&device->depthstencil_states, &object->entry); heap_free(object); wined3d_mutex_unlock(); - return E_FAIL; + return hr; } wined3d_mutex_unlock();
- TRACE("Created depthstencil state %p.\n", object); + ID3D11Device2_AddRef(object->device = &device->ID3D11Device2_iface); + + TRACE("Created depth/stencil state %p.\n", object); *state = object;
return S_OK;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 2 -- dlls/wined3d/adapter_vk.c | 31 +++++++++++------------ dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/context_vk.c | 13 ++++++++-- dlls/wined3d/cs.c | 2 +- dlls/wined3d/device.c | 46 +++++++++++++++++++++++++++++++++- dlls/wined3d/directx.c | 1 - dlls/wined3d/state.c | 39 +--------------------------- dlls/wined3d/utils.c | 4 +-- dlls/wined3d/wined3d_private.h | 3 ++- 10 files changed, 78 insertions(+), 65 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 055e243a439..ca9975d6a22 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -726,7 +726,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi
static void set_default_depth_stencil_state(struct wined3d_device *wined3d_device) { - wined3d_device_set_render_state(wined3d_device, WINED3D_RS_ZENABLE, TRUE); wined3d_device_set_render_state(wined3d_device, WINED3D_RS_ZWRITEENABLE, D3D11_DEPTH_WRITE_MASK_ALL); wined3d_device_set_render_state(wined3d_device, WINED3D_RS_ZFUNC, WINED3D_CMP_LESS); wined3d_device_set_render_state(wined3d_device, WINED3D_RS_STENCILENABLE, FALSE); @@ -759,7 +758,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3 front = &desc->FrontFace; back = &desc->BackFace;
- wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE, desc->DepthEnable); if (desc->DepthEnable) { wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZWRITEENABLE, desc->DepthWriteMask); diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index f3a8d8f89db..7b0c0c89897 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -100,16 +100,15 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] = {STATE_INDEXBUFFER, {STATE_INDEXBUFFER, state_nop}}, {STATE_RENDER(WINED3D_RS_ANTIALIAS), {STATE_RENDER(WINED3D_RS_ANTIALIAS), state_nop}}, {STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE), {STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE), state_nop}}, - {STATE_RENDER(WINED3D_RS_ZENABLE), {STATE_RENDER(WINED3D_RS_ZENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_WRAPU), {STATE_RENDER(WINED3D_RS_WRAPU), state_nop}}, {STATE_RENDER(WINED3D_RS_WRAPV), {STATE_RENDER(WINED3D_RS_WRAPV), state_nop}}, {STATE_RENDER(WINED3D_RS_LINEPATTERN), {STATE_RENDER(WINED3D_RS_LINEPATTERN), state_nop}}, {STATE_RENDER(WINED3D_RS_MONOENABLE), {STATE_RENDER(WINED3D_RS_MONOENABLE), state_nop}}, {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_ZWRITEENABLE), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, + {STATE_RENDER(WINED3D_RS_ZWRITEENABLE), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_LASTPIXEL), {STATE_RENDER(WINED3D_RS_LASTPIXEL), state_nop}}, - {STATE_RENDER(WINED3D_RS_ZFUNC), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, + {STATE_RENDER(WINED3D_RS_ZFUNC), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, {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}}, @@ -119,19 +118,19 @@ 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_STENCILENABLE), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILREF), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILMASK), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILWRITEMASK), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILENABLE), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILREF), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILMASK), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILWRITEMASK), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, {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_gl.c b/dlls/wined3d/context_gl.c index e3eae3aab58..186d70b45ad 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2818,7 +2818,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHATESTENABLE)); } gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZENABLE)); + context_invalidate_state(context, STATE_DEPTH_STENCIL); gl_info->gl_ops.gl.p_glDisable(GL_BLEND); gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); context_invalidate_state(context, STATE_BLEND); diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index a4f5f317f1f..356fec27a78 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -2034,10 +2034,19 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte update = true; }
- if (wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_RENDER(WINED3D_RS_ZENABLE)) + if (wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_DEPTH_STENCIL) || wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_FRAMEBUFFER)) { - key->ds_desc.depthTestEnable = !!state->render_states[WINED3D_RS_ZENABLE]; + const struct wined3d_depth_stencil_state *d = state->depth_stencil_state; + + if (d) + { + key->ds_desc.depthTestEnable = d->desc.depth; + } + else + { + key->ds_desc.depthTestEnable = VK_TRUE; + } key->ds_desc.depthWriteEnable = !!state->render_states[WINED3D_RS_ZWRITEENABLE]; key->ds_desc.depthCompareOp = vk_compare_op_from_wined3d(state->render_states[WINED3D_RS_ZFUNC]); key->ds_desc.stencilTestEnable = state->fb.depth_stencil && state->render_states[WINED3D_RS_STENCILENABLE]; diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index d6a78cc5d65..6509887afa9 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1226,7 +1226,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const if (!prev != !op->view) { /* Swapping NULL / non NULL depth stencil affects the depth and tests */ - device_invalidate_state(device, STATE_RENDER(WINED3D_RS_ZENABLE)); + device_invalidate_state(device, STATE_DEPTH_STENCIL); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILENABLE)); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK)); device_invalidate_state(device, STATE_RASTERIZER); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index a59a1efeab7..38b488cba81 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3576,10 +3576,10 @@ static void wined3d_device_set_texture(struct wined3d_device *device, void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock) { + BOOL set_blend_state = FALSE, set_depth_stencil_state = FALSE, set_rasterizer_state = FALSE; const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; const struct wined3d_saved_states *changed = &stateblock->changed; const unsigned int word_bit_count = sizeof(DWORD) * CHAR_BIT; - BOOL set_blend_state = FALSE, set_rasterizer_state = FALSE; unsigned int i, j, start, idx; struct wined3d_range range; uint32_t map; @@ -3684,6 +3684,10 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, set_blend_state = TRUE; break;
+ case WINED3D_RS_ZENABLE: + set_depth_stencil_state = TRUE; + break; + case WINED3D_RS_FILLMODE: case WINED3D_RS_CULLMODE: case WINED3D_RS_SLOPESCALEDEPTHBIAS: @@ -3812,6 +3816,46 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } }
+ if (set_depth_stencil_state) + { + struct wined3d_depth_stencil_state *depth_stencil_state; + struct wined3d_depth_stencil_state_desc desc; + struct wine_rb_entry *entry; + + memset(&desc, 0, sizeof(desc)); + switch (state->rs[WINED3D_RS_ZENABLE]) + { + case WINED3D_ZB_FALSE: + desc.depth = FALSE; + break; + + case WINED3D_ZB_USEW: + FIXME("W buffer is not well handled.\n"); + case WINED3D_ZB_TRUE: + desc.depth = TRUE; + break; + + default: + FIXME("Unrecognized depth buffer type %#x.\n", state->rs[WINED3D_RS_ZENABLE]); + } + + if ((entry = wine_rb_get(&device->depth_stencil_states, &desc))) + { + depth_stencil_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_depth_stencil_state, entry); + wined3d_device_set_depth_stencil_state(device, depth_stencil_state); + } + else if (SUCCEEDED(wined3d_depth_stencil_state_create(device, &desc, NULL, + &wined3d_null_parent_ops, &depth_stencil_state))) + { + wined3d_device_set_depth_stencil_state(device, depth_stencil_state); + if (wine_rb_put(&device->depth_stencil_states, &desc, &depth_stencil_state->entry) == -1) + { + ERR("Failed to insert depth/stencil state.\n"); + wined3d_depth_stencil_state_decref(depth_stencil_state); + } + } + } + for (i = 0; i < ARRAY_SIZE(changed->textureState); ++i) { map = changed->textureState[i]; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index cd05c264645..fced1eb110c 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2422,7 +2422,6 @@ static const struct wined3d_state_entry_template misc_state_template_no3d[] = {STATE_INDEXBUFFER, {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_ANTIALIAS), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE), {STATE_VDECL}}, - {STATE_RENDER(WINED3D_RS_ZENABLE), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_WRAPU), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_WRAPV), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_LINEPATTERN), {STATE_VDECL}}, diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index ac3afe881d6..d77722c00d4 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -291,42 +291,6 @@ static void state_lighting(struct wined3d_context *context, const struct wined3d } }
-static void state_zenable(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) -{ - enum wined3d_depth_buffer_type zenable = state->render_states[WINED3D_RS_ZENABLE]; - const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - - /* No z test without depth stencil buffers */ - if (!state->fb.depth_stencil) - { - TRACE("No Z buffer - disabling depth test\n"); - zenable = WINED3D_ZB_FALSE; - } - - switch (zenable) - { - case WINED3D_ZB_FALSE: - gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST); - checkGLcall("glDisable GL_DEPTH_TEST"); - break; - case WINED3D_ZB_TRUE: - gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_TEST); - checkGLcall("glEnable GL_DEPTH_TEST"); - break; - case WINED3D_ZB_USEW: - gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_TEST); - checkGLcall("glEnable GL_DEPTH_TEST"); - FIXME("W buffer is not well handled\n"); - break; - default: - FIXME("Unrecognized depth buffer type %#x.\n", zenable); - break; - } - - if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) - context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); -} - static void cullmode(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info) { enum wined3d_cull mode = r ? r->desc.cull_mode : WINED3D_CULL_BACK; @@ -4780,7 +4744,6 @@ const struct wined3d_state_entry_template misc_state_template_gl[] = { STATE_INDEXBUFFER, { STATE_INDEXBUFFER, state_nop }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_ANTIALIAS), { STATE_RENDER(WINED3D_RS_ANTIALIAS), state_antialias }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE), { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE), state_nop }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_ZENABLE), { STATE_RENDER(WINED3D_RS_ZENABLE), state_zenable }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_WRAPU), { STATE_RENDER(WINED3D_RS_WRAPU), state_wrapu }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_WRAPV), { STATE_RENDER(WINED3D_RS_WRAPV), state_wrapv }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_LINEPATTERN), { STATE_RENDER(WINED3D_RS_LINEPATTERN), state_linepattern }, WINED3D_GL_LEGACY_CONTEXT }, @@ -5605,7 +5568,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { { 1, 1}, { 3, 3}, - { 8, 8}, + { 7, 8}, { 17, 22}, { 27, 27}, { 40, 40}, diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 8d790c52945..01a838db897 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5446,8 +5446,8 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w float y_offset = flip ? (center_offset - (2.0f * y) - h) / h : (center_offset - (2.0f * y) - h) / -h; - enum wined3d_depth_buffer_type zenable = state->fb.depth_stencil ? - state->render_states[WINED3D_RS_ZENABLE] : WINED3D_ZB_FALSE; + bool zenable = state->fb.depth_stencil ? + (state->depth_stencil_state ? state->depth_stencil_state->desc.depth : true) : false; float z_scale = zenable ? clip_control ? 1.0f : 2.0f : 0.0f; float z_offset = zenable ? clip_control ? 0.0f : -1.0f : 0.0f; const struct wined3d_matrix projection = diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 177d4d01337..da3974973a1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3643,7 +3643,8 @@ struct wined3d_state
static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state) { - return state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE]; + return state->render_states[WINED3D_RS_ZWRITEENABLE] + || !state->depth_stencil_state || state->depth_stencil_state->desc.depth; }
struct wined3d_dummy_textures
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79327
Your paranoid android.
=== debiant (build log) ===
../wine/dlls/d3d11/state.c:718:45: error: storage size of ‘wined3d_desc’ isn’t known Task: The win32 Wine build failed
=== debiant (build log) ===
../wine/dlls/d3d11/state.c:718:45: error: storage size of ‘wined3d_desc’ isn’t known Task: The wow64 Wine build failed
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 4 ---- dlls/d3d11/state.c | 1 + dlls/wined3d/adapter_vk.c | 29 ++++++++++++++--------------- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/context_vk.c | 5 +++-- dlls/wined3d/device.c | 2 ++ dlls/wined3d/directx.c | 1 - dlls/wined3d/state.c | 29 ++++++++++++----------------- dlls/wined3d/texture.c | 4 ++-- dlls/wined3d/wined3d_private.h | 5 +++-- include/wine/wined3d.h | 1 + 11 files changed, 39 insertions(+), 44 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index ca9975d6a22..a8cba49e039 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -726,7 +726,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi
static void set_default_depth_stencil_state(struct wined3d_device *wined3d_device) { - wined3d_device_set_render_state(wined3d_device, WINED3D_RS_ZWRITEENABLE, D3D11_DEPTH_WRITE_MASK_ALL); wined3d_device_set_render_state(wined3d_device, WINED3D_RS_ZFUNC, WINED3D_CMP_LESS); wined3d_device_set_render_state(wined3d_device, WINED3D_RS_STENCILENABLE, FALSE); } @@ -759,10 +758,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3 back = &desc->BackFace;
if (desc->DepthEnable) - { - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZWRITEENABLE, desc->DepthWriteMask); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZFUNC, desc->DepthFunc); - }
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILENABLE, desc->StencilEnable); if (desc->StencilEnable) diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 5d4c3526595..d0513543c80 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -795,6 +795,7 @@ HRESULT d3d_depthstencil_state_create(struct d3d_device *device, const D3D11_DEP }
wined3d_desc.depth = desc->DepthEnable; + wined3d_desc.depth_write = desc->DepthWriteMask;
/* We cannot fail after creating a wined3d_depth_stencil_state object. It * would lead to double free. */ diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 7b0c0c89897..2045cf181cb 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -106,9 +106,8 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] = {STATE_RENDER(WINED3D_RS_MONOENABLE), {STATE_RENDER(WINED3D_RS_MONOENABLE), state_nop}}, {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_ZWRITEENABLE), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_LASTPIXEL), {STATE_RENDER(WINED3D_RS_LASTPIXEL), state_nop}}, - {STATE_RENDER(WINED3D_RS_ZFUNC), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {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}}, @@ -118,19 +117,19 @@ 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_STENCILENABLE), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILREF), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILMASK), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_STENCILWRITEMASK), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, - {STATE_RENDER(WINED3D_RS_BACK_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZWRITEENABLE)}}, + {STATE_RENDER(WINED3D_RS_STENCILENABLE), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILREF), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILMASK), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_STENCILWRITEMASK), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILFAIL), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILZFAIL), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILPASS), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, + {STATE_RENDER(WINED3D_RS_BACK_STENCILFUNC), {STATE_RENDER(WINED3D_RS_ZFUNC)}}, {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_gl.c b/dlls/wined3d/context_gl.c index 186d70b45ad..8c247afa02a 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -4507,7 +4507,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s return; }
- if (dsv && state->render_states[WINED3D_RS_ZWRITEENABLE]) + if (dsv && (!state->depth_stencil_state || state->depth_stencil_state->desc.depth_write)) { DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE;
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 356fec27a78..4a646504b3e 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -2042,12 +2042,13 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte if (d) { key->ds_desc.depthTestEnable = d->desc.depth; + key->ds_desc.depthWriteEnable = d->desc.depth_write; } else { key->ds_desc.depthTestEnable = VK_TRUE; + key->ds_desc.depthWriteEnable = VK_TRUE; } - key->ds_desc.depthWriteEnable = !!state->render_states[WINED3D_RS_ZWRITEENABLE]; key->ds_desc.depthCompareOp = vk_compare_op_from_wined3d(state->render_states[WINED3D_RS_ZFUNC]); key->ds_desc.stencilTestEnable = state->fb.depth_stencil && state->render_states[WINED3D_RS_STENCILENABLE]; if (key->ds_desc.stencilTestEnable) @@ -2862,7 +2863,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c wined3d_rendertarget_view_load_location(dsv, &context_vk->c, dsv->resource->draw_binding); else wined3d_rendertarget_view_prepare_location(dsv, &context_vk->c, dsv->resource->draw_binding); - if (state->render_states[WINED3D_RS_ZWRITEENABLE]) + if (!state->depth_stencil_state || state->depth_stencil_state->desc.depth_write) wined3d_rendertarget_view_invalidate_location(dsv, ~dsv->resource->draw_binding);
sample_count = max(1, wined3d_resource_get_sample_count(dsv->resource)); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 38b488cba81..c1c114b322d 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3685,6 +3685,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, break;
case WINED3D_RS_ZENABLE: + case WINED3D_RS_ZWRITEENABLE: set_depth_stencil_state = TRUE; break;
@@ -3838,6 +3839,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, default: FIXME("Unrecognized depth buffer type %#x.\n", state->rs[WINED3D_RS_ZENABLE]); } + desc.depth_write = state->rs[WINED3D_RS_ZWRITEENABLE];
if ((entry = wine_rb_get(&device->depth_stencil_states, &desc))) { diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index fced1eb110c..cf355438c45 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2428,7 +2428,6 @@ static const struct wined3d_state_entry_template misc_state_template_no3d[] = {STATE_RENDER(WINED3D_RS_MONOENABLE), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_ROP2), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_PLANEMASK), {STATE_VDECL}}, - {STATE_RENDER(WINED3D_RS_ZWRITEENABLE), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_LASTPIXEL), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_ZFUNC), {STATE_VDECL}}, {STATE_RENDER(WINED3D_RS_DITHERENABLE), {STATE_VDECL}}, diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index d77722c00d4..7a9e69f775c 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -359,22 +359,6 @@ static void state_ditherenable(struct wined3d_context *context, const struct win } }
-static void state_zwriteenable(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; - - if (state->render_states[WINED3D_RS_ZWRITEENABLE]) - { - gl_info->gl_ops.gl.p_glDepthMask(1); - checkGLcall("glDepthMask(1)"); - } - else - { - gl_info->gl_ops.gl.p_glDepthMask(0); - checkGLcall("glDepthMask(0)"); - } -} - GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) { switch (f) @@ -1226,6 +1210,17 @@ static void depth_stencil(struct wined3d_context *context, const struct wined3d_ checkGLcall("glDisable GL_DEPTH_TEST"); }
+ if (!d || d->desc.depth_write) + { + gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE); + checkGLcall("glDepthMask(GL_TRUE)"); + } + else + { + gl_info->gl_ops.gl.p_glDepthMask(GL_FALSE); + checkGLcall("glDepthMask(GL_FALSE)"); + } + if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); } @@ -4751,7 +4746,6 @@ const struct wined3d_state_entry_template misc_state_template_gl[] = { STATE_RENDER(WINED3D_RS_MONOENABLE), { STATE_RENDER(WINED3D_RS_MONOENABLE), state_monoenable }, WINED3D_GL_EXT_NONE }, { 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_ZWRITEENABLE), { STATE_RENDER(WINED3D_RS_ZWRITEENABLE), state_zwriteenable }, 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 }, @@ -5569,6 +5563,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 1, 1}, { 3, 3}, { 7, 8}, + { 14, 14}, { 17, 22}, { 27, 27}, { 40, 40}, diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 8e05c6ae194..911ee0e6262 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -505,7 +505,7 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct if (gl_mask & GL_DEPTH_BUFFER_BIT) { gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZWRITEENABLE)); + context_invalidate_state(context, STATE_DEPTH_STENCIL); } if (gl_mask & GL_STENCIL_BUFFER_BIT) { @@ -5403,7 +5403,7 @@ static void ffp_blitter_clear_rendertargets(struct wined3d_device *device, unsig if (flags & WINED3DCLEAR_ZBUFFER) { gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZWRITEENABLE)); + context_invalidate_state(context, STATE_DEPTH_STENCIL); gl_info->gl_ops.gl.p_glClearDepth(depth); checkGLcall("glClearDepth"); clear_mask = clear_mask | GL_DEPTH_BUFFER_BIT; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index da3974973a1..c44c4eac911 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3643,8 +3643,9 @@ struct wined3d_state
static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state) { - return state->render_states[WINED3D_RS_ZWRITEENABLE] - || !state->depth_stencil_state || state->depth_stencil_state->desc.depth; + if (!state->depth_stencil_state) + return true; + return state->depth_stencil_state->desc.depth || state->depth_stencil_state->desc.depth_write; }
struct wined3d_dummy_textures diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 77dbb775532..ef2a7de4580 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2039,6 +2039,7 @@ struct wined3d_blend_state_desc struct wined3d_depth_stencil_state_desc { BOOL depth; + BOOL depth_write; };
struct wined3d_rasterizer_state_desc
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79328
Your paranoid android.
=== debiant (build log) ===
error: patch failed: dlls/wined3d/state.c:1226 error: patch failed: include/wine/wined3d.h:2039 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/wined3d/state.c:1226 error: patch failed: include/wine/wined3d.h:2039 Task: Patch failed to apply
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79326
Your paranoid android.
=== debiant (build log) ===
../wine/dlls/d3d11/state.c:718:45: error: storage size of ‘wined3d_desc’ isn’t known Task: The win32 Wine build failed
=== debiant (build log) ===
../wine/dlls/d3d11/state.c:718:45: error: storage size of ‘wined3d_desc’ isn’t known Task: The wow64 Wine build failed