From 8b4e07d5f3ab3c02061530600a81323151892172 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 23 Sep 2020 23:51:57 -0500 Subject: [PATCH] wined3d: Factor out wined3d_state_uses_depth_buffer(). Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- 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 b7ca8ceca2e..e3eae3aab58 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 a7c77dd5a6b..aef24302087 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 13d8bce1acc..3fce04673aa 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 2be81ee2a0f..0ed1f133812 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;