wined3d: Check if formats support blending when attached to an FBO.
[wine.git] / dlls / d3d10core / device.c
blob030ed3924de1036c168e63d8cb9fa69fe3102244
1 /*
2 * Copyright 2008-2009 Henri Verbeet for CodeWeavers
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.
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.
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
20 #include "config.h"
21 #include "wine/port.h"
23 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 /* Inner IUnknown methods */
29 static inline struct d3d10_device *d3d10_device_from_inner_unknown(IUnknown *iface)
31 return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, inner_unknown_vtbl));
34 static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object)
36 struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
38 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_ID3D10Device))
43 IUnknown_AddRef((IUnknown *)This);
44 *object = This;
45 return S_OK;
48 if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
50 IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
51 *object = &This->device_parent_vtbl;
52 return S_OK;
55 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
57 *object = NULL;
58 return E_NOINTERFACE;
61 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
63 struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
64 ULONG refcount = InterlockedIncrement(&This->refcount);
66 TRACE("%p increasing refcount to %u\n", This, refcount);
68 return refcount;
71 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
73 struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
74 ULONG refcount = InterlockedDecrement(&This->refcount);
76 TRACE("%p decreasing refcount to %u\n", This, refcount);
78 if (!refcount)
80 if (This->wined3d_device) IWineD3DDevice_Release(This->wined3d_device);
83 return refcount;
86 /* IUnknown methods */
88 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid, void **object)
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);
95 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
97 struct d3d10_device *This = (struct d3d10_device *)iface;
98 TRACE("Forwarding to outer IUnknown\n");
99 return IUnknown_AddRef(This->outer_unknown);
102 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
104 struct d3d10_device *This = (struct d3d10_device *)iface;
105 TRACE("Forwarding to outer IUnknown\n");
106 return IUnknown_Release(This->outer_unknown);
109 /* ID3D10Device methods */
111 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
112 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
114 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
115 iface, start_slot, buffer_count, buffers);
118 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device *iface,
119 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
121 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
122 iface, start_slot, view_count, views);
125 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface, ID3D10PixelShader *shader)
127 struct d3d10_device *This = (struct d3d10_device *)iface;
128 struct d3d10_pixel_shader *ps = (struct d3d10_pixel_shader *)shader;
130 TRACE("iface %p, shader %p\n", iface, shader);
132 IWineD3DDevice_SetPixelShader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
135 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface,
136 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
138 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
139 iface, start_slot, sampler_count, samplers);
142 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface, ID3D10VertexShader *shader)
144 struct d3d10_device *This = (struct d3d10_device *)iface;
145 struct d3d10_vertex_shader *vs = (struct d3d10_vertex_shader *)shader;
147 TRACE("iface %p, shader %p\n", iface, shader);
149 IWineD3DDevice_SetVertexShader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
152 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface,
153 UINT index_count, UINT start_index_location, INT base_vertex_location)
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);
159 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface,
160 UINT vertex_count, UINT start_vertex_location)
162 struct d3d10_device *This = (struct d3d10_device *)iface;
164 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
165 iface, vertex_count, start_vertex_location);
167 IWineD3DDevice_DrawPrimitive(This->wined3d_device, start_vertex_location, vertex_count);
170 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
171 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
173 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
174 iface, start_slot, buffer_count, buffers);
177 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface, ID3D10InputLayout *input_layout)
179 struct d3d10_device *This = (struct d3d10_device *)iface;
181 TRACE("iface %p, input_layout %p\n", iface, input_layout);
183 IWineD3DDevice_SetVertexDeclaration(This->wined3d_device,
184 ((struct d3d10_input_layout *)input_layout)->wined3d_decl);
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)
191 struct d3d10_device *This = (struct d3d10_device *)iface;
192 unsigned int i;
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);
197 for (i = 0; i < buffer_count; ++i)
199 IWineD3DDevice_SetStreamSource(This->wined3d_device, start_slot,
200 ((struct d3d10_buffer *)buffers[i])->wined3d_buffer, offsets[i], strides[i]);
204 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
205 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
207 FIXME("iface %p, buffer %p, format %s, offset %u stub!\n",
208 iface, buffer, debug_dxgi_format(format), offset);
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)
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);
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)
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);
230 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
231 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
233 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
234 iface, start_slot, buffer_count, buffers);
237 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
239 if (shader) FIXME("iface %p, shader %p stub!\n", iface, shader);
240 else WARN("iface %p, shader %p stub!\n", iface, shader);
243 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface, D3D10_PRIMITIVE_TOPOLOGY topology)
245 struct d3d10_device *This = (struct d3d10_device *)iface;
247 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
249 IWineD3DDevice_SetPrimitiveType(This->wined3d_device, (WINED3DPRIMITIVETYPE)topology);
252 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
253 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
255 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
256 iface, start_slot, view_count, views);
259 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
260 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
262 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
263 iface, start_slot, sampler_count, samplers);
266 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
268 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
271 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
272 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
274 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
275 iface, start_slot, view_count, views);
278 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
279 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
281 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
282 iface, start_slot, sampler_count, samplers);
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)
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);
293 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
294 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
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);
300 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
301 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
303 FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n",
304 iface, depth_stencil_state, stencil_ref);
307 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
308 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
310 FIXME("iface %p, target_count %u, targets %p, offsets %p stub!\n", iface, target_count, targets, offsets);
313 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
315 FIXME("iface %p stub!\n", iface);
318 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
320 FIXME("iface %p, rasterizer_state %p stub!\n", iface, rasterizer_state);
323 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
324 UINT viewport_count, const D3D10_VIEWPORT *viewports)
326 FIXME("iface %p, viewport_count %u, viewports %p stub!\n", iface, viewport_count, viewports);
329 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
330 UINT rect_count, const D3D10_RECT *rects)
332 FIXME("iface %p, rect_count %u, rects %p\n", iface, rect_count, rects);
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)
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);
345 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
346 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
348 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
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)
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);
359 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
360 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
362 struct d3d10_device *This = (struct d3d10_device *)iface;
363 IWineD3DRendertargetView *wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view;
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]);
368 IWineD3DDevice_ClearRendertargetView(This->wined3d_device, wined3d_view, color_rgba);
371 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
372 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
374 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
375 iface, depth_stencil_view, flags, depth, stencil);
378 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
380 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
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)
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));
393 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
394 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
396 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
397 iface, start_slot, buffer_count, buffers);
400 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
401 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
403 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
404 iface, start_slot, view_count, views);
407 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
409 FIXME("iface %p, shader %p stub!\n", iface, shader);
412 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
413 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
415 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
416 iface, start_slot, sampler_count, samplers);
419 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
421 FIXME("iface %p, shader %p stub!\n", iface, shader);
424 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
425 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
427 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
428 iface, start_slot, buffer_count, buffers);
431 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
433 FIXME("iface %p, input_layout %p stub!\n", iface, input_layout);
436 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
437 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
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);
443 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
444 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
446 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
449 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
450 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
452 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
453 iface, start_slot, buffer_count, buffers);
456 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
458 FIXME("iface %p, shader %p stub!\n", iface, shader);
461 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface, D3D10_PRIMITIVE_TOPOLOGY *topology)
463 struct d3d10_device *This = (struct d3d10_device *)iface;
465 TRACE("iface %p, topology %p\n", iface, topology);
467 IWineD3DDevice_GetPrimitiveType(This->wined3d_device, (WINED3DPRIMITIVETYPE *)topology);
470 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
471 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
473 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
474 iface, start_slot, view_count, views);
477 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
478 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
480 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
481 iface, start_slot, sampler_count, samplers);
484 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
485 ID3D10Predicate **predicate, BOOL *value)
487 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
490 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
491 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
493 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
494 iface, start_slot, view_count, views);
497 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
498 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
500 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
501 iface, start_slot, sampler_count, samplers);
504 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
505 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
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);
511 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
512 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
514 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
515 iface, blend_state, blend_factor, sample_mask);
518 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
519 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
521 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n",
522 iface, depth_stencil_state, stencil_ref);
525 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
526 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
528 FIXME("iface %p, buffer_count %u, buffers %p, offsets %p stub!\n",
529 iface, buffer_count, buffers, offsets);
532 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
534 FIXME("iface %p, rasterizer_state %p stub!\n", iface, rasterizer_state);
537 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
538 UINT *viewport_count, D3D10_VIEWPORT *viewports)
540 FIXME("iface %p, viewport_count %p, viewports %p stub!\n", iface, viewport_count, viewports);
543 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
545 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
548 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
550 FIXME("iface %p stub!\n", iface);
552 return E_NOTIMPL;
555 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
557 FIXME("iface %p, flags %#x stub!\n", iface, flags);
559 return E_NOTIMPL;
562 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
564 FIXME("iface %p stub!\n", iface);
566 return 0;
569 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
570 REFGUID guid, UINT *data_size, void *data)
572 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
573 iface, debugstr_guid(guid), data_size, data);
575 return E_NOTIMPL;
578 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
579 REFGUID guid, UINT data_size, const void *data)
581 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
582 iface, debugstr_guid(guid), data_size, data);
584 return E_NOTIMPL;
587 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
588 REFGUID guid, const IUnknown *data)
590 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
592 return E_NOTIMPL;
595 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
597 FIXME("iface %p stub!\n", iface);
600 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
602 FIXME("iface %p stub!\n", iface);
605 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
606 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
608 struct d3d10_device *This = (struct d3d10_device *)iface;
609 struct wined3d_buffer_desc wined3d_desc;
610 struct d3d10_buffer *object;
611 HRESULT hr;
613 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
615 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
616 if (!object)
618 ERR("Failed to allocate D3D10 buffer object memory\n");
619 return E_OUTOFMEMORY;
622 object->vtbl = &d3d10_buffer_vtbl;
623 object->refcount = 1;
625 FIXME("Implement DXGI<->wined3d usage conversion\n");
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;
633 hr = IWineD3DDevice_CreateBuffer(This->wined3d_device, &wined3d_desc,
634 data ? data->pSysMem : NULL, (IUnknown *)object, &object->wined3d_buffer);
635 if (FAILED(hr))
637 ERR("CreateBuffer failed, returning %#x\n", hr);
638 HeapFree(GetProcessHeap(), 0, object);
639 return hr;
642 *buffer = (ID3D10Buffer *)object;
644 TRACE("Created ID3D10Buffer %p\n", object);
646 return S_OK;
649 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
650 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
652 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
654 return E_NOTIMPL;
657 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
658 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture2D **texture)
660 struct d3d10_device *This = (struct d3d10_device *)iface;
661 struct d3d10_texture2d *object;
662 HRESULT hr;
664 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
666 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
667 if (!object)
669 ERR("Failed to allocate D3D10 texture2d object memory\n");
670 return E_OUTOFMEMORY;
673 object->vtbl = &d3d10_texture2d_vtbl;
674 object->refcount = 1;
675 object->desc = *desc;
677 if (desc->MipLevels == 1 && desc->ArraySize == 1)
679 IWineDXGIDevice *wine_device;
681 hr = ID3D10Device_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
682 if (FAILED(hr))
684 ERR("Device should implement IWineDXGIDevice\n");
685 HeapFree(GetProcessHeap(), 0, object);
686 return E_FAIL;
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))
694 ERR("Failed to create DXGI surface, returning %#x\n", hr);
695 HeapFree(GetProcessHeap(), 0, object);
696 return hr;
699 FIXME("Implement DXGI<->wined3d usage conversion\n");
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, 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))
708 ERR("CreateSurface failed, returning %#x\n", hr);
709 IDXGISurface_Release(object->dxgi_surface);
710 HeapFree(GetProcessHeap(), 0, object);
711 return hr;
715 *texture = (ID3D10Texture2D *)object;
717 TRACE("Created ID3D10Texture2D %p\n", object);
719 return S_OK;
722 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
723 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture3D **texture)
725 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
727 return E_NOTIMPL;
730 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
731 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
733 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
735 return E_NOTIMPL;
738 static IWineD3DResource *d3d10_device_wined3d_resource_from_resource(ID3D10Resource *resource)
740 D3D10_RESOURCE_DIMENSION dimension;
742 ID3D10Resource_GetType(resource, &dimension);
744 switch(dimension)
746 case D3D10_RESOURCE_DIMENSION_BUFFER:
747 return (IWineD3DResource *)((struct d3d10_buffer *)resource)->wined3d_buffer;
749 case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
750 return (IWineD3DResource *)((struct d3d10_texture2d *)resource)->wined3d_surface;
752 default:
753 FIXME("Unhandled resource dimension %#x\n", dimension);
754 return NULL;
758 static HRESULT d3d10_device_set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10Resource *resource)
760 D3D10_RESOURCE_DIMENSION dimension;
761 HRESULT hr;
763 ID3D10Resource_GetType(resource, &dimension);
765 switch(dimension)
767 case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
769 ID3D10Texture1D *texture;
770 D3D10_TEXTURE1D_DESC texture_desc;
772 hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture);
773 if (FAILED(hr))
775 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D?\n");
776 return E_INVALIDARG;
779 ID3D10Texture1D_GetDesc(texture, &texture_desc);
780 ID3D10Texture1D_Release(texture);
782 desc->Format = texture_desc.Format;
783 if (texture_desc.ArraySize == 1)
785 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE1D;
786 desc->Texture1D.MipSlice = 0;
788 else
790 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE1DARRAY;
791 desc->Texture1DArray.MipSlice = 0;
792 desc->Texture1DArray.FirstArraySlice = 0;
793 desc->Texture1DArray.ArraySize = 1;
796 return S_OK;
799 case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
801 ID3D10Texture2D *texture;
802 D3D10_TEXTURE2D_DESC texture_desc;
804 hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture);
805 if (FAILED(hr))
807 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D?\n");
808 return E_INVALIDARG;
811 ID3D10Texture2D_GetDesc(texture, &texture_desc);
812 ID3D10Texture2D_Release(texture);
814 desc->Format = texture_desc.Format;
815 if (texture_desc.ArraySize == 1)
817 if (texture_desc.SampleDesc.Count == 1)
819 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
820 desc->Texture2D.MipSlice = 0;
822 else
824 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMS;
827 else
829 if (texture_desc.SampleDesc.Count == 1)
831 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DARRAY;
832 desc->Texture2DArray.MipSlice = 0;
833 desc->Texture2DArray.FirstArraySlice = 0;
834 desc->Texture2DArray.ArraySize = 1;
836 else
838 desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY;
839 desc->Texture2DMSArray.FirstArraySlice = 0;
840 desc->Texture2DMSArray.ArraySize = 1;
844 return S_OK;
847 case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
849 ID3D10Texture3D *texture;
850 D3D10_TEXTURE3D_DESC texture_desc;
852 hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture);
853 if (FAILED(hr))
855 ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D?\n");
856 return E_INVALIDARG;
859 ID3D10Texture3D_GetDesc(texture, &texture_desc);
860 ID3D10Texture3D_Release(texture);
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;
868 return S_OK;
871 default:
872 FIXME("Unhandled resource dimension %#x\n", dimension);
873 return E_INVALIDARG;
877 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
878 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
880 struct d3d10_device *This = (struct d3d10_device *)iface;
881 struct d3d10_rendertarget_view *object;
882 IWineD3DResource *wined3d_resource;
884 TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
886 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
887 if (!object)
889 ERR("Failed to allocate D3D10 rendertarget view object memory\n");
890 return E_OUTOFMEMORY;
893 object->vtbl = &d3d10_rendertarget_view_vtbl;
894 object->refcount = 1;
896 if (!desc)
898 HRESULT hr = d3d10_device_set_rtdesc_from_resource(&object->desc, resource);
899 if (FAILED(hr))
901 HeapFree(GetProcessHeap(), 0, object);
902 return hr;
905 else
907 object->desc = *desc;
910 wined3d_resource = d3d10_device_wined3d_resource_from_resource(resource);
911 if (!wined3d_resource)
913 FIXME("Failed to get wined3d resource for d3d10 resource %p\n", resource);
914 HeapFree(GetProcessHeap(), 0, object);
915 return E_FAIL;
917 IWineD3DDevice_CreateRendertargetView(This->wined3d_device,
918 wined3d_resource, (IUnknown *)object, &object->wined3d_view);
920 *view = (ID3D10RenderTargetView *)object;
922 return S_OK;
925 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
926 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
928 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
930 return E_NOTIMPL;
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)
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;
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);
948 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
949 if (!object)
951 ERR("Failed to allocate D3D10 input layout object memory\n");
952 return E_OUTOFMEMORY;
955 object->vtbl = &d3d10_input_layout_vtbl;
956 object->refcount = 1;
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))
962 HeapFree(GetProcessHeap(), 0, object);
963 return hr;
966 IWineD3DDevice_CreateVertexDeclaration(This->wined3d_device, &object->wined3d_decl,
967 (IUnknown *)object, wined3d_elements, wined3d_element_count);
969 HeapFree(GetProcessHeap(), 0, wined3d_elements);
971 *input_layout = (ID3D10InputLayout *)object;
973 return S_OK;
976 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
977 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
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;
984 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
985 iface, byte_code, byte_code_length, shader);
987 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
988 if (!object)
990 ERR("Failed to allocate D3D10 vertex shader object memory\n");
991 return E_OUTOFMEMORY;
994 object->vtbl = &d3d10_vertex_shader_vtbl;
995 object->refcount = 1;
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))
1001 ERR("Failed to extract shader, hr %#x\n", hr);
1002 HeapFree(GetProcessHeap(), 0, object);
1003 return hr;
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))
1011 ERR("CreateVertexShader failed, hr %#x\n", hr);
1012 shader_free_signature(&object->output_signature);
1013 HeapFree(GetProcessHeap(), 0, object);
1014 return hr;
1017 *shader = (ID3D10VertexShader *)object;
1019 return S_OK;
1022 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
1023 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1025 struct d3d10_geometry_shader *object;
1027 FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
1028 iface, byte_code, byte_code_length, shader);
1030 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1031 if (!object)
1033 ERR("Failed to allocate D3D10 geometry shader object memory\n");
1034 return E_OUTOFMEMORY;
1037 object->vtbl = &d3d10_geometry_shader_vtbl;
1038 object->refcount = 1;
1040 *shader = (ID3D10GeometryShader *)object;
1042 return S_OK;
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)
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);
1054 return E_NOTIMPL;
1057 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
1058 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
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;
1065 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1066 iface, byte_code, byte_code_length, shader);
1068 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1069 if (!object)
1071 ERR("Failed to allocate D3D10 pixel shader object memory\n");
1072 return E_OUTOFMEMORY;
1075 object->vtbl = &d3d10_pixel_shader_vtbl;
1076 object->refcount = 1;
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))
1082 ERR("Failed to extract shader, hr %#x\n", hr);
1083 HeapFree(GetProcessHeap(), 0, object);
1084 return hr;
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))
1092 ERR("CreatePixelShader failed, hr %#x\n", hr);
1093 shader_free_signature(&object->output_signature);
1094 HeapFree(GetProcessHeap(), 0, object);
1095 return hr;
1098 *shader = (ID3D10PixelShader *)object;
1100 return S_OK;
1103 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
1104 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1106 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1108 return E_NOTIMPL;
1111 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1112 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1114 FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface, desc, depth_stencil_state);
1116 return E_NOTIMPL;
1119 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1120 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1122 FIXME("iface %p, desc %p, rasterizer_state %p stub!\n", iface, desc, rasterizer_state);
1124 return E_NOTIMPL;
1127 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1128 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1130 FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface, desc, sampler_state);
1132 return E_NOTIMPL;
1135 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1136 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1138 FIXME("iface %p, desc %p, query %p stub!\n", iface, desc, query);
1140 return E_NOTIMPL;
1143 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1144 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1146 FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1148 return E_NOTIMPL;
1151 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1152 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1154 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1156 return E_NOTIMPL;
1159 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1160 DXGI_FORMAT format, UINT *format_support)
1162 FIXME("iface %p, format %s, format_support %p stub!\n",
1163 iface, debug_dxgi_format(format), format_support);
1165 return E_NOTIMPL;
1168 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1169 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
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);
1174 return E_NOTIMPL;
1177 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1179 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
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)
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);
1191 return E_NOTIMPL;
1194 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1196 FIXME("iface %p stub!\n", iface);
1198 return 0;
1201 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1202 HANDLE resource_handle, REFIID guid, void **resource)
1204 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1205 iface, resource_handle, debugstr_guid(guid), resource);
1207 return E_NOTIMPL;
1210 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1212 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1215 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1217 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1220 const struct ID3D10DeviceVtbl d3d10_device_vtbl =
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,
1324 const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1326 /* IUnknown methods */
1327 d3d10_device_inner_QueryInterface,
1328 d3d10_device_inner_AddRef,
1329 d3d10_device_inner_Release,
1332 /* IWineD3DDeviceParent IUnknown methods */
1334 static inline struct d3d10_device *device_from_device_parent(IWineD3DDeviceParent *iface)
1336 return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, device_parent_vtbl));
1339 static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
1341 struct d3d10_device *This = device_from_device_parent(iface);
1342 return d3d10_device_QueryInterface((ID3D10Device *)This, riid, object);
1345 static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
1347 struct d3d10_device *This = device_from_device_parent(iface);
1348 return d3d10_device_AddRef((ID3D10Device *)This);
1351 static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
1353 struct d3d10_device *This = device_from_device_parent(iface);
1354 return d3d10_device_Release((ID3D10Device *)This);
1357 /* IWineD3DDeviceParent methods */
1359 static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
1361 struct d3d10_device *This = device_from_device_parent(iface);
1363 TRACE("iface %p, device %p\n", iface, device);
1365 IWineD3DDevice_AddRef(device);
1366 This->wined3d_device = device;
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)
1373 struct d3d10_device *This = device_from_device_parent(iface);
1374 struct d3d10_texture2d *texture;
1375 D3D10_TEXTURE2D_DESC desc;
1376 HRESULT hr;
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);
1382 FIXME("Implement DXGI<->wined3d usage conversion\n");
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;
1396 hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1397 if (FAILED(hr))
1399 ERR("CreateTexture2D failed, returning %#x\n", hr);
1400 return hr;
1403 *surface = texture->wined3d_surface;
1405 return S_OK;
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)
1412 struct d3d10_device *This = device_from_device_parent(iface);
1413 struct d3d10_texture2d *texture;
1414 D3D10_TEXTURE2D_DESC desc;
1415 HRESULT hr;
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);
1421 FIXME("Implement DXGI<->wined3d usage conversion\n");
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;
1435 hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1436 if (FAILED(hr))
1438 ERR("CreateTexture2D failed, returning %#x\n", hr);
1439 return hr;
1442 *surface = texture->wined3d_surface;
1444 return S_OK;
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)
1451 struct d3d10_device *This = device_from_device_parent(iface);
1452 struct d3d10_texture2d *texture;
1453 D3D10_TEXTURE2D_DESC desc;
1454 HRESULT hr;
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);
1460 FIXME("Implement DXGI<->wined3d usage conversion\n");
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;
1474 hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
1475 if (FAILED(hr))
1477 ERR("CreateTexture2D failed, returning %#x\n", hr);
1478 return hr;
1481 *surface = texture->wined3d_surface;
1483 return S_OK;
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)
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);
1493 return E_NOTIMPL;
1496 static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
1497 WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
1499 IWineDXGIDevice *wine_device;
1500 HRESULT hr;
1502 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
1504 hr = IWineD3DDeviceParent_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
1505 if (FAILED(hr))
1507 ERR("Device should implement IWineDXGIDevice\n");
1508 return E_FAIL;
1511 hr = IWineDXGIDevice_create_swapchain(wine_device, present_parameters, swapchain);
1512 IWineDXGIDevice_Release(wine_device);
1513 if (FAILED(hr))
1515 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1516 return hr;
1519 return S_OK;
1522 const struct IWineD3DDeviceParentVtbl d3d10_wined3d_device_parent_vtbl =
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,