d3d11: Implement d3d11_immediate_context_DrawIndexed().
[wine/multimedia.git] / dlls / d3d11 / device.c
blob325c006f895d0a056a8e9eb201b9cacf676bc8eb
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 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
232 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
233 iface, index_count, start_index_location, base_vertex_location);
235 wined3d_mutex_lock();
236 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
237 wined3d_device_draw_indexed_primitive(device->wined3d_device, start_index_location, index_count);
238 wined3d_mutex_unlock();
241 static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext *iface,
242 UINT vertex_count, UINT start_vertex_location)
244 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
246 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
247 iface, vertex_count, start_vertex_location);
249 wined3d_mutex_lock();
250 wined3d_device_draw_primitive(device->wined3d_device, start_vertex_location, vertex_count);
251 wined3d_mutex_unlock();
254 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext *iface, ID3D11Resource *resource,
255 UINT subresource_idx, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE *mapped_subresource)
257 struct wined3d_resource *wined3d_resource;
258 struct wined3d_map_desc map_desc;
259 HRESULT hr;
261 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
262 iface, resource, subresource_idx, map_type, map_flags, mapped_subresource);
264 if (map_flags)
265 FIXME("Ignoring map_flags %#x.\n", map_flags);
267 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
269 wined3d_mutex_lock();
270 hr = wined3d_resource_map(wined3d_resource, subresource_idx,
271 &map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type));
272 wined3d_mutex_unlock();
274 mapped_subresource->pData = map_desc.data;
275 mapped_subresource->RowPitch = map_desc.row_pitch;
276 mapped_subresource->DepthPitch = map_desc.slice_pitch;
278 return hr;
281 static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext *iface, ID3D11Resource *resource,
282 UINT subresource_idx)
284 struct wined3d_resource *wined3d_resource;
286 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface, resource, subresource_idx);
288 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
290 wined3d_mutex_lock();
291 wined3d_resource_unmap(wined3d_resource, subresource_idx);
292 wined3d_mutex_unlock();
295 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext *iface,
296 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
298 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
299 unsigned int i;
301 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
302 iface, start_slot, buffer_count, buffers);
304 wined3d_mutex_lock();
305 for (i = 0; i < buffer_count; ++i)
307 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
309 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
310 buffer ? buffer->wined3d_buffer : NULL);
312 wined3d_mutex_unlock();
315 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext *iface,
316 ID3D11InputLayout *input_layout)
318 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
319 struct d3d_input_layout *layout = unsafe_impl_from_ID3D11InputLayout(input_layout);
321 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
323 wined3d_mutex_lock();
324 wined3d_device_set_vertex_declaration(device->wined3d_device, layout ? layout->wined3d_decl : NULL);
325 wined3d_mutex_unlock();
328 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext *iface,
329 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *strides, const UINT *offsets)
331 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
332 unsigned int i;
334 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
335 iface, start_slot, buffer_count, buffers, strides, offsets);
337 wined3d_mutex_lock();
338 for (i = 0; i < buffer_count; ++i)
340 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
342 wined3d_device_set_stream_source(device->wined3d_device, start_slot + i,
343 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
345 wined3d_mutex_unlock();
348 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext *iface,
349 ID3D11Buffer *buffer, DXGI_FORMAT format, UINT offset)
351 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
352 struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D11Buffer(buffer);
354 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
355 iface, buffer, debug_dxgi_format(format), offset);
357 if (offset)
358 FIXME("offset %u not supported.\n", offset);
360 wined3d_mutex_lock();
361 wined3d_device_set_index_buffer(device->wined3d_device,
362 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
363 wined3dformat_from_dxgi_format(format));
364 wined3d_mutex_unlock();
367 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext *iface,
368 UINT instance_index_count, UINT instance_count, UINT start_index_location, INT base_vertex_location,
369 UINT start_instance_location)
371 FIXME("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
372 "base_vertex_location %d, start_instance_location %u stub!\n",
373 iface, instance_index_count, instance_count, start_index_location,
374 base_vertex_location, start_instance_location);
377 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext *iface,
378 UINT instance_vertex_count, UINT instance_count, UINT start_vertex_location, UINT start_instance_location)
380 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
382 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
383 "start_instance_location %u.\n",
384 iface, instance_vertex_count, instance_count, start_vertex_location,
385 start_instance_location);
387 wined3d_mutex_lock();
388 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
389 instance_vertex_count, start_instance_location, instance_count);
390 wined3d_mutex_unlock();
393 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext *iface,
394 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
396 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
397 unsigned int i;
399 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
400 iface, start_slot, buffer_count, buffers);
402 wined3d_mutex_lock();
403 for (i = 0; i < buffer_count; ++i)
405 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
407 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
408 buffer ? buffer->wined3d_buffer : NULL);
410 wined3d_mutex_unlock();
413 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext *iface,
414 ID3D11GeometryShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
416 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
417 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D11GeometryShader(shader);
419 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
420 iface, shader, class_instances, class_instance_count);
422 if (class_instances)
423 FIXME("Dynamic linking is not implemented yet.\n");
425 wined3d_mutex_lock();
426 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
427 wined3d_mutex_unlock();
430 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext *iface,
431 D3D11_PRIMITIVE_TOPOLOGY topology)
433 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
435 TRACE("iface %p, topology %u.\n", iface, topology);
437 wined3d_mutex_lock();
438 wined3d_device_set_primitive_type(device->wined3d_device, (enum wined3d_primitive_type)topology);
439 wined3d_mutex_unlock();
442 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext *iface,
443 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
445 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
446 unsigned int i;
448 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
450 wined3d_mutex_lock();
451 for (i = 0; i < view_count; ++i)
453 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
455 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
456 view ? view->wined3d_view : NULL);
458 wined3d_mutex_unlock();
461 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext *iface,
462 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
464 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
465 unsigned int i;
467 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
468 iface, start_slot, sampler_count, samplers);
470 wined3d_mutex_lock();
471 for (i = 0; i < sampler_count; ++i)
473 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
475 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
476 sampler ? sampler->wined3d_sampler : NULL);
478 wined3d_mutex_unlock();
481 static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext *iface,
482 ID3D11Asynchronous *asynchronous)
484 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
487 static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext *iface,
488 ID3D11Asynchronous *asynchronous)
490 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
493 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceContext *iface,
494 ID3D11Asynchronous *asynchronous, void *data, UINT data_size, UINT data_flags)
496 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
497 iface, asynchronous, data, data_size, data_flags);
499 return E_NOTIMPL;
502 static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11DeviceContext *iface,
503 ID3D11Predicate *predicate, BOOL value)
505 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
506 struct d3d_query *query;
508 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
510 query = unsafe_impl_from_ID3D11Query((ID3D11Query *)predicate);
512 wined3d_mutex_lock();
513 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
514 wined3d_mutex_unlock();
517 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext *iface,
518 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
520 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
521 unsigned int i;
523 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
525 wined3d_mutex_lock();
526 for (i = 0; i < view_count; ++i)
528 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
530 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
531 view ? view->wined3d_view : NULL);
533 wined3d_mutex_unlock();
536 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext *iface,
537 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
539 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
540 unsigned int i;
542 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
543 iface, start_slot, sampler_count, samplers);
545 wined3d_mutex_lock();
546 for (i = 0; i < sampler_count; ++i)
548 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
550 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
551 sampler ? sampler->wined3d_sampler : NULL);
553 wined3d_mutex_unlock();
556 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext *iface,
557 UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views,
558 ID3D11DepthStencilView *depth_stencil_view)
560 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
561 struct d3d_depthstencil_view *dsv;
562 unsigned int i;
564 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
565 iface, render_target_view_count, render_target_views, depth_stencil_view);
567 wined3d_mutex_lock();
568 for (i = 0; i < render_target_view_count; ++i)
570 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D11RenderTargetView(render_target_views[i]);
571 wined3d_device_set_rendertarget_view(device->wined3d_device, i, rtv ? rtv->wined3d_view : NULL, FALSE);
573 for (; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
575 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
578 dsv = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view);
579 wined3d_device_set_depth_stencil_view(device->wined3d_device, dsv ? dsv->wined3d_view : NULL);
580 wined3d_mutex_unlock();
583 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
584 ID3D11DeviceContext *iface, UINT render_target_view_count,
585 ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view,
586 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
587 ID3D11UnorderedAccessView *const *unordered_access_views, const UINT *initial_counts)
589 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
590 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
591 "initial_counts %p stub!\n",
592 iface, render_target_view_count, render_target_views, depth_stencil_view,
593 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views,
594 initial_counts);
597 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext *iface,
598 ID3D11BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
600 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
601 const D3D11_BLEND_DESC *desc;
603 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
604 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
606 if (blend_factor[0] != 1.0f || blend_factor[1] != 1.0f || blend_factor[2] != 1.0f || blend_factor[3] != 1.0f)
607 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
608 blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
610 wined3d_mutex_lock();
611 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
612 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
613 if (!(device->blend_state = unsafe_impl_from_ID3D11BlendState(blend_state)))
615 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE);
616 wined3d_device_set_render_state(device->wined3d_device,
617 WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL);
618 wined3d_device_set_render_state(device->wined3d_device,
619 WINED3D_RS_COLORWRITEENABLE1, D3D11_COLOR_WRITE_ENABLE_ALL);
620 wined3d_device_set_render_state(device->wined3d_device,
621 WINED3D_RS_COLORWRITEENABLE2, D3D11_COLOR_WRITE_ENABLE_ALL);
622 wined3d_device_set_render_state(device->wined3d_device,
623 WINED3D_RS_COLORWRITEENABLE3, D3D11_COLOR_WRITE_ENABLE_ALL);
624 wined3d_mutex_unlock();
625 return;
628 desc = &device->blend_state->desc;
629 /* glSampleCoverage() */
630 if (desc->AlphaToCoverageEnable)
631 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc->AlphaToCoverageEnable);
632 /* glEnableIndexedEXT(GL_BLEND, ...) */
633 FIXME("Per-rendertarget blend not implemented.\n");
634 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE,
635 desc->RenderTarget[0].BlendEnable);
636 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLEND, desc->RenderTarget[0].SrcBlend);
637 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLEND, desc->RenderTarget[0].DestBlend);
638 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOP, desc->RenderTarget[0].BlendOp);
639 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SEPARATEALPHABLENDENABLE, TRUE);
640 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA,
641 desc->RenderTarget[0].SrcBlendAlpha);
642 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA,
643 desc->RenderTarget[0].DestBlendAlpha);
644 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA,
645 desc->RenderTarget[0].BlendOpAlpha);
646 FIXME("Color mask > 3 not implemented.\n");
647 wined3d_device_set_render_state(device->wined3d_device,
648 WINED3D_RS_COLORWRITEENABLE, desc->RenderTarget[0].RenderTargetWriteMask);
649 wined3d_device_set_render_state(device->wined3d_device,
650 WINED3D_RS_COLORWRITEENABLE1, desc->RenderTarget[1].RenderTargetWriteMask);
651 wined3d_device_set_render_state(device->wined3d_device,
652 WINED3D_RS_COLORWRITEENABLE2, desc->RenderTarget[2].RenderTargetWriteMask);
653 wined3d_device_set_render_state(device->wined3d_device,
654 WINED3D_RS_COLORWRITEENABLE3, desc->RenderTarget[3].RenderTargetWriteMask);
655 wined3d_mutex_unlock();
658 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext *iface,
659 ID3D11DepthStencilState *depth_stencil_state, UINT stencil_ref)
661 FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n", iface, depth_stencil_state, stencil_ref);
664 static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext *iface, UINT buffer_count,
665 ID3D11Buffer *const *buffers, const UINT *offsets)
667 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
668 unsigned int count, i;
670 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface, buffer_count, buffers, offsets);
672 count = min(buffer_count, D3D11_SO_BUFFER_SLOT_COUNT);
673 wined3d_mutex_lock();
674 for (i = 0; i < count; ++i)
676 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
678 wined3d_device_set_stream_output(device->wined3d_device, i,
679 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
681 for (; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i)
683 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
685 wined3d_mutex_unlock();
688 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawAuto(ID3D11DeviceContext *iface)
690 FIXME("iface %p stub!\n", iface);
693 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndirect(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_DrawInstancedIndirect(ID3D11DeviceContext *iface,
700 ID3D11Buffer *buffer, UINT offset)
702 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
705 static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceContext *iface,
706 UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z)
708 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
709 iface, thread_group_count_x, thread_group_count_y, thread_group_count_z);
712 static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext *iface,
713 ID3D11Buffer *buffer, UINT offset)
715 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
718 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceContext *iface,
719 ID3D11RasterizerState *rasterizer_state)
721 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
722 const D3D11_RASTERIZER_DESC *desc;
724 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
726 wined3d_mutex_lock();
727 if (!(device->rasterizer_state = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state)))
729 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
730 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
731 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
732 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
733 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
734 wined3d_mutex_unlock();
735 return;
738 desc = &device->rasterizer_state->desc;
739 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
740 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
741 /* glFrontFace() */
742 if (desc->FrontCounterClockwise)
743 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
744 /* OpenGL style depth bias. */
745 if (desc->DepthBias || desc->SlopeScaledDepthBias)
746 FIXME("Ignoring depth bias.\n");
747 /* GL_DEPTH_CLAMP */
748 if (!desc->DepthClipEnable)
749 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
750 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
751 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
752 wined3d_device_set_render_state(device->wined3d_device,
753 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
754 wined3d_mutex_unlock();
757 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext *iface,
758 UINT viewport_count, const D3D11_VIEWPORT *viewports)
760 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
761 struct wined3d_viewport wined3d_vp;
763 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
765 if (viewport_count > 1)
766 FIXME("Multiple viewports not implemented.\n");
768 if (!viewport_count)
769 return;
771 if (viewports[0].TopLeftX != (UINT)viewports[0].TopLeftX
772 || viewports[0].TopLeftY != (UINT)viewports[0].TopLeftY
773 || viewports[0].Width != (UINT)viewports[0].Width
774 || viewports[0].Height != (UINT)viewports[0].Height)
775 FIXME("Floating-point viewports not implemented.\n");
777 wined3d_vp.x = viewports[0].TopLeftX;
778 wined3d_vp.y = viewports[0].TopLeftY;
779 wined3d_vp.width = viewports[0].Width;
780 wined3d_vp.height = viewports[0].Height;
781 wined3d_vp.min_z = viewports[0].MinDepth;
782 wined3d_vp.max_z = viewports[0].MaxDepth;
784 wined3d_mutex_lock();
785 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
786 wined3d_mutex_unlock();
789 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext *iface,
790 UINT rect_count, const D3D11_RECT *rects)
792 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
794 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
796 if (rect_count > 1)
797 FIXME("Multiple scissor rects not implemented.\n");
799 if (!rect_count)
800 return;
802 wined3d_mutex_lock();
803 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
804 wined3d_mutex_unlock();
807 static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext *iface,
808 ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
809 ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box)
811 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
812 "src_resource %p, src_subresource_idx %u, src_box %p stub!\n",
813 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
814 src_resource, src_subresource_idx, src_box);
817 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext *iface,
818 ID3D11Resource *dst_resource, ID3D11Resource *src_resource)
820 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
821 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
823 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
825 wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource);
826 wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource);
827 wined3d_mutex_lock();
828 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
829 wined3d_mutex_unlock();
832 static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext *iface,
833 ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box,
834 const void *data, UINT row_pitch, UINT depth_pitch)
836 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
837 struct wined3d_resource *wined3d_resource;
838 struct wined3d_box wined3d_box;
840 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
841 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
843 if (box)
845 wined3d_box.left = box->left;
846 wined3d_box.top = box->top;
847 wined3d_box.front = box->front;
848 wined3d_box.right = box->right;
849 wined3d_box.bottom = box->bottom;
850 wined3d_box.back = box->back;
853 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
854 wined3d_mutex_lock();
855 wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource,
856 subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch);
857 wined3d_mutex_unlock();
860 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext *iface,
861 ID3D11Buffer *dst_buffer, UINT dst_offset, ID3D11UnorderedAccessView *src_view)
863 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
864 iface, dst_buffer, dst_offset, src_view);
867 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext *iface,
868 ID3D11RenderTargetView *render_target_view, const FLOAT color_rgba[4])
870 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
871 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D11RenderTargetView(render_target_view);
872 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
873 HRESULT hr;
875 TRACE("iface %p, render_target_view %p, color_rgba {%.8e %.8e %.8e %.8e}.\n",
876 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
878 wined3d_mutex_lock();
879 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
880 ERR("Failed to clear view, hr %#x.\n", hr);
881 wined3d_mutex_unlock();
884 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext *iface,
885 ID3D11UnorderedAccessView *unordered_access_view, const UINT values[4])
887 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
888 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
891 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext *iface,
892 ID3D11UnorderedAccessView *unordered_access_view, const FLOAT values[4])
894 FIXME("iface %p, unordered_access_view %p, values {%.8e %.8e %.8e %.8e} stub!\n",
895 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
898 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext *iface,
899 ID3D11DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
901 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
902 iface, depth_stencil_view, flags, depth, stencil);
905 static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface,
906 ID3D11ShaderResourceView *view)
908 FIXME("iface %p, view %p stub!\n", iface, view);
911 static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
912 ID3D11Resource *resource, FLOAT min_lod)
914 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface, resource, min_lod);
917 static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext *iface,
918 ID3D11Resource *resource)
920 FIXME("iface %p, resource %p stub!\n", iface, resource);
922 return 0.0f;
925 static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext *iface,
926 ID3D11Resource *dst_resource, UINT dst_subresource_idx,
927 ID3D11Resource *src_resource, UINT src_subresource_idx,
928 DXGI_FORMAT format)
930 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
931 "format %s stub!\n",
932 iface, dst_resource, dst_subresource_idx, src_resource, src_subresource_idx,
933 debug_dxgi_format(format));
936 static void STDMETHODCALLTYPE d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext *iface,
937 ID3D11CommandList *command_list, BOOL restore_state)
939 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface, command_list, restore_state);
942 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext *iface,
943 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
945 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
946 iface, start_slot, view_count, views);
949 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext *iface,
950 ID3D11HullShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
952 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
953 iface, shader, class_instances, class_instance_count);
956 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext *iface,
957 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
959 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
960 iface, start_slot, sampler_count, samplers);
963 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext *iface,
964 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
966 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
967 iface, start_slot, buffer_count, buffers);
970 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext *iface,
971 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
973 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
974 iface, start_slot, view_count, views);
977 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext *iface,
978 ID3D11DomainShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
980 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
981 iface, shader, class_instances, class_instance_count);
984 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext *iface,
985 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
987 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
988 iface, start_slot, sampler_count, samplers);
991 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext *iface,
992 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
994 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
995 iface, start_slot, buffer_count, buffers);
998 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext *iface,
999 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
1001 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1002 iface, start_slot, view_count, views);
1005 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext *iface,
1006 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts)
1008 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1009 iface, start_slot, view_count, views, initial_counts);
1012 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext *iface,
1013 ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
1015 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1016 iface, shader, class_instances, class_instance_count);
1019 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext *iface,
1020 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
1022 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1023 iface, start_slot, sampler_count, samplers);
1026 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext *iface,
1027 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
1029 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1030 iface, start_slot, buffer_count, buffers);
1033 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext *iface,
1034 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1036 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1037 unsigned int i;
1039 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1040 iface, start_slot, buffer_count, buffers);
1042 wined3d_mutex_lock();
1043 for (i = 0; i < buffer_count; ++i)
1045 struct wined3d_buffer *wined3d_buffer;
1046 struct d3d_buffer *buffer_impl;
1048 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
1050 buffers[i] = NULL;
1051 continue;
1054 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1055 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1056 ID3D11Buffer_AddRef(buffers[i]);
1058 wined3d_mutex_unlock();
1061 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext *iface,
1062 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1064 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1065 unsigned int i;
1067 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1068 iface, start_slot, view_count, views);
1070 wined3d_mutex_lock();
1071 for (i = 0; i < view_count; ++i)
1073 struct wined3d_shader_resource_view *wined3d_view;
1074 struct d3d_shader_resource_view *view_impl;
1076 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
1078 views[i] = NULL;
1079 continue;
1082 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1083 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1084 ID3D11ShaderResourceView_AddRef(views[i]);
1086 wined3d_mutex_unlock();
1089 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceContext *iface,
1090 ID3D11PixelShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1092 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1093 struct wined3d_shader *wined3d_shader;
1094 struct d3d_pixel_shader *shader_impl;
1096 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1097 iface, shader, class_instances, class_instance_count);
1099 if (class_instances || class_instance_count)
1100 FIXME("Dynamic linking not implemented yet.\n");
1102 wined3d_mutex_lock();
1103 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
1105 wined3d_mutex_unlock();
1106 *shader = NULL;
1107 return;
1110 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1111 wined3d_mutex_unlock();
1112 *shader = &shader_impl->ID3D11PixelShader_iface;
1113 ID3D11PixelShader_AddRef(*shader);
1116 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext *iface,
1117 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1119 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1120 unsigned int i;
1122 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1123 iface, start_slot, sampler_count, samplers);
1125 wined3d_mutex_lock();
1126 for (i = 0; i < sampler_count; ++i)
1128 struct wined3d_sampler *wined3d_sampler;
1129 struct d3d_sampler_state *sampler_impl;
1131 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
1133 samplers[i] = NULL;
1134 continue;
1137 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1138 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1139 ID3D11SamplerState_AddRef(samplers[i]);
1141 wined3d_mutex_unlock();
1144 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceContext *iface,
1145 ID3D11VertexShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1147 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1148 struct d3d_vertex_shader *shader_impl;
1149 struct wined3d_shader *wined3d_shader;
1151 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1152 iface, shader, class_instances, class_instance_count);
1154 if (class_instances || class_instance_count)
1155 FIXME("Dynamic linking not implemented yet.\n");
1157 wined3d_mutex_lock();
1158 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
1160 wined3d_mutex_unlock();
1161 *shader = NULL;
1162 return;
1165 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1166 wined3d_mutex_unlock();
1167 *shader = &shader_impl->ID3D11VertexShader_iface;
1168 ID3D11VertexShader_AddRef(*shader);
1171 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext *iface,
1172 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1174 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1175 unsigned int i;
1177 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1178 iface, start_slot, buffer_count, buffers);
1180 wined3d_mutex_lock();
1181 for (i = 0; i < buffer_count; ++i)
1183 struct wined3d_buffer *wined3d_buffer;
1184 struct d3d_buffer *buffer_impl;
1186 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
1188 buffers[i] = NULL;
1189 continue;
1192 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1193 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1194 ID3D11Buffer_AddRef(buffers[i]);
1196 wined3d_mutex_unlock();
1199 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext *iface,
1200 ID3D11InputLayout **input_layout)
1202 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1203 struct wined3d_vertex_declaration *wined3d_declaration;
1204 struct d3d_input_layout *input_layout_impl;
1206 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
1208 wined3d_mutex_lock();
1209 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
1211 wined3d_mutex_unlock();
1212 *input_layout = NULL;
1213 return;
1216 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
1217 wined3d_mutex_unlock();
1218 *input_layout = &input_layout_impl->ID3D11InputLayout_iface;
1219 ID3D11InputLayout_AddRef(*input_layout);
1222 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext *iface,
1223 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *strides, UINT *offsets)
1225 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1226 iface, start_slot, buffer_count, buffers, strides, offsets);
1229 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext *iface,
1230 ID3D11Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
1232 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
1235 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext *iface,
1236 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1238 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1239 unsigned int i;
1241 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1242 iface, start_slot, buffer_count, buffers);
1244 wined3d_mutex_lock();
1245 for (i = 0; i < buffer_count; ++i)
1247 struct wined3d_buffer *wined3d_buffer;
1248 struct d3d_buffer *buffer_impl;
1250 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
1252 buffers[i] = NULL;
1253 continue;
1256 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1257 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1258 ID3D11Buffer_AddRef(buffers[i]);
1260 wined3d_mutex_unlock();
1263 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceContext *iface,
1264 ID3D11GeometryShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1266 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1267 struct d3d_geometry_shader *shader_impl;
1268 struct wined3d_shader *wined3d_shader;
1270 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1271 iface, shader, class_instances, class_instance_count);
1273 if (class_instances || class_instance_count)
1274 FIXME("Dynamic linking not implemented yet.\n");
1276 wined3d_mutex_lock();
1277 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
1279 wined3d_mutex_unlock();
1280 *shader = NULL;
1281 return;
1284 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1285 wined3d_mutex_unlock();
1286 *shader = &shader_impl->ID3D11GeometryShader_iface;
1287 ID3D11GeometryShader_AddRef(*shader);
1290 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext *iface,
1291 D3D11_PRIMITIVE_TOPOLOGY *topology)
1293 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1295 TRACE("iface %p, topology %p.\n", iface, topology);
1297 wined3d_mutex_lock();
1298 wined3d_device_get_primitive_type(device->wined3d_device, (enum wined3d_primitive_type *)topology);
1299 wined3d_mutex_unlock();
1302 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext *iface,
1303 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1305 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1306 unsigned int i;
1308 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
1310 wined3d_mutex_lock();
1311 for (i = 0; i < view_count; ++i)
1313 struct wined3d_shader_resource_view *wined3d_view;
1314 struct d3d_shader_resource_view *view_impl;
1316 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
1318 views[i] = NULL;
1319 continue;
1322 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1323 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1324 ID3D11ShaderResourceView_AddRef(views[i]);
1326 wined3d_mutex_unlock();
1329 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext *iface,
1330 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1332 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1333 unsigned int i;
1335 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1336 iface, start_slot, sampler_count, samplers);
1338 wined3d_mutex_lock();
1339 for (i = 0; i < sampler_count; ++i)
1341 struct wined3d_sampler *wined3d_sampler;
1342 struct d3d_sampler_state *sampler_impl;
1344 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
1346 samplers[i] = NULL;
1347 continue;
1350 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1351 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1352 ID3D11SamplerState_AddRef(samplers[i]);
1354 wined3d_mutex_unlock();
1357 static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11DeviceContext *iface,
1358 ID3D11Predicate **predicate, BOOL *value)
1360 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1361 struct wined3d_query *wined3d_predicate;
1362 struct d3d_query *predicate_impl;
1364 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
1366 wined3d_mutex_lock();
1367 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
1369 wined3d_mutex_unlock();
1370 *predicate = NULL;
1371 return;
1374 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
1375 wined3d_mutex_unlock();
1376 *predicate = (ID3D11Predicate *)&predicate_impl->ID3D11Query_iface;
1377 ID3D11Predicate_AddRef(*predicate);
1380 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext *iface,
1381 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1383 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1384 unsigned int i;
1386 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
1388 wined3d_mutex_lock();
1389 for (i = 0; i < view_count; ++i)
1391 struct wined3d_shader_resource_view *wined3d_view;
1392 struct d3d_shader_resource_view *view_impl;
1394 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
1396 views[i] = NULL;
1397 continue;
1400 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1401 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1402 ID3D11ShaderResourceView_AddRef(views[i]);
1404 wined3d_mutex_unlock();
1407 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext *iface,
1408 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1410 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1411 unsigned int i;
1413 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1414 iface, start_slot, sampler_count, samplers);
1416 wined3d_mutex_lock();
1417 for (i = 0; i < sampler_count; ++i)
1419 struct d3d_sampler_state *sampler_impl;
1420 struct wined3d_sampler *wined3d_sampler;
1422 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
1424 samplers[i] = NULL;
1425 continue;
1428 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1429 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1430 ID3D11SamplerState_AddRef(samplers[i]);
1432 wined3d_mutex_unlock();
1435 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext *iface,
1436 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1437 ID3D11DepthStencilView **depth_stencil_view)
1439 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
1440 iface, render_target_view_count, render_target_views, depth_stencil_view);
1443 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1444 ID3D11DeviceContext *iface,
1445 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1446 ID3D11DepthStencilView **depth_stencil_view,
1447 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
1448 ID3D11UnorderedAccessView **unordered_access_views)
1450 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1451 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1452 "unordered_access_views %p stub!\n",
1453 iface, render_target_view_count, render_target_views, depth_stencil_view,
1454 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views);
1457 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext *iface,
1458 ID3D11BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1460 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1461 iface, blend_state, blend_factor, sample_mask);
1464 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext *iface,
1465 ID3D11DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1467 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface, depth_stencil_state, stencil_ref);
1470 static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext *iface,
1471 UINT buffer_count, ID3D11Buffer **buffers)
1473 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1474 unsigned int i;
1476 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface, buffer_count, buffers);
1478 wined3d_mutex_lock();
1479 for (i = 0; i < buffer_count; ++i)
1481 struct wined3d_buffer *wined3d_buffer;
1482 struct d3d_buffer *buffer_impl;
1484 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, NULL)))
1486 buffers[i] = NULL;
1487 continue;
1490 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1491 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1492 ID3D11Buffer_AddRef(buffers[i]);
1494 wined3d_mutex_unlock();
1497 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceContext *iface,
1498 ID3D11RasterizerState **rasterizer_state)
1500 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1502 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1504 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D11RasterizerState_iface : NULL))
1505 ID3D11RasterizerState_AddRef(*rasterizer_state);
1508 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext *iface,
1509 UINT *viewport_count, D3D11_VIEWPORT *viewports)
1511 FIXME("iface %p, viewport_count %p, viewports %p stub!\n", iface, viewport_count, viewports);
1514 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext *iface,
1515 UINT *rect_count, D3D11_RECT *rects)
1517 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
1520 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext *iface,
1521 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1523 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1526 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceContext *iface,
1527 ID3D11HullShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1529 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1530 iface, shader, class_instances, class_instance_count);
1533 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext *iface,
1534 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1536 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1537 iface, start_slot, sampler_count, samplers);
1540 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext *iface,
1541 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1543 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1544 iface, start_slot, buffer_count, buffers);
1547 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext *iface,
1548 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1550 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1551 iface, start_slot, view_count, views);
1554 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceContext *iface,
1555 ID3D11DomainShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1557 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1558 iface, shader, class_instances, class_instance_count);
1561 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext *iface,
1562 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1564 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1565 iface, start_slot, sampler_count, samplers);
1568 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext *iface,
1569 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1571 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1572 iface, start_slot, buffer_count, buffers);
1575 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext *iface,
1576 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1578 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1581 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext *iface,
1582 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView **views)
1584 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1587 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceContext *iface,
1588 ID3D11ComputeShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1590 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1591 iface, shader, class_instances, class_instance_count);
1594 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext *iface,
1595 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1597 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1598 iface, start_slot, sampler_count, samplers);
1601 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext *iface,
1602 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1604 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1605 iface, start_slot, buffer_count, buffers);
1608 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext *iface)
1610 FIXME("iface %p stub!\n", iface);
1613 static void STDMETHODCALLTYPE d3d11_immediate_context_Flush(ID3D11DeviceContext *iface)
1615 FIXME("iface %p stub!\n", iface);
1618 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_immediate_context_GetType(ID3D11DeviceContext *iface)
1620 TRACE("iface %p.\n", iface);
1622 return D3D11_DEVICE_CONTEXT_IMMEDIATE;
1625 static UINT STDMETHODCALLTYPE d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext *iface)
1627 FIXME("iface %p stub!\n", iface);
1629 return 0;
1632 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext *iface,
1633 BOOL restore, ID3D11CommandList **command_list)
1635 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface, restore, command_list);
1637 return E_NOTIMPL;
1640 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl =
1642 /* IUnknown methods */
1643 d3d11_immediate_context_QueryInterface,
1644 d3d11_immediate_context_AddRef,
1645 d3d11_immediate_context_Release,
1646 /* ID3D11DeviceChild methods */
1647 d3d11_immediate_context_GetDevice,
1648 d3d11_immediate_context_GetPrivateData,
1649 d3d11_immediate_context_SetPrivateData,
1650 d3d11_immediate_context_SetPrivateDataInterface,
1651 /* ID3D11DeviceContext methods */
1652 d3d11_immediate_context_VSSetConstantBuffers,
1653 d3d11_immediate_context_PSSetShaderResources,
1654 d3d11_immediate_context_PSSetShader,
1655 d3d11_immediate_context_PSSetSamplers,
1656 d3d11_immediate_context_VSSetShader,
1657 d3d11_immediate_context_DrawIndexed,
1658 d3d11_immediate_context_Draw,
1659 d3d11_immediate_context_Map,
1660 d3d11_immediate_context_Unmap,
1661 d3d11_immediate_context_PSSetConstantBuffers,
1662 d3d11_immediate_context_IASetInputLayout,
1663 d3d11_immediate_context_IASetVertexBuffers,
1664 d3d11_immediate_context_IASetIndexBuffer,
1665 d3d11_immediate_context_DrawIndexedInstanced,
1666 d3d11_immediate_context_DrawInstanced,
1667 d3d11_immediate_context_GSSetConstantBuffers,
1668 d3d11_immediate_context_GSSetShader,
1669 d3d11_immediate_context_IASetPrimitiveTopology,
1670 d3d11_immediate_context_VSSetShaderResources,
1671 d3d11_immediate_context_VSSetSamplers,
1672 d3d11_immediate_context_Begin,
1673 d3d11_immediate_context_End,
1674 d3d11_immediate_context_GetData,
1675 d3d11_immediate_context_SetPredication,
1676 d3d11_immediate_context_GSSetShaderResources,
1677 d3d11_immediate_context_GSSetSamplers,
1678 d3d11_immediate_context_OMSetRenderTargets,
1679 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews,
1680 d3d11_immediate_context_OMSetBlendState,
1681 d3d11_immediate_context_OMSetDepthStencilState,
1682 d3d11_immediate_context_SOSetTargets,
1683 d3d11_immediate_context_DrawAuto,
1684 d3d11_immediate_context_DrawIndexedInstancedIndirect,
1685 d3d11_immediate_context_DrawInstancedIndirect,
1686 d3d11_immediate_context_Dispatch,
1687 d3d11_immediate_context_DispatchIndirect,
1688 d3d11_immediate_context_RSSetState,
1689 d3d11_immediate_context_RSSetViewports,
1690 d3d11_immediate_context_RSSetScissorRects,
1691 d3d11_immediate_context_CopySubresourceRegion,
1692 d3d11_immediate_context_CopyResource,
1693 d3d11_immediate_context_UpdateSubresource,
1694 d3d11_immediate_context_CopyStructureCount,
1695 d3d11_immediate_context_ClearRenderTargetView,
1696 d3d11_immediate_context_ClearUnorderedAccessViewUint,
1697 d3d11_immediate_context_ClearUnorderedAccessViewFloat,
1698 d3d11_immediate_context_ClearDepthStencilView,
1699 d3d11_immediate_context_GenerateMips,
1700 d3d11_immediate_context_SetResourceMinLOD,
1701 d3d11_immediate_context_GetResourceMinLOD,
1702 d3d11_immediate_context_ResolveSubresource,
1703 d3d11_immediate_context_ExecuteCommandList,
1704 d3d11_immediate_context_HSSetShaderResources,
1705 d3d11_immediate_context_HSSetShader,
1706 d3d11_immediate_context_HSSetSamplers,
1707 d3d11_immediate_context_HSSetConstantBuffers,
1708 d3d11_immediate_context_DSSetShaderResources,
1709 d3d11_immediate_context_DSSetShader,
1710 d3d11_immediate_context_DSSetSamplers,
1711 d3d11_immediate_context_DSSetConstantBuffers,
1712 d3d11_immediate_context_CSSetShaderResources,
1713 d3d11_immediate_context_CSSetUnorderedAccessViews,
1714 d3d11_immediate_context_CSSetShader,
1715 d3d11_immediate_context_CSSetSamplers,
1716 d3d11_immediate_context_CSSetConstantBuffers,
1717 d3d11_immediate_context_VSGetConstantBuffers,
1718 d3d11_immediate_context_PSGetShaderResources,
1719 d3d11_immediate_context_PSGetShader,
1720 d3d11_immediate_context_PSGetSamplers,
1721 d3d11_immediate_context_VSGetShader,
1722 d3d11_immediate_context_PSGetConstantBuffers,
1723 d3d11_immediate_context_IAGetInputLayout,
1724 d3d11_immediate_context_IAGetVertexBuffers,
1725 d3d11_immediate_context_IAGetIndexBuffer,
1726 d3d11_immediate_context_GSGetConstantBuffers,
1727 d3d11_immediate_context_GSGetShader,
1728 d3d11_immediate_context_IAGetPrimitiveTopology,
1729 d3d11_immediate_context_VSGetShaderResources,
1730 d3d11_immediate_context_VSGetSamplers,
1731 d3d11_immediate_context_GetPredication,
1732 d3d11_immediate_context_GSGetShaderResources,
1733 d3d11_immediate_context_GSGetSamplers,
1734 d3d11_immediate_context_OMGetRenderTargets,
1735 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews,
1736 d3d11_immediate_context_OMGetBlendState,
1737 d3d11_immediate_context_OMGetDepthStencilState,
1738 d3d11_immediate_context_SOGetTargets,
1739 d3d11_immediate_context_RSGetState,
1740 d3d11_immediate_context_RSGetViewports,
1741 d3d11_immediate_context_RSGetScissorRects,
1742 d3d11_immediate_context_HSGetShaderResources,
1743 d3d11_immediate_context_HSGetShader,
1744 d3d11_immediate_context_HSGetSamplers,
1745 d3d11_immediate_context_HSGetConstantBuffers,
1746 d3d11_immediate_context_DSGetShaderResources,
1747 d3d11_immediate_context_DSGetShader,
1748 d3d11_immediate_context_DSGetSamplers,
1749 d3d11_immediate_context_DSGetConstantBuffers,
1750 d3d11_immediate_context_CSGetShaderResources,
1751 d3d11_immediate_context_CSGetUnorderedAccessViews,
1752 d3d11_immediate_context_CSGetShader,
1753 d3d11_immediate_context_CSGetSamplers,
1754 d3d11_immediate_context_CSGetConstantBuffers,
1755 d3d11_immediate_context_ClearState,
1756 d3d11_immediate_context_Flush,
1757 d3d11_immediate_context_GetType,
1758 d3d11_immediate_context_GetContextFlags,
1759 d3d11_immediate_context_FinishCommandList,
1762 static HRESULT d3d11_immediate_context_init(struct d3d11_immediate_context *context, struct d3d_device *device)
1764 context->ID3D11DeviceContext_iface.lpVtbl = &d3d11_immediate_context_vtbl;
1765 context->refcount = 1;
1767 ID3D11Device_AddRef(&device->ID3D11Device_iface);
1769 return S_OK;
1772 /* ID3D11Device methods */
1774 static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out)
1776 struct d3d_device *device = impl_from_ID3D11Device(iface);
1777 return IUnknown_QueryInterface(device->outer_unk, riid, out);
1780 static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device *iface)
1782 struct d3d_device *device = impl_from_ID3D11Device(iface);
1783 return IUnknown_AddRef(device->outer_unk);
1786 static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface)
1788 struct d3d_device *device = impl_from_ID3D11Device(iface);
1789 return IUnknown_Release(device->outer_unk);
1792 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc,
1793 const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer)
1795 struct d3d_device *device = impl_from_ID3D11Device(iface);
1796 struct d3d_buffer *object;
1797 HRESULT hr;
1799 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
1801 if (FAILED(hr = d3d_buffer_create(device, desc, data, &object)))
1802 return hr;
1804 *buffer = &object->ID3D11Buffer_iface;
1806 return S_OK;
1809 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
1810 const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture)
1812 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1814 return E_NOTIMPL;
1817 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
1818 const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture)
1820 struct d3d_device *device = impl_from_ID3D11Device(iface);
1821 struct d3d_texture2d *object;
1822 HRESULT hr;
1824 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1826 if (FAILED(hr = d3d_texture2d_create(device, desc, data, &object)))
1827 return hr;
1829 *texture = &object->ID3D11Texture2D_iface;
1831 return S_OK;
1834 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
1835 const D3D11_TEXTURE3D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture3D **texture)
1837 struct d3d_device *device = impl_from_ID3D11Device(iface);
1838 struct d3d_texture3d *object;
1839 HRESULT hr;
1841 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1843 if (FAILED(hr = d3d_texture3d_create(device, desc, data, &object)))
1844 return hr;
1846 *texture = &object->ID3D11Texture3D_iface;
1848 return S_OK;
1851 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device *iface,
1852 ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11ShaderResourceView **view)
1854 struct d3d_device *device = impl_from_ID3D11Device(iface);
1855 struct d3d_shader_resource_view *object;
1856 HRESULT hr;
1858 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1860 if (FAILED(hr = d3d_shader_resource_view_create(device, resource, desc, &object)))
1861 return hr;
1863 *view = &object->ID3D11ShaderResourceView_iface;
1865 return S_OK;
1868 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device *iface,
1869 ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11UnorderedAccessView **view)
1871 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1873 return E_NOTIMPL;
1876 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface,
1877 ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view)
1879 struct d3d_device *device = impl_from_ID3D11Device(iface);
1880 struct d3d_rendertarget_view *object;
1881 HRESULT hr;
1883 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1885 if (FAILED(hr = d3d_rendertarget_view_create(device, resource, desc, &object)))
1886 return hr;
1888 *view = &object->ID3D11RenderTargetView_iface;
1890 return S_OK;
1893 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface,
1894 ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11DepthStencilView **view)
1896 struct d3d_device *device = impl_from_ID3D11Device(iface);
1897 struct d3d_depthstencil_view *object;
1898 HRESULT hr;
1900 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1902 if (FAILED(hr = d3d_depthstencil_view_create(device, resource, desc, &object)))
1903 return hr;
1905 *view = &object->ID3D11DepthStencilView_iface;
1907 return S_OK;
1910 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *iface,
1911 const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code,
1912 SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout)
1914 struct d3d_device *device = impl_from_ID3D11Device(iface);
1915 struct d3d_input_layout *object;
1916 HRESULT hr;
1918 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
1919 "input_layout %p.\n", iface, element_descs, element_count, shader_byte_code,
1920 shader_byte_code_length, input_layout);
1922 if (FAILED(hr = d3d_input_layout_create(device, element_descs, element_count,
1923 shader_byte_code, shader_byte_code_length, &object)))
1924 return hr;
1926 *input_layout = &object->ID3D11InputLayout_iface;
1928 return S_OK;
1931 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code,
1932 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11VertexShader **shader)
1934 struct d3d_device *device = impl_from_ID3D11Device(iface);
1935 struct d3d_vertex_shader *object;
1936 HRESULT hr;
1938 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1939 iface, byte_code, byte_code_length, class_linkage, shader);
1941 if (class_linkage)
1942 FIXME("Class linkage is not implemented yet.\n");
1944 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
1945 return hr;
1947 *shader = &object->ID3D11VertexShader_iface;
1949 return S_OK;
1952 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device *iface, const void *byte_code,
1953 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
1955 struct d3d_device *device = impl_from_ID3D11Device(iface);
1956 struct d3d_geometry_shader *object;
1957 HRESULT hr;
1959 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1960 iface, byte_code, byte_code_length, class_linkage, shader);
1962 if (class_linkage)
1963 FIXME("Class linkage is not implemented yet.\n");
1965 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
1966 return hr;
1968 *shader = &object->ID3D11GeometryShader_iface;
1970 return S_OK;
1973 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device *iface,
1974 const void *byte_code, SIZE_T byte_code_length, const D3D11_SO_DECLARATION_ENTRY *so_entries,
1975 UINT entry_count, const UINT *buffer_strides, UINT strides_count, UINT rasterized_stream,
1976 ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
1978 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
1979 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
1980 iface, byte_code, byte_code_length, so_entries, entry_count, buffer_strides, strides_count,
1981 rasterized_stream, class_linkage, shader);
1983 return E_NOTIMPL;
1986 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *iface, const void *byte_code,
1987 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11PixelShader **shader)
1989 struct d3d_device *device = impl_from_ID3D11Device(iface);
1990 struct d3d_pixel_shader *object;
1991 HRESULT hr;
1993 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1994 iface, byte_code, byte_code_length, class_linkage, shader);
1996 if (class_linkage)
1997 FIXME("Class linkage is not implemented yet.\n");
1999 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
2000 return hr;
2002 *shader = &object->ID3D11PixelShader_iface;
2004 return S_OK;
2007 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *iface, const void *byte_code,
2008 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11HullShader **shader)
2010 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2011 iface, byte_code, byte_code_length, class_linkage, shader);
2013 return E_NOTIMPL;
2016 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code,
2017 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader)
2019 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2020 iface, byte_code, byte_code_length, class_linkage, shader);
2022 return E_NOTIMPL;
2025 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code,
2026 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11ComputeShader **shader)
2028 FIXME("iface %p, byte_code %p, byte_code_lenghth %lu, class_linkage %p, shader %p stub!\n",
2029 iface, byte_code, byte_code_length, class_linkage, shader);
2031 return E_NOTIMPL;
2034 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *iface,
2035 ID3D11ClassLinkage **class_linkage)
2037 FIXME("iface %p, class_linkage %p stub!\n", iface, class_linkage);
2039 return E_NOTIMPL;
2042 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *iface,
2043 const D3D11_BLEND_DESC *desc, ID3D11BlendState **blend_state)
2045 struct d3d_device *device = impl_from_ID3D11Device(iface);
2046 struct d3d_blend_state *object;
2047 struct wine_rb_entry *entry;
2048 D3D11_BLEND_DESC tmp_desc;
2049 unsigned int i, j;
2050 HRESULT hr;
2052 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
2054 if (!desc)
2055 return E_INVALIDARG;
2057 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2058 * D3D11_BLEND_DESC as a key in the rbtree. */
2059 memset(&tmp_desc, 0, sizeof(tmp_desc));
2060 tmp_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
2061 tmp_desc.IndependentBlendEnable = desc->IndependentBlendEnable;
2062 for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
2064 j = desc->IndependentBlendEnable ? i : 0;
2065 tmp_desc.RenderTarget[i].BlendEnable = desc->RenderTarget[j].BlendEnable;
2066 tmp_desc.RenderTarget[i].SrcBlend = desc->RenderTarget[j].SrcBlend;
2067 tmp_desc.RenderTarget[i].DestBlend = desc->RenderTarget[j].DestBlend;
2068 tmp_desc.RenderTarget[i].BlendOp = desc->RenderTarget[j].BlendOp;
2069 tmp_desc.RenderTarget[i].SrcBlendAlpha = desc->RenderTarget[j].SrcBlendAlpha;
2070 tmp_desc.RenderTarget[i].DestBlendAlpha = desc->RenderTarget[j].DestBlendAlpha;
2071 tmp_desc.RenderTarget[i].BlendOpAlpha = desc->RenderTarget[j].BlendOpAlpha;
2072 tmp_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTarget[j].RenderTargetWriteMask;
2075 wined3d_mutex_lock();
2076 if ((entry = wine_rb_get(&device->blend_states, &tmp_desc)))
2078 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_blend_state, entry);
2080 TRACE("Returning existing blend state %p.\n", object);
2081 *blend_state = &object->ID3D11BlendState_iface;
2082 ID3D11BlendState_AddRef(*blend_state);
2083 wined3d_mutex_unlock();
2085 return S_OK;
2087 wined3d_mutex_unlock();
2089 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2090 return E_OUTOFMEMORY;
2092 if (FAILED(hr = d3d_blend_state_init(object, device, &tmp_desc)))
2094 WARN("Failed to initialize blend state, hr %#x.\n", hr);
2095 HeapFree(GetProcessHeap(), 0, object);
2096 return hr;
2099 TRACE("Created blend state %p.\n", object);
2100 *blend_state = &object->ID3D11BlendState_iface;
2102 return S_OK;
2105 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface,
2106 const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state)
2108 struct d3d_device *device = impl_from_ID3D11Device(iface);
2109 struct d3d_depthstencil_state *object;
2110 D3D11_DEPTH_STENCIL_DESC tmp_desc;
2111 struct wine_rb_entry *entry;
2112 HRESULT hr;
2114 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
2116 if (!desc)
2117 return E_INVALIDARG;
2119 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2120 * it as a key in the rbtree. */
2121 memset(&tmp_desc, 0, sizeof(tmp_desc));
2122 tmp_desc.DepthEnable = desc->DepthEnable;
2123 tmp_desc.DepthWriteMask = desc->DepthWriteMask;
2124 tmp_desc.DepthFunc = desc->DepthFunc;
2125 tmp_desc.StencilEnable = desc->StencilEnable;
2126 tmp_desc.StencilReadMask = desc->StencilReadMask;
2127 tmp_desc.StencilWriteMask = desc->StencilWriteMask;
2128 tmp_desc.FrontFace = desc->FrontFace;
2129 tmp_desc.BackFace = desc->BackFace;
2131 wined3d_mutex_lock();
2132 if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
2134 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_depthstencil_state, entry);
2136 TRACE("Returning existing depthstencil state %p.\n", object);
2137 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
2138 ID3D11DepthStencilState_AddRef(*depth_stencil_state);
2139 wined3d_mutex_unlock();
2141 return S_OK;
2143 wined3d_mutex_unlock();
2145 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2146 return E_OUTOFMEMORY;
2148 if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc)))
2150 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
2151 HeapFree(GetProcessHeap(), 0, object);
2152 return hr;
2155 TRACE("Created depthstencil state %p.\n", object);
2156 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
2158 return S_OK;
2161 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface,
2162 const D3D11_RASTERIZER_DESC *desc, ID3D11RasterizerState **rasterizer_state)
2164 struct d3d_device *device = impl_from_ID3D11Device(iface);
2165 struct d3d_rasterizer_state *object;
2166 struct wine_rb_entry *entry;
2167 HRESULT hr;
2169 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
2171 if (!desc)
2172 return E_INVALIDARG;
2174 wined3d_mutex_lock();
2175 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
2177 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_rasterizer_state, entry);
2179 TRACE("Returning existing rasterizer state %p.\n", object);
2180 *rasterizer_state = &object->ID3D11RasterizerState_iface;
2181 ID3D11RasterizerState_AddRef(*rasterizer_state);
2182 wined3d_mutex_unlock();
2184 return S_OK;
2186 wined3d_mutex_unlock();
2188 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2189 return E_OUTOFMEMORY;
2191 if (FAILED(hr = d3d_rasterizer_state_init(object, device, desc)))
2193 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
2194 HeapFree(GetProcessHeap(), 0, object);
2195 return hr;
2198 TRACE("Created rasterizer state %p.\n", object);
2199 *rasterizer_state = &object->ID3D11RasterizerState_iface;
2201 return S_OK;
2204 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface,
2205 const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state)
2207 struct d3d_device *device = impl_from_ID3D11Device(iface);
2208 D3D11_SAMPLER_DESC normalized_desc;
2209 struct d3d_sampler_state *object;
2210 struct wine_rb_entry *entry;
2211 HRESULT hr;
2213 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
2215 if (!desc)
2216 return E_INVALIDARG;
2218 normalized_desc = *desc;
2219 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc.Filter))
2220 normalized_desc.MaxAnisotropy = 0;
2221 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc.Filter))
2222 normalized_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
2223 if (normalized_desc.AddressU != D3D11_TEXTURE_ADDRESS_BORDER
2224 && normalized_desc.AddressV != D3D11_TEXTURE_ADDRESS_BORDER
2225 && normalized_desc.AddressW != D3D11_TEXTURE_ADDRESS_BORDER)
2226 memset(&normalized_desc.BorderColor, 0, sizeof(normalized_desc.BorderColor));
2228 wined3d_mutex_lock();
2229 if ((entry = wine_rb_get(&device->sampler_states, &normalized_desc)))
2231 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_sampler_state, entry);
2233 TRACE("Returning existing sampler state %p.\n", object);
2234 *sampler_state = &object->ID3D11SamplerState_iface;
2235 ID3D11SamplerState_AddRef(*sampler_state);
2236 wined3d_mutex_unlock();
2238 return S_OK;
2240 wined3d_mutex_unlock();
2242 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2243 return E_OUTOFMEMORY;
2245 if (FAILED(hr = d3d_sampler_state_init(object, device, &normalized_desc)))
2247 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
2248 HeapFree(GetProcessHeap(), 0, object);
2249 return hr;
2252 TRACE("Created sampler state %p.\n", object);
2253 *sampler_state = &object->ID3D11SamplerState_iface;
2255 return S_OK;
2258 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
2259 const D3D11_QUERY_DESC *desc, ID3D11Query **query)
2261 struct d3d_device *device = impl_from_ID3D11Device(iface);
2262 struct d3d_query *object;
2263 HRESULT hr;
2265 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
2267 if (FAILED(hr = d3d_query_create(device, desc, FALSE, &object)))
2268 return hr;
2270 *query = &object->ID3D11Query_iface;
2272 return S_OK;
2275 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc,
2276 ID3D11Predicate **predicate)
2278 struct d3d_device *device = impl_from_ID3D11Device(iface);
2279 struct d3d_query *object;
2280 HRESULT hr;
2282 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
2284 if (FAILED(hr = d3d_query_create(device, desc, TRUE, &object)))
2285 return hr;
2287 *predicate = (ID3D11Predicate *)&object->ID3D11Query_iface;
2289 return S_OK;
2292 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2293 ID3D11Counter **counter)
2295 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
2297 return E_NOTIMPL;
2300 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device *iface, UINT flags,
2301 ID3D11DeviceContext **context)
2303 FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context);
2305 return E_NOTIMPL;
2308 static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device *iface, HANDLE resource, REFIID riid,
2309 void **out)
2311 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface, resource, debugstr_guid(riid), out);
2313 return E_NOTIMPL;
2316 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *iface, DXGI_FORMAT format,
2317 UINT *format_support)
2319 FIXME("iface %p, format %u, format_support %p stub!\n", iface, format, format_support);
2321 return E_NOTIMPL;
2324 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device *iface,
2325 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
2327 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
2328 iface, format, sample_count, quality_level_count);
2330 return E_NOTIMPL;
2333 static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device *iface, D3D11_COUNTER_INFO *info)
2335 FIXME("iface %p, info %p stub!\n", iface, info);
2338 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2339 D3D11_COUNTER_TYPE *type, UINT *active_counter_count, char *name, UINT *name_length,
2340 char *units, UINT *units_length, char *description, UINT *description_length)
2342 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2343 "units %p, units_length %p, description %p, description_length %p stub!\n",
2344 iface, desc, type, active_counter_count, name, name_length,
2345 units, units_length, description, description_length);
2347 return E_NOTIMPL;
2350 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device *iface, D3D11_FEATURE feature,
2351 void *feature_support_data, UINT feature_support_data_size)
2353 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2354 iface, feature, feature_support_data, feature_support_data_size);
2356 return E_NOTIMPL;
2359 static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface, REFGUID guid,
2360 UINT *data_size, void *data)
2362 IDXGIDevice *dxgi_device;
2363 HRESULT hr;
2365 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2367 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2368 return hr;
2369 hr = IDXGIDevice_GetPrivateData(dxgi_device, guid, data_size, data);
2370 IDXGIDevice_Release(dxgi_device);
2372 return hr;
2375 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface, REFGUID guid,
2376 UINT data_size, const void *data)
2378 IDXGIDevice *dxgi_device;
2379 HRESULT hr;
2381 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2383 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2384 return hr;
2385 hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data);
2386 IDXGIDevice_Release(dxgi_device);
2388 return hr;
2391 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device *iface, REFGUID guid,
2392 const IUnknown *data)
2394 IDXGIDevice *dxgi_device;
2395 HRESULT hr;
2397 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
2399 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2400 return hr;
2401 hr = IDXGIDevice_SetPrivateDataInterface(dxgi_device, guid, data);
2402 IDXGIDevice_Release(dxgi_device);
2404 return hr;
2407 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device *iface)
2409 FIXME("iface %p stub!\n", iface);
2411 return D3D_FEATURE_LEVEL_10_0;
2414 static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device *iface)
2416 FIXME("iface %p stub!\n", iface);
2418 return 0;
2421 static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device *iface)
2423 FIXME("iface %p stub!\n", iface);
2425 return S_OK;
2428 static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device *iface,
2429 ID3D11DeviceContext **immediate_context)
2431 struct d3d_device *device = impl_from_ID3D11Device(iface);
2433 TRACE("iface %p, immediate_context %p.\n", iface, immediate_context);
2435 *immediate_context = &device->immediate_context.ID3D11DeviceContext_iface;
2436 ID3D11DeviceContext_AddRef(*immediate_context);
2439 static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device *iface, UINT flags)
2441 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2443 return E_NOTIMPL;
2446 static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device *iface)
2448 FIXME("iface %p stub!\n", iface);
2450 return 0;
2453 static const struct ID3D11DeviceVtbl d3d11_device_vtbl =
2455 /* IUnknown methods */
2456 d3d11_device_QueryInterface,
2457 d3d11_device_AddRef,
2458 d3d11_device_Release,
2459 /* ID3D11Device methods */
2460 d3d11_device_CreateBuffer,
2461 d3d11_device_CreateTexture1D,
2462 d3d11_device_CreateTexture2D,
2463 d3d11_device_CreateTexture3D,
2464 d3d11_device_CreateShaderResourceView,
2465 d3d11_device_CreateUnorderedAccessView,
2466 d3d11_device_CreateRenderTargetView,
2467 d3d11_device_CreateDepthStencilView,
2468 d3d11_device_CreateInputLayout,
2469 d3d11_device_CreateVertexShader,
2470 d3d11_device_CreateGeometryShader,
2471 d3d11_device_CreateGeometryShaderWithStreamOutput,
2472 d3d11_device_CreatePixelShader,
2473 d3d11_device_CreateHullShader,
2474 d3d11_device_CreateDomainShader,
2475 d3d11_device_CreateComputeShader,
2476 d3d11_device_CreateClassLinkage,
2477 d3d11_device_CreateBlendState,
2478 d3d11_device_CreateDepthStencilState,
2479 d3d11_device_CreateRasterizerState,
2480 d3d11_device_CreateSamplerState,
2481 d3d11_device_CreateQuery,
2482 d3d11_device_CreatePredicate,
2483 d3d11_device_CreateCounter,
2484 d3d11_device_CreateDeferredContext,
2485 d3d11_device_OpenSharedResource,
2486 d3d11_device_CheckFormatSupport,
2487 d3d11_device_CheckMultisampleQualityLevels,
2488 d3d11_device_CheckCounterInfo,
2489 d3d11_device_CheckCounter,
2490 d3d11_device_CheckFeatureSupport,
2491 d3d11_device_GetPrivateData,
2492 d3d11_device_SetPrivateData,
2493 d3d11_device_SetPrivateDataInterface,
2494 d3d11_device_GetFeatureLevel,
2495 d3d11_device_GetCreationFlags,
2496 d3d11_device_GetDeviceRemovedReason,
2497 d3d11_device_GetImmediateContext,
2498 d3d11_device_SetExceptionMode,
2499 d3d11_device_GetExceptionMode,
2502 /* Inner IUnknown methods */
2504 static inline struct d3d_device *impl_from_IUnknown(IUnknown *iface)
2506 return CONTAINING_RECORD(iface, struct d3d_device, IUnknown_inner);
2509 static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
2511 struct d3d_device *device = impl_from_IUnknown(iface);
2513 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2515 if (IsEqualGUID(riid, &IID_ID3D11Device)
2516 || IsEqualGUID(riid, &IID_IUnknown))
2518 *out = &device->ID3D11Device_iface;
2520 else if (IsEqualGUID(riid, &IID_ID3D10Device1)
2521 || IsEqualGUID(riid, &IID_ID3D10Device))
2523 *out = &device->ID3D10Device1_iface;
2525 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
2527 *out = &device->ID3D10Multithread_iface;
2529 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
2531 *out = &device->IWineDXGIDeviceParent_iface;
2533 else
2535 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2536 *out = NULL;
2537 return E_NOINTERFACE;
2540 IUnknown_AddRef((IUnknown *)*out);
2541 return S_OK;
2544 static ULONG STDMETHODCALLTYPE d3d_device_inner_AddRef(IUnknown *iface)
2546 struct d3d_device *device = impl_from_IUnknown(iface);
2547 ULONG refcount = InterlockedIncrement(&device->refcount);
2549 TRACE("%p increasing refcount to %u.\n", device, refcount);
2551 return refcount;
2554 static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
2556 struct d3d_device *device = impl_from_IUnknown(iface);
2557 ULONG refcount = InterlockedDecrement(&device->refcount);
2559 TRACE("%p decreasing refcount to %u.\n", device, refcount);
2561 if (!refcount)
2563 if (device->wined3d_device)
2565 wined3d_mutex_lock();
2566 wined3d_device_decref(device->wined3d_device);
2567 wined3d_mutex_unlock();
2569 wine_rb_destroy(&device->sampler_states, NULL, NULL);
2570 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2571 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2572 wine_rb_destroy(&device->blend_states, NULL, NULL);
2575 return refcount;
2578 /* IUnknown methods */
2580 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
2581 void **ppv)
2583 struct d3d_device *This = impl_from_ID3D10Device(iface);
2584 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
2587 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
2589 struct d3d_device *This = impl_from_ID3D10Device(iface);
2590 return IUnknown_AddRef(This->outer_unk);
2593 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
2595 struct d3d_device *This = impl_from_ID3D10Device(iface);
2596 return IUnknown_Release(This->outer_unk);
2599 /* ID3D10Device methods */
2601 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
2602 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2604 struct d3d_device *device = impl_from_ID3D10Device(iface);
2605 unsigned int i;
2607 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2608 iface, start_slot, buffer_count, buffers);
2610 wined3d_mutex_lock();
2611 for (i = 0; i < buffer_count; ++i)
2613 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2615 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
2616 buffer ? buffer->wined3d_buffer : NULL);
2618 wined3d_mutex_unlock();
2621 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
2622 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2624 struct d3d_device *device = impl_from_ID3D10Device(iface);
2625 unsigned int i;
2627 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2628 iface, start_slot, view_count, views);
2630 wined3d_mutex_lock();
2631 for (i = 0; i < view_count; ++i)
2633 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2635 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
2636 view ? view->wined3d_view : NULL);
2638 wined3d_mutex_unlock();
2641 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
2642 ID3D10PixelShader *shader)
2644 struct d3d_device *This = impl_from_ID3D10Device(iface);
2645 struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
2647 TRACE("iface %p, shader %p\n", iface, shader);
2649 wined3d_mutex_lock();
2650 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
2651 wined3d_mutex_unlock();
2654 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
2655 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2657 struct d3d_device *device = impl_from_ID3D10Device(iface);
2658 unsigned int i;
2660 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2661 iface, start_slot, sampler_count, samplers);
2663 wined3d_mutex_lock();
2664 for (i = 0; i < sampler_count; ++i)
2666 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2668 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
2669 sampler ? sampler->wined3d_sampler : NULL);
2671 wined3d_mutex_unlock();
2674 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
2675 ID3D10VertexShader *shader)
2677 struct d3d_device *This = impl_from_ID3D10Device(iface);
2678 struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
2680 TRACE("iface %p, shader %p\n", iface, shader);
2682 wined3d_mutex_lock();
2683 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
2684 wined3d_mutex_unlock();
2687 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
2688 UINT start_index_location, INT base_vertex_location)
2690 struct d3d_device *This = impl_from_ID3D10Device(iface);
2692 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2693 iface, index_count, start_index_location, base_vertex_location);
2695 wined3d_mutex_lock();
2696 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
2697 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
2698 wined3d_mutex_unlock();
2701 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
2702 UINT start_vertex_location)
2704 struct d3d_device *This = impl_from_ID3D10Device(iface);
2706 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2707 iface, vertex_count, start_vertex_location);
2709 wined3d_mutex_lock();
2710 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
2711 wined3d_mutex_unlock();
2714 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
2715 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2717 struct d3d_device *device = impl_from_ID3D10Device(iface);
2718 unsigned int i;
2720 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2721 iface, start_slot, buffer_count, buffers);
2723 wined3d_mutex_lock();
2724 for (i = 0; i < buffer_count; ++i)
2726 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2728 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
2729 buffer ? buffer->wined3d_buffer : NULL);
2731 wined3d_mutex_unlock();
2734 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
2735 ID3D10InputLayout *input_layout)
2737 struct d3d_device *This = impl_from_ID3D10Device(iface);
2738 struct d3d_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
2740 TRACE("iface %p, input_layout %p\n", iface, input_layout);
2742 wined3d_mutex_lock();
2743 wined3d_device_set_vertex_declaration(This->wined3d_device,
2744 layout ? layout->wined3d_decl : NULL);
2745 wined3d_mutex_unlock();
2748 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
2749 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
2751 struct d3d_device *This = impl_from_ID3D10Device(iface);
2752 unsigned int i;
2754 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
2755 iface, start_slot, buffer_count, buffers, strides, offsets);
2757 wined3d_mutex_lock();
2758 for (i = 0; i < buffer_count; ++i)
2760 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2762 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
2763 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
2765 wined3d_mutex_unlock();
2768 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
2769 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
2771 struct d3d_device *This = impl_from_ID3D10Device(iface);
2772 struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
2774 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
2775 iface, buffer, debug_dxgi_format(format), offset);
2777 wined3d_mutex_lock();
2778 wined3d_device_set_index_buffer(This->wined3d_device,
2779 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
2780 wined3dformat_from_dxgi_format(format));
2781 wined3d_mutex_unlock();
2782 if (offset) FIXME("offset %u not supported.\n", offset);
2785 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
2786 UINT instance_index_count, UINT instance_count, UINT start_index_location,
2787 INT base_vertex_location, UINT start_instance_location)
2789 struct d3d_device *device = impl_from_ID3D10Device(iface);
2791 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
2792 "base_vertex_location %d, start_instance_location %u.\n",
2793 iface, instance_index_count, instance_count, start_index_location,
2794 base_vertex_location, start_instance_location);
2796 wined3d_mutex_lock();
2797 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
2798 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
2799 instance_index_count, start_instance_location, instance_count);
2800 wined3d_mutex_unlock();
2803 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
2804 UINT instance_vertex_count, UINT instance_count,
2805 UINT start_vertex_location, UINT start_instance_location)
2807 struct d3d_device *device = impl_from_ID3D10Device(iface);
2809 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
2810 "start_instance_location %u.\n", iface, instance_vertex_count, instance_count,
2811 start_vertex_location, start_instance_location);
2813 wined3d_mutex_lock();
2814 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
2815 instance_vertex_count, start_instance_location, instance_count);
2816 wined3d_mutex_unlock();
2819 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
2820 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2822 struct d3d_device *device = impl_from_ID3D10Device(iface);
2823 unsigned int i;
2825 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2826 iface, start_slot, buffer_count, buffers);
2828 wined3d_mutex_lock();
2829 for (i = 0; i < buffer_count; ++i)
2831 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2833 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
2834 buffer ? buffer->wined3d_buffer : NULL);
2836 wined3d_mutex_unlock();
2839 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
2841 struct d3d_device *device = impl_from_ID3D10Device(iface);
2842 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
2844 TRACE("iface %p, shader %p.\n", iface, shader);
2846 wined3d_mutex_lock();
2847 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
2848 wined3d_mutex_unlock();
2851 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
2852 D3D10_PRIMITIVE_TOPOLOGY topology)
2854 struct d3d_device *This = impl_from_ID3D10Device(iface);
2856 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
2858 wined3d_mutex_lock();
2859 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
2860 wined3d_mutex_unlock();
2863 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
2864 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2866 struct d3d_device *device = impl_from_ID3D10Device(iface);
2867 unsigned int i;
2869 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2870 iface, start_slot, view_count, views);
2872 wined3d_mutex_lock();
2873 for (i = 0; i < view_count; ++i)
2875 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2877 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
2878 view ? view->wined3d_view : NULL);
2880 wined3d_mutex_unlock();
2883 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
2884 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2886 struct d3d_device *device = impl_from_ID3D10Device(iface);
2887 unsigned int i;
2889 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2890 iface, start_slot, sampler_count, samplers);
2892 wined3d_mutex_lock();
2893 for (i = 0; i < sampler_count; ++i)
2895 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2897 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
2898 sampler ? sampler->wined3d_sampler : NULL);
2900 wined3d_mutex_unlock();
2903 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
2905 struct d3d_device *device = impl_from_ID3D10Device(iface);
2906 struct d3d_query *query;
2908 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
2910 query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
2911 wined3d_mutex_lock();
2912 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
2913 wined3d_mutex_unlock();
2916 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
2917 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2919 struct d3d_device *device = impl_from_ID3D10Device(iface);
2920 unsigned int i;
2922 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2923 iface, start_slot, view_count, views);
2925 wined3d_mutex_lock();
2926 for (i = 0; i < view_count; ++i)
2928 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2930 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
2931 view ? view->wined3d_view : NULL);
2933 wined3d_mutex_unlock();
2936 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
2937 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2939 struct d3d_device *device = impl_from_ID3D10Device(iface);
2940 unsigned int i;
2942 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2943 iface, start_slot, sampler_count, samplers);
2945 wined3d_mutex_lock();
2946 for (i = 0; i < sampler_count; ++i)
2948 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2950 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
2951 sampler ? sampler->wined3d_sampler : NULL);
2953 wined3d_mutex_unlock();
2956 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
2957 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
2958 ID3D10DepthStencilView *depth_stencil_view)
2960 struct d3d_device *device = impl_from_ID3D10Device(iface);
2961 struct d3d_depthstencil_view *dsv;
2962 unsigned int i;
2964 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
2965 iface, render_target_view_count, render_target_views, depth_stencil_view);
2967 wined3d_mutex_lock();
2968 for (i = 0; i < render_target_view_count; ++i)
2970 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
2972 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
2973 rtv ? rtv->wined3d_view : NULL, FALSE);
2975 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
2977 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
2980 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
2981 wined3d_device_set_depth_stencil_view(device->wined3d_device,
2982 dsv ? dsv->wined3d_view : NULL);
2983 wined3d_mutex_unlock();
2986 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
2987 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
2989 struct d3d_device *device = impl_from_ID3D10Device(iface);
2990 struct d3d_blend_state *blend_state_object;
2992 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
2993 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
2995 blend_state_object = unsafe_impl_from_ID3D10BlendState(blend_state);
2996 d3d11_immediate_context_OMSetBlendState(&device->immediate_context.ID3D11DeviceContext_iface,
2997 blend_state_object ? &blend_state_object->ID3D11BlendState_iface : NULL, blend_factor, sample_mask);
3000 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
3001 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
3003 struct d3d_device *device = impl_from_ID3D10Device(iface);
3005 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3006 iface, depth_stencil_state, stencil_ref);
3008 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
3009 device->stencil_ref = stencil_ref;
3012 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
3013 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
3015 struct d3d_device *device = impl_from_ID3D10Device(iface);
3016 unsigned int count, i;
3018 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
3020 count = min(target_count, 4);
3021 wined3d_mutex_lock();
3022 for (i = 0; i < count; ++i)
3024 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
3026 wined3d_device_set_stream_output(device->wined3d_device, i,
3027 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
3030 for (i = count; i < 4; ++i)
3032 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
3034 wined3d_mutex_unlock();
3037 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
3039 FIXME("iface %p stub!\n", iface);
3042 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
3044 struct d3d_device *device = impl_from_ID3D10Device(iface);
3045 struct d3d_rasterizer_state *rasterizer_state_object;
3047 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3049 rasterizer_state_object = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
3050 d3d11_immediate_context_RSSetState(&device->immediate_context.ID3D11DeviceContext_iface,
3051 rasterizer_state_object ? &rasterizer_state_object->ID3D11RasterizerState_iface : NULL);
3054 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
3055 UINT viewport_count, const D3D10_VIEWPORT *viewports)
3057 struct d3d_device *device = impl_from_ID3D10Device(iface);
3058 struct wined3d_viewport wined3d_vp;
3060 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
3062 if (viewport_count > 1)
3063 FIXME("Multiple viewports not implemented.\n");
3065 if (!viewport_count)
3066 return;
3068 wined3d_vp.x = viewports[0].TopLeftX;
3069 wined3d_vp.y = viewports[0].TopLeftY;
3070 wined3d_vp.width = viewports[0].Width;
3071 wined3d_vp.height = viewports[0].Height;
3072 wined3d_vp.min_z = viewports[0].MinDepth;
3073 wined3d_vp.max_z = viewports[0].MaxDepth;
3075 wined3d_mutex_lock();
3076 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
3077 wined3d_mutex_unlock();
3080 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
3081 UINT rect_count, const D3D10_RECT *rects)
3083 struct d3d_device *device = impl_from_ID3D10Device(iface);
3085 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
3087 if (rect_count > 1)
3088 FIXME("Multiple scissor rects not implemented.\n");
3090 if (!rect_count)
3091 return;
3093 wined3d_mutex_lock();
3094 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
3095 wined3d_mutex_unlock();
3098 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
3099 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
3100 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
3102 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
3103 struct d3d_device *device = impl_from_ID3D10Device(iface);
3104 struct wined3d_box wined3d_src_box;
3106 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3107 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3108 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
3109 src_resource, src_subresource_idx, src_box);
3111 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
3112 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
3113 wined3d_src_box.left = src_box->left;
3114 wined3d_src_box.top = src_box->top;
3115 wined3d_src_box.front = src_box->front;
3116 wined3d_src_box.right = src_box->right;
3117 wined3d_src_box.bottom = src_box->bottom;
3118 wined3d_src_box.back = src_box->back;
3119 wined3d_mutex_lock();
3120 wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
3121 dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, &wined3d_src_box);
3122 wined3d_mutex_unlock();
3125 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
3126 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
3128 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
3129 struct d3d_device *device = impl_from_ID3D10Device(iface);
3131 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
3133 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
3134 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
3135 wined3d_mutex_lock();
3136 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
3137 wined3d_mutex_unlock();
3140 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
3141 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
3142 const void *data, UINT row_pitch, UINT depth_pitch)
3144 struct d3d_device *device = impl_from_ID3D10Device(iface);
3145 ID3D11Resource *d3d11_resource;
3147 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3148 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
3150 ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource);
3151 d3d11_immediate_context_UpdateSubresource(&device->immediate_context.ID3D11DeviceContext_iface,
3152 d3d11_resource, subresource_idx, (const D3D11_BOX *)box, data, row_pitch, depth_pitch);
3153 ID3D11Resource_Release(d3d11_resource);
3156 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
3157 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
3159 struct d3d_device *device = impl_from_ID3D10Device(iface);
3160 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
3161 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
3162 HRESULT hr;
3164 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
3165 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
3167 wined3d_mutex_lock();
3168 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
3169 ERR("Failed to clear view, hr %#x.\n", hr);
3170 wined3d_mutex_unlock();
3173 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
3174 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
3176 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
3177 iface, depth_stencil_view, flags, depth, stencil);
3180 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
3181 ID3D10ShaderResourceView *shader_resource_view)
3183 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
3186 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
3187 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
3188 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
3190 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3191 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3192 iface, dst_resource, dst_subresource_idx,
3193 src_resource, src_subresource_idx, debug_dxgi_format(format));
3196 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
3197 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3199 struct d3d_device *device = impl_from_ID3D10Device(iface);
3200 unsigned int i;
3202 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3203 iface, start_slot, buffer_count, buffers);
3205 wined3d_mutex_lock();
3206 for (i = 0; i < buffer_count; ++i)
3208 struct wined3d_buffer *wined3d_buffer;
3209 struct d3d_buffer *buffer_impl;
3211 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
3213 buffers[i] = NULL;
3214 continue;
3217 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3218 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3219 ID3D10Buffer_AddRef(buffers[i]);
3221 wined3d_mutex_unlock();
3224 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
3225 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3227 struct d3d_device *device = impl_from_ID3D10Device(iface);
3228 unsigned int i;
3230 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3231 iface, start_slot, view_count, views);
3233 wined3d_mutex_lock();
3234 for (i = 0; i < view_count; ++i)
3236 struct wined3d_shader_resource_view *wined3d_view;
3237 struct d3d_shader_resource_view *view_impl;
3239 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
3241 views[i] = NULL;
3242 continue;
3245 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3246 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3247 ID3D10ShaderResourceView_AddRef(views[i]);
3249 wined3d_mutex_unlock();
3252 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
3254 struct d3d_device *device = impl_from_ID3D10Device(iface);
3255 struct d3d_pixel_shader *shader_impl;
3256 struct wined3d_shader *wined3d_shader;
3258 TRACE("iface %p, shader %p.\n", iface, shader);
3260 wined3d_mutex_lock();
3261 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
3263 wined3d_mutex_unlock();
3264 *shader = NULL;
3265 return;
3268 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3269 wined3d_mutex_unlock();
3270 *shader = &shader_impl->ID3D10PixelShader_iface;
3271 ID3D10PixelShader_AddRef(*shader);
3274 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
3275 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3277 struct d3d_device *device = impl_from_ID3D10Device(iface);
3278 unsigned int i;
3280 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3281 iface, start_slot, sampler_count, samplers);
3283 wined3d_mutex_lock();
3284 for (i = 0; i < sampler_count; ++i)
3286 struct d3d_sampler_state *sampler_impl;
3287 struct wined3d_sampler *wined3d_sampler;
3289 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
3291 samplers[i] = NULL;
3292 continue;
3295 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3296 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3297 ID3D10SamplerState_AddRef(samplers[i]);
3299 wined3d_mutex_unlock();
3302 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
3304 struct d3d_device *device = impl_from_ID3D10Device(iface);
3305 struct d3d_vertex_shader *shader_impl;
3306 struct wined3d_shader *wined3d_shader;
3308 TRACE("iface %p, shader %p.\n", iface, shader);
3310 wined3d_mutex_lock();
3311 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
3313 wined3d_mutex_unlock();
3314 *shader = NULL;
3315 return;
3318 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3319 wined3d_mutex_unlock();
3320 *shader = &shader_impl->ID3D10VertexShader_iface;
3321 ID3D10VertexShader_AddRef(*shader);
3324 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
3325 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3327 struct d3d_device *device = impl_from_ID3D10Device(iface);
3328 unsigned int i;
3330 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3331 iface, start_slot, buffer_count, buffers);
3333 wined3d_mutex_lock();
3334 for (i = 0; i < buffer_count; ++i)
3336 struct wined3d_buffer *wined3d_buffer;
3337 struct d3d_buffer *buffer_impl;
3339 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
3341 buffers[i] = NULL;
3342 continue;
3345 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3346 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3347 ID3D10Buffer_AddRef(buffers[i]);
3349 wined3d_mutex_unlock();
3352 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
3354 struct d3d_device *device = impl_from_ID3D10Device(iface);
3355 struct wined3d_vertex_declaration *wined3d_declaration;
3356 struct d3d_input_layout *input_layout_impl;
3358 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
3360 wined3d_mutex_lock();
3361 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
3363 wined3d_mutex_unlock();
3364 *input_layout = NULL;
3365 return;
3368 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
3369 wined3d_mutex_unlock();
3370 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
3371 ID3D10InputLayout_AddRef(*input_layout);
3374 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
3375 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
3377 struct d3d_device *device = impl_from_ID3D10Device(iface);
3378 unsigned int i;
3380 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3381 iface, start_slot, buffer_count, buffers, strides, offsets);
3383 wined3d_mutex_lock();
3384 for (i = 0; i < buffer_count; ++i)
3386 struct wined3d_buffer *wined3d_buffer;
3387 struct d3d_buffer *buffer_impl;
3389 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
3390 &wined3d_buffer, &offsets[i], &strides[i])))
3391 ERR("Failed to get vertex buffer.\n");
3393 if (!wined3d_buffer)
3395 buffers[i] = NULL;
3396 continue;
3399 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3400 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3401 ID3D10Buffer_AddRef(buffers[i]);
3403 wined3d_mutex_unlock();
3406 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
3407 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
3409 struct d3d_device *device = impl_from_ID3D10Device(iface);
3410 enum wined3d_format_id wined3d_format;
3411 struct wined3d_buffer *wined3d_buffer;
3412 struct d3d_buffer *buffer_impl;
3414 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
3416 wined3d_mutex_lock();
3417 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
3418 *format = dxgi_format_from_wined3dformat(wined3d_format);
3419 *offset = 0; /* FIXME */
3420 if (!wined3d_buffer)
3422 wined3d_mutex_unlock();
3423 *buffer = NULL;
3424 return;
3427 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3428 wined3d_mutex_unlock();
3429 *buffer = &buffer_impl->ID3D10Buffer_iface;
3430 ID3D10Buffer_AddRef(*buffer);
3433 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
3434 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3436 struct d3d_device *device = impl_from_ID3D10Device(iface);
3437 unsigned int i;
3439 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3440 iface, start_slot, buffer_count, buffers);
3442 wined3d_mutex_lock();
3443 for (i = 0; i < buffer_count; ++i)
3445 struct wined3d_buffer *wined3d_buffer;
3446 struct d3d_buffer *buffer_impl;
3448 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
3450 buffers[i] = NULL;
3451 continue;
3454 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3455 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3456 ID3D10Buffer_AddRef(buffers[i]);
3458 wined3d_mutex_unlock();
3461 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
3463 struct d3d_device *device = impl_from_ID3D10Device(iface);
3464 struct d3d_geometry_shader *shader_impl;
3465 struct wined3d_shader *wined3d_shader;
3467 TRACE("iface %p, shader %p.\n", iface, shader);
3469 wined3d_mutex_lock();
3470 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
3472 wined3d_mutex_unlock();
3473 *shader = NULL;
3474 return;
3477 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3478 wined3d_mutex_unlock();
3479 *shader = &shader_impl->ID3D10GeometryShader_iface;
3480 ID3D10GeometryShader_AddRef(*shader);
3483 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
3484 D3D10_PRIMITIVE_TOPOLOGY *topology)
3486 struct d3d_device *This = impl_from_ID3D10Device(iface);
3488 TRACE("iface %p, topology %p\n", iface, topology);
3490 wined3d_mutex_lock();
3491 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
3492 wined3d_mutex_unlock();
3495 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
3496 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3498 struct d3d_device *device = impl_from_ID3D10Device(iface);
3499 unsigned int i;
3501 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3502 iface, start_slot, view_count, views);
3504 wined3d_mutex_lock();
3505 for (i = 0; i < view_count; ++i)
3507 struct wined3d_shader_resource_view *wined3d_view;
3508 struct d3d_shader_resource_view *view_impl;
3510 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
3512 views[i] = NULL;
3513 continue;
3516 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3517 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3518 ID3D10ShaderResourceView_AddRef(views[i]);
3520 wined3d_mutex_unlock();
3523 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
3524 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3526 struct d3d_device *device = impl_from_ID3D10Device(iface);
3527 unsigned int i;
3529 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3530 iface, start_slot, sampler_count, samplers);
3532 wined3d_mutex_lock();
3533 for (i = 0; i < sampler_count; ++i)
3535 struct d3d_sampler_state *sampler_impl;
3536 struct wined3d_sampler *wined3d_sampler;
3538 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
3540 samplers[i] = NULL;
3541 continue;
3544 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3545 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3546 ID3D10SamplerState_AddRef(samplers[i]);
3548 wined3d_mutex_unlock();
3551 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
3552 ID3D10Predicate **predicate, BOOL *value)
3554 struct d3d_device *device = impl_from_ID3D10Device(iface);
3555 struct wined3d_query *wined3d_predicate;
3556 struct d3d_query *predicate_impl;
3558 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
3560 wined3d_mutex_lock();
3561 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
3563 wined3d_mutex_unlock();
3564 *predicate = NULL;
3565 return;
3568 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
3569 wined3d_mutex_unlock();
3570 *predicate = (ID3D10Predicate *)&predicate_impl->ID3D10Query_iface;
3571 ID3D10Predicate_AddRef(*predicate);
3574 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
3575 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3577 struct d3d_device *device = impl_from_ID3D10Device(iface);
3578 unsigned int i;
3580 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3581 iface, start_slot, view_count, views);
3583 wined3d_mutex_lock();
3584 for (i = 0; i < view_count; ++i)
3586 struct wined3d_shader_resource_view *wined3d_view;
3587 struct d3d_shader_resource_view *view_impl;
3589 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
3591 views[i] = NULL;
3592 continue;
3595 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3596 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3597 ID3D10ShaderResourceView_AddRef(views[i]);
3599 wined3d_mutex_unlock();
3602 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
3603 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3605 struct d3d_device *device = impl_from_ID3D10Device(iface);
3606 unsigned int i;
3608 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3609 iface, start_slot, sampler_count, samplers);
3611 wined3d_mutex_lock();
3612 for (i = 0; i < sampler_count; ++i)
3614 struct d3d_sampler_state *sampler_impl;
3615 struct wined3d_sampler *wined3d_sampler;
3617 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
3619 samplers[i] = NULL;
3620 continue;
3623 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3624 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3625 ID3D10SamplerState_AddRef(samplers[i]);
3627 wined3d_mutex_unlock();
3630 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
3631 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
3633 struct d3d_device *device = impl_from_ID3D10Device(iface);
3634 struct wined3d_rendertarget_view *wined3d_view;
3636 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3637 iface, view_count, render_target_views, depth_stencil_view);
3639 wined3d_mutex_lock();
3640 if (render_target_views)
3642 struct d3d_rendertarget_view *view_impl;
3643 unsigned int i;
3645 for (i = 0; i < view_count; ++i)
3647 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
3648 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3650 render_target_views[i] = NULL;
3651 continue;
3654 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
3655 ID3D10RenderTargetView_AddRef(render_target_views[i]);
3659 if (depth_stencil_view)
3661 struct d3d_depthstencil_view *view_impl;
3663 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
3664 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3666 *depth_stencil_view = NULL;
3668 else
3670 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
3671 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
3674 wined3d_mutex_unlock();
3677 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
3678 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
3680 struct d3d_device *device = impl_from_ID3D10Device(iface);
3682 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3683 iface, blend_state, blend_factor, sample_mask);
3685 if ((*blend_state = device->blend_state ? (ID3D10BlendState *)&device->blend_state->ID3D10BlendState1_iface : NULL))
3686 ID3D10BlendState_AddRef(*blend_state);
3687 wined3d_mutex_lock();
3688 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
3689 *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK);
3690 wined3d_mutex_unlock();
3693 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
3694 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
3696 struct d3d_device *device = impl_from_ID3D10Device(iface);
3698 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
3699 iface, depth_stencil_state, stencil_ref);
3701 if ((*depth_stencil_state = device->depth_stencil_state
3702 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
3703 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
3704 *stencil_ref = device->stencil_ref;
3707 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
3708 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
3710 struct d3d_device *device = impl_from_ID3D10Device(iface);
3711 unsigned int i;
3713 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
3714 iface, buffer_count, buffers, offsets);
3716 wined3d_mutex_lock();
3717 for (i = 0; i < buffer_count; ++i)
3719 struct wined3d_buffer *wined3d_buffer;
3720 struct d3d_buffer *buffer_impl;
3722 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
3724 buffers[i] = NULL;
3725 continue;
3728 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3729 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3730 ID3D10Buffer_AddRef(buffers[i]);
3732 wined3d_mutex_unlock();
3735 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
3737 struct d3d_device *device = impl_from_ID3D10Device(iface);
3739 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3741 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
3742 ID3D10RasterizerState_AddRef(*rasterizer_state);
3745 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
3746 UINT *viewport_count, D3D10_VIEWPORT *viewports)
3748 struct d3d_device *device = impl_from_ID3D10Device(iface);
3749 struct wined3d_viewport wined3d_vp;
3751 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
3753 if (!viewports)
3755 *viewport_count = 1;
3756 return;
3759 if (!*viewport_count)
3760 return;
3762 wined3d_mutex_lock();
3763 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
3764 wined3d_mutex_unlock();
3766 viewports[0].TopLeftX = wined3d_vp.x;
3767 viewports[0].TopLeftY = wined3d_vp.y;
3768 viewports[0].Width = wined3d_vp.width;
3769 viewports[0].Height = wined3d_vp.height;
3770 viewports[0].MinDepth = wined3d_vp.min_z;
3771 viewports[0].MaxDepth = wined3d_vp.max_z;
3773 if (*viewport_count > 1)
3774 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
3777 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
3779 struct d3d_device *device = impl_from_ID3D10Device(iface);
3781 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
3783 if (!rects)
3785 *rect_count = 1;
3786 return;
3789 if (!*rect_count)
3790 return;
3792 wined3d_mutex_lock();
3793 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
3794 wined3d_mutex_unlock();
3795 if (*rect_count > 1)
3796 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
3799 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
3801 TRACE("iface %p.\n", iface);
3803 /* In the current implementation the device is never removed, so we can
3804 * just return S_OK here. */
3806 return S_OK;
3809 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
3811 FIXME("iface %p, flags %#x stub!\n", iface, flags);
3813 return E_NOTIMPL;
3816 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
3818 FIXME("iface %p stub!\n", iface);
3820 return 0;
3823 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
3824 REFGUID guid, UINT *data_size, void *data)
3826 struct d3d_device *device = impl_from_ID3D10Device(iface);
3828 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3830 return d3d11_device_GetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3833 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
3834 REFGUID guid, UINT data_size, const void *data)
3836 struct d3d_device *device = impl_from_ID3D10Device(iface);
3838 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3840 return d3d11_device_SetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3843 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
3844 REFGUID guid, const IUnknown *data)
3846 struct d3d_device *device = impl_from_ID3D10Device(iface);
3848 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
3850 return d3d11_device_SetPrivateDataInterface(&device->ID3D11Device_iface, guid, data);
3853 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
3855 static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
3856 struct d3d_device *device = impl_from_ID3D10Device(iface);
3857 unsigned int i;
3859 TRACE("iface %p.\n", iface);
3861 wined3d_mutex_lock();
3862 wined3d_device_set_vertex_shader(device->wined3d_device, NULL);
3863 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3865 wined3d_device_set_vs_sampler(device->wined3d_device, i, NULL);
3867 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3869 wined3d_device_set_vs_resource_view(device->wined3d_device, i, NULL);
3871 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3873 wined3d_device_set_vs_cb(device->wined3d_device, i, NULL);
3875 wined3d_device_set_geometry_shader(device->wined3d_device, NULL);
3876 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3878 wined3d_device_set_gs_sampler(device->wined3d_device, i, NULL);
3880 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3882 wined3d_device_set_gs_resource_view(device->wined3d_device, i, NULL);
3884 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3886 wined3d_device_set_gs_cb(device->wined3d_device, i, NULL);
3888 wined3d_device_set_pixel_shader(device->wined3d_device, NULL);
3889 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3891 wined3d_device_set_ps_sampler(device->wined3d_device, i, NULL);
3893 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3895 wined3d_device_set_ps_resource_view(device->wined3d_device, i, NULL);
3897 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3899 wined3d_device_set_ps_cb(device->wined3d_device, i, NULL);
3901 for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i)
3903 wined3d_device_set_stream_source(device->wined3d_device, i, NULL, 0, 0);
3905 wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
3906 wined3d_device_set_vertex_declaration(device->wined3d_device, NULL);
3907 wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_UNDEFINED);
3908 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
3910 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
3912 wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL);
3913 ID3D10Device1_OMSetDepthStencilState(iface, NULL, 0);
3914 ID3D10Device1_OMSetBlendState(iface, NULL, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
3915 ID3D10Device1_RSSetViewports(iface, 0, NULL);
3916 ID3D10Device1_RSSetScissorRects(iface, 0, NULL);
3917 ID3D10Device1_RSSetState(iface, NULL);
3918 for (i = 0; i < D3D10_SO_BUFFER_SLOT_COUNT; ++i)
3920 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
3922 wined3d_device_set_predication(device->wined3d_device, NULL, FALSE);
3923 wined3d_mutex_unlock();
3926 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
3928 FIXME("iface %p stub!\n", iface);
3931 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
3932 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
3934 struct d3d_device *device = impl_from_ID3D10Device(iface);
3935 D3D11_BUFFER_DESC d3d11_desc;
3936 struct d3d_buffer *object;
3937 HRESULT hr;
3939 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
3941 d3d11_desc.ByteWidth = desc->ByteWidth;
3942 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3943 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3944 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3945 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3946 d3d11_desc.StructureByteStride = 0;
3948 if (FAILED(hr = d3d_buffer_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3949 return hr;
3951 *buffer = &object->ID3D10Buffer_iface;
3953 return S_OK;
3956 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
3957 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
3959 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
3961 return E_NOTIMPL;
3964 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
3965 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
3966 ID3D10Texture2D **texture)
3968 struct d3d_device *device = impl_from_ID3D10Device(iface);
3969 D3D11_TEXTURE2D_DESC d3d11_desc;
3970 struct d3d_texture2d *object;
3971 HRESULT hr;
3973 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
3975 d3d11_desc.Width = desc->Width;
3976 d3d11_desc.Height = desc->Height;
3977 d3d11_desc.MipLevels = desc->MipLevels;
3978 d3d11_desc.ArraySize = desc->ArraySize;
3979 d3d11_desc.Format = desc->Format;
3980 d3d11_desc.SampleDesc = desc->SampleDesc;
3981 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3982 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3983 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3984 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3986 if (FAILED(hr = d3d_texture2d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3987 return hr;
3989 *texture = &object->ID3D10Texture2D_iface;
3991 return S_OK;
3994 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
3995 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
3996 ID3D10Texture3D **texture)
3998 struct d3d_device *device = impl_from_ID3D10Device(iface);
3999 D3D11_TEXTURE3D_DESC d3d11_desc;
4000 struct d3d_texture3d *object;
4001 HRESULT hr;
4003 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
4005 d3d11_desc.Width = desc->Width;
4006 d3d11_desc.Height = desc->Height;
4007 d3d11_desc.Depth = desc->Depth;
4008 d3d11_desc.MipLevels = desc->MipLevels;
4009 d3d11_desc.Format = desc->Format;
4010 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
4011 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
4012 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
4013 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
4015 if (FAILED(hr = d3d_texture3d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
4016 return hr;
4018 *texture = &object->ID3D10Texture3D_iface;
4020 return S_OK;
4023 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
4024 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
4026 struct d3d_device *device = impl_from_ID3D10Device(iface);
4027 struct d3d_shader_resource_view *object;
4028 ID3D11Resource *d3d11_resource;
4029 HRESULT hr;
4031 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4033 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4035 ERR("Resource does not implement ID3D11Resource.\n");
4036 return E_FAIL;
4039 hr = d3d_shader_resource_view_create(device, d3d11_resource, (const D3D11_SHADER_RESOURCE_VIEW_DESC *)desc,
4040 &object);
4041 ID3D11Resource_Release(d3d11_resource);
4042 if (FAILED(hr))
4043 return hr;
4045 *view = &object->ID3D10ShaderResourceView1_iface;
4047 return S_OK;
4050 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
4051 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
4053 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4055 return d3d10_device_CreateShaderResourceView1(iface, resource,
4056 (const D3D10_SHADER_RESOURCE_VIEW_DESC1 *)desc, (ID3D10ShaderResourceView1 **)view);
4059 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
4060 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
4062 struct d3d_device *device = impl_from_ID3D10Device(iface);
4063 struct d3d_rendertarget_view *object;
4064 ID3D11Resource *d3d11_resource;
4065 HRESULT hr;
4067 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4069 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4071 ERR("Resource does not implement ID3D11Resource.\n");
4072 return E_FAIL;
4075 hr = d3d_rendertarget_view_create(device, d3d11_resource, (const D3D11_RENDER_TARGET_VIEW_DESC *)desc, &object);
4076 ID3D11Resource_Release(d3d11_resource);
4077 if (FAILED(hr))
4078 return hr;
4080 *view = &object->ID3D10RenderTargetView_iface;
4082 return S_OK;
4085 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
4086 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
4088 struct d3d_device *device = impl_from_ID3D10Device(iface);
4089 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc;
4090 struct d3d_depthstencil_view *object;
4091 ID3D11Resource *d3d11_resource;
4092 HRESULT hr;
4094 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4096 if (desc)
4098 d3d11_desc.Format = desc->Format;
4099 d3d11_desc.ViewDimension = desc->ViewDimension;
4100 d3d11_desc.Flags = 0;
4101 memcpy(&d3d11_desc.u, &desc->u, sizeof(d3d11_desc.u));
4104 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4106 ERR("Resource does not implement ID3D11Resource.\n");
4107 return E_FAIL;
4110 hr = d3d_depthstencil_view_create(device, d3d11_resource, desc ? &d3d11_desc : NULL, &object);
4111 ID3D11Resource_Release(d3d11_resource);
4112 if (FAILED(hr))
4113 return hr;
4115 *view = &object->ID3D10DepthStencilView_iface;
4117 return S_OK;
4120 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
4121 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
4122 const void *shader_byte_code, SIZE_T shader_byte_code_length,
4123 ID3D10InputLayout **input_layout)
4125 struct d3d_device *device = impl_from_ID3D10Device(iface);
4126 struct d3d_input_layout *object;
4127 HRESULT hr;
4129 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4130 "shader_byte_code_length %lu, input_layout %p\n",
4131 iface, element_descs, element_count, shader_byte_code,
4132 shader_byte_code_length, input_layout);
4134 if (FAILED(hr = d3d_input_layout_create(device, (const D3D11_INPUT_ELEMENT_DESC *)element_descs, element_count,
4135 shader_byte_code, shader_byte_code_length, &object)))
4136 return hr;
4138 *input_layout = &object->ID3D10InputLayout_iface;
4140 return S_OK;
4143 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
4144 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
4146 struct d3d_device *device = impl_from_ID3D10Device(iface);
4147 struct d3d_vertex_shader *object;
4148 HRESULT hr;
4150 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4151 iface, byte_code, byte_code_length, shader);
4153 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
4154 return hr;
4156 *shader = &object->ID3D10VertexShader_iface;
4158 return S_OK;
4161 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
4162 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
4164 struct d3d_device *device = impl_from_ID3D10Device(iface);
4165 struct d3d_geometry_shader *object;
4166 HRESULT hr;
4168 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4169 iface, byte_code, byte_code_length, shader);
4171 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
4172 return hr;
4174 *shader = &object->ID3D10GeometryShader_iface;
4176 return S_OK;
4179 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
4180 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
4181 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
4183 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4184 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4185 iface, byte_code, byte_code_length, output_stream_decls,
4186 output_stream_decl_count, output_stream_stride, shader);
4188 return E_NOTIMPL;
4191 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
4192 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
4194 struct d3d_device *device = impl_from_ID3D10Device(iface);
4195 struct d3d_pixel_shader *object;
4196 HRESULT hr;
4198 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4199 iface, byte_code, byte_code_length, shader);
4201 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
4202 return hr;
4204 *shader = &object->ID3D10PixelShader_iface;
4206 return S_OK;
4209 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
4210 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
4212 struct d3d_device *device = impl_from_ID3D10Device(iface);
4213 ID3D11BlendState *d3d11_blend_state;
4214 HRESULT hr;
4216 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4218 if (FAILED(hr = d3d11_device_CreateBlendState(&device->ID3D11Device_iface, (D3D11_BLEND_DESC *)desc,
4219 &d3d11_blend_state)))
4220 return hr;
4222 hr = ID3D11BlendState_QueryInterface(d3d11_blend_state, &IID_ID3D10BlendState1, (void **)blend_state);
4223 ID3D11BlendState_Release(d3d11_blend_state);
4224 return hr;
4227 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
4228 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
4230 D3D10_BLEND_DESC1 d3d10_1_desc;
4231 unsigned int i;
4233 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4235 if (!desc)
4236 return E_INVALIDARG;
4238 d3d10_1_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
4239 d3d10_1_desc.IndependentBlendEnable = FALSE;
4240 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT - 1; ++i)
4242 if (desc->BlendEnable[i] != desc->BlendEnable[i + 1]
4243 || desc->RenderTargetWriteMask[i] != desc->RenderTargetWriteMask[i + 1])
4244 d3d10_1_desc.IndependentBlendEnable = TRUE;
4247 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
4249 d3d10_1_desc.RenderTarget[i].BlendEnable = desc->BlendEnable[i];
4250 d3d10_1_desc.RenderTarget[i].SrcBlend = desc->SrcBlend;
4251 d3d10_1_desc.RenderTarget[i].DestBlend = desc->DestBlend;
4252 d3d10_1_desc.RenderTarget[i].BlendOp = desc->BlendOp;
4253 d3d10_1_desc.RenderTarget[i].SrcBlendAlpha = desc->SrcBlendAlpha;
4254 d3d10_1_desc.RenderTarget[i].DestBlendAlpha = desc->DestBlendAlpha;
4255 d3d10_1_desc.RenderTarget[i].BlendOpAlpha = desc->BlendOpAlpha;
4256 d3d10_1_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTargetWriteMask[i];
4259 return d3d10_device_CreateBlendState1(iface, &d3d10_1_desc, (ID3D10BlendState1 **)blend_state);
4262 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
4263 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
4265 struct d3d_device *device = impl_from_ID3D10Device(iface);
4266 ID3D11DepthStencilState *d3d11_depth_stencil_state;
4267 HRESULT hr;
4269 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
4271 if (FAILED(hr = d3d11_device_CreateDepthStencilState(&device->ID3D11Device_iface,
4272 (const D3D11_DEPTH_STENCIL_DESC *)desc, &d3d11_depth_stencil_state)))
4273 return hr;
4275 hr = ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state, &IID_ID3D10DepthStencilState,
4276 (void **)depth_stencil_state);
4277 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state);
4278 return hr;
4281 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
4282 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
4284 struct d3d_device *device = impl_from_ID3D10Device(iface);
4285 ID3D11RasterizerState *d3d11_rasterizer_state;
4286 HRESULT hr;
4288 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
4290 if (FAILED(hr = d3d11_device_CreateRasterizerState(&device->ID3D11Device_iface,
4291 (const D3D11_RASTERIZER_DESC *)desc, &d3d11_rasterizer_state)))
4292 return hr;
4294 hr = ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state,
4295 &IID_ID3D10RasterizerState, (void **)rasterizer_state);
4296 ID3D11RasterizerState_Release(d3d11_rasterizer_state);
4297 return hr;
4300 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
4301 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
4303 struct d3d_device *device = impl_from_ID3D10Device(iface);
4304 ID3D11SamplerState *d3d11_sampler_state;
4305 HRESULT hr;
4307 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
4309 if (FAILED(hr = d3d11_device_CreateSamplerState(&device->ID3D11Device_iface,
4310 (const D3D11_SAMPLER_DESC *)desc, &d3d11_sampler_state)))
4311 return hr;
4313 hr = ID3D11SamplerState_QueryInterface(d3d11_sampler_state, &IID_ID3D10SamplerState, (void **)sampler_state);
4314 ID3D11SamplerState_Release(d3d11_sampler_state);
4315 return hr;
4318 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
4319 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
4321 struct d3d_device *device = impl_from_ID3D10Device(iface);
4322 struct d3d_query *object;
4323 HRESULT hr;
4325 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
4327 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, FALSE, &object)))
4328 return hr;
4330 *query = &object->ID3D10Query_iface;
4332 return S_OK;
4335 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
4336 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
4338 struct d3d_device *device = impl_from_ID3D10Device(iface);
4339 struct d3d_query *object;
4340 HRESULT hr;
4342 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
4344 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, TRUE, &object)))
4345 return hr;
4347 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
4349 return S_OK;
4352 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
4353 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
4355 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
4357 return E_NOTIMPL;
4360 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
4361 DXGI_FORMAT format, UINT *format_support)
4363 FIXME("iface %p, format %s, format_support %p stub!\n",
4364 iface, debug_dxgi_format(format), format_support);
4366 return E_NOTIMPL;
4369 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
4370 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
4372 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
4373 iface, debug_dxgi_format(format), sample_count, quality_level_count);
4375 return E_NOTIMPL;
4378 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
4380 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
4383 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
4384 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
4385 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
4387 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4388 "units %p, units_length %p, description %p, description_length %p stub!\n",
4389 iface, desc, type, active_counters, name, name_length,
4390 units, units_length, description, description_length);
4392 return E_NOTIMPL;
4395 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
4397 FIXME("iface %p stub!\n", iface);
4399 return 0;
4402 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
4403 HANDLE resource_handle, REFIID guid, void **resource)
4405 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4406 iface, resource_handle, debugstr_guid(guid), resource);
4408 return E_NOTIMPL;
4411 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
4413 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
4416 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
4418 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
4421 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
4423 FIXME("iface %p stub!\n", iface);
4425 return D3D10_FEATURE_LEVEL_10_1;
4428 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
4430 /* IUnknown methods */
4431 d3d10_device_QueryInterface,
4432 d3d10_device_AddRef,
4433 d3d10_device_Release,
4434 /* ID3D10Device methods */
4435 d3d10_device_VSSetConstantBuffers,
4436 d3d10_device_PSSetShaderResources,
4437 d3d10_device_PSSetShader,
4438 d3d10_device_PSSetSamplers,
4439 d3d10_device_VSSetShader,
4440 d3d10_device_DrawIndexed,
4441 d3d10_device_Draw,
4442 d3d10_device_PSSetConstantBuffers,
4443 d3d10_device_IASetInputLayout,
4444 d3d10_device_IASetVertexBuffers,
4445 d3d10_device_IASetIndexBuffer,
4446 d3d10_device_DrawIndexedInstanced,
4447 d3d10_device_DrawInstanced,
4448 d3d10_device_GSSetConstantBuffers,
4449 d3d10_device_GSSetShader,
4450 d3d10_device_IASetPrimitiveTopology,
4451 d3d10_device_VSSetShaderResources,
4452 d3d10_device_VSSetSamplers,
4453 d3d10_device_SetPredication,
4454 d3d10_device_GSSetShaderResources,
4455 d3d10_device_GSSetSamplers,
4456 d3d10_device_OMSetRenderTargets,
4457 d3d10_device_OMSetBlendState,
4458 d3d10_device_OMSetDepthStencilState,
4459 d3d10_device_SOSetTargets,
4460 d3d10_device_DrawAuto,
4461 d3d10_device_RSSetState,
4462 d3d10_device_RSSetViewports,
4463 d3d10_device_RSSetScissorRects,
4464 d3d10_device_CopySubresourceRegion,
4465 d3d10_device_CopyResource,
4466 d3d10_device_UpdateSubresource,
4467 d3d10_device_ClearRenderTargetView,
4468 d3d10_device_ClearDepthStencilView,
4469 d3d10_device_GenerateMips,
4470 d3d10_device_ResolveSubresource,
4471 d3d10_device_VSGetConstantBuffers,
4472 d3d10_device_PSGetShaderResources,
4473 d3d10_device_PSGetShader,
4474 d3d10_device_PSGetSamplers,
4475 d3d10_device_VSGetShader,
4476 d3d10_device_PSGetConstantBuffers,
4477 d3d10_device_IAGetInputLayout,
4478 d3d10_device_IAGetVertexBuffers,
4479 d3d10_device_IAGetIndexBuffer,
4480 d3d10_device_GSGetConstantBuffers,
4481 d3d10_device_GSGetShader,
4482 d3d10_device_IAGetPrimitiveTopology,
4483 d3d10_device_VSGetShaderResources,
4484 d3d10_device_VSGetSamplers,
4485 d3d10_device_GetPredication,
4486 d3d10_device_GSGetShaderResources,
4487 d3d10_device_GSGetSamplers,
4488 d3d10_device_OMGetRenderTargets,
4489 d3d10_device_OMGetBlendState,
4490 d3d10_device_OMGetDepthStencilState,
4491 d3d10_device_SOGetTargets,
4492 d3d10_device_RSGetState,
4493 d3d10_device_RSGetViewports,
4494 d3d10_device_RSGetScissorRects,
4495 d3d10_device_GetDeviceRemovedReason,
4496 d3d10_device_SetExceptionMode,
4497 d3d10_device_GetExceptionMode,
4498 d3d10_device_GetPrivateData,
4499 d3d10_device_SetPrivateData,
4500 d3d10_device_SetPrivateDataInterface,
4501 d3d10_device_ClearState,
4502 d3d10_device_Flush,
4503 d3d10_device_CreateBuffer,
4504 d3d10_device_CreateTexture1D,
4505 d3d10_device_CreateTexture2D,
4506 d3d10_device_CreateTexture3D,
4507 d3d10_device_CreateShaderResourceView,
4508 d3d10_device_CreateRenderTargetView,
4509 d3d10_device_CreateDepthStencilView,
4510 d3d10_device_CreateInputLayout,
4511 d3d10_device_CreateVertexShader,
4512 d3d10_device_CreateGeometryShader,
4513 d3d10_device_CreateGeometryShaderWithStreamOutput,
4514 d3d10_device_CreatePixelShader,
4515 d3d10_device_CreateBlendState,
4516 d3d10_device_CreateDepthStencilState,
4517 d3d10_device_CreateRasterizerState,
4518 d3d10_device_CreateSamplerState,
4519 d3d10_device_CreateQuery,
4520 d3d10_device_CreatePredicate,
4521 d3d10_device_CreateCounter,
4522 d3d10_device_CheckFormatSupport,
4523 d3d10_device_CheckMultisampleQualityLevels,
4524 d3d10_device_CheckCounterInfo,
4525 d3d10_device_CheckCounter,
4526 d3d10_device_GetCreationFlags,
4527 d3d10_device_OpenSharedResource,
4528 d3d10_device_SetTextFilterSize,
4529 d3d10_device_GetTextFilterSize,
4530 d3d10_device_CreateShaderResourceView1,
4531 d3d10_device_CreateBlendState1,
4532 d3d10_device_GetFeatureLevel,
4535 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl =
4537 /* IUnknown methods */
4538 d3d_device_inner_QueryInterface,
4539 d3d_device_inner_AddRef,
4540 d3d_device_inner_Release,
4543 /* ID3D10Multithread methods */
4545 static inline struct d3d_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
4547 return CONTAINING_RECORD(iface, struct d3d_device, ID3D10Multithread_iface);
4550 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
4552 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4554 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
4556 return IUnknown_QueryInterface(device->outer_unk, iid, out);
4559 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
4561 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4563 TRACE("iface %p.\n", iface);
4565 return IUnknown_AddRef(device->outer_unk);
4568 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
4570 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4572 TRACE("iface %p.\n", iface);
4574 return IUnknown_Release(device->outer_unk);
4577 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
4579 TRACE("iface %p.\n", iface);
4581 wined3d_mutex_lock();
4584 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
4586 TRACE("iface %p.\n", iface);
4588 wined3d_mutex_unlock();
4591 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
4593 FIXME("iface %p, protect %#x stub!\n", iface, protect);
4595 return TRUE;
4598 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
4600 FIXME("iface %p stub!\n", iface);
4602 return TRUE;
4605 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
4607 d3d10_multithread_QueryInterface,
4608 d3d10_multithread_AddRef,
4609 d3d10_multithread_Release,
4610 d3d10_multithread_Enter,
4611 d3d10_multithread_Leave,
4612 d3d10_multithread_SetMultithreadProtected,
4613 d3d10_multithread_GetMultithreadProtected,
4616 /* IWineDXGIDeviceParent IUnknown methods */
4618 static inline struct d3d_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
4620 return CONTAINING_RECORD(iface, struct d3d_device, IWineDXGIDeviceParent_iface);
4623 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
4624 REFIID riid, void **ppv)
4626 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4627 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
4630 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
4632 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4633 return IUnknown_AddRef(device->outer_unk);
4636 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
4638 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4639 return IUnknown_Release(device->outer_unk);
4642 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
4643 IWineDXGIDeviceParent *iface)
4645 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4646 return &device->device_parent;
4649 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl =
4651 /* IUnknown methods */
4652 dxgi_device_parent_QueryInterface,
4653 dxgi_device_parent_AddRef,
4654 dxgi_device_parent_Release,
4655 /* IWineDXGIDeviceParent methods */
4656 dxgi_device_parent_get_wined3d_device_parent,
4659 static inline struct d3d_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
4661 return CONTAINING_RECORD(device_parent, struct d3d_device, device_parent);
4664 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
4665 struct wined3d_device *wined3d_device)
4667 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4669 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
4671 wined3d_device_incref(wined3d_device);
4672 device->wined3d_device = wined3d_device;
4675 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
4677 TRACE("device_parent %p.\n", device_parent);
4680 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
4682 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
4685 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
4686 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface, void **parent,
4687 const struct wined3d_parent_ops **parent_ops)
4689 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
4690 device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
4692 *parent = NULL;
4693 *parent_ops = &d3d_null_wined3d_parent_ops;
4695 return S_OK;
4698 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
4699 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, void **parent,
4700 const struct wined3d_parent_ops **parent_ops)
4702 TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
4703 device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
4705 *parent = NULL;
4706 *parent_ops = &d3d_null_wined3d_parent_ops;
4708 return S_OK;
4711 static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
4712 void *container_parent, const struct wined3d_resource_desc *wined3d_desc,
4713 struct wined3d_texture **wined3d_texture)
4715 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4716 struct d3d_texture2d *texture;
4717 ID3D10Texture2D *texture_iface;
4718 D3D10_TEXTURE2D_DESC desc;
4719 HRESULT hr;
4721 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
4722 device_parent, container_parent, wined3d_desc, wined3d_texture);
4724 FIXME("Implement DXGI<->wined3d usage conversion\n");
4726 desc.Width = wined3d_desc->width;
4727 desc.Height = wined3d_desc->height;
4728 desc.MipLevels = 1;
4729 desc.ArraySize = 1;
4730 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
4731 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
4732 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
4733 desc.Usage = D3D10_USAGE_DEFAULT;
4734 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
4735 desc.CPUAccessFlags = 0;
4736 desc.MiscFlags = 0;
4738 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
4739 &desc, NULL, &texture_iface)))
4741 ERR("CreateTexture2D failed, returning %#x\n", hr);
4742 return hr;
4745 texture = impl_from_ID3D10Texture2D(texture_iface);
4747 *wined3d_texture = texture->wined3d_texture;
4748 wined3d_texture_incref(*wined3d_texture);
4749 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
4751 return S_OK;
4754 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
4755 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
4757 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4758 IWineDXGIDevice *wine_device;
4759 HRESULT hr;
4761 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
4763 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
4764 &IID_IWineDXGIDevice, (void **)&wine_device)))
4766 ERR("Device should implement IWineDXGIDevice.\n");
4767 return E_FAIL;
4770 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
4771 IWineDXGIDevice_Release(wine_device);
4772 if (FAILED(hr))
4774 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
4775 return hr;
4778 return S_OK;
4781 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops =
4783 device_parent_wined3d_device_created,
4784 device_parent_mode_changed,
4785 device_parent_activate,
4786 device_parent_surface_created,
4787 device_parent_volume_created,
4788 device_parent_create_swapchain_texture,
4789 device_parent_create_swapchain,
4792 static void *d3d_rb_alloc(size_t size)
4794 return HeapAlloc(GetProcessHeap(), 0, size);
4797 static void *d3d_rb_realloc(void *ptr, size_t size)
4799 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
4802 static void d3d_rb_free(void *ptr)
4804 HeapFree(GetProcessHeap(), 0, ptr);
4807 static int d3d_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
4809 const D3D11_SAMPLER_DESC *ka = key;
4810 const D3D11_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_sampler_state, entry)->desc;
4812 return memcmp(ka, kb, sizeof(*ka));
4815 static const struct wine_rb_functions d3d_sampler_state_rb_ops =
4817 d3d_rb_alloc,
4818 d3d_rb_realloc,
4819 d3d_rb_free,
4820 d3d_sampler_state_compare,
4823 static int d3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
4825 const D3D11_BLEND_DESC *ka = key;
4826 const D3D11_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_blend_state, entry)->desc;
4828 return memcmp(ka, kb, sizeof(*ka));
4831 static const struct wine_rb_functions d3d_blend_state_rb_ops =
4833 d3d_rb_alloc,
4834 d3d_rb_realloc,
4835 d3d_rb_free,
4836 d3d_blend_state_compare,
4839 static int d3d_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
4841 const D3D11_DEPTH_STENCIL_DESC *ka = key;
4842 const D3D11_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
4843 const struct d3d_depthstencil_state, entry)->desc;
4845 return memcmp(ka, kb, sizeof(*ka));
4848 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops =
4850 d3d_rb_alloc,
4851 d3d_rb_realloc,
4852 d3d_rb_free,
4853 d3d_depthstencil_state_compare,
4856 static int d3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
4858 const D3D11_RASTERIZER_DESC *ka = key;
4859 const D3D11_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_rasterizer_state, entry)->desc;
4861 return memcmp(ka, kb, sizeof(*ka));
4864 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops =
4866 d3d_rb_alloc,
4867 d3d_rb_realloc,
4868 d3d_rb_free,
4869 d3d_rasterizer_state_compare,
4872 HRESULT d3d_device_init(struct d3d_device *device, void *outer_unknown)
4874 device->IUnknown_inner.lpVtbl = &d3d_device_inner_unknown_vtbl;
4875 device->ID3D11Device_iface.lpVtbl = &d3d11_device_vtbl;
4876 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
4877 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
4878 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d_dxgi_device_parent_vtbl;
4879 device->device_parent.ops = &d3d_wined3d_device_parent_ops;
4880 device->refcount = 1;
4881 /* COM aggregation always takes place */
4882 device->outer_unk = outer_unknown;
4884 if (FAILED(d3d11_immediate_context_init(&device->immediate_context, device)))
4886 WARN("Failed to initialize immediate device context.\n");
4887 return E_FAIL;
4889 ID3D11DeviceContext_Release(&device->immediate_context.ID3D11DeviceContext_iface);
4891 if (wine_rb_init(&device->blend_states, &d3d_blend_state_rb_ops) == -1)
4893 WARN("Failed to initialize blend state rbtree.\n");
4894 return E_FAIL;
4896 device->blend_factor[0] = 1.0f;
4897 device->blend_factor[1] = 1.0f;
4898 device->blend_factor[2] = 1.0f;
4899 device->blend_factor[3] = 1.0f;
4901 if (wine_rb_init(&device->depthstencil_states, &d3d_depthstencil_state_rb_ops) == -1)
4903 WARN("Failed to initialize depthstencil state rbtree.\n");
4904 wine_rb_destroy(&device->blend_states, NULL, NULL);
4905 return E_FAIL;
4908 if (wine_rb_init(&device->rasterizer_states, &d3d_rasterizer_state_rb_ops) == -1)
4910 WARN("Failed to initialize rasterizer state rbtree.\n");
4911 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
4912 wine_rb_destroy(&device->blend_states, NULL, NULL);
4913 return E_FAIL;
4916 if (wine_rb_init(&device->sampler_states, &d3d_sampler_state_rb_ops) == -1)
4918 WARN("Failed to initialize sampler state rbtree.\n");
4919 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
4920 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
4921 wine_rb_destroy(&device->blend_states, NULL, NULL);
4922 return E_FAIL;
4925 return S_OK;