d3d11: Implement d3d11_immediate_context_SOGetTargets().
[wine/multimedia.git] / dlls / d3d11 / device.c
blob56836214d918000b0ff4269be76f83aca2618567
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 #define NONAMELESSUNION
24 #include "d3d11_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
28 static void STDMETHODCALLTYPE d3d_null_wined3d_object_destroyed(void *parent) {}
30 const struct wined3d_parent_ops d3d_null_wined3d_parent_ops =
32 d3d_null_wined3d_object_destroyed,
35 /* ID3D11DeviceContext - immediate context methods */
37 static inline struct d3d11_immediate_context *impl_from_ID3D11DeviceContext(ID3D11DeviceContext *iface)
39 return CONTAINING_RECORD(iface, struct d3d11_immediate_context, ID3D11DeviceContext_iface);
42 static inline struct d3d_device *device_from_immediate_ID3D11DeviceContext(ID3D11DeviceContext *iface)
44 struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface);
45 return CONTAINING_RECORD(context, struct d3d_device, immediate_context);
48 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_QueryInterface(ID3D11DeviceContext *iface,
49 REFIID riid, void **out)
51 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
53 if (IsEqualGUID(riid, &IID_ID3D11DeviceContext)
54 || IsEqualGUID(riid, &IID_ID3D11DeviceChild)
55 || IsEqualGUID(riid, &IID_IUnknown))
57 ID3D11DeviceContext_AddRef(iface);
58 *out = iface;
59 return S_OK;
62 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
63 *out = NULL;
64 return E_NOINTERFACE;
67 static ULONG STDMETHODCALLTYPE d3d11_immediate_context_AddRef(ID3D11DeviceContext *iface)
69 struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface);
70 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
71 ULONG refcount = InterlockedIncrement(&context->refcount);
73 TRACE("%p increasing refcount to %u.\n", context, refcount);
75 if (refcount == 1)
77 ID3D11Device_AddRef(&device->ID3D11Device_iface);
80 return refcount;
83 static ULONG STDMETHODCALLTYPE d3d11_immediate_context_Release(ID3D11DeviceContext *iface)
85 struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface);
86 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
87 ULONG refcount = InterlockedDecrement(&context->refcount);
89 TRACE("%p decreasing refcount to %u.\n", context, refcount);
91 if (!refcount)
93 ID3D11Device_Release(&device->ID3D11Device_iface);
96 return refcount;
99 static void STDMETHODCALLTYPE d3d11_immediate_context_GetDevice(ID3D11DeviceContext *iface, ID3D11Device **device)
101 struct d3d_device *device_object = device_from_immediate_ID3D11DeviceContext(iface);
103 TRACE("iface %p, device %p.\n", iface, device);
105 *device = &device_object->ID3D11Device_iface;
106 ID3D11Device_AddRef(*device);
109 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext *iface, REFGUID guid,
110 UINT *data_size, void *data)
112 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
114 return E_NOTIMPL;
117 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext *iface, REFGUID guid,
118 UINT data_size, const void *data)
120 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
122 return E_NOTIMPL;
125 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext *iface,
126 REFGUID guid, const IUnknown *data)
128 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
130 return E_NOTIMPL;
133 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext *iface,
134 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
136 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(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 d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(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 d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext *iface,
154 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
156 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(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 d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(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 d3d11_immediate_context_PSSetShader(ID3D11DeviceContext *iface,
174 ID3D11PixelShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
176 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
177 struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D11PixelShader(shader);
179 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
180 iface, shader, class_instances, class_instance_count);
182 if (class_instances)
183 FIXME("Dynamic linking is not implemented yet.\n");
185 wined3d_mutex_lock();
186 wined3d_device_set_pixel_shader(device->wined3d_device, ps ? ps->wined3d_shader : NULL);
187 wined3d_mutex_unlock();
190 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext *iface,
191 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
193 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
194 unsigned int i;
196 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
197 iface, start_slot, sampler_count, samplers);
199 wined3d_mutex_lock();
200 for (i = 0; i < sampler_count; ++i)
202 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
204 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
205 sampler ? sampler->wined3d_sampler : NULL);
207 wined3d_mutex_unlock();
210 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceContext *iface,
211 ID3D11VertexShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
213 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
214 struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D11VertexShader(shader);
216 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
217 iface, shader, class_instances, class_instance_count);
219 if (class_instances)
220 FIXME("Dynamic linking is not implemented yet.\n");
222 wined3d_mutex_lock();
223 wined3d_device_set_vertex_shader(device->wined3d_device, vs ? vs->wined3d_shader : NULL);
224 wined3d_mutex_unlock();
227 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext *iface,
228 UINT index_count, UINT start_index_location, INT base_vertex_location)
230 FIXME("iface %p, index_count %u, start_index_location %u, base_vertex_location %d stub!\n",
231 iface, index_count, start_index_location, base_vertex_location);
234 static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext *iface,
235 UINT vertex_count, UINT start_vertex_location)
237 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
239 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
240 iface, vertex_count, start_vertex_location);
242 wined3d_mutex_lock();
243 wined3d_device_draw_primitive(device->wined3d_device, start_vertex_location, vertex_count);
244 wined3d_mutex_unlock();
247 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext *iface, ID3D11Resource *resource,
248 UINT subresource_idx, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE *mapped_subresource)
250 struct wined3d_resource *wined3d_resource;
251 struct wined3d_map_desc map_desc;
252 HRESULT hr;
254 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
255 iface, resource, subresource_idx, map_type, map_flags, mapped_subresource);
257 if (map_flags)
258 FIXME("Ignoring map_flags %#x.\n", map_flags);
260 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
262 wined3d_mutex_lock();
263 hr = wined3d_resource_map(wined3d_resource, subresource_idx,
264 &map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type));
265 wined3d_mutex_unlock();
267 mapped_subresource->pData = map_desc.data;
268 mapped_subresource->RowPitch = map_desc.row_pitch;
269 mapped_subresource->DepthPitch = map_desc.slice_pitch;
271 return hr;
274 static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext *iface, ID3D11Resource *resource,
275 UINT subresource_idx)
277 struct wined3d_resource *wined3d_resource;
279 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface, resource, subresource_idx);
281 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
283 wined3d_mutex_lock();
284 wined3d_resource_unmap(wined3d_resource, subresource_idx);
285 wined3d_mutex_unlock();
288 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext *iface,
289 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
291 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
292 unsigned int i;
294 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
295 iface, start_slot, buffer_count, buffers);
297 wined3d_mutex_lock();
298 for (i = 0; i < buffer_count; ++i)
300 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
302 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
303 buffer ? buffer->wined3d_buffer : NULL);
305 wined3d_mutex_unlock();
308 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext *iface,
309 ID3D11InputLayout *input_layout)
311 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
312 struct d3d_input_layout *layout = unsafe_impl_from_ID3D11InputLayout(input_layout);
314 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
316 wined3d_mutex_lock();
317 wined3d_device_set_vertex_declaration(device->wined3d_device, layout ? layout->wined3d_decl : NULL);
318 wined3d_mutex_unlock();
321 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext *iface,
322 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *strides, const UINT *offsets)
324 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
325 unsigned int i;
327 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
328 iface, start_slot, buffer_count, buffers, strides, offsets);
330 wined3d_mutex_lock();
331 for (i = 0; i < buffer_count; ++i)
333 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
335 wined3d_device_set_stream_source(device->wined3d_device, start_slot + i,
336 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
338 wined3d_mutex_unlock();
341 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext *iface,
342 ID3D11Buffer *buffer, DXGI_FORMAT format, UINT offset)
344 FIXME("iface %p, buffer %p, format %s, offset %u stub!\n",
345 iface, buffer, debug_dxgi_format(format), offset);
348 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext *iface,
349 UINT instance_index_count, UINT instance_count, UINT start_index_location, INT base_vertex_location,
350 UINT start_instance_location)
352 FIXME("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
353 "base_vertex_location %d, start_instance_location %u stub!\n",
354 iface, instance_index_count, instance_count, start_index_location,
355 base_vertex_location, start_instance_location);
358 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext *iface,
359 UINT instance_vertex_count, UINT instance_count, UINT start_vertex_location, UINT start_instance_location)
361 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
363 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
364 "start_instance_location %u.\n",
365 iface, instance_vertex_count, instance_count, start_vertex_location,
366 start_instance_location);
368 wined3d_mutex_lock();
369 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
370 instance_vertex_count, start_instance_location, instance_count);
371 wined3d_mutex_unlock();
374 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext *iface,
375 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
377 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
378 unsigned int i;
380 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
381 iface, start_slot, buffer_count, buffers);
383 wined3d_mutex_lock();
384 for (i = 0; i < buffer_count; ++i)
386 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
388 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
389 buffer ? buffer->wined3d_buffer : NULL);
391 wined3d_mutex_unlock();
394 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext *iface,
395 ID3D11GeometryShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
397 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
398 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D11GeometryShader(shader);
400 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
401 iface, shader, class_instances, class_instance_count);
403 if (class_instances)
404 FIXME("Dynamic linking is not implemented yet.\n");
406 wined3d_mutex_lock();
407 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
408 wined3d_mutex_unlock();
411 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext *iface,
412 D3D11_PRIMITIVE_TOPOLOGY topology)
414 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
416 TRACE("iface %p, topology %u.\n", iface, topology);
418 wined3d_mutex_lock();
419 wined3d_device_set_primitive_type(device->wined3d_device, (enum wined3d_primitive_type)topology);
420 wined3d_mutex_unlock();
423 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext *iface,
424 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
426 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
427 unsigned int i;
429 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
431 wined3d_mutex_lock();
432 for (i = 0; i < view_count; ++i)
434 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
436 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
437 view ? view->wined3d_view : NULL);
439 wined3d_mutex_unlock();
442 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext *iface,
443 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
445 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
446 unsigned int i;
448 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
449 iface, start_slot, sampler_count, samplers);
451 wined3d_mutex_lock();
452 for (i = 0; i < sampler_count; ++i)
454 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
456 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
457 sampler ? sampler->wined3d_sampler : NULL);
459 wined3d_mutex_unlock();
462 static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext *iface,
463 ID3D11Asynchronous *asynchronous)
465 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
468 static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext *iface,
469 ID3D11Asynchronous *asynchronous)
471 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
474 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceContext *iface,
475 ID3D11Asynchronous *asynchronous, void *data, UINT data_size, UINT data_flags)
477 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
478 iface, asynchronous, data, data_size, data_flags);
480 return E_NOTIMPL;
483 static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11DeviceContext *iface,
484 ID3D11Predicate *predicate, BOOL value)
486 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
487 struct d3d_query *query;
489 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
491 query = unsafe_impl_from_ID3D11Query((ID3D11Query *)predicate);
493 wined3d_mutex_lock();
494 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
495 wined3d_mutex_unlock();
498 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext *iface,
499 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
501 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
502 unsigned int i;
504 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
506 wined3d_mutex_lock();
507 for (i = 0; i < view_count; ++i)
509 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
511 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
512 view ? view->wined3d_view : NULL);
514 wined3d_mutex_unlock();
517 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext *iface,
518 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
520 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
521 unsigned int i;
523 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
524 iface, start_slot, sampler_count, samplers);
526 wined3d_mutex_lock();
527 for (i = 0; i < sampler_count; ++i)
529 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
531 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
532 sampler ? sampler->wined3d_sampler : NULL);
534 wined3d_mutex_unlock();
537 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext *iface,
538 UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views,
539 ID3D11DepthStencilView *depth_stencil_view)
541 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
542 struct d3d_depthstencil_view *dsv;
543 unsigned int i;
545 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
546 iface, render_target_view_count, render_target_views, depth_stencil_view);
548 wined3d_mutex_lock();
549 for (i = 0; i < render_target_view_count; ++i)
551 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D11RenderTargetView(render_target_views[i]);
552 wined3d_device_set_rendertarget_view(device->wined3d_device, i, rtv ? rtv->wined3d_view : NULL, FALSE);
554 for (; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
556 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
559 dsv = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view);
560 wined3d_device_set_depth_stencil_view(device->wined3d_device, dsv ? dsv->wined3d_view : NULL);
561 wined3d_mutex_unlock();
564 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
565 ID3D11DeviceContext *iface, UINT render_target_view_count,
566 ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view,
567 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
568 ID3D11UnorderedAccessView *const *unordered_access_views, const UINT *initial_counts)
570 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
571 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
572 "initial_counts %p stub!\n",
573 iface, render_target_view_count, render_target_views, depth_stencil_view,
574 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views,
575 initial_counts);
578 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext *iface,
579 ID3D11BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
581 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
582 const D3D11_BLEND_DESC *desc;
584 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
585 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
587 if (blend_factor[0] != 1.0f || blend_factor[1] != 1.0f || blend_factor[2] != 1.0f || blend_factor[3] != 1.0f)
588 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
589 blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
591 wined3d_mutex_lock();
592 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
593 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
594 if (!(device->blend_state = unsafe_impl_from_ID3D11BlendState(blend_state)))
596 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE);
597 wined3d_device_set_render_state(device->wined3d_device,
598 WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL);
599 wined3d_device_set_render_state(device->wined3d_device,
600 WINED3D_RS_COLORWRITEENABLE1, D3D11_COLOR_WRITE_ENABLE_ALL);
601 wined3d_device_set_render_state(device->wined3d_device,
602 WINED3D_RS_COLORWRITEENABLE2, D3D11_COLOR_WRITE_ENABLE_ALL);
603 wined3d_device_set_render_state(device->wined3d_device,
604 WINED3D_RS_COLORWRITEENABLE3, D3D11_COLOR_WRITE_ENABLE_ALL);
605 wined3d_mutex_unlock();
606 return;
609 desc = &device->blend_state->desc;
610 /* glSampleCoverage() */
611 if (desc->AlphaToCoverageEnable)
612 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc->AlphaToCoverageEnable);
613 /* glEnableIndexedEXT(GL_BLEND, ...) */
614 FIXME("Per-rendertarget blend not implemented.\n");
615 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE,
616 desc->RenderTarget[0].BlendEnable);
617 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLEND, desc->RenderTarget[0].SrcBlend);
618 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLEND, desc->RenderTarget[0].DestBlend);
619 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOP, desc->RenderTarget[0].BlendOp);
620 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SEPARATEALPHABLENDENABLE, TRUE);
621 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA,
622 desc->RenderTarget[0].SrcBlendAlpha);
623 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA,
624 desc->RenderTarget[0].DestBlendAlpha);
625 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA,
626 desc->RenderTarget[0].BlendOpAlpha);
627 FIXME("Color mask > 3 not implemented.\n");
628 wined3d_device_set_render_state(device->wined3d_device,
629 WINED3D_RS_COLORWRITEENABLE, desc->RenderTarget[0].RenderTargetWriteMask);
630 wined3d_device_set_render_state(device->wined3d_device,
631 WINED3D_RS_COLORWRITEENABLE1, desc->RenderTarget[1].RenderTargetWriteMask);
632 wined3d_device_set_render_state(device->wined3d_device,
633 WINED3D_RS_COLORWRITEENABLE2, desc->RenderTarget[2].RenderTargetWriteMask);
634 wined3d_device_set_render_state(device->wined3d_device,
635 WINED3D_RS_COLORWRITEENABLE3, desc->RenderTarget[3].RenderTargetWriteMask);
636 wined3d_mutex_unlock();
639 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext *iface,
640 ID3D11DepthStencilState *depth_stencil_state, UINT stencil_ref)
642 FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n", iface, depth_stencil_state, stencil_ref);
645 static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext *iface, UINT buffer_count,
646 ID3D11Buffer *const *buffers, const UINT *offsets)
648 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
649 unsigned int count, i;
651 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface, buffer_count, buffers, offsets);
653 count = min(buffer_count, D3D11_SO_BUFFER_SLOT_COUNT);
654 wined3d_mutex_lock();
655 for (i = 0; i < count; ++i)
657 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
659 wined3d_device_set_stream_output(device->wined3d_device, i,
660 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
662 for (; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i)
664 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
666 wined3d_mutex_unlock();
669 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawAuto(ID3D11DeviceContext *iface)
671 FIXME("iface %p stub!\n", iface);
674 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext *iface,
675 ID3D11Buffer *buffer, UINT offset)
677 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
680 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext *iface,
681 ID3D11Buffer *buffer, UINT offset)
683 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
686 static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceContext *iface,
687 UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z)
689 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
690 iface, thread_group_count_x, thread_group_count_y, thread_group_count_z);
693 static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext *iface,
694 ID3D11Buffer *buffer, UINT offset)
696 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
699 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceContext *iface,
700 ID3D11RasterizerState *rasterizer_state)
702 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
703 const D3D11_RASTERIZER_DESC *desc;
705 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
707 wined3d_mutex_lock();
708 if (!(device->rasterizer_state = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state)))
710 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
711 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
712 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
713 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
714 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
715 wined3d_mutex_unlock();
716 return;
719 desc = &device->rasterizer_state->desc;
720 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
721 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
722 /* glFrontFace() */
723 if (desc->FrontCounterClockwise)
724 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
725 /* OpenGL style depth bias. */
726 if (desc->DepthBias || desc->SlopeScaledDepthBias)
727 FIXME("Ignoring depth bias.\n");
728 /* GL_DEPTH_CLAMP */
729 if (!desc->DepthClipEnable)
730 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
731 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
732 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
733 wined3d_device_set_render_state(device->wined3d_device,
734 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
735 wined3d_mutex_unlock();
738 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext *iface,
739 UINT viewport_count, const D3D11_VIEWPORT *viewports)
741 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
742 struct wined3d_viewport wined3d_vp;
744 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
746 if (viewport_count > 1)
747 FIXME("Multiple viewports not implemented.\n");
749 if (!viewport_count)
750 return;
752 if (viewports[0].TopLeftX != (UINT)viewports[0].TopLeftX
753 || viewports[0].TopLeftY != (UINT)viewports[0].TopLeftY
754 || viewports[0].Width != (UINT)viewports[0].Width
755 || viewports[0].Height != (UINT)viewports[0].Height)
756 FIXME("Floating-point viewports not implemented.\n");
758 wined3d_vp.x = viewports[0].TopLeftX;
759 wined3d_vp.y = viewports[0].TopLeftY;
760 wined3d_vp.width = viewports[0].Width;
761 wined3d_vp.height = viewports[0].Height;
762 wined3d_vp.min_z = viewports[0].MinDepth;
763 wined3d_vp.max_z = viewports[0].MaxDepth;
765 wined3d_mutex_lock();
766 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
767 wined3d_mutex_unlock();
770 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext *iface,
771 UINT rect_count, const D3D11_RECT *rects)
773 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
775 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
777 if (rect_count > 1)
778 FIXME("Multiple scissor rects not implemented.\n");
780 if (!rect_count)
781 return;
783 wined3d_mutex_lock();
784 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
785 wined3d_mutex_unlock();
788 static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext *iface,
789 ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
790 ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box)
792 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
793 "src_resource %p, src_subresource_idx %u, src_box %p stub!\n",
794 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
795 src_resource, src_subresource_idx, src_box);
798 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext *iface,
799 ID3D11Resource *dst_resource, ID3D11Resource *src_resource)
801 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
802 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
804 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
806 wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource);
807 wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource);
808 wined3d_mutex_lock();
809 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
810 wined3d_mutex_unlock();
813 static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext *iface,
814 ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box,
815 const void *data, UINT row_pitch, UINT depth_pitch)
817 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
818 struct wined3d_resource *wined3d_resource;
819 struct wined3d_box wined3d_box;
821 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
822 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
824 if (box)
826 wined3d_box.left = box->left;
827 wined3d_box.top = box->top;
828 wined3d_box.front = box->front;
829 wined3d_box.right = box->right;
830 wined3d_box.bottom = box->bottom;
831 wined3d_box.back = box->back;
834 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
835 wined3d_mutex_lock();
836 wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource,
837 subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch);
838 wined3d_mutex_unlock();
841 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext *iface,
842 ID3D11Buffer *dst_buffer, UINT dst_offset, ID3D11UnorderedAccessView *src_view)
844 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
845 iface, dst_buffer, dst_offset, src_view);
848 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext *iface,
849 ID3D11RenderTargetView *render_target_view, const FLOAT color_rgba[4])
851 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
852 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D11RenderTargetView(render_target_view);
853 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
854 HRESULT hr;
856 TRACE("iface %p, render_target_view %p, color_rgba {%.8e %.8e %.8e %.8e}.\n",
857 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
859 wined3d_mutex_lock();
860 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
861 ERR("Failed to clear view, hr %#x.\n", hr);
862 wined3d_mutex_unlock();
865 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext *iface,
866 ID3D11UnorderedAccessView *unordered_access_view, const UINT values[4])
868 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
869 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
872 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext *iface,
873 ID3D11UnorderedAccessView *unordered_access_view, const FLOAT values[4])
875 FIXME("iface %p, unordered_access_view %p, values {%.8e %.8e %.8e %.8e} stub!\n",
876 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
879 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext *iface,
880 ID3D11DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
882 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
883 iface, depth_stencil_view, flags, depth, stencil);
886 static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface,
887 ID3D11ShaderResourceView *view)
889 FIXME("iface %p, view %p stub!\n", iface, view);
892 static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
893 ID3D11Resource *resource, FLOAT min_lod)
895 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface, resource, min_lod);
898 static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext *iface,
899 ID3D11Resource *resource)
901 FIXME("iface %p, resource %p stub!\n", iface, resource);
903 return 0.0f;
906 static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext *iface,
907 ID3D11Resource *dst_resource, UINT dst_subresource_idx,
908 ID3D11Resource *src_resource, UINT src_subresource_idx,
909 DXGI_FORMAT format)
911 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
912 "format %s stub!\n",
913 iface, dst_resource, dst_subresource_idx, src_resource, src_subresource_idx,
914 debug_dxgi_format(format));
917 static void STDMETHODCALLTYPE d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext *iface,
918 ID3D11CommandList *command_list, BOOL restore_state)
920 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface, command_list, restore_state);
923 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext *iface,
924 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
926 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
927 iface, start_slot, view_count, views);
930 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext *iface,
931 ID3D11HullShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
933 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
934 iface, shader, class_instances, class_instance_count);
937 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext *iface,
938 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
940 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
941 iface, start_slot, sampler_count, samplers);
944 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext *iface,
945 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
947 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
948 iface, start_slot, buffer_count, buffers);
951 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext *iface,
952 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
954 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
955 iface, start_slot, view_count, views);
958 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext *iface,
959 ID3D11DomainShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
961 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
962 iface, shader, class_instances, class_instance_count);
965 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext *iface,
966 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
968 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
969 iface, start_slot, sampler_count, samplers);
972 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext *iface,
973 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
975 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
976 iface, start_slot, buffer_count, buffers);
979 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext *iface,
980 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
982 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
983 iface, start_slot, view_count, views);
986 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext *iface,
987 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts)
989 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
990 iface, start_slot, view_count, views, initial_counts);
993 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext *iface,
994 ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
996 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
997 iface, shader, class_instances, class_instance_count);
1000 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext *iface,
1001 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
1003 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1004 iface, start_slot, sampler_count, samplers);
1007 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext *iface,
1008 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
1010 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1011 iface, start_slot, buffer_count, buffers);
1014 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext *iface,
1015 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1017 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1018 unsigned int i;
1020 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1021 iface, start_slot, buffer_count, buffers);
1023 wined3d_mutex_lock();
1024 for (i = 0; i < buffer_count; ++i)
1026 struct wined3d_buffer *wined3d_buffer;
1027 struct d3d_buffer *buffer_impl;
1029 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
1031 buffers[i] = NULL;
1032 continue;
1035 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1036 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1037 ID3D11Buffer_AddRef(buffers[i]);
1039 wined3d_mutex_unlock();
1042 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext *iface,
1043 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1045 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1046 unsigned int i;
1048 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1049 iface, start_slot, view_count, views);
1051 wined3d_mutex_lock();
1052 for (i = 0; i < view_count; ++i)
1054 struct wined3d_shader_resource_view *wined3d_view;
1055 struct d3d_shader_resource_view *view_impl;
1057 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
1059 views[i] = NULL;
1060 continue;
1063 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1064 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1065 ID3D11ShaderResourceView_AddRef(views[i]);
1067 wined3d_mutex_unlock();
1070 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceContext *iface,
1071 ID3D11PixelShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1073 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1074 struct wined3d_shader *wined3d_shader;
1075 struct d3d_pixel_shader *shader_impl;
1077 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1078 iface, shader, class_instances, class_instance_count);
1080 if (class_instances || class_instance_count)
1081 FIXME("Dynamic linking not implemented yet.\n");
1083 wined3d_mutex_lock();
1084 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
1086 wined3d_mutex_unlock();
1087 *shader = NULL;
1088 return;
1091 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1092 wined3d_mutex_unlock();
1093 *shader = &shader_impl->ID3D11PixelShader_iface;
1094 ID3D11PixelShader_AddRef(*shader);
1097 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext *iface,
1098 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1100 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1101 unsigned int i;
1103 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1104 iface, start_slot, sampler_count, samplers);
1106 wined3d_mutex_lock();
1107 for (i = 0; i < sampler_count; ++i)
1109 struct wined3d_sampler *wined3d_sampler;
1110 struct d3d_sampler_state *sampler_impl;
1112 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
1114 samplers[i] = NULL;
1115 continue;
1118 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1119 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1120 ID3D11SamplerState_AddRef(samplers[i]);
1122 wined3d_mutex_unlock();
1125 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceContext *iface,
1126 ID3D11VertexShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1128 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1129 struct d3d_vertex_shader *shader_impl;
1130 struct wined3d_shader *wined3d_shader;
1132 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1133 iface, shader, class_instances, class_instance_count);
1135 if (class_instances || class_instance_count)
1136 FIXME("Dynamic linking not implemented yet.\n");
1138 wined3d_mutex_lock();
1139 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
1141 wined3d_mutex_unlock();
1142 *shader = NULL;
1143 return;
1146 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1147 wined3d_mutex_unlock();
1148 *shader = &shader_impl->ID3D11VertexShader_iface;
1149 ID3D11VertexShader_AddRef(*shader);
1152 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext *iface,
1153 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1155 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1156 unsigned int i;
1158 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1159 iface, start_slot, buffer_count, buffers);
1161 wined3d_mutex_lock();
1162 for (i = 0; i < buffer_count; ++i)
1164 struct wined3d_buffer *wined3d_buffer;
1165 struct d3d_buffer *buffer_impl;
1167 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
1169 buffers[i] = NULL;
1170 continue;
1173 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1174 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1175 ID3D11Buffer_AddRef(buffers[i]);
1177 wined3d_mutex_unlock();
1180 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext *iface,
1181 ID3D11InputLayout **input_layout)
1183 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1184 struct wined3d_vertex_declaration *wined3d_declaration;
1185 struct d3d_input_layout *input_layout_impl;
1187 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
1189 wined3d_mutex_lock();
1190 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
1192 wined3d_mutex_unlock();
1193 *input_layout = NULL;
1194 return;
1197 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
1198 wined3d_mutex_unlock();
1199 *input_layout = &input_layout_impl->ID3D11InputLayout_iface;
1200 ID3D11InputLayout_AddRef(*input_layout);
1203 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext *iface,
1204 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *strides, UINT *offsets)
1206 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1207 iface, start_slot, buffer_count, buffers, strides, offsets);
1210 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext *iface,
1211 ID3D11Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
1213 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
1216 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext *iface,
1217 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1219 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1220 unsigned int i;
1222 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1223 iface, start_slot, buffer_count, buffers);
1225 wined3d_mutex_lock();
1226 for (i = 0; i < buffer_count; ++i)
1228 struct wined3d_buffer *wined3d_buffer;
1229 struct d3d_buffer *buffer_impl;
1231 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
1233 buffers[i] = NULL;
1234 continue;
1237 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1238 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1239 ID3D11Buffer_AddRef(buffers[i]);
1241 wined3d_mutex_unlock();
1244 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceContext *iface,
1245 ID3D11GeometryShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1247 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1248 struct d3d_geometry_shader *shader_impl;
1249 struct wined3d_shader *wined3d_shader;
1251 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1252 iface, shader, class_instances, class_instance_count);
1254 if (class_instances || class_instance_count)
1255 FIXME("Dynamic linking not implemented yet.\n");
1257 wined3d_mutex_lock();
1258 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
1260 wined3d_mutex_unlock();
1261 *shader = NULL;
1262 return;
1265 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1266 wined3d_mutex_unlock();
1267 *shader = &shader_impl->ID3D11GeometryShader_iface;
1268 ID3D11GeometryShader_AddRef(*shader);
1271 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext *iface,
1272 D3D11_PRIMITIVE_TOPOLOGY *topology)
1274 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1276 TRACE("iface %p, topology %p.\n", iface, topology);
1278 wined3d_mutex_lock();
1279 wined3d_device_get_primitive_type(device->wined3d_device, (enum wined3d_primitive_type *)topology);
1280 wined3d_mutex_unlock();
1283 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext *iface,
1284 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1286 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1287 unsigned int i;
1289 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
1291 wined3d_mutex_lock();
1292 for (i = 0; i < view_count; ++i)
1294 struct wined3d_shader_resource_view *wined3d_view;
1295 struct d3d_shader_resource_view *view_impl;
1297 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
1299 views[i] = NULL;
1300 continue;
1303 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1304 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1305 ID3D11ShaderResourceView_AddRef(views[i]);
1307 wined3d_mutex_unlock();
1310 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext *iface,
1311 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1313 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1314 unsigned int i;
1316 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1317 iface, start_slot, sampler_count, samplers);
1319 wined3d_mutex_lock();
1320 for (i = 0; i < sampler_count; ++i)
1322 struct wined3d_sampler *wined3d_sampler;
1323 struct d3d_sampler_state *sampler_impl;
1325 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
1327 samplers[i] = NULL;
1328 continue;
1331 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1332 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1333 ID3D11SamplerState_AddRef(samplers[i]);
1335 wined3d_mutex_unlock();
1338 static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11DeviceContext *iface,
1339 ID3D11Predicate **predicate, BOOL *value)
1341 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1342 struct wined3d_query *wined3d_predicate;
1343 struct d3d_query *predicate_impl;
1345 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
1347 wined3d_mutex_lock();
1348 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
1350 wined3d_mutex_unlock();
1351 *predicate = NULL;
1352 return;
1355 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
1356 wined3d_mutex_unlock();
1357 *predicate = (ID3D11Predicate *)&predicate_impl->ID3D11Query_iface;
1358 ID3D11Predicate_AddRef(*predicate);
1361 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext *iface,
1362 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1364 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1365 unsigned int i;
1367 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
1369 wined3d_mutex_lock();
1370 for (i = 0; i < view_count; ++i)
1372 struct wined3d_shader_resource_view *wined3d_view;
1373 struct d3d_shader_resource_view *view_impl;
1375 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
1377 views[i] = NULL;
1378 continue;
1381 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1382 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1383 ID3D11ShaderResourceView_AddRef(views[i]);
1385 wined3d_mutex_unlock();
1388 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext *iface,
1389 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1391 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1392 unsigned int i;
1394 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1395 iface, start_slot, sampler_count, samplers);
1397 wined3d_mutex_lock();
1398 for (i = 0; i < sampler_count; ++i)
1400 struct d3d_sampler_state *sampler_impl;
1401 struct wined3d_sampler *wined3d_sampler;
1403 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
1405 samplers[i] = NULL;
1406 continue;
1409 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1410 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1411 ID3D11SamplerState_AddRef(samplers[i]);
1413 wined3d_mutex_unlock();
1416 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext *iface,
1417 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1418 ID3D11DepthStencilView **depth_stencil_view)
1420 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
1421 iface, render_target_view_count, render_target_views, depth_stencil_view);
1424 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1425 ID3D11DeviceContext *iface,
1426 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1427 ID3D11DepthStencilView **depth_stencil_view,
1428 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
1429 ID3D11UnorderedAccessView **unordered_access_views)
1431 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1432 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1433 "unordered_access_views %p stub!\n",
1434 iface, render_target_view_count, render_target_views, depth_stencil_view,
1435 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views);
1438 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext *iface,
1439 ID3D11BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1441 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1442 iface, blend_state, blend_factor, sample_mask);
1445 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext *iface,
1446 ID3D11DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1448 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface, depth_stencil_state, stencil_ref);
1451 static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext *iface,
1452 UINT buffer_count, ID3D11Buffer **buffers)
1454 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1455 unsigned int i;
1457 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface, buffer_count, buffers);
1459 wined3d_mutex_lock();
1460 for (i = 0; i < buffer_count; ++i)
1462 struct wined3d_buffer *wined3d_buffer;
1463 struct d3d_buffer *buffer_impl;
1465 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, NULL)))
1467 buffers[i] = NULL;
1468 continue;
1471 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1472 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1473 ID3D11Buffer_AddRef(buffers[i]);
1475 wined3d_mutex_unlock();
1478 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceContext *iface,
1479 ID3D11RasterizerState **rasterizer_state)
1481 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1483 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1485 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D11RasterizerState_iface : NULL))
1486 ID3D11RasterizerState_AddRef(*rasterizer_state);
1489 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext *iface,
1490 UINT *viewport_count, D3D11_VIEWPORT *viewports)
1492 FIXME("iface %p, viewport_count %p, viewports %p stub!\n", iface, viewport_count, viewports);
1495 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext *iface,
1496 UINT *rect_count, D3D11_RECT *rects)
1498 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
1501 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext *iface,
1502 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1504 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1507 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceContext *iface,
1508 ID3D11HullShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1510 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1511 iface, shader, class_instances, class_instance_count);
1514 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext *iface,
1515 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1517 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1518 iface, start_slot, sampler_count, samplers);
1521 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext *iface,
1522 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1524 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1525 iface, start_slot, buffer_count, buffers);
1528 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext *iface,
1529 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1531 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1532 iface, start_slot, view_count, views);
1535 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceContext *iface,
1536 ID3D11DomainShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1538 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1539 iface, shader, class_instances, class_instance_count);
1542 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext *iface,
1543 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1545 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1546 iface, start_slot, sampler_count, samplers);
1549 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext *iface,
1550 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1552 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1553 iface, start_slot, buffer_count, buffers);
1556 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext *iface,
1557 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1559 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1562 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext *iface,
1563 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView **views)
1565 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1568 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceContext *iface,
1569 ID3D11ComputeShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1571 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1572 iface, shader, class_instances, class_instance_count);
1575 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext *iface,
1576 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1578 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1579 iface, start_slot, sampler_count, samplers);
1582 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext *iface,
1583 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1585 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1586 iface, start_slot, buffer_count, buffers);
1589 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext *iface)
1591 FIXME("iface %p stub!\n", iface);
1594 static void STDMETHODCALLTYPE d3d11_immediate_context_Flush(ID3D11DeviceContext *iface)
1596 FIXME("iface %p stub!\n", iface);
1599 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_immediate_context_GetType(ID3D11DeviceContext *iface)
1601 TRACE("iface %p.\n", iface);
1603 return D3D11_DEVICE_CONTEXT_IMMEDIATE;
1606 static UINT STDMETHODCALLTYPE d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext *iface)
1608 FIXME("iface %p stub!\n", iface);
1610 return 0;
1613 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext *iface,
1614 BOOL restore, ID3D11CommandList **command_list)
1616 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface, restore, command_list);
1618 return E_NOTIMPL;
1621 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl =
1623 /* IUnknown methods */
1624 d3d11_immediate_context_QueryInterface,
1625 d3d11_immediate_context_AddRef,
1626 d3d11_immediate_context_Release,
1627 /* ID3D11DeviceChild methods */
1628 d3d11_immediate_context_GetDevice,
1629 d3d11_immediate_context_GetPrivateData,
1630 d3d11_immediate_context_SetPrivateData,
1631 d3d11_immediate_context_SetPrivateDataInterface,
1632 /* ID3D11DeviceContext methods */
1633 d3d11_immediate_context_VSSetConstantBuffers,
1634 d3d11_immediate_context_PSSetShaderResources,
1635 d3d11_immediate_context_PSSetShader,
1636 d3d11_immediate_context_PSSetSamplers,
1637 d3d11_immediate_context_VSSetShader,
1638 d3d11_immediate_context_DrawIndexed,
1639 d3d11_immediate_context_Draw,
1640 d3d11_immediate_context_Map,
1641 d3d11_immediate_context_Unmap,
1642 d3d11_immediate_context_PSSetConstantBuffers,
1643 d3d11_immediate_context_IASetInputLayout,
1644 d3d11_immediate_context_IASetVertexBuffers,
1645 d3d11_immediate_context_IASetIndexBuffer,
1646 d3d11_immediate_context_DrawIndexedInstanced,
1647 d3d11_immediate_context_DrawInstanced,
1648 d3d11_immediate_context_GSSetConstantBuffers,
1649 d3d11_immediate_context_GSSetShader,
1650 d3d11_immediate_context_IASetPrimitiveTopology,
1651 d3d11_immediate_context_VSSetShaderResources,
1652 d3d11_immediate_context_VSSetSamplers,
1653 d3d11_immediate_context_Begin,
1654 d3d11_immediate_context_End,
1655 d3d11_immediate_context_GetData,
1656 d3d11_immediate_context_SetPredication,
1657 d3d11_immediate_context_GSSetShaderResources,
1658 d3d11_immediate_context_GSSetSamplers,
1659 d3d11_immediate_context_OMSetRenderTargets,
1660 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews,
1661 d3d11_immediate_context_OMSetBlendState,
1662 d3d11_immediate_context_OMSetDepthStencilState,
1663 d3d11_immediate_context_SOSetTargets,
1664 d3d11_immediate_context_DrawAuto,
1665 d3d11_immediate_context_DrawIndexedInstancedIndirect,
1666 d3d11_immediate_context_DrawInstancedIndirect,
1667 d3d11_immediate_context_Dispatch,
1668 d3d11_immediate_context_DispatchIndirect,
1669 d3d11_immediate_context_RSSetState,
1670 d3d11_immediate_context_RSSetViewports,
1671 d3d11_immediate_context_RSSetScissorRects,
1672 d3d11_immediate_context_CopySubresourceRegion,
1673 d3d11_immediate_context_CopyResource,
1674 d3d11_immediate_context_UpdateSubresource,
1675 d3d11_immediate_context_CopyStructureCount,
1676 d3d11_immediate_context_ClearRenderTargetView,
1677 d3d11_immediate_context_ClearUnorderedAccessViewUint,
1678 d3d11_immediate_context_ClearUnorderedAccessViewFloat,
1679 d3d11_immediate_context_ClearDepthStencilView,
1680 d3d11_immediate_context_GenerateMips,
1681 d3d11_immediate_context_SetResourceMinLOD,
1682 d3d11_immediate_context_GetResourceMinLOD,
1683 d3d11_immediate_context_ResolveSubresource,
1684 d3d11_immediate_context_ExecuteCommandList,
1685 d3d11_immediate_context_HSSetShaderResources,
1686 d3d11_immediate_context_HSSetShader,
1687 d3d11_immediate_context_HSSetSamplers,
1688 d3d11_immediate_context_HSSetConstantBuffers,
1689 d3d11_immediate_context_DSSetShaderResources,
1690 d3d11_immediate_context_DSSetShader,
1691 d3d11_immediate_context_DSSetSamplers,
1692 d3d11_immediate_context_DSSetConstantBuffers,
1693 d3d11_immediate_context_CSSetShaderResources,
1694 d3d11_immediate_context_CSSetUnorderedAccessViews,
1695 d3d11_immediate_context_CSSetShader,
1696 d3d11_immediate_context_CSSetSamplers,
1697 d3d11_immediate_context_CSSetConstantBuffers,
1698 d3d11_immediate_context_VSGetConstantBuffers,
1699 d3d11_immediate_context_PSGetShaderResources,
1700 d3d11_immediate_context_PSGetShader,
1701 d3d11_immediate_context_PSGetSamplers,
1702 d3d11_immediate_context_VSGetShader,
1703 d3d11_immediate_context_PSGetConstantBuffers,
1704 d3d11_immediate_context_IAGetInputLayout,
1705 d3d11_immediate_context_IAGetVertexBuffers,
1706 d3d11_immediate_context_IAGetIndexBuffer,
1707 d3d11_immediate_context_GSGetConstantBuffers,
1708 d3d11_immediate_context_GSGetShader,
1709 d3d11_immediate_context_IAGetPrimitiveTopology,
1710 d3d11_immediate_context_VSGetShaderResources,
1711 d3d11_immediate_context_VSGetSamplers,
1712 d3d11_immediate_context_GetPredication,
1713 d3d11_immediate_context_GSGetShaderResources,
1714 d3d11_immediate_context_GSGetSamplers,
1715 d3d11_immediate_context_OMGetRenderTargets,
1716 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews,
1717 d3d11_immediate_context_OMGetBlendState,
1718 d3d11_immediate_context_OMGetDepthStencilState,
1719 d3d11_immediate_context_SOGetTargets,
1720 d3d11_immediate_context_RSGetState,
1721 d3d11_immediate_context_RSGetViewports,
1722 d3d11_immediate_context_RSGetScissorRects,
1723 d3d11_immediate_context_HSGetShaderResources,
1724 d3d11_immediate_context_HSGetShader,
1725 d3d11_immediate_context_HSGetSamplers,
1726 d3d11_immediate_context_HSGetConstantBuffers,
1727 d3d11_immediate_context_DSGetShaderResources,
1728 d3d11_immediate_context_DSGetShader,
1729 d3d11_immediate_context_DSGetSamplers,
1730 d3d11_immediate_context_DSGetConstantBuffers,
1731 d3d11_immediate_context_CSGetShaderResources,
1732 d3d11_immediate_context_CSGetUnorderedAccessViews,
1733 d3d11_immediate_context_CSGetShader,
1734 d3d11_immediate_context_CSGetSamplers,
1735 d3d11_immediate_context_CSGetConstantBuffers,
1736 d3d11_immediate_context_ClearState,
1737 d3d11_immediate_context_Flush,
1738 d3d11_immediate_context_GetType,
1739 d3d11_immediate_context_GetContextFlags,
1740 d3d11_immediate_context_FinishCommandList,
1743 static HRESULT d3d11_immediate_context_init(struct d3d11_immediate_context *context, struct d3d_device *device)
1745 context->ID3D11DeviceContext_iface.lpVtbl = &d3d11_immediate_context_vtbl;
1746 context->refcount = 1;
1748 ID3D11Device_AddRef(&device->ID3D11Device_iface);
1750 return S_OK;
1753 /* ID3D11Device methods */
1755 static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out)
1757 struct d3d_device *device = impl_from_ID3D11Device(iface);
1758 return IUnknown_QueryInterface(device->outer_unk, riid, out);
1761 static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device *iface)
1763 struct d3d_device *device = impl_from_ID3D11Device(iface);
1764 return IUnknown_AddRef(device->outer_unk);
1767 static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface)
1769 struct d3d_device *device = impl_from_ID3D11Device(iface);
1770 return IUnknown_Release(device->outer_unk);
1773 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc,
1774 const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer)
1776 struct d3d_device *device = impl_from_ID3D11Device(iface);
1777 struct d3d_buffer *object;
1778 HRESULT hr;
1780 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
1782 if (FAILED(hr = d3d_buffer_create(device, desc, data, &object)))
1783 return hr;
1785 *buffer = &object->ID3D11Buffer_iface;
1787 return S_OK;
1790 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
1791 const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture)
1793 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1795 return E_NOTIMPL;
1798 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
1799 const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture)
1801 struct d3d_device *device = impl_from_ID3D11Device(iface);
1802 struct d3d_texture2d *object;
1803 HRESULT hr;
1805 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1807 if (FAILED(hr = d3d_texture2d_create(device, desc, data, &object)))
1808 return hr;
1810 *texture = &object->ID3D11Texture2D_iface;
1812 return S_OK;
1815 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
1816 const D3D11_TEXTURE3D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture3D **texture)
1818 struct d3d_device *device = impl_from_ID3D11Device(iface);
1819 struct d3d_texture3d *object;
1820 HRESULT hr;
1822 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1824 if (FAILED(hr = d3d_texture3d_create(device, desc, data, &object)))
1825 return hr;
1827 *texture = &object->ID3D11Texture3D_iface;
1829 return S_OK;
1832 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device *iface,
1833 ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11ShaderResourceView **view)
1835 struct d3d_device *device = impl_from_ID3D11Device(iface);
1836 struct d3d_shader_resource_view *object;
1837 HRESULT hr;
1839 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1841 if (FAILED(hr = d3d_shader_resource_view_create(device, resource, desc, &object)))
1842 return hr;
1844 *view = &object->ID3D11ShaderResourceView_iface;
1846 return S_OK;
1849 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device *iface,
1850 ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11UnorderedAccessView **view)
1852 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1854 return E_NOTIMPL;
1857 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface,
1858 ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view)
1860 struct d3d_device *device = impl_from_ID3D11Device(iface);
1861 struct d3d_rendertarget_view *object;
1862 HRESULT hr;
1864 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1866 if (FAILED(hr = d3d_rendertarget_view_create(device, resource, desc, &object)))
1867 return hr;
1869 *view = &object->ID3D11RenderTargetView_iface;
1871 return S_OK;
1874 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface,
1875 ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11DepthStencilView **view)
1877 struct d3d_device *device = impl_from_ID3D11Device(iface);
1878 struct d3d_depthstencil_view *object;
1879 HRESULT hr;
1881 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1883 if (FAILED(hr = d3d_depthstencil_view_create(device, resource, desc, &object)))
1884 return hr;
1886 *view = &object->ID3D11DepthStencilView_iface;
1888 return S_OK;
1891 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *iface,
1892 const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code,
1893 SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout)
1895 struct d3d_device *device = impl_from_ID3D11Device(iface);
1896 struct d3d_input_layout *object;
1897 HRESULT hr;
1899 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
1900 "input_layout %p.\n", iface, element_descs, element_count, shader_byte_code,
1901 shader_byte_code_length, input_layout);
1903 if (FAILED(hr = d3d_input_layout_create(device, element_descs, element_count,
1904 shader_byte_code, shader_byte_code_length, &object)))
1905 return hr;
1907 *input_layout = &object->ID3D11InputLayout_iface;
1909 return S_OK;
1912 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code,
1913 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11VertexShader **shader)
1915 struct d3d_device *device = impl_from_ID3D11Device(iface);
1916 struct d3d_vertex_shader *object;
1917 HRESULT hr;
1919 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1920 iface, byte_code, byte_code_length, class_linkage, shader);
1922 if (class_linkage)
1923 FIXME("Class linkage is not implemented yet.\n");
1925 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
1926 return hr;
1928 *shader = &object->ID3D11VertexShader_iface;
1930 return S_OK;
1933 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device *iface, const void *byte_code,
1934 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
1936 struct d3d_device *device = impl_from_ID3D11Device(iface);
1937 struct d3d_geometry_shader *object;
1938 HRESULT hr;
1940 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1941 iface, byte_code, byte_code_length, class_linkage, shader);
1943 if (class_linkage)
1944 FIXME("Class linkage is not implemented yet.\n");
1946 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
1947 return hr;
1949 *shader = &object->ID3D11GeometryShader_iface;
1951 return S_OK;
1954 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device *iface,
1955 const void *byte_code, SIZE_T byte_code_length, const D3D11_SO_DECLARATION_ENTRY *so_entries,
1956 UINT entry_count, const UINT *buffer_strides, UINT strides_count, UINT rasterized_stream,
1957 ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
1959 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
1960 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
1961 iface, byte_code, byte_code_length, so_entries, entry_count, buffer_strides, strides_count,
1962 rasterized_stream, class_linkage, shader);
1964 return E_NOTIMPL;
1967 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *iface, const void *byte_code,
1968 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11PixelShader **shader)
1970 struct d3d_device *device = impl_from_ID3D11Device(iface);
1971 struct d3d_pixel_shader *object;
1972 HRESULT hr;
1974 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1975 iface, byte_code, byte_code_length, class_linkage, shader);
1977 if (class_linkage)
1978 FIXME("Class linkage is not implemented yet.\n");
1980 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
1981 return hr;
1983 *shader = &object->ID3D11PixelShader_iface;
1985 return S_OK;
1988 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *iface, const void *byte_code,
1989 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11HullShader **shader)
1991 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
1992 iface, byte_code, byte_code_length, class_linkage, shader);
1994 return E_NOTIMPL;
1997 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code,
1998 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader)
2000 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2001 iface, byte_code, byte_code_length, class_linkage, shader);
2003 return E_NOTIMPL;
2006 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code,
2007 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11ComputeShader **shader)
2009 FIXME("iface %p, byte_code %p, byte_code_lenghth %lu, class_linkage %p, shader %p stub!\n",
2010 iface, byte_code, byte_code_length, class_linkage, shader);
2012 return E_NOTIMPL;
2015 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *iface,
2016 ID3D11ClassLinkage **class_linkage)
2018 FIXME("iface %p, class_linkage %p stub!\n", iface, class_linkage);
2020 return E_NOTIMPL;
2023 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *iface,
2024 const D3D11_BLEND_DESC *desc, ID3D11BlendState **blend_state)
2026 struct d3d_device *device = impl_from_ID3D11Device(iface);
2027 struct d3d_blend_state *object;
2028 struct wine_rb_entry *entry;
2029 D3D11_BLEND_DESC tmp_desc;
2030 unsigned int i, j;
2031 HRESULT hr;
2033 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
2035 if (!desc)
2036 return E_INVALIDARG;
2038 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2039 * D3D11_BLEND_DESC as a key in the rbtree. */
2040 memset(&tmp_desc, 0, sizeof(tmp_desc));
2041 tmp_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
2042 tmp_desc.IndependentBlendEnable = desc->IndependentBlendEnable;
2043 for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
2045 j = desc->IndependentBlendEnable ? i : 0;
2046 tmp_desc.RenderTarget[i].BlendEnable = desc->RenderTarget[j].BlendEnable;
2047 tmp_desc.RenderTarget[i].SrcBlend = desc->RenderTarget[j].SrcBlend;
2048 tmp_desc.RenderTarget[i].DestBlend = desc->RenderTarget[j].DestBlend;
2049 tmp_desc.RenderTarget[i].BlendOp = desc->RenderTarget[j].BlendOp;
2050 tmp_desc.RenderTarget[i].SrcBlendAlpha = desc->RenderTarget[j].SrcBlendAlpha;
2051 tmp_desc.RenderTarget[i].DestBlendAlpha = desc->RenderTarget[j].DestBlendAlpha;
2052 tmp_desc.RenderTarget[i].BlendOpAlpha = desc->RenderTarget[j].BlendOpAlpha;
2053 tmp_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTarget[j].RenderTargetWriteMask;
2056 wined3d_mutex_lock();
2057 if ((entry = wine_rb_get(&device->blend_states, &tmp_desc)))
2059 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_blend_state, entry);
2061 TRACE("Returning existing blend state %p.\n", object);
2062 *blend_state = &object->ID3D11BlendState_iface;
2063 ID3D11BlendState_AddRef(*blend_state);
2064 wined3d_mutex_unlock();
2066 return S_OK;
2068 wined3d_mutex_unlock();
2070 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2071 return E_OUTOFMEMORY;
2073 if (FAILED(hr = d3d_blend_state_init(object, device, &tmp_desc)))
2075 WARN("Failed to initialize blend state, hr %#x.\n", hr);
2076 HeapFree(GetProcessHeap(), 0, object);
2077 return hr;
2080 TRACE("Created blend state %p.\n", object);
2081 *blend_state = &object->ID3D11BlendState_iface;
2083 return S_OK;
2086 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface,
2087 const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state)
2089 struct d3d_device *device = impl_from_ID3D11Device(iface);
2090 struct d3d_depthstencil_state *object;
2091 D3D11_DEPTH_STENCIL_DESC tmp_desc;
2092 struct wine_rb_entry *entry;
2093 HRESULT hr;
2095 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
2097 if (!desc)
2098 return E_INVALIDARG;
2100 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2101 * it as a key in the rbtree. */
2102 memset(&tmp_desc, 0, sizeof(tmp_desc));
2103 tmp_desc.DepthEnable = desc->DepthEnable;
2104 tmp_desc.DepthWriteMask = desc->DepthWriteMask;
2105 tmp_desc.DepthFunc = desc->DepthFunc;
2106 tmp_desc.StencilEnable = desc->StencilEnable;
2107 tmp_desc.StencilReadMask = desc->StencilReadMask;
2108 tmp_desc.StencilWriteMask = desc->StencilWriteMask;
2109 tmp_desc.FrontFace = desc->FrontFace;
2110 tmp_desc.BackFace = desc->BackFace;
2112 wined3d_mutex_lock();
2113 if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
2115 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_depthstencil_state, entry);
2117 TRACE("Returning existing depthstencil state %p.\n", object);
2118 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
2119 ID3D11DepthStencilState_AddRef(*depth_stencil_state);
2120 wined3d_mutex_unlock();
2122 return S_OK;
2124 wined3d_mutex_unlock();
2126 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2127 return E_OUTOFMEMORY;
2129 if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc)))
2131 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
2132 HeapFree(GetProcessHeap(), 0, object);
2133 return hr;
2136 TRACE("Created depthstencil state %p.\n", object);
2137 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
2139 return S_OK;
2142 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface,
2143 const D3D11_RASTERIZER_DESC *desc, ID3D11RasterizerState **rasterizer_state)
2145 struct d3d_device *device = impl_from_ID3D11Device(iface);
2146 struct d3d_rasterizer_state *object;
2147 struct wine_rb_entry *entry;
2148 HRESULT hr;
2150 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
2152 if (!desc)
2153 return E_INVALIDARG;
2155 wined3d_mutex_lock();
2156 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
2158 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_rasterizer_state, entry);
2160 TRACE("Returning existing rasterizer state %p.\n", object);
2161 *rasterizer_state = &object->ID3D11RasterizerState_iface;
2162 ID3D11RasterizerState_AddRef(*rasterizer_state);
2163 wined3d_mutex_unlock();
2165 return S_OK;
2167 wined3d_mutex_unlock();
2169 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2170 return E_OUTOFMEMORY;
2172 if (FAILED(hr = d3d_rasterizer_state_init(object, device, desc)))
2174 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
2175 HeapFree(GetProcessHeap(), 0, object);
2176 return hr;
2179 TRACE("Created rasterizer state %p.\n", object);
2180 *rasterizer_state = &object->ID3D11RasterizerState_iface;
2182 return S_OK;
2185 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface,
2186 const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state)
2188 struct d3d_device *device = impl_from_ID3D11Device(iface);
2189 D3D11_SAMPLER_DESC normalized_desc;
2190 struct d3d_sampler_state *object;
2191 struct wine_rb_entry *entry;
2192 HRESULT hr;
2194 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
2196 if (!desc)
2197 return E_INVALIDARG;
2199 normalized_desc = *desc;
2200 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc.Filter))
2201 normalized_desc.MaxAnisotropy = 0;
2202 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc.Filter))
2203 normalized_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
2204 if (normalized_desc.AddressU != D3D11_TEXTURE_ADDRESS_BORDER
2205 && normalized_desc.AddressV != D3D11_TEXTURE_ADDRESS_BORDER
2206 && normalized_desc.AddressW != D3D11_TEXTURE_ADDRESS_BORDER)
2207 memset(&normalized_desc.BorderColor, 0, sizeof(normalized_desc.BorderColor));
2209 wined3d_mutex_lock();
2210 if ((entry = wine_rb_get(&device->sampler_states, &normalized_desc)))
2212 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_sampler_state, entry);
2214 TRACE("Returning existing sampler state %p.\n", object);
2215 *sampler_state = &object->ID3D11SamplerState_iface;
2216 ID3D11SamplerState_AddRef(*sampler_state);
2217 wined3d_mutex_unlock();
2219 return S_OK;
2221 wined3d_mutex_unlock();
2223 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2224 return E_OUTOFMEMORY;
2226 if (FAILED(hr = d3d_sampler_state_init(object, device, &normalized_desc)))
2228 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
2229 HeapFree(GetProcessHeap(), 0, object);
2230 return hr;
2233 TRACE("Created sampler state %p.\n", object);
2234 *sampler_state = &object->ID3D11SamplerState_iface;
2236 return S_OK;
2239 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
2240 const D3D11_QUERY_DESC *desc, ID3D11Query **query)
2242 struct d3d_device *device = impl_from_ID3D11Device(iface);
2243 struct d3d_query *object;
2244 HRESULT hr;
2246 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
2248 if (FAILED(hr = d3d_query_create(device, desc, FALSE, &object)))
2249 return hr;
2251 *query = &object->ID3D11Query_iface;
2253 return S_OK;
2256 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc,
2257 ID3D11Predicate **predicate)
2259 struct d3d_device *device = impl_from_ID3D11Device(iface);
2260 struct d3d_query *object;
2261 HRESULT hr;
2263 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
2265 if (FAILED(hr = d3d_query_create(device, desc, TRUE, &object)))
2266 return hr;
2268 *predicate = (ID3D11Predicate *)&object->ID3D11Query_iface;
2270 return S_OK;
2273 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2274 ID3D11Counter **counter)
2276 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
2278 return E_NOTIMPL;
2281 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device *iface, UINT flags,
2282 ID3D11DeviceContext **context)
2284 FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context);
2286 return E_NOTIMPL;
2289 static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device *iface, HANDLE resource, REFIID riid,
2290 void **out)
2292 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface, resource, debugstr_guid(riid), out);
2294 return E_NOTIMPL;
2297 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *iface, DXGI_FORMAT format,
2298 UINT *format_support)
2300 FIXME("iface %p, format %u, format_support %p stub!\n", iface, format, format_support);
2302 return E_NOTIMPL;
2305 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device *iface,
2306 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
2308 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
2309 iface, format, sample_count, quality_level_count);
2311 return E_NOTIMPL;
2314 static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device *iface, D3D11_COUNTER_INFO *info)
2316 FIXME("iface %p, info %p stub!\n", iface, info);
2319 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2320 D3D11_COUNTER_TYPE *type, UINT *active_counter_count, char *name, UINT *name_length,
2321 char *units, UINT *units_length, char *description, UINT *description_length)
2323 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2324 "units %p, units_length %p, description %p, description_length %p stub!\n",
2325 iface, desc, type, active_counter_count, name, name_length,
2326 units, units_length, description, description_length);
2328 return E_NOTIMPL;
2331 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device *iface, D3D11_FEATURE feature,
2332 void *feature_support_data, UINT feature_support_data_size)
2334 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2335 iface, feature, feature_support_data, feature_support_data_size);
2337 return E_NOTIMPL;
2340 static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface, REFGUID guid,
2341 UINT *data_size, void *data)
2343 IDXGIDevice *dxgi_device;
2344 HRESULT hr;
2346 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2348 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2349 return hr;
2350 hr = IDXGIDevice_GetPrivateData(dxgi_device, guid, data_size, data);
2351 IDXGIDevice_Release(dxgi_device);
2353 return hr;
2356 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface, REFGUID guid,
2357 UINT data_size, const void *data)
2359 IDXGIDevice *dxgi_device;
2360 HRESULT hr;
2362 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2364 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2365 return hr;
2366 hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data);
2367 IDXGIDevice_Release(dxgi_device);
2369 return hr;
2372 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device *iface, REFGUID guid,
2373 const IUnknown *data)
2375 IDXGIDevice *dxgi_device;
2376 HRESULT hr;
2378 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
2380 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2381 return hr;
2382 hr = IDXGIDevice_SetPrivateDataInterface(dxgi_device, guid, data);
2383 IDXGIDevice_Release(dxgi_device);
2385 return hr;
2388 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device *iface)
2390 FIXME("iface %p stub!\n", iface);
2392 return D3D_FEATURE_LEVEL_10_0;
2395 static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device *iface)
2397 FIXME("iface %p stub!\n", iface);
2399 return 0;
2402 static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device *iface)
2404 FIXME("iface %p stub!\n", iface);
2406 return S_OK;
2409 static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device *iface,
2410 ID3D11DeviceContext **immediate_context)
2412 struct d3d_device *device = impl_from_ID3D11Device(iface);
2414 TRACE("iface %p, immediate_context %p.\n", iface, immediate_context);
2416 *immediate_context = &device->immediate_context.ID3D11DeviceContext_iface;
2417 ID3D11DeviceContext_AddRef(*immediate_context);
2420 static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device *iface, UINT flags)
2422 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2424 return E_NOTIMPL;
2427 static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device *iface)
2429 FIXME("iface %p stub!\n", iface);
2431 return 0;
2434 static const struct ID3D11DeviceVtbl d3d11_device_vtbl =
2436 /* IUnknown methods */
2437 d3d11_device_QueryInterface,
2438 d3d11_device_AddRef,
2439 d3d11_device_Release,
2440 /* ID3D11Device methods */
2441 d3d11_device_CreateBuffer,
2442 d3d11_device_CreateTexture1D,
2443 d3d11_device_CreateTexture2D,
2444 d3d11_device_CreateTexture3D,
2445 d3d11_device_CreateShaderResourceView,
2446 d3d11_device_CreateUnorderedAccessView,
2447 d3d11_device_CreateRenderTargetView,
2448 d3d11_device_CreateDepthStencilView,
2449 d3d11_device_CreateInputLayout,
2450 d3d11_device_CreateVertexShader,
2451 d3d11_device_CreateGeometryShader,
2452 d3d11_device_CreateGeometryShaderWithStreamOutput,
2453 d3d11_device_CreatePixelShader,
2454 d3d11_device_CreateHullShader,
2455 d3d11_device_CreateDomainShader,
2456 d3d11_device_CreateComputeShader,
2457 d3d11_device_CreateClassLinkage,
2458 d3d11_device_CreateBlendState,
2459 d3d11_device_CreateDepthStencilState,
2460 d3d11_device_CreateRasterizerState,
2461 d3d11_device_CreateSamplerState,
2462 d3d11_device_CreateQuery,
2463 d3d11_device_CreatePredicate,
2464 d3d11_device_CreateCounter,
2465 d3d11_device_CreateDeferredContext,
2466 d3d11_device_OpenSharedResource,
2467 d3d11_device_CheckFormatSupport,
2468 d3d11_device_CheckMultisampleQualityLevels,
2469 d3d11_device_CheckCounterInfo,
2470 d3d11_device_CheckCounter,
2471 d3d11_device_CheckFeatureSupport,
2472 d3d11_device_GetPrivateData,
2473 d3d11_device_SetPrivateData,
2474 d3d11_device_SetPrivateDataInterface,
2475 d3d11_device_GetFeatureLevel,
2476 d3d11_device_GetCreationFlags,
2477 d3d11_device_GetDeviceRemovedReason,
2478 d3d11_device_GetImmediateContext,
2479 d3d11_device_SetExceptionMode,
2480 d3d11_device_GetExceptionMode,
2483 /* Inner IUnknown methods */
2485 static inline struct d3d_device *impl_from_IUnknown(IUnknown *iface)
2487 return CONTAINING_RECORD(iface, struct d3d_device, IUnknown_inner);
2490 static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
2492 struct d3d_device *device = impl_from_IUnknown(iface);
2494 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2496 if (IsEqualGUID(riid, &IID_ID3D11Device)
2497 || IsEqualGUID(riid, &IID_IUnknown))
2499 *out = &device->ID3D11Device_iface;
2501 else if (IsEqualGUID(riid, &IID_ID3D10Device1)
2502 || IsEqualGUID(riid, &IID_ID3D10Device))
2504 *out = &device->ID3D10Device1_iface;
2506 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
2508 *out = &device->ID3D10Multithread_iface;
2510 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
2512 *out = &device->IWineDXGIDeviceParent_iface;
2514 else
2516 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2517 *out = NULL;
2518 return E_NOINTERFACE;
2521 IUnknown_AddRef((IUnknown *)*out);
2522 return S_OK;
2525 static ULONG STDMETHODCALLTYPE d3d_device_inner_AddRef(IUnknown *iface)
2527 struct d3d_device *device = impl_from_IUnknown(iface);
2528 ULONG refcount = InterlockedIncrement(&device->refcount);
2530 TRACE("%p increasing refcount to %u.\n", device, refcount);
2532 return refcount;
2535 static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
2537 struct d3d_device *device = impl_from_IUnknown(iface);
2538 ULONG refcount = InterlockedDecrement(&device->refcount);
2540 TRACE("%p decreasing refcount to %u.\n", device, refcount);
2542 if (!refcount)
2544 if (device->wined3d_device)
2546 wined3d_mutex_lock();
2547 wined3d_device_decref(device->wined3d_device);
2548 wined3d_mutex_unlock();
2550 wine_rb_destroy(&device->sampler_states, NULL, NULL);
2551 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2552 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2553 wine_rb_destroy(&device->blend_states, NULL, NULL);
2556 return refcount;
2559 /* IUnknown methods */
2561 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
2562 void **ppv)
2564 struct d3d_device *This = impl_from_ID3D10Device(iface);
2565 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
2568 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
2570 struct d3d_device *This = impl_from_ID3D10Device(iface);
2571 return IUnknown_AddRef(This->outer_unk);
2574 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
2576 struct d3d_device *This = impl_from_ID3D10Device(iface);
2577 return IUnknown_Release(This->outer_unk);
2580 /* ID3D10Device methods */
2582 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
2583 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2585 struct d3d_device *device = impl_from_ID3D10Device(iface);
2586 unsigned int i;
2588 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2589 iface, start_slot, buffer_count, buffers);
2591 wined3d_mutex_lock();
2592 for (i = 0; i < buffer_count; ++i)
2594 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2596 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
2597 buffer ? buffer->wined3d_buffer : NULL);
2599 wined3d_mutex_unlock();
2602 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
2603 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2605 struct d3d_device *device = impl_from_ID3D10Device(iface);
2606 unsigned int i;
2608 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2609 iface, start_slot, view_count, views);
2611 wined3d_mutex_lock();
2612 for (i = 0; i < view_count; ++i)
2614 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2616 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
2617 view ? view->wined3d_view : NULL);
2619 wined3d_mutex_unlock();
2622 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
2623 ID3D10PixelShader *shader)
2625 struct d3d_device *This = impl_from_ID3D10Device(iface);
2626 struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
2628 TRACE("iface %p, shader %p\n", iface, shader);
2630 wined3d_mutex_lock();
2631 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
2632 wined3d_mutex_unlock();
2635 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
2636 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2638 struct d3d_device *device = impl_from_ID3D10Device(iface);
2639 unsigned int i;
2641 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2642 iface, start_slot, sampler_count, samplers);
2644 wined3d_mutex_lock();
2645 for (i = 0; i < sampler_count; ++i)
2647 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2649 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
2650 sampler ? sampler->wined3d_sampler : NULL);
2652 wined3d_mutex_unlock();
2655 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
2656 ID3D10VertexShader *shader)
2658 struct d3d_device *This = impl_from_ID3D10Device(iface);
2659 struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
2661 TRACE("iface %p, shader %p\n", iface, shader);
2663 wined3d_mutex_lock();
2664 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
2665 wined3d_mutex_unlock();
2668 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
2669 UINT start_index_location, INT base_vertex_location)
2671 struct d3d_device *This = impl_from_ID3D10Device(iface);
2673 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2674 iface, index_count, start_index_location, base_vertex_location);
2676 wined3d_mutex_lock();
2677 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
2678 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
2679 wined3d_mutex_unlock();
2682 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
2683 UINT start_vertex_location)
2685 struct d3d_device *This = impl_from_ID3D10Device(iface);
2687 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2688 iface, vertex_count, start_vertex_location);
2690 wined3d_mutex_lock();
2691 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
2692 wined3d_mutex_unlock();
2695 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
2696 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2698 struct d3d_device *device = impl_from_ID3D10Device(iface);
2699 unsigned int i;
2701 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2702 iface, start_slot, buffer_count, buffers);
2704 wined3d_mutex_lock();
2705 for (i = 0; i < buffer_count; ++i)
2707 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2709 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
2710 buffer ? buffer->wined3d_buffer : NULL);
2712 wined3d_mutex_unlock();
2715 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
2716 ID3D10InputLayout *input_layout)
2718 struct d3d_device *This = impl_from_ID3D10Device(iface);
2719 struct d3d_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
2721 TRACE("iface %p, input_layout %p\n", iface, input_layout);
2723 wined3d_mutex_lock();
2724 wined3d_device_set_vertex_declaration(This->wined3d_device,
2725 layout ? layout->wined3d_decl : NULL);
2726 wined3d_mutex_unlock();
2729 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
2730 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
2732 struct d3d_device *This = impl_from_ID3D10Device(iface);
2733 unsigned int i;
2735 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
2736 iface, start_slot, buffer_count, buffers, strides, offsets);
2738 wined3d_mutex_lock();
2739 for (i = 0; i < buffer_count; ++i)
2741 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2743 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
2744 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
2746 wined3d_mutex_unlock();
2749 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
2750 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
2752 struct d3d_device *This = impl_from_ID3D10Device(iface);
2753 struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
2755 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
2756 iface, buffer, debug_dxgi_format(format), offset);
2758 wined3d_mutex_lock();
2759 wined3d_device_set_index_buffer(This->wined3d_device,
2760 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
2761 wined3dformat_from_dxgi_format(format));
2762 wined3d_mutex_unlock();
2763 if (offset) FIXME("offset %u not supported.\n", offset);
2766 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
2767 UINT instance_index_count, UINT instance_count, UINT start_index_location,
2768 INT base_vertex_location, UINT start_instance_location)
2770 struct d3d_device *device = impl_from_ID3D10Device(iface);
2772 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
2773 "base_vertex_location %d, start_instance_location %u.\n",
2774 iface, instance_index_count, instance_count, start_index_location,
2775 base_vertex_location, start_instance_location);
2777 wined3d_mutex_lock();
2778 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
2779 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
2780 instance_index_count, start_instance_location, instance_count);
2781 wined3d_mutex_unlock();
2784 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
2785 UINT instance_vertex_count, UINT instance_count,
2786 UINT start_vertex_location, UINT start_instance_location)
2788 struct d3d_device *device = impl_from_ID3D10Device(iface);
2790 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
2791 "start_instance_location %u.\n", iface, instance_vertex_count, instance_count,
2792 start_vertex_location, start_instance_location);
2794 wined3d_mutex_lock();
2795 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
2796 instance_vertex_count, start_instance_location, instance_count);
2797 wined3d_mutex_unlock();
2800 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
2801 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2803 struct d3d_device *device = impl_from_ID3D10Device(iface);
2804 unsigned int i;
2806 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2807 iface, start_slot, buffer_count, buffers);
2809 wined3d_mutex_lock();
2810 for (i = 0; i < buffer_count; ++i)
2812 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2814 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
2815 buffer ? buffer->wined3d_buffer : NULL);
2817 wined3d_mutex_unlock();
2820 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
2822 struct d3d_device *device = impl_from_ID3D10Device(iface);
2823 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
2825 TRACE("iface %p, shader %p.\n", iface, shader);
2827 wined3d_mutex_lock();
2828 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
2829 wined3d_mutex_unlock();
2832 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
2833 D3D10_PRIMITIVE_TOPOLOGY topology)
2835 struct d3d_device *This = impl_from_ID3D10Device(iface);
2837 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
2839 wined3d_mutex_lock();
2840 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
2841 wined3d_mutex_unlock();
2844 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
2845 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2847 struct d3d_device *device = impl_from_ID3D10Device(iface);
2848 unsigned int i;
2850 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2851 iface, start_slot, view_count, views);
2853 wined3d_mutex_lock();
2854 for (i = 0; i < view_count; ++i)
2856 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2858 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
2859 view ? view->wined3d_view : NULL);
2861 wined3d_mutex_unlock();
2864 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
2865 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2867 struct d3d_device *device = impl_from_ID3D10Device(iface);
2868 unsigned int i;
2870 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2871 iface, start_slot, sampler_count, samplers);
2873 wined3d_mutex_lock();
2874 for (i = 0; i < sampler_count; ++i)
2876 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2878 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
2879 sampler ? sampler->wined3d_sampler : NULL);
2881 wined3d_mutex_unlock();
2884 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
2886 struct d3d_device *device = impl_from_ID3D10Device(iface);
2887 struct d3d_query *query;
2889 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
2891 query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
2892 wined3d_mutex_lock();
2893 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
2894 wined3d_mutex_unlock();
2897 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
2898 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2900 struct d3d_device *device = impl_from_ID3D10Device(iface);
2901 unsigned int i;
2903 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2904 iface, start_slot, view_count, views);
2906 wined3d_mutex_lock();
2907 for (i = 0; i < view_count; ++i)
2909 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2911 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
2912 view ? view->wined3d_view : NULL);
2914 wined3d_mutex_unlock();
2917 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
2918 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2920 struct d3d_device *device = impl_from_ID3D10Device(iface);
2921 unsigned int i;
2923 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2924 iface, start_slot, sampler_count, samplers);
2926 wined3d_mutex_lock();
2927 for (i = 0; i < sampler_count; ++i)
2929 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2931 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
2932 sampler ? sampler->wined3d_sampler : NULL);
2934 wined3d_mutex_unlock();
2937 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
2938 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
2939 ID3D10DepthStencilView *depth_stencil_view)
2941 struct d3d_device *device = impl_from_ID3D10Device(iface);
2942 struct d3d_depthstencil_view *dsv;
2943 unsigned int i;
2945 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
2946 iface, render_target_view_count, render_target_views, depth_stencil_view);
2948 wined3d_mutex_lock();
2949 for (i = 0; i < render_target_view_count; ++i)
2951 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
2953 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
2954 rtv ? rtv->wined3d_view : NULL, FALSE);
2956 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
2958 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
2961 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
2962 wined3d_device_set_depth_stencil_view(device->wined3d_device,
2963 dsv ? dsv->wined3d_view : NULL);
2964 wined3d_mutex_unlock();
2967 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
2968 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
2970 struct d3d_device *device = impl_from_ID3D10Device(iface);
2971 struct d3d_blend_state *blend_state_object;
2973 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
2974 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
2976 blend_state_object = unsafe_impl_from_ID3D10BlendState(blend_state);
2977 d3d11_immediate_context_OMSetBlendState(&device->immediate_context.ID3D11DeviceContext_iface,
2978 blend_state_object ? &blend_state_object->ID3D11BlendState_iface : NULL, blend_factor, sample_mask);
2981 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
2982 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
2984 struct d3d_device *device = impl_from_ID3D10Device(iface);
2986 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
2987 iface, depth_stencil_state, stencil_ref);
2989 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
2990 device->stencil_ref = stencil_ref;
2993 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
2994 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
2996 struct d3d_device *device = impl_from_ID3D10Device(iface);
2997 unsigned int count, i;
2999 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
3001 count = min(target_count, 4);
3002 wined3d_mutex_lock();
3003 for (i = 0; i < count; ++i)
3005 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
3007 wined3d_device_set_stream_output(device->wined3d_device, i,
3008 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
3011 for (i = count; i < 4; ++i)
3013 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
3015 wined3d_mutex_unlock();
3018 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
3020 FIXME("iface %p stub!\n", iface);
3023 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
3025 struct d3d_device *device = impl_from_ID3D10Device(iface);
3026 struct d3d_rasterizer_state *rasterizer_state_object;
3028 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3030 rasterizer_state_object = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
3031 d3d11_immediate_context_RSSetState(&device->immediate_context.ID3D11DeviceContext_iface,
3032 rasterizer_state_object ? &rasterizer_state_object->ID3D11RasterizerState_iface : NULL);
3035 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
3036 UINT viewport_count, const D3D10_VIEWPORT *viewports)
3038 struct d3d_device *device = impl_from_ID3D10Device(iface);
3039 struct wined3d_viewport wined3d_vp;
3041 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
3043 if (viewport_count > 1)
3044 FIXME("Multiple viewports not implemented.\n");
3046 if (!viewport_count)
3047 return;
3049 wined3d_vp.x = viewports[0].TopLeftX;
3050 wined3d_vp.y = viewports[0].TopLeftY;
3051 wined3d_vp.width = viewports[0].Width;
3052 wined3d_vp.height = viewports[0].Height;
3053 wined3d_vp.min_z = viewports[0].MinDepth;
3054 wined3d_vp.max_z = viewports[0].MaxDepth;
3056 wined3d_mutex_lock();
3057 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
3058 wined3d_mutex_unlock();
3061 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
3062 UINT rect_count, const D3D10_RECT *rects)
3064 struct d3d_device *device = impl_from_ID3D10Device(iface);
3066 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
3068 if (rect_count > 1)
3069 FIXME("Multiple scissor rects not implemented.\n");
3071 if (!rect_count)
3072 return;
3074 wined3d_mutex_lock();
3075 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
3076 wined3d_mutex_unlock();
3079 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
3080 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
3081 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
3083 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
3084 struct d3d_device *device = impl_from_ID3D10Device(iface);
3085 struct wined3d_box wined3d_src_box;
3087 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3088 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3089 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
3090 src_resource, src_subresource_idx, src_box);
3092 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
3093 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
3094 wined3d_src_box.left = src_box->left;
3095 wined3d_src_box.top = src_box->top;
3096 wined3d_src_box.front = src_box->front;
3097 wined3d_src_box.right = src_box->right;
3098 wined3d_src_box.bottom = src_box->bottom;
3099 wined3d_src_box.back = src_box->back;
3100 wined3d_mutex_lock();
3101 wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
3102 dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, &wined3d_src_box);
3103 wined3d_mutex_unlock();
3106 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
3107 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
3109 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
3110 struct d3d_device *device = impl_from_ID3D10Device(iface);
3112 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
3114 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
3115 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
3116 wined3d_mutex_lock();
3117 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
3118 wined3d_mutex_unlock();
3121 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
3122 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
3123 const void *data, UINT row_pitch, UINT depth_pitch)
3125 struct d3d_device *device = impl_from_ID3D10Device(iface);
3126 ID3D11Resource *d3d11_resource;
3128 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3129 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
3131 ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource);
3132 d3d11_immediate_context_UpdateSubresource(&device->immediate_context.ID3D11DeviceContext_iface,
3133 d3d11_resource, subresource_idx, (const D3D11_BOX *)box, data, row_pitch, depth_pitch);
3134 ID3D11Resource_Release(d3d11_resource);
3137 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
3138 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
3140 struct d3d_device *device = impl_from_ID3D10Device(iface);
3141 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
3142 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
3143 HRESULT hr;
3145 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
3146 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
3148 wined3d_mutex_lock();
3149 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
3150 ERR("Failed to clear view, hr %#x.\n", hr);
3151 wined3d_mutex_unlock();
3154 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
3155 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
3157 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
3158 iface, depth_stencil_view, flags, depth, stencil);
3161 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
3162 ID3D10ShaderResourceView *shader_resource_view)
3164 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
3167 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
3168 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
3169 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
3171 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3172 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3173 iface, dst_resource, dst_subresource_idx,
3174 src_resource, src_subresource_idx, debug_dxgi_format(format));
3177 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
3178 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3180 struct d3d_device *device = impl_from_ID3D10Device(iface);
3181 unsigned int i;
3183 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3184 iface, start_slot, buffer_count, buffers);
3186 wined3d_mutex_lock();
3187 for (i = 0; i < buffer_count; ++i)
3189 struct wined3d_buffer *wined3d_buffer;
3190 struct d3d_buffer *buffer_impl;
3192 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
3194 buffers[i] = NULL;
3195 continue;
3198 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3199 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3200 ID3D10Buffer_AddRef(buffers[i]);
3202 wined3d_mutex_unlock();
3205 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
3206 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3208 struct d3d_device *device = impl_from_ID3D10Device(iface);
3209 unsigned int i;
3211 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3212 iface, start_slot, view_count, views);
3214 wined3d_mutex_lock();
3215 for (i = 0; i < view_count; ++i)
3217 struct wined3d_shader_resource_view *wined3d_view;
3218 struct d3d_shader_resource_view *view_impl;
3220 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
3222 views[i] = NULL;
3223 continue;
3226 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3227 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3228 ID3D10ShaderResourceView_AddRef(views[i]);
3230 wined3d_mutex_unlock();
3233 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
3235 struct d3d_device *device = impl_from_ID3D10Device(iface);
3236 struct d3d_pixel_shader *shader_impl;
3237 struct wined3d_shader *wined3d_shader;
3239 TRACE("iface %p, shader %p.\n", iface, shader);
3241 wined3d_mutex_lock();
3242 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
3244 wined3d_mutex_unlock();
3245 *shader = NULL;
3246 return;
3249 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3250 wined3d_mutex_unlock();
3251 *shader = &shader_impl->ID3D10PixelShader_iface;
3252 ID3D10PixelShader_AddRef(*shader);
3255 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
3256 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3258 struct d3d_device *device = impl_from_ID3D10Device(iface);
3259 unsigned int i;
3261 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3262 iface, start_slot, sampler_count, samplers);
3264 wined3d_mutex_lock();
3265 for (i = 0; i < sampler_count; ++i)
3267 struct d3d_sampler_state *sampler_impl;
3268 struct wined3d_sampler *wined3d_sampler;
3270 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
3272 samplers[i] = NULL;
3273 continue;
3276 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3277 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3278 ID3D10SamplerState_AddRef(samplers[i]);
3280 wined3d_mutex_unlock();
3283 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
3285 struct d3d_device *device = impl_from_ID3D10Device(iface);
3286 struct d3d_vertex_shader *shader_impl;
3287 struct wined3d_shader *wined3d_shader;
3289 TRACE("iface %p, shader %p.\n", iface, shader);
3291 wined3d_mutex_lock();
3292 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
3294 wined3d_mutex_unlock();
3295 *shader = NULL;
3296 return;
3299 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3300 wined3d_mutex_unlock();
3301 *shader = &shader_impl->ID3D10VertexShader_iface;
3302 ID3D10VertexShader_AddRef(*shader);
3305 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
3306 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3308 struct d3d_device *device = impl_from_ID3D10Device(iface);
3309 unsigned int i;
3311 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3312 iface, start_slot, buffer_count, buffers);
3314 wined3d_mutex_lock();
3315 for (i = 0; i < buffer_count; ++i)
3317 struct wined3d_buffer *wined3d_buffer;
3318 struct d3d_buffer *buffer_impl;
3320 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
3322 buffers[i] = NULL;
3323 continue;
3326 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3327 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3328 ID3D10Buffer_AddRef(buffers[i]);
3330 wined3d_mutex_unlock();
3333 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
3335 struct d3d_device *device = impl_from_ID3D10Device(iface);
3336 struct wined3d_vertex_declaration *wined3d_declaration;
3337 struct d3d_input_layout *input_layout_impl;
3339 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
3341 wined3d_mutex_lock();
3342 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
3344 wined3d_mutex_unlock();
3345 *input_layout = NULL;
3346 return;
3349 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
3350 wined3d_mutex_unlock();
3351 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
3352 ID3D10InputLayout_AddRef(*input_layout);
3355 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
3356 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
3358 struct d3d_device *device = impl_from_ID3D10Device(iface);
3359 unsigned int i;
3361 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3362 iface, start_slot, buffer_count, buffers, strides, offsets);
3364 wined3d_mutex_lock();
3365 for (i = 0; i < buffer_count; ++i)
3367 struct wined3d_buffer *wined3d_buffer;
3368 struct d3d_buffer *buffer_impl;
3370 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
3371 &wined3d_buffer, &offsets[i], &strides[i])))
3372 ERR("Failed to get vertex buffer.\n");
3374 if (!wined3d_buffer)
3376 buffers[i] = NULL;
3377 continue;
3380 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3381 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3382 ID3D10Buffer_AddRef(buffers[i]);
3384 wined3d_mutex_unlock();
3387 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
3388 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
3390 struct d3d_device *device = impl_from_ID3D10Device(iface);
3391 enum wined3d_format_id wined3d_format;
3392 struct wined3d_buffer *wined3d_buffer;
3393 struct d3d_buffer *buffer_impl;
3395 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
3397 wined3d_mutex_lock();
3398 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
3399 *format = dxgi_format_from_wined3dformat(wined3d_format);
3400 *offset = 0; /* FIXME */
3401 if (!wined3d_buffer)
3403 wined3d_mutex_unlock();
3404 *buffer = NULL;
3405 return;
3408 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3409 wined3d_mutex_unlock();
3410 *buffer = &buffer_impl->ID3D10Buffer_iface;
3411 ID3D10Buffer_AddRef(*buffer);
3414 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
3415 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3417 struct d3d_device *device = impl_from_ID3D10Device(iface);
3418 unsigned int i;
3420 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3421 iface, start_slot, buffer_count, buffers);
3423 wined3d_mutex_lock();
3424 for (i = 0; i < buffer_count; ++i)
3426 struct wined3d_buffer *wined3d_buffer;
3427 struct d3d_buffer *buffer_impl;
3429 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
3431 buffers[i] = NULL;
3432 continue;
3435 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3436 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3437 ID3D10Buffer_AddRef(buffers[i]);
3439 wined3d_mutex_unlock();
3442 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
3444 struct d3d_device *device = impl_from_ID3D10Device(iface);
3445 struct d3d_geometry_shader *shader_impl;
3446 struct wined3d_shader *wined3d_shader;
3448 TRACE("iface %p, shader %p.\n", iface, shader);
3450 wined3d_mutex_lock();
3451 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
3453 wined3d_mutex_unlock();
3454 *shader = NULL;
3455 return;
3458 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3459 wined3d_mutex_unlock();
3460 *shader = &shader_impl->ID3D10GeometryShader_iface;
3461 ID3D10GeometryShader_AddRef(*shader);
3464 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
3465 D3D10_PRIMITIVE_TOPOLOGY *topology)
3467 struct d3d_device *This = impl_from_ID3D10Device(iface);
3469 TRACE("iface %p, topology %p\n", iface, topology);
3471 wined3d_mutex_lock();
3472 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
3473 wined3d_mutex_unlock();
3476 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
3477 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3479 struct d3d_device *device = impl_from_ID3D10Device(iface);
3480 unsigned int i;
3482 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3483 iface, start_slot, view_count, views);
3485 wined3d_mutex_lock();
3486 for (i = 0; i < view_count; ++i)
3488 struct wined3d_shader_resource_view *wined3d_view;
3489 struct d3d_shader_resource_view *view_impl;
3491 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
3493 views[i] = NULL;
3494 continue;
3497 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3498 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3499 ID3D10ShaderResourceView_AddRef(views[i]);
3501 wined3d_mutex_unlock();
3504 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
3505 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3507 struct d3d_device *device = impl_from_ID3D10Device(iface);
3508 unsigned int i;
3510 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3511 iface, start_slot, sampler_count, samplers);
3513 wined3d_mutex_lock();
3514 for (i = 0; i < sampler_count; ++i)
3516 struct d3d_sampler_state *sampler_impl;
3517 struct wined3d_sampler *wined3d_sampler;
3519 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
3521 samplers[i] = NULL;
3522 continue;
3525 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3526 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3527 ID3D10SamplerState_AddRef(samplers[i]);
3529 wined3d_mutex_unlock();
3532 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
3533 ID3D10Predicate **predicate, BOOL *value)
3535 struct d3d_device *device = impl_from_ID3D10Device(iface);
3536 struct wined3d_query *wined3d_predicate;
3537 struct d3d_query *predicate_impl;
3539 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
3541 wined3d_mutex_lock();
3542 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
3544 wined3d_mutex_unlock();
3545 *predicate = NULL;
3546 return;
3549 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
3550 wined3d_mutex_unlock();
3551 *predicate = (ID3D10Predicate *)&predicate_impl->ID3D10Query_iface;
3552 ID3D10Predicate_AddRef(*predicate);
3555 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
3556 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3558 struct d3d_device *device = impl_from_ID3D10Device(iface);
3559 unsigned int i;
3561 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3562 iface, start_slot, view_count, views);
3564 wined3d_mutex_lock();
3565 for (i = 0; i < view_count; ++i)
3567 struct wined3d_shader_resource_view *wined3d_view;
3568 struct d3d_shader_resource_view *view_impl;
3570 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
3572 views[i] = NULL;
3573 continue;
3576 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3577 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3578 ID3D10ShaderResourceView_AddRef(views[i]);
3580 wined3d_mutex_unlock();
3583 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
3584 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3586 struct d3d_device *device = impl_from_ID3D10Device(iface);
3587 unsigned int i;
3589 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3590 iface, start_slot, sampler_count, samplers);
3592 wined3d_mutex_lock();
3593 for (i = 0; i < sampler_count; ++i)
3595 struct d3d_sampler_state *sampler_impl;
3596 struct wined3d_sampler *wined3d_sampler;
3598 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
3600 samplers[i] = NULL;
3601 continue;
3604 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3605 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3606 ID3D10SamplerState_AddRef(samplers[i]);
3608 wined3d_mutex_unlock();
3611 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
3612 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
3614 struct d3d_device *device = impl_from_ID3D10Device(iface);
3615 struct wined3d_rendertarget_view *wined3d_view;
3617 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3618 iface, view_count, render_target_views, depth_stencil_view);
3620 wined3d_mutex_lock();
3621 if (render_target_views)
3623 struct d3d_rendertarget_view *view_impl;
3624 unsigned int i;
3626 for (i = 0; i < view_count; ++i)
3628 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
3629 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3631 render_target_views[i] = NULL;
3632 continue;
3635 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
3636 ID3D10RenderTargetView_AddRef(render_target_views[i]);
3640 if (depth_stencil_view)
3642 struct d3d_depthstencil_view *view_impl;
3644 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
3645 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3647 *depth_stencil_view = NULL;
3649 else
3651 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
3652 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
3655 wined3d_mutex_unlock();
3658 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
3659 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
3661 struct d3d_device *device = impl_from_ID3D10Device(iface);
3663 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3664 iface, blend_state, blend_factor, sample_mask);
3666 if ((*blend_state = device->blend_state ? (ID3D10BlendState *)&device->blend_state->ID3D10BlendState1_iface : NULL))
3667 ID3D10BlendState_AddRef(*blend_state);
3668 wined3d_mutex_lock();
3669 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
3670 *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK);
3671 wined3d_mutex_unlock();
3674 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
3675 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
3677 struct d3d_device *device = impl_from_ID3D10Device(iface);
3679 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
3680 iface, depth_stencil_state, stencil_ref);
3682 if ((*depth_stencil_state = device->depth_stencil_state
3683 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
3684 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
3685 *stencil_ref = device->stencil_ref;
3688 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
3689 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
3691 struct d3d_device *device = impl_from_ID3D10Device(iface);
3692 unsigned int i;
3694 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
3695 iface, buffer_count, buffers, offsets);
3697 wined3d_mutex_lock();
3698 for (i = 0; i < buffer_count; ++i)
3700 struct wined3d_buffer *wined3d_buffer;
3701 struct d3d_buffer *buffer_impl;
3703 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
3705 buffers[i] = NULL;
3706 continue;
3709 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3710 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3711 ID3D10Buffer_AddRef(buffers[i]);
3713 wined3d_mutex_unlock();
3716 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
3718 struct d3d_device *device = impl_from_ID3D10Device(iface);
3720 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3722 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
3723 ID3D10RasterizerState_AddRef(*rasterizer_state);
3726 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
3727 UINT *viewport_count, D3D10_VIEWPORT *viewports)
3729 struct d3d_device *device = impl_from_ID3D10Device(iface);
3730 struct wined3d_viewport wined3d_vp;
3732 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
3734 if (!viewports)
3736 *viewport_count = 1;
3737 return;
3740 if (!*viewport_count)
3741 return;
3743 wined3d_mutex_lock();
3744 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
3745 wined3d_mutex_unlock();
3747 viewports[0].TopLeftX = wined3d_vp.x;
3748 viewports[0].TopLeftY = wined3d_vp.y;
3749 viewports[0].Width = wined3d_vp.width;
3750 viewports[0].Height = wined3d_vp.height;
3751 viewports[0].MinDepth = wined3d_vp.min_z;
3752 viewports[0].MaxDepth = wined3d_vp.max_z;
3754 if (*viewport_count > 1)
3755 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
3758 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
3760 struct d3d_device *device = impl_from_ID3D10Device(iface);
3762 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
3764 if (!rects)
3766 *rect_count = 1;
3767 return;
3770 if (!*rect_count)
3771 return;
3773 wined3d_mutex_lock();
3774 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
3775 wined3d_mutex_unlock();
3776 if (*rect_count > 1)
3777 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
3780 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
3782 TRACE("iface %p.\n", iface);
3784 /* In the current implementation the device is never removed, so we can
3785 * just return S_OK here. */
3787 return S_OK;
3790 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
3792 FIXME("iface %p, flags %#x stub!\n", iface, flags);
3794 return E_NOTIMPL;
3797 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
3799 FIXME("iface %p stub!\n", iface);
3801 return 0;
3804 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
3805 REFGUID guid, UINT *data_size, void *data)
3807 struct d3d_device *device = impl_from_ID3D10Device(iface);
3809 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3811 return d3d11_device_GetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3814 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
3815 REFGUID guid, UINT data_size, const void *data)
3817 struct d3d_device *device = impl_from_ID3D10Device(iface);
3819 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3821 return d3d11_device_SetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3824 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
3825 REFGUID guid, const IUnknown *data)
3827 struct d3d_device *device = impl_from_ID3D10Device(iface);
3829 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
3831 return d3d11_device_SetPrivateDataInterface(&device->ID3D11Device_iface, guid, data);
3834 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
3836 static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
3837 struct d3d_device *device = impl_from_ID3D10Device(iface);
3838 unsigned int i;
3840 TRACE("iface %p.\n", iface);
3842 wined3d_mutex_lock();
3843 wined3d_device_set_vertex_shader(device->wined3d_device, NULL);
3844 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3846 wined3d_device_set_vs_sampler(device->wined3d_device, i, NULL);
3848 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3850 wined3d_device_set_vs_resource_view(device->wined3d_device, i, NULL);
3852 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3854 wined3d_device_set_vs_cb(device->wined3d_device, i, NULL);
3856 wined3d_device_set_geometry_shader(device->wined3d_device, NULL);
3857 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3859 wined3d_device_set_gs_sampler(device->wined3d_device, i, NULL);
3861 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3863 wined3d_device_set_gs_resource_view(device->wined3d_device, i, NULL);
3865 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3867 wined3d_device_set_gs_cb(device->wined3d_device, i, NULL);
3869 wined3d_device_set_pixel_shader(device->wined3d_device, NULL);
3870 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3872 wined3d_device_set_ps_sampler(device->wined3d_device, i, NULL);
3874 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3876 wined3d_device_set_ps_resource_view(device->wined3d_device, i, NULL);
3878 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3880 wined3d_device_set_ps_cb(device->wined3d_device, i, NULL);
3882 for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i)
3884 wined3d_device_set_stream_source(device->wined3d_device, i, NULL, 0, 0);
3886 wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
3887 wined3d_device_set_vertex_declaration(device->wined3d_device, NULL);
3888 wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_UNDEFINED);
3889 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
3891 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
3893 wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL);
3894 ID3D10Device1_OMSetDepthStencilState(iface, NULL, 0);
3895 ID3D10Device1_OMSetBlendState(iface, NULL, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
3896 ID3D10Device1_RSSetViewports(iface, 0, NULL);
3897 ID3D10Device1_RSSetScissorRects(iface, 0, NULL);
3898 ID3D10Device1_RSSetState(iface, NULL);
3899 for (i = 0; i < D3D10_SO_BUFFER_SLOT_COUNT; ++i)
3901 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
3903 wined3d_device_set_predication(device->wined3d_device, NULL, FALSE);
3904 wined3d_mutex_unlock();
3907 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
3909 FIXME("iface %p stub!\n", iface);
3912 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
3913 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
3915 struct d3d_device *device = impl_from_ID3D10Device(iface);
3916 D3D11_BUFFER_DESC d3d11_desc;
3917 struct d3d_buffer *object;
3918 HRESULT hr;
3920 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
3922 d3d11_desc.ByteWidth = desc->ByteWidth;
3923 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3924 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3925 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3926 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3927 d3d11_desc.StructureByteStride = 0;
3929 if (FAILED(hr = d3d_buffer_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3930 return hr;
3932 *buffer = &object->ID3D10Buffer_iface;
3934 return S_OK;
3937 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
3938 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
3940 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
3942 return E_NOTIMPL;
3945 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
3946 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
3947 ID3D10Texture2D **texture)
3949 struct d3d_device *device = impl_from_ID3D10Device(iface);
3950 D3D11_TEXTURE2D_DESC d3d11_desc;
3951 struct d3d_texture2d *object;
3952 HRESULT hr;
3954 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
3956 d3d11_desc.Width = desc->Width;
3957 d3d11_desc.Height = desc->Height;
3958 d3d11_desc.MipLevels = desc->MipLevels;
3959 d3d11_desc.ArraySize = desc->ArraySize;
3960 d3d11_desc.Format = desc->Format;
3961 d3d11_desc.SampleDesc = desc->SampleDesc;
3962 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3963 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3964 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3965 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3967 if (FAILED(hr = d3d_texture2d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3968 return hr;
3970 *texture = &object->ID3D10Texture2D_iface;
3972 return S_OK;
3975 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
3976 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
3977 ID3D10Texture3D **texture)
3979 struct d3d_device *device = impl_from_ID3D10Device(iface);
3980 D3D11_TEXTURE3D_DESC d3d11_desc;
3981 struct d3d_texture3d *object;
3982 HRESULT hr;
3984 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
3986 d3d11_desc.Width = desc->Width;
3987 d3d11_desc.Height = desc->Height;
3988 d3d11_desc.Depth = desc->Depth;
3989 d3d11_desc.MipLevels = desc->MipLevels;
3990 d3d11_desc.Format = desc->Format;
3991 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3992 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3993 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3994 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3996 if (FAILED(hr = d3d_texture3d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3997 return hr;
3999 *texture = &object->ID3D10Texture3D_iface;
4001 return S_OK;
4004 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
4005 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
4007 struct d3d_device *device = impl_from_ID3D10Device(iface);
4008 struct d3d_shader_resource_view *object;
4009 ID3D11Resource *d3d11_resource;
4010 HRESULT hr;
4012 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4014 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4016 ERR("Resource does not implement ID3D11Resource.\n");
4017 return E_FAIL;
4020 hr = d3d_shader_resource_view_create(device, d3d11_resource, (const D3D11_SHADER_RESOURCE_VIEW_DESC *)desc,
4021 &object);
4022 ID3D11Resource_Release(d3d11_resource);
4023 if (FAILED(hr))
4024 return hr;
4026 *view = &object->ID3D10ShaderResourceView1_iface;
4028 return S_OK;
4031 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
4032 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
4034 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4036 return d3d10_device_CreateShaderResourceView1(iface, resource,
4037 (const D3D10_SHADER_RESOURCE_VIEW_DESC1 *)desc, (ID3D10ShaderResourceView1 **)view);
4040 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
4041 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
4043 struct d3d_device *device = impl_from_ID3D10Device(iface);
4044 struct d3d_rendertarget_view *object;
4045 ID3D11Resource *d3d11_resource;
4046 HRESULT hr;
4048 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4050 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4052 ERR("Resource does not implement ID3D11Resource.\n");
4053 return E_FAIL;
4056 hr = d3d_rendertarget_view_create(device, d3d11_resource, (const D3D11_RENDER_TARGET_VIEW_DESC *)desc, &object);
4057 ID3D11Resource_Release(d3d11_resource);
4058 if (FAILED(hr))
4059 return hr;
4061 *view = &object->ID3D10RenderTargetView_iface;
4063 return S_OK;
4066 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
4067 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
4069 struct d3d_device *device = impl_from_ID3D10Device(iface);
4070 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc;
4071 struct d3d_depthstencil_view *object;
4072 ID3D11Resource *d3d11_resource;
4073 HRESULT hr;
4075 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4077 if (desc)
4079 d3d11_desc.Format = desc->Format;
4080 d3d11_desc.ViewDimension = desc->ViewDimension;
4081 d3d11_desc.Flags = 0;
4082 memcpy(&d3d11_desc.u, &desc->u, sizeof(d3d11_desc.u));
4085 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4087 ERR("Resource does not implement ID3D11Resource.\n");
4088 return E_FAIL;
4091 hr = d3d_depthstencil_view_create(device, d3d11_resource, desc ? &d3d11_desc : NULL, &object);
4092 ID3D11Resource_Release(d3d11_resource);
4093 if (FAILED(hr))
4094 return hr;
4096 *view = &object->ID3D10DepthStencilView_iface;
4098 return S_OK;
4101 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
4102 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
4103 const void *shader_byte_code, SIZE_T shader_byte_code_length,
4104 ID3D10InputLayout **input_layout)
4106 struct d3d_device *device = impl_from_ID3D10Device(iface);
4107 struct d3d_input_layout *object;
4108 HRESULT hr;
4110 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4111 "shader_byte_code_length %lu, input_layout %p\n",
4112 iface, element_descs, element_count, shader_byte_code,
4113 shader_byte_code_length, input_layout);
4115 if (FAILED(hr = d3d_input_layout_create(device, (const D3D11_INPUT_ELEMENT_DESC *)element_descs, element_count,
4116 shader_byte_code, shader_byte_code_length, &object)))
4117 return hr;
4119 *input_layout = &object->ID3D10InputLayout_iface;
4121 return S_OK;
4124 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
4125 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
4127 struct d3d_device *device = impl_from_ID3D10Device(iface);
4128 struct d3d_vertex_shader *object;
4129 HRESULT hr;
4131 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4132 iface, byte_code, byte_code_length, shader);
4134 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
4135 return hr;
4137 *shader = &object->ID3D10VertexShader_iface;
4139 return S_OK;
4142 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
4143 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
4145 struct d3d_device *device = impl_from_ID3D10Device(iface);
4146 struct d3d_geometry_shader *object;
4147 HRESULT hr;
4149 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4150 iface, byte_code, byte_code_length, shader);
4152 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
4153 return hr;
4155 *shader = &object->ID3D10GeometryShader_iface;
4157 return S_OK;
4160 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
4161 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
4162 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
4164 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4165 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4166 iface, byte_code, byte_code_length, output_stream_decls,
4167 output_stream_decl_count, output_stream_stride, shader);
4169 return E_NOTIMPL;
4172 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
4173 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
4175 struct d3d_device *device = impl_from_ID3D10Device(iface);
4176 struct d3d_pixel_shader *object;
4177 HRESULT hr;
4179 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4180 iface, byte_code, byte_code_length, shader);
4182 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
4183 return hr;
4185 *shader = &object->ID3D10PixelShader_iface;
4187 return S_OK;
4190 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
4191 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
4193 struct d3d_device *device = impl_from_ID3D10Device(iface);
4194 ID3D11BlendState *d3d11_blend_state;
4195 HRESULT hr;
4197 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4199 if (FAILED(hr = d3d11_device_CreateBlendState(&device->ID3D11Device_iface, (D3D11_BLEND_DESC *)desc,
4200 &d3d11_blend_state)))
4201 return hr;
4203 hr = ID3D11BlendState_QueryInterface(d3d11_blend_state, &IID_ID3D10BlendState1, (void **)blend_state);
4204 ID3D11BlendState_Release(d3d11_blend_state);
4205 return hr;
4208 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
4209 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
4211 D3D10_BLEND_DESC1 d3d10_1_desc;
4212 unsigned int i;
4214 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4216 if (!desc)
4217 return E_INVALIDARG;
4219 d3d10_1_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
4220 d3d10_1_desc.IndependentBlendEnable = FALSE;
4221 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT - 1; ++i)
4223 if (desc->BlendEnable[i] != desc->BlendEnable[i + 1]
4224 || desc->RenderTargetWriteMask[i] != desc->RenderTargetWriteMask[i + 1])
4225 d3d10_1_desc.IndependentBlendEnable = TRUE;
4228 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
4230 d3d10_1_desc.RenderTarget[i].BlendEnable = desc->BlendEnable[i];
4231 d3d10_1_desc.RenderTarget[i].SrcBlend = desc->SrcBlend;
4232 d3d10_1_desc.RenderTarget[i].DestBlend = desc->DestBlend;
4233 d3d10_1_desc.RenderTarget[i].BlendOp = desc->BlendOp;
4234 d3d10_1_desc.RenderTarget[i].SrcBlendAlpha = desc->SrcBlendAlpha;
4235 d3d10_1_desc.RenderTarget[i].DestBlendAlpha = desc->DestBlendAlpha;
4236 d3d10_1_desc.RenderTarget[i].BlendOpAlpha = desc->BlendOpAlpha;
4237 d3d10_1_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTargetWriteMask[i];
4240 return d3d10_device_CreateBlendState1(iface, &d3d10_1_desc, (ID3D10BlendState1 **)blend_state);
4243 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
4244 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
4246 struct d3d_device *device = impl_from_ID3D10Device(iface);
4247 ID3D11DepthStencilState *d3d11_depth_stencil_state;
4248 HRESULT hr;
4250 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
4252 if (FAILED(hr = d3d11_device_CreateDepthStencilState(&device->ID3D11Device_iface,
4253 (const D3D11_DEPTH_STENCIL_DESC *)desc, &d3d11_depth_stencil_state)))
4254 return hr;
4256 hr = ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state, &IID_ID3D10DepthStencilState,
4257 (void **)depth_stencil_state);
4258 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state);
4259 return hr;
4262 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
4263 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
4265 struct d3d_device *device = impl_from_ID3D10Device(iface);
4266 ID3D11RasterizerState *d3d11_rasterizer_state;
4267 HRESULT hr;
4269 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
4271 if (FAILED(hr = d3d11_device_CreateRasterizerState(&device->ID3D11Device_iface,
4272 (const D3D11_RASTERIZER_DESC *)desc, &d3d11_rasterizer_state)))
4273 return hr;
4275 hr = ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state,
4276 &IID_ID3D10RasterizerState, (void **)rasterizer_state);
4277 ID3D11RasterizerState_Release(d3d11_rasterizer_state);
4278 return hr;
4281 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
4282 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
4284 struct d3d_device *device = impl_from_ID3D10Device(iface);
4285 ID3D11SamplerState *d3d11_sampler_state;
4286 HRESULT hr;
4288 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
4290 if (FAILED(hr = d3d11_device_CreateSamplerState(&device->ID3D11Device_iface,
4291 (const D3D11_SAMPLER_DESC *)desc, &d3d11_sampler_state)))
4292 return hr;
4294 hr = ID3D11SamplerState_QueryInterface(d3d11_sampler_state, &IID_ID3D10SamplerState, (void **)sampler_state);
4295 ID3D11SamplerState_Release(d3d11_sampler_state);
4296 return hr;
4299 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
4300 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
4302 struct d3d_device *device = impl_from_ID3D10Device(iface);
4303 struct d3d_query *object;
4304 HRESULT hr;
4306 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
4308 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, FALSE, &object)))
4309 return hr;
4311 *query = &object->ID3D10Query_iface;
4313 return S_OK;
4316 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
4317 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
4319 struct d3d_device *device = impl_from_ID3D10Device(iface);
4320 struct d3d_query *object;
4321 HRESULT hr;
4323 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
4325 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, TRUE, &object)))
4326 return hr;
4328 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
4330 return S_OK;
4333 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
4334 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
4336 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
4338 return E_NOTIMPL;
4341 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
4342 DXGI_FORMAT format, UINT *format_support)
4344 FIXME("iface %p, format %s, format_support %p stub!\n",
4345 iface, debug_dxgi_format(format), format_support);
4347 return E_NOTIMPL;
4350 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
4351 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
4353 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
4354 iface, debug_dxgi_format(format), sample_count, quality_level_count);
4356 return E_NOTIMPL;
4359 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
4361 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
4364 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
4365 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
4366 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
4368 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4369 "units %p, units_length %p, description %p, description_length %p stub!\n",
4370 iface, desc, type, active_counters, name, name_length,
4371 units, units_length, description, description_length);
4373 return E_NOTIMPL;
4376 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
4378 FIXME("iface %p stub!\n", iface);
4380 return 0;
4383 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
4384 HANDLE resource_handle, REFIID guid, void **resource)
4386 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4387 iface, resource_handle, debugstr_guid(guid), resource);
4389 return E_NOTIMPL;
4392 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
4394 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
4397 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
4399 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
4402 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
4404 FIXME("iface %p stub!\n", iface);
4406 return D3D10_FEATURE_LEVEL_10_1;
4409 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
4411 /* IUnknown methods */
4412 d3d10_device_QueryInterface,
4413 d3d10_device_AddRef,
4414 d3d10_device_Release,
4415 /* ID3D10Device methods */
4416 d3d10_device_VSSetConstantBuffers,
4417 d3d10_device_PSSetShaderResources,
4418 d3d10_device_PSSetShader,
4419 d3d10_device_PSSetSamplers,
4420 d3d10_device_VSSetShader,
4421 d3d10_device_DrawIndexed,
4422 d3d10_device_Draw,
4423 d3d10_device_PSSetConstantBuffers,
4424 d3d10_device_IASetInputLayout,
4425 d3d10_device_IASetVertexBuffers,
4426 d3d10_device_IASetIndexBuffer,
4427 d3d10_device_DrawIndexedInstanced,
4428 d3d10_device_DrawInstanced,
4429 d3d10_device_GSSetConstantBuffers,
4430 d3d10_device_GSSetShader,
4431 d3d10_device_IASetPrimitiveTopology,
4432 d3d10_device_VSSetShaderResources,
4433 d3d10_device_VSSetSamplers,
4434 d3d10_device_SetPredication,
4435 d3d10_device_GSSetShaderResources,
4436 d3d10_device_GSSetSamplers,
4437 d3d10_device_OMSetRenderTargets,
4438 d3d10_device_OMSetBlendState,
4439 d3d10_device_OMSetDepthStencilState,
4440 d3d10_device_SOSetTargets,
4441 d3d10_device_DrawAuto,
4442 d3d10_device_RSSetState,
4443 d3d10_device_RSSetViewports,
4444 d3d10_device_RSSetScissorRects,
4445 d3d10_device_CopySubresourceRegion,
4446 d3d10_device_CopyResource,
4447 d3d10_device_UpdateSubresource,
4448 d3d10_device_ClearRenderTargetView,
4449 d3d10_device_ClearDepthStencilView,
4450 d3d10_device_GenerateMips,
4451 d3d10_device_ResolveSubresource,
4452 d3d10_device_VSGetConstantBuffers,
4453 d3d10_device_PSGetShaderResources,
4454 d3d10_device_PSGetShader,
4455 d3d10_device_PSGetSamplers,
4456 d3d10_device_VSGetShader,
4457 d3d10_device_PSGetConstantBuffers,
4458 d3d10_device_IAGetInputLayout,
4459 d3d10_device_IAGetVertexBuffers,
4460 d3d10_device_IAGetIndexBuffer,
4461 d3d10_device_GSGetConstantBuffers,
4462 d3d10_device_GSGetShader,
4463 d3d10_device_IAGetPrimitiveTopology,
4464 d3d10_device_VSGetShaderResources,
4465 d3d10_device_VSGetSamplers,
4466 d3d10_device_GetPredication,
4467 d3d10_device_GSGetShaderResources,
4468 d3d10_device_GSGetSamplers,
4469 d3d10_device_OMGetRenderTargets,
4470 d3d10_device_OMGetBlendState,
4471 d3d10_device_OMGetDepthStencilState,
4472 d3d10_device_SOGetTargets,
4473 d3d10_device_RSGetState,
4474 d3d10_device_RSGetViewports,
4475 d3d10_device_RSGetScissorRects,
4476 d3d10_device_GetDeviceRemovedReason,
4477 d3d10_device_SetExceptionMode,
4478 d3d10_device_GetExceptionMode,
4479 d3d10_device_GetPrivateData,
4480 d3d10_device_SetPrivateData,
4481 d3d10_device_SetPrivateDataInterface,
4482 d3d10_device_ClearState,
4483 d3d10_device_Flush,
4484 d3d10_device_CreateBuffer,
4485 d3d10_device_CreateTexture1D,
4486 d3d10_device_CreateTexture2D,
4487 d3d10_device_CreateTexture3D,
4488 d3d10_device_CreateShaderResourceView,
4489 d3d10_device_CreateRenderTargetView,
4490 d3d10_device_CreateDepthStencilView,
4491 d3d10_device_CreateInputLayout,
4492 d3d10_device_CreateVertexShader,
4493 d3d10_device_CreateGeometryShader,
4494 d3d10_device_CreateGeometryShaderWithStreamOutput,
4495 d3d10_device_CreatePixelShader,
4496 d3d10_device_CreateBlendState,
4497 d3d10_device_CreateDepthStencilState,
4498 d3d10_device_CreateRasterizerState,
4499 d3d10_device_CreateSamplerState,
4500 d3d10_device_CreateQuery,
4501 d3d10_device_CreatePredicate,
4502 d3d10_device_CreateCounter,
4503 d3d10_device_CheckFormatSupport,
4504 d3d10_device_CheckMultisampleQualityLevels,
4505 d3d10_device_CheckCounterInfo,
4506 d3d10_device_CheckCounter,
4507 d3d10_device_GetCreationFlags,
4508 d3d10_device_OpenSharedResource,
4509 d3d10_device_SetTextFilterSize,
4510 d3d10_device_GetTextFilterSize,
4511 d3d10_device_CreateShaderResourceView1,
4512 d3d10_device_CreateBlendState1,
4513 d3d10_device_GetFeatureLevel,
4516 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl =
4518 /* IUnknown methods */
4519 d3d_device_inner_QueryInterface,
4520 d3d_device_inner_AddRef,
4521 d3d_device_inner_Release,
4524 /* ID3D10Multithread methods */
4526 static inline struct d3d_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
4528 return CONTAINING_RECORD(iface, struct d3d_device, ID3D10Multithread_iface);
4531 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
4533 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4535 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
4537 return IUnknown_QueryInterface(device->outer_unk, iid, out);
4540 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
4542 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4544 TRACE("iface %p.\n", iface);
4546 return IUnknown_AddRef(device->outer_unk);
4549 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
4551 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4553 TRACE("iface %p.\n", iface);
4555 return IUnknown_Release(device->outer_unk);
4558 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
4560 TRACE("iface %p.\n", iface);
4562 wined3d_mutex_lock();
4565 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
4567 TRACE("iface %p.\n", iface);
4569 wined3d_mutex_unlock();
4572 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
4574 FIXME("iface %p, protect %#x stub!\n", iface, protect);
4576 return TRUE;
4579 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
4581 FIXME("iface %p stub!\n", iface);
4583 return TRUE;
4586 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
4588 d3d10_multithread_QueryInterface,
4589 d3d10_multithread_AddRef,
4590 d3d10_multithread_Release,
4591 d3d10_multithread_Enter,
4592 d3d10_multithread_Leave,
4593 d3d10_multithread_SetMultithreadProtected,
4594 d3d10_multithread_GetMultithreadProtected,
4597 /* IWineDXGIDeviceParent IUnknown methods */
4599 static inline struct d3d_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
4601 return CONTAINING_RECORD(iface, struct d3d_device, IWineDXGIDeviceParent_iface);
4604 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
4605 REFIID riid, void **ppv)
4607 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4608 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
4611 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
4613 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4614 return IUnknown_AddRef(device->outer_unk);
4617 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
4619 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4620 return IUnknown_Release(device->outer_unk);
4623 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
4624 IWineDXGIDeviceParent *iface)
4626 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4627 return &device->device_parent;
4630 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl =
4632 /* IUnknown methods */
4633 dxgi_device_parent_QueryInterface,
4634 dxgi_device_parent_AddRef,
4635 dxgi_device_parent_Release,
4636 /* IWineDXGIDeviceParent methods */
4637 dxgi_device_parent_get_wined3d_device_parent,
4640 static inline struct d3d_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
4642 return CONTAINING_RECORD(device_parent, struct d3d_device, device_parent);
4645 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
4646 struct wined3d_device *wined3d_device)
4648 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4650 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
4652 wined3d_device_incref(wined3d_device);
4653 device->wined3d_device = wined3d_device;
4656 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
4658 TRACE("device_parent %p.\n", device_parent);
4661 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
4663 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
4666 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
4667 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface, void **parent,
4668 const struct wined3d_parent_ops **parent_ops)
4670 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
4671 device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
4673 *parent = NULL;
4674 *parent_ops = &d3d_null_wined3d_parent_ops;
4676 return S_OK;
4679 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
4680 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, void **parent,
4681 const struct wined3d_parent_ops **parent_ops)
4683 TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
4684 device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
4686 *parent = NULL;
4687 *parent_ops = &d3d_null_wined3d_parent_ops;
4689 return S_OK;
4692 static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
4693 void *container_parent, const struct wined3d_resource_desc *wined3d_desc,
4694 struct wined3d_texture **wined3d_texture)
4696 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4697 struct d3d_texture2d *texture;
4698 ID3D10Texture2D *texture_iface;
4699 D3D10_TEXTURE2D_DESC desc;
4700 HRESULT hr;
4702 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
4703 device_parent, container_parent, wined3d_desc, wined3d_texture);
4705 FIXME("Implement DXGI<->wined3d usage conversion\n");
4707 desc.Width = wined3d_desc->width;
4708 desc.Height = wined3d_desc->height;
4709 desc.MipLevels = 1;
4710 desc.ArraySize = 1;
4711 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
4712 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
4713 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
4714 desc.Usage = D3D10_USAGE_DEFAULT;
4715 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
4716 desc.CPUAccessFlags = 0;
4717 desc.MiscFlags = 0;
4719 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
4720 &desc, NULL, &texture_iface)))
4722 ERR("CreateTexture2D failed, returning %#x\n", hr);
4723 return hr;
4726 texture = impl_from_ID3D10Texture2D(texture_iface);
4728 *wined3d_texture = texture->wined3d_texture;
4729 wined3d_texture_incref(*wined3d_texture);
4730 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
4732 return S_OK;
4735 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
4736 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
4738 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4739 IWineDXGIDevice *wine_device;
4740 HRESULT hr;
4742 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
4744 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
4745 &IID_IWineDXGIDevice, (void **)&wine_device)))
4747 ERR("Device should implement IWineDXGIDevice.\n");
4748 return E_FAIL;
4751 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
4752 IWineDXGIDevice_Release(wine_device);
4753 if (FAILED(hr))
4755 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
4756 return hr;
4759 return S_OK;
4762 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops =
4764 device_parent_wined3d_device_created,
4765 device_parent_mode_changed,
4766 device_parent_activate,
4767 device_parent_surface_created,
4768 device_parent_volume_created,
4769 device_parent_create_swapchain_texture,
4770 device_parent_create_swapchain,
4773 static void *d3d_rb_alloc(size_t size)
4775 return HeapAlloc(GetProcessHeap(), 0, size);
4778 static void *d3d_rb_realloc(void *ptr, size_t size)
4780 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
4783 static void d3d_rb_free(void *ptr)
4785 HeapFree(GetProcessHeap(), 0, ptr);
4788 static int d3d_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
4790 const D3D11_SAMPLER_DESC *ka = key;
4791 const D3D11_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_sampler_state, entry)->desc;
4793 return memcmp(ka, kb, sizeof(*ka));
4796 static const struct wine_rb_functions d3d_sampler_state_rb_ops =
4798 d3d_rb_alloc,
4799 d3d_rb_realloc,
4800 d3d_rb_free,
4801 d3d_sampler_state_compare,
4804 static int d3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
4806 const D3D11_BLEND_DESC *ka = key;
4807 const D3D11_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_blend_state, entry)->desc;
4809 return memcmp(ka, kb, sizeof(*ka));
4812 static const struct wine_rb_functions d3d_blend_state_rb_ops =
4814 d3d_rb_alloc,
4815 d3d_rb_realloc,
4816 d3d_rb_free,
4817 d3d_blend_state_compare,
4820 static int d3d_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
4822 const D3D11_DEPTH_STENCIL_DESC *ka = key;
4823 const D3D11_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
4824 const struct d3d_depthstencil_state, entry)->desc;
4826 return memcmp(ka, kb, sizeof(*ka));
4829 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops =
4831 d3d_rb_alloc,
4832 d3d_rb_realloc,
4833 d3d_rb_free,
4834 d3d_depthstencil_state_compare,
4837 static int d3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
4839 const D3D11_RASTERIZER_DESC *ka = key;
4840 const D3D11_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_rasterizer_state, entry)->desc;
4842 return memcmp(ka, kb, sizeof(*ka));
4845 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops =
4847 d3d_rb_alloc,
4848 d3d_rb_realloc,
4849 d3d_rb_free,
4850 d3d_rasterizer_state_compare,
4853 HRESULT d3d_device_init(struct d3d_device *device, void *outer_unknown)
4855 device->IUnknown_inner.lpVtbl = &d3d_device_inner_unknown_vtbl;
4856 device->ID3D11Device_iface.lpVtbl = &d3d11_device_vtbl;
4857 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
4858 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
4859 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d_dxgi_device_parent_vtbl;
4860 device->device_parent.ops = &d3d_wined3d_device_parent_ops;
4861 device->refcount = 1;
4862 /* COM aggregation always takes place */
4863 device->outer_unk = outer_unknown;
4865 if (FAILED(d3d11_immediate_context_init(&device->immediate_context, device)))
4867 WARN("Failed to initialize immediate device context.\n");
4868 return E_FAIL;
4870 ID3D11DeviceContext_Release(&device->immediate_context.ID3D11DeviceContext_iface);
4872 if (wine_rb_init(&device->blend_states, &d3d_blend_state_rb_ops) == -1)
4874 WARN("Failed to initialize blend state rbtree.\n");
4875 return E_FAIL;
4877 device->blend_factor[0] = 1.0f;
4878 device->blend_factor[1] = 1.0f;
4879 device->blend_factor[2] = 1.0f;
4880 device->blend_factor[3] = 1.0f;
4882 if (wine_rb_init(&device->depthstencil_states, &d3d_depthstencil_state_rb_ops) == -1)
4884 WARN("Failed to initialize depthstencil state rbtree.\n");
4885 wine_rb_destroy(&device->blend_states, NULL, NULL);
4886 return E_FAIL;
4889 if (wine_rb_init(&device->rasterizer_states, &d3d_rasterizer_state_rb_ops) == -1)
4891 WARN("Failed to initialize rasterizer state rbtree.\n");
4892 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
4893 wine_rb_destroy(&device->blend_states, NULL, NULL);
4894 return E_FAIL;
4897 if (wine_rb_init(&device->sampler_states, &d3d_sampler_state_rb_ops) == -1)
4899 WARN("Failed to initialize sampler state rbtree.\n");
4900 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
4901 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
4902 wine_rb_destroy(&device->blend_states, NULL, NULL);
4903 return E_FAIL;
4906 return S_OK;