[PATCH 4/5] wined3d: Move the stencil read mask to wined3d_depth_stencil_state.

Zebediah Figura z.figura12 at gmail.com
Fri Sep 25 16:01:24 CDT 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d11/device.c       | 1 -
 dlls/d3d11/state.c        | 1 +
 dlls/wined3d/adapter_vk.c | 1 -
 dlls/wined3d/context_vk.c | 4 ++--
 dlls/wined3d/device.c     | 2 ++
 dlls/wined3d/directx.c    | 1 -
 dlls/wined3d/state.c      | 4 ++--
 include/wine/wined3d.h    | 1 +
 8 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index cac72e614e5..7ed8dc8bd71 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -761,7 +761,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3
 
     if (desc->StencilEnable)
     {
-        wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILMASK, desc->StencilReadMask);
         wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILWRITEMASK, desc->StencilWriteMask);
         wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILREF, stencil_ref);
 
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c
index 609c5e4c103..78540d35117 100644
--- a/dlls/d3d11/state.c
+++ b/dlls/d3d11/state.c
@@ -797,6 +797,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.stencil = desc->StencilEnable;
+    wined3d_desc.stencil_read_mask = desc->StencilReadMask;
 
     /* 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 9c9da418406..ee5390006a0 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -122,7 +122,6 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] =
     {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)}},
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c
index 6eaee71c54a..f91a1e2e8e9 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -2051,7 +2051,7 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte
                 key->ds_desc.front.depthFailOp = vk_stencil_op_from_wined3d(
                         state->render_states[WINED3D_RS_STENCILZFAIL]);
                 key->ds_desc.front.compareOp = vk_compare_op_from_wined3d(state->render_states[WINED3D_RS_STENCILFUNC]);
-                key->ds_desc.front.compareMask = state->render_states[WINED3D_RS_STENCILMASK];
+                key->ds_desc.front.compareMask = d->desc.stencil_read_mask;
                 key->ds_desc.front.writeMask = state->render_states[WINED3D_RS_STENCILWRITEMASK];
                 key->ds_desc.front.reference = state->render_states[WINED3D_RS_STENCILREF]
                         & ((1 << state->fb.depth_stencil->format->stencil_size) - 1);
@@ -2066,7 +2066,7 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte
                             state->render_states[WINED3D_RS_BACK_STENCILZFAIL]);
                     key->ds_desc.back.compareOp = vk_compare_op_from_wined3d(
                             state->render_states[WINED3D_RS_BACK_STENCILFUNC]);
-                    key->ds_desc.back.compareMask = state->render_states[WINED3D_RS_STENCILMASK];
+                    key->ds_desc.back.compareMask = d->desc.stencil_read_mask;
                     key->ds_desc.back.writeMask = state->render_states[WINED3D_RS_STENCILWRITEMASK];
                     key->ds_desc.back.reference = state->render_states[WINED3D_RS_STENCILREF]
                             & ((1 << state->fb.depth_stencil->format->stencil_size) - 1);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1dcf4fcb93c..054fc528383 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3686,6 +3686,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
                     break;
 
                 case WINED3D_RS_STENCILENABLE:
+                case WINED3D_RS_STENCILMASK:
                 case WINED3D_RS_ZENABLE:
                 case WINED3D_RS_ZWRITEENABLE:
                     set_depth_stencil_state = TRUE;
@@ -3843,6 +3844,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
         }
         desc.depth_write = state->rs[WINED3D_RS_ZWRITEENABLE];
         desc.stencil = state->rs[WINED3D_RS_STENCILENABLE];
+        desc.stencil_read_mask = state->rs[WINED3D_RS_STENCILMASK];
 
         if ((entry = wine_rb_get(&device->depth_stencil_states, &desc)))
         {
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 0395c8dc24b..6829fc9ef76 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2444,7 +2444,6 @@ static const struct wined3d_state_entry_template misc_state_template_no3d[] =
     {STATE_RENDER(WINED3D_RS_STENCILPASS),                {STATE_VDECL}},
     {STATE_RENDER(WINED3D_RS_STENCILFUNC),                {STATE_VDECL}},
     {STATE_RENDER(WINED3D_RS_STENCILREF),                 {STATE_VDECL}},
-    {STATE_RENDER(WINED3D_RS_STENCILMASK),                {STATE_VDECL}},
     {STATE_RENDER(WINED3D_RS_STENCILWRITEMASK),           {STATE_VDECL}},
     {STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE),        {STATE_VDECL}},
     {STATE_RENDER(WINED3D_RS_BACK_STENCILFAIL),           {STATE_VDECL}},
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 0f88b4a2677..32076289ac6 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1082,7 +1082,7 @@ static void state_stencil(struct wined3d_context *context, const struct wined3d_
         func = GL_ALWAYS;
     if (!(func_back = wined3d_gl_compare_func(state->render_states[WINED3D_RS_BACK_STENCILFUNC])))
         func_back = GL_ALWAYS;
-    mask = state->render_states[WINED3D_RS_STENCILMASK];
+    mask = d->desc.stencil_read_mask;
     ref = state->render_states[WINED3D_RS_STENCILREF] & ((1 << state->fb.depth_stencil->format->stencil_size) - 1);
     stencilFail = gl_stencil_op(state->render_states[WINED3D_RS_STENCILFAIL]);
     depthFail = gl_stencil_op(state->render_states[WINED3D_RS_STENCILZFAIL]);
@@ -4758,7 +4758,6 @@ const struct wined3d_state_entry_template misc_state_template_gl[] =
     { STATE_RENDER(WINED3D_RS_STENCILPASS),               { STATE_DEPTH_STENCIL,                                NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_STENCILFUNC),               { STATE_DEPTH_STENCIL,                                NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_STENCILREF),                { STATE_DEPTH_STENCIL,                                NULL                }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3D_RS_STENCILMASK),               { STATE_DEPTH_STENCIL,                                NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK),          { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK),          state_stencilwrite2s_ext}, EXT_STENCIL_TWO_SIDE        },
     { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK),          { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK),          state_stencilwrite  }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE),       { STATE_DEPTH_STENCIL,                                NULL                }, WINED3D_GL_EXT_NONE             },
@@ -5565,6 +5564,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table)
         { 42,  45},
         { 47,  47},
         { 52,  52},
+        { 58,  58},
         { 61, 127},
         {149, 150},
         {162, 162},
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index ad860a1eae2..e2db42766fb 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2041,6 +2041,7 @@ struct wined3d_depth_stencil_state_desc
     BOOL depth;
     BOOL depth_write;
     BOOL stencil;
+    unsigned int stencil_read_mask;
 };
 
 struct wined3d_rasterizer_state_desc
-- 
2.28.0




More information about the wine-devel mailing list