[PATCH 1/4] wined3d: Factor out wined3d_state_uses_depth_buffer().
Zebediah Figura
z.figura12 at gmail.com
Wed Sep 23 23:51:57 CDT 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
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 ad72e51816d..249658b1093 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -2148,8 +2148,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);
@@ -2165,8 +2164,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;
@@ -2855,7 +2853,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 ec3b497f14c..355343b6b9e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3621,6 +3621,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;
--
2.28.0
More information about the wine-devel
mailing list