2 * Copyright 2009 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
23 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 static inline struct d3d10_blend_state *impl_from_ID3D10BlendState(ID3D10BlendState *iface)
29 return CONTAINING_RECORD(iface, struct d3d10_blend_state, ID3D10BlendState_iface);
32 /* IUnknown methods */
34 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_QueryInterface(ID3D10BlendState *iface,
35 REFIID riid, void **object)
37 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
39 if (IsEqualGUID(riid, &IID_ID3D10BlendState)
40 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
41 || IsEqualGUID(riid, &IID_IUnknown))
43 IUnknown_AddRef(iface);
48 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
54 static ULONG STDMETHODCALLTYPE d3d10_blend_state_AddRef(ID3D10BlendState *iface)
56 struct d3d10_blend_state *This = impl_from_ID3D10BlendState(iface);
57 ULONG refcount = InterlockedIncrement(&This->refcount);
59 TRACE("%p increasing refcount to %u.\n", This, refcount);
64 static ULONG STDMETHODCALLTYPE d3d10_blend_state_Release(ID3D10BlendState *iface)
66 struct d3d10_blend_state *state = impl_from_ID3D10BlendState(iface);
67 ULONG refcount = InterlockedDecrement(&state->refcount);
69 TRACE("%p decreasing refcount to %u.\n", state, refcount);
73 wine_rb_remove(&state->device->blend_states, &state->desc);
74 HeapFree(GetProcessHeap(), 0, state);
80 /* ID3D10DeviceChild methods */
82 static void STDMETHODCALLTYPE d3d10_blend_state_GetDevice(ID3D10BlendState *iface, ID3D10Device **device)
84 FIXME("iface %p, device %p stub!\n", iface, device);
87 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_GetPrivateData(ID3D10BlendState *iface,
88 REFGUID guid, UINT *data_size, void *data)
90 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
91 iface, debugstr_guid(guid), data_size, data);
96 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_SetPrivateData(ID3D10BlendState *iface,
97 REFGUID guid, UINT data_size, const void *data)
99 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
100 iface, debugstr_guid(guid), data_size, data);
105 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_SetPrivateDataInterface(ID3D10BlendState *iface,
106 REFGUID guid, const IUnknown *data)
108 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
113 /* ID3D10BlendState methods */
115 static void STDMETHODCALLTYPE d3d10_blend_state_GetDesc(ID3D10BlendState *iface,
116 D3D10_BLEND_DESC *desc)
118 struct d3d10_blend_state *state = impl_from_ID3D10BlendState(iface);
120 TRACE("iface %p, desc %p.\n", iface, desc);
125 static const struct ID3D10BlendStateVtbl d3d10_blend_state_vtbl =
127 /* IUnknown methods */
128 d3d10_blend_state_QueryInterface,
129 d3d10_blend_state_AddRef,
130 d3d10_blend_state_Release,
131 /* ID3D10DeviceChild methods */
132 d3d10_blend_state_GetDevice,
133 d3d10_blend_state_GetPrivateData,
134 d3d10_blend_state_SetPrivateData,
135 d3d10_blend_state_SetPrivateDataInterface,
136 /* ID3D10BlendState methods */
137 d3d10_blend_state_GetDesc,
140 HRESULT d3d10_blend_state_init(struct d3d10_blend_state *state, struct d3d10_device *device,
141 const D3D10_BLEND_DESC *desc)
143 state->ID3D10BlendState_iface.lpVtbl = &d3d10_blend_state_vtbl;
145 state->device = device;
148 if (wine_rb_put(&device->blend_states, desc, &state->entry) == -1)
150 ERR("Failed to insert blend state entry.\n");
157 struct d3d10_blend_state *unsafe_impl_from_ID3D10BlendState(ID3D10BlendState *iface)
161 assert(iface->lpVtbl == &d3d10_blend_state_vtbl);
163 return impl_from_ID3D10BlendState(iface);
166 static inline struct d3d10_depthstencil_state *impl_from_ID3D10DepthStencilState(ID3D10DepthStencilState *iface)
168 return CONTAINING_RECORD(iface, struct d3d10_depthstencil_state, ID3D10DepthStencilState_iface);
171 /* IUnknown methods */
173 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_QueryInterface(ID3D10DepthStencilState *iface,
174 REFIID riid, void **object)
176 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
178 if (IsEqualGUID(riid, &IID_ID3D10DepthStencilState)
179 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
180 || IsEqualGUID(riid, &IID_IUnknown))
182 IUnknown_AddRef(iface);
187 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
190 return E_NOINTERFACE;
193 static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_AddRef(ID3D10DepthStencilState *iface)
195 struct d3d10_depthstencil_state *This = impl_from_ID3D10DepthStencilState(iface);
196 ULONG refcount = InterlockedIncrement(&This->refcount);
198 TRACE("%p increasing refcount to %u.\n", This, refcount);
203 static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_Release(ID3D10DepthStencilState *iface)
205 struct d3d10_depthstencil_state *state = impl_from_ID3D10DepthStencilState(iface);
206 ULONG refcount = InterlockedDecrement(&state->refcount);
208 TRACE("%p decreasing refcount to %u.\n", state, refcount);
212 wine_rb_remove(&state->device->depthstencil_states, &state->desc);
213 HeapFree(GetProcessHeap(), 0, state);
219 /* ID3D10DeviceChild methods */
221 static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDevice(ID3D10DepthStencilState *iface, ID3D10Device **device)
223 FIXME("iface %p, device %p stub!\n", iface, device);
226 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_GetPrivateData(ID3D10DepthStencilState *iface,
227 REFGUID guid, UINT *data_size, void *data)
229 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
230 iface, debugstr_guid(guid), data_size, data);
235 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_SetPrivateData(ID3D10DepthStencilState *iface,
236 REFGUID guid, UINT data_size, const void *data)
238 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
239 iface, debugstr_guid(guid), data_size, data);
244 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_SetPrivateDataInterface(ID3D10DepthStencilState *iface,
245 REFGUID guid, const IUnknown *data)
247 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
252 /* ID3D10DepthStencilState methods */
254 static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDesc(ID3D10DepthStencilState *iface,
255 D3D10_DEPTH_STENCIL_DESC *desc)
257 struct d3d10_depthstencil_state *state = impl_from_ID3D10DepthStencilState(iface);
259 TRACE("iface %p, desc %p.\n", iface, desc);
264 static const struct ID3D10DepthStencilStateVtbl d3d10_depthstencil_state_vtbl =
266 /* IUnknown methods */
267 d3d10_depthstencil_state_QueryInterface,
268 d3d10_depthstencil_state_AddRef,
269 d3d10_depthstencil_state_Release,
270 /* ID3D10DeviceChild methods */
271 d3d10_depthstencil_state_GetDevice,
272 d3d10_depthstencil_state_GetPrivateData,
273 d3d10_depthstencil_state_SetPrivateData,
274 d3d10_depthstencil_state_SetPrivateDataInterface,
275 /* ID3D10DepthStencilState methods */
276 d3d10_depthstencil_state_GetDesc,
279 HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state, struct d3d10_device *device,
280 const D3D10_DEPTH_STENCIL_DESC *desc)
282 state->ID3D10DepthStencilState_iface.lpVtbl = &d3d10_depthstencil_state_vtbl;
284 state->device = device;
287 if (wine_rb_put(&device->depthstencil_states, desc, &state->entry) == -1)
289 ERR("Failed to insert depthstencil state entry.\n");
296 struct d3d10_depthstencil_state *unsafe_impl_from_ID3D10DepthStencilState(ID3D10DepthStencilState *iface)
300 assert(iface->lpVtbl == &d3d10_depthstencil_state_vtbl);
302 return impl_from_ID3D10DepthStencilState(iface);
305 static inline struct d3d10_rasterizer_state *impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface)
307 return CONTAINING_RECORD(iface, struct d3d10_rasterizer_state, ID3D10RasterizerState_iface);
310 /* IUnknown methods */
312 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_QueryInterface(ID3D10RasterizerState *iface,
313 REFIID riid, void **object)
315 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
317 if (IsEqualGUID(riid, &IID_ID3D10RasterizerState)
318 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
319 || IsEqualGUID(riid, &IID_IUnknown))
321 IUnknown_AddRef(iface);
326 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
329 return E_NOINTERFACE;
332 static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_AddRef(ID3D10RasterizerState *iface)
334 struct d3d10_rasterizer_state *This = impl_from_ID3D10RasterizerState(iface);
335 ULONG refcount = InterlockedIncrement(&This->refcount);
337 TRACE("%p increasing refcount to %u.\n", This, refcount);
342 static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_Release(ID3D10RasterizerState *iface)
344 struct d3d10_rasterizer_state *state = impl_from_ID3D10RasterizerState(iface);
345 ULONG refcount = InterlockedDecrement(&state->refcount);
347 TRACE("%p decreasing refcount to %u.\n", state, refcount);
351 wine_rb_remove(&state->device->rasterizer_states, &state->desc);
352 HeapFree(GetProcessHeap(), 0, state);
358 /* ID3D10DeviceChild methods */
360 static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDevice(ID3D10RasterizerState *iface, ID3D10Device **device)
362 FIXME("iface %p, device %p stub!\n", iface, device);
365 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_GetPrivateData(ID3D10RasterizerState *iface,
366 REFGUID guid, UINT *data_size, void *data)
368 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
369 iface, debugstr_guid(guid), data_size, data);
374 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_SetPrivateData(ID3D10RasterizerState *iface,
375 REFGUID guid, UINT data_size, const void *data)
377 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
378 iface, debugstr_guid(guid), data_size, data);
383 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_SetPrivateDataInterface(ID3D10RasterizerState *iface,
384 REFGUID guid, const IUnknown *data)
386 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
391 /* ID3D10RasterizerState methods */
393 static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDesc(ID3D10RasterizerState *iface,
394 D3D10_RASTERIZER_DESC *desc)
396 struct d3d10_rasterizer_state *state = impl_from_ID3D10RasterizerState(iface);
398 TRACE("iface %p, desc %p.\n", iface, desc);
403 static const struct ID3D10RasterizerStateVtbl d3d10_rasterizer_state_vtbl =
405 /* IUnknown methods */
406 d3d10_rasterizer_state_QueryInterface,
407 d3d10_rasterizer_state_AddRef,
408 d3d10_rasterizer_state_Release,
409 /* ID3D10DeviceChild methods */
410 d3d10_rasterizer_state_GetDevice,
411 d3d10_rasterizer_state_GetPrivateData,
412 d3d10_rasterizer_state_SetPrivateData,
413 d3d10_rasterizer_state_SetPrivateDataInterface,
414 /* ID3D10RasterizerState methods */
415 d3d10_rasterizer_state_GetDesc,
418 HRESULT d3d10_rasterizer_state_init(struct d3d10_rasterizer_state *state, struct d3d10_device *device,
419 const D3D10_RASTERIZER_DESC *desc)
421 state->ID3D10RasterizerState_iface.lpVtbl = &d3d10_rasterizer_state_vtbl;
423 state->device = device;
426 if (wine_rb_put(&device->rasterizer_states, desc, &state->entry) == -1)
428 ERR("Failed to insert rasterizer state entry.\n");
435 struct d3d10_rasterizer_state *unsafe_impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface)
439 assert(iface->lpVtbl == &d3d10_rasterizer_state_vtbl);
441 return impl_from_ID3D10RasterizerState(iface);
444 static inline struct d3d10_sampler_state *impl_from_ID3D10SamplerState(ID3D10SamplerState *iface)
446 return CONTAINING_RECORD(iface, struct d3d10_sampler_state, ID3D10SamplerState_iface);
449 /* IUnknown methods */
451 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_QueryInterface(ID3D10SamplerState *iface,
452 REFIID riid, void **object)
454 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
456 if (IsEqualGUID(riid, &IID_ID3D10SamplerState)
457 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
458 || IsEqualGUID(riid, &IID_IUnknown))
460 IUnknown_AddRef(iface);
465 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
468 return E_NOINTERFACE;
471 static ULONG STDMETHODCALLTYPE d3d10_sampler_state_AddRef(ID3D10SamplerState *iface)
473 struct d3d10_sampler_state *This = impl_from_ID3D10SamplerState(iface);
474 ULONG refcount = InterlockedIncrement(&This->refcount);
476 TRACE("%p increasing refcount to %u.\n", This, refcount);
481 static ULONG STDMETHODCALLTYPE d3d10_sampler_state_Release(ID3D10SamplerState *iface)
483 struct d3d10_sampler_state *state = impl_from_ID3D10SamplerState(iface);
484 ULONG refcount = InterlockedDecrement(&state->refcount);
486 TRACE("%p decreasing refcount to %u.\n", state, refcount);
490 wined3d_sampler_decref(state->wined3d_sampler);
491 wine_rb_remove(&state->device->sampler_states, &state->desc);
492 HeapFree(GetProcessHeap(), 0, state);
498 /* ID3D10DeviceChild methods */
500 static void STDMETHODCALLTYPE d3d10_sampler_state_GetDevice(ID3D10SamplerState *iface, ID3D10Device **device)
502 FIXME("iface %p, device %p stub!\n", iface, device);
505 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_GetPrivateData(ID3D10SamplerState *iface,
506 REFGUID guid, UINT *data_size, void *data)
508 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
509 iface, debugstr_guid(guid), data_size, data);
514 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_SetPrivateData(ID3D10SamplerState *iface,
515 REFGUID guid, UINT data_size, const void *data)
517 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
518 iface, debugstr_guid(guid), data_size, data);
523 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_SetPrivateDataInterface(ID3D10SamplerState *iface,
524 REFGUID guid, const IUnknown *data)
526 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
531 /* ID3D10SamplerState methods */
533 static void STDMETHODCALLTYPE d3d10_sampler_state_GetDesc(ID3D10SamplerState *iface,
534 D3D10_SAMPLER_DESC *desc)
536 struct d3d10_sampler_state *state = impl_from_ID3D10SamplerState(iface);
538 TRACE("iface %p, desc %p.\n", iface, desc);
543 static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl =
545 /* IUnknown methods */
546 d3d10_sampler_state_QueryInterface,
547 d3d10_sampler_state_AddRef,
548 d3d10_sampler_state_Release,
549 /* ID3D10DeviceChild methods */
550 d3d10_sampler_state_GetDevice,
551 d3d10_sampler_state_GetPrivateData,
552 d3d10_sampler_state_SetPrivateData,
553 d3d10_sampler_state_SetPrivateDataInterface,
554 /* ID3D10SamplerState methods */
555 d3d10_sampler_state_GetDesc,
558 HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state, struct d3d10_device *device,
559 const D3D10_SAMPLER_DESC *desc)
563 state->ID3D10SamplerState_iface.lpVtbl = &d3d10_sampler_state_vtbl;
565 state->device = device;
568 if (FAILED(hr = wined3d_sampler_create(state, &state->wined3d_sampler)))
570 WARN("Failed to create wined3d sampler, hr %#x.\n", hr);
574 if (wine_rb_put(&device->sampler_states, desc, &state->entry) == -1)
576 ERR("Failed to insert sampler state entry.\n");
577 wined3d_sampler_decref(state->wined3d_sampler);
584 struct d3d10_sampler_state *unsafe_impl_from_ID3D10SamplerState(ID3D10SamplerState *iface)
588 assert(iface->lpVtbl == &d3d10_sampler_state_vtbl);
590 return impl_from_ID3D10SamplerState(iface);