Zebediah Figura : wined3d: Factor out wined3d_state_uses_depth_buffer().

Alexandre Julliard julliard at winehq.org
Thu Sep 24 15:49:05 CDT 2020


Module: wine
Branch: master
Commit: 8b4e07d5f3ab3c02061530600a81323151892172
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8b4e07d5f3ab3c02061530600a81323151892172

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Sep 23 23:51:57 2020 -0500

wined3d: Factor out wined3d_state_uses_depth_buffer().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/context_gl.c      | 2 +-
 dlls/wined3d/context_vk.c      | 8 +++-----
 dlls/wined3d/device.c          | 3 +--
 dlls/wined3d/wined3d_private.h | 5 +++++
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index b7ca8ceca2..e3eae3aab5 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -4491,7 +4491,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->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE])
+        if (wined3d_state_uses_depth_buffer(state))
             wined3d_rendertarget_view_load_location(dsv, context, location);
         else
             wined3d_rendertarget_view_prepare_location(dsv, context, location);
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c
index a7c77dd5a6..aef2430208 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -2138,8 +2138,7 @@ static bool wined3d_context_vk_begin_render_pass(struct wined3d_context_vk *cont
         ++attachment_count;
     }
 
-    if ((state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE])
-            && (view = state->fb.depth_stencil))
+    if (wined3d_state_uses_depth_buffer(state) && (view = state->fb.depth_stencil))
     {
         rtv_vk = wined3d_rendertarget_view_vk(view);
         vk_views[attachment_count] = wined3d_rendertarget_view_vk_get_image_view(rtv_vk, context_vk);
@@ -2155,8 +2154,7 @@ static bool wined3d_context_vk_begin_render_pass(struct wined3d_context_vk *cont
     }
 
     if (!(context_vk->vk_render_pass = wined3d_context_vk_get_render_pass(context_vk, &state->fb,
-            ARRAY_SIZE(state->fb.render_targets), state->render_states[WINED3D_RS_ZWRITEENABLE]
-            || state->render_states[WINED3D_RS_ZENABLE], 0)))
+            ARRAY_SIZE(state->fb.render_targets), wined3d_state_uses_depth_buffer(state), 0)))
     {
         ERR("Failed to get render pass.\n");
         return false;
@@ -2845,7 +2843,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c
 
     if ((dsv = state->fb.depth_stencil))
     {
-        if (state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE])
+        if (wined3d_state_uses_depth_buffer(state))
             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);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 13d8bce1ac..3fce04673a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4264,8 +4264,7 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device
         }
     }
 
-    if (state->render_states[WINED3D_RS_ZENABLE] || state->render_states[WINED3D_RS_ZWRITEENABLE]
-            || state->render_states[WINED3D_RS_STENCILENABLE])
+    if (wined3d_state_uses_depth_buffer(state) || 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/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 2be81ee2a0..0ed1f13381 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3624,6 +3624,11 @@ struct wined3d_state
     struct wined3d_rasterizer_state *rasterizer_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];
+}
+
 struct wined3d_dummy_textures
 {
     GLuint tex_1d;




More information about the wine-cvs mailing list