wined3d: Store the register index in struct wined3d_shader_dst_param.
[wine] / dlls / d3d10core / device.c
1 /*
2  * Copyright 2008-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 /* Inner IUnknown methods */
28
29 static inline struct d3d10_device *d3d10_device_from_inner_unknown(IUnknown *iface)
30 {
31     return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, inner_unknown_vtbl));
32 }
33
34 static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object)
35 {
36     struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
37
38     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
39
40     if (IsEqualGUID(riid, &IID_IUnknown)
41             || IsEqualGUID(riid, &IID_ID3D10Device))
42     {
43         IUnknown_AddRef((IUnknown *)This);
44         *object = This;
45         return S_OK;
46     }
47
48     if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
49     {
50         IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
51         *object = &This->device_parent_vtbl;
52         return S_OK;
53     }
54
55     WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
56
57     *object = NULL;
58     return E_NOINTERFACE;
59 }
60
61 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
62 {
63     struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
64     ULONG refcount = InterlockedIncrement(&This->refcount);
65
66     TRACE("%p increasing refcount to %u\n", This, refcount);
67
68     return refcount;
69 }
70
71 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
72 {
73     struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
74     ULONG refcount = InterlockedDecrement(&This->refcount);
75
76     TRACE("%p decreasing refcount to %u\n", This, refcount);
77
78     if (!refcount)
79     {
80         if (This->wined3d_device) IWineD3DDevice_Release(This->wined3d_device);
81     }
82
83     return refcount;
84 }
85
86 /* IUnknown methods */
87
88 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid, void **object)
89 {
90     struct d3d10_device *This = (struct d3d10_device *)iface;
91     TRACE("Forwarding to outer IUnknown\n");
92     return IUnknown_QueryInterface(This->outer_unknown, riid, object);
93 }
94
95 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
96 {
97     struct d3d10_device *This = (struct d3d10_device *)iface;
98     TRACE("Forwarding to outer IUnknown\n");
99     return IUnknown_AddRef(This->outer_unknown);
100 }
101
102 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
103 {
104     struct d3d10_device *This = (struct d3d10_device *)iface;
105     TRACE("Forwarding to outer IUnknown\n");
106     return IUnknown_Release(This->outer_unknown);
107 }
108
109 /* ID3D10Device methods */
110
111 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
112         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
113 {
114     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
115             iface, start_slot, buffer_count, buffers);
116 }
117
118 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device *iface,
119         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
120 {
121     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
122             iface, start_slot, view_count, views);
123 }
124
125 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface, ID3D10PixelShader *shader)
126 {
127     FIXME("iface %p, shader %p stub!\n", iface, shader);
128 }
129
130 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface,
131         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
132 {
133     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
134             iface, start_slot, sampler_count, samplers);
135 }
136
137 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface, ID3D10VertexShader *shader)
138 {
139     FIXME("iface %p, shader %p stub!\n", iface, shader);
140 }
141
142 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface,
143         UINT index_count, UINT start_index_location, INT base_vertex_location)
144 {
145     FIXME("iface %p, index_count %u, start_index_location %u, base_vertex_location %d stub!\n",
146             iface, index_count, start_index_location, base_vertex_location);
147 }
148
149 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface,
150         UINT vertex_count, UINT start_vertex_location)
151 {
152     struct d3d10_device *This = (struct d3d10_device *)iface;
153
154     TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
155             iface, vertex_count, start_vertex_location);
156
157     IWineD3DDevice_DrawPrimitive(This->wined3d_device, start_vertex_location, vertex_count);
158 }
159
160 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
161         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
162 {
163     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
164             iface, start_slot, buffer_count, buffers);
165 }
166
167 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface, ID3D10InputLayout *input_layout)
168 {
169     struct d3d10_device *This = (struct d3d10_device *)iface;
170
171     TRACE("iface %p, input_layout %p\n", iface, input_layout);
172
173     IWineD3DDevice_SetVertexDeclaration(This->wined3d_device,
174             ((struct d3d10_input_layout *)input_layout)->wined3d_decl);
175 }
176
177 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *iface,
178         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers,
179         const UINT *strides, const UINT *offsets)
180 {
181     struct d3d10_device *This = (struct d3d10_device *)iface;
182     unsigned int i;
183
184     TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
185             iface, start_slot, buffer_count, buffers, strides, offsets);
186
187     for (i = 0; i < buffer_count; ++i)
188     {
189         IWineD3DDevice_SetStreamSource(This->wined3d_device, start_slot,
190                 ((struct d3d10_buffer *)buffers[i])->wined3d_buffer, offsets[i], strides[i]);
191     }
192 }
193
194 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
195         ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
196 {
197     FIXME("iface %p, buffer %p, format %s, offset %u stub!\n",
198             iface, buffer, debug_dxgi_format(format), offset);
199 }
200
201 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device *iface,
202         UINT instance_index_count, UINT instance_count, UINT start_index_location,
203         INT base_vertex_location, UINT start_instance_location)
204 {
205     FIXME("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
206             "\tbase_vertex_location %d, start_instance_location %u stub!\n",
207             iface, instance_index_count, instance_count, start_index_location,
208             base_vertex_location, start_instance_location);
209 }
210
211 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device *iface,
212         UINT instance_vertex_count, UINT instance_count,
213         UINT start_vertex_location, UINT start_instance_location)
214 {
215     FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
216             "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
217             start_vertex_location, start_instance_location);
218 }
219
220 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
221         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
222 {
223     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
224             iface, start_slot, buffer_count, buffers);
225 }
226
227 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
228 {
229     FIXME("iface %p, shader %p stub!\n", iface, shader);
230 }
231
232 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface, D3D10_PRIMITIVE_TOPOLOGY topology)
233 {
234     struct d3d10_device *This = (struct d3d10_device *)iface;
235
236     TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
237
238     IWineD3DDevice_SetPrimitiveType(This->wined3d_device, (WINED3DPRIMITIVETYPE)topology);
239 }
240
241 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
242         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
243 {
244     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
245             iface, start_slot, view_count, views);
246 }
247
248 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
249         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
250 {
251     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
252             iface, start_slot, sampler_count, samplers);
253 }
254
255 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
256 {
257     FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
258 }
259
260 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
261         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
262 {
263     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
264             iface, start_slot, view_count, views);
265 }
266
267 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
268         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
269 {
270     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
271             iface, start_slot, sampler_count, samplers);
272 }
273
274 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device *iface,
275         UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
276         ID3D10DepthStencilView *depth_stencil_view)
277 {
278     FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
279             iface, render_target_view_count, render_target_views, depth_stencil_view);
280 }
281
282 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
283         ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
284 {
285     FIXME("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x stub!\n",
286             iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
287 }
288
289 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
290         ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
291 {
292     FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n",
293             iface, depth_stencil_state, stencil_ref);
294 }
295
296 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
297         UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
298 {
299     FIXME("iface %p, target_count %u, targets %p, offsets %p stub!\n", iface, target_count, targets, offsets);
300 }
301
302 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
303 {
304     FIXME("iface %p stub!\n", iface);
305 }
306
307 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
308 {
309     FIXME("iface %p, rasterizer_state %p stub!\n", iface, rasterizer_state);
310 }
311
312 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
313         UINT viewport_count, const D3D10_VIEWPORT *viewports)
314 {
315     FIXME("iface %p, viewport_count %u, viewports %p stub!\n", iface, viewport_count, viewports);
316 }
317
318 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
319         UINT rect_count, const D3D10_RECT *rects)
320 {
321     FIXME("iface %p, rect_count %u, rects %p\n", iface, rect_count, rects);
322 }
323
324 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device *iface,
325         ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
326         ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
327 {
328     FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
329             "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
330             iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
331             src_resource, src_subresource_idx, src_box);
332 }
333
334 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
335         ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
336 {
337     FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
338 }
339
340 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface,
341         ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
342         const void *data, UINT row_pitch, UINT depth_pitch)
343 {
344     FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
345             iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
346 }
347
348 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
349         ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
350 {
351     struct d3d10_device *This = (struct d3d10_device *)iface;
352     IWineD3DRendertargetView *wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view;
353
354     TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
355             iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
356
357     IWineD3DDevice_ClearRendertargetView(This->wined3d_device, wined3d_view, color_rgba);
358 }
359
360 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
361         ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
362 {
363     FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
364             iface, depth_stencil_view, flags, depth, stencil);
365 }
366
367 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
368 {
369     FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
370 }
371
372 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device *iface,
373         ID3D10Resource *dst_resource, UINT dst_subresource_idx,
374         ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
375 {
376     FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
377             "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
378             iface, dst_resource, dst_subresource_idx,
379             src_resource, src_subresource_idx, debug_dxgi_format(format));
380 }
381
382 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
383         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
384 {
385     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
386             iface, start_slot, buffer_count, buffers);
387 }
388
389 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
390         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
391 {
392     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
393             iface, start_slot, view_count, views);
394 }
395
396 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
397 {
398     FIXME("iface %p, shader %p stub!\n", iface, shader);
399 }
400
401 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
402         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
403 {
404     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
405             iface, start_slot, sampler_count, samplers);
406 }
407
408 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
409 {
410     FIXME("iface %p, shader %p stub!\n", iface, shader);
411 }
412
413 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
414         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
415 {
416     FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
417             iface, start_slot, buffer_count, buffers);
418 }
419
420 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
421 {
422     FIXME("iface %p, input_layout %p stub!\n", iface, input_layout);
423 }
424
425 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
426         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
427 {
428     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
429             iface, start_slot, buffer_count, buffers, strides, offsets);
430 }
431
432 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
433         ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
434 {
435     FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
436 }
437
438 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
439         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
440 {
441     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
442             iface, start_slot, buffer_count, buffers);
443 }
444
445 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
446 {
447     FIXME("iface %p, shader %p stub!\n", iface, shader);
448 }
449
450 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface, D3D10_PRIMITIVE_TOPOLOGY *topology)
451 {
452     struct d3d10_device *This = (struct d3d10_device *)iface;
453
454     TRACE("iface %p, topology %p\n", iface, topology);
455
456     IWineD3DDevice_GetPrimitiveType(This->wined3d_device, (WINED3DPRIMITIVETYPE *)topology);
457 }
458
459 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
460         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
461 {
462     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
463             iface, start_slot, view_count, views);
464 }
465
466 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
467         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
468 {
469     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
470             iface, start_slot, sampler_count, samplers);
471 }
472
473 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
474         ID3D10Predicate **predicate, BOOL *value)
475 {
476     FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
477 }
478
479 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
480         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
481 {
482     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
483             iface, start_slot, view_count, views);
484 }
485
486 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
487         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
488 {
489     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
490             iface, start_slot, sampler_count, samplers);
491 }
492
493 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
494         UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
495 {
496     FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
497             iface, view_count, render_target_views, depth_stencil_view);
498 }
499
500 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
501         ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
502 {
503     FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
504             iface, blend_state, blend_factor, sample_mask);
505 }
506
507 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
508         ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
509 {
510     FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n",
511             iface, depth_stencil_state, stencil_ref);
512 }
513
514 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
515         UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
516 {
517     FIXME("iface %p, buffer_count %u, buffers %p, offsets %p stub!\n",
518             iface, buffer_count, buffers, offsets);
519 }
520
521 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
522 {
523     FIXME("iface %p, rasterizer_state %p stub!\n", iface, rasterizer_state);
524 }
525
526 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
527         UINT *viewport_count, D3D10_VIEWPORT *viewports)
528 {
529     FIXME("iface %p, viewport_count %p, viewports %p stub!\n", iface, viewport_count, viewports);
530 }
531
532 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
533 {
534     FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
535 }
536
537 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
538 {
539     FIXME("iface %p stub!\n", iface);
540
541     return E_NOTIMPL;
542 }
543
544 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
545 {
546     FIXME("iface %p, flags %#x stub!\n", iface, flags);
547
548     return E_NOTIMPL;
549 }
550
551 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
552 {
553     FIXME("iface %p stub!\n", iface);
554
555     return 0;
556 }
557
558 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
559         REFGUID guid, UINT *data_size, void *data)
560 {
561     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
562             iface, debugstr_guid(guid), data_size, data);
563
564     return E_NOTIMPL;
565 }
566
567 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
568         REFGUID guid, UINT data_size, const void *data)
569 {
570     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
571             iface, debugstr_guid(guid), data_size, data);
572
573     return E_NOTIMPL;
574 }
575
576 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
577         REFGUID guid, const IUnknown *data)
578 {
579     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
580
581     return E_NOTIMPL;
582 }
583
584 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
585 {
586     FIXME("iface %p stub!\n", iface);
587 }
588
589 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
590 {
591     FIXME("iface %p stub!\n", iface);
592 }
593
594 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
595         const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
596 {
597     struct d3d10_device *This = (struct d3d10_device *)iface;
598     struct wined3d_buffer_desc wined3d_desc;
599     struct d3d10_buffer *object;
600     HRESULT hr;
601
602     FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
603
604     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
605     if (!object)
606     {
607         ERR("Failed to allocate D3D10 buffer object memory\n");
608         return E_OUTOFMEMORY;
609     }
610
611     object->vtbl = &d3d10_buffer_vtbl;
612     object->refcount = 1;
613
614     FIXME("Implement DXGI<->wined3d usage conversion\n");
615
616     wined3d_desc.byte_width = desc->ByteWidth;
617     wined3d_desc.usage = desc->Usage;
618     wined3d_desc.bind_flags = desc->BindFlags;
619     wined3d_desc.cpu_access_flags = desc->CPUAccessFlags;
620     wined3d_desc.misc_flags = desc->MiscFlags;
621
622     hr = IWineD3DDevice_CreateBuffer(This->wined3d_device, &wined3d_desc,
623             data ? data->pSysMem : NULL, (IUnknown *)object, &object->wined3d_buffer);
624     if (FAILED(hr))
625     {
626         ERR("CreateBuffer failed, returning %#x\n", hr);
627         HeapFree(GetProcessHeap(), 0, object);
628         return hr;
629     }
630
631     *buffer = (ID3D10Buffer *)object;
632
633     TRACE("Created ID3D10Buffer %p\n", object);
634
635     return S_OK;
636 }
637
638 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
639         const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
640 {
641     FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
642
643     return E_NOTIMPL;
644 }
645
646 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
647         const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture2D **texture)
648 {
649     struct d3d10_device *This = (struct d3d10_device *)iface;
650     struct d3d10_texture2d *object;
651     HRESULT hr;
652
653     FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
654
655     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
656     if (!object)
657     {
658         ERR("Failed to allocate D3D10 texture2d object memory\n");
659         return E_OUTOFMEMORY;
660     }
661
662     object->vtbl = &d3d10_texture2d_vtbl;
663     object->refcount = 1;
664     object->desc = *desc;
665
666     if (desc->MipLevels == 1 && desc->ArraySize == 1)
667     {
668         IWineDXGIDevice *wine_device;
669
670         hr = ID3D10Device_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
671         if (FAILED(hr))
672         {
673             ERR("Device should implement IWineDXGIDevice\n");
674             HeapFree(GetProcessHeap(), 0, object);
675             return E_FAIL;
676         }
677
678         hr = IWineDXGIDevice_create_surface(wine_device, NULL, 0, NULL,
679                 (IUnknown *)object, (void **)&object->dxgi_surface);
680         IWineDXGIDevice_Release(wine_device);
681         if (FAILED(hr))
682         {
683             ERR("Failed to create DXGI surface, returning %#x\n", hr);
684             HeapFree(GetProcessHeap(), 0, object);
685             return hr;
686         }
687
688         FIXME("Implement DXGI<->wined3d usage conversion\n");
689
690         hr = IWineD3DDevice_CreateSurface(This->wined3d_device, desc->Width, desc->Height,
691                 wined3dformat_from_dxgi_format(desc->Format), FALSE, FALSE, 0,
692                 &object->wined3d_surface, WINED3DRTYPE_SURFACE, desc->Usage, WINED3DPOOL_DEFAULT,
693                 desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3DMULTISAMPLE_NONE,
694                 desc->SampleDesc.Quality, NULL, SURFACE_OPENGL, (IUnknown *)object);
695         if (FAILED(hr))
696         {
697             ERR("CreateSurface failed, returning %#x\n", hr);
698             IDXGISurface_Release(object->dxgi_surface);
699             HeapFree(GetProcessHeap(), 0, object);
700             return hr;
701         }
702     }
703
704     *texture = (ID3D10Texture2D *)object;
705
706     TRACE("Created ID3D10Texture2D %p\n", object);
707
708     return S_OK;
709 }
710
711 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
712         const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture3D **texture)
713 {
714     FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
715
716     return E_NOTIMPL;
717 }
718
719 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
720         ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
721 {
722     FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
723
724     return E_NOTIMPL;
725 }
726
727 static IWineD3DResource *d3d10_device_wined3d_resource_from_resource(ID3D10Resource *resource)
728 {
729     D3D10_RESOURCE_DIMENSION dimension;
730
731     ID3D10Resource_GetType(resource, &dimension);
732
733     switch(dimension)
734     {
735         case D3D10_RESOURCE_DIMENSION_BUFFER:
736             return (IWineD3DResource *)((struct d3d10_buffer *)resource)->wined3d_buffer;
737
738         case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
739             return (IWineD3DResource *)((struct d3d10_texture2d *)resource)->wined3d_surface;
740
741         default:
742             FIXME("Unhandled resource dimension %#x\n", dimension);
743             return NULL;
744     }
745 }
746
747 static HRESULT d3d10_device_set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10Resource *resource)
748 {
749     D3D10_RESOURCE_DIMENSION dimension;
750     HRESULT hr;
751
752     ID3D10Resource_GetType(resource, &dimension);
753
754     switch(dimension)
755     {
756         case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
757         {
758             ID3D10Texture1D *texture;
759             D3D10_TEXTURE1D_DESC texture_desc;
760
761             hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture);
762             if (FAILED(hr))
763             {
764                 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D?\n");
765                 return E_INVALIDARG;
766             }
767
768             ID3D10Texture1D_GetDesc(texture, &texture_desc);
769             ID3D10Texture1D_Release(texture);
770
771             desc->Format = texture_desc.Format;
772             if (texture_desc.ArraySize == 1)
773             {
774                 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE1D;
775                 desc->Texture1D.MipSlice = 0;
776             }
777             else
778             {
779                 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE1DARRAY;
780                 desc->Texture1DArray.MipSlice = 0;
781                 desc->Texture1DArray.FirstArraySlice = 0;
782                 desc->Texture1DArray.ArraySize = 1;
783             }
784
785             return S_OK;
786         }
787
788         case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
789         {
790             ID3D10Texture2D *texture;
791             D3D10_TEXTURE2D_DESC texture_desc;
792
793             hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture);
794             if (FAILED(hr))
795             {
796                 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D?\n");
797                 return E_INVALIDARG;
798             }
799
800             ID3D10Texture2D_GetDesc(texture, &texture_desc);
801             ID3D10Texture2D_Release(texture);
802
803             desc->Format = texture_desc.Format;
804             if (texture_desc.ArraySize == 1)
805             {
806                 if (texture_desc.SampleDesc.Count == 1)
807                 {
808                     desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
809                     desc->Texture2D.MipSlice = 0;
810                 }
811                 else
812                 {
813                     desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMS;
814                 }
815             }
816             else
817             {
818                 if (texture_desc.SampleDesc.Count == 1)
819                 {
820                     desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DARRAY;
821                     desc->Texture2DArray.MipSlice = 0;
822                     desc->Texture2DArray.FirstArraySlice = 0;
823                     desc->Texture2DArray.ArraySize = 1;
824                 }
825                 else
826                 {
827                     desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY;
828                     desc->Texture2DMSArray.FirstArraySlice = 0;
829                     desc->Texture2DMSArray.ArraySize = 1;
830                 }
831             }
832
833             return S_OK;
834         }
835
836         case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
837         {
838             ID3D10Texture3D *texture;
839             D3D10_TEXTURE3D_DESC texture_desc;
840
841             hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture);
842             if (FAILED(hr))
843             {
844                 ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D?\n");
845                 return E_INVALIDARG;
846             }
847
848             ID3D10Texture3D_GetDesc(texture, &texture_desc);
849             ID3D10Texture3D_Release(texture);
850
851             desc->Format = texture_desc.Format;
852             desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE3D;
853             desc->Texture3D.MipSlice = 0;
854             desc->Texture3D.FirstWSlice = 0;
855             desc->Texture3D.WSize = 1;
856
857             return S_OK;
858         }
859
860         default:
861             FIXME("Unhandled resource dimension %#x\n", dimension);
862             return E_INVALIDARG;
863     }
864 }
865
866 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
867         ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
868 {
869     struct d3d10_device *This = (struct d3d10_device *)iface;
870     struct d3d10_rendertarget_view *object;
871     IWineD3DResource *wined3d_resource;
872
873     TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
874
875     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
876     if (!object)
877     {
878         ERR("Failed to allocate D3D10 rendertarget view object memory\n");
879         return E_OUTOFMEMORY;
880     }
881
882     object->vtbl = &d3d10_rendertarget_view_vtbl;
883     object->refcount = 1;
884
885     if (!desc)
886     {
887         HRESULT hr = d3d10_device_set_rtdesc_from_resource(&object->desc, resource);
888         if (FAILED(hr))
889         {
890             HeapFree(GetProcessHeap(), 0, object);
891             return hr;
892         }
893     }
894     else
895     {
896         object->desc = *desc;
897     }
898
899     wined3d_resource = d3d10_device_wined3d_resource_from_resource(resource);
900     if (!wined3d_resource)
901     {
902         FIXME("Failed to get wined3d resource for d3d10 resource %p\n", resource);
903         HeapFree(GetProcessHeap(), 0, object);
904         return E_FAIL;
905     }
906     IWineD3DDevice_CreateRendertargetView(This->wined3d_device,
907             wined3d_resource, (IUnknown *)object, &object->wined3d_view);
908
909     *view = (ID3D10RenderTargetView *)object;
910
911     return S_OK;
912 }
913
914 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
915         ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
916 {
917     FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
918
919     return E_NOTIMPL;
920 }
921
922 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *iface,
923         const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code,
924         SIZE_T shader_byte_code_length, ID3D10InputLayout **input_layout)
925 {
926     struct d3d10_device *This = (struct d3d10_device *)iface;
927     struct d3d10_input_layout *object;
928     WINED3DVERTEXELEMENT *wined3d_elements;
929     UINT wined3d_element_count;
930     HRESULT hr;
931
932     TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
933             "\tshader_byte_code_length %lu, input_layout %p\n",
934             iface, element_descs, element_count, shader_byte_code,
935             shader_byte_code_length, input_layout);
936
937     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
938     if (!object)
939     {
940         ERR("Failed to allocate D3D10 input layout object memory\n");
941         return E_OUTOFMEMORY;
942     }
943
944     object->vtbl = &d3d10_input_layout_vtbl;
945     object->refcount = 1;
946
947     hr = d3d10_input_layout_to_wined3d_declaration(element_descs, element_count,
948             shader_byte_code, shader_byte_code_length, &wined3d_elements, &wined3d_element_count);
949     if (FAILED(hr))
950     {
951         HeapFree(GetProcessHeap(), 0, object);
952         return hr;
953     }
954
955     IWineD3DDevice_CreateVertexDeclaration(This->wined3d_device, &object->wined3d_decl,
956             (IUnknown *)object, wined3d_elements, wined3d_element_count);
957
958     HeapFree(GetProcessHeap(), 0, wined3d_elements);
959
960     *input_layout = (ID3D10InputLayout *)object;
961
962     return S_OK;
963 }
964
965 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
966         const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
967 {
968     struct d3d10_vertex_shader *object;
969
970     FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
971             iface, byte_code, byte_code_length, shader);
972
973     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
974     if (!object)
975     {
976         ERR("Failed to allocate D3D10 vertex shader object memory\n");
977         return E_OUTOFMEMORY;
978     }
979
980     object->vtbl = &d3d10_vertex_shader_vtbl;
981     object->refcount = 1;
982
983     *shader = (ID3D10VertexShader *)object;
984
985     return S_OK;
986 }
987
988 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
989         const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
990 {
991     struct d3d10_geometry_shader *object;
992
993     FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
994             iface, byte_code, byte_code_length, shader);
995
996     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
997     if (!object)
998     {
999         ERR("Failed to allocate D3D10 geometry shader object memory\n");
1000         return E_OUTOFMEMORY;
1001     }
1002
1003     object->vtbl = &d3d10_geometry_shader_vtbl;
1004     object->refcount = 1;
1005
1006     *shader = (ID3D10GeometryShader *)object;
1007
1008     return S_OK;
1009 }
1010
1011 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device *iface,
1012         const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1013         UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1014 {
1015     FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1016             "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1017             iface, byte_code, byte_code_length, output_stream_decls,
1018             output_stream_decl_count, output_stream_stride, shader);
1019
1020     return E_NOTIMPL;
1021 }
1022
1023 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
1024         const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1025 {
1026     struct d3d10_pixel_shader *object;
1027
1028     FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
1029             iface, byte_code, byte_code_length, shader);
1030
1031     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1032     if (!object)
1033     {
1034         ERR("Failed to allocate D3D10 pixel shader object memory\n");
1035         return E_OUTOFMEMORY;
1036     }
1037
1038     object->vtbl = &d3d10_pixel_shader_vtbl;
1039     object->refcount = 1;
1040
1041     *shader = (ID3D10PixelShader *)object;
1042
1043     return S_OK;
1044 }
1045
1046 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
1047         const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1048 {
1049     FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1050
1051     return E_NOTIMPL;
1052 }
1053
1054 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1055         const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1056 {
1057     FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface, desc, depth_stencil_state);
1058
1059     return E_NOTIMPL;
1060 }
1061
1062 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1063         const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1064 {
1065     FIXME("iface %p, desc %p, rasterizer_state %p stub!\n", iface, desc, rasterizer_state);
1066
1067     return E_NOTIMPL;
1068 }
1069
1070 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1071         const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1072 {
1073     FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface, desc, sampler_state);
1074
1075     return E_NOTIMPL;
1076 }
1077
1078 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1079         const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1080 {
1081     FIXME("iface %p, desc %p, query %p stub!\n", iface, desc, query);
1082
1083     return E_NOTIMPL;
1084 }
1085
1086 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1087         const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1088 {
1089     FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1090
1091     return E_NOTIMPL;
1092 }
1093
1094 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1095         const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1096 {
1097     FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1098
1099     return E_NOTIMPL;
1100 }
1101
1102 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1103         DXGI_FORMAT format, UINT *format_support)
1104 {
1105     FIXME("iface %p, format %s, format_support %p stub!\n",
1106             iface, debug_dxgi_format(format), format_support);
1107
1108     return E_NOTIMPL;
1109 }
1110
1111 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1112         DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1113 {
1114     FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1115             iface, debug_dxgi_format(format), sample_count, quality_level_count);
1116
1117     return E_NOTIMPL;
1118 }
1119
1120 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1121 {
1122     FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1123 }
1124
1125 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1126         const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1127         UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1128 {
1129     FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1130             "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1131             iface, desc, type, active_counters, name, name_length,
1132             units, units_length, description, description_length);
1133
1134     return E_NOTIMPL;
1135 }
1136
1137 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1138 {
1139     FIXME("iface %p stub!\n", iface);
1140
1141     return 0;
1142 }
1143
1144 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1145         HANDLE resource_handle, REFIID guid, void **resource)
1146 {
1147     FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1148             iface, resource_handle, debugstr_guid(guid), resource);
1149
1150     return E_NOTIMPL;
1151 }
1152
1153 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1154 {
1155     FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1156 }
1157
1158 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1159 {
1160     FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1161 }
1162
1163 const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1164 {
1165     /* IUnknown methods */
1166     d3d10_device_QueryInterface,
1167     d3d10_device_AddRef,
1168     d3d10_device_Release,
1169     /* ID3D10Device methods */
1170     d3d10_device_VSSetConstantBuffers,
1171     d3d10_device_PSSetShaderResources,
1172     d3d10_device_PSSetShader,
1173     d3d10_device_PSSetSamplers,
1174     d3d10_device_VSSetShader,
1175     d3d10_device_DrawIndexed,
1176     d3d10_device_Draw,
1177     d3d10_device_PSSetConstantBuffers,
1178     d3d10_device_IASetInputLayout,
1179     d3d10_device_IASetVertexBuffers,
1180     d3d10_device_IASetIndexBuffer,
1181     d3d10_device_DrawIndexedInstanced,
1182     d3d10_device_DrawInstanced,
1183     d3d10_device_GSSetConstantBuffers,
1184     d3d10_device_GSSetShader,
1185     d3d10_device_IASetPrimitiveTopology,
1186     d3d10_device_VSSetShaderResources,
1187     d3d10_device_VSSetSamplers,
1188     d3d10_device_SetPredication,
1189     d3d10_device_GSSetShaderResources,
1190     d3d10_device_GSSetSamplers,
1191     d3d10_device_OMSetRenderTargets,
1192     d3d10_device_OMSetBlendState,
1193     d3d10_device_OMSetDepthStencilState,
1194     d3d10_device_SOSetTargets,
1195     d3d10_device_DrawAuto,
1196     d3d10_device_RSSetState,
1197     d3d10_device_RSSetViewports,
1198     d3d10_device_RSSetScissorRects,
1199     d3d10_device_CopySubresourceRegion,
1200     d3d10_device_CopyResource,
1201     d3d10_device_UpdateSubresource,
1202     d3d10_device_ClearRenderTargetView,
1203     d3d10_device_ClearDepthStencilView,
1204     d3d10_device_GenerateMips,
1205     d3d10_device_ResolveSubresource,
1206     d3d10_device_VSGetConstantBuffers,
1207     d3d10_device_PSGetShaderResources,
1208     d3d10_device_PSGetShader,
1209     d3d10_device_PSGetSamplers,
1210     d3d10_device_VSGetShader,
1211     d3d10_device_PSGetConstantBuffers,
1212     d3d10_device_IAGetInputLayout,
1213     d3d10_device_IAGetVertexBuffers,
1214     d3d10_device_IAGetIndexBuffer,
1215     d3d10_device_GSGetConstantBuffers,
1216     d3d10_device_GSGetShader,
1217     d3d10_device_IAGetPrimitiveTopology,
1218     d3d10_device_VSGetShaderResources,
1219     d3d10_device_VSGetSamplers,
1220     d3d10_device_GetPredication,
1221     d3d10_device_GSGetShaderResources,
1222     d3d10_device_GSGetSamplers,
1223     d3d10_device_OMGetRenderTargets,
1224     d3d10_device_OMGetBlendState,
1225     d3d10_device_OMGetDepthStencilState,
1226     d3d10_device_SOGetTargets,
1227     d3d10_device_RSGetState,
1228     d3d10_device_RSGetViewports,
1229     d3d10_device_RSGetScissorRects,
1230     d3d10_device_GetDeviceRemovedReason,
1231     d3d10_device_SetExceptionMode,
1232     d3d10_device_GetExceptionMode,
1233     d3d10_device_GetPrivateData,
1234     d3d10_device_SetPrivateData,
1235     d3d10_device_SetPrivateDataInterface,
1236     d3d10_device_ClearState,
1237     d3d10_device_Flush,
1238     d3d10_device_CreateBuffer,
1239     d3d10_device_CreateTexture1D,
1240     d3d10_device_CreateTexture2D,
1241     d3d10_device_CreateTexture3D,
1242     d3d10_device_CreateShaderResourceView,
1243     d3d10_device_CreateRenderTargetView,
1244     d3d10_device_CreateDepthStencilView,
1245     d3d10_device_CreateInputLayout,
1246     d3d10_device_CreateVertexShader,
1247     d3d10_device_CreateGeometryShader,
1248     d3d10_device_CreateGeometryShaderWithStreamOutput,
1249     d3d10_device_CreatePixelShader,
1250     d3d10_device_CreateBlendState,
1251     d3d10_device_CreateDepthStencilState,
1252     d3d10_device_CreateRasterizerState,
1253     d3d10_device_CreateSamplerState,
1254     d3d10_device_CreateQuery,
1255     d3d10_device_CreatePredicate,
1256     d3d10_device_CreateCounter,
1257     d3d10_device_CheckFormatSupport,
1258     d3d10_device_CheckMultisampleQualityLevels,
1259     d3d10_device_CheckCounterInfo,
1260     d3d10_device_CheckCounter,
1261     d3d10_device_GetCreationFlags,
1262     d3d10_device_OpenSharedResource,
1263     d3d10_device_SetTextFilterSize,
1264     d3d10_device_GetTextFilterSize,
1265 };
1266
1267 const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1268 {
1269     /* IUnknown methods */
1270     d3d10_device_inner_QueryInterface,
1271     d3d10_device_inner_AddRef,
1272     d3d10_device_inner_Release,
1273 };
1274
1275 /* IWineD3DDeviceParent IUnknown methods */
1276
1277 static inline struct d3d10_device *device_from_device_parent(IWineD3DDeviceParent *iface)
1278 {
1279     return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, device_parent_vtbl));
1280 }
1281
1282 static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
1283 {
1284     struct d3d10_device *This = device_from_device_parent(iface);
1285     return d3d10_device_QueryInterface((ID3D10Device *)This, riid, object);
1286 }
1287
1288 static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
1289 {
1290     struct d3d10_device *This = device_from_device_parent(iface);
1291     return d3d10_device_AddRef((ID3D10Device *)This);
1292 }
1293
1294 static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
1295 {
1296     struct d3d10_device *This = device_from_device_parent(iface);
1297     return d3d10_device_Release((ID3D10Device *)This);
1298 }
1299
1300 /* IWineD3DDeviceParent methods */
1301
1302 static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
1303 {
1304     struct d3d10_device *This = device_from_device_parent(iface);
1305
1306     TRACE("iface %p, device %p\n", iface, device);
1307
1308     IWineD3DDevice_AddRef(device);
1309     This->wined3d_device = device;
1310 }
1311
1312 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
1313         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
1314         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
1315 {
1316     struct d3d10_device *This = device_from_device_parent(iface);
1317     struct d3d10_texture2d *texture;
1318     D3D10_TEXTURE2D_DESC desc;
1319     HRESULT hr;
1320
1321     FIXME("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
1322             "\tpool %#x, level %u, face %u, surface %p partial stub!\n",
1323             iface, superior, width, height, format, usage, pool, level, face, surface);
1324
1325     FIXME("Implement DXGI<->wined3d usage conversion\n");
1326
1327     desc.Width = width;
1328     desc.Height = height;
1329     desc.MipLevels = 1;
1330     desc.ArraySize = 1;
1331     desc.Format = dxgi_format_from_wined3dformat(format);
1332     desc.SampleDesc.Count = 1;
1333     desc.SampleDesc.Quality = 0;
1334     desc.Usage = usage;
1335     desc.BindFlags = 0;
1336     desc.CPUAccessFlags = 0;
1337     desc.MiscFlags = 0;
1338
1339     hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1340     if (FAILED(hr))
1341     {
1342         ERR("CreateTexture2D failed, returning %#x\n", hr);
1343         return hr;
1344     }
1345
1346     *surface = texture->wined3d_surface;
1347
1348     return S_OK;
1349 }
1350
1351 static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
1352         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
1353         DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
1354 {
1355     struct d3d10_device *This = device_from_device_parent(iface);
1356     struct d3d10_texture2d *texture;
1357     D3D10_TEXTURE2D_DESC desc;
1358     HRESULT hr;
1359
1360     FIXME("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
1361             "\tmultisample_quality %u, lockable %u, surface %p partial stub!\n",
1362             iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
1363
1364     FIXME("Implement DXGI<->wined3d usage conversion\n");
1365
1366     desc.Width = width;
1367     desc.Height = height;
1368     desc.MipLevels = 1;
1369     desc.ArraySize = 1;
1370     desc.Format = dxgi_format_from_wined3dformat(format);
1371     desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1372     desc.SampleDesc.Quality = multisample_quality;
1373     desc.Usage = D3D10_USAGE_DEFAULT;
1374     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1375     desc.CPUAccessFlags = 0;
1376     desc.MiscFlags = 0;
1377
1378     hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1379     if (FAILED(hr))
1380     {
1381         ERR("CreateTexture2D failed, returning %#x\n", hr);
1382         return hr;
1383     }
1384
1385     *surface = texture->wined3d_surface;
1386
1387     return S_OK;
1388 }
1389
1390 static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
1391         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
1392         DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
1393 {
1394     struct d3d10_device *This = device_from_device_parent(iface);
1395     struct d3d10_texture2d *texture;
1396     D3D10_TEXTURE2D_DESC desc;
1397     HRESULT hr;
1398
1399     FIXME("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
1400             "\tmultisample_quality %u, discard %u, surface %p partial stub!\n",
1401             iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
1402
1403     FIXME("Implement DXGI<->wined3d usage conversion\n");
1404
1405     desc.Width = width;
1406     desc.Height = height;
1407     desc.MipLevels = 1;
1408     desc.ArraySize = 1;
1409     desc.Format = dxgi_format_from_wined3dformat(format);
1410     desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1411     desc.SampleDesc.Quality = multisample_quality;
1412     desc.Usage = D3D10_USAGE_DEFAULT;
1413     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1414     desc.CPUAccessFlags = 0;
1415     desc.MiscFlags = 0;
1416
1417     hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1418     if (FAILED(hr))
1419     {
1420         ERR("CreateTexture2D failed, returning %#x\n", hr);
1421         return hr;
1422     }
1423
1424     *surface = texture->wined3d_surface;
1425
1426     return S_OK;
1427 }
1428
1429 static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
1430         IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
1431         WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
1432 {
1433     FIXME("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p stub!\n",
1434             iface, superior, width, height, depth, format, pool, usage, volume);
1435
1436     return E_NOTIMPL;
1437 }
1438
1439 static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
1440         WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
1441 {
1442     IWineDXGIDevice *wine_device;
1443     HRESULT hr;
1444
1445     TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
1446
1447     hr = IWineD3DDeviceParent_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
1448     if (FAILED(hr))
1449     {
1450         ERR("Device should implement IWineDXGIDevice\n");
1451         return E_FAIL;
1452     }
1453
1454     hr = IWineDXGIDevice_create_swapchain(wine_device, present_parameters, swapchain);
1455     IWineDXGIDevice_Release(wine_device);
1456     if (FAILED(hr))
1457     {
1458         ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1459         return hr;
1460     }
1461
1462     return S_OK;
1463 }
1464
1465 const struct IWineD3DDeviceParentVtbl d3d10_wined3d_device_parent_vtbl =
1466 {
1467     /* IUnknown methods */
1468     device_parent_QueryInterface,
1469     device_parent_AddRef,
1470     device_parent_Release,
1471     /* IWineD3DDeviceParent methods */
1472     device_parent_WineD3DDeviceCreated,
1473     device_parent_CreateSurface,
1474     device_parent_CreateRenderTarget,
1475     device_parent_CreateDepthStencilSurface,
1476     device_parent_CreateVolume,
1477     device_parent_CreateSwapChain,
1478 };