Commit 8b4e07d5 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Factor out wined3d_state_uses_depth_buffer().

parent 2370e7b9
...@@ -4491,7 +4491,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s ...@@ -4491,7 +4491,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
* that we never copy the stencil data.*/ * that we never copy the stencil data.*/
DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE; 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); wined3d_rendertarget_view_load_location(dsv, context, location);
else else
wined3d_rendertarget_view_prepare_location(dsv, context, location); wined3d_rendertarget_view_prepare_location(dsv, context, location);
......
...@@ -2138,8 +2138,7 @@ static bool wined3d_context_vk_begin_render_pass(struct wined3d_context_vk *cont ...@@ -2138,8 +2138,7 @@ static bool wined3d_context_vk_begin_render_pass(struct wined3d_context_vk *cont
++attachment_count; ++attachment_count;
} }
if ((state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE]) if (wined3d_state_uses_depth_buffer(state) && (view = state->fb.depth_stencil))
&& (view = state->fb.depth_stencil))
{ {
rtv_vk = wined3d_rendertarget_view_vk(view); rtv_vk = wined3d_rendertarget_view_vk(view);
vk_views[attachment_count] = wined3d_rendertarget_view_vk_get_image_view(rtv_vk, context_vk); 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 ...@@ -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, 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] ARRAY_SIZE(state->fb.render_targets), wined3d_state_uses_depth_buffer(state), 0)))
|| state->render_states[WINED3D_RS_ZENABLE], 0)))
{ {
ERR("Failed to get render pass.\n"); ERR("Failed to get render pass.\n");
return false; return false;
...@@ -2845,7 +2843,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c ...@@ -2845,7 +2843,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c
if ((dsv = state->fb.depth_stencil)) 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); wined3d_rendertarget_view_load_location(dsv, &context_vk->c, dsv->resource->draw_binding);
else else
wined3d_rendertarget_view_prepare_location(dsv, &context_vk->c, dsv->resource->draw_binding); wined3d_rendertarget_view_prepare_location(dsv, &context_vk->c, dsv->resource->draw_binding);
......
...@@ -4264,8 +4264,7 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device ...@@ -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] if (wined3d_state_uses_depth_buffer(state) || state->render_states[WINED3D_RS_STENCILENABLE])
|| state->render_states[WINED3D_RS_STENCILENABLE])
{ {
struct wined3d_rendertarget_view *rt = device->state.fb.render_targets[0]; struct wined3d_rendertarget_view *rt = device->state.fb.render_targets[0];
struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil; struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil;
......
...@@ -3624,6 +3624,11 @@ struct wined3d_state ...@@ -3624,6 +3624,11 @@ struct wined3d_state
struct wined3d_rasterizer_state *rasterizer_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 struct wined3d_dummy_textures
{ {
GLuint tex_1d; GLuint tex_1d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment