wbemprox: Implement Win32_CDROMDrive.MediaType.
[wine/wine-gecko.git] / dlls / d3d10core / device.c
blob1aa5e8b835e2da904765871cc347210c95592c54
1 /*
2 * Copyright 2008-2012 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, void **out)
43 struct d3d10_device *device = impl_from_IUnknown(iface);
45 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
47 if (IsEqualGUID(riid, &IID_ID3D10Device1)
48 || IsEqualGUID(riid, &IID_ID3D10Device)
49 || IsEqualGUID(riid, &IID_IUnknown))
51 *out = &device->ID3D10Device1_iface;
53 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
55 *out = &device->ID3D10Multithread_iface;
57 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
59 *out = &device->IWineDXGIDeviceParent_iface;
61 else
63 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
64 *out = NULL;
65 return E_NOINTERFACE;
68 IUnknown_AddRef((IUnknown *)*out);
69 return S_OK;
72 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
74 struct d3d10_device *This = impl_from_IUnknown(iface);
75 ULONG refcount = InterlockedIncrement(&This->refcount);
77 TRACE("%p increasing refcount to %u\n", This, refcount);
79 return refcount;
82 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
84 struct d3d10_device *device = impl_from_IUnknown(iface);
85 ULONG refcount = InterlockedDecrement(&device->refcount);
87 TRACE("%p decreasing refcount to %u.\n", device, refcount);
89 if (!refcount)
91 if (device->wined3d_device)
92 wined3d_device_decref(device->wined3d_device);
93 wine_rb_destroy(&device->sampler_states, NULL, NULL);
94 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
95 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
96 wine_rb_destroy(&device->blend_states, NULL, NULL);
99 return refcount;
102 /* IUnknown methods */
104 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
105 void **ppv)
107 struct d3d10_device *This = impl_from_ID3D10Device(iface);
108 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
111 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
113 struct d3d10_device *This = impl_from_ID3D10Device(iface);
114 return IUnknown_AddRef(This->outer_unk);
117 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
119 struct d3d10_device *This = impl_from_ID3D10Device(iface);
120 return IUnknown_Release(This->outer_unk);
123 /* ID3D10Device methods */
125 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
126 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
128 struct d3d10_device *device = impl_from_ID3D10Device(iface);
129 unsigned int i;
131 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
132 iface, start_slot, buffer_count, buffers);
134 for (i = 0; i < buffer_count; ++i)
136 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
138 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
139 buffer ? buffer->wined3d_buffer : NULL);
143 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
144 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
146 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
147 iface, start_slot, view_count, views);
150 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
151 ID3D10PixelShader *shader)
153 struct d3d10_device *This = impl_from_ID3D10Device(iface);
154 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
156 TRACE("iface %p, shader %p\n", iface, shader);
158 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
161 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
162 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
164 struct d3d10_device *device = impl_from_ID3D10Device(iface);
165 unsigned int i;
167 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
168 iface, start_slot, sampler_count, samplers);
170 for (i = 0; i < sampler_count; ++i)
172 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
174 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
175 sampler ? sampler->wined3d_sampler : NULL);
179 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
180 ID3D10VertexShader *shader)
182 struct d3d10_device *This = impl_from_ID3D10Device(iface);
183 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
185 TRACE("iface %p, shader %p\n", iface, shader);
187 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
190 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
191 UINT start_index_location, INT base_vertex_location)
193 struct d3d10_device *This = impl_from_ID3D10Device(iface);
195 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
196 iface, index_count, start_index_location, base_vertex_location);
198 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
199 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
202 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
203 UINT start_vertex_location)
205 struct d3d10_device *This = impl_from_ID3D10Device(iface);
207 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
208 iface, vertex_count, start_vertex_location);
210 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
213 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
214 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
216 struct d3d10_device *device = impl_from_ID3D10Device(iface);
217 unsigned int i;
219 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
220 iface, start_slot, buffer_count, buffers);
222 for (i = 0; i < buffer_count; ++i)
224 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
226 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
227 buffer ? buffer->wined3d_buffer : NULL);
231 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
232 ID3D10InputLayout *input_layout)
234 struct d3d10_device *This = impl_from_ID3D10Device(iface);
235 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
237 TRACE("iface %p, input_layout %p\n", iface, input_layout);
239 wined3d_device_set_vertex_declaration(This->wined3d_device,
240 layout ? layout->wined3d_decl : NULL);
243 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
244 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
246 struct d3d10_device *This = impl_from_ID3D10Device(iface);
247 unsigned int i;
249 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
250 iface, start_slot, buffer_count, buffers, strides, offsets);
252 for (i = 0; i < buffer_count; ++i)
254 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
256 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
257 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
261 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
262 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
264 struct d3d10_device *This = impl_from_ID3D10Device(iface);
265 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
267 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
268 iface, buffer, debug_dxgi_format(format), offset);
270 wined3d_device_set_index_buffer(This->wined3d_device,
271 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
272 wined3dformat_from_dxgi_format(format));
273 if (offset) FIXME("offset %u not supported.\n", offset);
276 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
277 UINT instance_index_count, UINT instance_count, UINT start_index_location,
278 INT base_vertex_location, UINT start_instance_location)
280 struct d3d10_device *device = impl_from_ID3D10Device(iface);
282 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
283 "\tbase_vertex_location %d, start_instance_location %u.\n",
284 iface, instance_index_count, instance_count, start_index_location,
285 base_vertex_location, start_instance_location);
287 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
288 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
289 instance_index_count, start_instance_location, instance_count);
292 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
293 UINT instance_vertex_count, UINT instance_count,
294 UINT start_vertex_location, UINT start_instance_location)
296 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
297 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
298 start_vertex_location, start_instance_location);
301 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
302 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
304 struct d3d10_device *device = impl_from_ID3D10Device(iface);
305 unsigned int i;
307 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
308 iface, start_slot, buffer_count, buffers);
310 for (i = 0; i < buffer_count; ++i)
312 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
314 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
315 buffer ? buffer->wined3d_buffer : NULL);
319 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
321 struct d3d10_device *device = impl_from_ID3D10Device(iface);
322 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
324 TRACE("iface %p, shader %p.\n", iface, shader);
326 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
329 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
330 D3D10_PRIMITIVE_TOPOLOGY topology)
332 struct d3d10_device *This = impl_from_ID3D10Device(iface);
334 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
336 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
339 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
340 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
342 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
343 iface, start_slot, view_count, views);
346 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
347 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
349 struct d3d10_device *device = impl_from_ID3D10Device(iface);
350 unsigned int i;
352 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
353 iface, start_slot, sampler_count, samplers);
355 for (i = 0; i < sampler_count; ++i)
357 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
359 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
360 sampler ? sampler->wined3d_sampler : NULL);
364 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
366 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
369 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
370 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
372 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
373 iface, start_slot, view_count, views);
376 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
377 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
379 struct d3d10_device *device = impl_from_ID3D10Device(iface);
380 unsigned int i;
382 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
383 iface, start_slot, sampler_count, samplers);
385 for (i = 0; i < sampler_count; ++i)
387 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
389 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
390 sampler ? sampler->wined3d_sampler : NULL);
394 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
395 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
396 ID3D10DepthStencilView *depth_stencil_view)
398 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
399 iface, render_target_view_count, render_target_views, depth_stencil_view);
402 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
403 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
405 struct d3d10_device *device = impl_from_ID3D10Device(iface);
407 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
408 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
410 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
411 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
412 device->sample_mask = sample_mask;
415 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
416 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
418 struct d3d10_device *device = impl_from_ID3D10Device(iface);
420 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
421 iface, depth_stencil_state, stencil_ref);
423 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
424 device->stencil_ref = stencil_ref;
427 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
428 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
430 struct d3d10_device *device = impl_from_ID3D10Device(iface);
431 unsigned int count, i;
433 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
435 count = min(target_count, 4);
436 for (i = 0; i < count; ++i)
438 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
440 wined3d_device_set_stream_output(device->wined3d_device, i,
441 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
444 for (i = count; i < 4; ++i)
446 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
450 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
452 FIXME("iface %p stub!\n", iface);
455 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
457 struct d3d10_device *device = impl_from_ID3D10Device(iface);
459 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
461 device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
464 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
465 UINT viewport_count, const D3D10_VIEWPORT *viewports)
467 struct d3d10_device *device = impl_from_ID3D10Device(iface);
468 struct wined3d_viewport wined3d_vp;
470 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
472 if (viewport_count > 1)
473 FIXME("Multiple viewports not implemented.\n");
475 if (!viewport_count)
476 return;
478 wined3d_vp.x = viewports[0].TopLeftX;
479 wined3d_vp.y = viewports[0].TopLeftY;
480 wined3d_vp.width = viewports[0].Width;
481 wined3d_vp.height = viewports[0].Height;
482 wined3d_vp.min_z = viewports[0].MinDepth;
483 wined3d_vp.max_z = viewports[0].MaxDepth;
485 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
488 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
489 UINT rect_count, const D3D10_RECT *rects)
491 struct d3d10_device *device = impl_from_ID3D10Device(iface);
493 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
495 if (rect_count > 1)
496 FIXME("Multiple scissor rects not implemented.\n");
498 if (!rect_count)
499 return;
501 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
504 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
505 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
506 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
508 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
509 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
510 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
511 src_resource, src_subresource_idx, src_box);
514 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
515 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
517 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
520 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
521 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
522 const void *data, UINT row_pitch, UINT depth_pitch)
524 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
525 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
528 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
529 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
531 struct d3d10_device *This = impl_from_ID3D10Device(iface);
532 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
533 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
535 TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
536 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
538 wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
541 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
542 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
544 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
545 iface, depth_stencil_view, flags, depth, stencil);
548 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
549 ID3D10ShaderResourceView *shader_resource_view)
551 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
554 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
555 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
556 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
558 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
559 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
560 iface, dst_resource, dst_subresource_idx,
561 src_resource, src_subresource_idx, debug_dxgi_format(format));
564 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
565 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
567 struct d3d10_device *device = impl_from_ID3D10Device(iface);
568 unsigned int i;
570 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
571 iface, start_slot, buffer_count, buffers);
573 for (i = 0; i < buffer_count; ++i)
575 struct wined3d_buffer *wined3d_buffer;
576 struct d3d10_buffer *buffer_impl;
578 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
580 buffers[i] = NULL;
581 continue;
584 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
585 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
586 ID3D10Buffer_AddRef(buffers[i]);
590 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
591 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
593 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
594 iface, start_slot, view_count, views);
597 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
599 struct d3d10_device *device = impl_from_ID3D10Device(iface);
600 struct d3d10_pixel_shader *shader_impl;
601 struct wined3d_shader *wined3d_shader;
603 TRACE("iface %p, shader %p.\n", iface, shader);
605 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
607 *shader = NULL;
608 return;
611 shader_impl = wined3d_shader_get_parent(wined3d_shader);
612 *shader = &shader_impl->ID3D10PixelShader_iface;
613 ID3D10PixelShader_AddRef(*shader);
616 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
617 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
619 struct d3d10_device *device = impl_from_ID3D10Device(iface);
620 unsigned int i;
622 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
623 iface, start_slot, sampler_count, samplers);
625 for (i = 0; i < sampler_count; ++i)
627 struct d3d10_sampler_state *sampler_impl;
628 struct wined3d_sampler *wined3d_sampler;
630 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
632 samplers[i] = NULL;
633 continue;
636 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
637 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
638 ID3D10SamplerState_AddRef(samplers[i]);
642 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
644 struct d3d10_device *device = impl_from_ID3D10Device(iface);
645 struct d3d10_vertex_shader *shader_impl;
646 struct wined3d_shader *wined3d_shader;
648 TRACE("iface %p, shader %p.\n", iface, shader);
650 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
652 *shader = NULL;
653 return;
656 shader_impl = wined3d_shader_get_parent(wined3d_shader);
657 *shader = &shader_impl->ID3D10VertexShader_iface;
658 ID3D10VertexShader_AddRef(*shader);
661 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
662 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
664 struct d3d10_device *device = impl_from_ID3D10Device(iface);
665 unsigned int i;
667 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
668 iface, start_slot, buffer_count, buffers);
670 for (i = 0; i < buffer_count; ++i)
672 struct wined3d_buffer *wined3d_buffer;
673 struct d3d10_buffer *buffer_impl;
675 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
677 buffers[i] = NULL;
678 continue;
681 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
682 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
683 ID3D10Buffer_AddRef(buffers[i]);
687 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
689 struct d3d10_device *device = impl_from_ID3D10Device(iface);
690 struct wined3d_vertex_declaration *wined3d_declaration;
691 struct d3d10_input_layout *input_layout_impl;
693 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
695 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
697 *input_layout = NULL;
698 return;
701 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
702 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
703 ID3D10InputLayout_AddRef(*input_layout);
706 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
707 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
709 struct d3d10_device *device = impl_from_ID3D10Device(iface);
710 unsigned int i;
712 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
713 iface, start_slot, buffer_count, buffers, strides, offsets);
715 for (i = 0; i < buffer_count; ++i)
717 struct wined3d_buffer *wined3d_buffer;
718 struct d3d10_buffer *buffer_impl;
720 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
721 &wined3d_buffer, &offsets[i], &strides[i])))
722 ERR("Failed to get vertex buffer.\n");
724 if (!wined3d_buffer)
726 buffers[i] = NULL;
727 continue;
730 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
731 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
732 ID3D10Buffer_AddRef(buffers[i]);
736 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
737 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
739 struct d3d10_device *device = impl_from_ID3D10Device(iface);
740 enum wined3d_format_id wined3d_format;
741 struct wined3d_buffer *wined3d_buffer;
742 struct d3d10_buffer *buffer_impl;
744 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
746 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
747 *format = dxgi_format_from_wined3dformat(wined3d_format);
748 *offset = 0; /* FIXME */
749 if (!wined3d_buffer)
751 *buffer = NULL;
752 return;
755 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
756 *buffer = &buffer_impl->ID3D10Buffer_iface;
757 ID3D10Buffer_AddRef(*buffer);
760 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
761 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
763 struct d3d10_device *device = impl_from_ID3D10Device(iface);
764 unsigned int i;
766 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
767 iface, start_slot, buffer_count, buffers);
769 for (i = 0; i < buffer_count; ++i)
771 struct wined3d_buffer *wined3d_buffer;
772 struct d3d10_buffer *buffer_impl;
774 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
776 buffers[i] = NULL;
777 continue;
780 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
781 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
782 ID3D10Buffer_AddRef(buffers[i]);
786 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
788 struct d3d10_device *device = impl_from_ID3D10Device(iface);
789 struct d3d10_geometry_shader *shader_impl;
790 struct wined3d_shader *wined3d_shader;
792 TRACE("iface %p, shader %p.\n", iface, shader);
794 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
796 *shader = NULL;
797 return;
800 shader_impl = wined3d_shader_get_parent(wined3d_shader);
801 *shader = &shader_impl->ID3D10GeometryShader_iface;
802 ID3D10GeometryShader_AddRef(*shader);
805 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
806 D3D10_PRIMITIVE_TOPOLOGY *topology)
808 struct d3d10_device *This = impl_from_ID3D10Device(iface);
810 TRACE("iface %p, topology %p\n", iface, topology);
812 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
815 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
816 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
818 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
819 iface, start_slot, view_count, views);
822 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
823 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
825 struct d3d10_device *device = impl_from_ID3D10Device(iface);
826 unsigned int i;
828 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
829 iface, start_slot, sampler_count, samplers);
831 for (i = 0; i < sampler_count; ++i)
833 struct d3d10_sampler_state *sampler_impl;
834 struct wined3d_sampler *wined3d_sampler;
836 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
838 samplers[i] = NULL;
839 continue;
842 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
843 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
844 ID3D10SamplerState_AddRef(samplers[i]);
848 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
849 ID3D10Predicate **predicate, BOOL *value)
851 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
854 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
855 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
857 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
858 iface, start_slot, view_count, views);
861 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
862 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
864 struct d3d10_device *device = impl_from_ID3D10Device(iface);
865 unsigned int i;
867 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
868 iface, start_slot, sampler_count, samplers);
870 for (i = 0; i < sampler_count; ++i)
872 struct d3d10_sampler_state *sampler_impl;
873 struct wined3d_sampler *wined3d_sampler;
875 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
877 samplers[i] = NULL;
878 continue;
881 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
882 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
883 ID3D10SamplerState_AddRef(samplers[i]);
887 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
888 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
890 FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
891 iface, view_count, render_target_views, depth_stencil_view);
894 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
895 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
897 struct d3d10_device *device = impl_from_ID3D10Device(iface);
899 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
900 iface, blend_state, blend_factor, sample_mask);
902 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
903 ID3D10BlendState_AddRef(*blend_state);
904 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
905 *sample_mask = device->sample_mask;
908 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
909 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
911 struct d3d10_device *device = impl_from_ID3D10Device(iface);
913 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
914 iface, depth_stencil_state, stencil_ref);
916 if ((*depth_stencil_state = device->depth_stencil_state
917 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
918 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
919 *stencil_ref = device->stencil_ref;
922 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
923 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
925 struct d3d10_device *device = impl_from_ID3D10Device(iface);
926 unsigned int i;
928 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
929 iface, buffer_count, buffers, offsets);
931 for (i = 0; i < buffer_count; ++i)
933 struct wined3d_buffer *wined3d_buffer;
934 struct d3d10_buffer *buffer_impl;
936 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
938 buffers[i] = NULL;
939 continue;
942 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
943 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
944 ID3D10Buffer_AddRef(buffers[i]);
948 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
950 struct d3d10_device *device = impl_from_ID3D10Device(iface);
952 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
954 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
955 ID3D10RasterizerState_AddRef(*rasterizer_state);
958 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
959 UINT *viewport_count, D3D10_VIEWPORT *viewports)
961 struct d3d10_device *device = impl_from_ID3D10Device(iface);
962 struct wined3d_viewport wined3d_vp;
964 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
966 if (!viewports)
968 *viewport_count = 1;
969 return;
972 if (!*viewport_count)
973 return;
975 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
977 viewports[0].TopLeftX = wined3d_vp.x;
978 viewports[0].TopLeftY = wined3d_vp.y;
979 viewports[0].Width = wined3d_vp.width;
980 viewports[0].Height = wined3d_vp.height;
981 viewports[0].MinDepth = wined3d_vp.min_z;
982 viewports[0].MaxDepth = wined3d_vp.max_z;
984 if (*viewport_count > 1)
985 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
988 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
990 struct d3d10_device *device = impl_from_ID3D10Device(iface);
992 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
994 if (!rects)
996 *rect_count = 1;
997 return;
1000 if (!*rect_count)
1001 return;
1003 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1004 if (*rect_count > 1)
1005 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1008 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1010 FIXME("iface %p stub!\n", iface);
1012 return E_NOTIMPL;
1015 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1017 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1019 return E_NOTIMPL;
1022 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1024 FIXME("iface %p stub!\n", iface);
1026 return 0;
1029 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1030 REFGUID guid, UINT *data_size, void *data)
1032 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1033 iface, debugstr_guid(guid), data_size, data);
1035 return E_NOTIMPL;
1038 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1039 REFGUID guid, UINT data_size, const void *data)
1041 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1042 iface, debugstr_guid(guid), data_size, data);
1044 return E_NOTIMPL;
1047 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1048 REFGUID guid, const IUnknown *data)
1050 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1052 return E_NOTIMPL;
1055 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1057 FIXME("iface %p stub!\n", iface);
1060 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1062 FIXME("iface %p stub!\n", iface);
1065 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1066 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1068 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1069 struct d3d10_buffer *object;
1070 HRESULT hr;
1072 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1074 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1075 if (!object)
1076 return E_OUTOFMEMORY;
1078 hr = d3d10_buffer_init(object, This, desc, data);
1079 if (FAILED(hr))
1081 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1082 HeapFree(GetProcessHeap(), 0, object);
1083 return hr;
1086 *buffer = &object->ID3D10Buffer_iface;
1088 TRACE("Created ID3D10Buffer %p\n", object);
1090 return S_OK;
1093 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1094 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1096 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1098 return E_NOTIMPL;
1101 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1102 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1103 ID3D10Texture2D **texture)
1105 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1106 struct d3d10_texture2d *object;
1107 HRESULT hr;
1109 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1111 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1112 if (!object)
1113 return E_OUTOFMEMORY;
1115 hr = d3d10_texture2d_init(object, This, desc);
1116 if (FAILED(hr))
1118 WARN("Failed to initialize texture, hr %#x.\n", hr);
1119 HeapFree(GetProcessHeap(), 0, object);
1120 return hr;
1123 *texture = &object->ID3D10Texture2D_iface;
1125 TRACE("Created ID3D10Texture2D %p\n", object);
1127 return S_OK;
1130 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1131 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1132 ID3D10Texture3D **texture)
1134 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1135 struct d3d10_texture3d *object;
1136 HRESULT hr;
1138 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1140 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1141 if (!object)
1142 return E_OUTOFMEMORY;
1144 hr = d3d10_texture3d_init(object, device, desc);
1145 if (FAILED(hr))
1147 WARN("Failed to initialize texture, hr %#x.\n", hr);
1148 HeapFree(GetProcessHeap(), 0, object);
1149 return hr;
1152 TRACE("Created 3D texture %p.\n", object);
1153 *texture = &object->ID3D10Texture3D_iface;
1155 return S_OK;
1158 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1159 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1161 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1162 struct d3d10_shader_resource_view *object;
1163 HRESULT hr;
1165 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1167 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1168 return E_OUTOFMEMORY;
1170 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1172 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1173 HeapFree(GetProcessHeap(), 0, object);
1174 return hr;
1177 TRACE("Created shader resource view %p.\n", object);
1178 *view = &object->ID3D10ShaderResourceView_iface;
1180 return S_OK;
1183 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1184 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1186 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1187 struct d3d10_rendertarget_view *object;
1188 HRESULT hr;
1190 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1192 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1193 return E_OUTOFMEMORY;
1195 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1197 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1198 HeapFree(GetProcessHeap(), 0, object);
1199 return hr;
1202 TRACE("Created rendertarget view %p.\n", object);
1203 *view = &object->ID3D10RenderTargetView_iface;
1205 return S_OK;
1208 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1209 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1211 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1212 struct d3d10_depthstencil_view *object;
1213 HRESULT hr;
1215 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1217 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1218 return E_OUTOFMEMORY;
1220 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1222 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1223 HeapFree(GetProcessHeap(), 0, object);
1224 return hr;
1227 TRACE("Created depthstencil view %p.\n", object);
1228 *view = &object->ID3D10DepthStencilView_iface;
1230 return S_OK;
1233 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1234 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1235 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1236 ID3D10InputLayout **input_layout)
1238 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1239 struct d3d10_input_layout *object;
1240 HRESULT hr;
1242 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1243 "\tshader_byte_code_length %lu, input_layout %p\n",
1244 iface, element_descs, element_count, shader_byte_code,
1245 shader_byte_code_length, input_layout);
1247 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1248 if (!object)
1249 return E_OUTOFMEMORY;
1251 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1252 shader_byte_code, shader_byte_code_length);
1253 if (FAILED(hr))
1255 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1256 HeapFree(GetProcessHeap(), 0, object);
1257 return hr;
1260 TRACE("Created input layout %p.\n", object);
1261 *input_layout = &object->ID3D10InputLayout_iface;
1263 return S_OK;
1266 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1267 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1269 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1270 struct d3d10_vertex_shader *object;
1271 HRESULT hr;
1273 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1274 iface, byte_code, byte_code_length, shader);
1276 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1277 if (!object)
1278 return E_OUTOFMEMORY;
1280 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1281 if (FAILED(hr))
1283 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1284 HeapFree(GetProcessHeap(), 0, object);
1285 return hr;
1288 TRACE("Created vertex shader %p.\n", object);
1289 *shader = &object->ID3D10VertexShader_iface;
1291 return S_OK;
1294 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1295 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1297 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1298 struct d3d10_geometry_shader *object;
1299 HRESULT hr;
1301 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1302 iface, byte_code, byte_code_length, shader);
1304 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1305 if (!object)
1306 return E_OUTOFMEMORY;
1308 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1309 if (FAILED(hr))
1311 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1312 HeapFree(GetProcessHeap(), 0, object);
1313 return hr;
1316 TRACE("Created geometry shader %p.\n", object);
1317 *shader = &object->ID3D10GeometryShader_iface;
1319 return S_OK;
1322 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1323 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1324 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1326 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1327 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1328 iface, byte_code, byte_code_length, output_stream_decls,
1329 output_stream_decl_count, output_stream_stride, shader);
1331 return E_NOTIMPL;
1334 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1335 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1337 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1338 struct d3d10_pixel_shader *object;
1339 HRESULT hr;
1341 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1342 iface, byte_code, byte_code_length, shader);
1344 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1345 if (!object)
1346 return E_OUTOFMEMORY;
1348 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1349 if (FAILED(hr))
1351 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1352 HeapFree(GetProcessHeap(), 0, object);
1353 return hr;
1356 TRACE("Created pixel shader %p.\n", object);
1357 *shader = &object->ID3D10PixelShader_iface;
1359 return S_OK;
1362 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1363 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1365 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1366 struct d3d10_blend_state *object;
1367 struct wine_rb_entry *entry;
1368 HRESULT hr;
1370 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1372 if (!desc)
1373 return E_INVALIDARG;
1375 if ((entry = wine_rb_get(&device->blend_states, desc)))
1377 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1379 TRACE("Returning existing blend state %p.\n", object);
1380 *blend_state = &object->ID3D10BlendState_iface;
1381 ID3D10BlendState_AddRef(*blend_state);
1383 return S_OK;
1386 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1387 if (!object)
1388 return E_OUTOFMEMORY;
1390 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1392 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1393 HeapFree(GetProcessHeap(), 0, object);
1394 return hr;
1397 TRACE("Created blend state %p.\n", object);
1398 *blend_state = &object->ID3D10BlendState_iface;
1400 return S_OK;
1403 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1404 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1406 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1407 struct d3d10_depthstencil_state *object;
1408 struct wine_rb_entry *entry;
1409 HRESULT hr;
1411 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1413 if (!desc)
1414 return E_INVALIDARG;
1416 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1418 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1420 TRACE("Returning existing depthstencil state %p.\n", object);
1421 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1422 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1424 return S_OK;
1427 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1428 if (!object)
1429 return E_OUTOFMEMORY;
1431 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1433 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1434 HeapFree(GetProcessHeap(), 0, object);
1435 return hr;
1438 TRACE("Created depthstencil state %p.\n", object);
1439 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1441 return S_OK;
1444 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1445 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1447 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1448 struct d3d10_rasterizer_state *object;
1449 struct wine_rb_entry *entry;
1450 HRESULT hr;
1452 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1454 if (!desc)
1455 return E_INVALIDARG;
1457 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1459 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1461 TRACE("Returning existing rasterizer state %p.\n", object);
1462 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1463 ID3D10RasterizerState_AddRef(*rasterizer_state);
1465 return S_OK;
1469 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1470 if (!object)
1471 return E_OUTOFMEMORY;
1473 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1475 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1476 HeapFree(GetProcessHeap(), 0, object);
1477 return hr;
1480 TRACE("Created rasterizer state %p.\n", object);
1481 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1483 return S_OK;
1486 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1487 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1489 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1490 struct d3d10_sampler_state *object;
1491 struct wine_rb_entry *entry;
1492 HRESULT hr;
1494 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1496 if (!desc)
1497 return E_INVALIDARG;
1499 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1501 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1503 TRACE("Returning existing sampler state %p.\n", object);
1504 *sampler_state = &object->ID3D10SamplerState_iface;
1505 ID3D10SamplerState_AddRef(*sampler_state);
1507 return S_OK;
1510 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1511 if (!object)
1512 return E_OUTOFMEMORY;
1514 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1516 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1517 HeapFree(GetProcessHeap(), 0, object);
1518 return hr;
1521 TRACE("Created sampler state %p.\n", object);
1522 *sampler_state = &object->ID3D10SamplerState_iface;
1524 return S_OK;
1527 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1528 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1530 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1531 struct d3d10_query *object;
1532 HRESULT hr;
1534 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1536 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1537 return E_OUTOFMEMORY;
1539 if (FAILED(hr = d3d10_query_init(object, device, FALSE)))
1541 WARN("Failed to initialize query, hr %#x.\n", hr);
1542 HeapFree(GetProcessHeap(), 0, object);
1543 return hr;
1546 TRACE("Created query %p.\n", object);
1547 *query = &object->ID3D10Query_iface;
1549 return S_OK;
1552 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1553 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1555 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1556 struct d3d10_query *object;
1557 HRESULT hr;
1559 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1561 if (!desc)
1562 return E_INVALIDARG;
1564 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1566 WARN("Query type %#x is not a predicate.\n", desc->Query);
1567 return E_INVALIDARG;
1570 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1571 return E_OUTOFMEMORY;
1573 if (FAILED(hr = d3d10_query_init(object, device, TRUE)))
1575 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1576 HeapFree(GetProcessHeap(), 0, object);
1577 return hr;
1580 TRACE("Created predicate %p.\n", object);
1581 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1583 return S_OK;
1586 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1587 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1589 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1591 return E_NOTIMPL;
1594 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1595 DXGI_FORMAT format, UINT *format_support)
1597 FIXME("iface %p, format %s, format_support %p stub!\n",
1598 iface, debug_dxgi_format(format), format_support);
1600 return E_NOTIMPL;
1603 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1604 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1606 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1607 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1609 return E_NOTIMPL;
1612 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1614 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1617 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1618 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1619 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1621 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1622 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1623 iface, desc, type, active_counters, name, name_length,
1624 units, units_length, description, description_length);
1626 return E_NOTIMPL;
1629 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1631 FIXME("iface %p stub!\n", iface);
1633 return 0;
1636 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1637 HANDLE resource_handle, REFIID guid, void **resource)
1639 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1640 iface, resource_handle, debugstr_guid(guid), resource);
1642 return E_NOTIMPL;
1645 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1647 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1650 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1652 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1655 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1656 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1658 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1660 return E_NOTIMPL;
1663 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1664 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1666 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1668 return E_NOTIMPL;
1671 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1673 FIXME("iface %p stub!\n", iface);
1675 return D3D10_FEATURE_LEVEL_10_1;
1678 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1680 /* IUnknown methods */
1681 d3d10_device_QueryInterface,
1682 d3d10_device_AddRef,
1683 d3d10_device_Release,
1684 /* ID3D10Device methods */
1685 d3d10_device_VSSetConstantBuffers,
1686 d3d10_device_PSSetShaderResources,
1687 d3d10_device_PSSetShader,
1688 d3d10_device_PSSetSamplers,
1689 d3d10_device_VSSetShader,
1690 d3d10_device_DrawIndexed,
1691 d3d10_device_Draw,
1692 d3d10_device_PSSetConstantBuffers,
1693 d3d10_device_IASetInputLayout,
1694 d3d10_device_IASetVertexBuffers,
1695 d3d10_device_IASetIndexBuffer,
1696 d3d10_device_DrawIndexedInstanced,
1697 d3d10_device_DrawInstanced,
1698 d3d10_device_GSSetConstantBuffers,
1699 d3d10_device_GSSetShader,
1700 d3d10_device_IASetPrimitiveTopology,
1701 d3d10_device_VSSetShaderResources,
1702 d3d10_device_VSSetSamplers,
1703 d3d10_device_SetPredication,
1704 d3d10_device_GSSetShaderResources,
1705 d3d10_device_GSSetSamplers,
1706 d3d10_device_OMSetRenderTargets,
1707 d3d10_device_OMSetBlendState,
1708 d3d10_device_OMSetDepthStencilState,
1709 d3d10_device_SOSetTargets,
1710 d3d10_device_DrawAuto,
1711 d3d10_device_RSSetState,
1712 d3d10_device_RSSetViewports,
1713 d3d10_device_RSSetScissorRects,
1714 d3d10_device_CopySubresourceRegion,
1715 d3d10_device_CopyResource,
1716 d3d10_device_UpdateSubresource,
1717 d3d10_device_ClearRenderTargetView,
1718 d3d10_device_ClearDepthStencilView,
1719 d3d10_device_GenerateMips,
1720 d3d10_device_ResolveSubresource,
1721 d3d10_device_VSGetConstantBuffers,
1722 d3d10_device_PSGetShaderResources,
1723 d3d10_device_PSGetShader,
1724 d3d10_device_PSGetSamplers,
1725 d3d10_device_VSGetShader,
1726 d3d10_device_PSGetConstantBuffers,
1727 d3d10_device_IAGetInputLayout,
1728 d3d10_device_IAGetVertexBuffers,
1729 d3d10_device_IAGetIndexBuffer,
1730 d3d10_device_GSGetConstantBuffers,
1731 d3d10_device_GSGetShader,
1732 d3d10_device_IAGetPrimitiveTopology,
1733 d3d10_device_VSGetShaderResources,
1734 d3d10_device_VSGetSamplers,
1735 d3d10_device_GetPredication,
1736 d3d10_device_GSGetShaderResources,
1737 d3d10_device_GSGetSamplers,
1738 d3d10_device_OMGetRenderTargets,
1739 d3d10_device_OMGetBlendState,
1740 d3d10_device_OMGetDepthStencilState,
1741 d3d10_device_SOGetTargets,
1742 d3d10_device_RSGetState,
1743 d3d10_device_RSGetViewports,
1744 d3d10_device_RSGetScissorRects,
1745 d3d10_device_GetDeviceRemovedReason,
1746 d3d10_device_SetExceptionMode,
1747 d3d10_device_GetExceptionMode,
1748 d3d10_device_GetPrivateData,
1749 d3d10_device_SetPrivateData,
1750 d3d10_device_SetPrivateDataInterface,
1751 d3d10_device_ClearState,
1752 d3d10_device_Flush,
1753 d3d10_device_CreateBuffer,
1754 d3d10_device_CreateTexture1D,
1755 d3d10_device_CreateTexture2D,
1756 d3d10_device_CreateTexture3D,
1757 d3d10_device_CreateShaderResourceView,
1758 d3d10_device_CreateRenderTargetView,
1759 d3d10_device_CreateDepthStencilView,
1760 d3d10_device_CreateInputLayout,
1761 d3d10_device_CreateVertexShader,
1762 d3d10_device_CreateGeometryShader,
1763 d3d10_device_CreateGeometryShaderWithStreamOutput,
1764 d3d10_device_CreatePixelShader,
1765 d3d10_device_CreateBlendState,
1766 d3d10_device_CreateDepthStencilState,
1767 d3d10_device_CreateRasterizerState,
1768 d3d10_device_CreateSamplerState,
1769 d3d10_device_CreateQuery,
1770 d3d10_device_CreatePredicate,
1771 d3d10_device_CreateCounter,
1772 d3d10_device_CheckFormatSupport,
1773 d3d10_device_CheckMultisampleQualityLevels,
1774 d3d10_device_CheckCounterInfo,
1775 d3d10_device_CheckCounter,
1776 d3d10_device_GetCreationFlags,
1777 d3d10_device_OpenSharedResource,
1778 d3d10_device_SetTextFilterSize,
1779 d3d10_device_GetTextFilterSize,
1780 d3d10_device_CreateShaderResourceView1,
1781 d3d10_device_CreateBlendState1,
1782 d3d10_device_GetFeatureLevel,
1785 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1787 /* IUnknown methods */
1788 d3d10_device_inner_QueryInterface,
1789 d3d10_device_inner_AddRef,
1790 d3d10_device_inner_Release,
1793 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
1795 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
1798 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
1800 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1802 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
1804 return IUnknown_QueryInterface(device->outer_unk, iid, out);
1807 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
1809 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1811 TRACE("iface %p.\n", iface);
1813 return IUnknown_AddRef(device->outer_unk);
1816 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
1818 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1820 TRACE("iface %p.\n", iface);
1822 return IUnknown_Release(device->outer_unk);
1825 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
1827 TRACE("iface %p.\n", iface);
1829 wined3d_mutex_lock();
1832 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
1834 TRACE("iface %p.\n", iface);
1836 wined3d_mutex_unlock();
1839 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
1841 FIXME("iface %p, protect %#x stub!\n", iface, protect);
1843 return TRUE;
1846 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
1848 FIXME("iface %p stub!\n", iface);
1850 return TRUE;
1853 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
1855 d3d10_multithread_QueryInterface,
1856 d3d10_multithread_AddRef,
1857 d3d10_multithread_Release,
1858 d3d10_multithread_Enter,
1859 d3d10_multithread_Leave,
1860 d3d10_multithread_SetMultithreadProtected,
1861 d3d10_multithread_GetMultithreadProtected,
1864 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1866 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1868 d3d10_subresource_destroyed,
1871 /* IWineDXGIDeviceParent IUnknown methods */
1873 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1875 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1878 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1879 REFIID riid, void **ppv)
1881 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1882 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1885 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1887 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1888 return IUnknown_AddRef(device->outer_unk);
1891 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1893 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1894 return IUnknown_Release(device->outer_unk);
1897 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1898 IWineDXGIDeviceParent *iface)
1900 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1901 return &device->device_parent;
1904 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1906 /* IUnknown methods */
1907 dxgi_device_parent_QueryInterface,
1908 dxgi_device_parent_AddRef,
1909 dxgi_device_parent_Release,
1910 /* IWineDXGIDeviceParent methods */
1911 dxgi_device_parent_get_wined3d_device_parent,
1914 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1916 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1919 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1920 struct wined3d_device *wined3d_device)
1922 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1924 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1926 wined3d_device_incref(wined3d_device);
1927 device->wined3d_device = wined3d_device;
1930 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1932 TRACE("device_parent %p.\n", device_parent);
1935 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
1936 void *container_parent, struct wined3d_surface *surface, void **parent,
1937 const struct wined3d_parent_ops **parent_ops)
1939 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
1940 device_parent, container_parent, surface, parent, parent_ops);
1942 *parent = container_parent;
1943 *parent_ops = &d3d10_null_wined3d_parent_ops;
1945 return S_OK;
1948 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
1949 void *container_parent, struct wined3d_volume *volume, void **parent,
1950 const struct wined3d_parent_ops **parent_ops)
1952 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
1953 device_parent, container_parent, volume, parent, parent_ops);
1955 *parent = container_parent;
1956 *parent_ops = &d3d10_null_wined3d_parent_ops;
1958 return S_OK;
1961 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1962 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
1964 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1965 struct wined3d_resource *sub_resource;
1966 struct d3d10_texture2d *texture;
1967 D3D10_TEXTURE2D_DESC desc;
1968 HRESULT hr;
1970 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
1971 device_parent, container_parent, wined3d_desc, surface);
1973 FIXME("Implement DXGI<->wined3d usage conversion\n");
1975 desc.Width = wined3d_desc->width;
1976 desc.Height = wined3d_desc->height;
1977 desc.MipLevels = 1;
1978 desc.ArraySize = 1;
1979 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
1980 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
1981 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
1982 desc.Usage = D3D10_USAGE_DEFAULT;
1983 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1984 desc.CPUAccessFlags = 0;
1985 desc.MiscFlags = 0;
1987 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
1988 &desc, NULL, (ID3D10Texture2D **)&texture)))
1990 ERR("CreateTexture2D failed, returning %#x\n", hr);
1991 return hr;
1994 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1995 *surface = wined3d_surface_from_resource(sub_resource);
1996 wined3d_surface_incref(*surface);
1997 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1999 return S_OK;
2002 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2003 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2005 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2006 IWineDXGIDevice *wine_device;
2007 HRESULT hr;
2009 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2011 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2012 &IID_IWineDXGIDevice, (void **)&wine_device)))
2014 ERR("Device should implement IWineDXGIDevice.\n");
2015 return E_FAIL;
2018 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2019 IWineDXGIDevice_Release(wine_device);
2020 if (FAILED(hr))
2022 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2023 return hr;
2026 return S_OK;
2029 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2031 device_parent_wined3d_device_created,
2032 device_parent_mode_changed,
2033 device_parent_surface_created,
2034 device_parent_volume_created,
2035 device_parent_create_swapchain_surface,
2036 device_parent_create_swapchain,
2039 static void *d3d10_rb_alloc(size_t size)
2041 return HeapAlloc(GetProcessHeap(), 0, size);
2044 static void *d3d10_rb_realloc(void *ptr, size_t size)
2046 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2049 static void d3d10_rb_free(void *ptr)
2051 HeapFree(GetProcessHeap(), 0, ptr);
2054 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2056 const D3D10_SAMPLER_DESC *ka = key;
2057 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2059 return memcmp(ka, kb, sizeof(*ka));
2062 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2064 d3d10_rb_alloc,
2065 d3d10_rb_realloc,
2066 d3d10_rb_free,
2067 d3d10_sampler_state_compare,
2070 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2072 const D3D10_BLEND_DESC *ka = key;
2073 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2075 return memcmp(ka, kb, sizeof(*ka));
2078 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2080 d3d10_rb_alloc,
2081 d3d10_rb_realloc,
2082 d3d10_rb_free,
2083 d3d10_blend_state_compare,
2086 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2088 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2089 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2090 const struct d3d10_depthstencil_state, entry)->desc;
2092 return memcmp(ka, kb, sizeof(*ka));
2095 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2097 d3d10_rb_alloc,
2098 d3d10_rb_realloc,
2099 d3d10_rb_free,
2100 d3d10_depthstencil_state_compare,
2103 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2105 const D3D10_RASTERIZER_DESC *ka = key;
2106 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2108 return memcmp(ka, kb, sizeof(*ka));
2111 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2113 d3d10_rb_alloc,
2114 d3d10_rb_realloc,
2115 d3d10_rb_free,
2116 d3d10_rasterizer_state_compare,
2119 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2121 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2122 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2123 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
2124 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2125 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2126 device->refcount = 1;
2127 /* COM aggregation always takes place */
2128 device->outer_unk = outer_unknown;
2130 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2132 WARN("Failed to initialize blend state rbtree.\n");
2133 return E_FAIL;
2136 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2138 WARN("Failed to initialize depthstencil state rbtree.\n");
2139 wine_rb_destroy(&device->blend_states, NULL, NULL);
2140 return E_FAIL;
2143 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2145 WARN("Failed to initialize rasterizer state rbtree.\n");
2146 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2147 wine_rb_destroy(&device->blend_states, NULL, NULL);
2148 return E_FAIL;
2151 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2153 WARN("Failed to initialize sampler state rbtree.\n");
2154 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2155 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2156 wine_rb_destroy(&device->blend_states, NULL, NULL);
2157 return E_FAIL;
2160 return S_OK;