Commit 086212ba authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Set an arary of stream sources as a single CS operation.

parent 460eabd9
...@@ -120,7 +120,7 @@ enum wined3d_cs_op ...@@ -120,7 +120,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_RENDERTARGET_VIEW, WINED3D_CS_OP_SET_RENDERTARGET_VIEW,
WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW, WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW,
WINED3D_CS_OP_SET_VERTEX_DECLARATION, WINED3D_CS_OP_SET_VERTEX_DECLARATION,
WINED3D_CS_OP_SET_STREAM_SOURCE, WINED3D_CS_OP_SET_STREAM_SOURCES,
WINED3D_CS_OP_SET_STREAM_OUTPUTS, WINED3D_CS_OP_SET_STREAM_OUTPUTS,
WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_INDEX_BUFFER,
WINED3D_CS_OP_SET_CONSTANT_BUFFERS, WINED3D_CS_OP_SET_CONSTANT_BUFFERS,
...@@ -255,11 +255,12 @@ struct wined3d_cs_set_vertex_declaration ...@@ -255,11 +255,12 @@ struct wined3d_cs_set_vertex_declaration
struct wined3d_vertex_declaration *declaration; struct wined3d_vertex_declaration *declaration;
}; };
struct wined3d_cs_set_stream_source struct wined3d_cs_set_stream_sources
{ {
enum wined3d_cs_op opcode; enum wined3d_cs_op opcode;
UINT stream_idx; unsigned int start_idx;
struct wined3d_stream_state state; unsigned int count;
struct wined3d_stream_state streams[1];
}; };
struct wined3d_cs_set_stream_outputs struct wined3d_cs_set_stream_outputs
...@@ -592,7 +593,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op) ...@@ -592,7 +593,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op)
WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDERTARGET_VIEW); WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDERTARGET_VIEW);
WINED3D_TO_STR(WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW); WINED3D_TO_STR(WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW);
WINED3D_TO_STR(WINED3D_CS_OP_SET_VERTEX_DECLARATION); WINED3D_TO_STR(WINED3D_CS_OP_SET_VERTEX_DECLARATION);
WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_SOURCE); WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_SOURCES);
WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_OUTPUTS); WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_OUTPUTS);
WINED3D_TO_STR(WINED3D_CS_OP_SET_INDEX_BUFFER); WINED3D_TO_STR(WINED3D_CS_OP_SET_INDEX_BUFFER);
WINED3D_TO_STR(WINED3D_CS_OP_SET_CONSTANT_BUFFERS); WINED3D_TO_STR(WINED3D_CS_OP_SET_CONSTANT_BUFFERS);
...@@ -1401,33 +1402,37 @@ void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_co ...@@ -1401,33 +1402,37 @@ void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_co
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
} }
static void wined3d_cs_exec_set_stream_source(struct wined3d_cs *cs, const void *data) static void wined3d_cs_exec_set_stream_sources(struct wined3d_cs *cs, const void *data)
{ {
const struct wined3d_cs_set_stream_source *op = data; const struct wined3d_cs_set_stream_sources *op = data;
struct wined3d_stream_state *stream; unsigned int i;
struct wined3d_buffer *prev;
stream = &cs->state.streams[op->stream_idx]; for (i = 0; i < op->count; ++i)
prev = stream->buffer; {
*stream = op->state; struct wined3d_buffer *prev = cs->state.streams[op->start_idx + i].buffer;
struct wined3d_buffer *buffer = op->streams[i].buffer;
if (op->state.buffer) if (buffer)
InterlockedIncrement(&op->state.buffer->resource.bind_count); InterlockedIncrement(&buffer->resource.bind_count);
if (prev) if (prev)
InterlockedDecrement(&prev->resource.bind_count); InterlockedDecrement(&prev->resource.bind_count);
}
memcpy(&cs->state.streams[op->start_idx], op->streams, op->count * sizeof(*op->streams));
device_invalidate_state(cs->c.device, STATE_STREAMSRC); device_invalidate_state(cs->c.device, STATE_STREAMSRC);
} }
void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx, void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context *context,
const struct wined3d_stream_state *state) unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams)
{ {
struct wined3d_cs_set_stream_source *op; struct wined3d_cs_set_stream_sources *op;
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op = wined3d_device_context_require_space(context,
op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE; offsetof(struct wined3d_cs_set_stream_sources, streams[count]), WINED3D_CS_QUEUE_DEFAULT);
op->stream_idx = stream_idx; op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCES;
op->state = *state; op->start_idx = start_idx;
op->count = count;
memcpy(op->streams, streams, count * sizeof(*streams));
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
} }
...@@ -2889,7 +2894,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void ...@@ -2889,7 +2894,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view, /* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view,
/* WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW */ wined3d_cs_exec_set_depth_stencil_view, /* WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW */ wined3d_cs_exec_set_depth_stencil_view,
/* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration, /* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration,
/* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source, /* WINED3D_CS_OP_SET_STREAM_SOURCES */ wined3d_cs_exec_set_stream_sources,
/* WINED3D_CS_OP_SET_STREAM_OUTPUTS */ wined3d_cs_exec_set_stream_outputs, /* WINED3D_CS_OP_SET_STREAM_OUTPUTS */ wined3d_cs_exec_set_stream_outputs,
/* 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_BUFFERS */ wined3d_cs_exec_set_constant_buffers, /* WINED3D_CS_OP_SET_CONSTANT_BUFFERS */ wined3d_cs_exec_set_constant_buffers,
......
...@@ -1661,8 +1661,7 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte ...@@ -1661,8 +1661,7 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte
wined3d_device_context_emit_set_stream_outputs(context, state->stream_output); wined3d_device_context_emit_set_stream_outputs(context, state->stream_output);
for (i = 0; i < WINED3D_MAX_STREAMS; ++i) wined3d_device_context_emit_set_stream_sources(context, 0, WINED3D_MAX_STREAMS, state->streams);
wined3d_device_context_emit_set_stream_source(context, i, &state->streams[i]);
wined3d_device_context_emit_set_index_buffer(context, state->index_buffer, wined3d_device_context_emit_set_index_buffer(context, state->index_buffer,
state->index_format, state->index_offset); state->index_format, state->index_offset);
...@@ -2247,6 +2246,7 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co ...@@ -2247,6 +2246,7 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co
if (!memcmp(streams, &state->streams[start_idx], count * sizeof(*streams))) if (!memcmp(streams, &state->streams[start_idx], count * sizeof(*streams)))
return WINED3D_OK; return WINED3D_OK;
wined3d_device_context_emit_set_stream_sources(context, start_idx, count, streams);
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
{ {
struct wined3d_buffer *prev = state->streams[start_idx + i].buffer; struct wined3d_buffer *prev = state->streams[start_idx + i].buffer;
...@@ -2256,7 +2256,6 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co ...@@ -2256,7 +2256,6 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co
if (buffer) if (buffer)
wined3d_buffer_incref(buffer); wined3d_buffer_incref(buffer);
wined3d_device_context_emit_set_stream_source(context, start_idx + i, &streams[i]);
if (prev) if (prev)
wined3d_buffer_decref(prev); wined3d_buffer_decref(prev);
} }
......
...@@ -4841,8 +4841,8 @@ void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device ...@@ -4841,8 +4841,8 @@ void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device
struct wined3d_shader_resource_view *const *views) DECLSPEC_HIDDEN; struct wined3d_shader_resource_view *const *views) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context *context, void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context *context,
const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]) DECLSPEC_HIDDEN; const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx, void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context *context,
const struct wined3d_stream_state *state) DECLSPEC_HIDDEN; unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, unsigned int stage, void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, unsigned int stage,
struct wined3d_texture *texture) DECLSPEC_HIDDEN; struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context *context, unsigned int stage, void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context *context, unsigned int stage,
......
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