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