d3d10core: Implement ID3D10Device1.
[wine.git] / dlls / d3d10core / device.c
blob0606af9dc014a1e918965ca200e85c9c225cb8db
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_IWineDXGIDeviceParent))
55 *out = &device->IWineDXGIDeviceParent_iface;
57 else
59 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
60 *out = NULL;
61 return E_NOINTERFACE;
64 IUnknown_AddRef((IUnknown *)*out);
65 return S_OK;
68 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
70 struct d3d10_device *This = impl_from_IUnknown(iface);
71 ULONG refcount = InterlockedIncrement(&This->refcount);
73 TRACE("%p increasing refcount to %u\n", This, refcount);
75 return refcount;
78 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
80 struct d3d10_device *device = impl_from_IUnknown(iface);
81 ULONG refcount = InterlockedDecrement(&device->refcount);
83 TRACE("%p decreasing refcount to %u.\n", device, refcount);
85 if (!refcount)
87 if (device->wined3d_device)
88 wined3d_device_decref(device->wined3d_device);
89 wine_rb_destroy(&device->sampler_states, NULL, NULL);
90 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
91 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
92 wine_rb_destroy(&device->blend_states, NULL, NULL);
95 return refcount;
98 /* IUnknown methods */
100 static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device1 *iface)
102 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device1_iface);
105 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
106 void **ppv)
108 struct d3d10_device *This = impl_from_ID3D10Device(iface);
109 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
112 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
114 struct d3d10_device *This = impl_from_ID3D10Device(iface);
115 return IUnknown_AddRef(This->outer_unk);
118 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
120 struct d3d10_device *This = impl_from_ID3D10Device(iface);
121 return IUnknown_Release(This->outer_unk);
124 /* ID3D10Device methods */
126 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
127 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
129 struct d3d10_device *device = impl_from_ID3D10Device(iface);
130 unsigned int i;
132 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
133 iface, start_slot, buffer_count, buffers);
135 for (i = 0; i < buffer_count; ++i)
137 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
139 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
140 buffer ? buffer->wined3d_buffer : NULL);
144 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
145 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
147 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
148 iface, start_slot, view_count, views);
151 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
152 ID3D10PixelShader *shader)
154 struct d3d10_device *This = impl_from_ID3D10Device(iface);
155 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
157 TRACE("iface %p, shader %p\n", iface, shader);
159 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
162 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
163 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
165 struct d3d10_device *device = impl_from_ID3D10Device(iface);
166 unsigned int i;
168 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
169 iface, start_slot, sampler_count, samplers);
171 for (i = 0; i < sampler_count; ++i)
173 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
175 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
176 sampler ? sampler->wined3d_sampler : NULL);
180 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
181 ID3D10VertexShader *shader)
183 struct d3d10_device *This = impl_from_ID3D10Device(iface);
184 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
186 TRACE("iface %p, shader %p\n", iface, shader);
188 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
191 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
192 UINT start_index_location, INT base_vertex_location)
194 struct d3d10_device *This = impl_from_ID3D10Device(iface);
196 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
197 iface, index_count, start_index_location, base_vertex_location);
199 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
200 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
203 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
204 UINT start_vertex_location)
206 struct d3d10_device *This = impl_from_ID3D10Device(iface);
208 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
209 iface, vertex_count, start_vertex_location);
211 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
214 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
215 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
217 struct d3d10_device *device = impl_from_ID3D10Device(iface);
218 unsigned int i;
220 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
221 iface, start_slot, buffer_count, buffers);
223 for (i = 0; i < buffer_count; ++i)
225 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
227 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
228 buffer ? buffer->wined3d_buffer : NULL);
232 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
233 ID3D10InputLayout *input_layout)
235 struct d3d10_device *This = impl_from_ID3D10Device(iface);
236 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
238 TRACE("iface %p, input_layout %p\n", iface, input_layout);
240 wined3d_device_set_vertex_declaration(This->wined3d_device,
241 layout ? layout->wined3d_decl : NULL);
244 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
245 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
247 struct d3d10_device *This = impl_from_ID3D10Device(iface);
248 unsigned int i;
250 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
251 iface, start_slot, buffer_count, buffers, strides, offsets);
253 for (i = 0; i < buffer_count; ++i)
255 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
257 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
258 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
262 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
263 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
265 struct d3d10_device *This = impl_from_ID3D10Device(iface);
266 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
268 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
269 iface, buffer, debug_dxgi_format(format), offset);
271 wined3d_device_set_index_buffer(This->wined3d_device,
272 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
273 wined3dformat_from_dxgi_format(format));
274 if (offset) FIXME("offset %u not supported.\n", offset);
277 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
278 UINT instance_index_count, UINT instance_count, UINT start_index_location,
279 INT base_vertex_location, UINT start_instance_location)
281 struct d3d10_device *device = impl_from_ID3D10Device(iface);
283 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
284 "\tbase_vertex_location %d, start_instance_location %u.\n",
285 iface, instance_index_count, instance_count, start_index_location,
286 base_vertex_location, start_instance_location);
288 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
289 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
290 instance_index_count, start_instance_location, instance_count);
293 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
294 UINT instance_vertex_count, UINT instance_count,
295 UINT start_vertex_location, UINT start_instance_location)
297 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
298 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
299 start_vertex_location, start_instance_location);
302 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
303 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
305 struct d3d10_device *device = impl_from_ID3D10Device(iface);
306 unsigned int i;
308 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
309 iface, start_slot, buffer_count, buffers);
311 for (i = 0; i < buffer_count; ++i)
313 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
315 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
316 buffer ? buffer->wined3d_buffer : NULL);
320 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
322 struct d3d10_device *device = impl_from_ID3D10Device(iface);
323 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
325 TRACE("iface %p, shader %p.\n", iface, shader);
327 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
330 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
331 D3D10_PRIMITIVE_TOPOLOGY topology)
333 struct d3d10_device *This = impl_from_ID3D10Device(iface);
335 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
337 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
340 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
341 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
343 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
344 iface, start_slot, view_count, views);
347 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
348 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
350 struct d3d10_device *device = impl_from_ID3D10Device(iface);
351 unsigned int i;
353 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
354 iface, start_slot, sampler_count, samplers);
356 for (i = 0; i < sampler_count; ++i)
358 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
360 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
361 sampler ? sampler->wined3d_sampler : NULL);
365 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
367 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
370 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
371 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
373 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
374 iface, start_slot, view_count, views);
377 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
378 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
380 struct d3d10_device *device = impl_from_ID3D10Device(iface);
381 unsigned int i;
383 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
384 iface, start_slot, sampler_count, samplers);
386 for (i = 0; i < sampler_count; ++i)
388 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
390 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
391 sampler ? sampler->wined3d_sampler : NULL);
395 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
396 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
397 ID3D10DepthStencilView *depth_stencil_view)
399 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
400 iface, render_target_view_count, render_target_views, depth_stencil_view);
403 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
404 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
406 struct d3d10_device *device = impl_from_ID3D10Device(iface);
408 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
409 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
411 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
412 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
413 device->sample_mask = sample_mask;
416 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
417 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
419 struct d3d10_device *device = impl_from_ID3D10Device(iface);
421 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
422 iface, depth_stencil_state, stencil_ref);
424 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
425 device->stencil_ref = stencil_ref;
428 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
429 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
431 struct d3d10_device *device = impl_from_ID3D10Device(iface);
432 unsigned int count, i;
434 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
436 count = min(target_count, 4);
437 for (i = 0; i < count; ++i)
439 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
441 wined3d_device_set_stream_output(device->wined3d_device, i,
442 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
445 for (i = count; i < 4; ++i)
447 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
451 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
453 FIXME("iface %p stub!\n", iface);
456 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
458 struct d3d10_device *device = impl_from_ID3D10Device(iface);
460 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
462 device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
465 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
466 UINT viewport_count, const D3D10_VIEWPORT *viewports)
468 struct d3d10_device *device = impl_from_ID3D10Device(iface);
469 struct wined3d_viewport wined3d_vp;
471 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
473 if (viewport_count > 1)
474 FIXME("Multiple viewports not implemented.\n");
476 if (!viewport_count)
477 return;
479 wined3d_vp.x = viewports[0].TopLeftX;
480 wined3d_vp.y = viewports[0].TopLeftY;
481 wined3d_vp.width = viewports[0].Width;
482 wined3d_vp.height = viewports[0].Height;
483 wined3d_vp.min_z = viewports[0].MinDepth;
484 wined3d_vp.max_z = viewports[0].MaxDepth;
486 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
489 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
490 UINT rect_count, const D3D10_RECT *rects)
492 struct d3d10_device *device = impl_from_ID3D10Device(iface);
494 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
496 if (rect_count > 1)
497 FIXME("Multiple scissor rects not implemented.\n");
499 if (!rect_count)
500 return;
502 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
505 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
506 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
507 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
509 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
510 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
511 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
512 src_resource, src_subresource_idx, src_box);
515 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
516 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
518 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
521 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
522 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
523 const void *data, UINT row_pitch, UINT depth_pitch)
525 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
526 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
529 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
530 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
532 struct d3d10_device *This = impl_from_ID3D10Device(iface);
533 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
534 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
536 TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
537 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
539 wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
542 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
543 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
545 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
546 iface, depth_stencil_view, flags, depth, stencil);
549 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
550 ID3D10ShaderResourceView *shader_resource_view)
552 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
555 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
556 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
557 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
559 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
560 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
561 iface, dst_resource, dst_subresource_idx,
562 src_resource, src_subresource_idx, debug_dxgi_format(format));
565 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
566 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
568 struct d3d10_device *device = impl_from_ID3D10Device(iface);
569 unsigned int i;
571 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
572 iface, start_slot, buffer_count, buffers);
574 for (i = 0; i < buffer_count; ++i)
576 struct wined3d_buffer *wined3d_buffer;
577 struct d3d10_buffer *buffer_impl;
579 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
581 buffers[i] = NULL;
582 continue;
585 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
586 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
587 ID3D10Buffer_AddRef(buffers[i]);
591 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
592 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
594 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
595 iface, start_slot, view_count, views);
598 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
600 struct d3d10_device *device = impl_from_ID3D10Device(iface);
601 struct d3d10_pixel_shader *shader_impl;
602 struct wined3d_shader *wined3d_shader;
604 TRACE("iface %p, shader %p.\n", iface, shader);
606 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
608 *shader = NULL;
609 return;
612 shader_impl = wined3d_shader_get_parent(wined3d_shader);
613 *shader = &shader_impl->ID3D10PixelShader_iface;
614 ID3D10PixelShader_AddRef(*shader);
617 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
618 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
620 struct d3d10_device *device = impl_from_ID3D10Device(iface);
621 unsigned int i;
623 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
624 iface, start_slot, sampler_count, samplers);
626 for (i = 0; i < sampler_count; ++i)
628 struct d3d10_sampler_state *sampler_impl;
629 struct wined3d_sampler *wined3d_sampler;
631 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
633 samplers[i] = NULL;
634 continue;
637 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
638 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
639 ID3D10SamplerState_AddRef(samplers[i]);
643 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
645 struct d3d10_device *device = impl_from_ID3D10Device(iface);
646 struct d3d10_vertex_shader *shader_impl;
647 struct wined3d_shader *wined3d_shader;
649 TRACE("iface %p, shader %p.\n", iface, shader);
651 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
653 *shader = NULL;
654 return;
657 shader_impl = wined3d_shader_get_parent(wined3d_shader);
658 *shader = &shader_impl->ID3D10VertexShader_iface;
659 ID3D10VertexShader_AddRef(*shader);
662 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
663 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
665 struct d3d10_device *device = impl_from_ID3D10Device(iface);
666 unsigned int i;
668 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
669 iface, start_slot, buffer_count, buffers);
671 for (i = 0; i < buffer_count; ++i)
673 struct wined3d_buffer *wined3d_buffer;
674 struct d3d10_buffer *buffer_impl;
676 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
678 buffers[i] = NULL;
679 continue;
682 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
683 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
684 ID3D10Buffer_AddRef(buffers[i]);
688 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
690 struct d3d10_device *device = impl_from_ID3D10Device(iface);
691 struct wined3d_vertex_declaration *wined3d_declaration;
692 struct d3d10_input_layout *input_layout_impl;
694 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
696 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
698 *input_layout = NULL;
699 return;
702 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
703 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
704 ID3D10InputLayout_AddRef(*input_layout);
707 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
708 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
710 struct d3d10_device *device = impl_from_ID3D10Device(iface);
711 unsigned int i;
713 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
714 iface, start_slot, buffer_count, buffers, strides, offsets);
716 for (i = 0; i < buffer_count; ++i)
718 struct wined3d_buffer *wined3d_buffer;
719 struct d3d10_buffer *buffer_impl;
721 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
722 &wined3d_buffer, &offsets[i], &strides[i])))
723 ERR("Failed to get vertex buffer.\n");
725 if (!wined3d_buffer)
727 buffers[i] = NULL;
728 continue;
731 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
732 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
733 ID3D10Buffer_AddRef(buffers[i]);
737 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
738 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
740 struct d3d10_device *device = impl_from_ID3D10Device(iface);
741 enum wined3d_format_id wined3d_format;
742 struct wined3d_buffer *wined3d_buffer;
743 struct d3d10_buffer *buffer_impl;
745 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
747 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
748 *format = dxgi_format_from_wined3dformat(wined3d_format);
749 *offset = 0; /* FIXME */
750 if (!wined3d_buffer)
752 *buffer = NULL;
753 return;
756 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
757 *buffer = &buffer_impl->ID3D10Buffer_iface;
758 ID3D10Buffer_AddRef(*buffer);
761 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
762 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
764 struct d3d10_device *device = impl_from_ID3D10Device(iface);
765 unsigned int i;
767 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
768 iface, start_slot, buffer_count, buffers);
770 for (i = 0; i < buffer_count; ++i)
772 struct wined3d_buffer *wined3d_buffer;
773 struct d3d10_buffer *buffer_impl;
775 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
777 buffers[i] = NULL;
778 continue;
781 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
782 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
783 ID3D10Buffer_AddRef(buffers[i]);
787 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
789 struct d3d10_device *device = impl_from_ID3D10Device(iface);
790 struct d3d10_geometry_shader *shader_impl;
791 struct wined3d_shader *wined3d_shader;
793 TRACE("iface %p, shader %p.\n", iface, shader);
795 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
797 *shader = NULL;
798 return;
801 shader_impl = wined3d_shader_get_parent(wined3d_shader);
802 *shader = &shader_impl->ID3D10GeometryShader_iface;
803 ID3D10GeometryShader_AddRef(*shader);
806 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
807 D3D10_PRIMITIVE_TOPOLOGY *topology)
809 struct d3d10_device *This = impl_from_ID3D10Device(iface);
811 TRACE("iface %p, topology %p\n", iface, topology);
813 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
816 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
817 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
819 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
820 iface, start_slot, view_count, views);
823 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
824 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
826 struct d3d10_device *device = impl_from_ID3D10Device(iface);
827 unsigned int i;
829 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
830 iface, start_slot, sampler_count, samplers);
832 for (i = 0; i < sampler_count; ++i)
834 struct d3d10_sampler_state *sampler_impl;
835 struct wined3d_sampler *wined3d_sampler;
837 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
839 samplers[i] = NULL;
840 continue;
843 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
844 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
845 ID3D10SamplerState_AddRef(samplers[i]);
849 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
850 ID3D10Predicate **predicate, BOOL *value)
852 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
855 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
856 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
858 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
859 iface, start_slot, view_count, views);
862 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
863 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
865 struct d3d10_device *device = impl_from_ID3D10Device(iface);
866 unsigned int i;
868 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
869 iface, start_slot, sampler_count, samplers);
871 for (i = 0; i < sampler_count; ++i)
873 struct d3d10_sampler_state *sampler_impl;
874 struct wined3d_sampler *wined3d_sampler;
876 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
878 samplers[i] = NULL;
879 continue;
882 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
883 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
884 ID3D10SamplerState_AddRef(samplers[i]);
888 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
889 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
891 FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
892 iface, view_count, render_target_views, depth_stencil_view);
895 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
896 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
898 struct d3d10_device *device = impl_from_ID3D10Device(iface);
900 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
901 iface, blend_state, blend_factor, sample_mask);
903 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
904 ID3D10BlendState_AddRef(*blend_state);
905 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
906 *sample_mask = device->sample_mask;
909 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
910 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
912 struct d3d10_device *device = impl_from_ID3D10Device(iface);
914 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
915 iface, depth_stencil_state, stencil_ref);
917 if ((*depth_stencil_state = device->depth_stencil_state
918 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
919 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
920 *stencil_ref = device->stencil_ref;
923 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
924 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
926 struct d3d10_device *device = impl_from_ID3D10Device(iface);
927 unsigned int i;
929 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
930 iface, buffer_count, buffers, offsets);
932 for (i = 0; i < buffer_count; ++i)
934 struct wined3d_buffer *wined3d_buffer;
935 struct d3d10_buffer *buffer_impl;
937 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
939 buffers[i] = NULL;
940 continue;
943 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
944 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
945 ID3D10Buffer_AddRef(buffers[i]);
949 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
951 struct d3d10_device *device = impl_from_ID3D10Device(iface);
953 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
955 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
956 ID3D10RasterizerState_AddRef(*rasterizer_state);
959 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
960 UINT *viewport_count, D3D10_VIEWPORT *viewports)
962 struct d3d10_device *device = impl_from_ID3D10Device(iface);
963 struct wined3d_viewport wined3d_vp;
965 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
967 if (!viewports)
969 *viewport_count = 1;
970 return;
973 if (!*viewport_count)
974 return;
976 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
978 viewports[0].TopLeftX = wined3d_vp.x;
979 viewports[0].TopLeftY = wined3d_vp.y;
980 viewports[0].Width = wined3d_vp.width;
981 viewports[0].Height = wined3d_vp.height;
982 viewports[0].MinDepth = wined3d_vp.min_z;
983 viewports[0].MaxDepth = wined3d_vp.max_z;
985 if (*viewport_count > 1)
986 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
989 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
991 struct d3d10_device *device = impl_from_ID3D10Device(iface);
993 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
995 if (!rects)
997 *rect_count = 1;
998 return;
1001 if (!*rect_count)
1002 return;
1004 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1005 if (*rect_count > 1)
1006 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1009 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1011 FIXME("iface %p stub!\n", iface);
1013 return E_NOTIMPL;
1016 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1018 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1020 return E_NOTIMPL;
1023 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1025 FIXME("iface %p stub!\n", iface);
1027 return 0;
1030 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1031 REFGUID guid, UINT *data_size, void *data)
1033 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1034 iface, debugstr_guid(guid), data_size, data);
1036 return E_NOTIMPL;
1039 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1040 REFGUID guid, UINT data_size, const void *data)
1042 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1043 iface, debugstr_guid(guid), data_size, data);
1045 return E_NOTIMPL;
1048 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1049 REFGUID guid, const IUnknown *data)
1051 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1053 return E_NOTIMPL;
1056 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1058 FIXME("iface %p stub!\n", iface);
1061 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1063 FIXME("iface %p stub!\n", iface);
1066 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1067 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1069 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1070 struct d3d10_buffer *object;
1071 HRESULT hr;
1073 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1075 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1076 if (!object)
1077 return E_OUTOFMEMORY;
1079 hr = d3d10_buffer_init(object, This, desc, data);
1080 if (FAILED(hr))
1082 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1083 HeapFree(GetProcessHeap(), 0, object);
1084 return hr;
1087 *buffer = &object->ID3D10Buffer_iface;
1089 TRACE("Created ID3D10Buffer %p\n", object);
1091 return S_OK;
1094 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1095 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1097 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1099 return E_NOTIMPL;
1102 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1103 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1104 ID3D10Texture2D **texture)
1106 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1107 struct d3d10_texture2d *object;
1108 HRESULT hr;
1110 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1112 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1113 if (!object)
1114 return E_OUTOFMEMORY;
1116 hr = d3d10_texture2d_init(object, This, desc);
1117 if (FAILED(hr))
1119 WARN("Failed to initialize texture, hr %#x.\n", hr);
1120 HeapFree(GetProcessHeap(), 0, object);
1121 return hr;
1124 *texture = &object->ID3D10Texture2D_iface;
1126 TRACE("Created ID3D10Texture2D %p\n", object);
1128 return S_OK;
1131 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1132 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1133 ID3D10Texture3D **texture)
1135 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1136 struct d3d10_texture3d *object;
1137 HRESULT hr;
1139 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1141 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1142 if (!object)
1143 return E_OUTOFMEMORY;
1145 hr = d3d10_texture3d_init(object, device, desc);
1146 if (FAILED(hr))
1148 WARN("Failed to initialize texture, hr %#x.\n", hr);
1149 HeapFree(GetProcessHeap(), 0, object);
1150 return hr;
1153 TRACE("Created 3D texture %p.\n", object);
1154 *texture = &object->ID3D10Texture3D_iface;
1156 return S_OK;
1159 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1160 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
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 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1168 if (!object)
1169 return E_OUTOFMEMORY;
1171 if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
1173 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1174 HeapFree(GetProcessHeap(), 0, object);
1175 return hr;
1178 TRACE("Created shader resource view %p.\n", object);
1179 *view = &object->ID3D10ShaderResourceView_iface;
1181 return S_OK;
1184 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1185 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1187 struct d3d10_rendertarget_view *object;
1188 HRESULT hr;
1190 TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1192 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1193 if (!object)
1194 return E_OUTOFMEMORY;
1196 hr = d3d10_rendertarget_view_init(object, resource, desc);
1197 if (FAILED(hr))
1199 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1200 HeapFree(GetProcessHeap(), 0, object);
1201 return hr;
1204 TRACE("Created rendertarget view %p.\n", object);
1205 *view = &object->ID3D10RenderTargetView_iface;
1207 return S_OK;
1210 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1211 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1213 struct d3d10_depthstencil_view *object;
1214 HRESULT hr;
1216 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1218 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1219 if (!object)
1220 return E_OUTOFMEMORY;
1222 if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
1224 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1225 HeapFree(GetProcessHeap(), 0, object);
1226 return hr;
1229 TRACE("Created depthstencil view %p.\n", object);
1230 *view = &object->ID3D10DepthStencilView_iface;
1232 return S_OK;
1235 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1236 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1237 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1238 ID3D10InputLayout **input_layout)
1240 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1241 struct d3d10_input_layout *object;
1242 HRESULT hr;
1244 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1245 "\tshader_byte_code_length %lu, input_layout %p\n",
1246 iface, element_descs, element_count, shader_byte_code,
1247 shader_byte_code_length, input_layout);
1249 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1250 if (!object)
1251 return E_OUTOFMEMORY;
1253 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1254 shader_byte_code, shader_byte_code_length);
1255 if (FAILED(hr))
1257 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1258 HeapFree(GetProcessHeap(), 0, object);
1259 return hr;
1262 TRACE("Created input layout %p.\n", object);
1263 *input_layout = &object->ID3D10InputLayout_iface;
1265 return S_OK;
1268 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1269 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1271 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1272 struct d3d10_vertex_shader *object;
1273 HRESULT hr;
1275 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1276 iface, byte_code, byte_code_length, shader);
1278 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1279 if (!object)
1280 return E_OUTOFMEMORY;
1282 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1283 if (FAILED(hr))
1285 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1286 HeapFree(GetProcessHeap(), 0, object);
1287 return hr;
1290 TRACE("Created vertex shader %p.\n", object);
1291 *shader = &object->ID3D10VertexShader_iface;
1293 return S_OK;
1296 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1297 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1299 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1300 struct d3d10_geometry_shader *object;
1301 HRESULT hr;
1303 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1304 iface, byte_code, byte_code_length, shader);
1306 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1307 if (!object)
1308 return E_OUTOFMEMORY;
1310 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1311 if (FAILED(hr))
1313 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1314 HeapFree(GetProcessHeap(), 0, object);
1315 return hr;
1318 TRACE("Created geometry shader %p.\n", object);
1319 *shader = &object->ID3D10GeometryShader_iface;
1321 return S_OK;
1324 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1325 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1326 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1328 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1329 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1330 iface, byte_code, byte_code_length, output_stream_decls,
1331 output_stream_decl_count, output_stream_stride, shader);
1333 return E_NOTIMPL;
1336 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1337 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1339 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1340 struct d3d10_pixel_shader *object;
1341 HRESULT hr;
1343 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1344 iface, byte_code, byte_code_length, shader);
1346 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1347 if (!object)
1348 return E_OUTOFMEMORY;
1350 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1351 if (FAILED(hr))
1353 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1354 HeapFree(GetProcessHeap(), 0, object);
1355 return hr;
1358 TRACE("Created pixel shader %p.\n", object);
1359 *shader = &object->ID3D10PixelShader_iface;
1361 return S_OK;
1364 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1365 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1367 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1368 struct d3d10_blend_state *object;
1369 struct wine_rb_entry *entry;
1370 HRESULT hr;
1372 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1374 if (!desc)
1375 return E_INVALIDARG;
1377 if ((entry = wine_rb_get(&device->blend_states, desc)))
1379 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1381 TRACE("Returning existing blend state %p.\n", object);
1382 *blend_state = &object->ID3D10BlendState_iface;
1383 ID3D10BlendState_AddRef(*blend_state);
1385 return S_OK;
1388 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1389 if (!object)
1390 return E_OUTOFMEMORY;
1392 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1394 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1395 HeapFree(GetProcessHeap(), 0, object);
1396 return hr;
1399 TRACE("Created blend state %p.\n", object);
1400 *blend_state = &object->ID3D10BlendState_iface;
1402 return S_OK;
1405 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1406 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1408 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1409 struct d3d10_depthstencil_state *object;
1410 struct wine_rb_entry *entry;
1411 HRESULT hr;
1413 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1415 if (!desc)
1416 return E_INVALIDARG;
1418 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1420 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1422 TRACE("Returning existing depthstencil state %p.\n", object);
1423 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1424 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1426 return S_OK;
1429 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1430 if (!object)
1431 return E_OUTOFMEMORY;
1433 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1435 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1436 HeapFree(GetProcessHeap(), 0, object);
1437 return hr;
1440 TRACE("Created depthstencil state %p.\n", object);
1441 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1443 return S_OK;
1446 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1447 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1449 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1450 struct d3d10_rasterizer_state *object;
1451 struct wine_rb_entry *entry;
1452 HRESULT hr;
1454 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1456 if (!desc)
1457 return E_INVALIDARG;
1459 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1461 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1463 TRACE("Returning existing rasterizer state %p.\n", object);
1464 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1465 ID3D10RasterizerState_AddRef(*rasterizer_state);
1467 return S_OK;
1471 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1472 if (!object)
1473 return E_OUTOFMEMORY;
1475 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1477 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1478 HeapFree(GetProcessHeap(), 0, object);
1479 return hr;
1482 TRACE("Created rasterizer state %p.\n", object);
1483 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1485 return S_OK;
1488 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1489 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1491 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1492 struct d3d10_sampler_state *object;
1493 struct wine_rb_entry *entry;
1494 HRESULT hr;
1496 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1498 if (!desc)
1499 return E_INVALIDARG;
1501 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1503 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1505 TRACE("Returning existing sampler state %p.\n", object);
1506 *sampler_state = &object->ID3D10SamplerState_iface;
1507 ID3D10SamplerState_AddRef(*sampler_state);
1509 return S_OK;
1512 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1513 if (!object)
1514 return E_OUTOFMEMORY;
1516 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1518 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1519 HeapFree(GetProcessHeap(), 0, object);
1520 return hr;
1523 TRACE("Created sampler state %p.\n", object);
1524 *sampler_state = &object->ID3D10SamplerState_iface;
1526 return S_OK;
1529 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1530 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1532 struct d3d10_query *object;
1533 HRESULT hr;
1535 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1537 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1538 if (!object)
1539 return E_OUTOFMEMORY;
1541 if (FAILED(hr = d3d10_query_init(object, FALSE)))
1543 WARN("Failed to initialize query, hr %#x.\n", hr);
1544 HeapFree(GetProcessHeap(), 0, object);
1545 return hr;
1548 TRACE("Created query %p.\n", object);
1549 *query = &object->ID3D10Query_iface;
1551 return S_OK;
1554 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1555 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1557 struct d3d10_query *object;
1558 HRESULT hr;
1560 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1562 if (!desc)
1563 return E_INVALIDARG;
1565 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1567 WARN("Query type %#x is not a predicate.\n", desc->Query);
1568 return E_INVALIDARG;
1571 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1572 return E_OUTOFMEMORY;
1574 if (FAILED(hr = d3d10_query_init(object, TRUE)))
1576 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1577 HeapFree(GetProcessHeap(), 0, object);
1578 return hr;
1581 TRACE("Created predicate %p.\n", object);
1582 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1584 return S_OK;
1587 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1588 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1590 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1592 return E_NOTIMPL;
1595 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1596 DXGI_FORMAT format, UINT *format_support)
1598 FIXME("iface %p, format %s, format_support %p stub!\n",
1599 iface, debug_dxgi_format(format), format_support);
1601 return E_NOTIMPL;
1604 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1605 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1607 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1608 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1610 return E_NOTIMPL;
1613 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1615 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1618 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1619 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1620 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1622 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1623 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1624 iface, desc, type, active_counters, name, name_length,
1625 units, units_length, description, description_length);
1627 return E_NOTIMPL;
1630 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1632 FIXME("iface %p stub!\n", iface);
1634 return 0;
1637 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1638 HANDLE resource_handle, REFIID guid, void **resource)
1640 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1641 iface, resource_handle, debugstr_guid(guid), resource);
1643 return E_NOTIMPL;
1646 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1648 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1651 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1653 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1656 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1657 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1659 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1661 return E_NOTIMPL;
1664 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1665 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1667 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1669 return E_NOTIMPL;
1672 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1674 FIXME("iface %p stub!\n", iface);
1676 return D3D10_FEATURE_LEVEL_10_1;
1679 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1681 /* IUnknown methods */
1682 d3d10_device_QueryInterface,
1683 d3d10_device_AddRef,
1684 d3d10_device_Release,
1685 /* ID3D10Device methods */
1686 d3d10_device_VSSetConstantBuffers,
1687 d3d10_device_PSSetShaderResources,
1688 d3d10_device_PSSetShader,
1689 d3d10_device_PSSetSamplers,
1690 d3d10_device_VSSetShader,
1691 d3d10_device_DrawIndexed,
1692 d3d10_device_Draw,
1693 d3d10_device_PSSetConstantBuffers,
1694 d3d10_device_IASetInputLayout,
1695 d3d10_device_IASetVertexBuffers,
1696 d3d10_device_IASetIndexBuffer,
1697 d3d10_device_DrawIndexedInstanced,
1698 d3d10_device_DrawInstanced,
1699 d3d10_device_GSSetConstantBuffers,
1700 d3d10_device_GSSetShader,
1701 d3d10_device_IASetPrimitiveTopology,
1702 d3d10_device_VSSetShaderResources,
1703 d3d10_device_VSSetSamplers,
1704 d3d10_device_SetPredication,
1705 d3d10_device_GSSetShaderResources,
1706 d3d10_device_GSSetSamplers,
1707 d3d10_device_OMSetRenderTargets,
1708 d3d10_device_OMSetBlendState,
1709 d3d10_device_OMSetDepthStencilState,
1710 d3d10_device_SOSetTargets,
1711 d3d10_device_DrawAuto,
1712 d3d10_device_RSSetState,
1713 d3d10_device_RSSetViewports,
1714 d3d10_device_RSSetScissorRects,
1715 d3d10_device_CopySubresourceRegion,
1716 d3d10_device_CopyResource,
1717 d3d10_device_UpdateSubresource,
1718 d3d10_device_ClearRenderTargetView,
1719 d3d10_device_ClearDepthStencilView,
1720 d3d10_device_GenerateMips,
1721 d3d10_device_ResolveSubresource,
1722 d3d10_device_VSGetConstantBuffers,
1723 d3d10_device_PSGetShaderResources,
1724 d3d10_device_PSGetShader,
1725 d3d10_device_PSGetSamplers,
1726 d3d10_device_VSGetShader,
1727 d3d10_device_PSGetConstantBuffers,
1728 d3d10_device_IAGetInputLayout,
1729 d3d10_device_IAGetVertexBuffers,
1730 d3d10_device_IAGetIndexBuffer,
1731 d3d10_device_GSGetConstantBuffers,
1732 d3d10_device_GSGetShader,
1733 d3d10_device_IAGetPrimitiveTopology,
1734 d3d10_device_VSGetShaderResources,
1735 d3d10_device_VSGetSamplers,
1736 d3d10_device_GetPredication,
1737 d3d10_device_GSGetShaderResources,
1738 d3d10_device_GSGetSamplers,
1739 d3d10_device_OMGetRenderTargets,
1740 d3d10_device_OMGetBlendState,
1741 d3d10_device_OMGetDepthStencilState,
1742 d3d10_device_SOGetTargets,
1743 d3d10_device_RSGetState,
1744 d3d10_device_RSGetViewports,
1745 d3d10_device_RSGetScissorRects,
1746 d3d10_device_GetDeviceRemovedReason,
1747 d3d10_device_SetExceptionMode,
1748 d3d10_device_GetExceptionMode,
1749 d3d10_device_GetPrivateData,
1750 d3d10_device_SetPrivateData,
1751 d3d10_device_SetPrivateDataInterface,
1752 d3d10_device_ClearState,
1753 d3d10_device_Flush,
1754 d3d10_device_CreateBuffer,
1755 d3d10_device_CreateTexture1D,
1756 d3d10_device_CreateTexture2D,
1757 d3d10_device_CreateTexture3D,
1758 d3d10_device_CreateShaderResourceView,
1759 d3d10_device_CreateRenderTargetView,
1760 d3d10_device_CreateDepthStencilView,
1761 d3d10_device_CreateInputLayout,
1762 d3d10_device_CreateVertexShader,
1763 d3d10_device_CreateGeometryShader,
1764 d3d10_device_CreateGeometryShaderWithStreamOutput,
1765 d3d10_device_CreatePixelShader,
1766 d3d10_device_CreateBlendState,
1767 d3d10_device_CreateDepthStencilState,
1768 d3d10_device_CreateRasterizerState,
1769 d3d10_device_CreateSamplerState,
1770 d3d10_device_CreateQuery,
1771 d3d10_device_CreatePredicate,
1772 d3d10_device_CreateCounter,
1773 d3d10_device_CheckFormatSupport,
1774 d3d10_device_CheckMultisampleQualityLevels,
1775 d3d10_device_CheckCounterInfo,
1776 d3d10_device_CheckCounter,
1777 d3d10_device_GetCreationFlags,
1778 d3d10_device_OpenSharedResource,
1779 d3d10_device_SetTextFilterSize,
1780 d3d10_device_GetTextFilterSize,
1781 d3d10_device_CreateShaderResourceView1,
1782 d3d10_device_CreateBlendState1,
1783 d3d10_device_GetFeatureLevel,
1786 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1788 /* IUnknown methods */
1789 d3d10_device_inner_QueryInterface,
1790 d3d10_device_inner_AddRef,
1791 d3d10_device_inner_Release,
1794 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1796 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1798 d3d10_subresource_destroyed,
1801 /* IWineDXGIDeviceParent IUnknown methods */
1803 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1805 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1808 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1809 REFIID riid, void **ppv)
1811 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1812 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1815 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1817 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1818 return IUnknown_AddRef(device->outer_unk);
1821 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1823 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1824 return IUnknown_Release(device->outer_unk);
1827 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1828 IWineDXGIDeviceParent *iface)
1830 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1831 return &device->device_parent;
1834 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1836 /* IUnknown methods */
1837 dxgi_device_parent_QueryInterface,
1838 dxgi_device_parent_AddRef,
1839 dxgi_device_parent_Release,
1840 /* IWineDXGIDeviceParent methods */
1841 dxgi_device_parent_get_wined3d_device_parent,
1844 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1846 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1849 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1850 struct wined3d_device *wined3d_device)
1852 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1854 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1856 wined3d_device_incref(wined3d_device);
1857 device->wined3d_device = wined3d_device;
1860 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1862 TRACE("device_parent %p.\n", device_parent);
1865 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
1866 void *container_parent, struct wined3d_surface *surface, void **parent,
1867 const struct wined3d_parent_ops **parent_ops)
1869 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
1870 device_parent, container_parent, surface, parent, parent_ops);
1872 *parent = container_parent;
1873 *parent_ops = &d3d10_null_wined3d_parent_ops;
1875 return S_OK;
1878 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
1879 void *container_parent, struct wined3d_volume *volume, void **parent,
1880 const struct wined3d_parent_ops **parent_ops)
1882 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
1883 device_parent, container_parent, volume, parent, parent_ops);
1885 *parent = container_parent;
1886 *parent_ops = &d3d10_null_wined3d_parent_ops;
1888 return S_OK;
1891 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1892 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
1894 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1895 struct wined3d_resource *sub_resource;
1896 struct d3d10_texture2d *texture;
1897 D3D10_TEXTURE2D_DESC desc;
1898 HRESULT hr;
1900 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
1901 device_parent, container_parent, wined3d_desc, surface);
1903 FIXME("Implement DXGI<->wined3d usage conversion\n");
1905 desc.Width = wined3d_desc->width;
1906 desc.Height = wined3d_desc->height;
1907 desc.MipLevels = 1;
1908 desc.ArraySize = 1;
1909 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
1910 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
1911 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
1912 desc.Usage = D3D10_USAGE_DEFAULT;
1913 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1914 desc.CPUAccessFlags = 0;
1915 desc.MiscFlags = 0;
1917 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
1918 &desc, NULL, (ID3D10Texture2D **)&texture)))
1920 ERR("CreateTexture2D failed, returning %#x\n", hr);
1921 return hr;
1924 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1925 *surface = wined3d_surface_from_resource(sub_resource);
1926 wined3d_surface_incref(*surface);
1927 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1929 return S_OK;
1932 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
1933 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
1935 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1936 IWineDXGIDevice *wine_device;
1937 HRESULT hr;
1939 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
1941 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
1942 &IID_IWineDXGIDevice, (void **)&wine_device)))
1944 ERR("Device should implement IWineDXGIDevice.\n");
1945 return E_FAIL;
1948 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
1949 IWineDXGIDevice_Release(wine_device);
1950 if (FAILED(hr))
1952 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1953 return hr;
1956 return S_OK;
1959 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
1961 device_parent_wined3d_device_created,
1962 device_parent_mode_changed,
1963 device_parent_surface_created,
1964 device_parent_volume_created,
1965 device_parent_create_swapchain_surface,
1966 device_parent_create_swapchain,
1969 static void *d3d10_rb_alloc(size_t size)
1971 return HeapAlloc(GetProcessHeap(), 0, size);
1974 static void *d3d10_rb_realloc(void *ptr, size_t size)
1976 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
1979 static void d3d10_rb_free(void *ptr)
1981 HeapFree(GetProcessHeap(), 0, ptr);
1984 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
1986 const D3D10_SAMPLER_DESC *ka = key;
1987 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
1989 return memcmp(ka, kb, sizeof(*ka));
1992 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
1994 d3d10_rb_alloc,
1995 d3d10_rb_realloc,
1996 d3d10_rb_free,
1997 d3d10_sampler_state_compare,
2000 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2002 const D3D10_BLEND_DESC *ka = key;
2003 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2005 return memcmp(ka, kb, sizeof(*ka));
2008 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2010 d3d10_rb_alloc,
2011 d3d10_rb_realloc,
2012 d3d10_rb_free,
2013 d3d10_blend_state_compare,
2016 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2018 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2019 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2020 const struct d3d10_depthstencil_state, entry)->desc;
2022 return memcmp(ka, kb, sizeof(*ka));
2025 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2027 d3d10_rb_alloc,
2028 d3d10_rb_realloc,
2029 d3d10_rb_free,
2030 d3d10_depthstencil_state_compare,
2033 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2035 const D3D10_RASTERIZER_DESC *ka = key;
2036 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2038 return memcmp(ka, kb, sizeof(*ka));
2041 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2043 d3d10_rb_alloc,
2044 d3d10_rb_realloc,
2045 d3d10_rb_free,
2046 d3d10_rasterizer_state_compare,
2049 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2051 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2052 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2053 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2054 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2055 device->refcount = 1;
2056 /* COM aggregation always takes place */
2057 device->outer_unk = outer_unknown;
2059 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2061 WARN("Failed to initialize blend state rbtree.\n");
2062 return E_FAIL;
2065 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2067 WARN("Failed to initialize depthstencil state rbtree.\n");
2068 wine_rb_destroy(&device->blend_states, NULL, NULL);
2069 return E_FAIL;
2072 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2074 WARN("Failed to initialize rasterizer state rbtree.\n");
2075 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2076 wine_rb_destroy(&device->blend_states, NULL, NULL);
2077 return E_FAIL;
2080 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2082 WARN("Failed to initialize sampler state rbtree.\n");
2083 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2084 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2085 wine_rb_destroy(&device->blend_states, NULL, NULL);
2086 return E_FAIL;
2089 return S_OK;