From b034f49183f557628a78bbda41598a65a63d8245 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 4 Dec 2012 22:10:10 +0100 Subject: [PATCH] d3d10core: Implement d3d10_device_PSSetConstantBuffers(). --- 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 deletion(-) diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 438beb0385d..cb0c1687932 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -194,8 +194,19 @@ static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface, UINT vertex static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(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_ps_cb(device->wined3d_device, start_slot + i, + buffer ? buffer->wined3d_buffer : NULL); + } } static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c293636072b..d55a155743f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2966,6 +2966,45 @@ struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined return device->stateBlock->state.pixel_shader; } +void CDECL wined3d_device_set_ps_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.ps_cb[idx]; + device->updateStateBlock->state.ps_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); + } + } +} + HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device, UINT start_register, const BOOL *constants, UINT bool_count) { diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 64998774d29..518ae2a2bb9 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -550,6 +550,15 @@ void stateblock_unbind_resources(struct wined3d_stateblock *stateblock) state->pixel_shader = NULL; wined3d_shader_decref(shader); } + + for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i) + { + if ((buffer = state->ps_cb[i])) + { + state->ps_cb[i] = NULL; + wined3d_buffer_decref(buffer); + } + } } ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock) diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index c97e7af48f5..b1b451373fb 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -126,6 +126,7 @@ @ cdecl wined3d_device_set_npatch_mode(ptr float) @ cdecl wined3d_device_set_pixel_shader(ptr ptr) @ cdecl wined3d_device_set_primitive_type(ptr long) +@ cdecl wined3d_device_set_ps_cb(ptr long ptr) @ cdecl wined3d_device_set_ps_consts_b(ptr long ptr long) @ cdecl wined3d_device_set_ps_consts_f(ptr long ptr long) @ cdecl wined3d_device_set_ps_consts_i(ptr long ptr long) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4d7d456f774..f0c44eb5d6e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2309,6 +2309,7 @@ struct wined3d_state struct wined3d_buffer *gs_cb[MAX_CONSTANT_BUFFERS]; struct wined3d_shader *pixel_shader; + struct wined3d_buffer *ps_cb[MAX_CONSTANT_BUFFERS]; BOOL ps_consts_b[MAX_CONST_B]; INT ps_consts_i[MAX_CONST_I * 4]; float *ps_consts_f; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 82287dff36d..bdc1092789c 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2219,6 +2219,7 @@ HRESULT __cdecl wined3d_device_set_npatch_mode(struct wined3d_device *device, fl void __cdecl wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader); void __cdecl wined3d_device_set_primitive_type(struct wined3d_device *device, enum wined3d_primitive_type primitive_topology); +void __cdecl wined3d_device_set_ps_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer); HRESULT __cdecl wined3d_device_set_ps_consts_b(struct wined3d_device *device, UINT start_register, const BOOL *constants, UINT bool_count); HRESULT __cdecl wined3d_device_set_ps_consts_f(struct wined3d_device *device,