[PATCH 4/5] d3d10core: Implement d3d10_device_GSSetConstantBuffers().
Henri Verbeet
hverbeet at codeweavers.com
Mon Dec 3 14:16:33 CST 2012
---
dlls/d3d10core/device.c | 13 ++++++++++++-
dlls/wined3d/device.c | 39 +++++++++++++++++++++++++++++++++++++++
dlls/wined3d/stateblock.c | 9 +++++++++
dlls/wined3d/wined3d.spec | 1 +
dlls/wined3d/wined3d_private.h | 1 +
include/wine/wined3d.h | 1 +
6 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 25439b0..fbebf9e 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -271,8 +271,19 @@ static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device *iface,
static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
{
- FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
+ struct d3d10_device *device = impl_from_ID3D10Device(iface);
+ unsigned int i;
+
+ TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
iface, start_slot, buffer_count, buffers);
+
+ for (i = 0; i < buffer_count; ++i)
+ {
+ struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
+
+ wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
+ buffer ? buffer->wined3d_buffer : NULL);
+ }
}
static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 57e1de9..6ea2f85 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3129,6 +3129,45 @@ struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wi
return device->stateBlock->state.geometry_shader;
}
+void CDECL wined3d_device_set_gs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
+{
+ struct wined3d_buffer *prev;
+
+ TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer);
+
+ if (idx >= MAX_CONSTANT_BUFFERS)
+ {
+ WARN("Invalid constant buffer index %u.\n", idx);
+ return;
+ }
+
+ prev = device->updateStateBlock->state.gs_cb[idx];
+ device->updateStateBlock->state.gs_cb[idx] = buffer;
+
+ if (device->isRecordingState)
+ {
+ if (buffer)
+ wined3d_buffer_incref(buffer);
+ if (prev)
+ wined3d_buffer_decref(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);
+ }
+ }
+}
+
/* Context activation is done by the caller. */
/* Do not call while under the GL lock. */
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 11d8fa8..6499877 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -536,6 +536,15 @@ void stateblock_unbind_resources(struct wined3d_stateblock *stateblock)
wined3d_shader_decref(shader);
}
+ for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
+ {
+ if ((buffer = state->gs_cb[i]))
+ {
+ state->gs_cb[i] = NULL;
+ wined3d_buffer_decref(buffer);
+ }
+ }
+
if ((shader = state->pixel_shader))
{
state->pixel_shader = NULL;
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index b7b04df..d08c33f 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -116,6 +116,7 @@
@ cdecl wined3d_device_set_dialog_box_mode(ptr long)
@ cdecl wined3d_device_set_gamma_ramp(ptr long long ptr)
@ cdecl wined3d_device_set_geometry_shader(ptr ptr)
+@ cdecl wined3d_device_set_gs_cb(ptr long ptr)
@ cdecl wined3d_device_set_index_buffer(ptr ptr long)
@ cdecl wined3d_device_set_light(ptr long ptr)
@ cdecl wined3d_device_set_light_enable(ptr long long)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ddf1fa2..4d7d456 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2306,6 +2306,7 @@ struct wined3d_state
float *vs_consts_f;
struct wined3d_shader *geometry_shader;
+ struct wined3d_buffer *gs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_shader *pixel_shader;
BOOL ps_consts_b[MAX_CONST_B];
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 7b1e043..206c8ef 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2206,6 +2206,7 @@ HRESULT __cdecl wined3d_device_set_dialog_box_mode(struct wined3d_device *device
void __cdecl wined3d_device_set_gamma_ramp(const struct wined3d_device *device,
UINT swapchain_idx, DWORD flags, const struct wined3d_gamma_ramp *ramp);
void __cdecl wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader);
+void __cdecl wined3d_device_set_gs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer);
void __cdecl wined3d_device_set_index_buffer(struct wined3d_device *device,
struct wined3d_buffer *index_buffer, enum wined3d_format_id format_id);
HRESULT __cdecl wined3d_device_set_light(struct wined3d_device *device,
--
1.7.8.6
More information about the wine-patches
mailing list