d3d11: Add ID3D11Device stub interface.
[wine.git] / dlls / d3d10core / device.c
blobad58cb3bd92b29b5d58a9031f5c79b518487b391
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_ID3D11Device))
55 *out = &device->ID3D11Device_iface;
57 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
59 *out = &device->ID3D10Multithread_iface;
61 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
63 *out = &device->IWineDXGIDeviceParent_iface;
65 else
67 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
68 *out = NULL;
69 return E_NOINTERFACE;
72 IUnknown_AddRef((IUnknown *)*out);
73 return S_OK;
76 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
78 struct d3d10_device *This = impl_from_IUnknown(iface);
79 ULONG refcount = InterlockedIncrement(&This->refcount);
81 TRACE("%p increasing refcount to %u\n", This, refcount);
83 return refcount;
86 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
88 struct d3d10_device *device = impl_from_IUnknown(iface);
89 ULONG refcount = InterlockedDecrement(&device->refcount);
91 TRACE("%p decreasing refcount to %u.\n", device, refcount);
93 if (!refcount)
95 if (device->wined3d_device)
97 wined3d_mutex_lock();
98 wined3d_device_decref(device->wined3d_device);
99 wined3d_mutex_unlock();
101 wine_rb_destroy(&device->sampler_states, NULL, NULL);
102 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
103 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
104 wine_rb_destroy(&device->blend_states, NULL, NULL);
107 return refcount;
110 /* IUnknown methods */
112 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
113 void **ppv)
115 struct d3d10_device *This = impl_from_ID3D10Device(iface);
116 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
119 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
121 struct d3d10_device *This = impl_from_ID3D10Device(iface);
122 return IUnknown_AddRef(This->outer_unk);
125 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
127 struct d3d10_device *This = impl_from_ID3D10Device(iface);
128 return IUnknown_Release(This->outer_unk);
131 /* ID3D10Device methods */
133 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
134 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
136 struct d3d10_device *device = impl_from_ID3D10Device(iface);
137 unsigned int i;
139 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
140 iface, start_slot, buffer_count, buffers);
142 wined3d_mutex_lock();
143 for (i = 0; i < buffer_count; ++i)
145 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
147 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
148 buffer ? buffer->wined3d_buffer : NULL);
150 wined3d_mutex_unlock();
153 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
154 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
156 struct d3d10_device *device = impl_from_ID3D10Device(iface);
157 unsigned int i;
159 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
160 iface, start_slot, view_count, views);
162 wined3d_mutex_lock();
163 for (i = 0; i < view_count; ++i)
165 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
167 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
168 view ? view->wined3d_view : NULL);
170 wined3d_mutex_unlock();
173 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
174 ID3D10PixelShader *shader)
176 struct d3d10_device *This = impl_from_ID3D10Device(iface);
177 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
179 TRACE("iface %p, shader %p\n", iface, shader);
181 wined3d_mutex_lock();
182 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
183 wined3d_mutex_unlock();
186 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
187 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
189 struct d3d10_device *device = impl_from_ID3D10Device(iface);
190 unsigned int i;
192 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
193 iface, start_slot, sampler_count, samplers);
195 wined3d_mutex_lock();
196 for (i = 0; i < sampler_count; ++i)
198 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
200 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
201 sampler ? sampler->wined3d_sampler : NULL);
203 wined3d_mutex_unlock();
206 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
207 ID3D10VertexShader *shader)
209 struct d3d10_device *This = impl_from_ID3D10Device(iface);
210 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
212 TRACE("iface %p, shader %p\n", iface, shader);
214 wined3d_mutex_lock();
215 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
216 wined3d_mutex_unlock();
219 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
220 UINT start_index_location, INT base_vertex_location)
222 struct d3d10_device *This = impl_from_ID3D10Device(iface);
224 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
225 iface, index_count, start_index_location, base_vertex_location);
227 wined3d_mutex_lock();
228 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
229 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
230 wined3d_mutex_unlock();
233 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
234 UINT start_vertex_location)
236 struct d3d10_device *This = impl_from_ID3D10Device(iface);
238 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
239 iface, vertex_count, start_vertex_location);
241 wined3d_mutex_lock();
242 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
243 wined3d_mutex_unlock();
246 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
247 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
249 struct d3d10_device *device = impl_from_ID3D10Device(iface);
250 unsigned int i;
252 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
253 iface, start_slot, buffer_count, buffers);
255 wined3d_mutex_lock();
256 for (i = 0; i < buffer_count; ++i)
258 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
260 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
261 buffer ? buffer->wined3d_buffer : NULL);
263 wined3d_mutex_unlock();
266 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
267 ID3D10InputLayout *input_layout)
269 struct d3d10_device *This = impl_from_ID3D10Device(iface);
270 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
272 TRACE("iface %p, input_layout %p\n", iface, input_layout);
274 wined3d_mutex_lock();
275 wined3d_device_set_vertex_declaration(This->wined3d_device,
276 layout ? layout->wined3d_decl : NULL);
277 wined3d_mutex_unlock();
280 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
281 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
283 struct d3d10_device *This = impl_from_ID3D10Device(iface);
284 unsigned int i;
286 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
287 iface, start_slot, buffer_count, buffers, strides, offsets);
289 wined3d_mutex_lock();
290 for (i = 0; i < buffer_count; ++i)
292 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
294 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
295 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
297 wined3d_mutex_unlock();
300 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
301 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
303 struct d3d10_device *This = impl_from_ID3D10Device(iface);
304 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
306 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
307 iface, buffer, debug_dxgi_format(format), offset);
309 wined3d_mutex_lock();
310 wined3d_device_set_index_buffer(This->wined3d_device,
311 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
312 wined3dformat_from_dxgi_format(format));
313 wined3d_mutex_unlock();
314 if (offset) FIXME("offset %u not supported.\n", offset);
317 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
318 UINT instance_index_count, UINT instance_count, UINT start_index_location,
319 INT base_vertex_location, UINT start_instance_location)
321 struct d3d10_device *device = impl_from_ID3D10Device(iface);
323 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
324 "base_vertex_location %d, start_instance_location %u.\n",
325 iface, instance_index_count, instance_count, start_index_location,
326 base_vertex_location, start_instance_location);
328 wined3d_mutex_lock();
329 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
330 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
331 instance_index_count, start_instance_location, instance_count);
332 wined3d_mutex_unlock();
335 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
336 UINT instance_vertex_count, UINT instance_count,
337 UINT start_vertex_location, UINT start_instance_location)
339 struct d3d10_device *device = impl_from_ID3D10Device(iface);
341 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
342 "start_instance_location %u.\n", iface, instance_vertex_count, instance_count,
343 start_vertex_location, start_instance_location);
345 wined3d_mutex_lock();
346 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
347 instance_vertex_count, start_instance_location, instance_count);
348 wined3d_mutex_unlock();
351 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
352 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
354 struct d3d10_device *device = impl_from_ID3D10Device(iface);
355 unsigned int i;
357 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
358 iface, start_slot, buffer_count, buffers);
360 wined3d_mutex_lock();
361 for (i = 0; i < buffer_count; ++i)
363 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
365 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
366 buffer ? buffer->wined3d_buffer : NULL);
368 wined3d_mutex_unlock();
371 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
373 struct d3d10_device *device = impl_from_ID3D10Device(iface);
374 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
376 TRACE("iface %p, shader %p.\n", iface, shader);
378 wined3d_mutex_lock();
379 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
380 wined3d_mutex_unlock();
383 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
384 D3D10_PRIMITIVE_TOPOLOGY topology)
386 struct d3d10_device *This = impl_from_ID3D10Device(iface);
388 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
390 wined3d_mutex_lock();
391 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
392 wined3d_mutex_unlock();
395 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
396 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
398 struct d3d10_device *device = impl_from_ID3D10Device(iface);
399 unsigned int i;
401 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
402 iface, start_slot, view_count, views);
404 wined3d_mutex_lock();
405 for (i = 0; i < view_count; ++i)
407 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
409 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
410 view ? view->wined3d_view : NULL);
412 wined3d_mutex_unlock();
415 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(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 wined3d_mutex_lock();
425 for (i = 0; i < sampler_count; ++i)
427 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
429 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
430 sampler ? sampler->wined3d_sampler : NULL);
432 wined3d_mutex_unlock();
435 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
437 struct d3d10_device *device = impl_from_ID3D10Device(iface);
438 struct d3d10_query *query;
440 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
442 query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
443 wined3d_mutex_lock();
444 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
445 wined3d_mutex_unlock();
448 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
449 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
451 struct d3d10_device *device = impl_from_ID3D10Device(iface);
452 unsigned int i;
454 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
455 iface, start_slot, view_count, views);
457 wined3d_mutex_lock();
458 for (i = 0; i < view_count; ++i)
460 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
462 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
463 view ? view->wined3d_view : NULL);
465 wined3d_mutex_unlock();
468 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
469 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
471 struct d3d10_device *device = impl_from_ID3D10Device(iface);
472 unsigned int i;
474 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
475 iface, start_slot, sampler_count, samplers);
477 wined3d_mutex_lock();
478 for (i = 0; i < sampler_count; ++i)
480 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
482 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
483 sampler ? sampler->wined3d_sampler : NULL);
485 wined3d_mutex_unlock();
488 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
489 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
490 ID3D10DepthStencilView *depth_stencil_view)
492 struct d3d10_device *device = impl_from_ID3D10Device(iface);
493 struct d3d10_depthstencil_view *dsv;
494 unsigned int i;
496 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
497 iface, render_target_view_count, render_target_views, depth_stencil_view);
499 wined3d_mutex_lock();
500 for (i = 0; i < render_target_view_count; ++i)
502 struct d3d10_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
504 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
505 rtv ? rtv->wined3d_view : NULL, FALSE);
507 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
509 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
512 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
513 wined3d_device_set_depth_stencil_view(device->wined3d_device,
514 dsv ? dsv->wined3d_view : NULL);
515 wined3d_mutex_unlock();
518 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
519 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
521 struct d3d10_device *device = impl_from_ID3D10Device(iface);
522 const D3D10_BLEND_DESC *desc;
524 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
525 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
527 if (blend_factor[0] != 1.0f || blend_factor[1] != 1.0f || blend_factor[2] != 1.0f || blend_factor[3] != 1.0f)
528 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
529 blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
530 wined3d_mutex_lock();
531 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
532 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
533 if (!(device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state)))
535 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE);
536 wined3d_device_set_render_state(device->wined3d_device,
537 WINED3D_RS_COLORWRITEENABLE, D3D10_COLOR_WRITE_ENABLE_ALL);
538 wined3d_device_set_render_state(device->wined3d_device,
539 WINED3D_RS_COLORWRITEENABLE1, D3D10_COLOR_WRITE_ENABLE_ALL);
540 wined3d_device_set_render_state(device->wined3d_device,
541 WINED3D_RS_COLORWRITEENABLE2, D3D10_COLOR_WRITE_ENABLE_ALL);
542 wined3d_device_set_render_state(device->wined3d_device,
543 WINED3D_RS_COLORWRITEENABLE3, D3D10_COLOR_WRITE_ENABLE_ALL);
544 wined3d_mutex_unlock();
545 return;
548 desc = &device->blend_state->desc;
549 /* glSampleCoverage() */
550 if (desc->AlphaToCoverageEnable)
551 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc->AlphaToCoverageEnable);
552 /* glEnableIndexedEXT(GL_BLEND, ...) */
553 FIXME("Per-rendertarget blend enable not implemented.\n");
554 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, desc->BlendEnable[0]);
555 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLEND, desc->SrcBlend);
556 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLEND, desc->DestBlend);
557 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOP, desc->BlendOp);
558 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SEPARATEALPHABLENDENABLE, TRUE);
559 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA, desc->SrcBlendAlpha);
560 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA, desc->DestBlendAlpha);
561 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA, desc->BlendOpAlpha);
562 FIXME("Color mask > 3 not implemented.\n");
563 wined3d_device_set_render_state(device->wined3d_device,
564 WINED3D_RS_COLORWRITEENABLE, desc->RenderTargetWriteMask[0]);
565 wined3d_device_set_render_state(device->wined3d_device,
566 WINED3D_RS_COLORWRITEENABLE1, desc->RenderTargetWriteMask[1]);
567 wined3d_device_set_render_state(device->wined3d_device,
568 WINED3D_RS_COLORWRITEENABLE2, desc->RenderTargetWriteMask[2]);
569 wined3d_device_set_render_state(device->wined3d_device,
570 WINED3D_RS_COLORWRITEENABLE3, desc->RenderTargetWriteMask[3]);
571 wined3d_mutex_unlock();
574 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
575 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
577 struct d3d10_device *device = impl_from_ID3D10Device(iface);
579 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
580 iface, depth_stencil_state, stencil_ref);
582 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
583 device->stencil_ref = stencil_ref;
586 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
587 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
589 struct d3d10_device *device = impl_from_ID3D10Device(iface);
590 unsigned int count, i;
592 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
594 count = min(target_count, 4);
595 wined3d_mutex_lock();
596 for (i = 0; i < count; ++i)
598 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
600 wined3d_device_set_stream_output(device->wined3d_device, i,
601 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
604 for (i = count; i < 4; ++i)
606 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
608 wined3d_mutex_unlock();
611 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
613 FIXME("iface %p stub!\n", iface);
616 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
618 struct d3d10_device *device = impl_from_ID3D10Device(iface);
619 const D3D10_RASTERIZER_DESC *desc;
621 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
623 wined3d_mutex_lock();
624 if (!(device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state)))
626 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
627 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
628 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
629 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
630 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
631 wined3d_mutex_unlock();
632 return;
635 desc = &device->rasterizer_state->desc;
636 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
637 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
638 /* glFrontFace() */
639 if (desc->FrontCounterClockwise)
640 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
641 /* OpenGL style depth bias. */
642 if (desc->DepthBias || desc->SlopeScaledDepthBias)
643 FIXME("Ignoring depth bias.\n");
644 /* GL_DEPTH_CLAMP */
645 if (!desc->DepthClipEnable)
646 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
647 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
648 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
649 wined3d_device_set_render_state(device->wined3d_device,
650 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
651 wined3d_mutex_unlock();
654 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
655 UINT viewport_count, const D3D10_VIEWPORT *viewports)
657 struct d3d10_device *device = impl_from_ID3D10Device(iface);
658 struct wined3d_viewport wined3d_vp;
660 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
662 if (viewport_count > 1)
663 FIXME("Multiple viewports not implemented.\n");
665 if (!viewport_count)
666 return;
668 wined3d_vp.x = viewports[0].TopLeftX;
669 wined3d_vp.y = viewports[0].TopLeftY;
670 wined3d_vp.width = viewports[0].Width;
671 wined3d_vp.height = viewports[0].Height;
672 wined3d_vp.min_z = viewports[0].MinDepth;
673 wined3d_vp.max_z = viewports[0].MaxDepth;
675 wined3d_mutex_lock();
676 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
677 wined3d_mutex_unlock();
680 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
681 UINT rect_count, const D3D10_RECT *rects)
683 struct d3d10_device *device = impl_from_ID3D10Device(iface);
685 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
687 if (rect_count > 1)
688 FIXME("Multiple scissor rects not implemented.\n");
690 if (!rect_count)
691 return;
693 wined3d_mutex_lock();
694 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
695 wined3d_mutex_unlock();
698 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
699 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
700 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
702 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
703 struct d3d10_device *device = impl_from_ID3D10Device(iface);
704 struct wined3d_box wined3d_src_box;
706 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
707 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
708 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
709 src_resource, src_subresource_idx, src_box);
711 wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
712 wined3d_src_resource = wined3d_resource_from_resource(src_resource);
713 wined3d_src_box.left = src_box->left;
714 wined3d_src_box.top = src_box->top;
715 wined3d_src_box.front = src_box->front;
716 wined3d_src_box.right = src_box->right;
717 wined3d_src_box.bottom = src_box->bottom;
718 wined3d_src_box.back = src_box->back;
719 wined3d_mutex_lock();
720 wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
721 dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, &wined3d_src_box);
722 wined3d_mutex_unlock();
725 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
726 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
728 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
729 struct d3d10_device *device = impl_from_ID3D10Device(iface);
731 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
733 wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
734 wined3d_src_resource = wined3d_resource_from_resource(src_resource);
735 wined3d_mutex_lock();
736 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
737 wined3d_mutex_unlock();
740 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
741 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
742 const void *data, UINT row_pitch, UINT depth_pitch)
744 struct d3d10_device *device = impl_from_ID3D10Device(iface);
745 struct wined3d_resource *wined3d_resource;
746 struct wined3d_box wined3d_box;
748 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
749 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
751 if (box)
753 wined3d_box.left = box->left;
754 wined3d_box.top = box->top;
755 wined3d_box.front = box->front;
756 wined3d_box.right = box->right;
757 wined3d_box.bottom = box->bottom;
758 wined3d_box.back = box->back;
761 wined3d_resource = wined3d_resource_from_resource(resource);
762 wined3d_mutex_lock();
763 wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource,
764 subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch);
765 wined3d_mutex_unlock();
768 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
769 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
771 struct d3d10_device *device = impl_from_ID3D10Device(iface);
772 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
773 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
774 HRESULT hr;
776 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
777 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
779 wined3d_mutex_lock();
780 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
781 ERR("Failed to clear view, hr %#x.\n", hr);
782 wined3d_mutex_unlock();
785 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
786 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
788 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
789 iface, depth_stencil_view, flags, depth, stencil);
792 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
793 ID3D10ShaderResourceView *shader_resource_view)
795 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
798 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
799 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
800 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
802 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
803 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
804 iface, dst_resource, dst_subresource_idx,
805 src_resource, src_subresource_idx, debug_dxgi_format(format));
808 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
809 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
811 struct d3d10_device *device = impl_from_ID3D10Device(iface);
812 unsigned int i;
814 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
815 iface, start_slot, buffer_count, buffers);
817 wined3d_mutex_lock();
818 for (i = 0; i < buffer_count; ++i)
820 struct wined3d_buffer *wined3d_buffer;
821 struct d3d10_buffer *buffer_impl;
823 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
825 buffers[i] = NULL;
826 continue;
829 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
830 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
831 ID3D10Buffer_AddRef(buffers[i]);
833 wined3d_mutex_unlock();
836 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
837 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
839 struct d3d10_device *device = impl_from_ID3D10Device(iface);
840 unsigned int i;
842 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
843 iface, start_slot, view_count, views);
845 wined3d_mutex_lock();
846 for (i = 0; i < view_count; ++i)
848 struct wined3d_shader_resource_view *wined3d_view;
849 struct d3d10_shader_resource_view *view_impl;
851 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
853 views[i] = NULL;
854 continue;
857 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
858 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
859 ID3D10ShaderResourceView_AddRef(views[i]);
861 wined3d_mutex_unlock();
864 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
866 struct d3d10_device *device = impl_from_ID3D10Device(iface);
867 struct d3d10_pixel_shader *shader_impl;
868 struct wined3d_shader *wined3d_shader;
870 TRACE("iface %p, shader %p.\n", iface, shader);
872 wined3d_mutex_lock();
873 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
875 wined3d_mutex_unlock();
876 *shader = NULL;
877 return;
880 shader_impl = wined3d_shader_get_parent(wined3d_shader);
881 wined3d_mutex_unlock();
882 *shader = &shader_impl->ID3D10PixelShader_iface;
883 ID3D10PixelShader_AddRef(*shader);
886 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
887 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
889 struct d3d10_device *device = impl_from_ID3D10Device(iface);
890 unsigned int i;
892 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
893 iface, start_slot, sampler_count, samplers);
895 wined3d_mutex_lock();
896 for (i = 0; i < sampler_count; ++i)
898 struct d3d10_sampler_state *sampler_impl;
899 struct wined3d_sampler *wined3d_sampler;
901 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
903 samplers[i] = NULL;
904 continue;
907 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
908 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
909 ID3D10SamplerState_AddRef(samplers[i]);
911 wined3d_mutex_unlock();
914 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
916 struct d3d10_device *device = impl_from_ID3D10Device(iface);
917 struct d3d10_vertex_shader *shader_impl;
918 struct wined3d_shader *wined3d_shader;
920 TRACE("iface %p, shader %p.\n", iface, shader);
922 wined3d_mutex_lock();
923 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
925 wined3d_mutex_unlock();
926 *shader = NULL;
927 return;
930 shader_impl = wined3d_shader_get_parent(wined3d_shader);
931 wined3d_mutex_unlock();
932 *shader = &shader_impl->ID3D10VertexShader_iface;
933 ID3D10VertexShader_AddRef(*shader);
936 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
937 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
939 struct d3d10_device *device = impl_from_ID3D10Device(iface);
940 unsigned int i;
942 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
943 iface, start_slot, buffer_count, buffers);
945 wined3d_mutex_lock();
946 for (i = 0; i < buffer_count; ++i)
948 struct wined3d_buffer *wined3d_buffer;
949 struct d3d10_buffer *buffer_impl;
951 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
953 buffers[i] = NULL;
954 continue;
957 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
958 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
959 ID3D10Buffer_AddRef(buffers[i]);
961 wined3d_mutex_unlock();
964 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
966 struct d3d10_device *device = impl_from_ID3D10Device(iface);
967 struct wined3d_vertex_declaration *wined3d_declaration;
968 struct d3d10_input_layout *input_layout_impl;
970 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
972 wined3d_mutex_lock();
973 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
975 wined3d_mutex_unlock();
976 *input_layout = NULL;
977 return;
980 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
981 wined3d_mutex_unlock();
982 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
983 ID3D10InputLayout_AddRef(*input_layout);
986 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
987 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
989 struct d3d10_device *device = impl_from_ID3D10Device(iface);
990 unsigned int i;
992 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
993 iface, start_slot, buffer_count, buffers, strides, offsets);
995 wined3d_mutex_lock();
996 for (i = 0; i < buffer_count; ++i)
998 struct wined3d_buffer *wined3d_buffer;
999 struct d3d10_buffer *buffer_impl;
1001 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
1002 &wined3d_buffer, &offsets[i], &strides[i])))
1003 ERR("Failed to get vertex buffer.\n");
1005 if (!wined3d_buffer)
1007 buffers[i] = NULL;
1008 continue;
1011 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1012 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1013 ID3D10Buffer_AddRef(buffers[i]);
1015 wined3d_mutex_unlock();
1018 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
1019 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
1021 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1022 enum wined3d_format_id wined3d_format;
1023 struct wined3d_buffer *wined3d_buffer;
1024 struct d3d10_buffer *buffer_impl;
1026 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
1028 wined3d_mutex_lock();
1029 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
1030 *format = dxgi_format_from_wined3dformat(wined3d_format);
1031 *offset = 0; /* FIXME */
1032 if (!wined3d_buffer)
1034 wined3d_mutex_unlock();
1035 *buffer = NULL;
1036 return;
1039 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1040 wined3d_mutex_unlock();
1041 *buffer = &buffer_impl->ID3D10Buffer_iface;
1042 ID3D10Buffer_AddRef(*buffer);
1045 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
1046 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
1048 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1049 unsigned int i;
1051 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1052 iface, start_slot, buffer_count, buffers);
1054 wined3d_mutex_lock();
1055 for (i = 0; i < buffer_count; ++i)
1057 struct wined3d_buffer *wined3d_buffer;
1058 struct d3d10_buffer *buffer_impl;
1060 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
1062 buffers[i] = NULL;
1063 continue;
1066 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1067 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1068 ID3D10Buffer_AddRef(buffers[i]);
1070 wined3d_mutex_unlock();
1073 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
1075 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1076 struct d3d10_geometry_shader *shader_impl;
1077 struct wined3d_shader *wined3d_shader;
1079 TRACE("iface %p, shader %p.\n", iface, shader);
1081 wined3d_mutex_lock();
1082 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
1084 wined3d_mutex_unlock();
1085 *shader = NULL;
1086 return;
1089 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1090 wined3d_mutex_unlock();
1091 *shader = &shader_impl->ID3D10GeometryShader_iface;
1092 ID3D10GeometryShader_AddRef(*shader);
1095 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
1096 D3D10_PRIMITIVE_TOPOLOGY *topology)
1098 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1100 TRACE("iface %p, topology %p\n", iface, topology);
1102 wined3d_mutex_lock();
1103 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
1104 wined3d_mutex_unlock();
1107 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
1108 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
1110 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1111 unsigned int i;
1113 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1114 iface, start_slot, view_count, views);
1116 wined3d_mutex_lock();
1117 for (i = 0; i < view_count; ++i)
1119 struct wined3d_shader_resource_view *wined3d_view;
1120 struct d3d10_shader_resource_view *view_impl;
1122 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
1124 views[i] = NULL;
1125 continue;
1128 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1129 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
1130 ID3D10ShaderResourceView_AddRef(views[i]);
1132 wined3d_mutex_unlock();
1135 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
1136 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
1138 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1139 unsigned int i;
1141 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1142 iface, start_slot, sampler_count, samplers);
1144 wined3d_mutex_lock();
1145 for (i = 0; i < sampler_count; ++i)
1147 struct d3d10_sampler_state *sampler_impl;
1148 struct wined3d_sampler *wined3d_sampler;
1150 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
1152 samplers[i] = NULL;
1153 continue;
1156 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1157 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
1158 ID3D10SamplerState_AddRef(samplers[i]);
1160 wined3d_mutex_unlock();
1163 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
1164 ID3D10Predicate **predicate, BOOL *value)
1166 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1167 struct wined3d_query *wined3d_predicate;
1168 struct d3d10_query *predicate_impl;
1170 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
1172 wined3d_mutex_lock();
1173 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
1175 wined3d_mutex_unlock();
1176 *predicate = NULL;
1177 return;
1180 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
1181 wined3d_mutex_unlock();
1182 *predicate = (ID3D10Predicate *)&predicate_impl->ID3D10Query_iface;
1183 ID3D10Predicate_AddRef(*predicate);
1186 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
1187 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
1189 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1190 unsigned int i;
1192 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1193 iface, start_slot, view_count, views);
1195 wined3d_mutex_lock();
1196 for (i = 0; i < view_count; ++i)
1198 struct wined3d_shader_resource_view *wined3d_view;
1199 struct d3d10_shader_resource_view *view_impl;
1201 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
1203 views[i] = NULL;
1204 continue;
1207 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1208 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
1209 ID3D10ShaderResourceView_AddRef(views[i]);
1211 wined3d_mutex_unlock();
1214 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
1215 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
1217 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1218 unsigned int i;
1220 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1221 iface, start_slot, sampler_count, samplers);
1223 wined3d_mutex_lock();
1224 for (i = 0; i < sampler_count; ++i)
1226 struct d3d10_sampler_state *sampler_impl;
1227 struct wined3d_sampler *wined3d_sampler;
1229 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
1231 samplers[i] = NULL;
1232 continue;
1235 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1236 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
1237 ID3D10SamplerState_AddRef(samplers[i]);
1239 wined3d_mutex_unlock();
1242 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
1243 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
1245 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1246 struct wined3d_rendertarget_view *wined3d_view;
1248 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1249 iface, view_count, render_target_views, depth_stencil_view);
1251 wined3d_mutex_lock();
1252 if (render_target_views)
1254 struct d3d10_rendertarget_view *view_impl;
1255 unsigned int i;
1257 for (i = 0; i < view_count; ++i)
1259 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
1260 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1262 render_target_views[i] = NULL;
1263 continue;
1266 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
1267 ID3D10RenderTargetView_AddRef(render_target_views[i]);
1271 if (depth_stencil_view)
1273 struct d3d10_depthstencil_view *view_impl;
1275 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
1276 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1278 *depth_stencil_view = NULL;
1280 else
1282 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
1283 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
1286 wined3d_mutex_unlock();
1289 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
1290 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1292 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1294 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1295 iface, blend_state, blend_factor, sample_mask);
1297 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
1298 ID3D10BlendState_AddRef(*blend_state);
1299 wined3d_mutex_lock();
1300 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
1301 *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK);
1302 wined3d_mutex_unlock();
1305 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
1306 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1308 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1310 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1311 iface, depth_stencil_state, stencil_ref);
1313 if ((*depth_stencil_state = device->depth_stencil_state
1314 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
1315 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1316 *stencil_ref = device->stencil_ref;
1319 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
1320 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
1322 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1323 unsigned int i;
1325 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1326 iface, buffer_count, buffers, offsets);
1328 wined3d_mutex_lock();
1329 for (i = 0; i < buffer_count; ++i)
1331 struct wined3d_buffer *wined3d_buffer;
1332 struct d3d10_buffer *buffer_impl;
1334 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
1336 buffers[i] = NULL;
1337 continue;
1340 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1341 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1342 ID3D10Buffer_AddRef(buffers[i]);
1344 wined3d_mutex_unlock();
1347 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
1349 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1351 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1353 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
1354 ID3D10RasterizerState_AddRef(*rasterizer_state);
1357 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
1358 UINT *viewport_count, D3D10_VIEWPORT *viewports)
1360 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1361 struct wined3d_viewport wined3d_vp;
1363 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
1365 if (!viewports)
1367 *viewport_count = 1;
1368 return;
1371 if (!*viewport_count)
1372 return;
1374 wined3d_mutex_lock();
1375 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
1376 wined3d_mutex_unlock();
1378 viewports[0].TopLeftX = wined3d_vp.x;
1379 viewports[0].TopLeftY = wined3d_vp.y;
1380 viewports[0].Width = wined3d_vp.width;
1381 viewports[0].Height = wined3d_vp.height;
1382 viewports[0].MinDepth = wined3d_vp.min_z;
1383 viewports[0].MaxDepth = wined3d_vp.max_z;
1385 if (*viewport_count > 1)
1386 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
1389 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
1391 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1393 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
1395 if (!rects)
1397 *rect_count = 1;
1398 return;
1401 if (!*rect_count)
1402 return;
1404 wined3d_mutex_lock();
1405 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1406 wined3d_mutex_unlock();
1407 if (*rect_count > 1)
1408 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1411 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1413 TRACE("iface %p.\n", iface);
1415 /* In the current implementation the device is never removed, so we can
1416 * just return S_OK here. */
1418 return S_OK;
1421 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1423 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1425 return E_NOTIMPL;
1428 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1430 FIXME("iface %p stub!\n", iface);
1432 return 0;
1435 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1436 REFGUID guid, UINT *data_size, void *data)
1438 IDXGIDevice *dxgi_device;
1439 HRESULT hr;
1441 TRACE("iface %p, guid %s, data_size %p, data %p.\n",
1442 iface, debugstr_guid(guid), data_size, data);
1444 if (FAILED(hr = ID3D10Device1_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
1445 return hr;
1446 hr = IDXGIDevice_GetPrivateData(dxgi_device, guid, data_size, data);
1447 IDXGIDevice_Release(dxgi_device);
1449 return hr;
1452 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1453 REFGUID guid, UINT data_size, const void *data)
1455 IDXGIDevice *dxgi_device;
1456 HRESULT hr;
1458 TRACE("iface %p, guid %s, data_size %u, data %p.\n",
1459 iface, debugstr_guid(guid), data_size, data);
1461 if (FAILED(hr = ID3D10Device1_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
1462 return hr;
1463 hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data);
1464 IDXGIDevice_Release(dxgi_device);
1466 return hr;
1469 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1470 REFGUID guid, const IUnknown *data)
1472 IDXGIDevice *dxgi_device;
1473 HRESULT hr;
1475 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
1477 if (FAILED(hr = ID3D10Device1_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
1478 return hr;
1479 hr = IDXGIDevice_SetPrivateDataInterface(dxgi_device, guid, data);
1480 IDXGIDevice_Release(dxgi_device);
1482 return hr;
1485 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1487 static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
1488 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1489 unsigned int i;
1491 TRACE("iface %p.\n", iface);
1493 wined3d_mutex_lock();
1494 wined3d_device_set_vertex_shader(device->wined3d_device, NULL);
1495 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
1497 wined3d_device_set_vs_sampler(device->wined3d_device, i, NULL);
1499 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
1501 wined3d_device_set_vs_resource_view(device->wined3d_device, i, NULL);
1503 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
1505 wined3d_device_set_vs_cb(device->wined3d_device, i, NULL);
1507 wined3d_device_set_geometry_shader(device->wined3d_device, NULL);
1508 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
1510 wined3d_device_set_gs_sampler(device->wined3d_device, i, NULL);
1512 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
1514 wined3d_device_set_gs_resource_view(device->wined3d_device, i, NULL);
1516 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
1518 wined3d_device_set_gs_cb(device->wined3d_device, i, NULL);
1520 wined3d_device_set_pixel_shader(device->wined3d_device, NULL);
1521 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
1523 wined3d_device_set_ps_sampler(device->wined3d_device, i, NULL);
1525 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
1527 wined3d_device_set_ps_resource_view(device->wined3d_device, i, NULL);
1529 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
1531 wined3d_device_set_ps_cb(device->wined3d_device, i, NULL);
1533 for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i)
1535 wined3d_device_set_stream_source(device->wined3d_device, i, NULL, 0, 0);
1537 wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
1538 wined3d_device_set_vertex_declaration(device->wined3d_device, NULL);
1539 wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_UNDEFINED);
1540 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
1542 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
1544 wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL);
1545 ID3D10Device1_OMSetDepthStencilState(iface, NULL, 0);
1546 ID3D10Device1_OMSetBlendState(iface, NULL, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
1547 ID3D10Device1_RSSetViewports(iface, 0, NULL);
1548 ID3D10Device1_RSSetScissorRects(iface, 0, NULL);
1549 ID3D10Device1_RSSetState(iface, NULL);
1550 for (i = 0; i < D3D10_SO_BUFFER_SLOT_COUNT; ++i)
1552 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
1554 wined3d_device_set_predication(device->wined3d_device, NULL, FALSE);
1555 wined3d_mutex_unlock();
1558 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1560 FIXME("iface %p stub!\n", iface);
1563 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1564 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1566 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1567 struct d3d10_buffer *object;
1568 HRESULT hr;
1570 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
1572 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1573 if (!object)
1574 return E_OUTOFMEMORY;
1576 hr = d3d10_buffer_init(object, This, desc, data);
1577 if (FAILED(hr))
1579 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1580 HeapFree(GetProcessHeap(), 0, object);
1581 return hr;
1584 *buffer = &object->ID3D10Buffer_iface;
1586 TRACE("Created ID3D10Buffer %p\n", object);
1588 return S_OK;
1591 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1592 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1594 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1596 return E_NOTIMPL;
1599 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1600 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1601 ID3D10Texture2D **texture)
1603 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1604 struct d3d10_texture2d *object;
1605 HRESULT hr;
1607 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1609 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1610 if (!object)
1611 return E_OUTOFMEMORY;
1613 if (FAILED(hr = d3d10_texture2d_init(object, device, desc, data)))
1615 WARN("Failed to initialize texture, hr %#x.\n", hr);
1616 HeapFree(GetProcessHeap(), 0, object);
1617 return hr;
1620 *texture = &object->ID3D10Texture2D_iface;
1622 TRACE("Created ID3D10Texture2D %p\n", object);
1624 return S_OK;
1627 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1628 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1629 ID3D10Texture3D **texture)
1631 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1632 struct d3d10_texture3d *object;
1633 HRESULT hr;
1635 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1637 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1638 if (!object)
1639 return E_OUTOFMEMORY;
1641 if (FAILED(hr = d3d10_texture3d_init(object, device, desc, data)))
1643 WARN("Failed to initialize texture, hr %#x.\n", hr);
1644 HeapFree(GetProcessHeap(), 0, object);
1645 return hr;
1648 TRACE("Created 3D texture %p.\n", object);
1649 *texture = &object->ID3D10Texture3D_iface;
1651 return S_OK;
1654 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1655 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1657 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1658 struct d3d10_shader_resource_view *object;
1659 HRESULT hr;
1661 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1663 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1664 return E_OUTOFMEMORY;
1666 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1668 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1669 HeapFree(GetProcessHeap(), 0, object);
1670 return hr;
1673 TRACE("Created shader resource view %p.\n", object);
1674 *view = &object->ID3D10ShaderResourceView_iface;
1676 return S_OK;
1679 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1680 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1682 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1683 struct d3d10_rendertarget_view *object;
1684 HRESULT hr;
1686 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1688 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1689 return E_OUTOFMEMORY;
1691 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1693 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1694 HeapFree(GetProcessHeap(), 0, object);
1695 return hr;
1698 TRACE("Created rendertarget view %p.\n", object);
1699 *view = &object->ID3D10RenderTargetView_iface;
1701 return S_OK;
1704 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1705 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1707 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1708 struct d3d10_depthstencil_view *object;
1709 HRESULT hr;
1711 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1713 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1714 return E_OUTOFMEMORY;
1716 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1718 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1719 HeapFree(GetProcessHeap(), 0, object);
1720 return hr;
1723 TRACE("Created depthstencil view %p.\n", object);
1724 *view = &object->ID3D10DepthStencilView_iface;
1726 return S_OK;
1729 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1730 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1731 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1732 ID3D10InputLayout **input_layout)
1734 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1735 struct d3d10_input_layout *object;
1736 HRESULT hr;
1738 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
1739 "shader_byte_code_length %lu, input_layout %p\n",
1740 iface, element_descs, element_count, shader_byte_code,
1741 shader_byte_code_length, input_layout);
1743 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1744 if (!object)
1745 return E_OUTOFMEMORY;
1747 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1748 shader_byte_code, shader_byte_code_length);
1749 if (FAILED(hr))
1751 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1752 HeapFree(GetProcessHeap(), 0, object);
1753 return hr;
1756 TRACE("Created input layout %p.\n", object);
1757 *input_layout = &object->ID3D10InputLayout_iface;
1759 return S_OK;
1762 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1763 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1765 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1766 struct d3d10_vertex_shader *object;
1767 HRESULT hr;
1769 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1770 iface, byte_code, byte_code_length, shader);
1772 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1773 if (!object)
1774 return E_OUTOFMEMORY;
1776 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1777 if (FAILED(hr))
1779 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1780 HeapFree(GetProcessHeap(), 0, object);
1781 return hr;
1784 TRACE("Created vertex shader %p.\n", object);
1785 *shader = &object->ID3D10VertexShader_iface;
1787 return S_OK;
1790 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1791 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1793 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1794 struct d3d10_geometry_shader *object;
1795 HRESULT hr;
1797 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1798 iface, byte_code, byte_code_length, shader);
1800 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1801 if (!object)
1802 return E_OUTOFMEMORY;
1804 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1805 if (FAILED(hr))
1807 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1808 HeapFree(GetProcessHeap(), 0, object);
1809 return hr;
1812 TRACE("Created geometry shader %p.\n", object);
1813 *shader = &object->ID3D10GeometryShader_iface;
1815 return S_OK;
1818 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1819 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1820 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1822 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
1823 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1824 iface, byte_code, byte_code_length, output_stream_decls,
1825 output_stream_decl_count, output_stream_stride, shader);
1827 return E_NOTIMPL;
1830 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1831 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1833 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1834 struct d3d10_pixel_shader *object;
1835 HRESULT hr;
1837 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1838 iface, byte_code, byte_code_length, shader);
1840 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1841 if (!object)
1842 return E_OUTOFMEMORY;
1844 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1845 if (FAILED(hr))
1847 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1848 HeapFree(GetProcessHeap(), 0, object);
1849 return hr;
1852 TRACE("Created pixel shader %p.\n", object);
1853 *shader = &object->ID3D10PixelShader_iface;
1855 return S_OK;
1858 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1859 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1861 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1862 struct d3d10_blend_state *object;
1863 struct wine_rb_entry *entry;
1864 HRESULT hr;
1866 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1868 if (!desc)
1869 return E_INVALIDARG;
1871 wined3d_mutex_lock();
1872 if ((entry = wine_rb_get(&device->blend_states, desc)))
1874 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1876 TRACE("Returning existing blend state %p.\n", object);
1877 *blend_state = &object->ID3D10BlendState_iface;
1878 ID3D10BlendState_AddRef(*blend_state);
1879 wined3d_mutex_unlock();
1881 return S_OK;
1883 wined3d_mutex_unlock();
1885 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1886 if (!object)
1887 return E_OUTOFMEMORY;
1889 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1891 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1892 HeapFree(GetProcessHeap(), 0, object);
1893 return hr;
1896 TRACE("Created blend state %p.\n", object);
1897 *blend_state = &object->ID3D10BlendState_iface;
1899 return S_OK;
1902 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1903 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1905 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1906 struct d3d10_depthstencil_state *object;
1907 D3D10_DEPTH_STENCIL_DESC tmp_desc;
1908 struct wine_rb_entry *entry;
1909 HRESULT hr;
1911 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1913 if (!desc)
1914 return E_INVALIDARG;
1916 /* D3D10_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
1917 * it as a key in the rbtree. */
1918 memset(&tmp_desc, 0, sizeof(tmp_desc));
1919 tmp_desc.DepthEnable = desc->DepthEnable;
1920 tmp_desc.DepthWriteMask = desc->DepthWriteMask;
1921 tmp_desc.DepthFunc = desc->DepthFunc;
1922 tmp_desc.StencilEnable = desc->StencilEnable;
1923 tmp_desc.StencilReadMask = desc->StencilReadMask;
1924 tmp_desc.StencilWriteMask = desc->StencilWriteMask;
1925 tmp_desc.FrontFace = desc->FrontFace;
1926 tmp_desc.BackFace = desc->BackFace;
1928 wined3d_mutex_lock();
1929 if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
1931 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1933 TRACE("Returning existing depthstencil state %p.\n", object);
1934 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1935 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1936 wined3d_mutex_unlock();
1938 return S_OK;
1940 wined3d_mutex_unlock();
1942 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1943 if (!object)
1944 return E_OUTOFMEMORY;
1946 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, &tmp_desc)))
1948 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1949 HeapFree(GetProcessHeap(), 0, object);
1950 return hr;
1953 TRACE("Created depthstencil state %p.\n", object);
1954 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1956 return S_OK;
1959 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1960 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1962 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1963 struct d3d10_rasterizer_state *object;
1964 struct wine_rb_entry *entry;
1965 HRESULT hr;
1967 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1969 if (!desc)
1970 return E_INVALIDARG;
1972 wined3d_mutex_lock();
1973 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1975 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1977 TRACE("Returning existing rasterizer state %p.\n", object);
1978 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1979 ID3D10RasterizerState_AddRef(*rasterizer_state);
1980 wined3d_mutex_unlock();
1982 return S_OK;
1984 wined3d_mutex_unlock();
1986 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1987 if (!object)
1988 return E_OUTOFMEMORY;
1990 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1992 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1993 HeapFree(GetProcessHeap(), 0, object);
1994 return hr;
1997 TRACE("Created rasterizer state %p.\n", object);
1998 *rasterizer_state = &object->ID3D10RasterizerState_iface;
2000 return S_OK;
2003 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
2004 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
2006 struct d3d10_device *device = impl_from_ID3D10Device(iface);
2007 struct d3d10_sampler_state *object;
2008 struct wine_rb_entry *entry;
2009 HRESULT hr;
2011 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
2013 if (!desc)
2014 return E_INVALIDARG;
2016 wined3d_mutex_lock();
2017 if ((entry = wine_rb_get(&device->sampler_states, desc)))
2019 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
2021 TRACE("Returning existing sampler state %p.\n", object);
2022 *sampler_state = &object->ID3D10SamplerState_iface;
2023 ID3D10SamplerState_AddRef(*sampler_state);
2024 wined3d_mutex_unlock();
2026 return S_OK;
2028 wined3d_mutex_unlock();
2030 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
2031 if (!object)
2032 return E_OUTOFMEMORY;
2034 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
2036 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
2037 HeapFree(GetProcessHeap(), 0, object);
2038 return hr;
2041 TRACE("Created sampler state %p.\n", object);
2042 *sampler_state = &object->ID3D10SamplerState_iface;
2044 return S_OK;
2047 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
2048 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
2050 struct d3d10_device *device = impl_from_ID3D10Device(iface);
2051 struct d3d10_query *object;
2052 HRESULT hr;
2054 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
2056 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2057 return E_OUTOFMEMORY;
2059 if (FAILED(hr = d3d10_query_init(object, device, desc, FALSE)))
2061 WARN("Failed to initialize query, hr %#x.\n", hr);
2062 HeapFree(GetProcessHeap(), 0, object);
2063 return hr;
2066 TRACE("Created query %p.\n", object);
2067 *query = &object->ID3D10Query_iface;
2069 return S_OK;
2072 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
2073 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
2075 struct d3d10_device *device = impl_from_ID3D10Device(iface);
2076 struct d3d10_query *object;
2077 HRESULT hr;
2079 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
2081 if (!desc)
2082 return E_INVALIDARG;
2084 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
2086 WARN("Query type %#x is not a predicate.\n", desc->Query);
2087 return E_INVALIDARG;
2090 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2091 return E_OUTOFMEMORY;
2093 if (FAILED(hr = d3d10_query_init(object, device, desc, TRUE)))
2095 WARN("Failed to initialize predicate, hr %#x.\n", hr);
2096 HeapFree(GetProcessHeap(), 0, object);
2097 return hr;
2100 TRACE("Created predicate %p.\n", object);
2101 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
2103 return S_OK;
2106 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
2107 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
2109 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
2111 return E_NOTIMPL;
2114 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
2115 DXGI_FORMAT format, UINT *format_support)
2117 FIXME("iface %p, format %s, format_support %p stub!\n",
2118 iface, debug_dxgi_format(format), format_support);
2120 return E_NOTIMPL;
2123 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
2124 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
2126 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
2127 iface, debug_dxgi_format(format), sample_count, quality_level_count);
2129 return E_NOTIMPL;
2132 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
2134 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
2137 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
2138 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
2139 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
2141 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
2142 "units %p, units_length %p, description %p, description_length %p stub!\n",
2143 iface, desc, type, active_counters, name, name_length,
2144 units, units_length, description, description_length);
2146 return E_NOTIMPL;
2149 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
2151 FIXME("iface %p stub!\n", iface);
2153 return 0;
2156 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
2157 HANDLE resource_handle, REFIID guid, void **resource)
2159 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
2160 iface, resource_handle, debugstr_guid(guid), resource);
2162 return E_NOTIMPL;
2165 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
2167 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
2170 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
2172 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
2175 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
2176 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
2178 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
2180 return E_NOTIMPL;
2183 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
2184 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
2186 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
2188 return E_NOTIMPL;
2191 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
2193 FIXME("iface %p stub!\n", iface);
2195 return D3D10_FEATURE_LEVEL_10_1;
2198 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
2200 /* IUnknown methods */
2201 d3d10_device_QueryInterface,
2202 d3d10_device_AddRef,
2203 d3d10_device_Release,
2204 /* ID3D10Device methods */
2205 d3d10_device_VSSetConstantBuffers,
2206 d3d10_device_PSSetShaderResources,
2207 d3d10_device_PSSetShader,
2208 d3d10_device_PSSetSamplers,
2209 d3d10_device_VSSetShader,
2210 d3d10_device_DrawIndexed,
2211 d3d10_device_Draw,
2212 d3d10_device_PSSetConstantBuffers,
2213 d3d10_device_IASetInputLayout,
2214 d3d10_device_IASetVertexBuffers,
2215 d3d10_device_IASetIndexBuffer,
2216 d3d10_device_DrawIndexedInstanced,
2217 d3d10_device_DrawInstanced,
2218 d3d10_device_GSSetConstantBuffers,
2219 d3d10_device_GSSetShader,
2220 d3d10_device_IASetPrimitiveTopology,
2221 d3d10_device_VSSetShaderResources,
2222 d3d10_device_VSSetSamplers,
2223 d3d10_device_SetPredication,
2224 d3d10_device_GSSetShaderResources,
2225 d3d10_device_GSSetSamplers,
2226 d3d10_device_OMSetRenderTargets,
2227 d3d10_device_OMSetBlendState,
2228 d3d10_device_OMSetDepthStencilState,
2229 d3d10_device_SOSetTargets,
2230 d3d10_device_DrawAuto,
2231 d3d10_device_RSSetState,
2232 d3d10_device_RSSetViewports,
2233 d3d10_device_RSSetScissorRects,
2234 d3d10_device_CopySubresourceRegion,
2235 d3d10_device_CopyResource,
2236 d3d10_device_UpdateSubresource,
2237 d3d10_device_ClearRenderTargetView,
2238 d3d10_device_ClearDepthStencilView,
2239 d3d10_device_GenerateMips,
2240 d3d10_device_ResolveSubresource,
2241 d3d10_device_VSGetConstantBuffers,
2242 d3d10_device_PSGetShaderResources,
2243 d3d10_device_PSGetShader,
2244 d3d10_device_PSGetSamplers,
2245 d3d10_device_VSGetShader,
2246 d3d10_device_PSGetConstantBuffers,
2247 d3d10_device_IAGetInputLayout,
2248 d3d10_device_IAGetVertexBuffers,
2249 d3d10_device_IAGetIndexBuffer,
2250 d3d10_device_GSGetConstantBuffers,
2251 d3d10_device_GSGetShader,
2252 d3d10_device_IAGetPrimitiveTopology,
2253 d3d10_device_VSGetShaderResources,
2254 d3d10_device_VSGetSamplers,
2255 d3d10_device_GetPredication,
2256 d3d10_device_GSGetShaderResources,
2257 d3d10_device_GSGetSamplers,
2258 d3d10_device_OMGetRenderTargets,
2259 d3d10_device_OMGetBlendState,
2260 d3d10_device_OMGetDepthStencilState,
2261 d3d10_device_SOGetTargets,
2262 d3d10_device_RSGetState,
2263 d3d10_device_RSGetViewports,
2264 d3d10_device_RSGetScissorRects,
2265 d3d10_device_GetDeviceRemovedReason,
2266 d3d10_device_SetExceptionMode,
2267 d3d10_device_GetExceptionMode,
2268 d3d10_device_GetPrivateData,
2269 d3d10_device_SetPrivateData,
2270 d3d10_device_SetPrivateDataInterface,
2271 d3d10_device_ClearState,
2272 d3d10_device_Flush,
2273 d3d10_device_CreateBuffer,
2274 d3d10_device_CreateTexture1D,
2275 d3d10_device_CreateTexture2D,
2276 d3d10_device_CreateTexture3D,
2277 d3d10_device_CreateShaderResourceView,
2278 d3d10_device_CreateRenderTargetView,
2279 d3d10_device_CreateDepthStencilView,
2280 d3d10_device_CreateInputLayout,
2281 d3d10_device_CreateVertexShader,
2282 d3d10_device_CreateGeometryShader,
2283 d3d10_device_CreateGeometryShaderWithStreamOutput,
2284 d3d10_device_CreatePixelShader,
2285 d3d10_device_CreateBlendState,
2286 d3d10_device_CreateDepthStencilState,
2287 d3d10_device_CreateRasterizerState,
2288 d3d10_device_CreateSamplerState,
2289 d3d10_device_CreateQuery,
2290 d3d10_device_CreatePredicate,
2291 d3d10_device_CreateCounter,
2292 d3d10_device_CheckFormatSupport,
2293 d3d10_device_CheckMultisampleQualityLevels,
2294 d3d10_device_CheckCounterInfo,
2295 d3d10_device_CheckCounter,
2296 d3d10_device_GetCreationFlags,
2297 d3d10_device_OpenSharedResource,
2298 d3d10_device_SetTextFilterSize,
2299 d3d10_device_GetTextFilterSize,
2300 d3d10_device_CreateShaderResourceView1,
2301 d3d10_device_CreateBlendState1,
2302 d3d10_device_GetFeatureLevel,
2305 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
2307 /* IUnknown methods */
2308 d3d10_device_inner_QueryInterface,
2309 d3d10_device_inner_AddRef,
2310 d3d10_device_inner_Release,
2313 /* ID3D11Device methods */
2315 static inline struct d3d10_device *impl_from_ID3D11Device(ID3D11Device *iface)
2317 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D11Device_iface);
2320 static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out)
2322 struct d3d10_device *device = impl_from_ID3D11Device(iface);
2323 return IUnknown_QueryInterface(device->outer_unk, riid, out);
2326 static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device *iface)
2328 struct d3d10_device *device = impl_from_ID3D11Device(iface);
2329 return IUnknown_AddRef(device->outer_unk);
2332 static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface)
2334 struct d3d10_device *device = impl_from_ID3D11Device(iface);
2335 return IUnknown_Release(device->outer_unk);
2338 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc,
2339 const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer)
2341 FIXME("iface %p, desc %p, data %p, buffer %p stub!\n", iface, desc, data, buffer);
2343 return E_NOTIMPL;
2346 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
2347 const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture)
2349 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
2351 return E_NOTIMPL;
2354 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
2355 const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture)
2357 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
2359 return E_NOTIMPL;
2362 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
2363 const D3D11_TEXTURE3D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture3D **texture)
2365 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
2367 return E_NOTIMPL;
2370 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device *iface,
2371 ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11ShaderResourceView **view)
2373 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
2375 return E_NOTIMPL;
2378 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device *iface,
2379 ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11UnorderedAccessView **view)
2381 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
2383 return E_NOTIMPL;
2386 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface,
2387 ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view)
2389 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
2391 return E_NOTIMPL;
2394 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface,
2395 ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11DepthStencilView **view)
2397 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
2399 return E_NOTIMPL;
2402 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *iface,
2403 const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code,
2404 SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout)
2406 FIXME("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2407 "input_layout %p stub!\n", iface, element_descs, element_count, shader_byte_code,
2408 shader_byte_code_length, input_layout);
2410 return E_NOTIMPL;
2413 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code,
2414 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11VertexShader **shader)
2416 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2417 iface, byte_code, byte_code_length, class_linkage, shader);
2419 return E_NOTIMPL;
2422 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device *iface, const void *byte_code,
2423 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
2425 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2426 iface, byte_code, byte_code_length, class_linkage, shader);
2428 return E_NOTIMPL;
2431 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device *iface,
2432 const void *byte_code, SIZE_T byte_code_length, const D3D11_SO_DECLARATION_ENTRY *so_entries,
2433 UINT entry_count, const UINT *buffer_strides, UINT strides_count, UINT rasterized_stream,
2434 ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
2436 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2437 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2438 iface, byte_code, byte_code_length, so_entries, entry_count, buffer_strides, strides_count,
2439 rasterized_stream, class_linkage, shader);
2441 return E_NOTIMPL;
2444 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *iface, const void *byte_code,
2445 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11PixelShader **shader)
2447 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2448 iface, byte_code, byte_code_length, class_linkage, shader);
2450 return E_NOTIMPL;
2453 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *iface, const void *byte_code,
2454 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11HullShader **shader)
2456 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2457 iface, byte_code, byte_code_length, class_linkage, shader);
2459 return E_NOTIMPL;
2462 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code,
2463 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader)
2465 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2466 iface, byte_code, byte_code_length, class_linkage, shader);
2468 return E_NOTIMPL;
2471 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code,
2472 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11ComputeShader **shader)
2474 FIXME("iface %p, byte_code %p, byte_code_lenghth %lu, class_linkage %p, shader %p stub!\n",
2475 iface, byte_code, byte_code_length, class_linkage, shader);
2477 return E_NOTIMPL;
2480 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *iface,
2481 ID3D11ClassLinkage **class_linkage)
2483 FIXME("iface %p, class_linkage %p stub!\n", iface, class_linkage);
2485 return E_NOTIMPL;
2488 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *iface,
2489 const D3D11_BLEND_DESC *desc, ID3D11BlendState **blend_state)
2491 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
2493 return E_NOTIMPL;
2496 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface,
2497 const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state)
2499 FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface, desc, depth_stencil_state);
2501 return E_NOTIMPL;
2504 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface,
2505 const D3D11_RASTERIZER_DESC *desc, ID3D11RasterizerState **rasterizer_state)
2507 FIXME("iface %p, desc %p, rasterizer_state %p stub!\n", iface, desc, rasterizer_state);
2509 return E_NOTIMPL;
2512 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface,
2513 const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state)
2515 FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface, desc, sampler_state);
2517 return E_NOTIMPL;
2520 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
2521 const D3D11_QUERY_DESC *desc, ID3D11Query **query)
2523 FIXME("iface %p, desc %p, query %p stub!\n", iface, desc, query);
2525 return E_NOTIMPL;
2528 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc,
2529 ID3D11Predicate **predicate)
2531 FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
2533 return E_NOTIMPL;
2536 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2537 ID3D11Counter **counter)
2539 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
2541 return E_NOTIMPL;
2544 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device *iface, UINT flags,
2545 ID3D11DeviceContext **context)
2547 FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context);
2549 return E_NOTIMPL;
2552 static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device *iface, HANDLE resource, REFIID riid,
2553 void **out)
2555 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface, resource, debugstr_guid(riid), out);
2557 return E_NOTIMPL;
2560 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *iface, DXGI_FORMAT format,
2561 UINT *format_support)
2563 FIXME("iface %p, format %u, format_support %p stub!\n", iface, format, format_support);
2565 return E_NOTIMPL;
2568 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device *iface,
2569 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
2571 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
2572 iface, format, sample_count, quality_level_count);
2574 return E_NOTIMPL;
2577 static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device *iface, D3D11_COUNTER_INFO *info)
2579 FIXME("iface %p, info %p stub!\n", iface, info);
2582 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2583 D3D11_COUNTER_TYPE *type, UINT *active_counter_count, char *name, UINT *name_length,
2584 char *units, UINT *units_length, char *description, UINT *description_length)
2586 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2587 "units %p, units_length %p, description %p, description_length %p stub!\n",
2588 iface, desc, type, active_counter_count, name, name_length,
2589 units, units_length, description, description_length);
2591 return E_NOTIMPL;
2594 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device *iface, D3D11_FEATURE feature,
2595 void *feature_support_data, UINT feature_support_data_size)
2597 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2598 iface, feature, feature_support_data, feature_support_data_size);
2600 return E_NOTIMPL;
2603 static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface, REFGUID guid,
2604 UINT *data_size, void *data)
2606 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
2608 return E_NOTIMPL;
2611 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface, REFGUID guid,
2612 UINT data_size, const void *data)
2614 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
2616 return E_NOTIMPL;
2619 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device *iface, REFGUID guid,
2620 const IUnknown *data_iface)
2622 FIXME("iface %p, guid %s, data_iface %p stub!\n", iface, debugstr_guid(guid), data_iface);
2624 return E_NOTIMPL;
2627 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device *iface)
2629 FIXME("iface %p stub!\n", iface);
2631 return D3D_FEATURE_LEVEL_10_0;
2634 static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device *iface)
2636 FIXME("iface %p stub!\n", iface);
2638 return 0;
2641 static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device *iface)
2643 FIXME("iface %p stub!\n", iface);
2645 return S_OK;
2648 static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device *iface,
2649 ID3D11DeviceContext **immediate_context)
2651 FIXME("iface %p, immediate_context %p stub!\n", iface, immediate_context);
2654 static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device *iface, UINT flags)
2656 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2658 return E_NOTIMPL;
2661 static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device *iface)
2663 FIXME("iface %p stub!\n", iface);
2665 return 0;
2668 static const struct ID3D11DeviceVtbl d3d11_device_vtbl =
2670 /* IUnknown methods */
2671 d3d11_device_QueryInterface,
2672 d3d11_device_AddRef,
2673 d3d11_device_Release,
2674 /* ID3D11Device methods */
2675 d3d11_device_CreateBuffer,
2676 d3d11_device_CreateTexture1D,
2677 d3d11_device_CreateTexture2D,
2678 d3d11_device_CreateTexture3D,
2679 d3d11_device_CreateShaderResourceView,
2680 d3d11_device_CreateUnorderedAccessView,
2681 d3d11_device_CreateRenderTargetView,
2682 d3d11_device_CreateDepthStencilView,
2683 d3d11_device_CreateInputLayout,
2684 d3d11_device_CreateVertexShader,
2685 d3d11_device_CreateGeometryShader,
2686 d3d11_device_CreateGeometryShaderWithStreamOutput,
2687 d3d11_device_CreatePixelShader,
2688 d3d11_device_CreateHullShader,
2689 d3d11_device_CreateDomainShader,
2690 d3d11_device_CreateComputeShader,
2691 d3d11_device_CreateClassLinkage,
2692 d3d11_device_CreateBlendState,
2693 d3d11_device_CreateDepthStencilState,
2694 d3d11_device_CreateRasterizerState,
2695 d3d11_device_CreateSamplerState,
2696 d3d11_device_CreateQuery,
2697 d3d11_device_CreatePredicate,
2698 d3d11_device_CreateCounter,
2699 d3d11_device_CreateDeferredContext,
2700 d3d11_device_OpenSharedResource,
2701 d3d11_device_CheckFormatSupport,
2702 d3d11_device_CheckMultisampleQualityLevels,
2703 d3d11_device_CheckCounterInfo,
2704 d3d11_device_CheckCounter,
2705 d3d11_device_CheckFeatureSupport,
2706 d3d11_device_GetPrivateData,
2707 d3d11_device_SetPrivateData,
2708 d3d11_device_SetPrivateDataInterface,
2709 d3d11_device_GetFeatureLevel,
2710 d3d11_device_GetCreationFlags,
2711 d3d11_device_GetDeviceRemovedReason,
2712 d3d11_device_GetImmediateContext,
2713 d3d11_device_SetExceptionMode,
2714 d3d11_device_GetExceptionMode,
2717 /* ID3D10Multithread methods */
2719 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
2721 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
2724 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
2726 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
2728 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
2730 return IUnknown_QueryInterface(device->outer_unk, iid, out);
2733 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
2735 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
2737 TRACE("iface %p.\n", iface);
2739 return IUnknown_AddRef(device->outer_unk);
2742 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
2744 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
2746 TRACE("iface %p.\n", iface);
2748 return IUnknown_Release(device->outer_unk);
2751 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
2753 TRACE("iface %p.\n", iface);
2755 wined3d_mutex_lock();
2758 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
2760 TRACE("iface %p.\n", iface);
2762 wined3d_mutex_unlock();
2765 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
2767 FIXME("iface %p, protect %#x stub!\n", iface, protect);
2769 return TRUE;
2772 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
2774 FIXME("iface %p stub!\n", iface);
2776 return TRUE;
2779 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
2781 d3d10_multithread_QueryInterface,
2782 d3d10_multithread_AddRef,
2783 d3d10_multithread_Release,
2784 d3d10_multithread_Enter,
2785 d3d10_multithread_Leave,
2786 d3d10_multithread_SetMultithreadProtected,
2787 d3d10_multithread_GetMultithreadProtected,
2790 /* IWineDXGIDeviceParent IUnknown methods */
2792 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
2794 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
2797 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
2798 REFIID riid, void **ppv)
2800 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2801 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
2804 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
2806 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2807 return IUnknown_AddRef(device->outer_unk);
2810 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
2812 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2813 return IUnknown_Release(device->outer_unk);
2816 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
2817 IWineDXGIDeviceParent *iface)
2819 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2820 return &device->device_parent;
2823 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
2825 /* IUnknown methods */
2826 dxgi_device_parent_QueryInterface,
2827 dxgi_device_parent_AddRef,
2828 dxgi_device_parent_Release,
2829 /* IWineDXGIDeviceParent methods */
2830 dxgi_device_parent_get_wined3d_device_parent,
2833 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
2835 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
2838 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
2839 struct wined3d_device *wined3d_device)
2841 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2843 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
2845 wined3d_device_incref(wined3d_device);
2846 device->wined3d_device = wined3d_device;
2849 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
2851 TRACE("device_parent %p.\n", device_parent);
2854 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
2856 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
2859 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
2860 void *container_parent, struct wined3d_surface *surface, void **parent,
2861 const struct wined3d_parent_ops **parent_ops)
2863 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2864 device_parent, container_parent, surface, parent, parent_ops);
2866 *parent = container_parent;
2867 *parent_ops = &d3d10_null_wined3d_parent_ops;
2869 return S_OK;
2872 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
2873 void *container_parent, struct wined3d_volume *volume, void **parent,
2874 const struct wined3d_parent_ops **parent_ops)
2876 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2877 device_parent, container_parent, volume, parent, parent_ops);
2879 *parent = container_parent;
2880 *parent_ops = &d3d10_null_wined3d_parent_ops;
2882 return S_OK;
2885 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
2886 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
2888 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2889 struct wined3d_resource *sub_resource;
2890 struct d3d10_texture2d *texture;
2891 D3D10_TEXTURE2D_DESC desc;
2892 HRESULT hr;
2894 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
2895 device_parent, container_parent, wined3d_desc, surface);
2897 FIXME("Implement DXGI<->wined3d usage conversion\n");
2899 desc.Width = wined3d_desc->width;
2900 desc.Height = wined3d_desc->height;
2901 desc.MipLevels = 1;
2902 desc.ArraySize = 1;
2903 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
2904 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
2905 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
2906 desc.Usage = D3D10_USAGE_DEFAULT;
2907 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
2908 desc.CPUAccessFlags = 0;
2909 desc.MiscFlags = 0;
2911 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
2912 &desc, NULL, (ID3D10Texture2D **)&texture)))
2914 ERR("CreateTexture2D failed, returning %#x\n", hr);
2915 return hr;
2918 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
2919 *surface = wined3d_surface_from_resource(sub_resource);
2920 wined3d_surface_incref(*surface);
2921 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
2923 return S_OK;
2926 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2927 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2929 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2930 IWineDXGIDevice *wine_device;
2931 HRESULT hr;
2933 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2935 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2936 &IID_IWineDXGIDevice, (void **)&wine_device)))
2938 ERR("Device should implement IWineDXGIDevice.\n");
2939 return E_FAIL;
2942 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2943 IWineDXGIDevice_Release(wine_device);
2944 if (FAILED(hr))
2946 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2947 return hr;
2950 return S_OK;
2953 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2955 device_parent_wined3d_device_created,
2956 device_parent_mode_changed,
2957 device_parent_activate,
2958 device_parent_surface_created,
2959 device_parent_volume_created,
2960 device_parent_create_swapchain_surface,
2961 device_parent_create_swapchain,
2964 static void *d3d10_rb_alloc(size_t size)
2966 return HeapAlloc(GetProcessHeap(), 0, size);
2969 static void *d3d10_rb_realloc(void *ptr, size_t size)
2971 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2974 static void d3d10_rb_free(void *ptr)
2976 HeapFree(GetProcessHeap(), 0, ptr);
2979 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2981 const D3D10_SAMPLER_DESC *ka = key;
2982 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2984 return memcmp(ka, kb, sizeof(*ka));
2987 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2989 d3d10_rb_alloc,
2990 d3d10_rb_realloc,
2991 d3d10_rb_free,
2992 d3d10_sampler_state_compare,
2995 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2997 const D3D10_BLEND_DESC *ka = key;
2998 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
3000 return memcmp(ka, kb, sizeof(*ka));
3003 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
3005 d3d10_rb_alloc,
3006 d3d10_rb_realloc,
3007 d3d10_rb_free,
3008 d3d10_blend_state_compare,
3011 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
3013 const D3D10_DEPTH_STENCIL_DESC *ka = key;
3014 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
3015 const struct d3d10_depthstencil_state, entry)->desc;
3017 return memcmp(ka, kb, sizeof(*ka));
3020 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
3022 d3d10_rb_alloc,
3023 d3d10_rb_realloc,
3024 d3d10_rb_free,
3025 d3d10_depthstencil_state_compare,
3028 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
3030 const D3D10_RASTERIZER_DESC *ka = key;
3031 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
3033 return memcmp(ka, kb, sizeof(*ka));
3036 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
3038 d3d10_rb_alloc,
3039 d3d10_rb_realloc,
3040 d3d10_rb_free,
3041 d3d10_rasterizer_state_compare,
3044 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
3046 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
3047 device->ID3D11Device_iface.lpVtbl = &d3d11_device_vtbl;
3048 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
3049 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
3050 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
3051 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
3052 device->refcount = 1;
3053 /* COM aggregation always takes place */
3054 device->outer_unk = outer_unknown;
3056 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
3058 WARN("Failed to initialize blend state rbtree.\n");
3059 return E_FAIL;
3061 device->blend_factor[0] = 1.0f;
3062 device->blend_factor[1] = 1.0f;
3063 device->blend_factor[2] = 1.0f;
3064 device->blend_factor[3] = 1.0f;
3066 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
3068 WARN("Failed to initialize depthstencil state rbtree.\n");
3069 wine_rb_destroy(&device->blend_states, NULL, NULL);
3070 return E_FAIL;
3073 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
3075 WARN("Failed to initialize rasterizer state rbtree.\n");
3076 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
3077 wine_rb_destroy(&device->blend_states, NULL, NULL);
3078 return E_FAIL;
3081 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
3083 WARN("Failed to initialize sampler state rbtree.\n");
3084 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
3085 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
3086 wine_rb_destroy(&device->blend_states, NULL, NULL);
3087 return E_FAIL;
3090 return S_OK;