From 1f864bc9c3ae7b9e659aaec4d809eacac6e7490b Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 1 Oct 2013 10:38:31 +0200 Subject: [PATCH] wined3d: Send vertex declaration binding updates through the command stream. --- dlls/wined3d/cs.c | 27 +++++++++++++++++++++++++++ dlls/wined3d/device.c | 23 +++++++---------------- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 3d155f1274b..1e427f4f0f3 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -32,6 +32,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_SCISSOR_RECT, WINED3D_CS_OP_SET_RENDER_TARGET, WINED3D_CS_OP_SET_DEPTH_STENCIL, + WINED3D_CS_OP_SET_VERTEX_DECLARATION, }; struct wined3d_cs_present @@ -91,6 +92,12 @@ struct wined3d_cs_set_depth_stencil struct wined3d_surface *depth_stencil; }; +struct wined3d_cs_set_vertex_declaration +{ + enum wined3d_cs_op opcode; + struct wined3d_vertex_declaration *declaration; +}; + static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_present *op = data; @@ -284,6 +291,25 @@ void wined3d_cs_emit_set_depth_stencil(struct wined3d_cs *cs, struct wined3d_sur cs->ops->submit(cs); } +static void wined3d_cs_exec_set_vertex_declaration(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_vertex_declaration *op = data; + + cs->state.vertex_declaration = op->declaration; + device_invalidate_state(cs->device, STATE_VDECL); +} + +void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3d_vertex_declaration *declaration) +{ + struct wined3d_cs_set_vertex_declaration *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_VERTEX_DECLARATION; + op->declaration = declaration; + + 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, @@ -293,6 +319,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect, /* WINED3D_CS_OP_SET_RENDER_TARGET */ wined3d_cs_exec_set_render_target, /* WINED3D_CS_OP_SET_DEPTH_STENCIL */ wined3d_cs_exec_set_depth_stencil, + /* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration, }; 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 12d0239e30f..d58147936d3 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2078,28 +2078,19 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, TRACE("device %p, declaration %p.\n", device, declaration); - if (declaration) - wined3d_vertex_declaration_incref(declaration); - if (prev) - wined3d_vertex_declaration_decref(prev); - - device->update_state->vertex_declaration = declaration; - if (device->recording) - { - TRACE("Recording... not performing anything.\n"); device->recording->changed.vertexDecl = TRUE; - return; - } if (declaration == prev) - { - /* Checked after the assignment to allow proper stateblock recording. */ - TRACE("Application is setting the old declaration over, nothing to do.\n"); return; - } - device_invalidate_state(device, STATE_VDECL); + if (declaration) + wined3d_vertex_declaration_incref(declaration); + device->update_state->vertex_declaration = declaration; + if (!device->recording) + wined3d_cs_emit_set_vertex_declaration(device->cs, declaration); + if (prev) + wined3d_vertex_declaration_decref(prev); } struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(const struct wined3d_device *device) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7409807a387..648780f2db7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2490,6 +2490,8 @@ void wined3d_cs_emit_set_depth_stencil(struct wined3d_cs *cs, struct wined3d_sur void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target_idx, struct wined3d_surface *render_target) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, + struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN; /* Direct3D terminology with little modifications. We do not have an issued state