Henri Verbeet : wined3d: Send constant buffer binding updates through the command stream.
Alexandre Julliard
julliard at winehq.org
Fri Oct 11 10:11:12 CDT 2013
Module: wine
Branch: master
Commit: 738de80d0cbf5e284f2592b59f5c6cbbe817d140
URL: http://source.winehq.org/git/wine.git/?a=commit;h=738de80d0cbf5e284f2592b59f5c6cbbe817d140
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Oct 10 23:49:44 2013 +0200
wined3d: Send constant buffer binding updates through the command stream.
---
dlls/wined3d/cs.c | 38 ++++++++++++++++++++++++++++++++++++++
dlls/wined3d/device.c | 30 ++++++++----------------------
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 12ab60e..7b33164 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -37,6 +37,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_STREAM_SOURCE,
WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ,
WINED3D_CS_OP_SET_INDEX_BUFFER,
+ WINED3D_CS_OP_SET_CONSTANT_BUFFER,
WINED3D_CS_OP_SET_TEXTURE,
WINED3D_CS_OP_SET_SHADER,
WINED3D_CS_OP_SET_RENDER_STATE,
@@ -134,6 +135,14 @@ struct wined3d_cs_set_index_buffer
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
{
enum wined3d_cs_op opcode;
@@ -493,6 +502,34 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff
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)
{
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
/* 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_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_SHADER */ wined3d_cs_exec_set_shader,
/* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 93aef9f..3fb11a8 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2098,30 +2098,16 @@ static void wined3d_device_set_constant_buffer(struct wined3d_device *device,
}
prev = device->update_state->cb[type][idx];
- device->update_state->cb[type][idx] = buffer;
-
- if (device->recording)
- {
- if (buffer)
- wined3d_buffer_incref(buffer);
- if (prev)
- wined3d_buffer_decref(prev);
+ if (buffer == prev)
return;
- }
- if (prev != buffer)
- {
- if (buffer)
- {
- InterlockedIncrement(&buffer->resource.bind_count);
- wined3d_buffer_incref(buffer);
- }
- if (prev)
- {
- InterlockedDecrement(&prev->resource.bind_count);
- wined3d_buffer_decref(prev);
- }
- }
+ if (buffer)
+ wined3d_buffer_incref(buffer);
+ device->update_state->cb[type][idx] = buffer;
+ if (!device->recording)
+ wined3d_cs_emit_set_constant_buffer(device->cs, type, idx, buffer);
+ if (prev)
+ wined3d_buffer_decref(prev);
}
void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index bfd9995..890f1a8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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;
void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
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_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list