[PATCH 5/5] wined3d: Move the depth write mask state to wined3d_depth_stencil_state.
Chip Davis
cdavis at codeweavers.com
Mon Apr 13 02:27:27 CDT 2020
Signed-off-by: Chip Davis <cdavis at codeweavers.com>
---
dlls/d3d11/device.c | 2 --
dlls/d3d11/state.c | 1 +
dlls/wined3d/context.c | 4 ++--
dlls/wined3d/device.c | 6 ++++--
dlls/wined3d/state.c | 29 ++++++++++++-----------------
dlls/wined3d/surface.c | 2 +-
include/wine/wined3d.h | 1 +
7 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index ed290750ac3..72203ee80c0 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,7 +758,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3
wined3d_device_set_depth_stencil_state(device->wined3d_device, device->depth_stencil_state->wined3d_state);
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);
}
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c
index 6d3736a1d95..503842dce0b 100644
--- a/dlls/d3d11/state.c
+++ b/dlls/d3d11/state.c
@@ -710,6 +710,7 @@ static HRESULT d3d_depthstencil_state_init(struct d3d_depthstencil_state *state,
HRESULT hr;
wined3d_desc.depth = desc->DepthEnable;
+ wined3d_desc.depth_writemask = desc->DepthWriteMask;
if (wine_rb_put(&device->depthstencil_states, desc, &state->entry) == -1)
{
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e280b6cd91b..81a51b51ce7 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -5193,7 +5193,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
* that we never copy the stencil data.*/
DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE;
- if (!state->depth_stencil_state || state->render_states[WINED3D_RS_ZWRITEENABLE]
+ if (!state->depth_stencil_state || state->depth_stencil_state->desc.depth_writemask
|| state->depth_stencil_state->desc.depth)
wined3d_rendertarget_view_load_location(dsv, context, location);
else
@@ -5210,7 +5210,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_writemask))
{
DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 3993b2a6fcf..1b7cfd062ee 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -399,7 +399,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
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;
@@ -3652,6 +3652,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;
@@ -3794,6 +3795,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
memset(&desc, 0, sizeof(desc));
desc.depth = state->rs[WINED3D_RS_ZENABLE];
+ desc.depth_writemask = state->rs[WINED3D_RS_ZWRITEENABLE];
if ((entry = wine_rb_get(&device->depth_stencil_states, &desc)))
{
@@ -4314,7 +4316,7 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device
}
if (!state->depth_stencil_state || state->depth_stencil_state->desc.depth
- || state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_STENCILENABLE])
+ || state->depth_stencil_state->desc.depth_writemask || state->render_states[WINED3D_RS_STENCILENABLE])
{
struct wined3d_rendertarget_view *rt = device->state.fb.render_targets[0];
struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index decfd996566..dcb7840fa10 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -324,6 +324,17 @@ static void depth(struct wined3d_context *context, const struct wined3d_state *s
break;
}
+ if (!ds || ds->desc.depth_writemask)
+ {
+ gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE);
+ checkGLcall("glDepthMask TRUE");
+ }
+ else
+ {
+ gl_info->gl_ops.gl.p_glDepthMask(GL_FALSE);
+ checkGLcall("glDepthMask FALSE");
+ }
+
if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)))
context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION));
}
@@ -401,22 +412,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)
@@ -4745,7 +4740,6 @@ const struct wined3d_state_entry_template misc_state_template[] =
{ 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 },
@@ -5561,6 +5555,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/surface.c b/dlls/wined3d/surface.c
index e965203950e..c10c2039cc7 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -117,7 +117,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)
{
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 55dad1bfd6b..7f5aa5cb038 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2036,6 +2036,7 @@ struct wined3d_blend_state_desc
struct wined3d_depth_stencil_state_desc
{
enum wined3d_depth_buffer_type depth;
+ unsigned int depth_writemask;
};
struct wined3d_rasterizer_state_desc
--
2.24.0
More information about the wine-devel
mailing list