quartz: Remove unused variables.
[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 static void STDMETHODCALLTYPE d3d10_null_wined3d_object_destroyed(void *parent) {}
28
29 const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops =
30 {
31     d3d10_null_wined3d_object_destroyed,
32 };
33
34 /* Inner IUnknown methods */
35
36 static inline struct d3d10_device *impl_from_IUnknown(IUnknown *iface)
37 {
38     return CONTAINING_RECORD(iface, struct d3d10_device, IUnknown_inner);
39 }
40
41 static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid,
42         void **ppv)
43 {
44     struct d3d10_device *This = impl_from_IUnknown(iface);
45
46     TRACE("iface %p, riid %s, ppv %p\n", iface, debugstr_guid(riid), ppv);
47
48     if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3D10Device))
49         *ppv = &This->ID3D10Device_iface;
50     else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
51         *ppv = &This->IWineDXGIDeviceParent_iface;
52     else
53     {
54         WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
55         *ppv = NULL;
56         return E_NOINTERFACE;
57     }
58
59     IUnknown_AddRef((IUnknown*)*ppv);
60     return S_OK;
61 }
62
63 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
64 {
65     struct d3d10_device *This = impl_from_IUnknown(iface);
66     ULONG refcount = InterlockedIncrement(&This->refcount);
67
68     TRACE("%p increasing refcount to %u\n", This, refcount);
69
70     return refcount;
71 }
72
73 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
74 {
75     struct d3d10_device *This = impl_from_IUnknown(iface);
76     ULONG refcount = InterlockedDecrement(&This->refcount);
77
78     TRACE("%p decreasing refcount to %u\n", This, refcount);
79
80     if (!refcount)
81     {
82         if (This->wined3d_device)
83             wined3d_device_decref(This->wined3d_device);
84     }
85
86     return refcount;
87 }
88
89 /* IUnknown methods */
90
91 static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device *iface)
92 {
93     return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device_iface);
94 }
95
96 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid,
97         void **ppv)
98 {
99     struct d3d10_device *This = impl_from_ID3D10Device(iface);
100     return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
101 }
102
103 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
104 {
105     struct d3d10_device *This = impl_from_ID3D10Device(iface);
106     return IUnknown_AddRef(This->outer_unk);
107 }
108
109 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
110 {
111     struct d3d10_device *This = impl_from_ID3D10Device(iface);
112     return IUnknown_Release(This->outer_unk);
113 }
114
115 /* ID3D10Device methods */
116
117 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
118         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
119 {
120     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
121             iface, start_slot, buffer_count, buffers);
122 }
123
124 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device *iface,
125         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
126 {
127     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
128             iface, start_slot, view_count, views);
129 }
130
131 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface,
132         ID3D10PixelShader *shader)
133 {
134     struct d3d10_device *This = impl_from_ID3D10Device(iface);
135     struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
136
137     TRACE("iface %p, shader %p\n", iface, shader);
138
139     wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
140 }
141
142 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface,
143         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
144 {
145     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
146             iface, start_slot, sampler_count, samplers);
147 }
148
149 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface,
150         ID3D10VertexShader *shader)
151 {
152     struct d3d10_device *This = impl_from_ID3D10Device(iface);
153     struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
154
155     TRACE("iface %p, shader %p\n", iface, shader);
156
157     wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
158 }
159
160 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface, UINT index_count,
161         UINT start_index_location, INT base_vertex_location)
162 {
163     struct d3d10_device *This = impl_from_ID3D10Device(iface);
164
165     TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
166             iface, index_count, start_index_location, base_vertex_location);
167
168     wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
169     wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
170 }
171
172 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface, UINT vertex_count,
173         UINT start_vertex_location)
174 {
175     struct d3d10_device *This = impl_from_ID3D10Device(iface);
176
177     TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
178             iface, vertex_count, start_vertex_location);
179
180     wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
181 }
182
183 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
184         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
185 {
186     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
187             iface, start_slot, buffer_count, buffers);
188 }
189
190 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface,
191         ID3D10InputLayout *input_layout)
192 {
193     struct d3d10_device *This = impl_from_ID3D10Device(iface);
194     struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
195
196     TRACE("iface %p, input_layout %p\n", iface, input_layout);
197
198     wined3d_device_set_vertex_declaration(This->wined3d_device,
199             layout ? layout->wined3d_decl : NULL);
200 }
201
202 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *iface, UINT start_slot,
203         UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
204 {
205     struct d3d10_device *This = impl_from_ID3D10Device(iface);
206     unsigned int i;
207
208     TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
209             iface, start_slot, buffer_count, buffers, strides, offsets);
210
211     for (i = 0; i < buffer_count; ++i)
212     {
213         struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
214
215         wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
216                 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
217     }
218 }
219
220 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
221         ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
222 {
223     struct d3d10_device *This = impl_from_ID3D10Device(iface);
224     struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
225
226     TRACE("iface %p, buffer %p, format %s, offset %u.\n",
227             iface, buffer, debug_dxgi_format(format), offset);
228
229     wined3d_device_set_index_buffer(This->wined3d_device,
230             buffer_impl ? buffer_impl->wined3d_buffer : NULL,
231             wined3dformat_from_dxgi_format(format));
232     if (offset) FIXME("offset %u not supported.\n", offset);
233 }
234
235 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device *iface,
236         UINT instance_index_count, UINT instance_count, UINT start_index_location,
237         INT base_vertex_location, UINT start_instance_location)
238 {
239     FIXME("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
240             "\tbase_vertex_location %d, start_instance_location %u stub!\n",
241             iface, instance_index_count, instance_count, start_index_location,
242             base_vertex_location, start_instance_location);
243 }
244
245 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device *iface,
246         UINT instance_vertex_count, UINT instance_count,
247         UINT start_vertex_location, UINT start_instance_location)
248 {
249     FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
250             "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
251             start_vertex_location, start_instance_location);
252 }
253
254 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
255         UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
256 {
257     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
258             iface, start_slot, buffer_count, buffers);
259 }
260
261 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
262 {
263     struct d3d10_device *device = impl_from_ID3D10Device(iface);
264     struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
265
266     TRACE("iface %p, shader %p.\n", iface, shader);
267
268     wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
269 }
270
271 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface,
272         D3D10_PRIMITIVE_TOPOLOGY topology)
273 {
274     struct d3d10_device *This = impl_from_ID3D10Device(iface);
275
276     TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
277
278     wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
279 }
280
281 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
282         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
283 {
284     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
285             iface, start_slot, view_count, views);
286 }
287
288 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
289         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
290 {
291     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
292             iface, start_slot, sampler_count, samplers);
293 }
294
295 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
296 {
297     FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
298 }
299
300 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
301         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
302 {
303     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
304             iface, start_slot, view_count, views);
305 }
306
307 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
308         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
309 {
310     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
311             iface, start_slot, sampler_count, samplers);
312 }
313
314 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device *iface,
315         UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
316         ID3D10DepthStencilView *depth_stencil_view)
317 {
318     FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
319             iface, render_target_view_count, render_target_views, depth_stencil_view);
320 }
321
322 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
323         ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
324 {
325     struct d3d10_device *device = impl_from_ID3D10Device(iface);
326
327     TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
328             iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
329
330     device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
331     memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
332     device->sample_mask = sample_mask;
333 }
334
335 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
336         ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
337 {
338     struct d3d10_device *device = impl_from_ID3D10Device(iface);
339
340     TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
341             iface, depth_stencil_state, stencil_ref);
342
343     device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
344     device->stencil_ref = stencil_ref;
345 }
346
347 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
348         UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
349 {
350     FIXME("iface %p, target_count %u, targets %p, offsets %p stub!\n", iface, target_count, targets, offsets);
351 }
352
353 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
354 {
355     FIXME("iface %p stub!\n", iface);
356 }
357
358 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
359 {
360     struct d3d10_device *device = impl_from_ID3D10Device(iface);
361
362     TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
363
364     device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
365 }
366
367 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
368         UINT viewport_count, const D3D10_VIEWPORT *viewports)
369 {
370     struct d3d10_device *device = impl_from_ID3D10Device(iface);
371     struct wined3d_viewport wined3d_vp;
372
373     TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
374
375     if (viewport_count > 1)
376         FIXME("Multiple viewports not implemented.\n");
377
378     if (!viewport_count)
379         return;
380
381     wined3d_vp.x = viewports[0].TopLeftX;
382     wined3d_vp.y = viewports[0].TopLeftY;
383     wined3d_vp.width = viewports[0].Width;
384     wined3d_vp.height = viewports[0].Height;
385     wined3d_vp.min_z = viewports[0].MinDepth;
386     wined3d_vp.max_z = viewports[0].MaxDepth;
387
388     wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
389 }
390
391 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
392         UINT rect_count, const D3D10_RECT *rects)
393 {
394     FIXME("iface %p, rect_count %u, rects %p\n", iface, rect_count, rects);
395 }
396
397 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device *iface,
398         ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
399         ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
400 {
401     FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
402             "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
403             iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
404             src_resource, src_subresource_idx, src_box);
405 }
406
407 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
408         ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
409 {
410     FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
411 }
412
413 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface,
414         ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
415         const void *data, UINT row_pitch, UINT depth_pitch)
416 {
417     FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
418             iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
419 }
420
421 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
422         ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
423 {
424     struct d3d10_device *This = impl_from_ID3D10Device(iface);
425     struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
426     const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
427
428     TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
429             iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
430
431     wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
432 }
433
434 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
435         ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
436 {
437     FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
438             iface, depth_stencil_view, flags, depth, stencil);
439 }
440
441 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
442 {
443     FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
444 }
445
446 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device *iface,
447         ID3D10Resource *dst_resource, UINT dst_subresource_idx,
448         ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
449 {
450     FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
451             "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
452             iface, dst_resource, dst_subresource_idx,
453             src_resource, src_subresource_idx, debug_dxgi_format(format));
454 }
455
456 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
457         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
458 {
459     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
460             iface, start_slot, buffer_count, buffers);
461 }
462
463 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
464         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
465 {
466     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
467             iface, start_slot, view_count, views);
468 }
469
470 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
471 {
472     struct d3d10_device *device = impl_from_ID3D10Device(iface);
473     struct d3d10_pixel_shader *shader_impl;
474     struct wined3d_shader *wined3d_shader;
475
476     TRACE("iface %p, shader %p.\n", iface, shader);
477
478     if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
479     {
480         *shader = NULL;
481         return;
482     }
483
484     shader_impl = wined3d_shader_get_parent(wined3d_shader);
485     *shader = &shader_impl->ID3D10PixelShader_iface;
486     ID3D10PixelShader_AddRef(*shader);
487 }
488
489 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
490         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
491 {
492     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
493             iface, start_slot, sampler_count, samplers);
494 }
495
496 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
497 {
498     struct d3d10_device *device = impl_from_ID3D10Device(iface);
499     struct d3d10_vertex_shader *shader_impl;
500     struct wined3d_shader *wined3d_shader;
501
502     TRACE("iface %p, shader %p.\n", iface, shader);
503
504     if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
505     {
506         *shader = NULL;
507         return;
508     }
509
510     shader_impl = wined3d_shader_get_parent(wined3d_shader);
511     *shader = &shader_impl->ID3D10VertexShader_iface;
512     ID3D10VertexShader_AddRef(*shader);
513 }
514
515 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
516         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
517 {
518     FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
519             iface, start_slot, buffer_count, buffers);
520 }
521
522 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
523 {
524     FIXME("iface %p, input_layout %p stub!\n", iface, input_layout);
525 }
526
527 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
528         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
529 {
530     struct d3d10_device *device = impl_from_ID3D10Device(iface);
531     unsigned int i;
532
533     TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
534             iface, start_slot, buffer_count, buffers, strides, offsets);
535
536     for (i = 0; i < buffer_count; ++i)
537     {
538         struct wined3d_buffer *wined3d_buffer;
539         struct d3d10_buffer *buffer_impl;
540
541         if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
542                 &wined3d_buffer, &offsets[i], &strides[i])))
543             ERR("Failed to get vertex buffer.\n");
544
545         if (!wined3d_buffer)
546         {
547             buffers[i] = NULL;
548             continue;
549         }
550
551         buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
552         buffers[i] = &buffer_impl->ID3D10Buffer_iface;
553         ID3D10Buffer_AddRef(buffers[i]);
554     }
555 }
556
557 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
558         ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
559 {
560     struct d3d10_device *device = impl_from_ID3D10Device(iface);
561     enum wined3d_format_id wined3d_format;
562     struct wined3d_buffer *wined3d_buffer;
563     struct d3d10_buffer *buffer_impl;
564
565     TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
566
567     wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
568     *format = dxgi_format_from_wined3dformat(wined3d_format);
569     *offset = 0; /* FIXME */
570     if (!wined3d_buffer)
571     {
572         *buffer = NULL;
573         return;
574     }
575
576     buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
577     *buffer = &buffer_impl->ID3D10Buffer_iface;
578     ID3D10Buffer_AddRef(*buffer);
579 }
580
581 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
582         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
583 {
584     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
585             iface, start_slot, buffer_count, buffers);
586 }
587
588 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
589 {
590     struct d3d10_device *device = impl_from_ID3D10Device(iface);
591     struct d3d10_geometry_shader *shader_impl;
592     struct wined3d_shader *wined3d_shader;
593
594     TRACE("iface %p, shader %p.\n", iface, shader);
595
596     if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
597     {
598         *shader = NULL;
599         return;
600     }
601
602     shader_impl = wined3d_shader_get_parent(wined3d_shader);
603     *shader = &shader_impl->ID3D10GeometryShader_iface;
604     ID3D10GeometryShader_AddRef(*shader);
605 }
606
607 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface,
608         D3D10_PRIMITIVE_TOPOLOGY *topology)
609 {
610     struct d3d10_device *This = impl_from_ID3D10Device(iface);
611
612     TRACE("iface %p, topology %p\n", iface, topology);
613
614     wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
615 }
616
617 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
618         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
619 {
620     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
621             iface, start_slot, view_count, views);
622 }
623
624 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
625         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
626 {
627     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
628             iface, start_slot, sampler_count, samplers);
629 }
630
631 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
632         ID3D10Predicate **predicate, BOOL *value)
633 {
634     FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
635 }
636
637 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
638         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
639 {
640     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
641             iface, start_slot, view_count, views);
642 }
643
644 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
645         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
646 {
647     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
648             iface, start_slot, sampler_count, samplers);
649 }
650
651 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
652         UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
653 {
654     FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
655             iface, view_count, render_target_views, depth_stencil_view);
656 }
657
658 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
659         ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
660 {
661     struct d3d10_device *device = impl_from_ID3D10Device(iface);
662
663     TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
664             iface, blend_state, blend_factor, sample_mask);
665
666     if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
667         ID3D10BlendState_AddRef(*blend_state);
668     memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
669     *sample_mask = device->sample_mask;
670 }
671
672 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
673         ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
674 {
675     struct d3d10_device *device = impl_from_ID3D10Device(iface);
676
677     TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
678             iface, depth_stencil_state, stencil_ref);
679
680     if ((*depth_stencil_state = device->depth_stencil_state
681             ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
682         ID3D10DepthStencilState_AddRef(*depth_stencil_state);
683     *stencil_ref = device->stencil_ref;
684 }
685
686 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
687         UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
688 {
689     FIXME("iface %p, buffer_count %u, buffers %p, offsets %p stub!\n",
690             iface, buffer_count, buffers, offsets);
691 }
692
693 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
694 {
695     struct d3d10_device *device = impl_from_ID3D10Device(iface);
696
697     TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
698
699     if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
700         ID3D10RasterizerState_AddRef(*rasterizer_state);
701 }
702
703 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
704         UINT *viewport_count, D3D10_VIEWPORT *viewports)
705 {
706     struct d3d10_device *device = impl_from_ID3D10Device(iface);
707     struct wined3d_viewport wined3d_vp;
708
709     TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
710
711     if (!viewports)
712     {
713         *viewport_count = 1;
714         return;
715     }
716
717     if (!*viewport_count)
718         return;
719
720     wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
721
722     viewports[0].TopLeftX = wined3d_vp.x;
723     viewports[0].TopLeftY = wined3d_vp.y;
724     viewports[0].Width = wined3d_vp.width;
725     viewports[0].Height = wined3d_vp.height;
726     viewports[0].MinDepth = wined3d_vp.min_z;
727     viewports[0].MaxDepth = wined3d_vp.max_z;
728
729     if (*viewport_count > 1)
730         memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
731 }
732
733 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
734 {
735     FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
736 }
737
738 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
739 {
740     FIXME("iface %p stub!\n", iface);
741
742     return E_NOTIMPL;
743 }
744
745 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
746 {
747     FIXME("iface %p, flags %#x stub!\n", iface, flags);
748
749     return E_NOTIMPL;
750 }
751
752 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
753 {
754     FIXME("iface %p stub!\n", iface);
755
756     return 0;
757 }
758
759 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
760         REFGUID guid, UINT *data_size, void *data)
761 {
762     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
763             iface, debugstr_guid(guid), data_size, data);
764
765     return E_NOTIMPL;
766 }
767
768 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
769         REFGUID guid, UINT data_size, const void *data)
770 {
771     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
772             iface, debugstr_guid(guid), data_size, data);
773
774     return E_NOTIMPL;
775 }
776
777 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
778         REFGUID guid, const IUnknown *data)
779 {
780     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
781
782     return E_NOTIMPL;
783 }
784
785 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
786 {
787     FIXME("iface %p stub!\n", iface);
788 }
789
790 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
791 {
792     FIXME("iface %p stub!\n", iface);
793 }
794
795 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
796         const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
797 {
798     struct d3d10_device *This = impl_from_ID3D10Device(iface);
799     struct d3d10_buffer *object;
800     HRESULT hr;
801
802     FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
803
804     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
805     if (!object)
806     {
807         ERR("Failed to allocate D3D10 buffer object memory\n");
808         return E_OUTOFMEMORY;
809     }
810
811     hr = d3d10_buffer_init(object, This, desc, data);
812     if (FAILED(hr))
813     {
814         WARN("Failed to initialize buffer, hr %#x.\n", hr);
815         HeapFree(GetProcessHeap(), 0, object);
816         return hr;
817     }
818
819     *buffer = &object->ID3D10Buffer_iface;
820
821     TRACE("Created ID3D10Buffer %p\n", object);
822
823     return S_OK;
824 }
825
826 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
827         const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
828 {
829     FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
830
831     return E_NOTIMPL;
832 }
833
834 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
835         const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
836         ID3D10Texture2D **texture)
837 {
838     struct d3d10_device *This = impl_from_ID3D10Device(iface);
839     struct d3d10_texture2d *object;
840     HRESULT hr;
841
842     FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
843
844     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
845     if (!object)
846     {
847         ERR("Failed to allocate D3D10 texture2d object memory\n");
848         return E_OUTOFMEMORY;
849     }
850
851     hr = d3d10_texture2d_init(object, This, desc);
852     if (FAILED(hr))
853     {
854         WARN("Failed to initialize texture, hr %#x.\n", hr);
855         HeapFree(GetProcessHeap(), 0, object);
856         return hr;
857     }
858
859     *texture = &object->ID3D10Texture2D_iface;
860
861     TRACE("Created ID3D10Texture2D %p\n", object);
862
863     return S_OK;
864 }
865
866 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
867         const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
868         ID3D10Texture3D **texture)
869 {
870     struct d3d10_device *device = impl_from_ID3D10Device(iface);
871     struct d3d10_texture3d *object;
872     HRESULT hr;
873
874     TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
875
876     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
877     if (!object)
878     {
879         ERR("Failed to allocate D3D10 texture3d object memory.\n");
880         return E_OUTOFMEMORY;
881     }
882
883     hr = d3d10_texture3d_init(object, device, desc);
884     if (FAILED(hr))
885     {
886         WARN("Failed to initialize texture, hr %#x.\n", hr);
887         HeapFree(GetProcessHeap(), 0, object);
888         return hr;
889     }
890
891     TRACE("Created 3D texture %p.\n", object);
892     *texture = &object->ID3D10Texture3D_iface;
893
894     return S_OK;
895 }
896
897 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
898         ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
899 {
900     struct d3d10_shader_resource_view *object;
901     HRESULT hr;
902
903     TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
904
905     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
906     if (!object)
907     {
908         ERR("Failed to allocate D3D10 shader resource view object memory.\n");
909         return E_OUTOFMEMORY;
910     }
911
912     if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
913     {
914         WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
915         HeapFree(GetProcessHeap(), 0, object);
916         return hr;
917     }
918
919     TRACE("Created shader resource view %p.\n", object);
920     *view = &object->ID3D10ShaderResourceView_iface;
921
922     return S_OK;
923 }
924
925 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
926         ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
927 {
928     struct d3d10_rendertarget_view *object;
929     HRESULT hr;
930
931     TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
932
933     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
934     if (!object)
935     {
936         ERR("Failed to allocate D3D10 rendertarget view object memory\n");
937         return E_OUTOFMEMORY;
938     }
939
940     hr = d3d10_rendertarget_view_init(object, resource, desc);
941     if (FAILED(hr))
942     {
943         WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
944         HeapFree(GetProcessHeap(), 0, object);
945         return hr;
946     }
947
948     TRACE("Created rendertarget view %p.\n", object);
949     *view = &object->ID3D10RenderTargetView_iface;
950
951     return S_OK;
952 }
953
954 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
955         ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
956 {
957     struct d3d10_depthstencil_view *object;
958     HRESULT hr;
959
960     TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
961
962     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
963     if (!object)
964     {
965         ERR("Failed to allocate D3D10 depthstencil view object memory.\n");
966         return E_OUTOFMEMORY;
967     }
968
969     if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
970     {
971         WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
972         HeapFree(GetProcessHeap(), 0, object);
973         return hr;
974     }
975
976     TRACE("Created depthstencil view %p.\n", object);
977     *view = &object->ID3D10DepthStencilView_iface;
978
979     return S_OK;
980 }
981
982 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *iface,
983         const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
984         const void *shader_byte_code, SIZE_T shader_byte_code_length,
985         ID3D10InputLayout **input_layout)
986 {
987     struct d3d10_device *This = impl_from_ID3D10Device(iface);
988     struct d3d10_input_layout *object;
989     HRESULT hr;
990
991     TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
992             "\tshader_byte_code_length %lu, input_layout %p\n",
993             iface, element_descs, element_count, shader_byte_code,
994             shader_byte_code_length, input_layout);
995
996     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
997     if (!object)
998     {
999         ERR("Failed to allocate D3D10 input layout object memory\n");
1000         return E_OUTOFMEMORY;
1001     }
1002
1003     hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1004             shader_byte_code, shader_byte_code_length);
1005     if (FAILED(hr))
1006     {
1007         WARN("Failed to initialize input layout, hr %#x.\n", hr);
1008         HeapFree(GetProcessHeap(), 0, object);
1009         return hr;
1010     }
1011
1012     TRACE("Created input layout %p.\n", object);
1013     *input_layout = &object->ID3D10InputLayout_iface;
1014
1015     return S_OK;
1016 }
1017
1018 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
1019         const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1020 {
1021     struct d3d10_device *This = impl_from_ID3D10Device(iface);
1022     struct d3d10_vertex_shader *object;
1023     HRESULT hr;
1024
1025     TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1026             iface, byte_code, byte_code_length, shader);
1027
1028     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1029     if (!object)
1030     {
1031         ERR("Failed to allocate D3D10 vertex shader object memory\n");
1032         return E_OUTOFMEMORY;
1033     }
1034
1035     hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1036     if (FAILED(hr))
1037     {
1038         WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1039         HeapFree(GetProcessHeap(), 0, object);
1040         return hr;
1041     }
1042
1043     TRACE("Created vertex shader %p.\n", object);
1044     *shader = &object->ID3D10VertexShader_iface;
1045
1046     return S_OK;
1047 }
1048
1049 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
1050         const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1051 {
1052     struct d3d10_device *This = impl_from_ID3D10Device(iface);
1053     struct d3d10_geometry_shader *object;
1054     HRESULT hr;
1055
1056     FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
1057             iface, byte_code, byte_code_length, shader);
1058
1059     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1060     if (!object)
1061     {
1062         ERR("Failed to allocate D3D10 geometry shader object memory\n");
1063         return E_OUTOFMEMORY;
1064     }
1065
1066     hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1067     if (FAILED(hr))
1068     {
1069         WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1070         HeapFree(GetProcessHeap(), 0, object);
1071         return hr;
1072     }
1073
1074     TRACE("Created geometry shader %p.\n", object);
1075     *shader = &object->ID3D10GeometryShader_iface;
1076
1077     return S_OK;
1078 }
1079
1080 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device *iface,
1081         const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1082         UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1083 {
1084     FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1085             "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1086             iface, byte_code, byte_code_length, output_stream_decls,
1087             output_stream_decl_count, output_stream_stride, shader);
1088
1089     return E_NOTIMPL;
1090 }
1091
1092 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
1093         const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1094 {
1095     struct d3d10_device *This = impl_from_ID3D10Device(iface);
1096     struct d3d10_pixel_shader *object;
1097     HRESULT hr;
1098
1099     TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1100             iface, byte_code, byte_code_length, shader);
1101
1102     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1103     if (!object)
1104     {
1105         ERR("Failed to allocate D3D10 pixel shader object memory\n");
1106         return E_OUTOFMEMORY;
1107     }
1108
1109     hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1110     if (FAILED(hr))
1111     {
1112         WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1113         HeapFree(GetProcessHeap(), 0, object);
1114         return hr;
1115     }
1116
1117     TRACE("Created pixel shader %p.\n", object);
1118     *shader = &object->ID3D10PixelShader_iface;
1119
1120     return S_OK;
1121 }
1122
1123 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
1124         const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1125 {
1126     struct d3d10_blend_state *object;
1127     HRESULT hr;
1128
1129     TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1130
1131     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1132     if (!object)
1133     {
1134         ERR("Failed to allocate D3D10 blend state object memory.\n");
1135         return E_OUTOFMEMORY;
1136     }
1137
1138     hr = d3d10_blend_state_init(object);
1139     if (FAILED(hr))
1140     {
1141         WARN("Failed to initialize blend state, hr %#x.\n", hr);
1142         HeapFree(GetProcessHeap(), 0, object);
1143         return hr;
1144     }
1145
1146     TRACE("Created blend state %p.\n", object);
1147     *blend_state = &object->ID3D10BlendState_iface;
1148
1149     return S_OK;
1150 }
1151
1152 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1153         const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1154 {
1155     struct d3d10_depthstencil_state *object;
1156     HRESULT hr;
1157
1158     TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1159
1160     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1161     if (!object)
1162     {
1163         ERR("Failed to allocate D3D10 depthstencil state object memory.\n");
1164         return E_OUTOFMEMORY;
1165     }
1166
1167     hr = d3d10_depthstencil_state_init(object);
1168     if (FAILED(hr))
1169     {
1170         WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1171         HeapFree(GetProcessHeap(), 0, object);
1172         return hr;
1173     }
1174
1175     TRACE("Created depthstencil state %p.\n", object);
1176     *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1177
1178     return S_OK;
1179 }
1180
1181 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1182         const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1183 {
1184     struct d3d10_rasterizer_state *object;
1185     HRESULT hr;
1186
1187     TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1188
1189     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1190     if (!object)
1191     {
1192         ERR("Failed to allocate D3D10 rasterizer state object memory.\n");
1193         return E_OUTOFMEMORY;
1194     }
1195
1196     hr = d3d10_rasterizer_state_init(object);
1197     if (FAILED(hr))
1198     {
1199         WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1200         HeapFree(GetProcessHeap(), 0, object);
1201         return hr;
1202     }
1203
1204     TRACE("Created rasterizer state %p.\n", object);
1205     *rasterizer_state = &object->ID3D10RasterizerState_iface;
1206
1207     return S_OK;
1208 }
1209
1210 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1211         const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1212 {
1213     struct d3d10_sampler_state *object;
1214     HRESULT hr;
1215
1216     TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1217
1218     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1219     if (!object)
1220     {
1221         ERR("Failed to allocate D3D10 sampler state object memory.\n");
1222         return E_OUTOFMEMORY;
1223     }
1224
1225     hr = d3d10_sampler_state_init(object);
1226     if (FAILED(hr))
1227     {
1228         WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1229         HeapFree(GetProcessHeap(), 0, object);
1230         return hr;
1231     }
1232
1233     TRACE("Created sampler state %p.\n", object);
1234     *sampler_state = &object->ID3D10SamplerState_iface;
1235
1236     return S_OK;
1237 }
1238
1239 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1240         const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1241 {
1242     struct d3d10_query *object;
1243     HRESULT hr;
1244
1245     TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1246
1247     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1248     if (!object)
1249     {
1250         ERR("Failed to allocate D3D10 query object memory.\n");
1251         return E_OUTOFMEMORY;
1252     }
1253
1254     hr = d3d10_query_init(object);
1255     if (FAILED(hr))
1256     {
1257         WARN("Failed to initialize query, hr %#x.\n", hr);
1258         HeapFree(GetProcessHeap(), 0, object);
1259         return hr;
1260     }
1261
1262     TRACE("Created query %p.\n", object);
1263     *query = &object->ID3D10Query_iface;
1264
1265     return S_OK;
1266 }
1267
1268 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1269         const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1270 {
1271     FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1272
1273     return E_NOTIMPL;
1274 }
1275
1276 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1277         const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1278 {
1279     FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1280
1281     return E_NOTIMPL;
1282 }
1283
1284 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1285         DXGI_FORMAT format, UINT *format_support)
1286 {
1287     FIXME("iface %p, format %s, format_support %p stub!\n",
1288             iface, debug_dxgi_format(format), format_support);
1289
1290     return E_NOTIMPL;
1291 }
1292
1293 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1294         DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1295 {
1296     FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1297             iface, debug_dxgi_format(format), sample_count, quality_level_count);
1298
1299     return E_NOTIMPL;
1300 }
1301
1302 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1303 {
1304     FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1305 }
1306
1307 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1308         const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1309         UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1310 {
1311     FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1312             "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1313             iface, desc, type, active_counters, name, name_length,
1314             units, units_length, description, description_length);
1315
1316     return E_NOTIMPL;
1317 }
1318
1319 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1320 {
1321     FIXME("iface %p stub!\n", iface);
1322
1323     return 0;
1324 }
1325
1326 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1327         HANDLE resource_handle, REFIID guid, void **resource)
1328 {
1329     FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1330             iface, resource_handle, debugstr_guid(guid), resource);
1331
1332     return E_NOTIMPL;
1333 }
1334
1335 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1336 {
1337     FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1338 }
1339
1340 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1341 {
1342     FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1343 }
1344
1345 static const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1346 {
1347     /* IUnknown methods */
1348     d3d10_device_QueryInterface,
1349     d3d10_device_AddRef,
1350     d3d10_device_Release,
1351     /* ID3D10Device methods */
1352     d3d10_device_VSSetConstantBuffers,
1353     d3d10_device_PSSetShaderResources,
1354     d3d10_device_PSSetShader,
1355     d3d10_device_PSSetSamplers,
1356     d3d10_device_VSSetShader,
1357     d3d10_device_DrawIndexed,
1358     d3d10_device_Draw,
1359     d3d10_device_PSSetConstantBuffers,
1360     d3d10_device_IASetInputLayout,
1361     d3d10_device_IASetVertexBuffers,
1362     d3d10_device_IASetIndexBuffer,
1363     d3d10_device_DrawIndexedInstanced,
1364     d3d10_device_DrawInstanced,
1365     d3d10_device_GSSetConstantBuffers,
1366     d3d10_device_GSSetShader,
1367     d3d10_device_IASetPrimitiveTopology,
1368     d3d10_device_VSSetShaderResources,
1369     d3d10_device_VSSetSamplers,
1370     d3d10_device_SetPredication,
1371     d3d10_device_GSSetShaderResources,
1372     d3d10_device_GSSetSamplers,
1373     d3d10_device_OMSetRenderTargets,
1374     d3d10_device_OMSetBlendState,
1375     d3d10_device_OMSetDepthStencilState,
1376     d3d10_device_SOSetTargets,
1377     d3d10_device_DrawAuto,
1378     d3d10_device_RSSetState,
1379     d3d10_device_RSSetViewports,
1380     d3d10_device_RSSetScissorRects,
1381     d3d10_device_CopySubresourceRegion,
1382     d3d10_device_CopyResource,
1383     d3d10_device_UpdateSubresource,
1384     d3d10_device_ClearRenderTargetView,
1385     d3d10_device_ClearDepthStencilView,
1386     d3d10_device_GenerateMips,
1387     d3d10_device_ResolveSubresource,
1388     d3d10_device_VSGetConstantBuffers,
1389     d3d10_device_PSGetShaderResources,
1390     d3d10_device_PSGetShader,
1391     d3d10_device_PSGetSamplers,
1392     d3d10_device_VSGetShader,
1393     d3d10_device_PSGetConstantBuffers,
1394     d3d10_device_IAGetInputLayout,
1395     d3d10_device_IAGetVertexBuffers,
1396     d3d10_device_IAGetIndexBuffer,
1397     d3d10_device_GSGetConstantBuffers,
1398     d3d10_device_GSGetShader,
1399     d3d10_device_IAGetPrimitiveTopology,
1400     d3d10_device_VSGetShaderResources,
1401     d3d10_device_VSGetSamplers,
1402     d3d10_device_GetPredication,
1403     d3d10_device_GSGetShaderResources,
1404     d3d10_device_GSGetSamplers,
1405     d3d10_device_OMGetRenderTargets,
1406     d3d10_device_OMGetBlendState,
1407     d3d10_device_OMGetDepthStencilState,
1408     d3d10_device_SOGetTargets,
1409     d3d10_device_RSGetState,
1410     d3d10_device_RSGetViewports,
1411     d3d10_device_RSGetScissorRects,
1412     d3d10_device_GetDeviceRemovedReason,
1413     d3d10_device_SetExceptionMode,
1414     d3d10_device_GetExceptionMode,
1415     d3d10_device_GetPrivateData,
1416     d3d10_device_SetPrivateData,
1417     d3d10_device_SetPrivateDataInterface,
1418     d3d10_device_ClearState,
1419     d3d10_device_Flush,
1420     d3d10_device_CreateBuffer,
1421     d3d10_device_CreateTexture1D,
1422     d3d10_device_CreateTexture2D,
1423     d3d10_device_CreateTexture3D,
1424     d3d10_device_CreateShaderResourceView,
1425     d3d10_device_CreateRenderTargetView,
1426     d3d10_device_CreateDepthStencilView,
1427     d3d10_device_CreateInputLayout,
1428     d3d10_device_CreateVertexShader,
1429     d3d10_device_CreateGeometryShader,
1430     d3d10_device_CreateGeometryShaderWithStreamOutput,
1431     d3d10_device_CreatePixelShader,
1432     d3d10_device_CreateBlendState,
1433     d3d10_device_CreateDepthStencilState,
1434     d3d10_device_CreateRasterizerState,
1435     d3d10_device_CreateSamplerState,
1436     d3d10_device_CreateQuery,
1437     d3d10_device_CreatePredicate,
1438     d3d10_device_CreateCounter,
1439     d3d10_device_CheckFormatSupport,
1440     d3d10_device_CheckMultisampleQualityLevels,
1441     d3d10_device_CheckCounterInfo,
1442     d3d10_device_CheckCounter,
1443     d3d10_device_GetCreationFlags,
1444     d3d10_device_OpenSharedResource,
1445     d3d10_device_SetTextFilterSize,
1446     d3d10_device_GetTextFilterSize,
1447 };
1448
1449 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1450 {
1451     /* IUnknown methods */
1452     d3d10_device_inner_QueryInterface,
1453     d3d10_device_inner_AddRef,
1454     d3d10_device_inner_Release,
1455 };
1456
1457 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1458
1459 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1460 {
1461     d3d10_subresource_destroyed,
1462 };
1463
1464 /* IWineDXGIDeviceParent IUnknown methods */
1465
1466 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1467 {
1468     return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1469 }
1470
1471 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1472         REFIID riid, void **ppv)
1473 {
1474     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1475     return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1476 }
1477
1478 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1479 {
1480     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1481     return IUnknown_AddRef(device->outer_unk);
1482 }
1483
1484 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1485 {
1486     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1487     return IUnknown_Release(device->outer_unk);
1488 }
1489
1490 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1491         IWineDXGIDeviceParent *iface)
1492 {
1493     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1494     return &device->device_parent;
1495 }
1496
1497 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1498 {
1499     /* IUnknown methods */
1500     dxgi_device_parent_QueryInterface,
1501     dxgi_device_parent_AddRef,
1502     dxgi_device_parent_Release,
1503     /* IWineDXGIDeviceParent methods */
1504     dxgi_device_parent_get_wined3d_device_parent,
1505 };
1506
1507 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1508 {
1509     return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1510 }
1511
1512 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1513         struct wined3d_device *wined3d_device)
1514 {
1515     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1516
1517     TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1518
1519     wined3d_device_incref(wined3d_device);
1520     device->wined3d_device = wined3d_device;
1521 }
1522
1523 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1524 {
1525     TRACE("device_parent %p.\n", device_parent);
1526 }
1527
1528 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
1529         void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
1530         enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
1531 {
1532     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1533
1534     TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
1535             "\tpool %#x, sub_resource_idx %u, surface %p.\n",
1536             device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
1537
1538     return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
1539             WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent,
1540             &d3d10_null_wined3d_parent_ops, surface);
1541 }
1542
1543 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1544         void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
1545         enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
1546 {
1547     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1548     struct wined3d_resource *sub_resource;
1549     struct d3d10_texture2d *texture;
1550     D3D10_TEXTURE2D_DESC desc;
1551     HRESULT hr;
1552
1553     FIXME("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
1554             "\tmultisample_type %#x, multisample_quality %u, surface %p partial stub!\n",
1555             device_parent, container_parent, width, height, format_id, usage,
1556             multisample_type, multisample_quality, surface);
1557
1558     FIXME("Implement DXGI<->wined3d usage conversion\n");
1559
1560     desc.Width = width;
1561     desc.Height = height;
1562     desc.MipLevels = 1;
1563     desc.ArraySize = 1;
1564     desc.Format = dxgi_format_from_wined3dformat(format_id);
1565     desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1566     desc.SampleDesc.Quality = multisample_quality;
1567     desc.Usage = D3D10_USAGE_DEFAULT;
1568     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1569     desc.CPUAccessFlags = 0;
1570     desc.MiscFlags = 0;
1571
1572     hr = d3d10_device_CreateTexture2D(&device->ID3D10Device_iface, &desc, NULL,
1573             (ID3D10Texture2D **)&texture);
1574     if (FAILED(hr))
1575     {
1576         ERR("CreateTexture2D failed, returning %#x\n", hr);
1577         return hr;
1578     }
1579
1580     sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1581     *surface = wined3d_surface_from_resource(sub_resource);
1582     wined3d_surface_incref(*surface);
1583     ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1584
1585     return S_OK;
1586 }
1587
1588 static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
1589         void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
1590         enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
1591 {
1592     HRESULT hr;
1593
1594     TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
1595             "format %#x, pool %#x, usage %#x, volume %p.\n",
1596             device_parent, container_parent, width, height, depth,
1597             format, pool, usage, volume);
1598
1599     hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
1600             width, height, depth, usage, format, pool, NULL, &d3d10_subresource_parent_ops, volume);
1601     if (FAILED(hr))
1602     {
1603         WARN("Failed to create wined3d volume, hr %#x.\n", hr);
1604         return hr;
1605     }
1606
1607     return S_OK;
1608 }
1609
1610 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
1611         struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
1612 {
1613     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1614     IWineDXGIDevice *wine_device;
1615     HRESULT hr;
1616
1617     TRACE("device_parent %p, desc %p, swapchain %p\n", device_parent, desc, swapchain);
1618
1619     hr = d3d10_device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice,
1620             (void **)&wine_device);
1621     if (FAILED(hr))
1622     {
1623         ERR("Device should implement IWineDXGIDevice\n");
1624         return E_FAIL;
1625     }
1626
1627     hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
1628     IWineDXGIDevice_Release(wine_device);
1629     if (FAILED(hr))
1630     {
1631         ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1632         return hr;
1633     }
1634
1635     return S_OK;
1636 }
1637
1638 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
1639 {
1640     device_parent_wined3d_device_created,
1641     device_parent_mode_changed,
1642     device_parent_create_swapchain_surface,
1643     device_parent_create_texture_surface,
1644     device_parent_create_volume,
1645     device_parent_create_swapchain,
1646 };
1647
1648 void d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
1649 {
1650     device->ID3D10Device_iface.lpVtbl = &d3d10_device_vtbl;
1651     device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
1652     device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
1653     device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
1654     device->refcount = 1;
1655     /* COM aggregation always takes place */
1656     device->outer_unk = outer_unknown;
1657 }