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

Alexandre Julliard julliard at winehq.org
Mon Jul 19 15:59:14 CDT 2021


Module: wine
Branch: master
Commit: 086212ba57e4c1234d6f9fb1d5eec9e00e75533f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=086212ba57e4c1234d6f9fb1d5eec9e00e75533f

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Thu Jul 15 00:18:32 2021 -0500

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

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/cs.c              | 53 +++++++++++++++++++++++-------------------
 dlls/wined3d/device.c          |  5 ++--
 dlls/wined3d/wined3d_private.h |  4 ++--
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index a5d330d7b6c..2b14da03c2f 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -120,7 +120,7 @@ enum wined3d_cs_op
     WINED3D_CS_OP_SET_RENDERTARGET_VIEW,
     WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW,
     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_INDEX_BUFFER,
     WINED3D_CS_OP_SET_CONSTANT_BUFFERS,
@@ -255,11 +255,12 @@ struct wined3d_cs_set_vertex_declaration
     struct wined3d_vertex_declaration *declaration;
 };
 
-struct wined3d_cs_set_stream_source
+struct wined3d_cs_set_stream_sources
 {
     enum wined3d_cs_op opcode;
-    UINT stream_idx;
-    struct wined3d_stream_state state;
+    unsigned int start_idx;
+    unsigned int count;
+    struct wined3d_stream_state streams[1];
 };
 
 struct wined3d_cs_set_stream_outputs
@@ -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_DEPTH_STENCIL_VIEW);
         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_INDEX_BUFFER);
         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
     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;
-    struct wined3d_stream_state *stream;
-    struct wined3d_buffer *prev;
+    const struct wined3d_cs_set_stream_sources *op = data;
+    unsigned int i;
 
-    stream = &cs->state.streams[op->stream_idx];
-    prev = stream->buffer;
-    *stream = op->state;
+    for (i = 0; i < op->count; ++i)
+    {
+        struct wined3d_buffer *prev = cs->state.streams[op->start_idx + i].buffer;
+        struct wined3d_buffer *buffer = op->streams[i].buffer;
 
-    if (op->state.buffer)
-        InterlockedIncrement(&op->state.buffer->resource.bind_count);
-    if (prev)
-        InterlockedDecrement(&prev->resource.bind_count);
+        if (buffer)
+            InterlockedIncrement(&buffer->resource.bind_count);
+        if (prev)
+            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);
 }
 
-void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx,
-        const struct wined3d_stream_state *state)
+void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context *context,
+        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->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE;
-    op->stream_idx = stream_idx;
-    op->state = *state;
+    op = wined3d_device_context_require_space(context,
+            offsetof(struct wined3d_cs_set_stream_sources, streams[count]), WINED3D_CS_QUEUE_DEFAULT);
+    op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCES;
+    op->start_idx = start_idx;
+    op->count = count;
+    memcpy(op->streams, streams, count * sizeof(*streams));
 
     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
     /* 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_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_INDEX_BUFFER            */ wined3d_cs_exec_set_index_buffer,
     /* WINED3D_CS_OP_SET_CONSTANT_BUFFERS        */ wined3d_cs_exec_set_constant_buffers,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5a4e7df6f9e..a03d56b244d 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -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);
 
-    for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
-        wined3d_device_context_emit_set_stream_source(context, i, &state->streams[i]);
+    wined3d_device_context_emit_set_stream_sources(context, 0, WINED3D_MAX_STREAMS, state->streams);
 
     wined3d_device_context_emit_set_index_buffer(context, state->index_buffer,
             state->index_format, state->index_offset);
@@ -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)))
         return WINED3D_OK;
 
+    wined3d_device_context_emit_set_stream_sources(context, start_idx, count, streams);
     for (i = 0; i < count; ++i)
     {
         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
 
         if (buffer)
             wined3d_buffer_incref(buffer);
-        wined3d_device_context_emit_set_stream_source(context, start_idx + i, &streams[i]);
         if (prev)
             wined3d_buffer_decref(prev);
     }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 52a4bc33337..38d6796e666 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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;
 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;
-void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx,
-        const struct wined3d_stream_state *state) DECLSPEC_HIDDEN;
+void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context *context,
+        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,
         struct wined3d_texture *texture) DECLSPEC_HIDDEN;
 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context *context, unsigned int stage,




More information about the wine-cvs mailing list