[PATCH 2/4] wined3d: Store whether a depth/stencil state writes to the depth/stencil buffer in the state itself.

Zebediah Figura zfigura at codeweavers.com
Thu Jun 2 20:23:48 CDT 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/wined3d/context_gl.c      | 2 +-
 dlls/wined3d/context_vk.c      | 2 +-
 dlls/wined3d/state.c           | 7 +++++++
 dlls/wined3d/wined3d_private.h | 2 ++
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index b9964b1fd86..721ffdc3c09 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -5172,7 +5172,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
         return;
     }
 
-    if (dsv && (!state->depth_stencil_state || state->depth_stencil_state->desc.depth_write))
+    if (dsv && (!state->depth_stencil_state || state->depth_stencil_state->writes_ds))
     {
         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 c257b5f3c86..a9b875a132e 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -3455,7 +3455,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c
             wined3d_rendertarget_view_prepare_location(dsv, &context_vk->c, dsv->resource->draw_binding);
         }
 
-        if (!state->depth_stencil_state || state->depth_stencil_state->desc.depth_write)
+        if (!state->depth_stencil_state || state->depth_stencil_state->writes_ds)
             invalidate_ds = true;
 
         sample_count = max(1, wined3d_resource_get_sample_count(dsv->resource));
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 56fd759e5e2..228b4901c00 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -146,6 +146,11 @@ void * CDECL wined3d_depth_stencil_state_get_parent(const struct wined3d_depth_s
     return state->parent;
 }
 
+static bool depth_stencil_state_desc_writes_ds(const struct wined3d_depth_stencil_state_desc *desc)
+{
+    return desc->depth_write;
+}
+
 HRESULT CDECL wined3d_depth_stencil_state_create(struct wined3d_device *device,
         const struct wined3d_depth_stencil_state_desc *desc, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_depth_stencil_state **state)
@@ -164,6 +169,8 @@ HRESULT CDECL wined3d_depth_stencil_state_create(struct wined3d_device *device,
     object->parent_ops = parent_ops;
     object->device = device;
 
+    object->writes_ds = depth_stencil_state_desc_writes_ds(desc);
+
     TRACE("Created depth/stencil state %p.\n", object);
     *state = object;
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c1ec05a28c6..affef24d353 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3779,6 +3779,8 @@ struct wined3d_depth_stencil_state
     LONG refcount;
     struct wined3d_depth_stencil_state_desc desc;
 
+    bool writes_ds;
+
     void *parent;
     const struct wined3d_parent_ops *parent_ops;
 
-- 
2.36.1




More information about the wine-devel mailing list