d3d10core: Implement d3d10_device_SetPredication().
[wine/multimedia.git] / dlls / d3d10core / device.c
blob7dc65437b848740c8bf3c027a8cba21ba3a72664
1 /*
2 * Copyright 2008-2012 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
23 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 static void STDMETHODCALLTYPE d3d10_null_wined3d_object_destroyed(void *parent) {}
29 const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops =
31 d3d10_null_wined3d_object_destroyed,
34 /* Inner IUnknown methods */
36 static inline struct d3d10_device *impl_from_IUnknown(IUnknown *iface)
38 return CONTAINING_RECORD(iface, struct d3d10_device, IUnknown_inner);
41 static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
43 struct d3d10_device *device = impl_from_IUnknown(iface);
45 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
47 if (IsEqualGUID(riid, &IID_ID3D10Device1)
48 || IsEqualGUID(riid, &IID_ID3D10Device)
49 || IsEqualGUID(riid, &IID_IUnknown))
51 *out = &device->ID3D10Device1_iface;
53 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
55 *out = &device->ID3D10Multithread_iface;
57 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
59 *out = &device->IWineDXGIDeviceParent_iface;
61 else
63 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
64 *out = NULL;
65 return E_NOINTERFACE;
68 IUnknown_AddRef((IUnknown *)*out);
69 return S_OK;
72 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
74 struct d3d10_device *This = impl_from_IUnknown(iface);
75 ULONG refcount = InterlockedIncrement(&This->refcount);
77 TRACE("%p increasing refcount to %u\n", This, refcount);
79 return refcount;
82 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
84 struct d3d10_device *device = impl_from_IUnknown(iface);
85 ULONG refcount = InterlockedDecrement(&device->refcount);
87 TRACE("%p decreasing refcount to %u.\n", device, refcount);
89 if (!refcount)
91 if (device->wined3d_device)
92 wined3d_device_decref(device->wined3d_device);
93 wine_rb_destroy(&device->sampler_states, NULL, NULL);
94 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
95 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
96 wine_rb_destroy(&device->blend_states, NULL, NULL);
99 return refcount;
102 /* IUnknown methods */
104 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
105 void **ppv)
107 struct d3d10_device *This = impl_from_ID3D10Device(iface);
108 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
111 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
113 struct d3d10_device *This = impl_from_ID3D10Device(iface);
114 return IUnknown_AddRef(This->outer_unk);
117 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
119 struct d3d10_device *This = impl_from_ID3D10Device(iface);
120 return IUnknown_Release(This->outer_unk);
123 /* ID3D10Device methods */
125 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
126 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
128 struct d3d10_device *device = impl_from_ID3D10Device(iface);
129 unsigned int i;
131 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
132 iface, start_slot, buffer_count, buffers);
134 for (i = 0; i < buffer_count; ++i)
136 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
138 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
139 buffer ? buffer->wined3d_buffer : NULL);
143 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
144 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
146 struct d3d10_device *device = impl_from_ID3D10Device(iface);
147 unsigned int i;
149 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
150 iface, start_slot, view_count, views);
152 for (i = 0; i < view_count; ++i)
154 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
156 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
157 view ? view->wined3d_view : NULL);
161 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
162 ID3D10PixelShader *shader)
164 struct d3d10_device *This = impl_from_ID3D10Device(iface);
165 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
167 TRACE("iface %p, shader %p\n", iface, shader);
169 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
172 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
173 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
175 struct d3d10_device *device = impl_from_ID3D10Device(iface);
176 unsigned int i;
178 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
179 iface, start_slot, sampler_count, samplers);
181 for (i = 0; i < sampler_count; ++i)
183 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
185 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
186 sampler ? sampler->wined3d_sampler : NULL);
190 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
191 ID3D10VertexShader *shader)
193 struct d3d10_device *This = impl_from_ID3D10Device(iface);
194 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
196 TRACE("iface %p, shader %p\n", iface, shader);
198 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
201 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
202 UINT start_index_location, INT base_vertex_location)
204 struct d3d10_device *This = impl_from_ID3D10Device(iface);
206 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
207 iface, index_count, start_index_location, base_vertex_location);
209 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
210 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
213 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
214 UINT start_vertex_location)
216 struct d3d10_device *This = impl_from_ID3D10Device(iface);
218 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
219 iface, vertex_count, start_vertex_location);
221 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
224 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
225 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
227 struct d3d10_device *device = impl_from_ID3D10Device(iface);
228 unsigned int i;
230 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
231 iface, start_slot, buffer_count, buffers);
233 for (i = 0; i < buffer_count; ++i)
235 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
237 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
238 buffer ? buffer->wined3d_buffer : NULL);
242 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
243 ID3D10InputLayout *input_layout)
245 struct d3d10_device *This = impl_from_ID3D10Device(iface);
246 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
248 TRACE("iface %p, input_layout %p\n", iface, input_layout);
250 wined3d_device_set_vertex_declaration(This->wined3d_device,
251 layout ? layout->wined3d_decl : NULL);
254 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
255 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
257 struct d3d10_device *This = impl_from_ID3D10Device(iface);
258 unsigned int i;
260 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
261 iface, start_slot, buffer_count, buffers, strides, offsets);
263 for (i = 0; i < buffer_count; ++i)
265 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
267 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
268 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
272 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
273 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
275 struct d3d10_device *This = impl_from_ID3D10Device(iface);
276 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
278 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
279 iface, buffer, debug_dxgi_format(format), offset);
281 wined3d_device_set_index_buffer(This->wined3d_device,
282 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
283 wined3dformat_from_dxgi_format(format));
284 if (offset) FIXME("offset %u not supported.\n", offset);
287 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
288 UINT instance_index_count, UINT instance_count, UINT start_index_location,
289 INT base_vertex_location, UINT start_instance_location)
291 struct d3d10_device *device = impl_from_ID3D10Device(iface);
293 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
294 "\tbase_vertex_location %d, start_instance_location %u.\n",
295 iface, instance_index_count, instance_count, start_index_location,
296 base_vertex_location, start_instance_location);
298 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
299 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
300 instance_index_count, start_instance_location, instance_count);
303 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
304 UINT instance_vertex_count, UINT instance_count,
305 UINT start_vertex_location, UINT start_instance_location)
307 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
308 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
309 start_vertex_location, start_instance_location);
312 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
313 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
315 struct d3d10_device *device = impl_from_ID3D10Device(iface);
316 unsigned int i;
318 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
319 iface, start_slot, buffer_count, buffers);
321 for (i = 0; i < buffer_count; ++i)
323 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
325 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
326 buffer ? buffer->wined3d_buffer : NULL);
330 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
332 struct d3d10_device *device = impl_from_ID3D10Device(iface);
333 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
335 TRACE("iface %p, shader %p.\n", iface, shader);
337 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
340 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
341 D3D10_PRIMITIVE_TOPOLOGY topology)
343 struct d3d10_device *This = impl_from_ID3D10Device(iface);
345 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
347 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
350 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
351 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
353 struct d3d10_device *device = impl_from_ID3D10Device(iface);
354 unsigned int i;
356 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
357 iface, start_slot, view_count, views);
359 for (i = 0; i < view_count; ++i)
361 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
363 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
364 view ? view->wined3d_view : NULL);
368 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
369 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
371 struct d3d10_device *device = impl_from_ID3D10Device(iface);
372 unsigned int i;
374 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
375 iface, start_slot, sampler_count, samplers);
377 for (i = 0; i < sampler_count; ++i)
379 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
381 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
382 sampler ? sampler->wined3d_sampler : NULL);
386 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
388 struct d3d10_device *device = impl_from_ID3D10Device(iface);
389 struct d3d10_query *query;
391 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
393 query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
394 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
397 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
398 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
400 struct d3d10_device *device = impl_from_ID3D10Device(iface);
401 unsigned int i;
403 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
404 iface, start_slot, view_count, views);
406 for (i = 0; i < view_count; ++i)
408 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
410 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
411 view ? view->wined3d_view : NULL);
415 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
416 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
418 struct d3d10_device *device = impl_from_ID3D10Device(iface);
419 unsigned int i;
421 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
422 iface, start_slot, sampler_count, samplers);
424 for (i = 0; i < sampler_count; ++i)
426 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
428 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
429 sampler ? sampler->wined3d_sampler : NULL);
433 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
434 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
435 ID3D10DepthStencilView *depth_stencil_view)
437 struct d3d10_device *device = impl_from_ID3D10Device(iface);
438 struct d3d10_depthstencil_view *dsv;
439 unsigned int i;
441 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
442 iface, render_target_view_count, render_target_views, depth_stencil_view);
444 for (i = 0; i < render_target_view_count; ++i)
446 struct d3d10_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
448 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
449 rtv ? rtv->wined3d_view : NULL, FALSE);
451 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
453 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
456 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
457 wined3d_device_set_depth_stencil_view(device->wined3d_device,
458 dsv ? dsv->wined3d_view : NULL);
461 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
462 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
464 struct d3d10_device *device = impl_from_ID3D10Device(iface);
466 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
467 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
469 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
470 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
471 device->sample_mask = sample_mask;
474 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
475 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
477 struct d3d10_device *device = impl_from_ID3D10Device(iface);
479 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
480 iface, depth_stencil_state, stencil_ref);
482 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
483 device->stencil_ref = stencil_ref;
486 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
487 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
489 struct d3d10_device *device = impl_from_ID3D10Device(iface);
490 unsigned int count, i;
492 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
494 count = min(target_count, 4);
495 for (i = 0; i < count; ++i)
497 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
499 wined3d_device_set_stream_output(device->wined3d_device, i,
500 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
503 for (i = count; i < 4; ++i)
505 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
509 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
511 FIXME("iface %p stub!\n", iface);
514 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
516 struct d3d10_device *device = impl_from_ID3D10Device(iface);
517 const D3D10_RASTERIZER_DESC *desc;
519 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
521 if (!(device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state)))
523 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
524 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
525 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
526 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
527 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
528 return;
531 desc = &device->rasterizer_state->desc;
532 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
533 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
534 /* glFrontFace() */
535 if (desc->FrontCounterClockwise)
536 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
537 /* OpenGL style depth bias. */
538 if (desc->DepthBias || desc->SlopeScaledDepthBias)
539 FIXME("Ignoring depth bias.\n");
540 /* GL_DEPTH_CLAMP */
541 if (!desc->DepthClipEnable)
542 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
543 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
544 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
545 wined3d_device_set_render_state(device->wined3d_device,
546 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
549 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
550 UINT viewport_count, const D3D10_VIEWPORT *viewports)
552 struct d3d10_device *device = impl_from_ID3D10Device(iface);
553 struct wined3d_viewport wined3d_vp;
555 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
557 if (viewport_count > 1)
558 FIXME("Multiple viewports not implemented.\n");
560 if (!viewport_count)
561 return;
563 wined3d_vp.x = viewports[0].TopLeftX;
564 wined3d_vp.y = viewports[0].TopLeftY;
565 wined3d_vp.width = viewports[0].Width;
566 wined3d_vp.height = viewports[0].Height;
567 wined3d_vp.min_z = viewports[0].MinDepth;
568 wined3d_vp.max_z = viewports[0].MaxDepth;
570 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
573 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
574 UINT rect_count, const D3D10_RECT *rects)
576 struct d3d10_device *device = impl_from_ID3D10Device(iface);
578 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
580 if (rect_count > 1)
581 FIXME("Multiple scissor rects not implemented.\n");
583 if (!rect_count)
584 return;
586 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
589 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
590 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
591 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
593 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
594 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
595 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
596 src_resource, src_subresource_idx, src_box);
599 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
600 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
602 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
603 struct d3d10_device *device = impl_from_ID3D10Device(iface);
605 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
607 wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
608 wined3d_src_resource = wined3d_resource_from_resource(src_resource);
609 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
612 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
613 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
614 const void *data, UINT row_pitch, UINT depth_pitch)
616 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
617 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
620 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
621 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
623 struct d3d10_device *device = impl_from_ID3D10Device(iface);
624 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
625 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
626 HRESULT hr;
628 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
629 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
631 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
632 ERR("Failed to clear view, hr %#x.\n", hr);
635 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
636 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
638 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
639 iface, depth_stencil_view, flags, depth, stencil);
642 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
643 ID3D10ShaderResourceView *shader_resource_view)
645 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
648 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
649 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
650 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
652 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
653 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
654 iface, dst_resource, dst_subresource_idx,
655 src_resource, src_subresource_idx, debug_dxgi_format(format));
658 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
659 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
661 struct d3d10_device *device = impl_from_ID3D10Device(iface);
662 unsigned int i;
664 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
665 iface, start_slot, buffer_count, buffers);
667 for (i = 0; i < buffer_count; ++i)
669 struct wined3d_buffer *wined3d_buffer;
670 struct d3d10_buffer *buffer_impl;
672 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
674 buffers[i] = NULL;
675 continue;
678 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
679 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
680 ID3D10Buffer_AddRef(buffers[i]);
684 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
685 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
687 struct d3d10_device *device = impl_from_ID3D10Device(iface);
688 unsigned int i;
690 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
691 iface, start_slot, view_count, views);
693 for (i = 0; i < view_count; ++i)
695 struct wined3d_shader_resource_view *wined3d_view;
696 struct d3d10_shader_resource_view *view_impl;
698 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
700 views[i] = NULL;
701 continue;
704 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
705 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
706 ID3D10ShaderResourceView_AddRef(views[i]);
710 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
712 struct d3d10_device *device = impl_from_ID3D10Device(iface);
713 struct d3d10_pixel_shader *shader_impl;
714 struct wined3d_shader *wined3d_shader;
716 TRACE("iface %p, shader %p.\n", iface, shader);
718 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
720 *shader = NULL;
721 return;
724 shader_impl = wined3d_shader_get_parent(wined3d_shader);
725 *shader = &shader_impl->ID3D10PixelShader_iface;
726 ID3D10PixelShader_AddRef(*shader);
729 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
730 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
732 struct d3d10_device *device = impl_from_ID3D10Device(iface);
733 unsigned int i;
735 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
736 iface, start_slot, sampler_count, samplers);
738 for (i = 0; i < sampler_count; ++i)
740 struct d3d10_sampler_state *sampler_impl;
741 struct wined3d_sampler *wined3d_sampler;
743 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
745 samplers[i] = NULL;
746 continue;
749 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
750 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
751 ID3D10SamplerState_AddRef(samplers[i]);
755 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
757 struct d3d10_device *device = impl_from_ID3D10Device(iface);
758 struct d3d10_vertex_shader *shader_impl;
759 struct wined3d_shader *wined3d_shader;
761 TRACE("iface %p, shader %p.\n", iface, shader);
763 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
765 *shader = NULL;
766 return;
769 shader_impl = wined3d_shader_get_parent(wined3d_shader);
770 *shader = &shader_impl->ID3D10VertexShader_iface;
771 ID3D10VertexShader_AddRef(*shader);
774 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
775 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
777 struct d3d10_device *device = impl_from_ID3D10Device(iface);
778 unsigned int i;
780 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
781 iface, start_slot, buffer_count, buffers);
783 for (i = 0; i < buffer_count; ++i)
785 struct wined3d_buffer *wined3d_buffer;
786 struct d3d10_buffer *buffer_impl;
788 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
790 buffers[i] = NULL;
791 continue;
794 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
795 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
796 ID3D10Buffer_AddRef(buffers[i]);
800 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
802 struct d3d10_device *device = impl_from_ID3D10Device(iface);
803 struct wined3d_vertex_declaration *wined3d_declaration;
804 struct d3d10_input_layout *input_layout_impl;
806 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
808 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
810 *input_layout = NULL;
811 return;
814 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
815 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
816 ID3D10InputLayout_AddRef(*input_layout);
819 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
820 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
822 struct d3d10_device *device = impl_from_ID3D10Device(iface);
823 unsigned int i;
825 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
826 iface, start_slot, buffer_count, buffers, strides, offsets);
828 for (i = 0; i < buffer_count; ++i)
830 struct wined3d_buffer *wined3d_buffer;
831 struct d3d10_buffer *buffer_impl;
833 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
834 &wined3d_buffer, &offsets[i], &strides[i])))
835 ERR("Failed to get vertex buffer.\n");
837 if (!wined3d_buffer)
839 buffers[i] = NULL;
840 continue;
843 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
844 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
845 ID3D10Buffer_AddRef(buffers[i]);
849 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
850 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
852 struct d3d10_device *device = impl_from_ID3D10Device(iface);
853 enum wined3d_format_id wined3d_format;
854 struct wined3d_buffer *wined3d_buffer;
855 struct d3d10_buffer *buffer_impl;
857 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
859 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
860 *format = dxgi_format_from_wined3dformat(wined3d_format);
861 *offset = 0; /* FIXME */
862 if (!wined3d_buffer)
864 *buffer = NULL;
865 return;
868 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
869 *buffer = &buffer_impl->ID3D10Buffer_iface;
870 ID3D10Buffer_AddRef(*buffer);
873 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
874 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
876 struct d3d10_device *device = impl_from_ID3D10Device(iface);
877 unsigned int i;
879 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
880 iface, start_slot, buffer_count, buffers);
882 for (i = 0; i < buffer_count; ++i)
884 struct wined3d_buffer *wined3d_buffer;
885 struct d3d10_buffer *buffer_impl;
887 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
889 buffers[i] = NULL;
890 continue;
893 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
894 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
895 ID3D10Buffer_AddRef(buffers[i]);
899 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
901 struct d3d10_device *device = impl_from_ID3D10Device(iface);
902 struct d3d10_geometry_shader *shader_impl;
903 struct wined3d_shader *wined3d_shader;
905 TRACE("iface %p, shader %p.\n", iface, shader);
907 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
909 *shader = NULL;
910 return;
913 shader_impl = wined3d_shader_get_parent(wined3d_shader);
914 *shader = &shader_impl->ID3D10GeometryShader_iface;
915 ID3D10GeometryShader_AddRef(*shader);
918 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
919 D3D10_PRIMITIVE_TOPOLOGY *topology)
921 struct d3d10_device *This = impl_from_ID3D10Device(iface);
923 TRACE("iface %p, topology %p\n", iface, topology);
925 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
928 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
929 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
931 struct d3d10_device *device = impl_from_ID3D10Device(iface);
932 unsigned int i;
934 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
935 iface, start_slot, view_count, views);
937 for (i = 0; i < view_count; ++i)
939 struct wined3d_shader_resource_view *wined3d_view;
940 struct d3d10_shader_resource_view *view_impl;
942 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
944 views[i] = NULL;
945 continue;
948 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
949 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
950 ID3D10ShaderResourceView_AddRef(views[i]);
954 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
955 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
957 struct d3d10_device *device = impl_from_ID3D10Device(iface);
958 unsigned int i;
960 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
961 iface, start_slot, sampler_count, samplers);
963 for (i = 0; i < sampler_count; ++i)
965 struct d3d10_sampler_state *sampler_impl;
966 struct wined3d_sampler *wined3d_sampler;
968 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
970 samplers[i] = NULL;
971 continue;
974 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
975 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
976 ID3D10SamplerState_AddRef(samplers[i]);
980 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
981 ID3D10Predicate **predicate, BOOL *value)
983 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
986 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
987 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
989 struct d3d10_device *device = impl_from_ID3D10Device(iface);
990 unsigned int i;
992 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
993 iface, start_slot, view_count, views);
995 for (i = 0; i < view_count; ++i)
997 struct wined3d_shader_resource_view *wined3d_view;
998 struct d3d10_shader_resource_view *view_impl;
1000 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
1002 views[i] = NULL;
1003 continue;
1006 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1007 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
1008 ID3D10ShaderResourceView_AddRef(views[i]);
1012 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
1013 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
1015 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1016 unsigned int i;
1018 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1019 iface, start_slot, sampler_count, samplers);
1021 for (i = 0; i < sampler_count; ++i)
1023 struct d3d10_sampler_state *sampler_impl;
1024 struct wined3d_sampler *wined3d_sampler;
1026 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
1028 samplers[i] = NULL;
1029 continue;
1032 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1033 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
1034 ID3D10SamplerState_AddRef(samplers[i]);
1038 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
1039 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
1041 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1042 struct wined3d_rendertarget_view *wined3d_view;
1044 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1045 iface, view_count, render_target_views, depth_stencil_view);
1047 if (render_target_views)
1049 struct d3d10_rendertarget_view *view_impl;
1050 unsigned int i;
1052 for (i = 0; i < view_count; ++i)
1054 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
1055 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1057 render_target_views[i] = NULL;
1058 continue;
1061 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
1062 ID3D10RenderTargetView_AddRef(render_target_views[i]);
1066 if (depth_stencil_view)
1068 struct d3d10_depthstencil_view *view_impl;
1070 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
1071 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1073 *depth_stencil_view = NULL;
1075 else
1077 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
1078 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
1083 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
1084 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1086 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1088 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1089 iface, blend_state, blend_factor, sample_mask);
1091 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
1092 ID3D10BlendState_AddRef(*blend_state);
1093 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
1094 *sample_mask = device->sample_mask;
1097 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
1098 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1100 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1102 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1103 iface, depth_stencil_state, stencil_ref);
1105 if ((*depth_stencil_state = device->depth_stencil_state
1106 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
1107 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1108 *stencil_ref = device->stencil_ref;
1111 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
1112 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
1114 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1115 unsigned int i;
1117 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1118 iface, buffer_count, buffers, offsets);
1120 for (i = 0; i < buffer_count; ++i)
1122 struct wined3d_buffer *wined3d_buffer;
1123 struct d3d10_buffer *buffer_impl;
1125 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
1127 buffers[i] = NULL;
1128 continue;
1131 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1132 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1133 ID3D10Buffer_AddRef(buffers[i]);
1137 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
1139 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1141 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1143 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
1144 ID3D10RasterizerState_AddRef(*rasterizer_state);
1147 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
1148 UINT *viewport_count, D3D10_VIEWPORT *viewports)
1150 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1151 struct wined3d_viewport wined3d_vp;
1153 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
1155 if (!viewports)
1157 *viewport_count = 1;
1158 return;
1161 if (!*viewport_count)
1162 return;
1164 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
1166 viewports[0].TopLeftX = wined3d_vp.x;
1167 viewports[0].TopLeftY = wined3d_vp.y;
1168 viewports[0].Width = wined3d_vp.width;
1169 viewports[0].Height = wined3d_vp.height;
1170 viewports[0].MinDepth = wined3d_vp.min_z;
1171 viewports[0].MaxDepth = wined3d_vp.max_z;
1173 if (*viewport_count > 1)
1174 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
1177 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
1179 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1181 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
1183 if (!rects)
1185 *rect_count = 1;
1186 return;
1189 if (!*rect_count)
1190 return;
1192 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1193 if (*rect_count > 1)
1194 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1197 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1199 TRACE("iface %p.\n", iface);
1201 /* In the current implementation the device is never removed, so we can
1202 * just return S_OK here. */
1204 return S_OK;
1207 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1209 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1211 return E_NOTIMPL;
1214 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1216 FIXME("iface %p stub!\n", iface);
1218 return 0;
1221 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1222 REFGUID guid, UINT *data_size, void *data)
1224 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1225 iface, debugstr_guid(guid), data_size, data);
1227 return E_NOTIMPL;
1230 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1231 REFGUID guid, UINT data_size, const void *data)
1233 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1234 iface, debugstr_guid(guid), data_size, data);
1236 return E_NOTIMPL;
1239 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1240 REFGUID guid, const IUnknown *data)
1242 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1244 return E_NOTIMPL;
1247 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1249 FIXME("iface %p stub!\n", iface);
1252 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1254 FIXME("iface %p stub!\n", iface);
1257 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1258 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1260 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1261 struct d3d10_buffer *object;
1262 HRESULT hr;
1264 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1266 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1267 if (!object)
1268 return E_OUTOFMEMORY;
1270 hr = d3d10_buffer_init(object, This, desc, data);
1271 if (FAILED(hr))
1273 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1274 HeapFree(GetProcessHeap(), 0, object);
1275 return hr;
1278 *buffer = &object->ID3D10Buffer_iface;
1280 TRACE("Created ID3D10Buffer %p\n", object);
1282 return S_OK;
1285 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1286 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1288 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1290 return E_NOTIMPL;
1293 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1294 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1295 ID3D10Texture2D **texture)
1297 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1298 struct d3d10_texture2d *object;
1299 HRESULT hr;
1301 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1303 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1304 if (!object)
1305 return E_OUTOFMEMORY;
1307 hr = d3d10_texture2d_init(object, This, desc);
1308 if (FAILED(hr))
1310 WARN("Failed to initialize texture, hr %#x.\n", hr);
1311 HeapFree(GetProcessHeap(), 0, object);
1312 return hr;
1315 *texture = &object->ID3D10Texture2D_iface;
1317 TRACE("Created ID3D10Texture2D %p\n", object);
1319 return S_OK;
1322 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1323 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1324 ID3D10Texture3D **texture)
1326 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1327 struct d3d10_texture3d *object;
1328 HRESULT hr;
1330 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1332 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1333 if (!object)
1334 return E_OUTOFMEMORY;
1336 hr = d3d10_texture3d_init(object, device, desc);
1337 if (FAILED(hr))
1339 WARN("Failed to initialize texture, hr %#x.\n", hr);
1340 HeapFree(GetProcessHeap(), 0, object);
1341 return hr;
1344 TRACE("Created 3D texture %p.\n", object);
1345 *texture = &object->ID3D10Texture3D_iface;
1347 return S_OK;
1350 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1351 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1353 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1354 struct d3d10_shader_resource_view *object;
1355 HRESULT hr;
1357 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1359 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1360 return E_OUTOFMEMORY;
1362 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1364 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1365 HeapFree(GetProcessHeap(), 0, object);
1366 return hr;
1369 TRACE("Created shader resource view %p.\n", object);
1370 *view = &object->ID3D10ShaderResourceView_iface;
1372 return S_OK;
1375 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1376 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1378 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1379 struct d3d10_rendertarget_view *object;
1380 HRESULT hr;
1382 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1384 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1385 return E_OUTOFMEMORY;
1387 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1389 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1390 HeapFree(GetProcessHeap(), 0, object);
1391 return hr;
1394 TRACE("Created rendertarget view %p.\n", object);
1395 *view = &object->ID3D10RenderTargetView_iface;
1397 return S_OK;
1400 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1401 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1403 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1404 struct d3d10_depthstencil_view *object;
1405 HRESULT hr;
1407 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1409 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1410 return E_OUTOFMEMORY;
1412 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1414 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1415 HeapFree(GetProcessHeap(), 0, object);
1416 return hr;
1419 TRACE("Created depthstencil view %p.\n", object);
1420 *view = &object->ID3D10DepthStencilView_iface;
1422 return S_OK;
1425 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1426 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1427 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1428 ID3D10InputLayout **input_layout)
1430 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1431 struct d3d10_input_layout *object;
1432 HRESULT hr;
1434 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1435 "\tshader_byte_code_length %lu, input_layout %p\n",
1436 iface, element_descs, element_count, shader_byte_code,
1437 shader_byte_code_length, input_layout);
1439 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1440 if (!object)
1441 return E_OUTOFMEMORY;
1443 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1444 shader_byte_code, shader_byte_code_length);
1445 if (FAILED(hr))
1447 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1448 HeapFree(GetProcessHeap(), 0, object);
1449 return hr;
1452 TRACE("Created input layout %p.\n", object);
1453 *input_layout = &object->ID3D10InputLayout_iface;
1455 return S_OK;
1458 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1459 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1461 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1462 struct d3d10_vertex_shader *object;
1463 HRESULT hr;
1465 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1466 iface, byte_code, byte_code_length, shader);
1468 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1469 if (!object)
1470 return E_OUTOFMEMORY;
1472 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1473 if (FAILED(hr))
1475 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1476 HeapFree(GetProcessHeap(), 0, object);
1477 return hr;
1480 TRACE("Created vertex shader %p.\n", object);
1481 *shader = &object->ID3D10VertexShader_iface;
1483 return S_OK;
1486 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1487 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1489 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1490 struct d3d10_geometry_shader *object;
1491 HRESULT hr;
1493 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1494 iface, byte_code, byte_code_length, shader);
1496 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1497 if (!object)
1498 return E_OUTOFMEMORY;
1500 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1501 if (FAILED(hr))
1503 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1504 HeapFree(GetProcessHeap(), 0, object);
1505 return hr;
1508 TRACE("Created geometry shader %p.\n", object);
1509 *shader = &object->ID3D10GeometryShader_iface;
1511 return S_OK;
1514 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1515 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1516 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1518 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1519 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1520 iface, byte_code, byte_code_length, output_stream_decls,
1521 output_stream_decl_count, output_stream_stride, shader);
1523 return E_NOTIMPL;
1526 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1527 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1529 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1530 struct d3d10_pixel_shader *object;
1531 HRESULT hr;
1533 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1534 iface, byte_code, byte_code_length, shader);
1536 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1537 if (!object)
1538 return E_OUTOFMEMORY;
1540 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1541 if (FAILED(hr))
1543 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1544 HeapFree(GetProcessHeap(), 0, object);
1545 return hr;
1548 TRACE("Created pixel shader %p.\n", object);
1549 *shader = &object->ID3D10PixelShader_iface;
1551 return S_OK;
1554 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1555 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1557 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1558 struct d3d10_blend_state *object;
1559 struct wine_rb_entry *entry;
1560 HRESULT hr;
1562 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1564 if (!desc)
1565 return E_INVALIDARG;
1567 if ((entry = wine_rb_get(&device->blend_states, desc)))
1569 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1571 TRACE("Returning existing blend state %p.\n", object);
1572 *blend_state = &object->ID3D10BlendState_iface;
1573 ID3D10BlendState_AddRef(*blend_state);
1575 return S_OK;
1578 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1579 if (!object)
1580 return E_OUTOFMEMORY;
1582 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1584 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1585 HeapFree(GetProcessHeap(), 0, object);
1586 return hr;
1589 TRACE("Created blend state %p.\n", object);
1590 *blend_state = &object->ID3D10BlendState_iface;
1592 return S_OK;
1595 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1596 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1598 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1599 struct d3d10_depthstencil_state *object;
1600 struct wine_rb_entry *entry;
1601 HRESULT hr;
1603 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1605 if (!desc)
1606 return E_INVALIDARG;
1608 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1610 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1612 TRACE("Returning existing depthstencil state %p.\n", object);
1613 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1614 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1616 return S_OK;
1619 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1620 if (!object)
1621 return E_OUTOFMEMORY;
1623 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1625 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1626 HeapFree(GetProcessHeap(), 0, object);
1627 return hr;
1630 TRACE("Created depthstencil state %p.\n", object);
1631 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1633 return S_OK;
1636 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1637 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1639 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1640 struct d3d10_rasterizer_state *object;
1641 struct wine_rb_entry *entry;
1642 HRESULT hr;
1644 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1646 if (!desc)
1647 return E_INVALIDARG;
1649 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1651 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1653 TRACE("Returning existing rasterizer state %p.\n", object);
1654 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1655 ID3D10RasterizerState_AddRef(*rasterizer_state);
1657 return S_OK;
1661 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1662 if (!object)
1663 return E_OUTOFMEMORY;
1665 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1667 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1668 HeapFree(GetProcessHeap(), 0, object);
1669 return hr;
1672 TRACE("Created rasterizer state %p.\n", object);
1673 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1675 return S_OK;
1678 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1679 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1681 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1682 struct d3d10_sampler_state *object;
1683 struct wine_rb_entry *entry;
1684 HRESULT hr;
1686 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1688 if (!desc)
1689 return E_INVALIDARG;
1691 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1693 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1695 TRACE("Returning existing sampler state %p.\n", object);
1696 *sampler_state = &object->ID3D10SamplerState_iface;
1697 ID3D10SamplerState_AddRef(*sampler_state);
1699 return S_OK;
1702 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1703 if (!object)
1704 return E_OUTOFMEMORY;
1706 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1708 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1709 HeapFree(GetProcessHeap(), 0, object);
1710 return hr;
1713 TRACE("Created sampler state %p.\n", object);
1714 *sampler_state = &object->ID3D10SamplerState_iface;
1716 return S_OK;
1719 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1720 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1722 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1723 struct d3d10_query *object;
1724 HRESULT hr;
1726 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1728 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1729 return E_OUTOFMEMORY;
1731 if (FAILED(hr = d3d10_query_init(object, device, desc, FALSE)))
1733 WARN("Failed to initialize query, hr %#x.\n", hr);
1734 HeapFree(GetProcessHeap(), 0, object);
1735 return hr;
1738 TRACE("Created query %p.\n", object);
1739 *query = &object->ID3D10Query_iface;
1741 return S_OK;
1744 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1745 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1747 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1748 struct d3d10_query *object;
1749 HRESULT hr;
1751 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1753 if (!desc)
1754 return E_INVALIDARG;
1756 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1758 WARN("Query type %#x is not a predicate.\n", desc->Query);
1759 return E_INVALIDARG;
1762 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1763 return E_OUTOFMEMORY;
1765 if (FAILED(hr = d3d10_query_init(object, device, desc, TRUE)))
1767 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1768 HeapFree(GetProcessHeap(), 0, object);
1769 return hr;
1772 TRACE("Created predicate %p.\n", object);
1773 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1775 return S_OK;
1778 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1779 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1781 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1783 return E_NOTIMPL;
1786 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1787 DXGI_FORMAT format, UINT *format_support)
1789 FIXME("iface %p, format %s, format_support %p stub!\n",
1790 iface, debug_dxgi_format(format), format_support);
1792 return E_NOTIMPL;
1795 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1796 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1798 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1799 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1801 return E_NOTIMPL;
1804 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1806 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1809 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1810 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1811 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1813 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1814 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1815 iface, desc, type, active_counters, name, name_length,
1816 units, units_length, description, description_length);
1818 return E_NOTIMPL;
1821 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1823 FIXME("iface %p stub!\n", iface);
1825 return 0;
1828 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1829 HANDLE resource_handle, REFIID guid, void **resource)
1831 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1832 iface, resource_handle, debugstr_guid(guid), resource);
1834 return E_NOTIMPL;
1837 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1839 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1842 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1844 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1847 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1848 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1850 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1852 return E_NOTIMPL;
1855 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1856 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1858 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1860 return E_NOTIMPL;
1863 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1865 FIXME("iface %p stub!\n", iface);
1867 return D3D10_FEATURE_LEVEL_10_1;
1870 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1872 /* IUnknown methods */
1873 d3d10_device_QueryInterface,
1874 d3d10_device_AddRef,
1875 d3d10_device_Release,
1876 /* ID3D10Device methods */
1877 d3d10_device_VSSetConstantBuffers,
1878 d3d10_device_PSSetShaderResources,
1879 d3d10_device_PSSetShader,
1880 d3d10_device_PSSetSamplers,
1881 d3d10_device_VSSetShader,
1882 d3d10_device_DrawIndexed,
1883 d3d10_device_Draw,
1884 d3d10_device_PSSetConstantBuffers,
1885 d3d10_device_IASetInputLayout,
1886 d3d10_device_IASetVertexBuffers,
1887 d3d10_device_IASetIndexBuffer,
1888 d3d10_device_DrawIndexedInstanced,
1889 d3d10_device_DrawInstanced,
1890 d3d10_device_GSSetConstantBuffers,
1891 d3d10_device_GSSetShader,
1892 d3d10_device_IASetPrimitiveTopology,
1893 d3d10_device_VSSetShaderResources,
1894 d3d10_device_VSSetSamplers,
1895 d3d10_device_SetPredication,
1896 d3d10_device_GSSetShaderResources,
1897 d3d10_device_GSSetSamplers,
1898 d3d10_device_OMSetRenderTargets,
1899 d3d10_device_OMSetBlendState,
1900 d3d10_device_OMSetDepthStencilState,
1901 d3d10_device_SOSetTargets,
1902 d3d10_device_DrawAuto,
1903 d3d10_device_RSSetState,
1904 d3d10_device_RSSetViewports,
1905 d3d10_device_RSSetScissorRects,
1906 d3d10_device_CopySubresourceRegion,
1907 d3d10_device_CopyResource,
1908 d3d10_device_UpdateSubresource,
1909 d3d10_device_ClearRenderTargetView,
1910 d3d10_device_ClearDepthStencilView,
1911 d3d10_device_GenerateMips,
1912 d3d10_device_ResolveSubresource,
1913 d3d10_device_VSGetConstantBuffers,
1914 d3d10_device_PSGetShaderResources,
1915 d3d10_device_PSGetShader,
1916 d3d10_device_PSGetSamplers,
1917 d3d10_device_VSGetShader,
1918 d3d10_device_PSGetConstantBuffers,
1919 d3d10_device_IAGetInputLayout,
1920 d3d10_device_IAGetVertexBuffers,
1921 d3d10_device_IAGetIndexBuffer,
1922 d3d10_device_GSGetConstantBuffers,
1923 d3d10_device_GSGetShader,
1924 d3d10_device_IAGetPrimitiveTopology,
1925 d3d10_device_VSGetShaderResources,
1926 d3d10_device_VSGetSamplers,
1927 d3d10_device_GetPredication,
1928 d3d10_device_GSGetShaderResources,
1929 d3d10_device_GSGetSamplers,
1930 d3d10_device_OMGetRenderTargets,
1931 d3d10_device_OMGetBlendState,
1932 d3d10_device_OMGetDepthStencilState,
1933 d3d10_device_SOGetTargets,
1934 d3d10_device_RSGetState,
1935 d3d10_device_RSGetViewports,
1936 d3d10_device_RSGetScissorRects,
1937 d3d10_device_GetDeviceRemovedReason,
1938 d3d10_device_SetExceptionMode,
1939 d3d10_device_GetExceptionMode,
1940 d3d10_device_GetPrivateData,
1941 d3d10_device_SetPrivateData,
1942 d3d10_device_SetPrivateDataInterface,
1943 d3d10_device_ClearState,
1944 d3d10_device_Flush,
1945 d3d10_device_CreateBuffer,
1946 d3d10_device_CreateTexture1D,
1947 d3d10_device_CreateTexture2D,
1948 d3d10_device_CreateTexture3D,
1949 d3d10_device_CreateShaderResourceView,
1950 d3d10_device_CreateRenderTargetView,
1951 d3d10_device_CreateDepthStencilView,
1952 d3d10_device_CreateInputLayout,
1953 d3d10_device_CreateVertexShader,
1954 d3d10_device_CreateGeometryShader,
1955 d3d10_device_CreateGeometryShaderWithStreamOutput,
1956 d3d10_device_CreatePixelShader,
1957 d3d10_device_CreateBlendState,
1958 d3d10_device_CreateDepthStencilState,
1959 d3d10_device_CreateRasterizerState,
1960 d3d10_device_CreateSamplerState,
1961 d3d10_device_CreateQuery,
1962 d3d10_device_CreatePredicate,
1963 d3d10_device_CreateCounter,
1964 d3d10_device_CheckFormatSupport,
1965 d3d10_device_CheckMultisampleQualityLevels,
1966 d3d10_device_CheckCounterInfo,
1967 d3d10_device_CheckCounter,
1968 d3d10_device_GetCreationFlags,
1969 d3d10_device_OpenSharedResource,
1970 d3d10_device_SetTextFilterSize,
1971 d3d10_device_GetTextFilterSize,
1972 d3d10_device_CreateShaderResourceView1,
1973 d3d10_device_CreateBlendState1,
1974 d3d10_device_GetFeatureLevel,
1977 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1979 /* IUnknown methods */
1980 d3d10_device_inner_QueryInterface,
1981 d3d10_device_inner_AddRef,
1982 d3d10_device_inner_Release,
1985 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
1987 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
1990 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
1992 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1994 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
1996 return IUnknown_QueryInterface(device->outer_unk, iid, out);
1999 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
2001 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
2003 TRACE("iface %p.\n", iface);
2005 return IUnknown_AddRef(device->outer_unk);
2008 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
2010 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
2012 TRACE("iface %p.\n", iface);
2014 return IUnknown_Release(device->outer_unk);
2017 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
2019 TRACE("iface %p.\n", iface);
2021 wined3d_mutex_lock();
2024 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
2026 TRACE("iface %p.\n", iface);
2028 wined3d_mutex_unlock();
2031 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
2033 FIXME("iface %p, protect %#x stub!\n", iface, protect);
2035 return TRUE;
2038 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
2040 FIXME("iface %p stub!\n", iface);
2042 return TRUE;
2045 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
2047 d3d10_multithread_QueryInterface,
2048 d3d10_multithread_AddRef,
2049 d3d10_multithread_Release,
2050 d3d10_multithread_Enter,
2051 d3d10_multithread_Leave,
2052 d3d10_multithread_SetMultithreadProtected,
2053 d3d10_multithread_GetMultithreadProtected,
2056 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
2058 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
2060 d3d10_subresource_destroyed,
2063 /* IWineDXGIDeviceParent IUnknown methods */
2065 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
2067 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
2070 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
2071 REFIID riid, void **ppv)
2073 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2074 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
2077 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
2079 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2080 return IUnknown_AddRef(device->outer_unk);
2083 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
2085 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2086 return IUnknown_Release(device->outer_unk);
2089 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
2090 IWineDXGIDeviceParent *iface)
2092 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2093 return &device->device_parent;
2096 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
2098 /* IUnknown methods */
2099 dxgi_device_parent_QueryInterface,
2100 dxgi_device_parent_AddRef,
2101 dxgi_device_parent_Release,
2102 /* IWineDXGIDeviceParent methods */
2103 dxgi_device_parent_get_wined3d_device_parent,
2106 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
2108 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
2111 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
2112 struct wined3d_device *wined3d_device)
2114 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2116 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
2118 wined3d_device_incref(wined3d_device);
2119 device->wined3d_device = wined3d_device;
2122 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
2124 TRACE("device_parent %p.\n", device_parent);
2127 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
2129 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
2132 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
2133 void *container_parent, struct wined3d_surface *surface, void **parent,
2134 const struct wined3d_parent_ops **parent_ops)
2136 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2137 device_parent, container_parent, surface, parent, parent_ops);
2139 *parent = container_parent;
2140 *parent_ops = &d3d10_null_wined3d_parent_ops;
2142 return S_OK;
2145 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
2146 void *container_parent, struct wined3d_volume *volume, void **parent,
2147 const struct wined3d_parent_ops **parent_ops)
2149 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2150 device_parent, container_parent, volume, parent, parent_ops);
2152 *parent = container_parent;
2153 *parent_ops = &d3d10_null_wined3d_parent_ops;
2155 return S_OK;
2158 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
2159 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
2161 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2162 struct wined3d_resource *sub_resource;
2163 struct d3d10_texture2d *texture;
2164 D3D10_TEXTURE2D_DESC desc;
2165 HRESULT hr;
2167 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
2168 device_parent, container_parent, wined3d_desc, surface);
2170 FIXME("Implement DXGI<->wined3d usage conversion\n");
2172 desc.Width = wined3d_desc->width;
2173 desc.Height = wined3d_desc->height;
2174 desc.MipLevels = 1;
2175 desc.ArraySize = 1;
2176 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
2177 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
2178 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
2179 desc.Usage = D3D10_USAGE_DEFAULT;
2180 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
2181 desc.CPUAccessFlags = 0;
2182 desc.MiscFlags = 0;
2184 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
2185 &desc, NULL, (ID3D10Texture2D **)&texture)))
2187 ERR("CreateTexture2D failed, returning %#x\n", hr);
2188 return hr;
2191 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
2192 *surface = wined3d_surface_from_resource(sub_resource);
2193 wined3d_surface_incref(*surface);
2194 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
2196 return S_OK;
2199 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2200 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2202 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2203 IWineDXGIDevice *wine_device;
2204 HRESULT hr;
2206 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2208 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2209 &IID_IWineDXGIDevice, (void **)&wine_device)))
2211 ERR("Device should implement IWineDXGIDevice.\n");
2212 return E_FAIL;
2215 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2216 IWineDXGIDevice_Release(wine_device);
2217 if (FAILED(hr))
2219 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2220 return hr;
2223 return S_OK;
2226 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2228 device_parent_wined3d_device_created,
2229 device_parent_mode_changed,
2230 device_parent_activate,
2231 device_parent_surface_created,
2232 device_parent_volume_created,
2233 device_parent_create_swapchain_surface,
2234 device_parent_create_swapchain,
2237 static void *d3d10_rb_alloc(size_t size)
2239 return HeapAlloc(GetProcessHeap(), 0, size);
2242 static void *d3d10_rb_realloc(void *ptr, size_t size)
2244 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2247 static void d3d10_rb_free(void *ptr)
2249 HeapFree(GetProcessHeap(), 0, ptr);
2252 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2254 const D3D10_SAMPLER_DESC *ka = key;
2255 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2257 return memcmp(ka, kb, sizeof(*ka));
2260 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2262 d3d10_rb_alloc,
2263 d3d10_rb_realloc,
2264 d3d10_rb_free,
2265 d3d10_sampler_state_compare,
2268 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2270 const D3D10_BLEND_DESC *ka = key;
2271 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2273 return memcmp(ka, kb, sizeof(*ka));
2276 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2278 d3d10_rb_alloc,
2279 d3d10_rb_realloc,
2280 d3d10_rb_free,
2281 d3d10_blend_state_compare,
2284 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2286 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2287 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2288 const struct d3d10_depthstencil_state, entry)->desc;
2290 return memcmp(ka, kb, sizeof(*ka));
2293 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2295 d3d10_rb_alloc,
2296 d3d10_rb_realloc,
2297 d3d10_rb_free,
2298 d3d10_depthstencil_state_compare,
2301 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2303 const D3D10_RASTERIZER_DESC *ka = key;
2304 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2306 return memcmp(ka, kb, sizeof(*ka));
2309 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2311 d3d10_rb_alloc,
2312 d3d10_rb_realloc,
2313 d3d10_rb_free,
2314 d3d10_rasterizer_state_compare,
2317 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2319 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2320 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2321 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
2322 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2323 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2324 device->refcount = 1;
2325 /* COM aggregation always takes place */
2326 device->outer_unk = outer_unknown;
2328 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2330 WARN("Failed to initialize blend state rbtree.\n");
2331 return E_FAIL;
2333 device->blend_factor[0] = 1.0f;
2334 device->blend_factor[1] = 1.0f;
2335 device->blend_factor[2] = 1.0f;
2336 device->blend_factor[3] = 1.0f;
2337 device->sample_mask = D3D10_DEFAULT_SAMPLE_MASK;
2339 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2341 WARN("Failed to initialize depthstencil state rbtree.\n");
2342 wine_rb_destroy(&device->blend_states, NULL, NULL);
2343 return E_FAIL;
2346 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2348 WARN("Failed to initialize rasterizer state rbtree.\n");
2349 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2350 wine_rb_destroy(&device->blend_states, NULL, NULL);
2351 return E_FAIL;
2354 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2356 WARN("Failed to initialize sampler state rbtree.\n");
2357 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2358 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2359 wine_rb_destroy(&device->blend_states, NULL, NULL);
2360 return E_FAIL;
2363 return S_OK;