d3d10core: Implement d3d10_shader_resource_view_GetDesc().
[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,
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     if (shader) FIXME("iface %p, shader %p stub!\n", iface, shader);
264     else WARN("iface %p, shader %p stub!\n", iface, shader);
265 }
266
267 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface,
268         D3D10_PRIMITIVE_TOPOLOGY topology)
269 {
270     struct d3d10_device *This = impl_from_ID3D10Device(iface);
271
272     TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
273
274     wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
275 }
276
277 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
278         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
279 {
280     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
281             iface, start_slot, view_count, views);
282 }
283
284 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
285         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
286 {
287     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
288             iface, start_slot, sampler_count, samplers);
289 }
290
291 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
292 {
293     FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
294 }
295
296 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
297         UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
298 {
299     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
300             iface, start_slot, view_count, views);
301 }
302
303 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
304         UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
305 {
306     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
307             iface, start_slot, sampler_count, samplers);
308 }
309
310 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device *iface,
311         UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
312         ID3D10DepthStencilView *depth_stencil_view)
313 {
314     FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
315             iface, render_target_view_count, render_target_views, depth_stencil_view);
316 }
317
318 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
319         ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
320 {
321     FIXME("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x stub!\n",
322             iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
323 }
324
325 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
326         ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
327 {
328     FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n",
329             iface, depth_stencil_state, stencil_ref);
330 }
331
332 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
333         UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
334 {
335     FIXME("iface %p, target_count %u, targets %p, offsets %p stub!\n", iface, target_count, targets, offsets);
336 }
337
338 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
339 {
340     FIXME("iface %p stub!\n", iface);
341 }
342
343 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
344 {
345     FIXME("iface %p, rasterizer_state %p stub!\n", iface, rasterizer_state);
346 }
347
348 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
349         UINT viewport_count, const D3D10_VIEWPORT *viewports)
350 {
351     FIXME("iface %p, viewport_count %u, viewports %p stub!\n", iface, viewport_count, viewports);
352 }
353
354 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
355         UINT rect_count, const D3D10_RECT *rects)
356 {
357     FIXME("iface %p, rect_count %u, rects %p\n", iface, rect_count, rects);
358 }
359
360 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device *iface,
361         ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
362         ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
363 {
364     FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
365             "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
366             iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
367             src_resource, src_subresource_idx, src_box);
368 }
369
370 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
371         ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
372 {
373     FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
374 }
375
376 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface,
377         ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
378         const void *data, UINT row_pitch, UINT depth_pitch)
379 {
380     FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
381             iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
382 }
383
384 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
385         ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
386 {
387     struct d3d10_device *This = impl_from_ID3D10Device(iface);
388     struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
389     const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
390
391     TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
392             iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
393
394     wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
395 }
396
397 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
398         ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
399 {
400     FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
401             iface, depth_stencil_view, flags, depth, stencil);
402 }
403
404 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
405 {
406     FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
407 }
408
409 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device *iface,
410         ID3D10Resource *dst_resource, UINT dst_subresource_idx,
411         ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
412 {
413     FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
414             "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
415             iface, dst_resource, dst_subresource_idx,
416             src_resource, src_subresource_idx, debug_dxgi_format(format));
417 }
418
419 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
420         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
421 {
422     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
423             iface, start_slot, buffer_count, buffers);
424 }
425
426 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
427         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
428 {
429     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
430             iface, start_slot, view_count, views);
431 }
432
433 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
434 {
435     FIXME("iface %p, shader %p stub!\n", iface, shader);
436 }
437
438 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
439         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
440 {
441     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
442             iface, start_slot, sampler_count, samplers);
443 }
444
445 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
446 {
447     FIXME("iface %p, shader %p stub!\n", iface, shader);
448 }
449
450 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
451         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
452 {
453     FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
454             iface, start_slot, buffer_count, buffers);
455 }
456
457 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
458 {
459     FIXME("iface %p, input_layout %p stub!\n", iface, input_layout);
460 }
461
462 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
463         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
464 {
465     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
466             iface, start_slot, buffer_count, buffers, strides, offsets);
467 }
468
469 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
470         ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
471 {
472     FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
473 }
474
475 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
476         UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
477 {
478     FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
479             iface, start_slot, buffer_count, buffers);
480 }
481
482 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
483 {
484     FIXME("iface %p, shader %p stub!\n", iface, shader);
485 }
486
487 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface,
488         D3D10_PRIMITIVE_TOPOLOGY *topology)
489 {
490     struct d3d10_device *This = impl_from_ID3D10Device(iface);
491
492     TRACE("iface %p, topology %p\n", iface, topology);
493
494     wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
495 }
496
497 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
498         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
499 {
500     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
501             iface, start_slot, view_count, views);
502 }
503
504 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
505         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
506 {
507     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
508             iface, start_slot, sampler_count, samplers);
509 }
510
511 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
512         ID3D10Predicate **predicate, BOOL *value)
513 {
514     FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
515 }
516
517 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
518         UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
519 {
520     FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
521             iface, start_slot, view_count, views);
522 }
523
524 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
525         UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
526 {
527     FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
528             iface, start_slot, sampler_count, samplers);
529 }
530
531 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
532         UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
533 {
534     FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
535             iface, view_count, render_target_views, depth_stencil_view);
536 }
537
538 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
539         ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
540 {
541     FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
542             iface, blend_state, blend_factor, sample_mask);
543 }
544
545 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
546         ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
547 {
548     FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n",
549             iface, depth_stencil_state, stencil_ref);
550 }
551
552 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
553         UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
554 {
555     FIXME("iface %p, buffer_count %u, buffers %p, offsets %p stub!\n",
556             iface, buffer_count, buffers, offsets);
557 }
558
559 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
560 {
561     FIXME("iface %p, rasterizer_state %p stub!\n", iface, rasterizer_state);
562 }
563
564 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
565         UINT *viewport_count, D3D10_VIEWPORT *viewports)
566 {
567     FIXME("iface %p, viewport_count %p, viewports %p stub!\n", iface, viewport_count, viewports);
568 }
569
570 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
571 {
572     FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
573 }
574
575 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
576 {
577     FIXME("iface %p stub!\n", iface);
578
579     return E_NOTIMPL;
580 }
581
582 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
583 {
584     FIXME("iface %p, flags %#x stub!\n", iface, flags);
585
586     return E_NOTIMPL;
587 }
588
589 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
590 {
591     FIXME("iface %p stub!\n", iface);
592
593     return 0;
594 }
595
596 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
597         REFGUID guid, UINT *data_size, void *data)
598 {
599     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
600             iface, debugstr_guid(guid), data_size, data);
601
602     return E_NOTIMPL;
603 }
604
605 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
606         REFGUID guid, UINT data_size, const void *data)
607 {
608     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
609             iface, debugstr_guid(guid), data_size, data);
610
611     return E_NOTIMPL;
612 }
613
614 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
615         REFGUID guid, const IUnknown *data)
616 {
617     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
618
619     return E_NOTIMPL;
620 }
621
622 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
623 {
624     FIXME("iface %p stub!\n", iface);
625 }
626
627 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
628 {
629     FIXME("iface %p stub!\n", iface);
630 }
631
632 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
633         const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
634 {
635     struct d3d10_device *This = impl_from_ID3D10Device(iface);
636     struct d3d10_buffer *object;
637     HRESULT hr;
638
639     FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
640
641     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
642     if (!object)
643     {
644         ERR("Failed to allocate D3D10 buffer object memory\n");
645         return E_OUTOFMEMORY;
646     }
647
648     hr = d3d10_buffer_init(object, This, desc, data);
649     if (FAILED(hr))
650     {
651         WARN("Failed to initialize buffer, hr %#x.\n", hr);
652         HeapFree(GetProcessHeap(), 0, object);
653         return hr;
654     }
655
656     *buffer = &object->ID3D10Buffer_iface;
657
658     TRACE("Created ID3D10Buffer %p\n", object);
659
660     return S_OK;
661 }
662
663 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
664         const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
665 {
666     FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
667
668     return E_NOTIMPL;
669 }
670
671 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
672         const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
673         ID3D10Texture2D **texture)
674 {
675     struct d3d10_device *This = impl_from_ID3D10Device(iface);
676     struct d3d10_texture2d *object;
677     HRESULT hr;
678
679     FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
680
681     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
682     if (!object)
683     {
684         ERR("Failed to allocate D3D10 texture2d object memory\n");
685         return E_OUTOFMEMORY;
686     }
687
688     hr = d3d10_texture2d_init(object, This, desc);
689     if (FAILED(hr))
690     {
691         WARN("Failed to initialize texture, hr %#x.\n", hr);
692         HeapFree(GetProcessHeap(), 0, object);
693         return hr;
694     }
695
696     *texture = &object->ID3D10Texture2D_iface;
697
698     TRACE("Created ID3D10Texture2D %p\n", object);
699
700     return S_OK;
701 }
702
703 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
704         const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
705         ID3D10Texture3D **texture)
706 {
707     struct d3d10_device *device = impl_from_ID3D10Device(iface);
708     struct d3d10_texture3d *object;
709     HRESULT hr;
710
711     TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
712
713     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
714     if (!object)
715     {
716         ERR("Failed to allocate D3D10 texture3d object memory.\n");
717         return E_OUTOFMEMORY;
718     }
719
720     hr = d3d10_texture3d_init(object, device, desc);
721     if (FAILED(hr))
722     {
723         WARN("Failed to initialize texture, hr %#x.\n", hr);
724         HeapFree(GetProcessHeap(), 0, object);
725         return hr;
726     }
727
728     TRACE("Created 3D texture %p.\n", object);
729     *texture = &object->ID3D10Texture3D_iface;
730
731     return S_OK;
732 }
733
734 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
735         ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
736 {
737     struct d3d10_shader_resource_view *object;
738     HRESULT hr;
739
740     TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
741
742     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
743     if (!object)
744     {
745         ERR("Failed to allocate D3D10 shader resource view object memory.\n");
746         return E_OUTOFMEMORY;
747     }
748
749     if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
750     {
751         WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
752         HeapFree(GetProcessHeap(), 0, object);
753         return hr;
754     }
755
756     TRACE("Created shader resource view %p.\n", object);
757     *view = &object->ID3D10ShaderResourceView_iface;
758
759     return S_OK;
760 }
761
762 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
763         ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
764 {
765     struct d3d10_rendertarget_view *object;
766     HRESULT hr;
767
768     TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
769
770     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
771     if (!object)
772     {
773         ERR("Failed to allocate D3D10 rendertarget view object memory\n");
774         return E_OUTOFMEMORY;
775     }
776
777     hr = d3d10_rendertarget_view_init(object, resource, desc);
778     if (FAILED(hr))
779     {
780         WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
781         HeapFree(GetProcessHeap(), 0, object);
782         return hr;
783     }
784
785     TRACE("Created rendertarget view %p.\n", object);
786     *view = &object->ID3D10RenderTargetView_iface;
787
788     return S_OK;
789 }
790
791 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
792         ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
793 {
794     struct d3d10_depthstencil_view *object;
795     HRESULT hr;
796
797     TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
798
799     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
800     if (!object)
801     {
802         ERR("Failed to allocate D3D10 depthstencil view object memory.\n");
803         return E_OUTOFMEMORY;
804     }
805
806     if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
807     {
808         WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
809         HeapFree(GetProcessHeap(), 0, object);
810         return hr;
811     }
812
813     TRACE("Created depthstencil view %p.\n", object);
814     *view = &object->ID3D10DepthStencilView_iface;
815
816     return S_OK;
817 }
818
819 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *iface,
820         const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
821         const void *shader_byte_code, SIZE_T shader_byte_code_length,
822         ID3D10InputLayout **input_layout)
823 {
824     struct d3d10_device *This = impl_from_ID3D10Device(iface);
825     struct d3d10_input_layout *object;
826     HRESULT hr;
827
828     TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
829             "\tshader_byte_code_length %lu, input_layout %p\n",
830             iface, element_descs, element_count, shader_byte_code,
831             shader_byte_code_length, input_layout);
832
833     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
834     if (!object)
835     {
836         ERR("Failed to allocate D3D10 input layout object memory\n");
837         return E_OUTOFMEMORY;
838     }
839
840     hr = d3d10_input_layout_init(object, This, element_descs, element_count,
841             shader_byte_code, shader_byte_code_length);
842     if (FAILED(hr))
843     {
844         WARN("Failed to initialize input layout, hr %#x.\n", hr);
845         HeapFree(GetProcessHeap(), 0, object);
846         return hr;
847     }
848
849     TRACE("Created input layout %p.\n", object);
850     *input_layout = &object->ID3D10InputLayout_iface;
851
852     return S_OK;
853 }
854
855 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
856         const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
857 {
858     struct d3d10_device *This = impl_from_ID3D10Device(iface);
859     struct d3d10_vertex_shader *object;
860     HRESULT hr;
861
862     TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
863             iface, byte_code, byte_code_length, shader);
864
865     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
866     if (!object)
867     {
868         ERR("Failed to allocate D3D10 vertex shader object memory\n");
869         return E_OUTOFMEMORY;
870     }
871
872     hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
873     if (FAILED(hr))
874     {
875         WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
876         HeapFree(GetProcessHeap(), 0, object);
877         return hr;
878     }
879
880     TRACE("Created vertex shader %p.\n", object);
881     *shader = &object->ID3D10VertexShader_iface;
882
883     return S_OK;
884 }
885
886 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
887         const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
888 {
889     struct d3d10_device *This = impl_from_ID3D10Device(iface);
890     struct d3d10_geometry_shader *object;
891     HRESULT hr;
892
893     FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
894             iface, byte_code, byte_code_length, shader);
895
896     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
897     if (!object)
898     {
899         ERR("Failed to allocate D3D10 geometry shader object memory\n");
900         return E_OUTOFMEMORY;
901     }
902
903     hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
904     if (FAILED(hr))
905     {
906         WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
907         HeapFree(GetProcessHeap(), 0, object);
908     }
909
910     TRACE("Created geometry shader %p.\n", object);
911     *shader = &object->ID3D10GeometryShader_iface;
912
913     return S_OK;
914 }
915
916 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device *iface,
917         const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
918         UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
919 {
920     FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
921             "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
922             iface, byte_code, byte_code_length, output_stream_decls,
923             output_stream_decl_count, output_stream_stride, shader);
924
925     return E_NOTIMPL;
926 }
927
928 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
929         const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
930 {
931     struct d3d10_device *This = impl_from_ID3D10Device(iface);
932     struct d3d10_pixel_shader *object;
933     HRESULT hr;
934
935     TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
936             iface, byte_code, byte_code_length, shader);
937
938     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
939     if (!object)
940     {
941         ERR("Failed to allocate D3D10 pixel shader object memory\n");
942         return E_OUTOFMEMORY;
943     }
944
945     hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
946     if (FAILED(hr))
947     {
948         WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
949         HeapFree(GetProcessHeap(), 0, object);
950         return hr;
951     }
952
953     TRACE("Created pixel shader %p.\n", object);
954     *shader = &object->ID3D10PixelShader_iface;
955
956     return S_OK;
957 }
958
959 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
960         const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
961 {
962     struct d3d10_blend_state *object;
963     HRESULT hr;
964
965     TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
966
967     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
968     if (!object)
969     {
970         ERR("Failed to allocate D3D10 blend state object memory.\n");
971         return E_OUTOFMEMORY;
972     }
973
974     hr = d3d10_blend_state_init(object);
975     if (FAILED(hr))
976     {
977         WARN("Failed to initialize blend state, hr %#x.\n", hr);
978         HeapFree(GetProcessHeap(), 0, object);
979         return hr;
980     }
981
982     TRACE("Created blend state %p.\n", object);
983     *blend_state = &object->ID3D10BlendState_iface;
984
985     return S_OK;
986 }
987
988 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
989         const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
990 {
991     struct d3d10_depthstencil_state *object;
992     HRESULT hr;
993
994     TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
995
996     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
997     if (!object)
998     {
999         ERR("Failed to allocate D3D10 depthstencil state object memory.\n");
1000         return E_OUTOFMEMORY;
1001     }
1002
1003     hr = d3d10_depthstencil_state_init(object);
1004     if (FAILED(hr))
1005     {
1006         WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1007         HeapFree(GetProcessHeap(), 0, object);
1008         return hr;
1009     }
1010
1011     TRACE("Created depthstencil state %p.\n", object);
1012     *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1013
1014     return S_OK;
1015 }
1016
1017 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1018         const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1019 {
1020     struct d3d10_rasterizer_state *object;
1021     HRESULT hr;
1022
1023     TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1024
1025     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1026     if (!object)
1027     {
1028         ERR("Failed to allocate D3D10 rasterizer state object memory.\n");
1029         return E_OUTOFMEMORY;
1030     }
1031
1032     hr = d3d10_rasterizer_state_init(object);
1033     if (FAILED(hr))
1034     {
1035         WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1036         HeapFree(GetProcessHeap(), 0, object);
1037         return hr;
1038     }
1039
1040     TRACE("Created rasterizer state %p.\n", object);
1041     *rasterizer_state = &object->ID3D10RasterizerState_iface;
1042
1043     return S_OK;
1044 }
1045
1046 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1047         const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1048 {
1049     struct d3d10_sampler_state *object;
1050     HRESULT hr;
1051
1052     FIXME("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1053
1054     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1055     if (!object)
1056     {
1057         ERR("Failed to allocate D3D10 sampler state object memory.\n");
1058         return E_OUTOFMEMORY;
1059     }
1060
1061     hr = d3d10_sampler_state_init(object);
1062     if (FAILED(hr))
1063     {
1064         WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1065         HeapFree(GetProcessHeap(), 0, object);
1066         return hr;
1067     }
1068
1069     TRACE("Created sampler state %p.\n", object);
1070     *sampler_state = &object->ID3D10SamplerState_iface;
1071
1072     return S_OK;
1073 }
1074
1075 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1076         const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1077 {
1078     struct d3d10_query *object;
1079     HRESULT hr;
1080
1081     TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1082
1083     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1084     if (!object)
1085     {
1086         ERR("Failed to allocate D3D10 query object memory.\n");
1087         return E_OUTOFMEMORY;
1088     }
1089
1090     hr = d3d10_query_init(object);
1091     if (FAILED(hr))
1092     {
1093         WARN("Failed to initialize query, hr %#x.\n", hr);
1094         HeapFree(GetProcessHeap(), 0, object);
1095         return hr;
1096     }
1097
1098     TRACE("Created query %p.\n", object);
1099     *query = &object->ID3D10Query_iface;
1100
1101     return S_OK;
1102 }
1103
1104 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1105         const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1106 {
1107     FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1108
1109     return E_NOTIMPL;
1110 }
1111
1112 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1113         const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1114 {
1115     FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1116
1117     return E_NOTIMPL;
1118 }
1119
1120 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1121         DXGI_FORMAT format, UINT *format_support)
1122 {
1123     FIXME("iface %p, format %s, format_support %p stub!\n",
1124             iface, debug_dxgi_format(format), format_support);
1125
1126     return E_NOTIMPL;
1127 }
1128
1129 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1130         DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1131 {
1132     FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1133             iface, debug_dxgi_format(format), sample_count, quality_level_count);
1134
1135     return E_NOTIMPL;
1136 }
1137
1138 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1139 {
1140     FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1141 }
1142
1143 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1144         const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1145         UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1146 {
1147     FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1148             "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1149             iface, desc, type, active_counters, name, name_length,
1150             units, units_length, description, description_length);
1151
1152     return E_NOTIMPL;
1153 }
1154
1155 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1156 {
1157     FIXME("iface %p stub!\n", iface);
1158
1159     return 0;
1160 }
1161
1162 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1163         HANDLE resource_handle, REFIID guid, void **resource)
1164 {
1165     FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1166             iface, resource_handle, debugstr_guid(guid), resource);
1167
1168     return E_NOTIMPL;
1169 }
1170
1171 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1172 {
1173     FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1174 }
1175
1176 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1177 {
1178     FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1179 }
1180
1181 static const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1182 {
1183     /* IUnknown methods */
1184     d3d10_device_QueryInterface,
1185     d3d10_device_AddRef,
1186     d3d10_device_Release,
1187     /* ID3D10Device methods */
1188     d3d10_device_VSSetConstantBuffers,
1189     d3d10_device_PSSetShaderResources,
1190     d3d10_device_PSSetShader,
1191     d3d10_device_PSSetSamplers,
1192     d3d10_device_VSSetShader,
1193     d3d10_device_DrawIndexed,
1194     d3d10_device_Draw,
1195     d3d10_device_PSSetConstantBuffers,
1196     d3d10_device_IASetInputLayout,
1197     d3d10_device_IASetVertexBuffers,
1198     d3d10_device_IASetIndexBuffer,
1199     d3d10_device_DrawIndexedInstanced,
1200     d3d10_device_DrawInstanced,
1201     d3d10_device_GSSetConstantBuffers,
1202     d3d10_device_GSSetShader,
1203     d3d10_device_IASetPrimitiveTopology,
1204     d3d10_device_VSSetShaderResources,
1205     d3d10_device_VSSetSamplers,
1206     d3d10_device_SetPredication,
1207     d3d10_device_GSSetShaderResources,
1208     d3d10_device_GSSetSamplers,
1209     d3d10_device_OMSetRenderTargets,
1210     d3d10_device_OMSetBlendState,
1211     d3d10_device_OMSetDepthStencilState,
1212     d3d10_device_SOSetTargets,
1213     d3d10_device_DrawAuto,
1214     d3d10_device_RSSetState,
1215     d3d10_device_RSSetViewports,
1216     d3d10_device_RSSetScissorRects,
1217     d3d10_device_CopySubresourceRegion,
1218     d3d10_device_CopyResource,
1219     d3d10_device_UpdateSubresource,
1220     d3d10_device_ClearRenderTargetView,
1221     d3d10_device_ClearDepthStencilView,
1222     d3d10_device_GenerateMips,
1223     d3d10_device_ResolveSubresource,
1224     d3d10_device_VSGetConstantBuffers,
1225     d3d10_device_PSGetShaderResources,
1226     d3d10_device_PSGetShader,
1227     d3d10_device_PSGetSamplers,
1228     d3d10_device_VSGetShader,
1229     d3d10_device_PSGetConstantBuffers,
1230     d3d10_device_IAGetInputLayout,
1231     d3d10_device_IAGetVertexBuffers,
1232     d3d10_device_IAGetIndexBuffer,
1233     d3d10_device_GSGetConstantBuffers,
1234     d3d10_device_GSGetShader,
1235     d3d10_device_IAGetPrimitiveTopology,
1236     d3d10_device_VSGetShaderResources,
1237     d3d10_device_VSGetSamplers,
1238     d3d10_device_GetPredication,
1239     d3d10_device_GSGetShaderResources,
1240     d3d10_device_GSGetSamplers,
1241     d3d10_device_OMGetRenderTargets,
1242     d3d10_device_OMGetBlendState,
1243     d3d10_device_OMGetDepthStencilState,
1244     d3d10_device_SOGetTargets,
1245     d3d10_device_RSGetState,
1246     d3d10_device_RSGetViewports,
1247     d3d10_device_RSGetScissorRects,
1248     d3d10_device_GetDeviceRemovedReason,
1249     d3d10_device_SetExceptionMode,
1250     d3d10_device_GetExceptionMode,
1251     d3d10_device_GetPrivateData,
1252     d3d10_device_SetPrivateData,
1253     d3d10_device_SetPrivateDataInterface,
1254     d3d10_device_ClearState,
1255     d3d10_device_Flush,
1256     d3d10_device_CreateBuffer,
1257     d3d10_device_CreateTexture1D,
1258     d3d10_device_CreateTexture2D,
1259     d3d10_device_CreateTexture3D,
1260     d3d10_device_CreateShaderResourceView,
1261     d3d10_device_CreateRenderTargetView,
1262     d3d10_device_CreateDepthStencilView,
1263     d3d10_device_CreateInputLayout,
1264     d3d10_device_CreateVertexShader,
1265     d3d10_device_CreateGeometryShader,
1266     d3d10_device_CreateGeometryShaderWithStreamOutput,
1267     d3d10_device_CreatePixelShader,
1268     d3d10_device_CreateBlendState,
1269     d3d10_device_CreateDepthStencilState,
1270     d3d10_device_CreateRasterizerState,
1271     d3d10_device_CreateSamplerState,
1272     d3d10_device_CreateQuery,
1273     d3d10_device_CreatePredicate,
1274     d3d10_device_CreateCounter,
1275     d3d10_device_CheckFormatSupport,
1276     d3d10_device_CheckMultisampleQualityLevels,
1277     d3d10_device_CheckCounterInfo,
1278     d3d10_device_CheckCounter,
1279     d3d10_device_GetCreationFlags,
1280     d3d10_device_OpenSharedResource,
1281     d3d10_device_SetTextFilterSize,
1282     d3d10_device_GetTextFilterSize,
1283 };
1284
1285 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1286 {
1287     /* IUnknown methods */
1288     d3d10_device_inner_QueryInterface,
1289     d3d10_device_inner_AddRef,
1290     d3d10_device_inner_Release,
1291 };
1292
1293 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1294
1295 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1296 {
1297     d3d10_subresource_destroyed,
1298 };
1299
1300 /* IWineDXGIDeviceParent IUnknown methods */
1301
1302 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1303 {
1304     return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1305 }
1306
1307 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1308         REFIID riid, void **ppv)
1309 {
1310     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1311     return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1312 }
1313
1314 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1315 {
1316     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1317     return IUnknown_AddRef(device->outer_unk);
1318 }
1319
1320 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1321 {
1322     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1323     return IUnknown_Release(device->outer_unk);
1324 }
1325
1326 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1327         IWineDXGIDeviceParent *iface)
1328 {
1329     struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1330     return &device->device_parent;
1331 }
1332
1333 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1334 {
1335     /* IUnknown methods */
1336     dxgi_device_parent_QueryInterface,
1337     dxgi_device_parent_AddRef,
1338     dxgi_device_parent_Release,
1339     /* IWineDXGIDeviceParent methods */
1340     dxgi_device_parent_get_wined3d_device_parent,
1341 };
1342
1343 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1344 {
1345     return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1346 }
1347
1348 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1349         struct wined3d_device *wined3d_device)
1350 {
1351     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1352
1353     TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1354
1355     wined3d_device_incref(wined3d_device);
1356     device->wined3d_device = wined3d_device;
1357 }
1358
1359 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1360 {
1361     TRACE("device_parent %p.\n", device_parent);
1362 }
1363
1364 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
1365         void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
1366         enum wined3d_pool pool, UINT level, enum wined3d_cubemap_face face, struct wined3d_surface **surface)
1367 {
1368     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1369
1370     TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
1371             "\tpool %#x, level %u, face %u, surface %p.\n",
1372             device_parent, container_parent, width, height, format, usage, pool, level, face, surface);
1373
1374     return wined3d_surface_create(device->wined3d_device, width, height, format, level,
1375             usage, pool, WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent,
1376             &d3d10_null_wined3d_parent_ops, surface);
1377 }
1378
1379 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1380         void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
1381         enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
1382 {
1383     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1384     struct wined3d_resource *sub_resource;
1385     struct d3d10_texture2d *texture;
1386     D3D10_TEXTURE2D_DESC desc;
1387     HRESULT hr;
1388
1389     FIXME("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
1390             "\tmultisample_type %#x, multisample_quality %u, surface %p partial stub!\n",
1391             device_parent, container_parent, width, height, format_id, usage,
1392             multisample_type, multisample_quality, surface);
1393
1394     FIXME("Implement DXGI<->wined3d usage conversion\n");
1395
1396     desc.Width = width;
1397     desc.Height = height;
1398     desc.MipLevels = 1;
1399     desc.ArraySize = 1;
1400     desc.Format = dxgi_format_from_wined3dformat(format_id);
1401     desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1402     desc.SampleDesc.Quality = multisample_quality;
1403     desc.Usage = D3D10_USAGE_DEFAULT;
1404     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1405     desc.CPUAccessFlags = 0;
1406     desc.MiscFlags = 0;
1407
1408     hr = d3d10_device_CreateTexture2D(&device->ID3D10Device_iface, &desc, NULL,
1409             (ID3D10Texture2D **)&texture);
1410     if (FAILED(hr))
1411     {
1412         ERR("CreateTexture2D failed, returning %#x\n", hr);
1413         return hr;
1414     }
1415
1416     sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1417     *surface = wined3d_surface_from_resource(sub_resource);
1418     wined3d_surface_incref(*surface);
1419     ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1420
1421     return S_OK;
1422 }
1423
1424 static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
1425         void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
1426         enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
1427 {
1428     HRESULT hr;
1429
1430     TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
1431             "format %#x, pool %#x, usage %#x, volume %p.\n",
1432             device_parent, container_parent, width, height, depth,
1433             format, pool, usage, volume);
1434
1435     hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
1436             width, height, depth, usage, format, pool, NULL, &d3d10_subresource_parent_ops, volume);
1437     if (FAILED(hr))
1438     {
1439         WARN("Failed to create wined3d volume, hr %#x.\n", hr);
1440         return hr;
1441     }
1442
1443     return S_OK;
1444 }
1445
1446 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
1447         struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
1448 {
1449     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1450     IWineDXGIDevice *wine_device;
1451     HRESULT hr;
1452
1453     TRACE("device_parent %p, desc %p, swapchain %p\n", device_parent, desc, swapchain);
1454
1455     hr = d3d10_device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice,
1456             (void **)&wine_device);
1457     if (FAILED(hr))
1458     {
1459         ERR("Device should implement IWineDXGIDevice\n");
1460         return E_FAIL;
1461     }
1462
1463     hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
1464     IWineDXGIDevice_Release(wine_device);
1465     if (FAILED(hr))
1466     {
1467         ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1468         return hr;
1469     }
1470
1471     return S_OK;
1472 }
1473
1474 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
1475 {
1476     device_parent_wined3d_device_created,
1477     device_parent_mode_changed,
1478     device_parent_create_swapchain_surface,
1479     device_parent_create_texture_surface,
1480     device_parent_create_volume,
1481     device_parent_create_swapchain,
1482 };
1483
1484 void d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
1485 {
1486     device->ID3D10Device_iface.lpVtbl = &d3d10_device_vtbl;
1487     device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
1488     device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
1489     device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
1490     device->refcount = 1;
1491     /* COM aggregation always takes place */
1492     device->outer_unk = outer_unknown;
1493 }