From db68c43678f28acebafaab1fc3608b3963dcc65f Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 9 Oct 2013 10:39:36 +0200 Subject: [PATCH] wined3d: Send clip plane updates through the command stream. --- dlls/wined3d/cs.c | 29 +++++++++++++++++++++++++++++ dlls/wined3d/device.c | 10 ++-------- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 16ffcf9bdf7..b6542bcaeb3 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -45,6 +45,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_TEXTURE_STATE, WINED3D_CS_OP_SET_SAMPLER_STATE, WINED3D_CS_OP_SET_TRANSFORM, + WINED3D_CS_OP_SET_CLIP_PLANE, }; struct wined3d_cs_present @@ -177,6 +178,13 @@ struct wined3d_cs_set_transform const struct wined3d_matrix *matrix; }; +struct wined3d_cs_set_clip_plane +{ + enum wined3d_cs_op opcode; + UINT plane_idx; + const struct wined3d_vec4 *plane; +}; + static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_present *op = data; @@ -691,6 +699,26 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform cs->ops->submit(cs); } +static void wined3d_cs_exec_set_clip_plane(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_clip_plane *op = data; + + cs->state.clip_planes[op->plane_idx] = *op->plane; + device_invalidate_state(cs->device, STATE_CLIPPLANE(op->plane_idx)); +} + +void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const struct wined3d_vec4 *plane) +{ + struct wined3d_cs_set_clip_plane *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE; + op->plane_idx = plane_idx; + op->plane = plane; + + cs->ops->submit(cs); +} + static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = { /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, @@ -712,6 +740,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, /* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state, /* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform, + /* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane, }; static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e37a28df5fb..1f2642bb526 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1734,14 +1734,8 @@ HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device, device->update_state->clip_planes[plane_idx] = *plane; - /* Handle recording of state blocks. */ - if (device->recording) - { - TRACE("Recording... not performing anything.\n"); - return WINED3D_OK; - } - - device_invalidate_state(device, STATE_CLIPPLANE(plane_idx)); + if (!device->recording) + wined3d_cs_emit_set_clip_plane(device->cs, plane_idx, plane); return WINED3D_OK; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 69738d5247c..6dc5c7f3379 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2485,6 +2485,8 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, UINT start_idx, UINT index_coun void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region, DWORD flags) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, + const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_depth_stencil(struct wined3d_cs *cs, struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_geometry_shader(struct wined3d_cs *cs, struct wined3d_shader *shader) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,