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