2 * Copyright 2008-2012 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
23 #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 static 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
);
62 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
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
);
77 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
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
);
93 ID3D11Device_Release(&device
->ID3D11Device_iface
);
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 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
114 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
116 return d3d_get_private_data(&context
->private_store
, guid
, data_size
, data
);
119 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext
*iface
, REFGUID guid
,
120 UINT data_size
, const void *data
)
122 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
124 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
126 return d3d_set_private_data(&context
->private_store
, guid
, data_size
, data
);
129 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext
*iface
,
130 REFGUID guid
, const IUnknown
*data
)
132 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
134 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
136 return d3d_set_private_data_interface(&context
->private_store
, guid
, data
);
139 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext
*iface
,
140 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
142 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
145 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
146 iface
, start_slot
, buffer_count
, buffers
);
148 wined3d_mutex_lock();
149 for (i
= 0; i
< buffer_count
; ++i
)
151 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
153 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
154 buffer
? buffer
->wined3d_buffer
: NULL
);
156 wined3d_mutex_unlock();
159 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext
*iface
,
160 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
162 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
165 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
166 iface
, start_slot
, view_count
, views
);
168 wined3d_mutex_lock();
169 for (i
= 0; i
< view_count
; ++i
)
171 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
173 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
174 view
? view
->wined3d_view
: NULL
);
176 wined3d_mutex_unlock();
179 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShader(ID3D11DeviceContext
*iface
,
180 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
182 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
183 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
185 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
186 iface
, shader
, class_instances
, class_instance_count
);
189 FIXME("Dynamic linking is not implemented yet.\n");
191 wined3d_mutex_lock();
192 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
193 wined3d_mutex_unlock();
196 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext
*iface
,
197 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
199 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
202 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
203 iface
, start_slot
, sampler_count
, samplers
);
205 wined3d_mutex_lock();
206 for (i
= 0; i
< sampler_count
; ++i
)
208 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
210 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
211 sampler
? sampler
->wined3d_sampler
: NULL
);
213 wined3d_mutex_unlock();
216 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShader(ID3D11DeviceContext
*iface
,
217 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
219 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
220 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
222 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
223 iface
, shader
, class_instances
, class_instance_count
);
226 FIXME("Dynamic linking is not implemented yet.\n");
228 wined3d_mutex_lock();
229 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
230 wined3d_mutex_unlock();
233 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext
*iface
,
234 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
236 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
238 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
239 iface
, index_count
, start_index_location
, base_vertex_location
);
241 wined3d_mutex_lock();
242 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
243 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
244 wined3d_mutex_unlock();
247 static void STDMETHODCALLTYPE
d3d11_immediate_context_Draw(ID3D11DeviceContext
*iface
,
248 UINT vertex_count
, UINT start_vertex_location
)
250 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
252 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
253 iface
, vertex_count
, start_vertex_location
);
255 wined3d_mutex_lock();
256 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
257 wined3d_mutex_unlock();
260 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_Map(ID3D11DeviceContext
*iface
, ID3D11Resource
*resource
,
261 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
263 struct wined3d_resource
*wined3d_resource
;
264 struct wined3d_map_desc map_desc
;
267 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
268 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
271 FIXME("Ignoring map_flags %#x.\n", map_flags
);
273 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
275 wined3d_mutex_lock();
276 hr
= wined3d_resource_map(wined3d_resource
, subresource_idx
,
277 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
278 wined3d_mutex_unlock();
280 mapped_subresource
->pData
= map_desc
.data
;
281 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
282 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
287 static void STDMETHODCALLTYPE
d3d11_immediate_context_Unmap(ID3D11DeviceContext
*iface
, ID3D11Resource
*resource
,
288 UINT subresource_idx
)
290 struct wined3d_resource
*wined3d_resource
;
292 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
294 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
296 wined3d_mutex_lock();
297 wined3d_resource_unmap(wined3d_resource
, subresource_idx
);
298 wined3d_mutex_unlock();
301 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext
*iface
,
302 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
304 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
307 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
308 iface
, start_slot
, buffer_count
, buffers
);
310 wined3d_mutex_lock();
311 for (i
= 0; i
< buffer_count
; ++i
)
313 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
315 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
316 buffer
? buffer
->wined3d_buffer
: NULL
);
318 wined3d_mutex_unlock();
321 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext
*iface
,
322 ID3D11InputLayout
*input_layout
)
324 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
325 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
327 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
329 wined3d_mutex_lock();
330 wined3d_device_set_vertex_declaration(device
->wined3d_device
, layout
? layout
->wined3d_decl
: NULL
);
331 wined3d_mutex_unlock();
334 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext
*iface
,
335 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
337 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
340 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
341 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
343 wined3d_mutex_lock();
344 for (i
= 0; i
< buffer_count
; ++i
)
346 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
348 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
349 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
351 wined3d_mutex_unlock();
354 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext
*iface
,
355 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
357 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
358 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
360 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
361 iface
, buffer
, debug_dxgi_format(format
), offset
);
363 wined3d_mutex_lock();
364 wined3d_device_set_index_buffer(device
->wined3d_device
,
365 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
366 wined3dformat_from_dxgi_format(format
), offset
);
367 wined3d_mutex_unlock();
370 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext
*iface
,
371 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
372 UINT start_instance_location
)
374 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
376 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
377 "base_vertex_location %d, start_instance_location %u.\n",
378 iface
, instance_index_count
, instance_count
, start_index_location
,
379 base_vertex_location
, start_instance_location
);
381 wined3d_mutex_lock();
382 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
383 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
384 instance_index_count
, start_instance_location
, instance_count
);
385 wined3d_mutex_unlock();
388 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext
*iface
,
389 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
391 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
393 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
394 "start_instance_location %u.\n",
395 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
396 start_instance_location
);
398 wined3d_mutex_lock();
399 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
400 instance_vertex_count
, start_instance_location
, instance_count
);
401 wined3d_mutex_unlock();
404 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext
*iface
,
405 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
407 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
410 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
411 iface
, start_slot
, buffer_count
, buffers
);
413 wined3d_mutex_lock();
414 for (i
= 0; i
< buffer_count
; ++i
)
416 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
418 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
419 buffer
? buffer
->wined3d_buffer
: NULL
);
421 wined3d_mutex_unlock();
424 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext
*iface
,
425 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
427 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
428 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
430 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
431 iface
, shader
, class_instances
, class_instance_count
);
434 FIXME("Dynamic linking is not implemented yet.\n");
436 wined3d_mutex_lock();
437 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
438 wined3d_mutex_unlock();
441 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext
*iface
,
442 D3D11_PRIMITIVE_TOPOLOGY topology
)
444 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
445 enum wined3d_primitive_type primitive_type
;
446 unsigned int patch_vertex_count
;
448 TRACE("iface %p, topology %#x.\n", iface
, topology
);
450 wined3d_primitive_type_from_d3d11_primitive_topology(topology
, &primitive_type
, &patch_vertex_count
);
452 wined3d_mutex_lock();
453 wined3d_device_set_primitive_type(device
->wined3d_device
, primitive_type
, patch_vertex_count
);
454 wined3d_mutex_unlock();
457 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext
*iface
,
458 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
460 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
463 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
465 wined3d_mutex_lock();
466 for (i
= 0; i
< view_count
; ++i
)
468 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
470 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
471 view
? view
->wined3d_view
: NULL
);
473 wined3d_mutex_unlock();
476 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext
*iface
,
477 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
479 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
482 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
483 iface
, start_slot
, sampler_count
, samplers
);
485 wined3d_mutex_lock();
486 for (i
= 0; i
< sampler_count
; ++i
)
488 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
490 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
491 sampler
? sampler
->wined3d_sampler
: NULL
);
493 wined3d_mutex_unlock();
496 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext
*iface
,
497 ID3D11Asynchronous
*asynchronous
)
499 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
502 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
504 wined3d_mutex_lock();
505 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_BEGIN
)))
506 ERR("Failed to issue query, hr %#x.\n", hr
);
507 wined3d_mutex_unlock();
510 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext
*iface
,
511 ID3D11Asynchronous
*asynchronous
)
513 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
516 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
518 wined3d_mutex_lock();
519 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_END
)))
520 ERR("Failed to issue query, hr %#x.\n", hr
);
521 wined3d_mutex_unlock();
524 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext
*iface
,
525 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
527 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
528 unsigned int wined3d_flags
;
531 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
532 iface
, asynchronous
, data
, data_size
, data_flags
);
534 if (!data
&& data_size
)
537 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
539 wined3d_mutex_lock();
540 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
542 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
543 if (hr
== WINED3DERR_INVALIDCALL
)
544 hr
= DXGI_ERROR_INVALID_CALL
;
548 WARN("Invalid data size %u.\n", data_size
);
551 wined3d_mutex_unlock();
556 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext
*iface
,
557 ID3D11Predicate
*predicate
, BOOL value
)
559 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
560 struct d3d_query
*query
;
562 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
564 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
566 wined3d_mutex_lock();
567 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
568 wined3d_mutex_unlock();
571 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext
*iface
,
572 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
574 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
577 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
579 wined3d_mutex_lock();
580 for (i
= 0; i
< view_count
; ++i
)
582 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
584 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
585 view
? view
->wined3d_view
: NULL
);
587 wined3d_mutex_unlock();
590 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext
*iface
,
591 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
593 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
596 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
597 iface
, start_slot
, sampler_count
, samplers
);
599 wined3d_mutex_lock();
600 for (i
= 0; i
< sampler_count
; ++i
)
602 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
604 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
605 sampler
? sampler
->wined3d_sampler
: NULL
);
607 wined3d_mutex_unlock();
610 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext
*iface
,
611 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
612 ID3D11DepthStencilView
*depth_stencil_view
)
614 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
615 struct d3d_depthstencil_view
*dsv
;
618 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
619 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
621 wined3d_mutex_lock();
622 for (i
= 0; i
< render_target_view_count
; ++i
)
624 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
625 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
627 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
629 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
632 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
633 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
634 wined3d_mutex_unlock();
637 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
638 ID3D11DeviceContext
*iface
, UINT render_target_view_count
,
639 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
640 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
641 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
643 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
646 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
647 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
648 "initial_counts %p.\n",
649 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
650 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
653 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
655 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
659 if (unordered_access_view_count
!= D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
661 wined3d_mutex_lock();
662 for (i
= 0; i
< unordered_access_view_start_slot
; ++i
)
664 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
666 for (i
= 0; i
< unordered_access_view_count
; ++i
)
668 struct d3d11_unordered_access_view
*view
669 = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views
[i
]);
671 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
672 unordered_access_view_start_slot
+ i
,
673 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
675 for (; unordered_access_view_start_slot
+ i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
677 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
678 unordered_access_view_start_slot
+ i
, NULL
, ~0u);
680 wined3d_mutex_unlock();
684 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
685 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
687 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
688 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
689 const D3D11_BLEND_DESC
*desc
;
691 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
692 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
695 blend_factor
= default_blend_factor
;
697 wined3d_mutex_lock();
698 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
699 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
700 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
702 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
703 wined3d_device_set_render_state(device
->wined3d_device
,
704 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
705 wined3d_device_set_render_state(device
->wined3d_device
,
706 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
707 wined3d_device_set_render_state(device
->wined3d_device
,
708 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
709 wined3d_device_set_render_state(device
->wined3d_device
,
710 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
711 wined3d_mutex_unlock();
715 desc
= &device
->blend_state
->desc
;
716 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
717 desc
->RenderTarget
[0].BlendEnable
);
718 if (desc
->RenderTarget
[0].BlendEnable
)
720 const D3D11_RENDER_TARGET_BLEND_DESC
*d
= &desc
->RenderTarget
[0];
722 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
, d
->SrcBlend
);
723 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
, d
->DestBlend
);
724 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
, d
->BlendOp
);
725 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
726 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
, d
->SrcBlendAlpha
);
727 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
, d
->DestBlendAlpha
);
728 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
, d
->BlendOpAlpha
);
730 if (memcmp(blend_factor
, default_blend_factor
, sizeof(default_blend_factor
))
731 && (d
->SrcBlend
== D3D11_BLEND_BLEND_FACTOR
|| d
->SrcBlend
== D3D11_BLEND_INV_BLEND_FACTOR
732 || d
->DestBlend
== D3D11_BLEND_BLEND_FACTOR
|| d
->DestBlend
== D3D11_BLEND_INV_BLEND_FACTOR
733 || d
->SrcBlendAlpha
== D3D11_BLEND_BLEND_FACTOR
|| d
->SrcBlendAlpha
== D3D11_BLEND_INV_BLEND_FACTOR
734 || d
->DestBlendAlpha
== D3D11_BLEND_BLEND_FACTOR
|| d
->DestBlendAlpha
== D3D11_BLEND_INV_BLEND_FACTOR
))
735 FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor
));
737 wined3d_device_set_render_state(device
->wined3d_device
,
738 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
739 wined3d_device_set_render_state(device
->wined3d_device
,
740 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
741 wined3d_device_set_render_state(device
->wined3d_device
,
742 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
743 wined3d_device_set_render_state(device
->wined3d_device
,
744 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
745 wined3d_mutex_unlock();
748 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
749 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
751 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
752 const D3D11_DEPTH_STENCILOP_DESC
*front
, *back
;
753 const D3D11_DEPTH_STENCIL_DESC
*desc
;
755 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
756 iface
, depth_stencil_state
, stencil_ref
);
758 wined3d_mutex_lock();
759 device
->stencil_ref
= stencil_ref
;
760 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
762 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
763 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
764 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, D3D11_COMPARISON_LESS
);
765 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
766 wined3d_mutex_unlock();
770 desc
= &device
->depth_stencil_state
->desc
;
772 front
= &desc
->FrontFace
;
773 back
= &desc
->BackFace
;
775 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
776 if (desc
->DepthEnable
)
778 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
779 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
782 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
783 if (desc
->StencilEnable
)
785 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
786 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
787 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
789 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, front
->StencilFailOp
);
790 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
, front
->StencilDepthFailOp
);
791 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, front
->StencilPassOp
);
792 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, front
->StencilFunc
);
793 if (front
->StencilFailOp
!= back
->StencilFailOp
794 || front
->StencilDepthFailOp
!= back
->StencilDepthFailOp
795 || front
->StencilPassOp
!= back
->StencilPassOp
796 || front
->StencilFunc
!= back
->StencilFunc
)
798 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_TWOSIDEDSTENCILMODE
, TRUE
);
799 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILFAIL
, back
->StencilFailOp
);
800 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILZFAIL
,
801 back
->StencilDepthFailOp
);
802 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILPASS
, back
->StencilPassOp
);
803 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILFUNC
, back
->StencilFunc
);
807 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_TWOSIDEDSTENCILMODE
, FALSE
);
810 wined3d_mutex_unlock();
813 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
814 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
816 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
817 unsigned int count
, i
;
819 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
821 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
822 wined3d_mutex_lock();
823 for (i
= 0; i
< count
; ++i
)
825 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
827 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
828 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
? offsets
[i
] : 0);
830 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
832 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
834 wined3d_mutex_unlock();
837 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
839 FIXME("iface %p stub!\n", iface
);
842 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext
*iface
,
843 ID3D11Buffer
*buffer
, UINT offset
)
845 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
846 struct d3d_buffer
*d3d_buffer
;
848 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
850 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
852 wined3d_mutex_lock();
853 wined3d_device_draw_indexed_primitive_instanced_indirect(device
->wined3d_device
,
854 d3d_buffer
->wined3d_buffer
, offset
);
855 wined3d_mutex_unlock();
858 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
859 ID3D11Buffer
*buffer
, UINT offset
)
861 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
862 struct d3d_buffer
*d3d_buffer
;
864 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
866 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
868 wined3d_mutex_lock();
869 wined3d_device_draw_primitive_instanced_indirect(device
->wined3d_device
,
870 d3d_buffer
->wined3d_buffer
, offset
);
871 wined3d_mutex_unlock();
874 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
875 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
877 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
879 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
880 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
882 wined3d_mutex_lock();
883 wined3d_device_dispatch_compute(device
->wined3d_device
,
884 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
885 wined3d_mutex_unlock();
888 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
889 ID3D11Buffer
*buffer
, UINT offset
)
891 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
892 struct d3d_buffer
*buffer_impl
;
894 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
896 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
898 wined3d_mutex_lock();
899 wined3d_device_dispatch_compute_indirect(device
->wined3d_device
,
900 buffer_impl
->wined3d_buffer
, offset
);
901 wined3d_mutex_unlock();
904 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
905 ID3D11RasterizerState
*rasterizer_state
)
907 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
908 struct d3d_rasterizer_state
*rasterizer_state_impl
;
909 const D3D11_RASTERIZER_DESC
*desc
;
911 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
913 wined3d_mutex_lock();
914 if (!(rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
916 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
917 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
918 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_BACK
);
919 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
920 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
921 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
922 wined3d_mutex_unlock();
926 wined3d_device_set_rasterizer_state(device
->wined3d_device
, rasterizer_state_impl
->wined3d_state
);
928 desc
= &rasterizer_state_impl
->desc
;
929 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
930 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
931 /* OpenGL style depth bias. */
932 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
933 FIXME("Ignoring depth bias.\n");
935 if (!desc
->DepthClipEnable
)
936 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
937 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
938 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
939 wined3d_device_set_render_state(device
->wined3d_device
,
940 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
941 wined3d_mutex_unlock();
944 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
945 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
947 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
948 struct wined3d_viewport wined3d_vp
;
950 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
952 if (viewport_count
> 1)
953 FIXME("Multiple viewports not implemented.\n");
958 wined3d_vp
.x
= viewports
[0].TopLeftX
;
959 wined3d_vp
.y
= viewports
[0].TopLeftY
;
960 wined3d_vp
.width
= viewports
[0].Width
;
961 wined3d_vp
.height
= viewports
[0].Height
;
962 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
963 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
965 wined3d_mutex_lock();
966 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
967 wined3d_mutex_unlock();
970 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
971 UINT rect_count
, const D3D11_RECT
*rects
)
973 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
975 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
978 FIXME("Multiple scissor rects not implemented.\n");
983 wined3d_mutex_lock();
984 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
985 wined3d_mutex_unlock();
988 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
989 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
990 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
992 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
993 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
994 struct wined3d_box wined3d_src_box
;
996 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
997 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
998 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
999 src_resource
, src_subresource_idx
, src_box
);
1002 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
1003 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
1005 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1006 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1007 wined3d_mutex_lock();
1008 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
1009 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
1010 wined3d_mutex_unlock();
1013 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
1014 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
1016 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1017 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1019 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1021 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1022 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1023 wined3d_mutex_lock();
1024 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1025 wined3d_mutex_unlock();
1028 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
1029 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1030 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1032 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1033 struct wined3d_resource
*wined3d_resource
;
1034 struct wined3d_box wined3d_box
;
1036 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1037 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1040 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1042 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1043 wined3d_mutex_lock();
1044 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1045 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
1046 wined3d_mutex_unlock();
1049 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
1050 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1052 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1053 struct d3d11_unordered_access_view
*uav
;
1054 struct d3d_buffer
*buffer_impl
;
1056 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1057 iface
, dst_buffer
, dst_offset
, src_view
);
1059 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1060 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1062 wined3d_mutex_lock();
1063 wined3d_device_copy_uav_counter(device
->wined3d_device
,
1064 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1065 wined3d_mutex_unlock();
1068 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
1069 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1071 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1072 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1073 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1076 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1077 iface
, render_target_view
, debug_float4(color_rgba
));
1082 wined3d_mutex_lock();
1083 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1084 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1085 ERR("Failed to clear view, hr %#x.\n", hr
);
1086 wined3d_mutex_unlock();
1089 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
1090 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1092 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1093 struct d3d11_unordered_access_view
*view
;
1095 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1096 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1098 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1099 wined3d_mutex_lock();
1100 wined3d_device_clear_unordered_access_view_uint(device
->wined3d_device
,
1101 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1102 wined3d_mutex_unlock();
1105 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
1106 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1108 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1109 iface
, unordered_access_view
, debug_float4(values
));
1112 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
1113 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1115 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1116 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1117 DWORD wined3d_flags
;
1120 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1121 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1126 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1128 wined3d_mutex_lock();
1129 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1130 wined3d_flags
, NULL
, depth
, stencil
)))
1131 ERR("Failed to clear view, hr %#x.\n", hr
);
1132 wined3d_mutex_unlock();
1135 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1136 ID3D11ShaderResourceView
*view
)
1138 FIXME("iface %p, view %p stub!\n", iface
, view
);
1141 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1142 ID3D11Resource
*resource
, FLOAT min_lod
)
1144 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1147 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1148 ID3D11Resource
*resource
)
1150 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1155 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1156 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1157 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1160 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1161 "format %s stub!\n",
1162 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1163 debug_dxgi_format(format
));
1166 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1167 ID3D11CommandList
*command_list
, BOOL restore_state
)
1169 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1172 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1173 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1175 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1178 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1179 iface
, start_slot
, view_count
, views
);
1181 wined3d_mutex_lock();
1182 for (i
= 0; i
< view_count
; ++i
)
1184 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1186 wined3d_device_set_hs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1187 view
? view
->wined3d_view
: NULL
);
1189 wined3d_mutex_unlock();
1192 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1193 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1195 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1196 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1198 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1199 iface
, shader
, class_instances
, class_instance_count
);
1201 if (class_instances
)
1202 FIXME("Dynamic linking is not implemented yet.\n");
1204 wined3d_mutex_lock();
1205 wined3d_device_set_hull_shader(device
->wined3d_device
, hs
? hs
->wined3d_shader
: NULL
);
1206 wined3d_mutex_unlock();
1209 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1210 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1212 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1215 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1216 iface
, start_slot
, sampler_count
, samplers
);
1218 wined3d_mutex_lock();
1219 for (i
= 0; i
< sampler_count
; ++i
)
1221 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1223 wined3d_device_set_hs_sampler(device
->wined3d_device
, start_slot
+ i
,
1224 sampler
? sampler
->wined3d_sampler
: NULL
);
1226 wined3d_mutex_unlock();
1229 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1230 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1232 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1235 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1236 iface
, start_slot
, buffer_count
, buffers
);
1238 wined3d_mutex_lock();
1239 for (i
= 0; i
< buffer_count
; ++i
)
1241 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1243 wined3d_device_set_hs_cb(device
->wined3d_device
, start_slot
+ i
,
1244 buffer
? buffer
->wined3d_buffer
: NULL
);
1246 wined3d_mutex_unlock();
1249 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1250 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1252 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1255 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1256 iface
, start_slot
, view_count
, views
);
1258 wined3d_mutex_lock();
1259 for (i
= 0; i
< view_count
; ++i
)
1261 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1263 wined3d_device_set_ds_resource_view(device
->wined3d_device
, start_slot
+ i
,
1264 view
? view
->wined3d_view
: NULL
);
1266 wined3d_mutex_unlock();
1269 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1270 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1272 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1273 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1275 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1276 iface
, shader
, class_instances
, class_instance_count
);
1278 if (class_instances
)
1279 FIXME("Dynamic linking is not implemented yet.\n");
1281 wined3d_mutex_lock();
1282 wined3d_device_set_domain_shader(device
->wined3d_device
, ds
? ds
->wined3d_shader
: NULL
);
1283 wined3d_mutex_unlock();
1286 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1287 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1289 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1292 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1293 iface
, start_slot
, sampler_count
, samplers
);
1295 wined3d_mutex_lock();
1296 for (i
= 0; i
< sampler_count
; ++i
)
1298 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1300 wined3d_device_set_ds_sampler(device
->wined3d_device
, start_slot
+ i
,
1301 sampler
? sampler
->wined3d_sampler
: NULL
);
1303 wined3d_mutex_unlock();
1306 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1307 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1309 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1312 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1313 iface
, start_slot
, buffer_count
, buffers
);
1315 wined3d_mutex_lock();
1316 for (i
= 0; i
< buffer_count
; ++i
)
1318 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1320 wined3d_device_set_ds_cb(device
->wined3d_device
, start_slot
+ i
,
1321 buffer
? buffer
->wined3d_buffer
: NULL
);
1323 wined3d_mutex_unlock();
1326 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1327 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1329 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1332 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1333 iface
, start_slot
, view_count
, views
);
1335 wined3d_mutex_lock();
1336 for (i
= 0; i
< view_count
; ++i
)
1338 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1340 wined3d_device_set_cs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1341 view
? view
->wined3d_view
: NULL
);
1343 wined3d_mutex_unlock();
1346 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1347 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1349 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1352 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1353 iface
, start_slot
, view_count
, views
, initial_counts
);
1355 wined3d_mutex_lock();
1356 for (i
= 0; i
< view_count
; ++i
)
1358 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1360 wined3d_device_set_cs_uav(device
->wined3d_device
, start_slot
+ i
,
1361 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
1363 wined3d_mutex_unlock();
1366 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1367 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1369 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1370 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1372 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1373 iface
, shader
, class_instances
, class_instance_count
);
1375 if (class_instances
)
1376 FIXME("Dynamic linking is not implemented yet.\n");
1378 wined3d_mutex_lock();
1379 wined3d_device_set_compute_shader(device
->wined3d_device
, cs
? cs
->wined3d_shader
: NULL
);
1380 wined3d_mutex_unlock();
1383 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1384 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1386 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1389 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1390 iface
, start_slot
, sampler_count
, samplers
);
1392 wined3d_mutex_lock();
1393 for (i
= 0; i
< sampler_count
; ++i
)
1395 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1397 wined3d_device_set_cs_sampler(device
->wined3d_device
, start_slot
+ i
,
1398 sampler
? sampler
->wined3d_sampler
: NULL
);
1400 wined3d_mutex_unlock();
1403 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1404 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1406 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1409 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1410 iface
, start_slot
, buffer_count
, buffers
);
1412 wined3d_mutex_lock();
1413 for (i
= 0; i
< buffer_count
; ++i
)
1415 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1417 wined3d_device_set_cs_cb(device
->wined3d_device
, start_slot
+ i
,
1418 buffer
? buffer
->wined3d_buffer
: NULL
);
1420 wined3d_mutex_unlock();
1423 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1424 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1426 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1429 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1430 iface
, start_slot
, buffer_count
, buffers
);
1432 wined3d_mutex_lock();
1433 for (i
= 0; i
< buffer_count
; ++i
)
1435 struct wined3d_buffer
*wined3d_buffer
;
1436 struct d3d_buffer
*buffer_impl
;
1438 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1444 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1445 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1446 ID3D11Buffer_AddRef(buffers
[i
]);
1448 wined3d_mutex_unlock();
1451 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1452 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1454 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1457 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1458 iface
, start_slot
, view_count
, views
);
1460 wined3d_mutex_lock();
1461 for (i
= 0; i
< view_count
; ++i
)
1463 struct wined3d_shader_resource_view
*wined3d_view
;
1464 struct d3d_shader_resource_view
*view_impl
;
1466 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1472 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1473 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1474 ID3D11ShaderResourceView_AddRef(views
[i
]);
1476 wined3d_mutex_unlock();
1479 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1480 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1482 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1483 struct wined3d_shader
*wined3d_shader
;
1484 struct d3d_pixel_shader
*shader_impl
;
1486 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1487 iface
, shader
, class_instances
, class_instance_count
);
1489 if (class_instances
|| class_instance_count
)
1490 FIXME("Dynamic linking not implemented yet.\n");
1492 wined3d_mutex_lock();
1493 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1495 wined3d_mutex_unlock();
1500 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1501 wined3d_mutex_unlock();
1502 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1503 ID3D11PixelShader_AddRef(*shader
);
1506 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1507 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1509 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1512 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1513 iface
, start_slot
, sampler_count
, samplers
);
1515 wined3d_mutex_lock();
1516 for (i
= 0; i
< sampler_count
; ++i
)
1518 struct wined3d_sampler
*wined3d_sampler
;
1519 struct d3d_sampler_state
*sampler_impl
;
1521 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1527 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1528 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1529 ID3D11SamplerState_AddRef(samplers
[i
]);
1531 wined3d_mutex_unlock();
1534 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1535 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1537 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1538 struct d3d_vertex_shader
*shader_impl
;
1539 struct wined3d_shader
*wined3d_shader
;
1541 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1542 iface
, shader
, class_instances
, class_instance_count
);
1544 if (class_instances
|| class_instance_count
)
1545 FIXME("Dynamic linking not implemented yet.\n");
1547 wined3d_mutex_lock();
1548 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1550 wined3d_mutex_unlock();
1555 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1556 wined3d_mutex_unlock();
1557 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1558 ID3D11VertexShader_AddRef(*shader
);
1561 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1562 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1564 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1567 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1568 iface
, start_slot
, buffer_count
, buffers
);
1570 wined3d_mutex_lock();
1571 for (i
= 0; i
< buffer_count
; ++i
)
1573 struct wined3d_buffer
*wined3d_buffer
;
1574 struct d3d_buffer
*buffer_impl
;
1576 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1582 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1583 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1584 ID3D11Buffer_AddRef(buffers
[i
]);
1586 wined3d_mutex_unlock();
1589 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1590 ID3D11InputLayout
**input_layout
)
1592 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1593 struct wined3d_vertex_declaration
*wined3d_declaration
;
1594 struct d3d_input_layout
*input_layout_impl
;
1596 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1598 wined3d_mutex_lock();
1599 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1601 wined3d_mutex_unlock();
1602 *input_layout
= NULL
;
1606 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1607 wined3d_mutex_unlock();
1608 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1609 ID3D11InputLayout_AddRef(*input_layout
);
1612 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1613 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1615 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1618 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1619 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1621 wined3d_mutex_lock();
1622 for (i
= 0; i
< buffer_count
; ++i
)
1624 struct wined3d_buffer
*wined3d_buffer
= NULL
;
1625 struct d3d_buffer
*buffer_impl
;
1627 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1628 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1630 FIXME("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1637 if (!wined3d_buffer
)
1643 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1644 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1646 wined3d_mutex_unlock();
1649 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1650 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1652 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1653 enum wined3d_format_id wined3d_format
;
1654 struct wined3d_buffer
*wined3d_buffer
;
1655 struct d3d_buffer
*buffer_impl
;
1657 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1659 wined3d_mutex_lock();
1660 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1661 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1662 if (!wined3d_buffer
)
1664 wined3d_mutex_unlock();
1669 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1670 wined3d_mutex_unlock();
1671 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1674 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1675 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1677 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1680 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1681 iface
, start_slot
, buffer_count
, buffers
);
1683 wined3d_mutex_lock();
1684 for (i
= 0; i
< buffer_count
; ++i
)
1686 struct wined3d_buffer
*wined3d_buffer
;
1687 struct d3d_buffer
*buffer_impl
;
1689 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1695 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1696 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1697 ID3D11Buffer_AddRef(buffers
[i
]);
1699 wined3d_mutex_unlock();
1702 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1703 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1705 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1706 struct d3d_geometry_shader
*shader_impl
;
1707 struct wined3d_shader
*wined3d_shader
;
1709 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1710 iface
, shader
, class_instances
, class_instance_count
);
1712 if (class_instances
|| class_instance_count
)
1713 FIXME("Dynamic linking not implemented yet.\n");
1715 wined3d_mutex_lock();
1716 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1718 wined3d_mutex_unlock();
1723 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1724 wined3d_mutex_unlock();
1725 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1726 ID3D11GeometryShader_AddRef(*shader
);
1729 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1730 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1732 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1733 enum wined3d_primitive_type primitive_type
;
1734 unsigned int patch_vertex_count
;
1736 TRACE("iface %p, topology %p.\n", iface
, topology
);
1738 wined3d_mutex_lock();
1739 wined3d_device_get_primitive_type(device
->wined3d_device
, &primitive_type
, &patch_vertex_count
);
1740 wined3d_mutex_unlock();
1742 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1745 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1746 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1748 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1751 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1753 wined3d_mutex_lock();
1754 for (i
= 0; i
< view_count
; ++i
)
1756 struct wined3d_shader_resource_view
*wined3d_view
;
1757 struct d3d_shader_resource_view
*view_impl
;
1759 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1765 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1766 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1767 ID3D11ShaderResourceView_AddRef(views
[i
]);
1769 wined3d_mutex_unlock();
1772 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1773 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1775 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1778 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1779 iface
, start_slot
, sampler_count
, samplers
);
1781 wined3d_mutex_lock();
1782 for (i
= 0; i
< sampler_count
; ++i
)
1784 struct wined3d_sampler
*wined3d_sampler
;
1785 struct d3d_sampler_state
*sampler_impl
;
1787 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1793 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1794 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1795 ID3D11SamplerState_AddRef(samplers
[i
]);
1797 wined3d_mutex_unlock();
1800 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1801 ID3D11Predicate
**predicate
, BOOL
*value
)
1803 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1804 struct wined3d_query
*wined3d_predicate
;
1805 struct d3d_query
*predicate_impl
;
1807 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1809 wined3d_mutex_lock();
1810 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1812 wined3d_mutex_unlock();
1817 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1818 wined3d_mutex_unlock();
1819 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1820 ID3D11Predicate_AddRef(*predicate
);
1823 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1824 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1826 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1829 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1831 wined3d_mutex_lock();
1832 for (i
= 0; i
< view_count
; ++i
)
1834 struct wined3d_shader_resource_view
*wined3d_view
;
1835 struct d3d_shader_resource_view
*view_impl
;
1837 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1843 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1844 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1845 ID3D11ShaderResourceView_AddRef(views
[i
]);
1847 wined3d_mutex_unlock();
1850 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1851 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1853 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1856 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1857 iface
, start_slot
, sampler_count
, samplers
);
1859 wined3d_mutex_lock();
1860 for (i
= 0; i
< sampler_count
; ++i
)
1862 struct d3d_sampler_state
*sampler_impl
;
1863 struct wined3d_sampler
*wined3d_sampler
;
1865 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1871 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1872 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1873 ID3D11SamplerState_AddRef(samplers
[i
]);
1875 wined3d_mutex_unlock();
1878 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1879 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1880 ID3D11DepthStencilView
**depth_stencil_view
)
1882 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1883 struct wined3d_rendertarget_view
*wined3d_view
;
1885 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1886 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1888 wined3d_mutex_lock();
1889 if (render_target_views
)
1891 struct d3d_rendertarget_view
*view_impl
;
1894 for (i
= 0; i
< render_target_view_count
; ++i
)
1896 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1897 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1899 render_target_views
[i
] = NULL
;
1903 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1904 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1908 if (depth_stencil_view
)
1910 struct d3d_depthstencil_view
*view_impl
;
1912 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1913 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1915 *depth_stencil_view
= NULL
;
1919 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1920 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1923 wined3d_mutex_unlock();
1926 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1927 ID3D11DeviceContext
*iface
,
1928 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1929 ID3D11DepthStencilView
**depth_stencil_view
,
1930 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1931 ID3D11UnorderedAccessView
**unordered_access_views
)
1933 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1934 struct wined3d_unordered_access_view
*wined3d_view
;
1935 struct d3d11_unordered_access_view
*view_impl
;
1938 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1939 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1940 "unordered_access_views %p.\n",
1941 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1942 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1944 if (render_target_views
|| depth_stencil_view
)
1945 d3d11_immediate_context_OMGetRenderTargets(iface
, render_target_view_count
,
1946 render_target_views
, depth_stencil_view
);
1948 if (unordered_access_views
)
1950 wined3d_mutex_lock();
1951 for (i
= 0; i
< unordered_access_view_count
; ++i
)
1953 if (!(wined3d_view
= wined3d_device_get_unordered_access_view(device
->wined3d_device
,
1954 unordered_access_view_start_slot
+ i
)))
1956 unordered_access_views
[i
] = NULL
;
1960 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
1961 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
1962 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
1964 wined3d_mutex_unlock();
1968 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1969 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1971 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1973 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1974 iface
, blend_state
, blend_factor
, sample_mask
);
1976 if ((*blend_state
= device
->blend_state
? &device
->blend_state
->ID3D11BlendState_iface
: NULL
))
1977 ID3D11BlendState_AddRef(*blend_state
);
1978 wined3d_mutex_lock();
1979 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
1980 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1981 wined3d_mutex_unlock();
1984 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1985 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1987 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1989 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1990 iface
, depth_stencil_state
, stencil_ref
);
1992 if ((*depth_stencil_state
= device
->depth_stencil_state
1993 ? &device
->depth_stencil_state
->ID3D11DepthStencilState_iface
: NULL
))
1994 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
1995 *stencil_ref
= device
->stencil_ref
;
1998 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1999 UINT buffer_count
, ID3D11Buffer
**buffers
)
2001 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2004 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
2006 wined3d_mutex_lock();
2007 for (i
= 0; i
< buffer_count
; ++i
)
2009 struct wined3d_buffer
*wined3d_buffer
;
2010 struct d3d_buffer
*buffer_impl
;
2012 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
2018 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2019 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
2020 ID3D11Buffer_AddRef(buffers
[i
]);
2022 wined3d_mutex_unlock();
2025 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
2026 ID3D11RasterizerState
**rasterizer_state
)
2028 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2029 struct d3d_rasterizer_state
*rasterizer_state_impl
;
2030 struct wined3d_rasterizer_state
*wined3d_state
;
2032 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
2034 wined3d_mutex_lock();
2035 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
2037 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
2038 ID3D11RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D11RasterizerState_iface
);
2042 *rasterizer_state
= NULL
;
2044 wined3d_mutex_unlock();
2047 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
2048 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
2050 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2051 struct wined3d_viewport wined3d_vp
;
2053 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2057 *viewport_count
= 1;
2061 if (!*viewport_count
)
2064 wined3d_mutex_lock();
2065 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
2066 wined3d_mutex_unlock();
2068 viewports
[0].TopLeftX
= wined3d_vp
.x
;
2069 viewports
[0].TopLeftY
= wined3d_vp
.y
;
2070 viewports
[0].Width
= wined3d_vp
.width
;
2071 viewports
[0].Height
= wined3d_vp
.height
;
2072 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
2073 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
2075 if (*viewport_count
> 1)
2076 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
2079 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
2080 UINT
*rect_count
, D3D11_RECT
*rects
)
2082 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2084 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2095 wined3d_mutex_lock();
2096 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
2097 wined3d_mutex_unlock();
2098 if (*rect_count
> 1)
2099 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
2102 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
2103 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2105 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2108 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2110 wined3d_mutex_lock();
2111 for (i
= 0; i
< view_count
; ++i
)
2113 struct wined3d_shader_resource_view
*wined3d_view
;
2114 struct d3d_shader_resource_view
*view_impl
;
2116 if (!(wined3d_view
= wined3d_device_get_hs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2122 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2123 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2125 wined3d_mutex_unlock();
2128 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
2129 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2131 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2132 struct d3d11_hull_shader
*shader_impl
;
2133 struct wined3d_shader
*wined3d_shader
;
2135 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2136 iface
, shader
, class_instances
, class_instance_count
);
2138 if (class_instances
|| class_instance_count
)
2139 FIXME("Dynamic linking not implemented yet.\n");
2141 wined3d_mutex_lock();
2142 if (!(wined3d_shader
= wined3d_device_get_hull_shader(device
->wined3d_device
)))
2144 wined3d_mutex_unlock();
2149 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2150 wined3d_mutex_unlock();
2151 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2154 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
2155 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2157 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2160 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2161 iface
, start_slot
, sampler_count
, samplers
);
2163 wined3d_mutex_lock();
2164 for (i
= 0; i
< sampler_count
; ++i
)
2166 struct wined3d_sampler
*wined3d_sampler
;
2167 struct d3d_sampler_state
*sampler_impl
;
2169 if (!(wined3d_sampler
= wined3d_device_get_hs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2175 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2176 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2178 wined3d_mutex_unlock();
2181 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
2182 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2184 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2187 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2188 iface
, start_slot
, buffer_count
, buffers
);
2190 wined3d_mutex_lock();
2191 for (i
= 0; i
< buffer_count
; ++i
)
2193 struct wined3d_buffer
*wined3d_buffer
;
2194 struct d3d_buffer
*buffer_impl
;
2196 if (!(wined3d_buffer
= wined3d_device_get_hs_cb(device
->wined3d_device
, start_slot
+ i
)))
2202 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2203 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
2205 wined3d_mutex_unlock();
2208 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
2209 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2211 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2214 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2215 iface
, start_slot
, view_count
, views
);
2217 wined3d_mutex_lock();
2218 for (i
= 0; i
< view_count
; ++i
)
2220 struct wined3d_shader_resource_view
*wined3d_view
;
2221 struct d3d_shader_resource_view
*view_impl
;
2223 if (!(wined3d_view
= wined3d_device_get_ds_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2229 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2230 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2232 wined3d_mutex_unlock();
2235 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
2236 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2238 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2239 struct d3d11_domain_shader
*shader_impl
;
2240 struct wined3d_shader
*wined3d_shader
;
2242 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2243 iface
, shader
, class_instances
, class_instance_count
);
2245 if (class_instances
|| class_instance_count
)
2246 FIXME("Dynamic linking not implemented yet.\n");
2248 wined3d_mutex_lock();
2249 if (!(wined3d_shader
= wined3d_device_get_domain_shader(device
->wined3d_device
)))
2251 wined3d_mutex_unlock();
2256 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2257 wined3d_mutex_unlock();
2258 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2261 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
2262 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2264 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2267 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2268 iface
, start_slot
, sampler_count
, samplers
);
2270 wined3d_mutex_lock();
2271 for (i
= 0; i
< sampler_count
; ++i
)
2273 struct wined3d_sampler
*wined3d_sampler
;
2274 struct d3d_sampler_state
*sampler_impl
;
2276 if (!(wined3d_sampler
= wined3d_device_get_ds_sampler(device
->wined3d_device
, start_slot
+ i
)))
2282 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2283 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2285 wined3d_mutex_unlock();
2288 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
2289 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2291 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2294 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2295 iface
, start_slot
, buffer_count
, buffers
);
2297 wined3d_mutex_lock();
2298 for (i
= 0; i
< buffer_count
; ++i
)
2300 struct wined3d_buffer
*wined3d_buffer
;
2301 struct d3d_buffer
*buffer_impl
;
2303 if (!(wined3d_buffer
= wined3d_device_get_ds_cb(device
->wined3d_device
, start_slot
+ i
)))
2309 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2310 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
2312 wined3d_mutex_unlock();
2315 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
2316 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2318 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2321 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2323 wined3d_mutex_lock();
2324 for (i
= 0; i
< view_count
; ++i
)
2326 struct wined3d_shader_resource_view
*wined3d_view
;
2327 struct d3d_shader_resource_view
*view_impl
;
2329 if (!(wined3d_view
= wined3d_device_get_cs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2335 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2336 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2338 wined3d_mutex_unlock();
2341 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
2342 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2344 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2347 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2349 wined3d_mutex_lock();
2350 for (i
= 0; i
< view_count
; ++i
)
2352 struct wined3d_unordered_access_view
*wined3d_view
;
2353 struct d3d11_unordered_access_view
*view_impl
;
2355 if (!(wined3d_view
= wined3d_device_get_cs_uav(device
->wined3d_device
, start_slot
+ i
)))
2361 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2362 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2364 wined3d_mutex_unlock();
2367 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
2368 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2370 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2371 struct d3d11_compute_shader
*shader_impl
;
2372 struct wined3d_shader
*wined3d_shader
;
2374 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2375 iface
, shader
, class_instances
, class_instance_count
);
2377 if (class_instances
|| class_instance_count
)
2378 FIXME("Dynamic linking not implemented yet.\n");
2380 wined3d_mutex_lock();
2381 if (!(wined3d_shader
= wined3d_device_get_compute_shader(device
->wined3d_device
)))
2383 wined3d_mutex_unlock();
2388 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2389 wined3d_mutex_unlock();
2390 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2393 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
2394 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2396 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2399 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2400 iface
, start_slot
, sampler_count
, samplers
);
2402 wined3d_mutex_lock();
2403 for (i
= 0; i
< sampler_count
; ++i
)
2405 struct wined3d_sampler
*wined3d_sampler
;
2406 struct d3d_sampler_state
*sampler_impl
;
2408 if (!(wined3d_sampler
= wined3d_device_get_cs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2414 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2415 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2417 wined3d_mutex_unlock();
2420 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
2421 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2423 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2426 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2427 iface
, start_slot
, buffer_count
, buffers
);
2429 wined3d_mutex_lock();
2430 for (i
= 0; i
< buffer_count
; ++i
)
2432 struct wined3d_buffer
*wined3d_buffer
;
2433 struct d3d_buffer
*buffer_impl
;
2435 if (!(wined3d_buffer
= wined3d_device_get_cs_cb(device
->wined3d_device
, start_slot
+ i
)))
2441 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2442 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
2444 wined3d_mutex_unlock();
2447 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
2449 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2450 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
2453 TRACE("iface %p.\n", iface
);
2455 wined3d_mutex_lock();
2456 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
2457 wined3d_device_set_hull_shader(device
->wined3d_device
, NULL
);
2458 wined3d_device_set_domain_shader(device
->wined3d_device
, NULL
);
2459 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
2460 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
2461 wined3d_device_set_compute_shader(device
->wined3d_device
, NULL
);
2462 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
2464 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
2465 wined3d_device_set_hs_sampler(device
->wined3d_device
, i
, NULL
);
2466 wined3d_device_set_ds_sampler(device
->wined3d_device
, i
, NULL
);
2467 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
2468 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
2469 wined3d_device_set_cs_sampler(device
->wined3d_device
, i
, NULL
);
2471 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2473 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
2474 wined3d_device_set_hs_resource_view(device
->wined3d_device
, i
, NULL
);
2475 wined3d_device_set_ds_resource_view(device
->wined3d_device
, i
, NULL
);
2476 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
2477 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
2478 wined3d_device_set_cs_resource_view(device
->wined3d_device
, i
, NULL
);
2480 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
2482 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
2483 wined3d_device_set_hs_cb(device
->wined3d_device
, i
, NULL
);
2484 wined3d_device_set_ds_cb(device
->wined3d_device
, i
, NULL
);
2485 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
2486 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
2487 wined3d_device_set_cs_cb(device
->wined3d_device
, i
, NULL
);
2489 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2491 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
2493 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
2494 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
2495 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
, 0);
2496 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2498 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
2500 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
2501 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
2503 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
2504 wined3d_device_set_cs_uav(device
->wined3d_device
, i
, NULL
, ~0u);
2506 ID3D11DeviceContext_OMSetDepthStencilState(iface
, NULL
, 0);
2507 ID3D11DeviceContext_OMSetBlendState(iface
, NULL
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
2508 ID3D11DeviceContext_RSSetViewports(iface
, 0, NULL
);
2509 ID3D11DeviceContext_RSSetScissorRects(iface
, 0, NULL
);
2510 ID3D11DeviceContext_RSSetState(iface
, NULL
);
2511 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
2513 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
2515 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
2516 wined3d_mutex_unlock();
2519 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
2521 FIXME("iface %p stub!\n", iface
);
2524 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
2526 TRACE("iface %p.\n", iface
);
2528 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
2531 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
2533 FIXME("iface %p stub!\n", iface
);
2538 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
2539 BOOL restore
, ID3D11CommandList
**command_list
)
2541 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
2546 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
2548 /* IUnknown methods */
2549 d3d11_immediate_context_QueryInterface
,
2550 d3d11_immediate_context_AddRef
,
2551 d3d11_immediate_context_Release
,
2552 /* ID3D11DeviceChild methods */
2553 d3d11_immediate_context_GetDevice
,
2554 d3d11_immediate_context_GetPrivateData
,
2555 d3d11_immediate_context_SetPrivateData
,
2556 d3d11_immediate_context_SetPrivateDataInterface
,
2557 /* ID3D11DeviceContext methods */
2558 d3d11_immediate_context_VSSetConstantBuffers
,
2559 d3d11_immediate_context_PSSetShaderResources
,
2560 d3d11_immediate_context_PSSetShader
,
2561 d3d11_immediate_context_PSSetSamplers
,
2562 d3d11_immediate_context_VSSetShader
,
2563 d3d11_immediate_context_DrawIndexed
,
2564 d3d11_immediate_context_Draw
,
2565 d3d11_immediate_context_Map
,
2566 d3d11_immediate_context_Unmap
,
2567 d3d11_immediate_context_PSSetConstantBuffers
,
2568 d3d11_immediate_context_IASetInputLayout
,
2569 d3d11_immediate_context_IASetVertexBuffers
,
2570 d3d11_immediate_context_IASetIndexBuffer
,
2571 d3d11_immediate_context_DrawIndexedInstanced
,
2572 d3d11_immediate_context_DrawInstanced
,
2573 d3d11_immediate_context_GSSetConstantBuffers
,
2574 d3d11_immediate_context_GSSetShader
,
2575 d3d11_immediate_context_IASetPrimitiveTopology
,
2576 d3d11_immediate_context_VSSetShaderResources
,
2577 d3d11_immediate_context_VSSetSamplers
,
2578 d3d11_immediate_context_Begin
,
2579 d3d11_immediate_context_End
,
2580 d3d11_immediate_context_GetData
,
2581 d3d11_immediate_context_SetPredication
,
2582 d3d11_immediate_context_GSSetShaderResources
,
2583 d3d11_immediate_context_GSSetSamplers
,
2584 d3d11_immediate_context_OMSetRenderTargets
,
2585 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
2586 d3d11_immediate_context_OMSetBlendState
,
2587 d3d11_immediate_context_OMSetDepthStencilState
,
2588 d3d11_immediate_context_SOSetTargets
,
2589 d3d11_immediate_context_DrawAuto
,
2590 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
2591 d3d11_immediate_context_DrawInstancedIndirect
,
2592 d3d11_immediate_context_Dispatch
,
2593 d3d11_immediate_context_DispatchIndirect
,
2594 d3d11_immediate_context_RSSetState
,
2595 d3d11_immediate_context_RSSetViewports
,
2596 d3d11_immediate_context_RSSetScissorRects
,
2597 d3d11_immediate_context_CopySubresourceRegion
,
2598 d3d11_immediate_context_CopyResource
,
2599 d3d11_immediate_context_UpdateSubresource
,
2600 d3d11_immediate_context_CopyStructureCount
,
2601 d3d11_immediate_context_ClearRenderTargetView
,
2602 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
2603 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
2604 d3d11_immediate_context_ClearDepthStencilView
,
2605 d3d11_immediate_context_GenerateMips
,
2606 d3d11_immediate_context_SetResourceMinLOD
,
2607 d3d11_immediate_context_GetResourceMinLOD
,
2608 d3d11_immediate_context_ResolveSubresource
,
2609 d3d11_immediate_context_ExecuteCommandList
,
2610 d3d11_immediate_context_HSSetShaderResources
,
2611 d3d11_immediate_context_HSSetShader
,
2612 d3d11_immediate_context_HSSetSamplers
,
2613 d3d11_immediate_context_HSSetConstantBuffers
,
2614 d3d11_immediate_context_DSSetShaderResources
,
2615 d3d11_immediate_context_DSSetShader
,
2616 d3d11_immediate_context_DSSetSamplers
,
2617 d3d11_immediate_context_DSSetConstantBuffers
,
2618 d3d11_immediate_context_CSSetShaderResources
,
2619 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2620 d3d11_immediate_context_CSSetShader
,
2621 d3d11_immediate_context_CSSetSamplers
,
2622 d3d11_immediate_context_CSSetConstantBuffers
,
2623 d3d11_immediate_context_VSGetConstantBuffers
,
2624 d3d11_immediate_context_PSGetShaderResources
,
2625 d3d11_immediate_context_PSGetShader
,
2626 d3d11_immediate_context_PSGetSamplers
,
2627 d3d11_immediate_context_VSGetShader
,
2628 d3d11_immediate_context_PSGetConstantBuffers
,
2629 d3d11_immediate_context_IAGetInputLayout
,
2630 d3d11_immediate_context_IAGetVertexBuffers
,
2631 d3d11_immediate_context_IAGetIndexBuffer
,
2632 d3d11_immediate_context_GSGetConstantBuffers
,
2633 d3d11_immediate_context_GSGetShader
,
2634 d3d11_immediate_context_IAGetPrimitiveTopology
,
2635 d3d11_immediate_context_VSGetShaderResources
,
2636 d3d11_immediate_context_VSGetSamplers
,
2637 d3d11_immediate_context_GetPredication
,
2638 d3d11_immediate_context_GSGetShaderResources
,
2639 d3d11_immediate_context_GSGetSamplers
,
2640 d3d11_immediate_context_OMGetRenderTargets
,
2641 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2642 d3d11_immediate_context_OMGetBlendState
,
2643 d3d11_immediate_context_OMGetDepthStencilState
,
2644 d3d11_immediate_context_SOGetTargets
,
2645 d3d11_immediate_context_RSGetState
,
2646 d3d11_immediate_context_RSGetViewports
,
2647 d3d11_immediate_context_RSGetScissorRects
,
2648 d3d11_immediate_context_HSGetShaderResources
,
2649 d3d11_immediate_context_HSGetShader
,
2650 d3d11_immediate_context_HSGetSamplers
,
2651 d3d11_immediate_context_HSGetConstantBuffers
,
2652 d3d11_immediate_context_DSGetShaderResources
,
2653 d3d11_immediate_context_DSGetShader
,
2654 d3d11_immediate_context_DSGetSamplers
,
2655 d3d11_immediate_context_DSGetConstantBuffers
,
2656 d3d11_immediate_context_CSGetShaderResources
,
2657 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2658 d3d11_immediate_context_CSGetShader
,
2659 d3d11_immediate_context_CSGetSamplers
,
2660 d3d11_immediate_context_CSGetConstantBuffers
,
2661 d3d11_immediate_context_ClearState
,
2662 d3d11_immediate_context_Flush
,
2663 d3d11_immediate_context_GetType
,
2664 d3d11_immediate_context_GetContextFlags
,
2665 d3d11_immediate_context_FinishCommandList
,
2668 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
2670 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
2671 context
->refcount
= 1;
2673 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
2675 wined3d_private_store_init(&context
->private_store
);
2678 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
2680 wined3d_private_store_cleanup(&context
->private_store
);
2683 /* ID3D11Device methods */
2685 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
2687 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2688 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
2691 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
2693 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2694 return IUnknown_AddRef(device
->outer_unk
);
2697 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
2699 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2700 return IUnknown_Release(device
->outer_unk
);
2703 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
2704 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
2706 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2707 struct d3d_buffer
*object
;
2710 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2712 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
2715 *buffer
= &object
->ID3D11Buffer_iface
;
2720 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
2721 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
2723 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2728 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
2729 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2731 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2732 struct d3d_texture2d
*object
;
2735 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2737 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2740 *texture
= &object
->ID3D11Texture2D_iface
;
2745 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2746 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2748 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2749 struct d3d_texture3d
*object
;
2752 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2754 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2757 *texture
= &object
->ID3D11Texture3D_iface
;
2762 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2763 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2765 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2766 struct d3d_shader_resource_view
*object
;
2769 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2772 return E_INVALIDARG
;
2774 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2777 *view
= &object
->ID3D11ShaderResourceView_iface
;
2782 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2783 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2785 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2786 struct d3d11_unordered_access_view
*object
;
2789 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2791 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
2794 *view
= &object
->ID3D11UnorderedAccessView_iface
;
2799 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2800 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2802 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2803 struct d3d_rendertarget_view
*object
;
2806 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2809 return E_INVALIDARG
;
2811 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2814 *view
= &object
->ID3D11RenderTargetView_iface
;
2819 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2820 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2822 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2823 struct d3d_depthstencil_view
*object
;
2826 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2828 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2831 *view
= &object
->ID3D11DepthStencilView_iface
;
2836 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2837 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2838 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2840 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2841 struct d3d_input_layout
*object
;
2844 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2845 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2846 shader_byte_code_length
, input_layout
);
2848 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2849 shader_byte_code
, shader_byte_code_length
, &object
)))
2852 *input_layout
= &object
->ID3D11InputLayout_iface
;
2857 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2858 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2860 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2861 struct d3d_vertex_shader
*object
;
2864 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2865 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2868 FIXME("Class linkage is not implemented yet.\n");
2870 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2873 *shader
= &object
->ID3D11VertexShader_iface
;
2878 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2879 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2881 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2882 struct d3d_geometry_shader
*object
;
2885 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2886 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2889 FIXME("Class linkage is not implemented yet.\n");
2891 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
2892 NULL
, 0, NULL
, 0, 0, &object
)))
2895 *shader
= &object
->ID3D11GeometryShader_iface
;
2900 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2901 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2902 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
2903 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2905 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2906 struct d3d_geometry_shader
*object
;
2909 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2910 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
2911 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2912 rasterizer_stream
, class_linkage
, shader
);
2915 FIXME("Class linkage is not implemented yet.\n");
2917 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
2918 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
2924 *shader
= &object
->ID3D11GeometryShader_iface
;
2929 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2930 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2932 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2933 struct d3d_pixel_shader
*object
;
2936 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2937 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2940 FIXME("Class linkage is not implemented yet.\n");
2942 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2945 *shader
= &object
->ID3D11PixelShader_iface
;
2950 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2951 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2953 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2954 struct d3d11_hull_shader
*object
;
2957 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2958 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2961 FIXME("Class linkage is not implemented yet.\n");
2963 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2966 *shader
= &object
->ID3D11HullShader_iface
;
2971 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2972 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2974 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2975 struct d3d11_domain_shader
*object
;
2978 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2979 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2982 FIXME("Class linkage is not implemented yet.\n");
2984 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2987 *shader
= &object
->ID3D11DomainShader_iface
;
2992 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2993 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2995 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2996 struct d3d11_compute_shader
*object
;
2999 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3000 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3003 FIXME("Class linkage is not implemented yet.\n");
3005 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3008 *shader
= &object
->ID3D11ComputeShader_iface
;
3013 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
3014 ID3D11ClassLinkage
**class_linkage
)
3016 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3017 struct d3d11_class_linkage
*object
;
3020 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3022 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3025 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3030 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
3031 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3033 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3034 struct d3d_blend_state
*object
;
3037 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3039 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3042 *blend_state
= &object
->ID3D11BlendState_iface
;
3047 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
3048 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3050 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3051 struct d3d_depthstencil_state
*object
;
3054 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3056 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3059 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3064 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
3065 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3067 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3068 struct d3d_rasterizer_state
*object
;
3071 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3073 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
3076 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
3081 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
3082 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3084 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3085 struct d3d_sampler_state
*object
;
3088 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3090 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3093 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3098 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
3099 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3101 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3102 struct d3d_query
*object
;
3105 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3107 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3112 *query
= &object
->ID3D11Query_iface
;
3116 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3120 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
3121 ID3D11Predicate
**predicate
)
3123 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3124 struct d3d_query
*object
;
3127 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3129 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3134 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3138 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3142 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
3143 ID3D11Counter
**counter
)
3145 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3150 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
3151 ID3D11DeviceContext
**context
)
3153 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3158 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
3161 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
3166 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
3167 UINT
*format_support
)
3169 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3170 struct wined3d_device_creation_parameters params
;
3171 enum wined3d_format_id wined3d_format
;
3172 struct wined3d
*wined3d
;
3177 enum wined3d_resource_type rtype
;
3179 D3D11_FORMAT_SUPPORT flag
;
3183 {WINED3D_RTYPE_TEXTURE_2D
, WINED3DUSAGE_TEXTURE
, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3184 {WINED3D_RTYPE_TEXTURE_3D
, WINED3DUSAGE_TEXTURE
, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3185 {WINED3D_RTYPE_NONE
, WINED3DUSAGE_RENDERTARGET
, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3186 {WINED3D_RTYPE_NONE
, WINED3DUSAGE_DEPTHSTENCIL
, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3190 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3192 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3193 if (format
&& !wined3d_format
)
3195 WARN("Invalid format %#x.\n", format
);
3196 *format_support
= 0;
3200 *format_support
= 0;
3202 wined3d_mutex_lock();
3203 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3204 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3205 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3207 hr
= wined3d_check_device_format(wined3d
, params
.adapter_idx
, params
.device_type
,
3208 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].rtype
, wined3d_format
);
3209 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOAUTOGEN
)
3211 if (hr
!= WINED3D_OK
)
3213 WARN("Failed to check device format support, hr %#x.\n", hr
);
3214 wined3d_mutex_unlock();
3218 *format_support
|= flag_mapping
[i
].flag
;
3220 wined3d_mutex_unlock();
3225 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
3226 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3228 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3229 struct wined3d_device_creation_parameters params
;
3230 struct wined3d
*wined3d
;
3233 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3234 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3236 if (!quality_level_count
)
3237 return E_INVALIDARG
;
3239 *quality_level_count
= 0;
3243 if (sample_count
== 1)
3245 *quality_level_count
= 1;
3248 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3251 wined3d_mutex_lock();
3252 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3253 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3254 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
3255 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3256 wined3d_mutex_unlock();
3258 if (hr
== WINED3DERR_INVALIDCALL
)
3259 return E_INVALIDARG
;
3260 if (hr
== WINED3DERR_NOTAVAILABLE
)
3265 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
3267 FIXME("iface %p, info %p stub!\n", iface
, info
);
3270 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
3271 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3272 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3274 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3275 "units %p, units_length %p, description %p, description_length %p stub!\n",
3276 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3277 units
, units_length
, description
, description_length
);
3282 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
3283 void *feature_support_data
, UINT feature_support_data_size
)
3285 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3286 WINED3DCAPS wined3d_caps
;
3289 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3290 iface
, feature
, feature_support_data
, feature_support_data_size
);
3294 case D3D11_FEATURE_THREADING
:
3296 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
3297 if (feature_support_data_size
!= sizeof(*threading_data
))
3299 WARN("Invalid data size.\n");
3300 return E_INVALIDARG
;
3303 /* We lie about the threading support to make Tomb Raider 2013 and
3304 * Deus Ex: Human Revolution happy. */
3305 FIXME("Returning fake threading support data.\n");
3306 threading_data
->DriverConcurrentCreates
= TRUE
;
3307 threading_data
->DriverCommandLists
= TRUE
;
3311 case D3D11_FEATURE_DOUBLES
:
3313 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
3314 if (feature_support_data_size
!= sizeof(*doubles_data
))
3316 WARN("Invalid data size.\n");
3317 return E_INVALIDARG
;
3320 wined3d_mutex_lock();
3321 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3322 wined3d_mutex_unlock();
3325 WARN("Failed to get device caps, hr %#x.\n", hr
);
3329 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
3333 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
3335 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
3336 if (feature_support_data_size
!= sizeof(*options
))
3338 WARN("Invalid data size.\n");
3339 return E_INVALIDARG
;
3342 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
3347 FIXME("Unhandled feature %#x.\n", feature
);
3352 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
3353 UINT
*data_size
, void *data
)
3355 IDXGIDevice
*dxgi_device
;
3358 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3360 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3362 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
3363 IDXGIDevice_Release(dxgi_device
);
3368 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
3369 UINT data_size
, const void *data
)
3371 IDXGIDevice
*dxgi_device
;
3374 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3376 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3378 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
3379 IDXGIDevice_Release(dxgi_device
);
3384 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
3385 const IUnknown
*data
)
3387 IDXGIDevice
*dxgi_device
;
3390 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
3392 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3394 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
3395 IDXGIDevice_Release(dxgi_device
);
3400 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
3402 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3404 TRACE("iface %p.\n", iface
);
3406 return device
->feature_level
;
3409 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
3411 FIXME("iface %p stub!\n", iface
);
3416 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
3418 FIXME("iface %p stub!\n", iface
);
3423 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
3424 ID3D11DeviceContext
**immediate_context
)
3426 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3428 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3430 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
3431 ID3D11DeviceContext_AddRef(*immediate_context
);
3434 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
3436 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
3441 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
3443 FIXME("iface %p stub!\n", iface
);
3448 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
3450 /* IUnknown methods */
3451 d3d11_device_QueryInterface
,
3452 d3d11_device_AddRef
,
3453 d3d11_device_Release
,
3454 /* ID3D11Device methods */
3455 d3d11_device_CreateBuffer
,
3456 d3d11_device_CreateTexture1D
,
3457 d3d11_device_CreateTexture2D
,
3458 d3d11_device_CreateTexture3D
,
3459 d3d11_device_CreateShaderResourceView
,
3460 d3d11_device_CreateUnorderedAccessView
,
3461 d3d11_device_CreateRenderTargetView
,
3462 d3d11_device_CreateDepthStencilView
,
3463 d3d11_device_CreateInputLayout
,
3464 d3d11_device_CreateVertexShader
,
3465 d3d11_device_CreateGeometryShader
,
3466 d3d11_device_CreateGeometryShaderWithStreamOutput
,
3467 d3d11_device_CreatePixelShader
,
3468 d3d11_device_CreateHullShader
,
3469 d3d11_device_CreateDomainShader
,
3470 d3d11_device_CreateComputeShader
,
3471 d3d11_device_CreateClassLinkage
,
3472 d3d11_device_CreateBlendState
,
3473 d3d11_device_CreateDepthStencilState
,
3474 d3d11_device_CreateRasterizerState
,
3475 d3d11_device_CreateSamplerState
,
3476 d3d11_device_CreateQuery
,
3477 d3d11_device_CreatePredicate
,
3478 d3d11_device_CreateCounter
,
3479 d3d11_device_CreateDeferredContext
,
3480 d3d11_device_OpenSharedResource
,
3481 d3d11_device_CheckFormatSupport
,
3482 d3d11_device_CheckMultisampleQualityLevels
,
3483 d3d11_device_CheckCounterInfo
,
3484 d3d11_device_CheckCounter
,
3485 d3d11_device_CheckFeatureSupport
,
3486 d3d11_device_GetPrivateData
,
3487 d3d11_device_SetPrivateData
,
3488 d3d11_device_SetPrivateDataInterface
,
3489 d3d11_device_GetFeatureLevel
,
3490 d3d11_device_GetCreationFlags
,
3491 d3d11_device_GetDeviceRemovedReason
,
3492 d3d11_device_GetImmediateContext
,
3493 d3d11_device_SetExceptionMode
,
3494 d3d11_device_GetExceptionMode
,
3497 /* Inner IUnknown methods */
3499 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
3501 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
3504 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
3506 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3508 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
3510 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
3511 || IsEqualGUID(riid
, &IID_IUnknown
))
3513 *out
= &device
->ID3D11Device_iface
;
3515 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
3516 || IsEqualGUID(riid
, &IID_ID3D10Device
))
3518 *out
= &device
->ID3D10Device1_iface
;
3520 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
3522 *out
= &device
->ID3D10Multithread_iface
;
3524 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
3526 *out
= &device
->IWineDXGIDeviceParent_iface
;
3530 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
3532 return E_NOINTERFACE
;
3535 IUnknown_AddRef((IUnknown
*)*out
);
3539 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
3541 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3542 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
3544 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
3549 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
3551 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3552 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
3554 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
3558 d3d11_immediate_context_destroy(&device
->immediate_context
);
3559 if (device
->wined3d_device
)
3561 wined3d_mutex_lock();
3562 wined3d_device_decref(device
->wined3d_device
);
3563 wined3d_mutex_unlock();
3565 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
3566 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3567 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3568 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3574 /* IUnknown methods */
3576 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
3579 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3580 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
3583 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
3585 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3586 return IUnknown_AddRef(device
->outer_unk
);
3589 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
3591 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3592 return IUnknown_Release(device
->outer_unk
);
3595 /* ID3D10Device methods */
3597 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
3598 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3600 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3603 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3604 iface
, start_slot
, buffer_count
, buffers
);
3606 wined3d_mutex_lock();
3607 for (i
= 0; i
< buffer_count
; ++i
)
3609 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3611 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
3612 buffer
? buffer
->wined3d_buffer
: NULL
);
3614 wined3d_mutex_unlock();
3617 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
3618 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3620 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3623 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3624 iface
, start_slot
, view_count
, views
);
3626 wined3d_mutex_lock();
3627 for (i
= 0; i
< view_count
; ++i
)
3629 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3631 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
3632 view
? view
->wined3d_view
: NULL
);
3634 wined3d_mutex_unlock();
3637 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
3638 ID3D10PixelShader
*shader
)
3640 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3641 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
3643 TRACE("iface %p, shader %p\n", iface
, shader
);
3645 wined3d_mutex_lock();
3646 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
3647 wined3d_mutex_unlock();
3650 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
3651 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3653 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3656 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3657 iface
, start_slot
, sampler_count
, samplers
);
3659 wined3d_mutex_lock();
3660 for (i
= 0; i
< sampler_count
; ++i
)
3662 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3664 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
3665 sampler
? sampler
->wined3d_sampler
: NULL
);
3667 wined3d_mutex_unlock();
3670 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
3671 ID3D10VertexShader
*shader
)
3673 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3674 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
3676 TRACE("iface %p, shader %p\n", iface
, shader
);
3678 wined3d_mutex_lock();
3679 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
3680 wined3d_mutex_unlock();
3683 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
3684 UINT start_index_location
, INT base_vertex_location
)
3686 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3688 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
3689 iface
, index_count
, start_index_location
, base_vertex_location
);
3691 wined3d_mutex_lock();
3692 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3693 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
3694 wined3d_mutex_unlock();
3697 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
3698 UINT start_vertex_location
)
3700 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3702 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
3703 iface
, vertex_count
, start_vertex_location
);
3705 wined3d_mutex_lock();
3706 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
3707 wined3d_mutex_unlock();
3710 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
3711 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3713 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3716 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3717 iface
, start_slot
, buffer_count
, buffers
);
3719 wined3d_mutex_lock();
3720 for (i
= 0; i
< buffer_count
; ++i
)
3722 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3724 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
3725 buffer
? buffer
->wined3d_buffer
: NULL
);
3727 wined3d_mutex_unlock();
3730 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
3731 ID3D10InputLayout
*input_layout
)
3733 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3734 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
3736 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
3738 wined3d_mutex_lock();
3739 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
3740 layout
? layout
->wined3d_decl
: NULL
);
3741 wined3d_mutex_unlock();
3744 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
3745 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
3747 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3750 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
3751 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3753 wined3d_mutex_lock();
3754 for (i
= 0; i
< buffer_count
; ++i
)
3756 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3758 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
3759 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3761 wined3d_mutex_unlock();
3764 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3765 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3767 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3768 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3770 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3771 iface
, buffer
, debug_dxgi_format(format
), offset
);
3773 wined3d_mutex_lock();
3774 wined3d_device_set_index_buffer(device
->wined3d_device
,
3775 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3776 wined3dformat_from_dxgi_format(format
), offset
);
3777 wined3d_mutex_unlock();
3780 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3781 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3782 INT base_vertex_location
, UINT start_instance_location
)
3784 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3786 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3787 "base_vertex_location %d, start_instance_location %u.\n",
3788 iface
, instance_index_count
, instance_count
, start_index_location
,
3789 base_vertex_location
, start_instance_location
);
3791 wined3d_mutex_lock();
3792 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3793 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3794 instance_index_count
, start_instance_location
, instance_count
);
3795 wined3d_mutex_unlock();
3798 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3799 UINT instance_vertex_count
, UINT instance_count
,
3800 UINT start_vertex_location
, UINT start_instance_location
)
3802 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3804 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3805 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3806 start_vertex_location
, start_instance_location
);
3808 wined3d_mutex_lock();
3809 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3810 instance_vertex_count
, start_instance_location
, instance_count
);
3811 wined3d_mutex_unlock();
3814 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3815 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3817 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3820 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3821 iface
, start_slot
, buffer_count
, buffers
);
3823 wined3d_mutex_lock();
3824 for (i
= 0; i
< buffer_count
; ++i
)
3826 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3828 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3829 buffer
? buffer
->wined3d_buffer
: NULL
);
3831 wined3d_mutex_unlock();
3834 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3836 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3837 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3839 TRACE("iface %p, shader %p.\n", iface
, shader
);
3841 wined3d_mutex_lock();
3842 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3843 wined3d_mutex_unlock();
3846 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3847 D3D10_PRIMITIVE_TOPOLOGY topology
)
3849 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3851 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
3853 wined3d_mutex_lock();
3854 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
, 0);
3855 wined3d_mutex_unlock();
3858 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3859 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3861 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3864 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3865 iface
, start_slot
, view_count
, views
);
3867 wined3d_mutex_lock();
3868 for (i
= 0; i
< view_count
; ++i
)
3870 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3872 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3873 view
? view
->wined3d_view
: NULL
);
3875 wined3d_mutex_unlock();
3878 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3879 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3881 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3884 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3885 iface
, start_slot
, sampler_count
, samplers
);
3887 wined3d_mutex_lock();
3888 for (i
= 0; i
< sampler_count
; ++i
)
3890 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3892 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3893 sampler
? sampler
->wined3d_sampler
: NULL
);
3895 wined3d_mutex_unlock();
3898 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3900 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3901 struct d3d_query
*query
;
3903 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3905 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3906 wined3d_mutex_lock();
3907 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3908 wined3d_mutex_unlock();
3911 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3912 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3914 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3917 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3918 iface
, start_slot
, view_count
, views
);
3920 wined3d_mutex_lock();
3921 for (i
= 0; i
< view_count
; ++i
)
3923 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3925 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3926 view
? view
->wined3d_view
: NULL
);
3928 wined3d_mutex_unlock();
3931 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3932 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3934 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3937 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3938 iface
, start_slot
, sampler_count
, samplers
);
3940 wined3d_mutex_lock();
3941 for (i
= 0; i
< sampler_count
; ++i
)
3943 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3945 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3946 sampler
? sampler
->wined3d_sampler
: NULL
);
3948 wined3d_mutex_unlock();
3951 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3952 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3953 ID3D10DepthStencilView
*depth_stencil_view
)
3955 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3956 struct d3d_depthstencil_view
*dsv
;
3959 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3960 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3962 wined3d_mutex_lock();
3963 for (i
= 0; i
< render_target_view_count
; ++i
)
3965 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3967 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3968 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3970 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3972 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3975 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3976 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3977 dsv
? dsv
->wined3d_view
: NULL
);
3978 wined3d_mutex_unlock();
3981 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3982 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3984 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3985 struct d3d_blend_state
*blend_state_object
;
3987 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3988 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3990 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3991 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3992 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3995 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3996 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3998 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3999 struct d3d_depthstencil_state
*ds_state_object
;
4001 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
4002 iface
, depth_stencil_state
, stencil_ref
);
4004 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
4005 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4006 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
4009 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
4010 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
4012 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4013 unsigned int count
, i
;
4015 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
4017 count
= min(target_count
, D3D10_SO_BUFFER_SLOT_COUNT
);
4018 wined3d_mutex_lock();
4019 for (i
= 0; i
< count
; ++i
)
4021 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
4023 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
4024 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
4027 for (i
= count
; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4029 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4031 wined3d_mutex_unlock();
4034 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
4036 FIXME("iface %p stub!\n", iface
);
4039 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
4041 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4042 struct d3d_rasterizer_state
*rasterizer_state_object
;
4044 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4046 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
4047 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4048 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
4051 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
4052 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
4054 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4055 struct wined3d_viewport wined3d_vp
;
4057 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
4059 if (viewport_count
> 1)
4060 FIXME("Multiple viewports not implemented.\n");
4062 if (!viewport_count
)
4065 wined3d_vp
.x
= viewports
[0].TopLeftX
;
4066 wined3d_vp
.y
= viewports
[0].TopLeftY
;
4067 wined3d_vp
.width
= viewports
[0].Width
;
4068 wined3d_vp
.height
= viewports
[0].Height
;
4069 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
4070 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
4072 wined3d_mutex_lock();
4073 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
4074 wined3d_mutex_unlock();
4077 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
4078 UINT rect_count
, const D3D10_RECT
*rects
)
4080 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4082 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
4085 FIXME("Multiple scissor rects not implemented.\n");
4090 wined3d_mutex_lock();
4091 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
4092 wined3d_mutex_unlock();
4095 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
4096 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
4097 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
4099 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4100 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4101 struct wined3d_box wined3d_src_box
;
4103 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
4104 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
4105 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
4106 src_resource
, src_subresource_idx
, src_box
);
4109 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
4110 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
4112 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4113 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4114 wined3d_mutex_lock();
4115 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
4116 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
4117 wined3d_mutex_unlock();
4120 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
4121 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
4123 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4124 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4126 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
4128 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4129 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4130 wined3d_mutex_lock();
4131 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
4132 wined3d_mutex_unlock();
4135 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
4136 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
4137 const void *data
, UINT row_pitch
, UINT depth_pitch
)
4139 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4140 ID3D11Resource
*d3d11_resource
;
4142 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
4143 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
4145 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
4146 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4147 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
4148 ID3D11Resource_Release(d3d11_resource
);
4151 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
4152 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
4154 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4155 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
4156 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
4159 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
4160 iface
, render_target_view
, debug_float4(color_rgba
));
4165 wined3d_mutex_lock();
4166 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4167 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
4168 ERR("Failed to clear view, hr %#x.\n", hr
);
4169 wined3d_mutex_unlock();
4172 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
4173 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
4175 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4176 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4177 DWORD wined3d_flags
;
4180 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
4181 iface
, depth_stencil_view
, flags
, depth
, stencil
);
4186 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
4188 wined3d_mutex_lock();
4189 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4190 wined3d_flags
, NULL
, depth
, stencil
)))
4191 ERR("Failed to clear view, hr %#x.\n", hr
);
4192 wined3d_mutex_unlock();
4195 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
4196 ID3D10ShaderResourceView
*shader_resource_view
)
4198 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
4201 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
4202 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
4203 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
4205 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
4206 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
4207 iface
, dst_resource
, dst_subresource_idx
,
4208 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
4211 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
4212 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4214 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4217 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4218 iface
, start_slot
, buffer_count
, buffers
);
4220 wined3d_mutex_lock();
4221 for (i
= 0; i
< buffer_count
; ++i
)
4223 struct wined3d_buffer
*wined3d_buffer
;
4224 struct d3d_buffer
*buffer_impl
;
4226 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
4232 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4233 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4234 ID3D10Buffer_AddRef(buffers
[i
]);
4236 wined3d_mutex_unlock();
4239 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
4240 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4242 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4245 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4246 iface
, start_slot
, view_count
, views
);
4248 wined3d_mutex_lock();
4249 for (i
= 0; i
< view_count
; ++i
)
4251 struct wined3d_shader_resource_view
*wined3d_view
;
4252 struct d3d_shader_resource_view
*view_impl
;
4254 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4260 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4261 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4262 ID3D10ShaderResourceView_AddRef(views
[i
]);
4264 wined3d_mutex_unlock();
4267 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
4269 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4270 struct d3d_pixel_shader
*shader_impl
;
4271 struct wined3d_shader
*wined3d_shader
;
4273 TRACE("iface %p, shader %p.\n", iface
, shader
);
4275 wined3d_mutex_lock();
4276 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
4278 wined3d_mutex_unlock();
4283 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4284 wined3d_mutex_unlock();
4285 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
4286 ID3D10PixelShader_AddRef(*shader
);
4289 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
4290 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4292 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4295 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4296 iface
, start_slot
, sampler_count
, samplers
);
4298 wined3d_mutex_lock();
4299 for (i
= 0; i
< sampler_count
; ++i
)
4301 struct d3d_sampler_state
*sampler_impl
;
4302 struct wined3d_sampler
*wined3d_sampler
;
4304 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
4310 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4311 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4312 ID3D10SamplerState_AddRef(samplers
[i
]);
4314 wined3d_mutex_unlock();
4317 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
4319 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4320 struct d3d_vertex_shader
*shader_impl
;
4321 struct wined3d_shader
*wined3d_shader
;
4323 TRACE("iface %p, shader %p.\n", iface
, shader
);
4325 wined3d_mutex_lock();
4326 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
4328 wined3d_mutex_unlock();
4333 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4334 wined3d_mutex_unlock();
4335 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
4336 ID3D10VertexShader_AddRef(*shader
);
4339 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
4340 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4342 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4345 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4346 iface
, start_slot
, buffer_count
, buffers
);
4348 wined3d_mutex_lock();
4349 for (i
= 0; i
< buffer_count
; ++i
)
4351 struct wined3d_buffer
*wined3d_buffer
;
4352 struct d3d_buffer
*buffer_impl
;
4354 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
4360 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4361 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4362 ID3D10Buffer_AddRef(buffers
[i
]);
4364 wined3d_mutex_unlock();
4367 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
4369 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4370 struct wined3d_vertex_declaration
*wined3d_declaration
;
4371 struct d3d_input_layout
*input_layout_impl
;
4373 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
4375 wined3d_mutex_lock();
4376 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
4378 wined3d_mutex_unlock();
4379 *input_layout
= NULL
;
4383 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
4384 wined3d_mutex_unlock();
4385 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
4386 ID3D10InputLayout_AddRef(*input_layout
);
4389 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
4390 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
4392 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4395 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
4396 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4398 wined3d_mutex_lock();
4399 for (i
= 0; i
< buffer_count
; ++i
)
4401 struct wined3d_buffer
*wined3d_buffer
= NULL
;
4402 struct d3d_buffer
*buffer_impl
;
4404 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
4405 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
4406 ERR("Failed to get vertex buffer.\n");
4408 if (!wined3d_buffer
)
4414 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4415 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4416 ID3D10Buffer_AddRef(buffers
[i
]);
4418 wined3d_mutex_unlock();
4421 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
4422 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
4424 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4425 enum wined3d_format_id wined3d_format
;
4426 struct wined3d_buffer
*wined3d_buffer
;
4427 struct d3d_buffer
*buffer_impl
;
4429 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
4431 wined3d_mutex_lock();
4432 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
4433 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
4434 if (!wined3d_buffer
)
4436 wined3d_mutex_unlock();
4441 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4442 wined3d_mutex_unlock();
4443 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
4444 ID3D10Buffer_AddRef(*buffer
);
4447 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
4448 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4450 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4453 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4454 iface
, start_slot
, buffer_count
, buffers
);
4456 wined3d_mutex_lock();
4457 for (i
= 0; i
< buffer_count
; ++i
)
4459 struct wined3d_buffer
*wined3d_buffer
;
4460 struct d3d_buffer
*buffer_impl
;
4462 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
4468 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4469 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4470 ID3D10Buffer_AddRef(buffers
[i
]);
4472 wined3d_mutex_unlock();
4475 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
4477 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4478 struct d3d_geometry_shader
*shader_impl
;
4479 struct wined3d_shader
*wined3d_shader
;
4481 TRACE("iface %p, shader %p.\n", iface
, shader
);
4483 wined3d_mutex_lock();
4484 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
4486 wined3d_mutex_unlock();
4491 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4492 wined3d_mutex_unlock();
4493 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
4494 ID3D10GeometryShader_AddRef(*shader
);
4497 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
4498 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
4500 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4502 TRACE("iface %p, topology %p.\n", iface
, topology
);
4504 wined3d_mutex_lock();
4505 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
, NULL
);
4506 wined3d_mutex_unlock();
4509 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
4510 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4512 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4515 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4516 iface
, start_slot
, view_count
, views
);
4518 wined3d_mutex_lock();
4519 for (i
= 0; i
< view_count
; ++i
)
4521 struct wined3d_shader_resource_view
*wined3d_view
;
4522 struct d3d_shader_resource_view
*view_impl
;
4524 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4530 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4531 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4532 ID3D10ShaderResourceView_AddRef(views
[i
]);
4534 wined3d_mutex_unlock();
4537 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
4538 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4540 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4543 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4544 iface
, start_slot
, sampler_count
, samplers
);
4546 wined3d_mutex_lock();
4547 for (i
= 0; i
< sampler_count
; ++i
)
4549 struct d3d_sampler_state
*sampler_impl
;
4550 struct wined3d_sampler
*wined3d_sampler
;
4552 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4558 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4559 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4560 ID3D10SamplerState_AddRef(samplers
[i
]);
4562 wined3d_mutex_unlock();
4565 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
4566 ID3D10Predicate
**predicate
, BOOL
*value
)
4568 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4569 struct wined3d_query
*wined3d_predicate
;
4570 struct d3d_query
*predicate_impl
;
4572 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
4574 wined3d_mutex_lock();
4575 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
4577 wined3d_mutex_unlock();
4582 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
4583 wined3d_mutex_unlock();
4584 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
4585 ID3D10Predicate_AddRef(*predicate
);
4588 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
4589 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4591 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4594 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4595 iface
, start_slot
, view_count
, views
);
4597 wined3d_mutex_lock();
4598 for (i
= 0; i
< view_count
; ++i
)
4600 struct wined3d_shader_resource_view
*wined3d_view
;
4601 struct d3d_shader_resource_view
*view_impl
;
4603 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4609 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4610 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4611 ID3D10ShaderResourceView_AddRef(views
[i
]);
4613 wined3d_mutex_unlock();
4616 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
4617 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4619 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4622 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4623 iface
, start_slot
, sampler_count
, samplers
);
4625 wined3d_mutex_lock();
4626 for (i
= 0; i
< sampler_count
; ++i
)
4628 struct d3d_sampler_state
*sampler_impl
;
4629 struct wined3d_sampler
*wined3d_sampler
;
4631 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4637 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4638 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4639 ID3D10SamplerState_AddRef(samplers
[i
]);
4641 wined3d_mutex_unlock();
4644 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
4645 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
4647 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4648 struct wined3d_rendertarget_view
*wined3d_view
;
4650 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4651 iface
, view_count
, render_target_views
, depth_stencil_view
);
4653 wined3d_mutex_lock();
4654 if (render_target_views
)
4656 struct d3d_rendertarget_view
*view_impl
;
4659 for (i
= 0; i
< view_count
; ++i
)
4661 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
4662 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4664 render_target_views
[i
] = NULL
;
4668 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
4669 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
4673 if (depth_stencil_view
)
4675 struct d3d_depthstencil_view
*view_impl
;
4677 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
4678 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4680 *depth_stencil_view
= NULL
;
4684 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
4685 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
4688 wined3d_mutex_unlock();
4691 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
4692 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
4694 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4695 ID3D11BlendState
*d3d11_blend_state
;
4697 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
4698 iface
, blend_state
, blend_factor
, sample_mask
);
4700 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4701 &d3d11_blend_state
, blend_factor
, sample_mask
);
4703 if (d3d11_blend_state
)
4704 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
4706 *blend_state
= NULL
;
4709 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
4710 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
4712 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4713 ID3D11DepthStencilState
*d3d11_iface
;
4715 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
4716 iface
, depth_stencil_state
, stencil_ref
);
4718 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4719 &d3d11_iface
, stencil_ref
);
4722 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
4724 *depth_stencil_state
= NULL
;
4727 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
4728 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
4730 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4733 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
4734 iface
, buffer_count
, buffers
, offsets
);
4736 wined3d_mutex_lock();
4737 for (i
= 0; i
< buffer_count
; ++i
)
4739 struct wined3d_buffer
*wined3d_buffer
;
4740 struct d3d_buffer
*buffer_impl
;
4742 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
4748 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4749 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4750 ID3D10Buffer_AddRef(buffers
[i
]);
4752 wined3d_mutex_unlock();
4755 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
4757 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4758 struct d3d_rasterizer_state
*rasterizer_state_impl
;
4759 struct wined3d_rasterizer_state
*wined3d_state
;
4761 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4763 wined3d_mutex_lock();
4764 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
4766 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
4767 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
4771 *rasterizer_state
= NULL
;
4773 wined3d_mutex_unlock();
4776 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4777 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4779 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4780 struct wined3d_viewport wined3d_vp
;
4782 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4786 *viewport_count
= 1;
4790 if (!*viewport_count
)
4793 wined3d_mutex_lock();
4794 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4795 wined3d_mutex_unlock();
4797 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4798 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4799 viewports
[0].Width
= wined3d_vp
.width
;
4800 viewports
[0].Height
= wined3d_vp
.height
;
4801 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4802 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4804 if (*viewport_count
> 1)
4805 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4808 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4810 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4812 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4823 wined3d_mutex_lock();
4824 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4825 wined3d_mutex_unlock();
4826 if (*rect_count
> 1)
4827 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4830 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4832 TRACE("iface %p.\n", iface
);
4834 /* In the current implementation the device is never removed, so we can
4835 * just return S_OK here. */
4840 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4842 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4847 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4849 FIXME("iface %p stub!\n", iface
);
4854 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4855 REFGUID guid
, UINT
*data_size
, void *data
)
4857 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4859 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4861 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4864 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4865 REFGUID guid
, UINT data_size
, const void *data
)
4867 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4869 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4871 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4874 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4875 REFGUID guid
, const IUnknown
*data
)
4877 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4879 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4881 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4884 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4886 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4888 TRACE("iface %p.\n", iface
);
4890 d3d11_immediate_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext_iface
);
4893 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4895 FIXME("iface %p stub!\n", iface
);
4898 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4899 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4901 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4902 D3D11_BUFFER_DESC d3d11_desc
;
4903 struct d3d_buffer
*object
;
4906 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4908 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4909 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4910 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4911 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4912 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4913 d3d11_desc
.StructureByteStride
= 0;
4915 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4918 *buffer
= &object
->ID3D10Buffer_iface
;
4923 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4924 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4926 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4931 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4932 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4933 ID3D10Texture2D
**texture
)
4935 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4936 D3D11_TEXTURE2D_DESC d3d11_desc
;
4937 struct d3d_texture2d
*object
;
4940 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4942 d3d11_desc
.Width
= desc
->Width
;
4943 d3d11_desc
.Height
= desc
->Height
;
4944 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4945 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4946 d3d11_desc
.Format
= desc
->Format
;
4947 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4948 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4949 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4950 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4951 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4953 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4956 *texture
= &object
->ID3D10Texture2D_iface
;
4961 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4962 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4963 ID3D10Texture3D
**texture
)
4965 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4966 D3D11_TEXTURE3D_DESC d3d11_desc
;
4967 struct d3d_texture3d
*object
;
4970 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4972 d3d11_desc
.Width
= desc
->Width
;
4973 d3d11_desc
.Height
= desc
->Height
;
4974 d3d11_desc
.Depth
= desc
->Depth
;
4975 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4976 d3d11_desc
.Format
= desc
->Format
;
4977 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4978 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4979 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4980 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4982 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4985 *texture
= &object
->ID3D10Texture3D_iface
;
4990 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4991 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4993 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4994 struct d3d_shader_resource_view
*object
;
4995 ID3D11Resource
*d3d11_resource
;
4998 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5001 return E_INVALIDARG
;
5003 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5005 ERR("Resource does not implement ID3D11Resource.\n");
5009 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
5011 ID3D11Resource_Release(d3d11_resource
);
5015 *view
= &object
->ID3D10ShaderResourceView1_iface
;
5020 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
5021 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
5023 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5025 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
5026 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
5029 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
5030 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
5032 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5033 struct d3d_rendertarget_view
*object
;
5034 ID3D11Resource
*d3d11_resource
;
5037 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5040 return E_INVALIDARG
;
5042 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5044 ERR("Resource does not implement ID3D11Resource.\n");
5048 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
5049 ID3D11Resource_Release(d3d11_resource
);
5053 *view
= &object
->ID3D10RenderTargetView_iface
;
5058 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
5059 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
5061 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5062 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
5063 struct d3d_depthstencil_view
*object
;
5064 ID3D11Resource
*d3d11_resource
;
5067 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5071 d3d11_desc
.Format
= desc
->Format
;
5072 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
5073 d3d11_desc
.Flags
= 0;
5074 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
5077 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5079 ERR("Resource does not implement ID3D11Resource.\n");
5083 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
5084 ID3D11Resource_Release(d3d11_resource
);
5088 *view
= &object
->ID3D10DepthStencilView_iface
;
5093 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
5094 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
5095 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
5096 ID3D10InputLayout
**input_layout
)
5098 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5099 struct d3d_input_layout
*object
;
5102 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
5103 "shader_byte_code_length %lu, input_layout %p\n",
5104 iface
, element_descs
, element_count
, shader_byte_code
,
5105 shader_byte_code_length
, input_layout
);
5107 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
5108 shader_byte_code
, shader_byte_code_length
, &object
)))
5111 *input_layout
= &object
->ID3D10InputLayout_iface
;
5116 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
5117 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
5119 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5120 struct d3d_vertex_shader
*object
;
5123 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5124 iface
, byte_code
, byte_code_length
, shader
);
5126 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5129 *shader
= &object
->ID3D10VertexShader_iface
;
5134 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
5135 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
5137 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5138 struct d3d_geometry_shader
*object
;
5141 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5142 iface
, byte_code
, byte_code_length
, shader
);
5144 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5145 NULL
, 0, NULL
, 0, 0, &object
)))
5148 *shader
= &object
->ID3D10GeometryShader_iface
;
5153 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
5154 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
5155 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
5157 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5158 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
5159 struct d3d_geometry_shader
*object
;
5160 unsigned int i
, stride_count
= 1;
5163 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
5164 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
5165 iface
, byte_code
, byte_code_length
, output_stream_decls
,
5166 output_stream_decl_count
, output_stream_stride
, shader
);
5168 if (!output_stream_decl_count
&& output_stream_stride
)
5170 WARN("Stride must be 0 when declaration entry count is 0.\n");
5172 return E_INVALIDARG
;
5175 if (output_stream_decl_count
5176 && !(so_entries
= d3d11_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
5178 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
5180 return E_OUTOFMEMORY
;
5183 for (i
= 0; i
< output_stream_decl_count
; ++i
)
5185 so_entries
[i
].Stream
= 0;
5186 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
5187 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
5188 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
5189 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
5190 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
5192 if (output_stream_decls
[i
].OutputSlot
)
5195 if (output_stream_stride
)
5197 WARN("Stride must be 0 when multiple output slots are used.\n");
5198 HeapFree(GetProcessHeap(), 0, so_entries
);
5200 return E_INVALIDARG
;
5205 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5206 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
5207 HeapFree(GetProcessHeap(), 0, so_entries
);
5214 *shader
= &object
->ID3D10GeometryShader_iface
;
5219 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
5220 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
5222 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5223 struct d3d_pixel_shader
*object
;
5226 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5227 iface
, byte_code
, byte_code_length
, shader
);
5229 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5232 *shader
= &object
->ID3D10PixelShader_iface
;
5237 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
5238 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
5240 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5241 struct d3d_blend_state
*object
;
5244 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5246 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
5249 *blend_state
= &object
->ID3D10BlendState1_iface
;
5254 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
5255 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
5257 D3D10_BLEND_DESC1 d3d10_1_desc
;
5260 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5263 return E_INVALIDARG
;
5265 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
5266 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
5267 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
5269 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
5270 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
5271 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
5274 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5276 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
5277 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
5278 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
5279 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
5280 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
5281 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
5282 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
5283 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
5286 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
5289 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
5290 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
5292 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5293 struct d3d_depthstencil_state
*object
;
5296 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
5298 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
5301 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
5306 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
5307 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
5309 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5310 struct d3d_rasterizer_state
*object
;
5313 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
5315 if (FAILED(hr
= d3d_rasterizer_state_create(device
, (const D3D11_RASTERIZER_DESC
*)desc
, &object
)))
5318 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
5323 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
5324 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
5326 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5327 struct d3d_sampler_state
*object
;
5330 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
5332 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
5335 *sampler_state
= &object
->ID3D10SamplerState_iface
;
5340 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
5341 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
5343 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5344 struct d3d_query
*object
;
5347 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
5349 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
5354 *query
= &object
->ID3D10Query_iface
;
5358 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5362 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
5363 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
5365 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5366 struct d3d_query
*object
;
5369 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
5371 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
5376 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
5380 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5384 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
5385 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
5387 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
5392 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
5393 DXGI_FORMAT format
, UINT
*format_support
)
5395 FIXME("iface %p, format %s, format_support %p stub!\n",
5396 iface
, debug_dxgi_format(format
), format_support
);
5401 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
5402 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
5404 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5406 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
5407 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
5409 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
5410 sample_count
, quality_level_count
);
5413 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
5415 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
5418 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
5419 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
5420 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
5422 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
5423 "units %p, units_length %p, description %p, description_length %p stub!\n",
5424 iface
, desc
, type
, active_counters
, name
, name_length
,
5425 units
, units_length
, description
, description_length
);
5430 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
5432 FIXME("iface %p stub!\n", iface
);
5437 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
5438 HANDLE resource_handle
, REFIID guid
, void **resource
)
5440 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
5441 iface
, resource_handle
, debugstr_guid(guid
), resource
);
5446 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
5448 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
5451 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
5453 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
5456 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
5458 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5460 TRACE("iface %p.\n", iface
);
5462 return device
->feature_level
;
5465 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
5467 /* IUnknown methods */
5468 d3d10_device_QueryInterface
,
5469 d3d10_device_AddRef
,
5470 d3d10_device_Release
,
5471 /* ID3D10Device methods */
5472 d3d10_device_VSSetConstantBuffers
,
5473 d3d10_device_PSSetShaderResources
,
5474 d3d10_device_PSSetShader
,
5475 d3d10_device_PSSetSamplers
,
5476 d3d10_device_VSSetShader
,
5477 d3d10_device_DrawIndexed
,
5479 d3d10_device_PSSetConstantBuffers
,
5480 d3d10_device_IASetInputLayout
,
5481 d3d10_device_IASetVertexBuffers
,
5482 d3d10_device_IASetIndexBuffer
,
5483 d3d10_device_DrawIndexedInstanced
,
5484 d3d10_device_DrawInstanced
,
5485 d3d10_device_GSSetConstantBuffers
,
5486 d3d10_device_GSSetShader
,
5487 d3d10_device_IASetPrimitiveTopology
,
5488 d3d10_device_VSSetShaderResources
,
5489 d3d10_device_VSSetSamplers
,
5490 d3d10_device_SetPredication
,
5491 d3d10_device_GSSetShaderResources
,
5492 d3d10_device_GSSetSamplers
,
5493 d3d10_device_OMSetRenderTargets
,
5494 d3d10_device_OMSetBlendState
,
5495 d3d10_device_OMSetDepthStencilState
,
5496 d3d10_device_SOSetTargets
,
5497 d3d10_device_DrawAuto
,
5498 d3d10_device_RSSetState
,
5499 d3d10_device_RSSetViewports
,
5500 d3d10_device_RSSetScissorRects
,
5501 d3d10_device_CopySubresourceRegion
,
5502 d3d10_device_CopyResource
,
5503 d3d10_device_UpdateSubresource
,
5504 d3d10_device_ClearRenderTargetView
,
5505 d3d10_device_ClearDepthStencilView
,
5506 d3d10_device_GenerateMips
,
5507 d3d10_device_ResolveSubresource
,
5508 d3d10_device_VSGetConstantBuffers
,
5509 d3d10_device_PSGetShaderResources
,
5510 d3d10_device_PSGetShader
,
5511 d3d10_device_PSGetSamplers
,
5512 d3d10_device_VSGetShader
,
5513 d3d10_device_PSGetConstantBuffers
,
5514 d3d10_device_IAGetInputLayout
,
5515 d3d10_device_IAGetVertexBuffers
,
5516 d3d10_device_IAGetIndexBuffer
,
5517 d3d10_device_GSGetConstantBuffers
,
5518 d3d10_device_GSGetShader
,
5519 d3d10_device_IAGetPrimitiveTopology
,
5520 d3d10_device_VSGetShaderResources
,
5521 d3d10_device_VSGetSamplers
,
5522 d3d10_device_GetPredication
,
5523 d3d10_device_GSGetShaderResources
,
5524 d3d10_device_GSGetSamplers
,
5525 d3d10_device_OMGetRenderTargets
,
5526 d3d10_device_OMGetBlendState
,
5527 d3d10_device_OMGetDepthStencilState
,
5528 d3d10_device_SOGetTargets
,
5529 d3d10_device_RSGetState
,
5530 d3d10_device_RSGetViewports
,
5531 d3d10_device_RSGetScissorRects
,
5532 d3d10_device_GetDeviceRemovedReason
,
5533 d3d10_device_SetExceptionMode
,
5534 d3d10_device_GetExceptionMode
,
5535 d3d10_device_GetPrivateData
,
5536 d3d10_device_SetPrivateData
,
5537 d3d10_device_SetPrivateDataInterface
,
5538 d3d10_device_ClearState
,
5540 d3d10_device_CreateBuffer
,
5541 d3d10_device_CreateTexture1D
,
5542 d3d10_device_CreateTexture2D
,
5543 d3d10_device_CreateTexture3D
,
5544 d3d10_device_CreateShaderResourceView
,
5545 d3d10_device_CreateRenderTargetView
,
5546 d3d10_device_CreateDepthStencilView
,
5547 d3d10_device_CreateInputLayout
,
5548 d3d10_device_CreateVertexShader
,
5549 d3d10_device_CreateGeometryShader
,
5550 d3d10_device_CreateGeometryShaderWithStreamOutput
,
5551 d3d10_device_CreatePixelShader
,
5552 d3d10_device_CreateBlendState
,
5553 d3d10_device_CreateDepthStencilState
,
5554 d3d10_device_CreateRasterizerState
,
5555 d3d10_device_CreateSamplerState
,
5556 d3d10_device_CreateQuery
,
5557 d3d10_device_CreatePredicate
,
5558 d3d10_device_CreateCounter
,
5559 d3d10_device_CheckFormatSupport
,
5560 d3d10_device_CheckMultisampleQualityLevels
,
5561 d3d10_device_CheckCounterInfo
,
5562 d3d10_device_CheckCounter
,
5563 d3d10_device_GetCreationFlags
,
5564 d3d10_device_OpenSharedResource
,
5565 d3d10_device_SetTextFilterSize
,
5566 d3d10_device_GetTextFilterSize
,
5567 d3d10_device_CreateShaderResourceView1
,
5568 d3d10_device_CreateBlendState1
,
5569 d3d10_device_GetFeatureLevel
,
5572 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
5574 /* IUnknown methods */
5575 d3d_device_inner_QueryInterface
,
5576 d3d_device_inner_AddRef
,
5577 d3d_device_inner_Release
,
5580 /* ID3D10Multithread methods */
5582 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
5584 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
5587 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
5589 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5591 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
5593 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
5596 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
5598 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5600 TRACE("iface %p.\n", iface
);
5602 return IUnknown_AddRef(device
->outer_unk
);
5605 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
5607 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5609 TRACE("iface %p.\n", iface
);
5611 return IUnknown_Release(device
->outer_unk
);
5614 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
5616 TRACE("iface %p.\n", iface
);
5618 wined3d_mutex_lock();
5621 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
5623 TRACE("iface %p.\n", iface
);
5625 wined3d_mutex_unlock();
5628 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
5630 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
5635 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
5637 FIXME("iface %p stub!\n", iface
);
5642 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
5644 d3d10_multithread_QueryInterface
,
5645 d3d10_multithread_AddRef
,
5646 d3d10_multithread_Release
,
5647 d3d10_multithread_Enter
,
5648 d3d10_multithread_Leave
,
5649 d3d10_multithread_SetMultithreadProtected
,
5650 d3d10_multithread_GetMultithreadProtected
,
5653 /* IWineDXGIDeviceParent IUnknown methods */
5655 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
5657 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
5660 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
5661 REFIID riid
, void **ppv
)
5663 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5664 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
5667 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
5669 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5670 return IUnknown_AddRef(device
->outer_unk
);
5673 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
5675 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5676 return IUnknown_Release(device
->outer_unk
);
5679 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
5680 IWineDXGIDeviceParent
*iface
)
5682 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5683 return &device
->device_parent
;
5686 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
5688 /* IUnknown methods */
5689 dxgi_device_parent_QueryInterface
,
5690 dxgi_device_parent_AddRef
,
5691 dxgi_device_parent_Release
,
5692 /* IWineDXGIDeviceParent methods */
5693 dxgi_device_parent_get_wined3d_device_parent
,
5696 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
5698 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
5701 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
5702 struct wined3d_device
*wined3d_device
)
5704 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5706 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
5708 wined3d_device_incref(wined3d_device
);
5709 device
->wined3d_device
= wined3d_device
;
5712 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
5714 TRACE("device_parent %p.\n", device_parent
);
5717 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
5719 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
5722 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
5723 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
5724 const struct wined3d_parent_ops
**parent_ops
)
5726 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
5727 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
5730 *parent_ops
= &d3d_null_wined3d_parent_ops
;
5735 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
5736 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
5737 struct wined3d_texture
**wined3d_texture
)
5739 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5740 struct d3d_texture2d
*texture
;
5741 ID3D10Texture2D
*texture_iface
;
5742 D3D10_TEXTURE2D_DESC desc
;
5745 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, texture flags %#x, "
5746 "wined3d_texture %p partial stub!\n", device_parent
, container_parent
,
5747 wined3d_desc
, texture_flags
, wined3d_texture
);
5749 FIXME("Implement DXGI<->wined3d usage conversion.\n");
5751 desc
.Width
= wined3d_desc
->width
;
5752 desc
.Height
= wined3d_desc
->height
;
5755 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
5756 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
5757 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
5758 desc
.Usage
= D3D10_USAGE_DEFAULT
;
5759 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5760 desc
.CPUAccessFlags
= 0;
5763 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
5765 desc
.MiscFlags
|= D3D10_RESOURCE_MISC_GDI_COMPATIBLE
;
5766 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
5770 FIXME("Unhandled flags %#x.\n", texture_flags
);
5772 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
5773 &desc
, NULL
, &texture_iface
)))
5775 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
5779 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5781 *wined3d_texture
= texture
->wined3d_texture
;
5782 wined3d_texture_incref(*wined3d_texture
);
5783 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5788 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5789 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5791 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5792 IWineDXGIDevice
*wine_device
;
5795 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5797 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5798 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5800 ERR("Device should implement IWineDXGIDevice.\n");
5804 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, TRUE
, swapchain
);
5805 IWineDXGIDevice_Release(wine_device
);
5808 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5815 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5817 device_parent_wined3d_device_created
,
5818 device_parent_mode_changed
,
5819 device_parent_activate
,
5820 device_parent_sub_resource_created
,
5821 device_parent_sub_resource_created
,
5822 device_parent_create_swapchain_texture
,
5823 device_parent_create_swapchain
,
5826 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5828 const D3D11_SAMPLER_DESC
*ka
= key
;
5829 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5831 return memcmp(ka
, kb
, sizeof(*ka
));
5834 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5836 const D3D11_BLEND_DESC
*ka
= key
;
5837 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5839 return memcmp(ka
, kb
, sizeof(*ka
));
5842 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5844 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5845 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5846 const struct d3d_depthstencil_state
, entry
)->desc
;
5848 return memcmp(ka
, kb
, sizeof(*ka
));
5851 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5853 const D3D11_RASTERIZER_DESC
*ka
= key
;
5854 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5856 return memcmp(ka
, kb
, sizeof(*ka
));
5859 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5861 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5862 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5863 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5864 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5865 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5866 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5867 device
->refcount
= 1;
5868 /* COM aggregation always takes place */
5869 device
->outer_unk
= outer_unknown
;
5871 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5872 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5874 device
->blend_factor
[0] = 1.0f
;
5875 device
->blend_factor
[1] = 1.0f
;
5876 device
->blend_factor
[2] = 1.0f
;
5877 device
->blend_factor
[3] = 1.0f
;
5879 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
5880 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
5881 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
5882 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);