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