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
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,
44 struct d3d10_device *This = impl_from_IUnknown(iface);
46 TRACE("iface %p, riid %s, ppv %p\n", iface, debugstr_guid(riid), ppv);
48 if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3D10Device))
49 *ppv = &This->ID3D10Device_iface;
50 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
51 *ppv = &This->IWineDXGIDeviceParent_iface;
54 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
59 IUnknown_AddRef((IUnknown*)*ppv);
63 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
65 struct d3d10_device *This = impl_from_IUnknown(iface);
66 ULONG refcount = InterlockedIncrement(&This->refcount);
68 TRACE("%p increasing refcount to %u\n", This, refcount);
73 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
75 struct d3d10_device *device = impl_from_IUnknown(iface);
76 ULONG refcount = InterlockedDecrement(&device->refcount);
78 TRACE("%p decreasing refcount to %u.\n", device, refcount);
82 if (device->wined3d_device)
83 wined3d_device_decref(device->wined3d_device);
84 wine_rb_destroy(&device->sampler_states, NULL, NULL);
85 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
86 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
87 wine_rb_destroy(&device->blend_states, NULL, NULL);
93 /* IUnknown methods */
95 static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device *iface)
97 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device_iface);
100 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid,
103 struct d3d10_device *This = impl_from_ID3D10Device(iface);
104 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
107 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
109 struct d3d10_device *This = impl_from_ID3D10Device(iface);
110 return IUnknown_AddRef(This->outer_unk);
113 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
115 struct d3d10_device *This = impl_from_ID3D10Device(iface);
116 return IUnknown_Release(This->outer_unk);
119 /* ID3D10Device methods */
121 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
122 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
124 struct d3d10_device *device = impl_from_ID3D10Device(iface);
127 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
128 iface, start_slot, buffer_count, buffers);
130 for (i = 0; i < buffer_count; ++i)
132 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
134 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
135 buffer ? buffer->wined3d_buffer : NULL);
139 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device *iface,
140 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
142 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
143 iface, start_slot, view_count, views);
146 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface,
147 ID3D10PixelShader *shader)
149 struct d3d10_device *This = impl_from_ID3D10Device(iface);
150 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
152 TRACE("iface %p, shader %p\n", iface, shader);
154 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
157 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface,
158 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
160 struct d3d10_device *device = impl_from_ID3D10Device(iface);
163 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
164 iface, start_slot, sampler_count, samplers);
166 for (i = 0; i < sampler_count; ++i)
168 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
170 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
171 sampler ? sampler->wined3d_sampler : NULL);
175 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface,
176 ID3D10VertexShader *shader)
178 struct d3d10_device *This = impl_from_ID3D10Device(iface);
179 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
181 TRACE("iface %p, shader %p\n", iface, shader);
183 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
186 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface, UINT index_count,
187 UINT start_index_location, INT base_vertex_location)
189 struct d3d10_device *This = impl_from_ID3D10Device(iface);
191 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
192 iface, index_count, start_index_location, base_vertex_location);
194 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
195 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
198 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface, UINT vertex_count,
199 UINT start_vertex_location)
201 struct d3d10_device *This = impl_from_ID3D10Device(iface);
203 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
204 iface, vertex_count, start_vertex_location);
206 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
209 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
210 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
212 struct d3d10_device *device = impl_from_ID3D10Device(iface);
215 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
216 iface, start_slot, buffer_count, buffers);
218 for (i = 0; i < buffer_count; ++i)
220 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
222 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
223 buffer ? buffer->wined3d_buffer : NULL);
227 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface,
228 ID3D10InputLayout *input_layout)
230 struct d3d10_device *This = impl_from_ID3D10Device(iface);
231 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
233 TRACE("iface %p, input_layout %p\n", iface, input_layout);
235 wined3d_device_set_vertex_declaration(This->wined3d_device,
236 layout ? layout->wined3d_decl : NULL);
239 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *iface, UINT start_slot,
240 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
242 struct d3d10_device *This = impl_from_ID3D10Device(iface);
245 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
246 iface, start_slot, buffer_count, buffers, strides, offsets);
248 for (i = 0; i < buffer_count; ++i)
250 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
252 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
253 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
257 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
258 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
260 struct d3d10_device *This = impl_from_ID3D10Device(iface);
261 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
263 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
264 iface, buffer, debug_dxgi_format(format), offset);
266 wined3d_device_set_index_buffer(This->wined3d_device,
267 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
268 wined3dformat_from_dxgi_format(format));
269 if (offset) FIXME("offset %u not supported.\n", offset);
272 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device *iface,
273 UINT instance_index_count, UINT instance_count, UINT start_index_location,
274 INT base_vertex_location, UINT start_instance_location)
276 struct d3d10_device *device = impl_from_ID3D10Device(iface);
278 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
279 "\tbase_vertex_location %d, start_instance_location %u.\n",
280 iface, instance_index_count, instance_count, start_index_location,
281 base_vertex_location, start_instance_location);
283 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
284 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
285 instance_index_count, start_instance_location, instance_count);
288 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device *iface,
289 UINT instance_vertex_count, UINT instance_count,
290 UINT start_vertex_location, UINT start_instance_location)
292 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
293 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
294 start_vertex_location, start_instance_location);
297 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
298 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
300 struct d3d10_device *device = impl_from_ID3D10Device(iface);
303 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
304 iface, start_slot, buffer_count, buffers);
306 for (i = 0; i < buffer_count; ++i)
308 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
310 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
311 buffer ? buffer->wined3d_buffer : NULL);
315 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
317 struct d3d10_device *device = impl_from_ID3D10Device(iface);
318 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
320 TRACE("iface %p, shader %p.\n", iface, shader);
322 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
325 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface,
326 D3D10_PRIMITIVE_TOPOLOGY topology)
328 struct d3d10_device *This = impl_from_ID3D10Device(iface);
330 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
332 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
335 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
336 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
338 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
339 iface, start_slot, view_count, views);
342 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
343 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
345 struct d3d10_device *device = impl_from_ID3D10Device(iface);
348 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
349 iface, start_slot, sampler_count, samplers);
351 for (i = 0; i < sampler_count; ++i)
353 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
355 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
356 sampler ? sampler->wined3d_sampler : NULL);
360 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
362 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
365 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
366 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
368 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
369 iface, start_slot, view_count, views);
372 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
373 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
375 struct d3d10_device *device = impl_from_ID3D10Device(iface);
378 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
379 iface, start_slot, sampler_count, samplers);
381 for (i = 0; i < sampler_count; ++i)
383 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
385 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
386 sampler ? sampler->wined3d_sampler : NULL);
390 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device *iface,
391 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
392 ID3D10DepthStencilView *depth_stencil_view)
394 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
395 iface, render_target_view_count, render_target_views, depth_stencil_view);
398 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
399 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
401 struct d3d10_device *device = impl_from_ID3D10Device(iface);
403 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
404 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
406 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
407 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
408 device->sample_mask = sample_mask;
411 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
412 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
414 struct d3d10_device *device = impl_from_ID3D10Device(iface);
416 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
417 iface, depth_stencil_state, stencil_ref);
419 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
420 device->stencil_ref = stencil_ref;
423 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
424 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
426 struct d3d10_device *device = impl_from_ID3D10Device(iface);
427 unsigned int count, i;
429 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
431 count = min(target_count, 4);
432 for (i = 0; i < count; ++i)
434 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
436 wined3d_device_set_stream_output(device->wined3d_device, i,
437 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
440 for (i = count; i < 4; ++i)
442 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
446 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
448 FIXME("iface %p stub!\n", iface);
451 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
453 struct d3d10_device *device = impl_from_ID3D10Device(iface);
455 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
457 device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
460 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
461 UINT viewport_count, const D3D10_VIEWPORT *viewports)
463 struct d3d10_device *device = impl_from_ID3D10Device(iface);
464 struct wined3d_viewport wined3d_vp;
466 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
468 if (viewport_count > 1)
469 FIXME("Multiple viewports not implemented.\n");
474 wined3d_vp.x = viewports[0].TopLeftX;
475 wined3d_vp.y = viewports[0].TopLeftY;
476 wined3d_vp.width = viewports[0].Width;
477 wined3d_vp.height = viewports[0].Height;
478 wined3d_vp.min_z = viewports[0].MinDepth;
479 wined3d_vp.max_z = viewports[0].MaxDepth;
481 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
484 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
485 UINT rect_count, const D3D10_RECT *rects)
487 struct d3d10_device *device = impl_from_ID3D10Device(iface);
489 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
492 FIXME("Multiple scissor rects not implemented.\n");
497 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
500 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device *iface,
501 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
502 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
504 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
505 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
506 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
507 src_resource, src_subresource_idx, src_box);
510 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
511 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
513 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
516 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface,
517 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
518 const void *data, UINT row_pitch, UINT depth_pitch)
520 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
521 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
524 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
525 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
527 struct d3d10_device *This = impl_from_ID3D10Device(iface);
528 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
529 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
531 TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
532 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
534 wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
537 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
538 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
540 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
541 iface, depth_stencil_view, flags, depth, stencil);
544 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
546 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
549 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device *iface,
550 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
551 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
553 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
554 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
555 iface, dst_resource, dst_subresource_idx,
556 src_resource, src_subresource_idx, debug_dxgi_format(format));
559 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
560 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
562 struct d3d10_device *device = impl_from_ID3D10Device(iface);
565 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
566 iface, start_slot, buffer_count, buffers);
568 for (i = 0; i < buffer_count; ++i)
570 struct wined3d_buffer *wined3d_buffer;
571 struct d3d10_buffer *buffer_impl;
573 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
579 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
580 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
581 ID3D10Buffer_AddRef(buffers[i]);
585 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
586 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
588 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
589 iface, start_slot, view_count, views);
592 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
594 struct d3d10_device *device = impl_from_ID3D10Device(iface);
595 struct d3d10_pixel_shader *shader_impl;
596 struct wined3d_shader *wined3d_shader;
598 TRACE("iface %p, shader %p.\n", iface, shader);
600 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
606 shader_impl = wined3d_shader_get_parent(wined3d_shader);
607 *shader = &shader_impl->ID3D10PixelShader_iface;
608 ID3D10PixelShader_AddRef(*shader);
611 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
612 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
614 struct d3d10_device *device = impl_from_ID3D10Device(iface);
617 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
618 iface, start_slot, sampler_count, samplers);
620 for (i = 0; i < sampler_count; ++i)
622 struct d3d10_sampler_state *sampler_impl;
623 struct wined3d_sampler *wined3d_sampler;
625 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
631 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
632 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
633 ID3D10SamplerState_AddRef(samplers[i]);
637 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
639 struct d3d10_device *device = impl_from_ID3D10Device(iface);
640 struct d3d10_vertex_shader *shader_impl;
641 struct wined3d_shader *wined3d_shader;
643 TRACE("iface %p, shader %p.\n", iface, shader);
645 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
651 shader_impl = wined3d_shader_get_parent(wined3d_shader);
652 *shader = &shader_impl->ID3D10VertexShader_iface;
653 ID3D10VertexShader_AddRef(*shader);
656 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
657 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
659 struct d3d10_device *device = impl_from_ID3D10Device(iface);
662 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
663 iface, start_slot, buffer_count, buffers);
665 for (i = 0; i < buffer_count; ++i)
667 struct wined3d_buffer *wined3d_buffer;
668 struct d3d10_buffer *buffer_impl;
670 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
676 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
677 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
678 ID3D10Buffer_AddRef(buffers[i]);
682 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
684 struct d3d10_device *device = impl_from_ID3D10Device(iface);
685 struct wined3d_vertex_declaration *wined3d_declaration;
686 struct d3d10_input_layout *input_layout_impl;
688 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
690 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
692 *input_layout = NULL;
696 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
697 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
698 ID3D10InputLayout_AddRef(*input_layout);
701 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
702 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
704 struct d3d10_device *device = impl_from_ID3D10Device(iface);
707 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
708 iface, start_slot, buffer_count, buffers, strides, offsets);
710 for (i = 0; i < buffer_count; ++i)
712 struct wined3d_buffer *wined3d_buffer;
713 struct d3d10_buffer *buffer_impl;
715 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
716 &wined3d_buffer, &offsets[i], &strides[i])))
717 ERR("Failed to get vertex buffer.\n");
725 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
726 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
727 ID3D10Buffer_AddRef(buffers[i]);
731 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
732 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
734 struct d3d10_device *device = impl_from_ID3D10Device(iface);
735 enum wined3d_format_id wined3d_format;
736 struct wined3d_buffer *wined3d_buffer;
737 struct d3d10_buffer *buffer_impl;
739 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
741 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
742 *format = dxgi_format_from_wined3dformat(wined3d_format);
743 *offset = 0; /* FIXME */
750 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
751 *buffer = &buffer_impl->ID3D10Buffer_iface;
752 ID3D10Buffer_AddRef(*buffer);
755 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
756 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
758 struct d3d10_device *device = impl_from_ID3D10Device(iface);
761 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
762 iface, start_slot, buffer_count, buffers);
764 for (i = 0; i < buffer_count; ++i)
766 struct wined3d_buffer *wined3d_buffer;
767 struct d3d10_buffer *buffer_impl;
769 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
775 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
776 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
777 ID3D10Buffer_AddRef(buffers[i]);
781 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
783 struct d3d10_device *device = impl_from_ID3D10Device(iface);
784 struct d3d10_geometry_shader *shader_impl;
785 struct wined3d_shader *wined3d_shader;
787 TRACE("iface %p, shader %p.\n", iface, shader);
789 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
795 shader_impl = wined3d_shader_get_parent(wined3d_shader);
796 *shader = &shader_impl->ID3D10GeometryShader_iface;
797 ID3D10GeometryShader_AddRef(*shader);
800 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface,
801 D3D10_PRIMITIVE_TOPOLOGY *topology)
803 struct d3d10_device *This = impl_from_ID3D10Device(iface);
805 TRACE("iface %p, topology %p\n", iface, topology);
807 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
810 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
811 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
813 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
814 iface, start_slot, view_count, views);
817 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
818 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
820 struct d3d10_device *device = impl_from_ID3D10Device(iface);
823 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
824 iface, start_slot, sampler_count, samplers);
826 for (i = 0; i < sampler_count; ++i)
828 struct d3d10_sampler_state *sampler_impl;
829 struct wined3d_sampler *wined3d_sampler;
831 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
837 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
838 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
839 ID3D10SamplerState_AddRef(samplers[i]);
843 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
844 ID3D10Predicate **predicate, BOOL *value)
846 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
849 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
850 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
852 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
853 iface, start_slot, view_count, views);
856 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
857 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
859 struct d3d10_device *device = impl_from_ID3D10Device(iface);
862 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
863 iface, start_slot, sampler_count, samplers);
865 for (i = 0; i < sampler_count; ++i)
867 struct d3d10_sampler_state *sampler_impl;
868 struct wined3d_sampler *wined3d_sampler;
870 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
876 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
877 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
878 ID3D10SamplerState_AddRef(samplers[i]);
882 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
883 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
885 FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
886 iface, view_count, render_target_views, depth_stencil_view);
889 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
890 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
892 struct d3d10_device *device = impl_from_ID3D10Device(iface);
894 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
895 iface, blend_state, blend_factor, sample_mask);
897 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
898 ID3D10BlendState_AddRef(*blend_state);
899 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
900 *sample_mask = device->sample_mask;
903 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
904 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
906 struct d3d10_device *device = impl_from_ID3D10Device(iface);
908 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
909 iface, depth_stencil_state, stencil_ref);
911 if ((*depth_stencil_state = device->depth_stencil_state
912 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
913 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
914 *stencil_ref = device->stencil_ref;
917 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
918 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
920 struct d3d10_device *device = impl_from_ID3D10Device(iface);
923 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
924 iface, buffer_count, buffers, offsets);
926 for (i = 0; i < buffer_count; ++i)
928 struct wined3d_buffer *wined3d_buffer;
929 struct d3d10_buffer *buffer_impl;
931 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
937 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
938 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
939 ID3D10Buffer_AddRef(buffers[i]);
943 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
945 struct d3d10_device *device = impl_from_ID3D10Device(iface);
947 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
949 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
950 ID3D10RasterizerState_AddRef(*rasterizer_state);
953 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
954 UINT *viewport_count, D3D10_VIEWPORT *viewports)
956 struct d3d10_device *device = impl_from_ID3D10Device(iface);
957 struct wined3d_viewport wined3d_vp;
959 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
967 if (!*viewport_count)
970 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
972 viewports[0].TopLeftX = wined3d_vp.x;
973 viewports[0].TopLeftY = wined3d_vp.y;
974 viewports[0].Width = wined3d_vp.width;
975 viewports[0].Height = wined3d_vp.height;
976 viewports[0].MinDepth = wined3d_vp.min_z;
977 viewports[0].MaxDepth = wined3d_vp.max_z;
979 if (*viewport_count > 1)
980 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
983 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
985 struct d3d10_device *device = impl_from_ID3D10Device(iface);
987 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
998 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1000 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1003 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
1005 FIXME("iface %p stub!\n", iface);
1010 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
1012 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1017 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
1019 FIXME("iface %p stub!\n", iface);
1024 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
1025 REFGUID guid, UINT *data_size, void *data)
1027 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1028 iface, debugstr_guid(guid), data_size, data);
1033 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
1034 REFGUID guid, UINT data_size, const void *data)
1036 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1037 iface, debugstr_guid(guid), data_size, data);
1042 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
1043 REFGUID guid, const IUnknown *data)
1045 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1050 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
1052 FIXME("iface %p stub!\n", iface);
1055 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
1057 FIXME("iface %p stub!\n", iface);
1060 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
1061 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1063 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1064 struct d3d10_buffer *object;
1067 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1069 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1071 return E_OUTOFMEMORY;
1073 hr = d3d10_buffer_init(object, This, desc, data);
1076 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1077 HeapFree(GetProcessHeap(), 0, object);
1081 *buffer = &object->ID3D10Buffer_iface;
1083 TRACE("Created ID3D10Buffer %p\n", object);
1088 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
1089 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1091 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1096 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
1097 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1098 ID3D10Texture2D **texture)
1100 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1101 struct d3d10_texture2d *object;
1104 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1106 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1108 return E_OUTOFMEMORY;
1110 hr = d3d10_texture2d_init(object, This, desc);
1113 WARN("Failed to initialize texture, hr %#x.\n", hr);
1114 HeapFree(GetProcessHeap(), 0, object);
1118 *texture = &object->ID3D10Texture2D_iface;
1120 TRACE("Created ID3D10Texture2D %p\n", object);
1125 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
1126 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1127 ID3D10Texture3D **texture)
1129 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1130 struct d3d10_texture3d *object;
1133 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1135 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1137 return E_OUTOFMEMORY;
1139 hr = d3d10_texture3d_init(object, device, desc);
1142 WARN("Failed to initialize texture, hr %#x.\n", hr);
1143 HeapFree(GetProcessHeap(), 0, object);
1147 TRACE("Created 3D texture %p.\n", object);
1148 *texture = &object->ID3D10Texture3D_iface;
1153 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
1154 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1156 struct d3d10_shader_resource_view *object;
1159 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1161 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1163 return E_OUTOFMEMORY;
1165 if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
1167 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1168 HeapFree(GetProcessHeap(), 0, object);
1172 TRACE("Created shader resource view %p.\n", object);
1173 *view = &object->ID3D10ShaderResourceView_iface;
1178 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
1179 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1181 struct d3d10_rendertarget_view *object;
1184 TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1186 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1188 return E_OUTOFMEMORY;
1190 hr = d3d10_rendertarget_view_init(object, resource, desc);
1193 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1194 HeapFree(GetProcessHeap(), 0, object);
1198 TRACE("Created rendertarget view %p.\n", object);
1199 *view = &object->ID3D10RenderTargetView_iface;
1204 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
1205 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1207 struct d3d10_depthstencil_view *object;
1210 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1212 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1214 return E_OUTOFMEMORY;
1216 if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
1218 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1219 HeapFree(GetProcessHeap(), 0, object);
1223 TRACE("Created depthstencil view %p.\n", object);
1224 *view = &object->ID3D10DepthStencilView_iface;
1229 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *iface,
1230 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1231 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1232 ID3D10InputLayout **input_layout)
1234 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1235 struct d3d10_input_layout *object;
1238 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1239 "\tshader_byte_code_length %lu, input_layout %p\n",
1240 iface, element_descs, element_count, shader_byte_code,
1241 shader_byte_code_length, input_layout);
1243 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1245 return E_OUTOFMEMORY;
1247 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1248 shader_byte_code, shader_byte_code_length);
1251 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1252 HeapFree(GetProcessHeap(), 0, object);
1256 TRACE("Created input layout %p.\n", object);
1257 *input_layout = &object->ID3D10InputLayout_iface;
1262 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
1263 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1265 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1266 struct d3d10_vertex_shader *object;
1269 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1270 iface, byte_code, byte_code_length, shader);
1272 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1274 return E_OUTOFMEMORY;
1276 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1279 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1280 HeapFree(GetProcessHeap(), 0, object);
1284 TRACE("Created vertex shader %p.\n", object);
1285 *shader = &object->ID3D10VertexShader_iface;
1290 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
1291 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1293 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1294 struct d3d10_geometry_shader *object;
1297 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1298 iface, byte_code, byte_code_length, shader);
1300 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1302 return E_OUTOFMEMORY;
1304 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1307 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1308 HeapFree(GetProcessHeap(), 0, object);
1312 TRACE("Created geometry shader %p.\n", object);
1313 *shader = &object->ID3D10GeometryShader_iface;
1318 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device *iface,
1319 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1320 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1322 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1323 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1324 iface, byte_code, byte_code_length, output_stream_decls,
1325 output_stream_decl_count, output_stream_stride, shader);
1330 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
1331 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1333 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1334 struct d3d10_pixel_shader *object;
1337 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1338 iface, byte_code, byte_code_length, shader);
1340 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1342 return E_OUTOFMEMORY;
1344 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1347 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1348 HeapFree(GetProcessHeap(), 0, object);
1352 TRACE("Created pixel shader %p.\n", object);
1353 *shader = &object->ID3D10PixelShader_iface;
1358 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device *iface,
1359 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1361 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1362 struct d3d10_blend_state *object;
1363 struct wine_rb_entry *entry;
1366 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1369 return E_INVALIDARG;
1371 if ((entry = wine_rb_get(&device->blend_states, desc)))
1373 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1375 TRACE("Returning existing blend state %p.\n", object);
1376 *blend_state = &object->ID3D10BlendState_iface;
1377 ID3D10BlendState_AddRef(*blend_state);
1382 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1384 return E_OUTOFMEMORY;
1386 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1388 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1389 HeapFree(GetProcessHeap(), 0, object);
1393 TRACE("Created blend state %p.\n", object);
1394 *blend_state = &object->ID3D10BlendState_iface;
1399 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1400 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1402 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1403 struct d3d10_depthstencil_state *object;
1404 struct wine_rb_entry *entry;
1407 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1410 return E_INVALIDARG;
1412 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1414 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1416 TRACE("Returning existing depthstencil state %p.\n", object);
1417 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1418 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1423 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1425 return E_OUTOFMEMORY;
1427 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1429 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1430 HeapFree(GetProcessHeap(), 0, object);
1434 TRACE("Created depthstencil state %p.\n", object);
1435 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1440 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1441 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1443 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1444 struct d3d10_rasterizer_state *object;
1445 struct wine_rb_entry *entry;
1448 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1451 return E_INVALIDARG;
1453 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1455 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1457 TRACE("Returning existing rasterizer state %p.\n", object);
1458 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1459 ID3D10RasterizerState_AddRef(*rasterizer_state);
1465 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1467 return E_OUTOFMEMORY;
1469 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1471 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1472 HeapFree(GetProcessHeap(), 0, object);
1476 TRACE("Created rasterizer state %p.\n", object);
1477 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1482 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1483 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1485 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1486 struct d3d10_sampler_state *object;
1487 struct wine_rb_entry *entry;
1490 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1493 return E_INVALIDARG;
1495 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1497 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1499 TRACE("Returning existing sampler state %p.\n", object);
1500 *sampler_state = &object->ID3D10SamplerState_iface;
1501 ID3D10SamplerState_AddRef(*sampler_state);
1506 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1508 return E_OUTOFMEMORY;
1510 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1512 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1513 HeapFree(GetProcessHeap(), 0, object);
1517 TRACE("Created sampler state %p.\n", object);
1518 *sampler_state = &object->ID3D10SamplerState_iface;
1523 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1524 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1526 struct d3d10_query *object;
1529 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1531 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1533 return E_OUTOFMEMORY;
1535 hr = d3d10_query_init(object);
1538 WARN("Failed to initialize query, hr %#x.\n", hr);
1539 HeapFree(GetProcessHeap(), 0, object);
1543 TRACE("Created query %p.\n", object);
1544 *query = &object->ID3D10Query_iface;
1549 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1550 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1552 FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1557 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1558 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1560 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1565 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1566 DXGI_FORMAT format, UINT *format_support)
1568 FIXME("iface %p, format %s, format_support %p stub!\n",
1569 iface, debug_dxgi_format(format), format_support);
1574 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1575 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1577 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1578 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1583 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1585 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1588 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1589 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1590 UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1592 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1593 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1594 iface, desc, type, active_counters, name, name_length,
1595 units, units_length, description, description_length);
1600 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1602 FIXME("iface %p stub!\n", iface);
1607 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1608 HANDLE resource_handle, REFIID guid, void **resource)
1610 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1611 iface, resource_handle, debugstr_guid(guid), resource);
1616 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1618 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1621 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1623 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1626 static const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1628 /* IUnknown methods */
1629 d3d10_device_QueryInterface,
1630 d3d10_device_AddRef,
1631 d3d10_device_Release,
1632 /* ID3D10Device methods */
1633 d3d10_device_VSSetConstantBuffers,
1634 d3d10_device_PSSetShaderResources,
1635 d3d10_device_PSSetShader,
1636 d3d10_device_PSSetSamplers,
1637 d3d10_device_VSSetShader,
1638 d3d10_device_DrawIndexed,
1640 d3d10_device_PSSetConstantBuffers,
1641 d3d10_device_IASetInputLayout,
1642 d3d10_device_IASetVertexBuffers,
1643 d3d10_device_IASetIndexBuffer,
1644 d3d10_device_DrawIndexedInstanced,
1645 d3d10_device_DrawInstanced,
1646 d3d10_device_GSSetConstantBuffers,
1647 d3d10_device_GSSetShader,
1648 d3d10_device_IASetPrimitiveTopology,
1649 d3d10_device_VSSetShaderResources,
1650 d3d10_device_VSSetSamplers,
1651 d3d10_device_SetPredication,
1652 d3d10_device_GSSetShaderResources,
1653 d3d10_device_GSSetSamplers,
1654 d3d10_device_OMSetRenderTargets,
1655 d3d10_device_OMSetBlendState,
1656 d3d10_device_OMSetDepthStencilState,
1657 d3d10_device_SOSetTargets,
1658 d3d10_device_DrawAuto,
1659 d3d10_device_RSSetState,
1660 d3d10_device_RSSetViewports,
1661 d3d10_device_RSSetScissorRects,
1662 d3d10_device_CopySubresourceRegion,
1663 d3d10_device_CopyResource,
1664 d3d10_device_UpdateSubresource,
1665 d3d10_device_ClearRenderTargetView,
1666 d3d10_device_ClearDepthStencilView,
1667 d3d10_device_GenerateMips,
1668 d3d10_device_ResolveSubresource,
1669 d3d10_device_VSGetConstantBuffers,
1670 d3d10_device_PSGetShaderResources,
1671 d3d10_device_PSGetShader,
1672 d3d10_device_PSGetSamplers,
1673 d3d10_device_VSGetShader,
1674 d3d10_device_PSGetConstantBuffers,
1675 d3d10_device_IAGetInputLayout,
1676 d3d10_device_IAGetVertexBuffers,
1677 d3d10_device_IAGetIndexBuffer,
1678 d3d10_device_GSGetConstantBuffers,
1679 d3d10_device_GSGetShader,
1680 d3d10_device_IAGetPrimitiveTopology,
1681 d3d10_device_VSGetShaderResources,
1682 d3d10_device_VSGetSamplers,
1683 d3d10_device_GetPredication,
1684 d3d10_device_GSGetShaderResources,
1685 d3d10_device_GSGetSamplers,
1686 d3d10_device_OMGetRenderTargets,
1687 d3d10_device_OMGetBlendState,
1688 d3d10_device_OMGetDepthStencilState,
1689 d3d10_device_SOGetTargets,
1690 d3d10_device_RSGetState,
1691 d3d10_device_RSGetViewports,
1692 d3d10_device_RSGetScissorRects,
1693 d3d10_device_GetDeviceRemovedReason,
1694 d3d10_device_SetExceptionMode,
1695 d3d10_device_GetExceptionMode,
1696 d3d10_device_GetPrivateData,
1697 d3d10_device_SetPrivateData,
1698 d3d10_device_SetPrivateDataInterface,
1699 d3d10_device_ClearState,
1701 d3d10_device_CreateBuffer,
1702 d3d10_device_CreateTexture1D,
1703 d3d10_device_CreateTexture2D,
1704 d3d10_device_CreateTexture3D,
1705 d3d10_device_CreateShaderResourceView,
1706 d3d10_device_CreateRenderTargetView,
1707 d3d10_device_CreateDepthStencilView,
1708 d3d10_device_CreateInputLayout,
1709 d3d10_device_CreateVertexShader,
1710 d3d10_device_CreateGeometryShader,
1711 d3d10_device_CreateGeometryShaderWithStreamOutput,
1712 d3d10_device_CreatePixelShader,
1713 d3d10_device_CreateBlendState,
1714 d3d10_device_CreateDepthStencilState,
1715 d3d10_device_CreateRasterizerState,
1716 d3d10_device_CreateSamplerState,
1717 d3d10_device_CreateQuery,
1718 d3d10_device_CreatePredicate,
1719 d3d10_device_CreateCounter,
1720 d3d10_device_CheckFormatSupport,
1721 d3d10_device_CheckMultisampleQualityLevels,
1722 d3d10_device_CheckCounterInfo,
1723 d3d10_device_CheckCounter,
1724 d3d10_device_GetCreationFlags,
1725 d3d10_device_OpenSharedResource,
1726 d3d10_device_SetTextFilterSize,
1727 d3d10_device_GetTextFilterSize,
1730 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1732 /* IUnknown methods */
1733 d3d10_device_inner_QueryInterface,
1734 d3d10_device_inner_AddRef,
1735 d3d10_device_inner_Release,
1738 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1740 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1742 d3d10_subresource_destroyed,
1745 /* IWineDXGIDeviceParent IUnknown methods */
1747 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1749 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1752 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1753 REFIID riid, void **ppv)
1755 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1756 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1759 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1761 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1762 return IUnknown_AddRef(device->outer_unk);
1765 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1767 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1768 return IUnknown_Release(device->outer_unk);
1771 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1772 IWineDXGIDeviceParent *iface)
1774 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1775 return &device->device_parent;
1778 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1780 /* IUnknown methods */
1781 dxgi_device_parent_QueryInterface,
1782 dxgi_device_parent_AddRef,
1783 dxgi_device_parent_Release,
1784 /* IWineDXGIDeviceParent methods */
1785 dxgi_device_parent_get_wined3d_device_parent,
1788 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1790 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1793 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1794 struct wined3d_device *wined3d_device)
1796 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1798 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1800 wined3d_device_incref(wined3d_device);
1801 device->wined3d_device = wined3d_device;
1804 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1806 TRACE("device_parent %p.\n", device_parent);
1809 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
1810 void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
1811 enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
1813 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1815 TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
1816 "\tpool %#x, sub_resource_idx %u, surface %p.\n",
1817 device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
1819 return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
1820 WINED3D_MULTISAMPLE_NONE, 0, 0, container_parent, &d3d10_null_wined3d_parent_ops, surface);
1823 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1824 void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
1825 enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
1827 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1828 struct wined3d_resource *sub_resource;
1829 struct d3d10_texture2d *texture;
1830 D3D10_TEXTURE2D_DESC desc;
1833 FIXME("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
1834 "\tmultisample_type %#x, multisample_quality %u, surface %p partial stub!\n",
1835 device_parent, container_parent, width, height, format_id, usage,
1836 multisample_type, multisample_quality, surface);
1838 FIXME("Implement DXGI<->wined3d usage conversion\n");
1841 desc.Height = height;
1844 desc.Format = dxgi_format_from_wined3dformat(format_id);
1845 desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1846 desc.SampleDesc.Quality = multisample_quality;
1847 desc.Usage = D3D10_USAGE_DEFAULT;
1848 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1849 desc.CPUAccessFlags = 0;
1852 hr = d3d10_device_CreateTexture2D(&device->ID3D10Device_iface, &desc, NULL,
1853 (ID3D10Texture2D **)&texture);
1856 ERR("CreateTexture2D failed, returning %#x\n", hr);
1860 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1861 *surface = wined3d_surface_from_resource(sub_resource);
1862 wined3d_surface_incref(*surface);
1863 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1868 static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
1869 void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
1870 enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
1874 TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
1875 "format %#x, pool %#x, usage %#x, volume %p.\n",
1876 device_parent, container_parent, width, height, depth,
1877 format, pool, usage, volume);
1879 hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
1880 width, height, depth, usage, format, pool, NULL, &d3d10_subresource_parent_ops, volume);
1883 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
1890 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
1891 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
1893 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1894 IWineDXGIDevice *wine_device;
1897 TRACE("device_parent %p, desc %p, swapchain %p\n", device_parent, desc, swapchain);
1899 hr = d3d10_device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice,
1900 (void **)&wine_device);
1903 ERR("Device should implement IWineDXGIDevice\n");
1907 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
1908 IWineDXGIDevice_Release(wine_device);
1911 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1918 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
1920 device_parent_wined3d_device_created,
1921 device_parent_mode_changed,
1922 device_parent_create_swapchain_surface,
1923 device_parent_create_texture_surface,
1924 device_parent_create_volume,
1925 device_parent_create_swapchain,
1928 static void *d3d10_rb_alloc(size_t size)
1930 return HeapAlloc(GetProcessHeap(), 0, size);
1933 static void *d3d10_rb_realloc(void *ptr, size_t size)
1935 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
1938 static void d3d10_rb_free(void *ptr)
1940 HeapFree(GetProcessHeap(), 0, ptr);
1943 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
1945 const D3D10_SAMPLER_DESC *ka = key;
1946 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
1948 return memcmp(ka, kb, sizeof(*ka));
1951 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
1956 d3d10_sampler_state_compare,
1959 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
1961 const D3D10_BLEND_DESC *ka = key;
1962 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
1964 return memcmp(ka, kb, sizeof(*ka));
1967 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
1972 d3d10_blend_state_compare,
1975 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
1977 const D3D10_DEPTH_STENCIL_DESC *ka = key;
1978 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
1979 const struct d3d10_depthstencil_state, entry)->desc;
1981 return memcmp(ka, kb, sizeof(*ka));
1984 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
1989 d3d10_depthstencil_state_compare,
1992 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
1994 const D3D10_RASTERIZER_DESC *ka = key;
1995 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
1997 return memcmp(ka, kb, sizeof(*ka));
2000 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2005 d3d10_rasterizer_state_compare,
2008 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2010 device->ID3D10Device_iface.lpVtbl = &d3d10_device_vtbl;
2011 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2012 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2013 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2014 device->refcount = 1;
2015 /* COM aggregation always takes place */
2016 device->outer_unk = outer_unknown;
2018 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2020 WARN("Failed to initialize blend state rbtree.\n");
2024 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2026 WARN("Failed to initialize depthstencil state rbtree.\n");
2027 wine_rb_destroy(&device->blend_states, NULL, NULL);
2031 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2033 WARN("Failed to initialize rasterizer state rbtree.\n");
2034 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2035 wine_rb_destroy(&device->blend_states, NULL, NULL);
2039 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2041 WARN("Failed to initialize sampler state rbtree.\n");
2042 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2043 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2044 wine_rb_destroy(&device->blend_states, NULL, NULL);