wined3d: Handle the sampler type shift in the frontend.
[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, 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_device *This = (struct d3d10_device *)iface;
1027     struct d3d10_pixel_shader *object;
1028     const DWORD *shader_code;
1029     HRESULT hr;
1030
1031     TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1032             iface, byte_code, byte_code_length, shader);
1033
1034     hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_code);
1035     if (FAILED(hr))
1036     {
1037         ERR("Failed to extract shader, hr %#x\n", hr);
1038         return hr;
1039     }
1040
1041     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1042     if (!object)
1043     {
1044         ERR("Failed to allocate D3D10 pixel shader object memory\n");
1045         return E_OUTOFMEMORY;
1046     }
1047
1048     object->vtbl = &d3d10_pixel_shader_vtbl;
1049     object->refcount = 1;
1050
1051     hr = IWineD3DDevice_CreatePixelShader(This->wined3d_device,
1052             shader_code, &object->wined3d_shader, (IUnknown *)object);
1053     if (FAILED(hr))
1054     {
1055         ERR("CreatePixelShader failed, hr %#x\n", hr);
1056         HeapFree(GetProcessHeap(), 0, object);
1057         return hr;
1058     }
1059
1060     *shader = (ID3D10PixelShader *)object;
1061
1062     return S_OK;
1063 }
1064
1065 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
1066         const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1067 {
1068     FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1069
1070     return E_NOTIMPL;
1071 }
1072
1073 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1074         const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1075 {
1076     FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface, desc, depth_stencil_state);
1077
1078     return E_NOTIMPL;
1079 }
1080
1081 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1082         const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1083 {
1084     FIXME("iface %p, desc %p, rasterizer_state %p stub!\n", iface, desc, rasterizer_state);
1085
1086     return E_NOTIMPL;
1087 }
1088
1089 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1090         const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1091 {
1092     FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface, desc, sampler_state);
1093
1094     return E_NOTIMPL;
1095 }
1096
1097 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1098         const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1099 {
1100     FIXME("iface %p, desc %p, query %p stub!\n", iface, desc, query);
1101
1102     return E_NOTIMPL;
1103 }
1104
1105 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1106         const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1107 {
1108     FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1109
1110     return E_NOTIMPL;
1111 }
1112
1113 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1114         const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1115 {
1116     FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1117
1118     return E_NOTIMPL;
1119 }
1120
1121 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1122         DXGI_FORMAT format, UINT *format_support)
1123 {
1124     FIXME("iface %p, format %s, format_support %p stub!\n",
1125             iface, debug_dxgi_format(format), format_support);
1126
1127     return E_NOTIMPL;
1128 }
1129
1130 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1131         DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1132 {
1133     FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1134             iface, debug_dxgi_format(format), sample_count, quality_level_count);
1135
1136     return E_NOTIMPL;
1137 }
1138
1139 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1140 {
1141     FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1142 }
1143
1144 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1145         const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1146         UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1147 {
1148     FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1149             "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1150             iface, desc, type, active_counters, name, name_length,
1151             units, units_length, description, description_length);
1152
1153     return E_NOTIMPL;
1154 }
1155
1156 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1157 {
1158     FIXME("iface %p stub!\n", iface);
1159
1160     return 0;
1161 }
1162
1163 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1164         HANDLE resource_handle, REFIID guid, void **resource)
1165 {
1166     FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1167             iface, resource_handle, debugstr_guid(guid), resource);
1168
1169     return E_NOTIMPL;
1170 }
1171
1172 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1173 {
1174     FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1175 }
1176
1177 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1178 {
1179     FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1180 }
1181
1182 const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1183 {
1184     /* IUnknown methods */
1185     d3d10_device_QueryInterface,
1186     d3d10_device_AddRef,
1187     d3d10_device_Release,
1188     /* ID3D10Device methods */
1189     d3d10_device_VSSetConstantBuffers,
1190     d3d10_device_PSSetShaderResources,
1191     d3d10_device_PSSetShader,
1192     d3d10_device_PSSetSamplers,
1193     d3d10_device_VSSetShader,
1194     d3d10_device_DrawIndexed,
1195     d3d10_device_Draw,
1196     d3d10_device_PSSetConstantBuffers,
1197     d3d10_device_IASetInputLayout,
1198     d3d10_device_IASetVertexBuffers,
1199     d3d10_device_IASetIndexBuffer,
1200     d3d10_device_DrawIndexedInstanced,
1201     d3d10_device_DrawInstanced,
1202     d3d10_device_GSSetConstantBuffers,
1203     d3d10_device_GSSetShader,
1204     d3d10_device_IASetPrimitiveTopology,
1205     d3d10_device_VSSetShaderResources,
1206     d3d10_device_VSSetSamplers,
1207     d3d10_device_SetPredication,
1208     d3d10_device_GSSetShaderResources,
1209     d3d10_device_GSSetSamplers,
1210     d3d10_device_OMSetRenderTargets,
1211     d3d10_device_OMSetBlendState,
1212     d3d10_device_OMSetDepthStencilState,
1213     d3d10_device_SOSetTargets,
1214     d3d10_device_DrawAuto,
1215     d3d10_device_RSSetState,
1216     d3d10_device_RSSetViewports,
1217     d3d10_device_RSSetScissorRects,
1218     d3d10_device_CopySubresourceRegion,
1219     d3d10_device_CopyResource,
1220     d3d10_device_UpdateSubresource,
1221     d3d10_device_ClearRenderTargetView,
1222     d3d10_device_ClearDepthStencilView,
1223     d3d10_device_GenerateMips,
1224     d3d10_device_ResolveSubresource,
1225     d3d10_device_VSGetConstantBuffers,
1226     d3d10_device_PSGetShaderResources,
1227     d3d10_device_PSGetShader,
1228     d3d10_device_PSGetSamplers,
1229     d3d10_device_VSGetShader,
1230     d3d10_device_PSGetConstantBuffers,
1231     d3d10_device_IAGetInputLayout,
1232     d3d10_device_IAGetVertexBuffers,
1233     d3d10_device_IAGetIndexBuffer,
1234     d3d10_device_GSGetConstantBuffers,
1235     d3d10_device_GSGetShader,
1236     d3d10_device_IAGetPrimitiveTopology,
1237     d3d10_device_VSGetShaderResources,
1238     d3d10_device_VSGetSamplers,
1239     d3d10_device_GetPredication,
1240     d3d10_device_GSGetShaderResources,
1241     d3d10_device_GSGetSamplers,
1242     d3d10_device_OMGetRenderTargets,
1243     d3d10_device_OMGetBlendState,
1244     d3d10_device_OMGetDepthStencilState,
1245     d3d10_device_SOGetTargets,
1246     d3d10_device_RSGetState,
1247     d3d10_device_RSGetViewports,
1248     d3d10_device_RSGetScissorRects,
1249     d3d10_device_GetDeviceRemovedReason,
1250     d3d10_device_SetExceptionMode,
1251     d3d10_device_GetExceptionMode,
1252     d3d10_device_GetPrivateData,
1253     d3d10_device_SetPrivateData,
1254     d3d10_device_SetPrivateDataInterface,
1255     d3d10_device_ClearState,
1256     d3d10_device_Flush,
1257     d3d10_device_CreateBuffer,
1258     d3d10_device_CreateTexture1D,
1259     d3d10_device_CreateTexture2D,
1260     d3d10_device_CreateTexture3D,
1261     d3d10_device_CreateShaderResourceView,
1262     d3d10_device_CreateRenderTargetView,
1263     d3d10_device_CreateDepthStencilView,
1264     d3d10_device_CreateInputLayout,
1265     d3d10_device_CreateVertexShader,
1266     d3d10_device_CreateGeometryShader,
1267     d3d10_device_CreateGeometryShaderWithStreamOutput,
1268     d3d10_device_CreatePixelShader,
1269     d3d10_device_CreateBlendState,
1270     d3d10_device_CreateDepthStencilState,
1271     d3d10_device_CreateRasterizerState,
1272     d3d10_device_CreateSamplerState,
1273     d3d10_device_CreateQuery,
1274     d3d10_device_CreatePredicate,
1275     d3d10_device_CreateCounter,
1276     d3d10_device_CheckFormatSupport,
1277     d3d10_device_CheckMultisampleQualityLevels,
1278     d3d10_device_CheckCounterInfo,
1279     d3d10_device_CheckCounter,
1280     d3d10_device_GetCreationFlags,
1281     d3d10_device_OpenSharedResource,
1282     d3d10_device_SetTextFilterSize,
1283     d3d10_device_GetTextFilterSize,
1284 };
1285
1286 const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1287 {
1288     /* IUnknown methods */
1289     d3d10_device_inner_QueryInterface,
1290     d3d10_device_inner_AddRef,
1291     d3d10_device_inner_Release,
1292 };
1293
1294 /* IWineD3DDeviceParent IUnknown methods */
1295
1296 static inline struct d3d10_device *device_from_device_parent(IWineD3DDeviceParent *iface)
1297 {
1298     return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, device_parent_vtbl));
1299 }
1300
1301 static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
1302 {
1303     struct d3d10_device *This = device_from_device_parent(iface);
1304     return d3d10_device_QueryInterface((ID3D10Device *)This, riid, object);
1305 }
1306
1307 static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
1308 {
1309     struct d3d10_device *This = device_from_device_parent(iface);
1310     return d3d10_device_AddRef((ID3D10Device *)This);
1311 }
1312
1313 static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
1314 {
1315     struct d3d10_device *This = device_from_device_parent(iface);
1316     return d3d10_device_Release((ID3D10Device *)This);
1317 }
1318
1319 /* IWineD3DDeviceParent methods */
1320
1321 static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
1322 {
1323     struct d3d10_device *This = device_from_device_parent(iface);
1324
1325     TRACE("iface %p, device %p\n", iface, device);
1326
1327     IWineD3DDevice_AddRef(device);
1328     This->wined3d_device = device;
1329 }
1330
1331 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
1332         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
1333         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
1334 {
1335     struct d3d10_device *This = device_from_device_parent(iface);
1336     struct d3d10_texture2d *texture;
1337     D3D10_TEXTURE2D_DESC desc;
1338     HRESULT hr;
1339
1340     FIXME("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
1341             "\tpool %#x, level %u, face %u, surface %p partial stub!\n",
1342             iface, superior, width, height, format, usage, pool, level, face, surface);
1343
1344     FIXME("Implement DXGI<->wined3d usage conversion\n");
1345
1346     desc.Width = width;
1347     desc.Height = height;
1348     desc.MipLevels = 1;
1349     desc.ArraySize = 1;
1350     desc.Format = dxgi_format_from_wined3dformat(format);
1351     desc.SampleDesc.Count = 1;
1352     desc.SampleDesc.Quality = 0;
1353     desc.Usage = usage;
1354     desc.BindFlags = 0;
1355     desc.CPUAccessFlags = 0;
1356     desc.MiscFlags = 0;
1357
1358     hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1359     if (FAILED(hr))
1360     {
1361         ERR("CreateTexture2D failed, returning %#x\n", hr);
1362         return hr;
1363     }
1364
1365     *surface = texture->wined3d_surface;
1366
1367     return S_OK;
1368 }
1369
1370 static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
1371         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
1372         DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
1373 {
1374     struct d3d10_device *This = device_from_device_parent(iface);
1375     struct d3d10_texture2d *texture;
1376     D3D10_TEXTURE2D_DESC desc;
1377     HRESULT hr;
1378
1379     FIXME("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
1380             "\tmultisample_quality %u, lockable %u, surface %p partial stub!\n",
1381             iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
1382
1383     FIXME("Implement DXGI<->wined3d usage conversion\n");
1384
1385     desc.Width = width;
1386     desc.Height = height;
1387     desc.MipLevels = 1;
1388     desc.ArraySize = 1;
1389     desc.Format = dxgi_format_from_wined3dformat(format);
1390     desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1391     desc.SampleDesc.Quality = multisample_quality;
1392     desc.Usage = D3D10_USAGE_DEFAULT;
1393     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1394     desc.CPUAccessFlags = 0;
1395     desc.MiscFlags = 0;
1396
1397     hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1398     if (FAILED(hr))
1399     {
1400         ERR("CreateTexture2D failed, returning %#x\n", hr);
1401         return hr;
1402     }
1403
1404     *surface = texture->wined3d_surface;
1405
1406     return S_OK;
1407 }
1408
1409 static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
1410         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
1411         DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
1412 {
1413     struct d3d10_device *This = device_from_device_parent(iface);
1414     struct d3d10_texture2d *texture;
1415     D3D10_TEXTURE2D_DESC desc;
1416     HRESULT hr;
1417
1418     FIXME("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
1419             "\tmultisample_quality %u, discard %u, surface %p partial stub!\n",
1420             iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
1421
1422     FIXME("Implement DXGI<->wined3d usage conversion\n");
1423
1424     desc.Width = width;
1425     desc.Height = height;
1426     desc.MipLevels = 1;
1427     desc.ArraySize = 1;
1428     desc.Format = dxgi_format_from_wined3dformat(format);
1429     desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1430     desc.SampleDesc.Quality = multisample_quality;
1431     desc.Usage = D3D10_USAGE_DEFAULT;
1432     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1433     desc.CPUAccessFlags = 0;
1434     desc.MiscFlags = 0;
1435
1436     hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1437     if (FAILED(hr))
1438     {
1439         ERR("CreateTexture2D failed, returning %#x\n", hr);
1440         return hr;
1441     }
1442
1443     *surface = texture->wined3d_surface;
1444
1445     return S_OK;
1446 }
1447
1448 static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
1449         IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
1450         WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
1451 {
1452     FIXME("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p stub!\n",
1453             iface, superior, width, height, depth, format, pool, usage, volume);
1454
1455     return E_NOTIMPL;
1456 }
1457
1458 static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
1459         WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
1460 {
1461     IWineDXGIDevice *wine_device;
1462     HRESULT hr;
1463
1464     TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
1465
1466     hr = IWineD3DDeviceParent_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
1467     if (FAILED(hr))
1468     {
1469         ERR("Device should implement IWineDXGIDevice\n");
1470         return E_FAIL;
1471     }
1472
1473     hr = IWineDXGIDevice_create_swapchain(wine_device, present_parameters, swapchain);
1474     IWineDXGIDevice_Release(wine_device);
1475     if (FAILED(hr))
1476     {
1477         ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1478         return hr;
1479     }
1480
1481     return S_OK;
1482 }
1483
1484 const struct IWineD3DDeviceParentVtbl d3d10_wined3d_device_parent_vtbl =
1485 {
1486     /* IUnknown methods */
1487     device_parent_QueryInterface,
1488     device_parent_AddRef,
1489     device_parent_Release,
1490     /* IWineD3DDeviceParent methods */
1491     device_parent_WineD3DDeviceCreated,
1492     device_parent_CreateSurface,
1493     device_parent_CreateRenderTarget,
1494     device_parent_CreateDepthStencilSurface,
1495     device_parent_CreateVolume,
1496     device_parent_CreateSwapChain,
1497 };