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