Commit 738de80d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Send constant buffer binding updates through the command stream.

parent bd961941
...@@ -37,6 +37,7 @@ enum wined3d_cs_op ...@@ -37,6 +37,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_STREAM_SOURCE, WINED3D_CS_OP_SET_STREAM_SOURCE,
WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ, WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ,
WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_INDEX_BUFFER,
WINED3D_CS_OP_SET_CONSTANT_BUFFER,
WINED3D_CS_OP_SET_TEXTURE, WINED3D_CS_OP_SET_TEXTURE,
WINED3D_CS_OP_SET_SHADER, WINED3D_CS_OP_SET_SHADER,
WINED3D_CS_OP_SET_RENDER_STATE, WINED3D_CS_OP_SET_RENDER_STATE,
...@@ -134,6 +135,14 @@ struct wined3d_cs_set_index_buffer ...@@ -134,6 +135,14 @@ struct wined3d_cs_set_index_buffer
enum wined3d_format_id format_id; enum wined3d_format_id format_id;
}; };
struct wined3d_cs_set_constant_buffer
{
enum wined3d_cs_op opcode;
enum wined3d_shader_type type;
UINT cb_idx;
struct wined3d_buffer *buffer;
};
struct wined3d_cs_set_texture struct wined3d_cs_set_texture
{ {
enum wined3d_cs_op opcode; enum wined3d_cs_op opcode;
...@@ -493,6 +502,34 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff ...@@ -493,6 +502,34 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff
cs->ops->submit(cs); cs->ops->submit(cs);
} }
static void wined3d_cs_exec_set_constant_buffer(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_set_constant_buffer *op = data;
struct wined3d_buffer *prev;
prev = cs->state.cb[op->type][op->cb_idx];
cs->state.cb[op->type][op->cb_idx] = op->buffer;
if (op->buffer)
InterlockedIncrement(&op->buffer->resource.bind_count);
if (prev)
InterlockedDecrement(&prev->resource.bind_count);
}
void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT cb_idx, struct wined3d_buffer *buffer)
{
struct wined3d_cs_set_constant_buffer *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER;
op->type = type;
op->cb_idx = cb_idx;
op->buffer = buffer;
cs->ops->submit(cs);
}
static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data) static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data)
{ {
const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info; const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info;
...@@ -720,6 +757,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void ...@@ -720,6 +757,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source, /* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source,
/* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq, /* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq,
/* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer, /* 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_TEXTURE */ wined3d_cs_exec_set_texture,
/* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, /* 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_RENDER_STATE */ wined3d_cs_exec_set_render_state,
......
...@@ -2098,30 +2098,16 @@ static void wined3d_device_set_constant_buffer(struct wined3d_device *device, ...@@ -2098,30 +2098,16 @@ static void wined3d_device_set_constant_buffer(struct wined3d_device *device,
} }
prev = device->update_state->cb[type][idx]; prev = device->update_state->cb[type][idx];
device->update_state->cb[type][idx] = buffer; if (buffer == prev)
if (device->recording)
{
if (buffer)
wined3d_buffer_incref(buffer);
if (prev)
wined3d_buffer_decref(prev);
return; return;
}
if (prev != buffer) if (buffer)
{ wined3d_buffer_incref(buffer);
if (buffer) device->update_state->cb[type][idx] = buffer;
{ if (!device->recording)
InterlockedIncrement(&buffer->resource.bind_count); wined3d_cs_emit_set_constant_buffer(device->cs, type, idx, buffer);
wined3d_buffer_incref(buffer); if (prev)
} wined3d_buffer_decref(prev);
if (prev)
{
InterlockedDecrement(&prev->resource.bind_count);
wined3d_buffer_decref(prev);
}
}
} }
void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer) void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
......
...@@ -2475,6 +2475,8 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw ...@@ -2475,6 +2475,8 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
const RGNDATA *dirty_region, DWORD flags) DECLSPEC_HIDDEN; const RGNDATA *dirty_region, DWORD flags) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN; const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT cb_idx, struct wined3d_buffer *buffer) 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_depth_stencil(struct wined3d_cs *cs, struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer, void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
enum wined3d_format_id format_id) DECLSPEC_HIDDEN; enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
......
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