d3d10core: Implement d3d10_device_IAGetIndexBuffer().
[wine] / dlls / d3d10core / state.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  *
18  */
19
20 #include "config.h"
21 #include "wine/port.h"
22
23 #include "d3d10core_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
26
27 static inline struct d3d10_blend_state *impl_from_ID3D10BlendState(ID3D10BlendState *iface)
28 {
29     return CONTAINING_RECORD(iface, struct d3d10_blend_state, ID3D10BlendState_iface);
30 }
31
32 /* IUnknown methods */
33
34 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_QueryInterface(ID3D10BlendState *iface,
35         REFIID riid, void **object)
36 {
37     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
38
39     if (IsEqualGUID(riid, &IID_ID3D10BlendState)
40             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
41             || IsEqualGUID(riid, &IID_IUnknown))
42     {
43         IUnknown_AddRef(iface);
44         *object = iface;
45         return S_OK;
46     }
47
48     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
49
50     *object = NULL;
51     return E_NOINTERFACE;
52 }
53
54 static ULONG STDMETHODCALLTYPE d3d10_blend_state_AddRef(ID3D10BlendState *iface)
55 {
56     struct d3d10_blend_state *This = impl_from_ID3D10BlendState(iface);
57     ULONG refcount = InterlockedIncrement(&This->refcount);
58
59     TRACE("%p increasing refcount to %u.\n", This, refcount);
60
61     return refcount;
62 }
63
64 static ULONG STDMETHODCALLTYPE d3d10_blend_state_Release(ID3D10BlendState *iface)
65 {
66     struct d3d10_blend_state *This = impl_from_ID3D10BlendState(iface);
67     ULONG refcount = InterlockedDecrement(&This->refcount);
68
69     TRACE("%p decreasing refcount to %u.\n", This, refcount);
70
71     if (!refcount)
72     {
73         HeapFree(GetProcessHeap(), 0, This);
74     }
75
76     return refcount;
77 }
78
79 /* ID3D10DeviceChild methods */
80
81 static void STDMETHODCALLTYPE d3d10_blend_state_GetDevice(ID3D10BlendState *iface, ID3D10Device **device)
82 {
83     FIXME("iface %p, device %p stub!\n", iface, device);
84 }
85
86 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_GetPrivateData(ID3D10BlendState *iface,
87         REFGUID guid, UINT *data_size, void *data)
88 {
89     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
90             iface, debugstr_guid(guid), data_size, data);
91
92     return E_NOTIMPL;
93 }
94
95 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_SetPrivateData(ID3D10BlendState *iface,
96         REFGUID guid, UINT data_size, const void *data)
97 {
98     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
99             iface, debugstr_guid(guid), data_size, data);
100
101     return E_NOTIMPL;
102 }
103
104 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_SetPrivateDataInterface(ID3D10BlendState *iface,
105         REFGUID guid, const IUnknown *data)
106 {
107     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
108
109     return E_NOTIMPL;
110 }
111
112 /* ID3D10BlendState methods */
113
114 static void STDMETHODCALLTYPE d3d10_blend_state_GetDesc(ID3D10BlendState *iface,
115         D3D10_BLEND_DESC *desc)
116 {
117     FIXME("iface %p, desc %p stub!\n", iface, desc);
118 }
119
120 static const struct ID3D10BlendStateVtbl d3d10_blend_state_vtbl =
121 {
122     /* IUnknown methods */
123     d3d10_blend_state_QueryInterface,
124     d3d10_blend_state_AddRef,
125     d3d10_blend_state_Release,
126     /* ID3D10DeviceChild methods */
127     d3d10_blend_state_GetDevice,
128     d3d10_blend_state_GetPrivateData,
129     d3d10_blend_state_SetPrivateData,
130     d3d10_blend_state_SetPrivateDataInterface,
131     /* ID3D10BlendState methods */
132     d3d10_blend_state_GetDesc,
133 };
134
135 HRESULT d3d10_blend_state_init(struct d3d10_blend_state *state)
136 {
137     state->ID3D10BlendState_iface.lpVtbl = &d3d10_blend_state_vtbl;
138     state->refcount = 1;
139
140     return S_OK;
141 }
142
143 struct d3d10_blend_state *unsafe_impl_from_ID3D10BlendState(ID3D10BlendState *iface)
144 {
145     if (!iface)
146         return NULL;
147     assert(iface->lpVtbl == &d3d10_blend_state_vtbl);
148
149     return impl_from_ID3D10BlendState(iface);
150 }
151
152 static inline struct d3d10_depthstencil_state *impl_from_ID3D10DepthStencilState(ID3D10DepthStencilState *iface)
153 {
154     return CONTAINING_RECORD(iface, struct d3d10_depthstencil_state, ID3D10DepthStencilState_iface);
155 }
156
157 /* IUnknown methods */
158
159 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_QueryInterface(ID3D10DepthStencilState *iface,
160         REFIID riid, void **object)
161 {
162     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
163
164     if (IsEqualGUID(riid, &IID_ID3D10DepthStencilState)
165             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
166             || IsEqualGUID(riid, &IID_IUnknown))
167     {
168         IUnknown_AddRef(iface);
169         *object = iface;
170         return S_OK;
171     }
172
173     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
174
175     *object = NULL;
176     return E_NOINTERFACE;
177 }
178
179 static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_AddRef(ID3D10DepthStencilState *iface)
180 {
181     struct d3d10_depthstencil_state *This = impl_from_ID3D10DepthStencilState(iface);
182     ULONG refcount = InterlockedIncrement(&This->refcount);
183
184     TRACE("%p increasing refcount to %u.\n", This, refcount);
185
186     return refcount;
187 }
188
189 static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_Release(ID3D10DepthStencilState *iface)
190 {
191     struct d3d10_depthstencil_state *This = impl_from_ID3D10DepthStencilState(iface);
192     ULONG refcount = InterlockedDecrement(&This->refcount);
193
194     TRACE("%p decreasing refcount to %u.\n", This, refcount);
195
196     if (!refcount)
197     {
198         HeapFree(GetProcessHeap(), 0, This);
199     }
200
201     return refcount;
202 }
203
204 /* ID3D10DeviceChild methods */
205
206 static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDevice(ID3D10DepthStencilState *iface, ID3D10Device **device)
207 {
208     FIXME("iface %p, device %p stub!\n", iface, device);
209 }
210
211 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_GetPrivateData(ID3D10DepthStencilState *iface,
212         REFGUID guid, UINT *data_size, void *data)
213 {
214     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
215             iface, debugstr_guid(guid), data_size, data);
216
217     return E_NOTIMPL;
218 }
219
220 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_SetPrivateData(ID3D10DepthStencilState *iface,
221         REFGUID guid, UINT data_size, const void *data)
222 {
223     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
224             iface, debugstr_guid(guid), data_size, data);
225
226     return E_NOTIMPL;
227 }
228
229 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_SetPrivateDataInterface(ID3D10DepthStencilState *iface,
230         REFGUID guid, const IUnknown *data)
231 {
232     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
233
234     return E_NOTIMPL;
235 }
236
237 /* ID3D10DepthStencilState methods */
238
239 static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDesc(ID3D10DepthStencilState *iface,
240         D3D10_DEPTH_STENCIL_DESC *desc)
241 {
242     FIXME("iface %p, desc %p stub!\n", iface, desc);
243 }
244
245 static const struct ID3D10DepthStencilStateVtbl d3d10_depthstencil_state_vtbl =
246 {
247     /* IUnknown methods */
248     d3d10_depthstencil_state_QueryInterface,
249     d3d10_depthstencil_state_AddRef,
250     d3d10_depthstencil_state_Release,
251     /* ID3D10DeviceChild methods */
252     d3d10_depthstencil_state_GetDevice,
253     d3d10_depthstencil_state_GetPrivateData,
254     d3d10_depthstencil_state_SetPrivateData,
255     d3d10_depthstencil_state_SetPrivateDataInterface,
256     /* ID3D10DepthStencilState methods */
257     d3d10_depthstencil_state_GetDesc,
258 };
259
260 HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state)
261 {
262     state->ID3D10DepthStencilState_iface.lpVtbl = &d3d10_depthstencil_state_vtbl;
263     state->refcount = 1;
264
265     return S_OK;
266 }
267
268 struct d3d10_depthstencil_state *unsafe_impl_from_ID3D10DepthStencilState(ID3D10DepthStencilState *iface)
269 {
270     if (!iface)
271         return NULL;
272     assert(iface->lpVtbl == &d3d10_depthstencil_state_vtbl);
273
274     return impl_from_ID3D10DepthStencilState(iface);
275 }
276
277 static inline struct d3d10_rasterizer_state *impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface)
278 {
279     return CONTAINING_RECORD(iface, struct d3d10_rasterizer_state, ID3D10RasterizerState_iface);
280 }
281
282 /* IUnknown methods */
283
284 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_QueryInterface(ID3D10RasterizerState *iface,
285         REFIID riid, void **object)
286 {
287     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
288
289     if (IsEqualGUID(riid, &IID_ID3D10RasterizerState)
290             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
291             || IsEqualGUID(riid, &IID_IUnknown))
292     {
293         IUnknown_AddRef(iface);
294         *object = iface;
295         return S_OK;
296     }
297
298     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
299
300     *object = NULL;
301     return E_NOINTERFACE;
302 }
303
304 static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_AddRef(ID3D10RasterizerState *iface)
305 {
306     struct d3d10_rasterizer_state *This = impl_from_ID3D10RasterizerState(iface);
307     ULONG refcount = InterlockedIncrement(&This->refcount);
308
309     TRACE("%p increasing refcount to %u.\n", This, refcount);
310
311     return refcount;
312 }
313
314 static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_Release(ID3D10RasterizerState *iface)
315 {
316     struct d3d10_rasterizer_state *This = impl_from_ID3D10RasterizerState(iface);
317     ULONG refcount = InterlockedDecrement(&This->refcount);
318
319     TRACE("%p decreasing refcount to %u.\n", This, refcount);
320
321     if (!refcount)
322     {
323         HeapFree(GetProcessHeap(), 0, This);
324     }
325
326     return refcount;
327 }
328
329 /* ID3D10DeviceChild methods */
330
331 static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDevice(ID3D10RasterizerState *iface, ID3D10Device **device)
332 {
333     FIXME("iface %p, device %p stub!\n", iface, device);
334 }
335
336 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_GetPrivateData(ID3D10RasterizerState *iface,
337         REFGUID guid, UINT *data_size, void *data)
338 {
339     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
340             iface, debugstr_guid(guid), data_size, data);
341
342     return E_NOTIMPL;
343 }
344
345 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_SetPrivateData(ID3D10RasterizerState *iface,
346         REFGUID guid, UINT data_size, const void *data)
347 {
348     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
349             iface, debugstr_guid(guid), data_size, data);
350
351     return E_NOTIMPL;
352 }
353
354 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_SetPrivateDataInterface(ID3D10RasterizerState *iface,
355         REFGUID guid, const IUnknown *data)
356 {
357     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
358
359     return E_NOTIMPL;
360 }
361
362 /* ID3D10RasterizerState methods */
363
364 static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDesc(ID3D10RasterizerState *iface,
365         D3D10_RASTERIZER_DESC *desc)
366 {
367     FIXME("iface %p, desc %p stub!\n", iface, desc);
368 }
369
370 static const struct ID3D10RasterizerStateVtbl d3d10_rasterizer_state_vtbl =
371 {
372     /* IUnknown methods */
373     d3d10_rasterizer_state_QueryInterface,
374     d3d10_rasterizer_state_AddRef,
375     d3d10_rasterizer_state_Release,
376     /* ID3D10DeviceChild methods */
377     d3d10_rasterizer_state_GetDevice,
378     d3d10_rasterizer_state_GetPrivateData,
379     d3d10_rasterizer_state_SetPrivateData,
380     d3d10_rasterizer_state_SetPrivateDataInterface,
381     /* ID3D10RasterizerState methods */
382     d3d10_rasterizer_state_GetDesc,
383 };
384
385 HRESULT d3d10_rasterizer_state_init(struct d3d10_rasterizer_state *state)
386 {
387     state->ID3D10RasterizerState_iface.lpVtbl = &d3d10_rasterizer_state_vtbl;
388     state->refcount = 1;
389
390     return S_OK;
391 }
392
393 struct d3d10_rasterizer_state *unsafe_impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface)
394 {
395     if (!iface)
396         return NULL;
397     assert(iface->lpVtbl == &d3d10_rasterizer_state_vtbl);
398
399     return impl_from_ID3D10RasterizerState(iface);
400 }
401
402 static inline struct d3d10_sampler_state *impl_from_ID3D10SamplerState(ID3D10SamplerState *iface)
403 {
404     return CONTAINING_RECORD(iface, struct d3d10_sampler_state, ID3D10SamplerState_iface);
405 }
406
407 /* IUnknown methods */
408
409 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_QueryInterface(ID3D10SamplerState *iface,
410         REFIID riid, void **object)
411 {
412     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
413
414     if (IsEqualGUID(riid, &IID_ID3D10SamplerState)
415             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
416             || IsEqualGUID(riid, &IID_IUnknown))
417     {
418         IUnknown_AddRef(iface);
419         *object = iface;
420         return S_OK;
421     }
422
423     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
424
425     *object = NULL;
426     return E_NOINTERFACE;
427 }
428
429 static ULONG STDMETHODCALLTYPE d3d10_sampler_state_AddRef(ID3D10SamplerState *iface)
430 {
431     struct d3d10_sampler_state *This = impl_from_ID3D10SamplerState(iface);
432     ULONG refcount = InterlockedIncrement(&This->refcount);
433
434     TRACE("%p increasing refcount to %u.\n", This, refcount);
435
436     return refcount;
437 }
438
439 static ULONG STDMETHODCALLTYPE d3d10_sampler_state_Release(ID3D10SamplerState *iface)
440 {
441     struct d3d10_sampler_state *This = impl_from_ID3D10SamplerState(iface);
442     ULONG refcount = InterlockedDecrement(&This->refcount);
443
444     TRACE("%p decreasing refcount to %u.\n", This, refcount);
445
446     if (!refcount)
447     {
448         HeapFree(GetProcessHeap(), 0, This);
449     }
450
451     return refcount;
452 }
453
454 /* ID3D10DeviceChild methods */
455
456 static void STDMETHODCALLTYPE d3d10_sampler_state_GetDevice(ID3D10SamplerState *iface, ID3D10Device **device)
457 {
458     FIXME("iface %p, device %p stub!\n", iface, device);
459 }
460
461 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_GetPrivateData(ID3D10SamplerState *iface,
462         REFGUID guid, UINT *data_size, void *data)
463 {
464     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
465             iface, debugstr_guid(guid), data_size, data);
466
467     return E_NOTIMPL;
468 }
469
470 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_SetPrivateData(ID3D10SamplerState *iface,
471         REFGUID guid, UINT data_size, const void *data)
472 {
473     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
474             iface, debugstr_guid(guid), data_size, data);
475
476     return E_NOTIMPL;
477 }
478
479 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_SetPrivateDataInterface(ID3D10SamplerState *iface,
480         REFGUID guid, const IUnknown *data)
481 {
482     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
483
484     return E_NOTIMPL;
485 }
486
487 /* ID3D10SamplerState methods */
488
489 static void STDMETHODCALLTYPE d3d10_sampler_state_GetDesc(ID3D10SamplerState *iface,
490         D3D10_SAMPLER_DESC *desc)
491 {
492     FIXME("iface %p, desc %p stub!\n", iface, desc);
493 }
494
495 static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl =
496 {
497     /* IUnknown methods */
498     d3d10_sampler_state_QueryInterface,
499     d3d10_sampler_state_AddRef,
500     d3d10_sampler_state_Release,
501     /* ID3D10DeviceChild methods */
502     d3d10_sampler_state_GetDevice,
503     d3d10_sampler_state_GetPrivateData,
504     d3d10_sampler_state_SetPrivateData,
505     d3d10_sampler_state_SetPrivateDataInterface,
506     /* ID3D10SamplerState methods */
507     d3d10_sampler_state_GetDesc,
508 };
509
510 HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state)
511 {
512     state->ID3D10SamplerState_iface.lpVtbl = &d3d10_sampler_state_vtbl;
513     state->refcount = 1;
514
515     return S_OK;
516 }