wined3d: Move the depth write enable state to wined3d_depth_stencil_state.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9bfc0f7094
commit
4a5760b28b
|
@ -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)
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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)}},
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -3686,6 +3686,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;
|
||||
|
||||
|
@ -3839,6 +3840,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)))
|
||||
{
|
||||
|
|
|
@ -2432,7 +2432,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}},
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue