From f699b6da0bb83c00026208bef5a1eb086bc993c8 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 10 Oct 2013 23:49:45 +0200 Subject: [PATCH] wined3d: Send sampler binding updates through the command stream. --- dlls/wined3d/cs.c | 31 +++++++++++++++++++++++++++++++ dlls/wined3d/device.c | 6 +++++- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 7b331643478..bf682e5d7b9 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -39,6 +39,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_CONSTANT_BUFFER, WINED3D_CS_OP_SET_TEXTURE, + WINED3D_CS_OP_SET_SAMPLER, WINED3D_CS_OP_SET_SHADER, WINED3D_CS_OP_SET_RENDER_STATE, WINED3D_CS_OP_SET_TEXTURE_STATE, @@ -150,6 +151,14 @@ struct wined3d_cs_set_texture struct wined3d_texture *texture; }; +struct wined3d_cs_set_sampler +{ + enum wined3d_cs_op opcode; + enum wined3d_shader_type type; + UINT sampler_idx; + struct wined3d_sampler *sampler; +}; + struct wined3d_cs_set_shader { enum wined3d_cs_op opcode; @@ -599,6 +608,27 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined cs->ops->submit(cs); } +static void wined3d_cs_exec_set_sampler(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_sampler *op = data; + + cs->state.sampler[op->type][op->sampler_idx] = op->sampler; +} + +void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type, + UINT sampler_idx, struct wined3d_sampler *sampler) +{ + struct wined3d_cs_set_sampler *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_SAMPLER; + op->type = type; + op->sampler_idx = sampler_idx; + op->sampler = sampler; + + cs->ops->submit(cs); +} + static void wined3d_cs_exec_set_shader(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_shader *op = data; @@ -759,6 +789,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer, /* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer, /* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture, + /* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler, /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3fb11a8b2e3..cafb539302c 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2142,10 +2142,14 @@ static void wined3d_device_set_sampler(struct wined3d_device *device, } prev = device->update_state->sampler[type][idx]; - device->update_state->sampler[type][idx] = sampler; + if (sampler == prev) + return; if (sampler) wined3d_sampler_incref(sampler); + device->update_state->sampler[type][idx] = sampler; + if (!device->recording) + wined3d_cs_emit_set_sampler(device->cs, type, idx, sampler); if (prev) wined3d_sampler_decref(prev); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 890f1a87064..7d160eb19b8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2485,6 +2485,8 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN; 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_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type, + UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, enum wined3d_sampler_state state, DWORD value) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) DECLSPEC_HIDDEN;