d3d10core: Fix the stream index in d3d10_device_IASetVertexBuffers().
[wine.git] / dlls / d3d10core / device.c
blobbe55387a0b75ce09c7e30b817733bd851b334721
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 static void STDMETHODCALLTYPE d3d10_null_wined3d_object_destroyed(void *parent) {}
29 const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops =
31 d3d10_null_wined3d_object_destroyed,
34 /* Inner IUnknown methods */
36 static inline struct d3d10_device *impl_from_IUnknown(IUnknown *iface)
38 return CONTAINING_RECORD(iface, struct d3d10_device, IUnknown_inner);
41 static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid,
42 void **ppv)
44 struct d3d10_device *This = impl_from_IUnknown(iface);
46 TRACE("iface %p, riid %s, ppv %p\n", iface, debugstr_guid(riid), ppv);
48 if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3D10Device))
49 *ppv = &This->ID3D10Device_iface;
50 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
51 *ppv = &This->IWineDXGIDeviceParent_iface;
52 else
54 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
55 *ppv = NULL;
56 return E_NOINTERFACE;
59 IUnknown_AddRef((IUnknown*)*ppv);
60 return S_OK;
63 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
65 struct d3d10_device *This = impl_from_IUnknown(iface);
66 ULONG refcount = InterlockedIncrement(&This->refcount);
68 TRACE("%p increasing refcount to %u\n", This, refcount);
70 return refcount;
73 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
75 struct d3d10_device *This = impl_from_IUnknown(iface);
76 ULONG refcount = InterlockedDecrement(&This->refcount);
78 TRACE("%p decreasing refcount to %u\n", This, refcount);
80 if (!refcount)
82 if (This->wined3d_device)
83 wined3d_device_decref(This->wined3d_device);
86 return refcount;
89 /* IUnknown methods */
91 static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device *iface)
93 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device_iface);
96 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid,
97 void **ppv)
99 struct d3d10_device *This = impl_from_ID3D10Device(iface);
100 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
103 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
105 struct d3d10_device *This = impl_from_ID3D10Device(iface);
106 return IUnknown_AddRef(This->outer_unk);
109 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
111 struct d3d10_device *This = impl_from_ID3D10Device(iface);
112 return IUnknown_Release(This->outer_unk);
115 /* ID3D10Device methods */
117 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
118 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
120 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
121 iface, start_slot, buffer_count, buffers);
124 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device *iface,
125 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
127 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
128 iface, start_slot, view_count, views);
131 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface,
132 ID3D10PixelShader *shader)
134 struct d3d10_device *This = impl_from_ID3D10Device(iface);
135 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
137 TRACE("iface %p, shader %p\n", iface, shader);
139 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
142 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface,
143 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
145 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
146 iface, start_slot, sampler_count, samplers);
149 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface,
150 ID3D10VertexShader *shader)
152 struct d3d10_device *This = impl_from_ID3D10Device(iface);
153 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
155 TRACE("iface %p, shader %p\n", iface, shader);
157 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
160 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface, UINT index_count,
161 UINT start_index_location, INT base_vertex_location)
163 struct d3d10_device *This = impl_from_ID3D10Device(iface);
165 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
166 iface, index_count, start_index_location, base_vertex_location);
168 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
169 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
172 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface, UINT vertex_count,
173 UINT start_vertex_location)
175 struct d3d10_device *This = impl_from_ID3D10Device(iface);
177 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
178 iface, vertex_count, start_vertex_location);
180 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
183 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
184 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
186 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
187 iface, start_slot, buffer_count, buffers);
190 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface,
191 ID3D10InputLayout *input_layout)
193 struct d3d10_device *This = impl_from_ID3D10Device(iface);
194 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
196 TRACE("iface %p, input_layout %p\n", iface, input_layout);
198 wined3d_device_set_vertex_declaration(This->wined3d_device,
199 layout ? layout->wined3d_decl : NULL);
202 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *iface, UINT start_slot,
203 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
205 struct d3d10_device *This = impl_from_ID3D10Device(iface);
206 unsigned int i;
208 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
209 iface, start_slot, buffer_count, buffers, strides, offsets);
211 for (i = 0; i < buffer_count; ++i)
213 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
215 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
216 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
220 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
221 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
223 struct d3d10_device *This = impl_from_ID3D10Device(iface);
224 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
226 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
227 iface, buffer, debug_dxgi_format(format), offset);
229 wined3d_device_set_index_buffer(This->wined3d_device,
230 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
231 wined3dformat_from_dxgi_format(format));
232 if (offset) FIXME("offset %u not supported.\n", offset);
235 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device *iface,
236 UINT instance_index_count, UINT instance_count, UINT start_index_location,
237 INT base_vertex_location, UINT start_instance_location)
239 FIXME("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
240 "\tbase_vertex_location %d, start_instance_location %u stub!\n",
241 iface, instance_index_count, instance_count, start_index_location,
242 base_vertex_location, start_instance_location);
245 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device *iface,
246 UINT instance_vertex_count, UINT instance_count,
247 UINT start_vertex_location, UINT start_instance_location)
249 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
250 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
251 start_vertex_location, start_instance_location);
254 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
255 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
257 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
258 iface, start_slot, buffer_count, buffers);
261 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
263 struct d3d10_device *device = impl_from_ID3D10Device(iface);
264 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
266 TRACE("iface %p, shader %p.\n", iface, shader);
268 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
271 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface,
272 D3D10_PRIMITIVE_TOPOLOGY topology)
274 struct d3d10_device *This = impl_from_ID3D10Device(iface);
276 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
278 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
281 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
282 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
284 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
285 iface, start_slot, view_count, views);
288 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
289 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
291 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
292 iface, start_slot, sampler_count, samplers);
295 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
297 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
300 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
301 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
303 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
304 iface, start_slot, view_count, views);
307 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
308 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
310 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
311 iface, start_slot, sampler_count, samplers);
314 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device *iface,
315 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
316 ID3D10DepthStencilView *depth_stencil_view)
318 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
319 iface, render_target_view_count, render_target_views, depth_stencil_view);
322 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
323 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
325 struct d3d10_device *device = impl_from_ID3D10Device(iface);
327 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
328 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
330 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
331 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
332 device->sample_mask = sample_mask;
335 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
336 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
338 struct d3d10_device *device = impl_from_ID3D10Device(iface);
340 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
341 iface, depth_stencil_state, stencil_ref);
343 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
344 device->stencil_ref = stencil_ref;
347 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
348 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
350 FIXME("iface %p, target_count %u, targets %p, offsets %p stub!\n", iface, target_count, targets, offsets);
353 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
355 FIXME("iface %p stub!\n", iface);
358 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
360 struct d3d10_device *device = impl_from_ID3D10Device(iface);
362 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
364 device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
367 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
368 UINT viewport_count, const D3D10_VIEWPORT *viewports)
370 struct d3d10_device *device = impl_from_ID3D10Device(iface);
371 struct wined3d_viewport wined3d_vp;
373 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
375 if (viewport_count > 1)
376 FIXME("Multiple viewports not implemented.\n");
378 if (!viewport_count)
379 return;
381 wined3d_vp.x = viewports[0].TopLeftX;
382 wined3d_vp.y = viewports[0].TopLeftY;
383 wined3d_vp.width = viewports[0].Width;
384 wined3d_vp.height = viewports[0].Height;
385 wined3d_vp.min_z = viewports[0].MinDepth;
386 wined3d_vp.max_z = viewports[0].MaxDepth;
388 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
391 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
392 UINT rect_count, const D3D10_RECT *rects)
394 FIXME("iface %p, rect_count %u, rects %p\n", iface, rect_count, rects);
397 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device *iface,
398 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
399 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
401 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
402 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
403 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
404 src_resource, src_subresource_idx, src_box);
407 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
408 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
410 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
413 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface,
414 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
415 const void *data, UINT row_pitch, UINT depth_pitch)
417 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
418 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
421 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
422 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
424 struct d3d10_device *This = impl_from_ID3D10Device(iface);
425 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
426 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
428 TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
429 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
431 wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
434 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
435 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
437 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
438 iface, depth_stencil_view, flags, depth, stencil);
441 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
443 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
446 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device *iface,
447 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
448 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
450 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
451 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
452 iface, dst_resource, dst_subresource_idx,
453 src_resource, src_subresource_idx, debug_dxgi_format(format));
456 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
457 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
459 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
460 iface, start_slot, buffer_count, buffers);
463 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
464 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
466 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
467 iface, start_slot, view_count, views);
470 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
472 struct d3d10_device *device = impl_from_ID3D10Device(iface);
473 struct d3d10_pixel_shader *shader_impl;
474 struct wined3d_shader *wined3d_shader;
476 TRACE("iface %p, shader %p.\n", iface, shader);
478 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
480 *shader = NULL;
481 return;
484 shader_impl = wined3d_shader_get_parent(wined3d_shader);
485 *shader = &shader_impl->ID3D10PixelShader_iface;
486 ID3D10PixelShader_AddRef(*shader);
489 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
490 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
492 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
493 iface, start_slot, sampler_count, samplers);
496 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
498 struct d3d10_device *device = impl_from_ID3D10Device(iface);
499 struct d3d10_vertex_shader *shader_impl;
500 struct wined3d_shader *wined3d_shader;
502 TRACE("iface %p, shader %p.\n", iface, shader);
504 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
506 *shader = NULL;
507 return;
510 shader_impl = wined3d_shader_get_parent(wined3d_shader);
511 *shader = &shader_impl->ID3D10VertexShader_iface;
512 ID3D10VertexShader_AddRef(*shader);
515 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
516 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
518 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
519 iface, start_slot, buffer_count, buffers);
522 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
524 FIXME("iface %p, input_layout %p stub!\n", iface, input_layout);
527 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
528 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
530 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
531 iface, start_slot, buffer_count, buffers, strides, offsets);
534 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
535 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
537 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
540 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
541 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
543 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
544 iface, start_slot, buffer_count, buffers);
547 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
549 struct d3d10_device *device = impl_from_ID3D10Device(iface);
550 struct d3d10_geometry_shader *shader_impl;
551 struct wined3d_shader *wined3d_shader;
553 TRACE("iface %p, shader %p.\n", iface, shader);
555 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
557 *shader = NULL;
558 return;
561 shader_impl = wined3d_shader_get_parent(wined3d_shader);
562 *shader = &shader_impl->ID3D10GeometryShader_iface;
563 ID3D10GeometryShader_AddRef(*shader);
566 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface,
567 D3D10_PRIMITIVE_TOPOLOGY *topology)
569 struct d3d10_device *This = impl_from_ID3D10Device(iface);
571 TRACE("iface %p, topology %p\n", iface, topology);
573 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
576 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
577 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
579 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
580 iface, start_slot, view_count, views);
583 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
584 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
586 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
587 iface, start_slot, sampler_count, samplers);
590 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
591 ID3D10Predicate **predicate, BOOL *value)
593 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
596 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
597 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
599 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
600 iface, start_slot, view_count, views);
603 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
604 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
606 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
607 iface, start_slot, sampler_count, samplers);
610 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
611 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
613 FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
614 iface, view_count, render_target_views, depth_stencil_view);
617 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
618 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
620 struct d3d10_device *device = impl_from_ID3D10Device(iface);
622 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
623 iface, blend_state, blend_factor, sample_mask);
625 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
626 ID3D10BlendState_AddRef(*blend_state);
627 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
628 *sample_mask = device->sample_mask;
631 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
632 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
634 struct d3d10_device *device = impl_from_ID3D10Device(iface);
636 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
637 iface, depth_stencil_state, stencil_ref);
639 if ((*depth_stencil_state = device->depth_stencil_state
640 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
641 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
642 *stencil_ref = device->stencil_ref;
645 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
646 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
648 FIXME("iface %p, buffer_count %u, buffers %p, offsets %p stub!\n",
649 iface, buffer_count, buffers, offsets);
652 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
654 struct d3d10_device *device = impl_from_ID3D10Device(iface);
656 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
658 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
659 ID3D10RasterizerState_AddRef(*rasterizer_state);
662 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
663 UINT *viewport_count, D3D10_VIEWPORT *viewports)
665 struct d3d10_device *device = impl_from_ID3D10Device(iface);
666 struct wined3d_viewport wined3d_vp;
668 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
670 if (!viewports)
672 *viewport_count = 1;
673 return;
676 if (!*viewport_count)
677 return;
679 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
681 viewports[0].TopLeftX = wined3d_vp.x;
682 viewports[0].TopLeftY = wined3d_vp.y;
683 viewports[0].Width = wined3d_vp.width;
684 viewports[0].Height = wined3d_vp.height;
685 viewports[0].MinDepth = wined3d_vp.min_z;
686 viewports[0].MaxDepth = wined3d_vp.max_z;
688 if (*viewport_count > 1)
689 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
692 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
694 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
697 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
699 FIXME("iface %p stub!\n", iface);
701 return E_NOTIMPL;
704 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
706 FIXME("iface %p, flags %#x stub!\n", iface, flags);
708 return E_NOTIMPL;
711 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
713 FIXME("iface %p stub!\n", iface);
715 return 0;
718 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
719 REFGUID guid, UINT *data_size, void *data)
721 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
722 iface, debugstr_guid(guid), data_size, data);
724 return E_NOTIMPL;
727 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
728 REFGUID guid, UINT data_size, const void *data)
730 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
731 iface, debugstr_guid(guid), data_size, data);
733 return E_NOTIMPL;
736 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
737 REFGUID guid, const IUnknown *data)
739 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
741 return E_NOTIMPL;
744 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
746 FIXME("iface %p stub!\n", iface);
749 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
751 FIXME("iface %p stub!\n", iface);
754 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
755 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
757 struct d3d10_device *This = impl_from_ID3D10Device(iface);
758 struct d3d10_buffer *object;
759 HRESULT hr;
761 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
763 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
764 if (!object)
766 ERR("Failed to allocate D3D10 buffer object memory\n");
767 return E_OUTOFMEMORY;
770 hr = d3d10_buffer_init(object, This, desc, data);
771 if (FAILED(hr))
773 WARN("Failed to initialize buffer, hr %#x.\n", hr);
774 HeapFree(GetProcessHeap(), 0, object);
775 return hr;
778 *buffer = &object->ID3D10Buffer_iface;
780 TRACE("Created ID3D10Buffer %p\n", object);
782 return S_OK;
785 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
786 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
788 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
790 return E_NOTIMPL;
793 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
794 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
795 ID3D10Texture2D **texture)
797 struct d3d10_device *This = impl_from_ID3D10Device(iface);
798 struct d3d10_texture2d *object;
799 HRESULT hr;
801 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
803 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
804 if (!object)
806 ERR("Failed to allocate D3D10 texture2d object memory\n");
807 return E_OUTOFMEMORY;
810 hr = d3d10_texture2d_init(object, This, desc);
811 if (FAILED(hr))
813 WARN("Failed to initialize texture, hr %#x.\n", hr);
814 HeapFree(GetProcessHeap(), 0, object);
815 return hr;
818 *texture = &object->ID3D10Texture2D_iface;
820 TRACE("Created ID3D10Texture2D %p\n", object);
822 return S_OK;
825 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
826 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
827 ID3D10Texture3D **texture)
829 struct d3d10_device *device = impl_from_ID3D10Device(iface);
830 struct d3d10_texture3d *object;
831 HRESULT hr;
833 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
835 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
836 if (!object)
838 ERR("Failed to allocate D3D10 texture3d object memory.\n");
839 return E_OUTOFMEMORY;
842 hr = d3d10_texture3d_init(object, device, desc);
843 if (FAILED(hr))
845 WARN("Failed to initialize texture, hr %#x.\n", hr);
846 HeapFree(GetProcessHeap(), 0, object);
847 return hr;
850 TRACE("Created 3D texture %p.\n", object);
851 *texture = &object->ID3D10Texture3D_iface;
853 return S_OK;
856 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
857 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
859 struct d3d10_shader_resource_view *object;
860 HRESULT hr;
862 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
864 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
865 if (!object)
867 ERR("Failed to allocate D3D10 shader resource view object memory.\n");
868 return E_OUTOFMEMORY;
871 if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
873 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
874 HeapFree(GetProcessHeap(), 0, object);
875 return hr;
878 TRACE("Created shader resource view %p.\n", object);
879 *view = &object->ID3D10ShaderResourceView_iface;
881 return S_OK;
884 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
885 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
887 struct d3d10_rendertarget_view *object;
888 HRESULT hr;
890 TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
892 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
893 if (!object)
895 ERR("Failed to allocate D3D10 rendertarget view object memory\n");
896 return E_OUTOFMEMORY;
899 hr = d3d10_rendertarget_view_init(object, resource, desc);
900 if (FAILED(hr))
902 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
903 HeapFree(GetProcessHeap(), 0, object);
904 return hr;
907 TRACE("Created rendertarget view %p.\n", object);
908 *view = &object->ID3D10RenderTargetView_iface;
910 return S_OK;
913 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
914 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
916 struct d3d10_depthstencil_view *object;
917 HRESULT hr;
919 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
921 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
922 if (!object)
924 ERR("Failed to allocate D3D10 depthstencil view object memory.\n");
925 return E_OUTOFMEMORY;
928 if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
930 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
931 HeapFree(GetProcessHeap(), 0, object);
932 return hr;
935 TRACE("Created depthstencil view %p.\n", object);
936 *view = &object->ID3D10DepthStencilView_iface;
938 return S_OK;
941 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *iface,
942 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
943 const void *shader_byte_code, SIZE_T shader_byte_code_length,
944 ID3D10InputLayout **input_layout)
946 struct d3d10_device *This = impl_from_ID3D10Device(iface);
947 struct d3d10_input_layout *object;
948 HRESULT hr;
950 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
951 "\tshader_byte_code_length %lu, input_layout %p\n",
952 iface, element_descs, element_count, shader_byte_code,
953 shader_byte_code_length, input_layout);
955 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
956 if (!object)
958 ERR("Failed to allocate D3D10 input layout object memory\n");
959 return E_OUTOFMEMORY;
962 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
963 shader_byte_code, shader_byte_code_length);
964 if (FAILED(hr))
966 WARN("Failed to initialize input layout, hr %#x.\n", hr);
967 HeapFree(GetProcessHeap(), 0, object);
968 return hr;
971 TRACE("Created input layout %p.\n", object);
972 *input_layout = &object->ID3D10InputLayout_iface;
974 return S_OK;
977 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
978 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
980 struct d3d10_device *This = impl_from_ID3D10Device(iface);
981 struct d3d10_vertex_shader *object;
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 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
995 if (FAILED(hr))
997 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
998 HeapFree(GetProcessHeap(), 0, object);
999 return hr;
1002 TRACE("Created vertex shader %p.\n", object);
1003 *shader = &object->ID3D10VertexShader_iface;
1005 return S_OK;
1008 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
1009 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1011 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1012 struct d3d10_geometry_shader *object;
1013 HRESULT hr;
1015 FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
1016 iface, byte_code, byte_code_length, shader);
1018 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1019 if (!object)
1021 ERR("Failed to allocate D3D10 geometry shader object memory\n");
1022 return E_OUTOFMEMORY;
1025 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1026 if (FAILED(hr))
1028 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1029 HeapFree(GetProcessHeap(), 0, object);
1030 return hr;
1033 TRACE("Created geometry shader %p.\n", object);
1034 *shader = &object->ID3D10GeometryShader_iface;
1036 return S_OK;
1039 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device *iface,
1040 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1041 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1043 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1044 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1045 iface, byte_code, byte_code_length, output_stream_decls,
1046 output_stream_decl_count, output_stream_stride, shader);
1048 return E_NOTIMPL;
1051 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
1052 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1054 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1055 struct d3d10_pixel_shader *object;
1056 HRESULT hr;
1058 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1059 iface, byte_code, byte_code_length, shader);
1061 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1062 if (!object)
1064 ERR("Failed to allocate D3D10 pixel shader object memory\n");
1065 return E_OUTOFMEMORY;
1068 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1069 if (FAILED(hr))
1071 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1072 HeapFree(GetProcessHeap(), 0, object);
1073 return hr;
1076 TRACE("Created pixel shader %p.\n", object);
1077 *shader = &object->ID3D10PixelShader_iface;
1079 return S_OK;
1082 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
1083 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1085 struct d3d10_blend_state *object;
1086 HRESULT hr;
1088 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1090 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1091 if (!object)
1093 ERR("Failed to allocate D3D10 blend state object memory.\n");
1094 return E_OUTOFMEMORY;
1097 hr = d3d10_blend_state_init(object);
1098 if (FAILED(hr))
1100 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1101 HeapFree(GetProcessHeap(), 0, object);
1102 return hr;
1105 TRACE("Created blend state %p.\n", object);
1106 *blend_state = &object->ID3D10BlendState_iface;
1108 return S_OK;
1111 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1112 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1114 struct d3d10_depthstencil_state *object;
1115 HRESULT hr;
1117 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1119 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1120 if (!object)
1122 ERR("Failed to allocate D3D10 depthstencil state object memory.\n");
1123 return E_OUTOFMEMORY;
1126 hr = d3d10_depthstencil_state_init(object);
1127 if (FAILED(hr))
1129 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1130 HeapFree(GetProcessHeap(), 0, object);
1131 return hr;
1134 TRACE("Created depthstencil state %p.\n", object);
1135 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1137 return S_OK;
1140 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1141 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1143 struct d3d10_rasterizer_state *object;
1144 HRESULT hr;
1146 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1148 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1149 if (!object)
1151 ERR("Failed to allocate D3D10 rasterizer state object memory.\n");
1152 return E_OUTOFMEMORY;
1155 hr = d3d10_rasterizer_state_init(object);
1156 if (FAILED(hr))
1158 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1159 HeapFree(GetProcessHeap(), 0, object);
1160 return hr;
1163 TRACE("Created rasterizer state %p.\n", object);
1164 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1166 return S_OK;
1169 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1170 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1172 struct d3d10_sampler_state *object;
1173 HRESULT hr;
1175 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1177 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1178 if (!object)
1180 ERR("Failed to allocate D3D10 sampler state object memory.\n");
1181 return E_OUTOFMEMORY;
1184 hr = d3d10_sampler_state_init(object);
1185 if (FAILED(hr))
1187 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1188 HeapFree(GetProcessHeap(), 0, object);
1189 return hr;
1192 TRACE("Created sampler state %p.\n", object);
1193 *sampler_state = &object->ID3D10SamplerState_iface;
1195 return S_OK;
1198 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1199 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1201 struct d3d10_query *object;
1202 HRESULT hr;
1204 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1206 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1207 if (!object)
1209 ERR("Failed to allocate D3D10 query object memory.\n");
1210 return E_OUTOFMEMORY;
1213 hr = d3d10_query_init(object);
1214 if (FAILED(hr))
1216 WARN("Failed to initialize query, hr %#x.\n", hr);
1217 HeapFree(GetProcessHeap(), 0, object);
1218 return hr;
1221 TRACE("Created query %p.\n", object);
1222 *query = &object->ID3D10Query_iface;
1224 return S_OK;
1227 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1228 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1230 FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1232 return E_NOTIMPL;
1235 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1236 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1238 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1240 return E_NOTIMPL;
1243 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1244 DXGI_FORMAT format, UINT *format_support)
1246 FIXME("iface %p, format %s, format_support %p stub!\n",
1247 iface, debug_dxgi_format(format), format_support);
1249 return E_NOTIMPL;
1252 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1253 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1255 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1256 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1258 return E_NOTIMPL;
1261 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1263 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1266 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1267 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1268 UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1270 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1271 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1272 iface, desc, type, active_counters, name, name_length,
1273 units, units_length, description, description_length);
1275 return E_NOTIMPL;
1278 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1280 FIXME("iface %p stub!\n", iface);
1282 return 0;
1285 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1286 HANDLE resource_handle, REFIID guid, void **resource)
1288 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1289 iface, resource_handle, debugstr_guid(guid), resource);
1291 return E_NOTIMPL;
1294 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1296 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1299 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1301 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1304 static const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1306 /* IUnknown methods */
1307 d3d10_device_QueryInterface,
1308 d3d10_device_AddRef,
1309 d3d10_device_Release,
1310 /* ID3D10Device methods */
1311 d3d10_device_VSSetConstantBuffers,
1312 d3d10_device_PSSetShaderResources,
1313 d3d10_device_PSSetShader,
1314 d3d10_device_PSSetSamplers,
1315 d3d10_device_VSSetShader,
1316 d3d10_device_DrawIndexed,
1317 d3d10_device_Draw,
1318 d3d10_device_PSSetConstantBuffers,
1319 d3d10_device_IASetInputLayout,
1320 d3d10_device_IASetVertexBuffers,
1321 d3d10_device_IASetIndexBuffer,
1322 d3d10_device_DrawIndexedInstanced,
1323 d3d10_device_DrawInstanced,
1324 d3d10_device_GSSetConstantBuffers,
1325 d3d10_device_GSSetShader,
1326 d3d10_device_IASetPrimitiveTopology,
1327 d3d10_device_VSSetShaderResources,
1328 d3d10_device_VSSetSamplers,
1329 d3d10_device_SetPredication,
1330 d3d10_device_GSSetShaderResources,
1331 d3d10_device_GSSetSamplers,
1332 d3d10_device_OMSetRenderTargets,
1333 d3d10_device_OMSetBlendState,
1334 d3d10_device_OMSetDepthStencilState,
1335 d3d10_device_SOSetTargets,
1336 d3d10_device_DrawAuto,
1337 d3d10_device_RSSetState,
1338 d3d10_device_RSSetViewports,
1339 d3d10_device_RSSetScissorRects,
1340 d3d10_device_CopySubresourceRegion,
1341 d3d10_device_CopyResource,
1342 d3d10_device_UpdateSubresource,
1343 d3d10_device_ClearRenderTargetView,
1344 d3d10_device_ClearDepthStencilView,
1345 d3d10_device_GenerateMips,
1346 d3d10_device_ResolveSubresource,
1347 d3d10_device_VSGetConstantBuffers,
1348 d3d10_device_PSGetShaderResources,
1349 d3d10_device_PSGetShader,
1350 d3d10_device_PSGetSamplers,
1351 d3d10_device_VSGetShader,
1352 d3d10_device_PSGetConstantBuffers,
1353 d3d10_device_IAGetInputLayout,
1354 d3d10_device_IAGetVertexBuffers,
1355 d3d10_device_IAGetIndexBuffer,
1356 d3d10_device_GSGetConstantBuffers,
1357 d3d10_device_GSGetShader,
1358 d3d10_device_IAGetPrimitiveTopology,
1359 d3d10_device_VSGetShaderResources,
1360 d3d10_device_VSGetSamplers,
1361 d3d10_device_GetPredication,
1362 d3d10_device_GSGetShaderResources,
1363 d3d10_device_GSGetSamplers,
1364 d3d10_device_OMGetRenderTargets,
1365 d3d10_device_OMGetBlendState,
1366 d3d10_device_OMGetDepthStencilState,
1367 d3d10_device_SOGetTargets,
1368 d3d10_device_RSGetState,
1369 d3d10_device_RSGetViewports,
1370 d3d10_device_RSGetScissorRects,
1371 d3d10_device_GetDeviceRemovedReason,
1372 d3d10_device_SetExceptionMode,
1373 d3d10_device_GetExceptionMode,
1374 d3d10_device_GetPrivateData,
1375 d3d10_device_SetPrivateData,
1376 d3d10_device_SetPrivateDataInterface,
1377 d3d10_device_ClearState,
1378 d3d10_device_Flush,
1379 d3d10_device_CreateBuffer,
1380 d3d10_device_CreateTexture1D,
1381 d3d10_device_CreateTexture2D,
1382 d3d10_device_CreateTexture3D,
1383 d3d10_device_CreateShaderResourceView,
1384 d3d10_device_CreateRenderTargetView,
1385 d3d10_device_CreateDepthStencilView,
1386 d3d10_device_CreateInputLayout,
1387 d3d10_device_CreateVertexShader,
1388 d3d10_device_CreateGeometryShader,
1389 d3d10_device_CreateGeometryShaderWithStreamOutput,
1390 d3d10_device_CreatePixelShader,
1391 d3d10_device_CreateBlendState,
1392 d3d10_device_CreateDepthStencilState,
1393 d3d10_device_CreateRasterizerState,
1394 d3d10_device_CreateSamplerState,
1395 d3d10_device_CreateQuery,
1396 d3d10_device_CreatePredicate,
1397 d3d10_device_CreateCounter,
1398 d3d10_device_CheckFormatSupport,
1399 d3d10_device_CheckMultisampleQualityLevels,
1400 d3d10_device_CheckCounterInfo,
1401 d3d10_device_CheckCounter,
1402 d3d10_device_GetCreationFlags,
1403 d3d10_device_OpenSharedResource,
1404 d3d10_device_SetTextFilterSize,
1405 d3d10_device_GetTextFilterSize,
1408 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1410 /* IUnknown methods */
1411 d3d10_device_inner_QueryInterface,
1412 d3d10_device_inner_AddRef,
1413 d3d10_device_inner_Release,
1416 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1418 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1420 d3d10_subresource_destroyed,
1423 /* IWineDXGIDeviceParent IUnknown methods */
1425 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1427 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1430 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1431 REFIID riid, void **ppv)
1433 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1434 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1437 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1439 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1440 return IUnknown_AddRef(device->outer_unk);
1443 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1445 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1446 return IUnknown_Release(device->outer_unk);
1449 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1450 IWineDXGIDeviceParent *iface)
1452 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1453 return &device->device_parent;
1456 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1458 /* IUnknown methods */
1459 dxgi_device_parent_QueryInterface,
1460 dxgi_device_parent_AddRef,
1461 dxgi_device_parent_Release,
1462 /* IWineDXGIDeviceParent methods */
1463 dxgi_device_parent_get_wined3d_device_parent,
1466 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1468 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1471 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1472 struct wined3d_device *wined3d_device)
1474 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1476 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1478 wined3d_device_incref(wined3d_device);
1479 device->wined3d_device = wined3d_device;
1482 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1484 TRACE("device_parent %p.\n", device_parent);
1487 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
1488 void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
1489 enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
1491 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1493 TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
1494 "\tpool %#x, sub_resource_idx %u, surface %p.\n",
1495 device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
1497 return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
1498 WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent,
1499 &d3d10_null_wined3d_parent_ops, surface);
1502 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1503 void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
1504 enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
1506 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1507 struct wined3d_resource *sub_resource;
1508 struct d3d10_texture2d *texture;
1509 D3D10_TEXTURE2D_DESC desc;
1510 HRESULT hr;
1512 FIXME("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
1513 "\tmultisample_type %#x, multisample_quality %u, surface %p partial stub!\n",
1514 device_parent, container_parent, width, height, format_id, usage,
1515 multisample_type, multisample_quality, surface);
1517 FIXME("Implement DXGI<->wined3d usage conversion\n");
1519 desc.Width = width;
1520 desc.Height = height;
1521 desc.MipLevels = 1;
1522 desc.ArraySize = 1;
1523 desc.Format = dxgi_format_from_wined3dformat(format_id);
1524 desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1525 desc.SampleDesc.Quality = multisample_quality;
1526 desc.Usage = D3D10_USAGE_DEFAULT;
1527 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1528 desc.CPUAccessFlags = 0;
1529 desc.MiscFlags = 0;
1531 hr = d3d10_device_CreateTexture2D(&device->ID3D10Device_iface, &desc, NULL,
1532 (ID3D10Texture2D **)&texture);
1533 if (FAILED(hr))
1535 ERR("CreateTexture2D failed, returning %#x\n", hr);
1536 return hr;
1539 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1540 *surface = wined3d_surface_from_resource(sub_resource);
1541 wined3d_surface_incref(*surface);
1542 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1544 return S_OK;
1547 static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
1548 void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
1549 enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
1551 HRESULT hr;
1553 TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
1554 "format %#x, pool %#x, usage %#x, volume %p.\n",
1555 device_parent, container_parent, width, height, depth,
1556 format, pool, usage, volume);
1558 hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
1559 width, height, depth, usage, format, pool, NULL, &d3d10_subresource_parent_ops, volume);
1560 if (FAILED(hr))
1562 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
1563 return hr;
1566 return S_OK;
1569 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
1570 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
1572 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1573 IWineDXGIDevice *wine_device;
1574 HRESULT hr;
1576 TRACE("device_parent %p, desc %p, swapchain %p\n", device_parent, desc, swapchain);
1578 hr = d3d10_device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice,
1579 (void **)&wine_device);
1580 if (FAILED(hr))
1582 ERR("Device should implement IWineDXGIDevice\n");
1583 return E_FAIL;
1586 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
1587 IWineDXGIDevice_Release(wine_device);
1588 if (FAILED(hr))
1590 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1591 return hr;
1594 return S_OK;
1597 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
1599 device_parent_wined3d_device_created,
1600 device_parent_mode_changed,
1601 device_parent_create_swapchain_surface,
1602 device_parent_create_texture_surface,
1603 device_parent_create_volume,
1604 device_parent_create_swapchain,
1607 void d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
1609 device->ID3D10Device_iface.lpVtbl = &d3d10_device_vtbl;
1610 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
1611 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
1612 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
1613 device->refcount = 1;
1614 /* COM aggregation always takes place */
1615 device->outer_unk = outer_unknown;