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