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