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 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
848 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
849 ID3D11Buffer
*buffer
, UINT offset
)
851 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
854 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
855 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
857 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
859 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
860 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
862 wined3d_mutex_lock();
863 wined3d_device_dispatch_compute(device
->wined3d_device
,
864 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
865 wined3d_mutex_unlock();
868 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
869 ID3D11Buffer
*buffer
, UINT offset
)
871 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
872 struct d3d_buffer
*buffer_impl
;
874 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
876 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
878 wined3d_mutex_lock();
879 wined3d_device_dispatch_compute_indirect(device
->wined3d_device
,
880 buffer_impl
->wined3d_buffer
, offset
);
881 wined3d_mutex_unlock();
884 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
885 ID3D11RasterizerState
*rasterizer_state
)
887 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
888 struct d3d_rasterizer_state
*rasterizer_state_impl
;
889 const D3D11_RASTERIZER_DESC
*desc
;
891 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
893 wined3d_mutex_lock();
894 if (!(rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
896 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
897 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
898 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_BACK
);
899 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
900 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
901 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
902 wined3d_mutex_unlock();
906 wined3d_device_set_rasterizer_state(device
->wined3d_device
, rasterizer_state_impl
->wined3d_state
);
908 desc
= &rasterizer_state_impl
->desc
;
909 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
910 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
911 /* OpenGL style depth bias. */
912 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
913 FIXME("Ignoring depth bias.\n");
915 if (!desc
->DepthClipEnable
)
916 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
917 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
918 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
919 wined3d_device_set_render_state(device
->wined3d_device
,
920 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
921 wined3d_mutex_unlock();
924 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
925 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
927 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
928 struct wined3d_viewport wined3d_vp
;
930 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
932 if (viewport_count
> 1)
933 FIXME("Multiple viewports not implemented.\n");
938 wined3d_vp
.x
= viewports
[0].TopLeftX
;
939 wined3d_vp
.y
= viewports
[0].TopLeftY
;
940 wined3d_vp
.width
= viewports
[0].Width
;
941 wined3d_vp
.height
= viewports
[0].Height
;
942 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
943 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
945 wined3d_mutex_lock();
946 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
947 wined3d_mutex_unlock();
950 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
951 UINT rect_count
, const D3D11_RECT
*rects
)
953 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
955 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
958 FIXME("Multiple scissor rects not implemented.\n");
963 wined3d_mutex_lock();
964 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
965 wined3d_mutex_unlock();
968 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
969 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
970 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
972 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
973 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
974 struct wined3d_box wined3d_src_box
;
976 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
977 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
978 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
979 src_resource
, src_subresource_idx
, src_box
);
982 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
983 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
985 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
986 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
987 wined3d_mutex_lock();
988 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
989 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
990 wined3d_mutex_unlock();
993 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
994 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
996 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
997 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
999 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1001 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1002 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1003 wined3d_mutex_lock();
1004 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1005 wined3d_mutex_unlock();
1008 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
1009 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1010 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1012 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1013 struct wined3d_resource
*wined3d_resource
;
1014 struct wined3d_box wined3d_box
;
1016 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1017 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1020 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1022 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1023 wined3d_mutex_lock();
1024 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1025 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
1026 wined3d_mutex_unlock();
1029 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
1030 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1032 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1033 struct d3d11_unordered_access_view
*uav
;
1034 struct d3d_buffer
*buffer_impl
;
1036 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1037 iface
, dst_buffer
, dst_offset
, src_view
);
1039 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1040 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1042 wined3d_mutex_lock();
1043 wined3d_device_copy_uav_counter(device
->wined3d_device
,
1044 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1045 wined3d_mutex_unlock();
1048 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
1049 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1051 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1052 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1053 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1056 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1057 iface
, render_target_view
, debug_float4(color_rgba
));
1062 wined3d_mutex_lock();
1063 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1064 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1065 ERR("Failed to clear view, hr %#x.\n", hr
);
1066 wined3d_mutex_unlock();
1069 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
1070 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1072 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1073 struct d3d11_unordered_access_view
*view
;
1075 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1076 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1078 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1079 wined3d_mutex_lock();
1080 wined3d_device_clear_unordered_access_view_uint(device
->wined3d_device
,
1081 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1082 wined3d_mutex_unlock();
1085 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
1086 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1088 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1089 iface
, unordered_access_view
, debug_float4(values
));
1092 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
1093 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1095 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1096 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1097 DWORD wined3d_flags
;
1100 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1101 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1106 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1108 wined3d_mutex_lock();
1109 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1110 wined3d_flags
, NULL
, depth
, stencil
)))
1111 ERR("Failed to clear view, hr %#x.\n", hr
);
1112 wined3d_mutex_unlock();
1115 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1116 ID3D11ShaderResourceView
*view
)
1118 FIXME("iface %p, view %p stub!\n", iface
, view
);
1121 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1122 ID3D11Resource
*resource
, FLOAT min_lod
)
1124 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1127 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1128 ID3D11Resource
*resource
)
1130 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1135 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1136 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1137 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1140 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1141 "format %s stub!\n",
1142 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1143 debug_dxgi_format(format
));
1146 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1147 ID3D11CommandList
*command_list
, BOOL restore_state
)
1149 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1152 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1153 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1155 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1158 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1159 iface
, start_slot
, view_count
, views
);
1161 wined3d_mutex_lock();
1162 for (i
= 0; i
< view_count
; ++i
)
1164 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1166 wined3d_device_set_hs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1167 view
? view
->wined3d_view
: NULL
);
1169 wined3d_mutex_unlock();
1172 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1173 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1175 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1176 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1178 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1179 iface
, shader
, class_instances
, class_instance_count
);
1181 if (class_instances
)
1182 FIXME("Dynamic linking is not implemented yet.\n");
1184 wined3d_mutex_lock();
1185 wined3d_device_set_hull_shader(device
->wined3d_device
, hs
? hs
->wined3d_shader
: NULL
);
1186 wined3d_mutex_unlock();
1189 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1190 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1192 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1195 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1196 iface
, start_slot
, sampler_count
, samplers
);
1198 wined3d_mutex_lock();
1199 for (i
= 0; i
< sampler_count
; ++i
)
1201 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1203 wined3d_device_set_hs_sampler(device
->wined3d_device
, start_slot
+ i
,
1204 sampler
? sampler
->wined3d_sampler
: NULL
);
1206 wined3d_mutex_unlock();
1209 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1210 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1212 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1215 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1216 iface
, start_slot
, buffer_count
, buffers
);
1218 wined3d_mutex_lock();
1219 for (i
= 0; i
< buffer_count
; ++i
)
1221 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1223 wined3d_device_set_hs_cb(device
->wined3d_device
, start_slot
+ i
,
1224 buffer
? buffer
->wined3d_buffer
: NULL
);
1226 wined3d_mutex_unlock();
1229 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1230 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1232 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1235 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1236 iface
, start_slot
, view_count
, views
);
1238 wined3d_mutex_lock();
1239 for (i
= 0; i
< view_count
; ++i
)
1241 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1243 wined3d_device_set_ds_resource_view(device
->wined3d_device
, start_slot
+ i
,
1244 view
? view
->wined3d_view
: NULL
);
1246 wined3d_mutex_unlock();
1249 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1250 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1252 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1253 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1255 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1256 iface
, shader
, class_instances
, class_instance_count
);
1258 if (class_instances
)
1259 FIXME("Dynamic linking is not implemented yet.\n");
1261 wined3d_mutex_lock();
1262 wined3d_device_set_domain_shader(device
->wined3d_device
, ds
? ds
->wined3d_shader
: NULL
);
1263 wined3d_mutex_unlock();
1266 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1267 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1269 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1272 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1273 iface
, start_slot
, sampler_count
, samplers
);
1275 wined3d_mutex_lock();
1276 for (i
= 0; i
< sampler_count
; ++i
)
1278 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1280 wined3d_device_set_ds_sampler(device
->wined3d_device
, start_slot
+ i
,
1281 sampler
? sampler
->wined3d_sampler
: NULL
);
1283 wined3d_mutex_unlock();
1286 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1287 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1289 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1292 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1293 iface
, start_slot
, buffer_count
, buffers
);
1295 wined3d_mutex_lock();
1296 for (i
= 0; i
< buffer_count
; ++i
)
1298 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1300 wined3d_device_set_ds_cb(device
->wined3d_device
, start_slot
+ i
,
1301 buffer
? buffer
->wined3d_buffer
: NULL
);
1303 wined3d_mutex_unlock();
1306 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1307 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1309 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1312 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1313 iface
, start_slot
, view_count
, views
);
1315 wined3d_mutex_lock();
1316 for (i
= 0; i
< view_count
; ++i
)
1318 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1320 wined3d_device_set_cs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1321 view
? view
->wined3d_view
: NULL
);
1323 wined3d_mutex_unlock();
1326 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1327 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1329 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1332 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1333 iface
, start_slot
, view_count
, views
, initial_counts
);
1335 wined3d_mutex_lock();
1336 for (i
= 0; i
< view_count
; ++i
)
1338 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1340 wined3d_device_set_cs_uav(device
->wined3d_device
, start_slot
+ i
,
1341 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
1343 wined3d_mutex_unlock();
1346 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1347 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1349 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1350 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1352 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1353 iface
, shader
, class_instances
, class_instance_count
);
1355 if (class_instances
)
1356 FIXME("Dynamic linking is not implemented yet.\n");
1358 wined3d_mutex_lock();
1359 wined3d_device_set_compute_shader(device
->wined3d_device
, cs
? cs
->wined3d_shader
: NULL
);
1360 wined3d_mutex_unlock();
1363 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1364 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1366 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1369 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1370 iface
, start_slot
, sampler_count
, samplers
);
1372 wined3d_mutex_lock();
1373 for (i
= 0; i
< sampler_count
; ++i
)
1375 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1377 wined3d_device_set_cs_sampler(device
->wined3d_device
, start_slot
+ i
,
1378 sampler
? sampler
->wined3d_sampler
: NULL
);
1380 wined3d_mutex_unlock();
1383 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1384 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1386 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1389 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1390 iface
, start_slot
, buffer_count
, buffers
);
1392 wined3d_mutex_lock();
1393 for (i
= 0; i
< buffer_count
; ++i
)
1395 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1397 wined3d_device_set_cs_cb(device
->wined3d_device
, start_slot
+ i
,
1398 buffer
? buffer
->wined3d_buffer
: NULL
);
1400 wined3d_mutex_unlock();
1403 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1404 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**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 wined3d_buffer
*wined3d_buffer
;
1416 struct d3d_buffer
*buffer_impl
;
1418 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1424 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1425 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1426 ID3D11Buffer_AddRef(buffers
[i
]);
1428 wined3d_mutex_unlock();
1431 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1432 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1434 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1437 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1438 iface
, start_slot
, view_count
, views
);
1440 wined3d_mutex_lock();
1441 for (i
= 0; i
< view_count
; ++i
)
1443 struct wined3d_shader_resource_view
*wined3d_view
;
1444 struct d3d_shader_resource_view
*view_impl
;
1446 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1452 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1453 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1454 ID3D11ShaderResourceView_AddRef(views
[i
]);
1456 wined3d_mutex_unlock();
1459 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1460 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1462 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1463 struct wined3d_shader
*wined3d_shader
;
1464 struct d3d_pixel_shader
*shader_impl
;
1466 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1467 iface
, shader
, class_instances
, class_instance_count
);
1469 if (class_instances
|| class_instance_count
)
1470 FIXME("Dynamic linking not implemented yet.\n");
1472 wined3d_mutex_lock();
1473 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1475 wined3d_mutex_unlock();
1480 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1481 wined3d_mutex_unlock();
1482 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1483 ID3D11PixelShader_AddRef(*shader
);
1486 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1487 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1489 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1492 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1493 iface
, start_slot
, sampler_count
, samplers
);
1495 wined3d_mutex_lock();
1496 for (i
= 0; i
< sampler_count
; ++i
)
1498 struct wined3d_sampler
*wined3d_sampler
;
1499 struct d3d_sampler_state
*sampler_impl
;
1501 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1507 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1508 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1509 ID3D11SamplerState_AddRef(samplers
[i
]);
1511 wined3d_mutex_unlock();
1514 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1515 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1517 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1518 struct d3d_vertex_shader
*shader_impl
;
1519 struct wined3d_shader
*wined3d_shader
;
1521 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1522 iface
, shader
, class_instances
, class_instance_count
);
1524 if (class_instances
|| class_instance_count
)
1525 FIXME("Dynamic linking not implemented yet.\n");
1527 wined3d_mutex_lock();
1528 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1530 wined3d_mutex_unlock();
1535 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1536 wined3d_mutex_unlock();
1537 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1538 ID3D11VertexShader_AddRef(*shader
);
1541 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1542 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1544 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1547 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1548 iface
, start_slot
, buffer_count
, buffers
);
1550 wined3d_mutex_lock();
1551 for (i
= 0; i
< buffer_count
; ++i
)
1553 struct wined3d_buffer
*wined3d_buffer
;
1554 struct d3d_buffer
*buffer_impl
;
1556 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1562 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1563 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1564 ID3D11Buffer_AddRef(buffers
[i
]);
1566 wined3d_mutex_unlock();
1569 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1570 ID3D11InputLayout
**input_layout
)
1572 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1573 struct wined3d_vertex_declaration
*wined3d_declaration
;
1574 struct d3d_input_layout
*input_layout_impl
;
1576 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1578 wined3d_mutex_lock();
1579 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1581 wined3d_mutex_unlock();
1582 *input_layout
= NULL
;
1586 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1587 wined3d_mutex_unlock();
1588 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1589 ID3D11InputLayout_AddRef(*input_layout
);
1592 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1593 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1595 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1598 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1599 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1601 wined3d_mutex_lock();
1602 for (i
= 0; i
< buffer_count
; ++i
)
1604 struct wined3d_buffer
*wined3d_buffer
= NULL
;
1605 struct d3d_buffer
*buffer_impl
;
1607 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1608 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1610 FIXME("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1617 if (!wined3d_buffer
)
1623 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1624 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1626 wined3d_mutex_unlock();
1629 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1630 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1632 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1633 enum wined3d_format_id wined3d_format
;
1634 struct wined3d_buffer
*wined3d_buffer
;
1635 struct d3d_buffer
*buffer_impl
;
1637 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1639 wined3d_mutex_lock();
1640 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1641 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1642 if (!wined3d_buffer
)
1644 wined3d_mutex_unlock();
1649 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1650 wined3d_mutex_unlock();
1651 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1654 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1655 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1657 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1660 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1661 iface
, start_slot
, buffer_count
, buffers
);
1663 wined3d_mutex_lock();
1664 for (i
= 0; i
< buffer_count
; ++i
)
1666 struct wined3d_buffer
*wined3d_buffer
;
1667 struct d3d_buffer
*buffer_impl
;
1669 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1675 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1676 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1677 ID3D11Buffer_AddRef(buffers
[i
]);
1679 wined3d_mutex_unlock();
1682 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1683 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1685 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1686 struct d3d_geometry_shader
*shader_impl
;
1687 struct wined3d_shader
*wined3d_shader
;
1689 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1690 iface
, shader
, class_instances
, class_instance_count
);
1692 if (class_instances
|| class_instance_count
)
1693 FIXME("Dynamic linking not implemented yet.\n");
1695 wined3d_mutex_lock();
1696 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1698 wined3d_mutex_unlock();
1703 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1704 wined3d_mutex_unlock();
1705 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1706 ID3D11GeometryShader_AddRef(*shader
);
1709 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1710 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1712 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1713 enum wined3d_primitive_type primitive_type
;
1714 unsigned int patch_vertex_count
;
1716 TRACE("iface %p, topology %p.\n", iface
, topology
);
1718 wined3d_mutex_lock();
1719 wined3d_device_get_primitive_type(device
->wined3d_device
, &primitive_type
, &patch_vertex_count
);
1720 wined3d_mutex_unlock();
1722 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1725 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1726 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1728 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1731 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1733 wined3d_mutex_lock();
1734 for (i
= 0; i
< view_count
; ++i
)
1736 struct wined3d_shader_resource_view
*wined3d_view
;
1737 struct d3d_shader_resource_view
*view_impl
;
1739 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1745 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1746 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1747 ID3D11ShaderResourceView_AddRef(views
[i
]);
1749 wined3d_mutex_unlock();
1752 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1753 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1755 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1758 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1759 iface
, start_slot
, sampler_count
, samplers
);
1761 wined3d_mutex_lock();
1762 for (i
= 0; i
< sampler_count
; ++i
)
1764 struct wined3d_sampler
*wined3d_sampler
;
1765 struct d3d_sampler_state
*sampler_impl
;
1767 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1773 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1774 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1775 ID3D11SamplerState_AddRef(samplers
[i
]);
1777 wined3d_mutex_unlock();
1780 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1781 ID3D11Predicate
**predicate
, BOOL
*value
)
1783 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1784 struct wined3d_query
*wined3d_predicate
;
1785 struct d3d_query
*predicate_impl
;
1787 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1789 wined3d_mutex_lock();
1790 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1792 wined3d_mutex_unlock();
1797 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1798 wined3d_mutex_unlock();
1799 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1800 ID3D11Predicate_AddRef(*predicate
);
1803 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1804 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1806 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1809 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1811 wined3d_mutex_lock();
1812 for (i
= 0; i
< view_count
; ++i
)
1814 struct wined3d_shader_resource_view
*wined3d_view
;
1815 struct d3d_shader_resource_view
*view_impl
;
1817 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1823 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1824 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1825 ID3D11ShaderResourceView_AddRef(views
[i
]);
1827 wined3d_mutex_unlock();
1830 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1831 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1833 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1836 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1837 iface
, start_slot
, sampler_count
, samplers
);
1839 wined3d_mutex_lock();
1840 for (i
= 0; i
< sampler_count
; ++i
)
1842 struct d3d_sampler_state
*sampler_impl
;
1843 struct wined3d_sampler
*wined3d_sampler
;
1845 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1851 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1852 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1853 ID3D11SamplerState_AddRef(samplers
[i
]);
1855 wined3d_mutex_unlock();
1858 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1859 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1860 ID3D11DepthStencilView
**depth_stencil_view
)
1862 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1863 struct wined3d_rendertarget_view
*wined3d_view
;
1865 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1866 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1868 wined3d_mutex_lock();
1869 if (render_target_views
)
1871 struct d3d_rendertarget_view
*view_impl
;
1874 for (i
= 0; i
< render_target_view_count
; ++i
)
1876 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1877 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1879 render_target_views
[i
] = NULL
;
1883 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1884 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1888 if (depth_stencil_view
)
1890 struct d3d_depthstencil_view
*view_impl
;
1892 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1893 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1895 *depth_stencil_view
= NULL
;
1899 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1900 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1903 wined3d_mutex_unlock();
1906 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1907 ID3D11DeviceContext
*iface
,
1908 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1909 ID3D11DepthStencilView
**depth_stencil_view
,
1910 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1911 ID3D11UnorderedAccessView
**unordered_access_views
)
1913 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1914 struct wined3d_unordered_access_view
*wined3d_view
;
1915 struct d3d11_unordered_access_view
*view_impl
;
1918 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1919 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1920 "unordered_access_views %p.\n",
1921 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1922 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1924 if (render_target_views
|| depth_stencil_view
)
1925 d3d11_immediate_context_OMGetRenderTargets(iface
, render_target_view_count
,
1926 render_target_views
, depth_stencil_view
);
1928 if (unordered_access_views
)
1930 wined3d_mutex_lock();
1931 for (i
= 0; i
< unordered_access_view_count
; ++i
)
1933 if (!(wined3d_view
= wined3d_device_get_unordered_access_view(device
->wined3d_device
,
1934 unordered_access_view_start_slot
+ i
)))
1936 unordered_access_views
[i
] = NULL
;
1940 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
1941 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
1942 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
1944 wined3d_mutex_unlock();
1948 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1949 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1951 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1953 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1954 iface
, blend_state
, blend_factor
, sample_mask
);
1956 if ((*blend_state
= device
->blend_state
? &device
->blend_state
->ID3D11BlendState_iface
: NULL
))
1957 ID3D11BlendState_AddRef(*blend_state
);
1958 wined3d_mutex_lock();
1959 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
1960 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1961 wined3d_mutex_unlock();
1964 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1965 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1967 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1969 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1970 iface
, depth_stencil_state
, stencil_ref
);
1972 if ((*depth_stencil_state
= device
->depth_stencil_state
1973 ? &device
->depth_stencil_state
->ID3D11DepthStencilState_iface
: NULL
))
1974 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
1975 *stencil_ref
= device
->stencil_ref
;
1978 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1979 UINT buffer_count
, ID3D11Buffer
**buffers
)
1981 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1984 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1986 wined3d_mutex_lock();
1987 for (i
= 0; i
< buffer_count
; ++i
)
1989 struct wined3d_buffer
*wined3d_buffer
;
1990 struct d3d_buffer
*buffer_impl
;
1992 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1998 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1999 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
2000 ID3D11Buffer_AddRef(buffers
[i
]);
2002 wined3d_mutex_unlock();
2005 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
2006 ID3D11RasterizerState
**rasterizer_state
)
2008 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2009 struct d3d_rasterizer_state
*rasterizer_state_impl
;
2010 struct wined3d_rasterizer_state
*wined3d_state
;
2012 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
2014 wined3d_mutex_lock();
2015 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
2017 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
2018 ID3D11RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D11RasterizerState_iface
);
2022 *rasterizer_state
= NULL
;
2024 wined3d_mutex_unlock();
2027 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
2028 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
2030 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2031 struct wined3d_viewport wined3d_vp
;
2033 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2037 *viewport_count
= 1;
2041 if (!*viewport_count
)
2044 wined3d_mutex_lock();
2045 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
2046 wined3d_mutex_unlock();
2048 viewports
[0].TopLeftX
= wined3d_vp
.x
;
2049 viewports
[0].TopLeftY
= wined3d_vp
.y
;
2050 viewports
[0].Width
= wined3d_vp
.width
;
2051 viewports
[0].Height
= wined3d_vp
.height
;
2052 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
2053 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
2055 if (*viewport_count
> 1)
2056 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
2059 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
2060 UINT
*rect_count
, D3D11_RECT
*rects
)
2062 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2064 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2075 wined3d_mutex_lock();
2076 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
2077 wined3d_mutex_unlock();
2078 if (*rect_count
> 1)
2079 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
2082 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
2083 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2085 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2088 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2090 wined3d_mutex_lock();
2091 for (i
= 0; i
< view_count
; ++i
)
2093 struct wined3d_shader_resource_view
*wined3d_view
;
2094 struct d3d_shader_resource_view
*view_impl
;
2096 if (!(wined3d_view
= wined3d_device_get_hs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2102 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2103 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2105 wined3d_mutex_unlock();
2108 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
2109 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2111 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2112 struct d3d11_hull_shader
*shader_impl
;
2113 struct wined3d_shader
*wined3d_shader
;
2115 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2116 iface
, shader
, class_instances
, class_instance_count
);
2118 if (class_instances
|| class_instance_count
)
2119 FIXME("Dynamic linking not implemented yet.\n");
2121 wined3d_mutex_lock();
2122 if (!(wined3d_shader
= wined3d_device_get_hull_shader(device
->wined3d_device
)))
2124 wined3d_mutex_unlock();
2129 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2130 wined3d_mutex_unlock();
2131 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2134 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
2135 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2137 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2140 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2141 iface
, start_slot
, sampler_count
, samplers
);
2143 wined3d_mutex_lock();
2144 for (i
= 0; i
< sampler_count
; ++i
)
2146 struct wined3d_sampler
*wined3d_sampler
;
2147 struct d3d_sampler_state
*sampler_impl
;
2149 if (!(wined3d_sampler
= wined3d_device_get_hs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2155 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2156 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2158 wined3d_mutex_unlock();
2161 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
2162 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2164 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2167 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2168 iface
, start_slot
, buffer_count
, buffers
);
2170 wined3d_mutex_lock();
2171 for (i
= 0; i
< buffer_count
; ++i
)
2173 struct wined3d_buffer
*wined3d_buffer
;
2174 struct d3d_buffer
*buffer_impl
;
2176 if (!(wined3d_buffer
= wined3d_device_get_hs_cb(device
->wined3d_device
, start_slot
+ i
)))
2182 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2183 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
2185 wined3d_mutex_unlock();
2188 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
2189 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2191 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2194 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2195 iface
, start_slot
, view_count
, views
);
2197 wined3d_mutex_lock();
2198 for (i
= 0; i
< view_count
; ++i
)
2200 struct wined3d_shader_resource_view
*wined3d_view
;
2201 struct d3d_shader_resource_view
*view_impl
;
2203 if (!(wined3d_view
= wined3d_device_get_ds_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2209 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2210 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2212 wined3d_mutex_unlock();
2215 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
2216 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2218 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2219 struct d3d11_domain_shader
*shader_impl
;
2220 struct wined3d_shader
*wined3d_shader
;
2222 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2223 iface
, shader
, class_instances
, class_instance_count
);
2225 if (class_instances
|| class_instance_count
)
2226 FIXME("Dynamic linking not implemented yet.\n");
2228 wined3d_mutex_lock();
2229 if (!(wined3d_shader
= wined3d_device_get_domain_shader(device
->wined3d_device
)))
2231 wined3d_mutex_unlock();
2236 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2237 wined3d_mutex_unlock();
2238 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2241 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
2242 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2244 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2247 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2248 iface
, start_slot
, sampler_count
, samplers
);
2250 wined3d_mutex_lock();
2251 for (i
= 0; i
< sampler_count
; ++i
)
2253 struct wined3d_sampler
*wined3d_sampler
;
2254 struct d3d_sampler_state
*sampler_impl
;
2256 if (!(wined3d_sampler
= wined3d_device_get_ds_sampler(device
->wined3d_device
, start_slot
+ i
)))
2262 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2263 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2265 wined3d_mutex_unlock();
2268 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
2269 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2271 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2274 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2275 iface
, start_slot
, buffer_count
, buffers
);
2277 wined3d_mutex_lock();
2278 for (i
= 0; i
< buffer_count
; ++i
)
2280 struct wined3d_buffer
*wined3d_buffer
;
2281 struct d3d_buffer
*buffer_impl
;
2283 if (!(wined3d_buffer
= wined3d_device_get_ds_cb(device
->wined3d_device
, start_slot
+ i
)))
2289 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2290 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
2292 wined3d_mutex_unlock();
2295 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
2296 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2298 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2301 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2303 wined3d_mutex_lock();
2304 for (i
= 0; i
< view_count
; ++i
)
2306 struct wined3d_shader_resource_view
*wined3d_view
;
2307 struct d3d_shader_resource_view
*view_impl
;
2309 if (!(wined3d_view
= wined3d_device_get_cs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2315 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2316 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2318 wined3d_mutex_unlock();
2321 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
2322 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2324 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2327 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2329 wined3d_mutex_lock();
2330 for (i
= 0; i
< view_count
; ++i
)
2332 struct wined3d_unordered_access_view
*wined3d_view
;
2333 struct d3d11_unordered_access_view
*view_impl
;
2335 if (!(wined3d_view
= wined3d_device_get_cs_uav(device
->wined3d_device
, start_slot
+ i
)))
2341 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2342 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2344 wined3d_mutex_unlock();
2347 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
2348 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2350 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2351 struct d3d11_compute_shader
*shader_impl
;
2352 struct wined3d_shader
*wined3d_shader
;
2354 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2355 iface
, shader
, class_instances
, class_instance_count
);
2357 if (class_instances
|| class_instance_count
)
2358 FIXME("Dynamic linking not implemented yet.\n");
2360 wined3d_mutex_lock();
2361 if (!(wined3d_shader
= wined3d_device_get_compute_shader(device
->wined3d_device
)))
2363 wined3d_mutex_unlock();
2368 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2369 wined3d_mutex_unlock();
2370 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2373 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
2374 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2376 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2379 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2380 iface
, start_slot
, sampler_count
, samplers
);
2382 wined3d_mutex_lock();
2383 for (i
= 0; i
< sampler_count
; ++i
)
2385 struct wined3d_sampler
*wined3d_sampler
;
2386 struct d3d_sampler_state
*sampler_impl
;
2388 if (!(wined3d_sampler
= wined3d_device_get_cs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2394 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2395 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2397 wined3d_mutex_unlock();
2400 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
2401 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2403 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2406 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2407 iface
, start_slot
, buffer_count
, buffers
);
2409 wined3d_mutex_lock();
2410 for (i
= 0; i
< buffer_count
; ++i
)
2412 struct wined3d_buffer
*wined3d_buffer
;
2413 struct d3d_buffer
*buffer_impl
;
2415 if (!(wined3d_buffer
= wined3d_device_get_cs_cb(device
->wined3d_device
, start_slot
+ i
)))
2421 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2422 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
2424 wined3d_mutex_unlock();
2427 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
2429 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
2430 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
2433 TRACE("iface %p.\n", iface
);
2435 wined3d_mutex_lock();
2436 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
2437 wined3d_device_set_hull_shader(device
->wined3d_device
, NULL
);
2438 wined3d_device_set_domain_shader(device
->wined3d_device
, NULL
);
2439 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
2440 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
2441 wined3d_device_set_compute_shader(device
->wined3d_device
, NULL
);
2442 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
2444 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
2445 wined3d_device_set_hs_sampler(device
->wined3d_device
, i
, NULL
);
2446 wined3d_device_set_ds_sampler(device
->wined3d_device
, i
, NULL
);
2447 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
2448 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
2449 wined3d_device_set_cs_sampler(device
->wined3d_device
, i
, NULL
);
2451 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2453 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
2454 wined3d_device_set_hs_resource_view(device
->wined3d_device
, i
, NULL
);
2455 wined3d_device_set_ds_resource_view(device
->wined3d_device
, i
, NULL
);
2456 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
2457 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
2458 wined3d_device_set_cs_resource_view(device
->wined3d_device
, i
, NULL
);
2460 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
2462 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
2463 wined3d_device_set_hs_cb(device
->wined3d_device
, i
, NULL
);
2464 wined3d_device_set_ds_cb(device
->wined3d_device
, i
, NULL
);
2465 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
2466 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
2467 wined3d_device_set_cs_cb(device
->wined3d_device
, i
, NULL
);
2469 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2471 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
2473 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
2474 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
2475 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
, 0);
2476 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2478 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
2480 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
2481 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
2483 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
2484 wined3d_device_set_cs_uav(device
->wined3d_device
, i
, NULL
, ~0u);
2486 ID3D11DeviceContext_OMSetDepthStencilState(iface
, NULL
, 0);
2487 ID3D11DeviceContext_OMSetBlendState(iface
, NULL
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
2488 ID3D11DeviceContext_RSSetViewports(iface
, 0, NULL
);
2489 ID3D11DeviceContext_RSSetScissorRects(iface
, 0, NULL
);
2490 ID3D11DeviceContext_RSSetState(iface
, NULL
);
2491 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
2493 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
2495 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
2496 wined3d_mutex_unlock();
2499 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
2501 FIXME("iface %p stub!\n", iface
);
2504 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
2506 TRACE("iface %p.\n", iface
);
2508 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
2511 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
2513 FIXME("iface %p stub!\n", iface
);
2518 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
2519 BOOL restore
, ID3D11CommandList
**command_list
)
2521 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
2526 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
2528 /* IUnknown methods */
2529 d3d11_immediate_context_QueryInterface
,
2530 d3d11_immediate_context_AddRef
,
2531 d3d11_immediate_context_Release
,
2532 /* ID3D11DeviceChild methods */
2533 d3d11_immediate_context_GetDevice
,
2534 d3d11_immediate_context_GetPrivateData
,
2535 d3d11_immediate_context_SetPrivateData
,
2536 d3d11_immediate_context_SetPrivateDataInterface
,
2537 /* ID3D11DeviceContext methods */
2538 d3d11_immediate_context_VSSetConstantBuffers
,
2539 d3d11_immediate_context_PSSetShaderResources
,
2540 d3d11_immediate_context_PSSetShader
,
2541 d3d11_immediate_context_PSSetSamplers
,
2542 d3d11_immediate_context_VSSetShader
,
2543 d3d11_immediate_context_DrawIndexed
,
2544 d3d11_immediate_context_Draw
,
2545 d3d11_immediate_context_Map
,
2546 d3d11_immediate_context_Unmap
,
2547 d3d11_immediate_context_PSSetConstantBuffers
,
2548 d3d11_immediate_context_IASetInputLayout
,
2549 d3d11_immediate_context_IASetVertexBuffers
,
2550 d3d11_immediate_context_IASetIndexBuffer
,
2551 d3d11_immediate_context_DrawIndexedInstanced
,
2552 d3d11_immediate_context_DrawInstanced
,
2553 d3d11_immediate_context_GSSetConstantBuffers
,
2554 d3d11_immediate_context_GSSetShader
,
2555 d3d11_immediate_context_IASetPrimitiveTopology
,
2556 d3d11_immediate_context_VSSetShaderResources
,
2557 d3d11_immediate_context_VSSetSamplers
,
2558 d3d11_immediate_context_Begin
,
2559 d3d11_immediate_context_End
,
2560 d3d11_immediate_context_GetData
,
2561 d3d11_immediate_context_SetPredication
,
2562 d3d11_immediate_context_GSSetShaderResources
,
2563 d3d11_immediate_context_GSSetSamplers
,
2564 d3d11_immediate_context_OMSetRenderTargets
,
2565 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
2566 d3d11_immediate_context_OMSetBlendState
,
2567 d3d11_immediate_context_OMSetDepthStencilState
,
2568 d3d11_immediate_context_SOSetTargets
,
2569 d3d11_immediate_context_DrawAuto
,
2570 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
2571 d3d11_immediate_context_DrawInstancedIndirect
,
2572 d3d11_immediate_context_Dispatch
,
2573 d3d11_immediate_context_DispatchIndirect
,
2574 d3d11_immediate_context_RSSetState
,
2575 d3d11_immediate_context_RSSetViewports
,
2576 d3d11_immediate_context_RSSetScissorRects
,
2577 d3d11_immediate_context_CopySubresourceRegion
,
2578 d3d11_immediate_context_CopyResource
,
2579 d3d11_immediate_context_UpdateSubresource
,
2580 d3d11_immediate_context_CopyStructureCount
,
2581 d3d11_immediate_context_ClearRenderTargetView
,
2582 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
2583 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
2584 d3d11_immediate_context_ClearDepthStencilView
,
2585 d3d11_immediate_context_GenerateMips
,
2586 d3d11_immediate_context_SetResourceMinLOD
,
2587 d3d11_immediate_context_GetResourceMinLOD
,
2588 d3d11_immediate_context_ResolveSubresource
,
2589 d3d11_immediate_context_ExecuteCommandList
,
2590 d3d11_immediate_context_HSSetShaderResources
,
2591 d3d11_immediate_context_HSSetShader
,
2592 d3d11_immediate_context_HSSetSamplers
,
2593 d3d11_immediate_context_HSSetConstantBuffers
,
2594 d3d11_immediate_context_DSSetShaderResources
,
2595 d3d11_immediate_context_DSSetShader
,
2596 d3d11_immediate_context_DSSetSamplers
,
2597 d3d11_immediate_context_DSSetConstantBuffers
,
2598 d3d11_immediate_context_CSSetShaderResources
,
2599 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2600 d3d11_immediate_context_CSSetShader
,
2601 d3d11_immediate_context_CSSetSamplers
,
2602 d3d11_immediate_context_CSSetConstantBuffers
,
2603 d3d11_immediate_context_VSGetConstantBuffers
,
2604 d3d11_immediate_context_PSGetShaderResources
,
2605 d3d11_immediate_context_PSGetShader
,
2606 d3d11_immediate_context_PSGetSamplers
,
2607 d3d11_immediate_context_VSGetShader
,
2608 d3d11_immediate_context_PSGetConstantBuffers
,
2609 d3d11_immediate_context_IAGetInputLayout
,
2610 d3d11_immediate_context_IAGetVertexBuffers
,
2611 d3d11_immediate_context_IAGetIndexBuffer
,
2612 d3d11_immediate_context_GSGetConstantBuffers
,
2613 d3d11_immediate_context_GSGetShader
,
2614 d3d11_immediate_context_IAGetPrimitiveTopology
,
2615 d3d11_immediate_context_VSGetShaderResources
,
2616 d3d11_immediate_context_VSGetSamplers
,
2617 d3d11_immediate_context_GetPredication
,
2618 d3d11_immediate_context_GSGetShaderResources
,
2619 d3d11_immediate_context_GSGetSamplers
,
2620 d3d11_immediate_context_OMGetRenderTargets
,
2621 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2622 d3d11_immediate_context_OMGetBlendState
,
2623 d3d11_immediate_context_OMGetDepthStencilState
,
2624 d3d11_immediate_context_SOGetTargets
,
2625 d3d11_immediate_context_RSGetState
,
2626 d3d11_immediate_context_RSGetViewports
,
2627 d3d11_immediate_context_RSGetScissorRects
,
2628 d3d11_immediate_context_HSGetShaderResources
,
2629 d3d11_immediate_context_HSGetShader
,
2630 d3d11_immediate_context_HSGetSamplers
,
2631 d3d11_immediate_context_HSGetConstantBuffers
,
2632 d3d11_immediate_context_DSGetShaderResources
,
2633 d3d11_immediate_context_DSGetShader
,
2634 d3d11_immediate_context_DSGetSamplers
,
2635 d3d11_immediate_context_DSGetConstantBuffers
,
2636 d3d11_immediate_context_CSGetShaderResources
,
2637 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2638 d3d11_immediate_context_CSGetShader
,
2639 d3d11_immediate_context_CSGetSamplers
,
2640 d3d11_immediate_context_CSGetConstantBuffers
,
2641 d3d11_immediate_context_ClearState
,
2642 d3d11_immediate_context_Flush
,
2643 d3d11_immediate_context_GetType
,
2644 d3d11_immediate_context_GetContextFlags
,
2645 d3d11_immediate_context_FinishCommandList
,
2648 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
2650 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
2651 context
->refcount
= 1;
2653 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
2655 wined3d_private_store_init(&context
->private_store
);
2658 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
2660 wined3d_private_store_cleanup(&context
->private_store
);
2663 /* ID3D11Device methods */
2665 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
2667 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2668 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
2671 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
2673 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2674 return IUnknown_AddRef(device
->outer_unk
);
2677 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
2679 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2680 return IUnknown_Release(device
->outer_unk
);
2683 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
2684 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
2686 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2687 struct d3d_buffer
*object
;
2690 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2692 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
2695 *buffer
= &object
->ID3D11Buffer_iface
;
2700 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
2701 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
2703 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2708 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
2709 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2711 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2712 struct d3d_texture2d
*object
;
2715 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2717 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2720 *texture
= &object
->ID3D11Texture2D_iface
;
2725 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2726 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2728 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2729 struct d3d_texture3d
*object
;
2732 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2734 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2737 *texture
= &object
->ID3D11Texture3D_iface
;
2742 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2743 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2745 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2746 struct d3d_shader_resource_view
*object
;
2749 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2752 return E_INVALIDARG
;
2754 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2757 *view
= &object
->ID3D11ShaderResourceView_iface
;
2762 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2763 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2765 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2766 struct d3d11_unordered_access_view
*object
;
2769 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2771 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
2774 *view
= &object
->ID3D11UnorderedAccessView_iface
;
2779 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2780 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2782 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2783 struct d3d_rendertarget_view
*object
;
2786 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2789 return E_INVALIDARG
;
2791 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2794 *view
= &object
->ID3D11RenderTargetView_iface
;
2799 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2800 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2802 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2803 struct d3d_depthstencil_view
*object
;
2806 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2808 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2811 *view
= &object
->ID3D11DepthStencilView_iface
;
2816 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2817 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2818 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2820 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2821 struct d3d_input_layout
*object
;
2824 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2825 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2826 shader_byte_code_length
, input_layout
);
2828 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2829 shader_byte_code
, shader_byte_code_length
, &object
)))
2832 *input_layout
= &object
->ID3D11InputLayout_iface
;
2837 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2838 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2840 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2841 struct d3d_vertex_shader
*object
;
2844 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2845 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2848 FIXME("Class linkage is not implemented yet.\n");
2850 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2853 *shader
= &object
->ID3D11VertexShader_iface
;
2858 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2859 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2861 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2862 struct d3d_geometry_shader
*object
;
2865 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2866 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2869 FIXME("Class linkage is not implemented yet.\n");
2871 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
2872 NULL
, 0, NULL
, 0, 0, &object
)))
2875 *shader
= &object
->ID3D11GeometryShader_iface
;
2880 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2881 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2882 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
2883 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2885 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2886 struct d3d_geometry_shader
*object
;
2889 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2890 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
2891 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2892 rasterizer_stream
, class_linkage
, shader
);
2895 FIXME("Class linkage is not implemented yet.\n");
2897 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
2898 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
2904 *shader
= &object
->ID3D11GeometryShader_iface
;
2909 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2910 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2912 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2913 struct d3d_pixel_shader
*object
;
2916 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2917 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2920 FIXME("Class linkage is not implemented yet.\n");
2922 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2925 *shader
= &object
->ID3D11PixelShader_iface
;
2930 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2931 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2933 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2934 struct d3d11_hull_shader
*object
;
2937 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2938 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2941 FIXME("Class linkage is not implemented yet.\n");
2943 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2946 *shader
= &object
->ID3D11HullShader_iface
;
2951 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2952 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2954 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2955 struct d3d11_domain_shader
*object
;
2958 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2959 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2962 FIXME("Class linkage is not implemented yet.\n");
2964 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2967 *shader
= &object
->ID3D11DomainShader_iface
;
2972 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2973 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2975 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2976 struct d3d11_compute_shader
*object
;
2979 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2980 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2983 FIXME("Class linkage is not implemented yet.\n");
2985 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2988 *shader
= &object
->ID3D11ComputeShader_iface
;
2993 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2994 ID3D11ClassLinkage
**class_linkage
)
2996 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2997 struct d3d11_class_linkage
*object
;
3000 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3002 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3005 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3010 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
3011 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3013 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3014 struct d3d_blend_state
*object
;
3017 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3019 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3022 *blend_state
= &object
->ID3D11BlendState_iface
;
3027 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
3028 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3030 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3031 struct d3d_depthstencil_state
*object
;
3034 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3036 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3039 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3044 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
3045 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3047 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3048 struct d3d_rasterizer_state
*object
;
3051 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3053 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
3056 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
3061 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
3062 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3064 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3065 struct d3d_sampler_state
*object
;
3068 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3070 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3073 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3078 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
3079 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3081 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3082 struct d3d_query
*object
;
3085 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3087 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3092 *query
= &object
->ID3D11Query_iface
;
3096 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3100 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
3101 ID3D11Predicate
**predicate
)
3103 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3104 struct d3d_query
*object
;
3107 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3109 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3114 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3118 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3122 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
3123 ID3D11Counter
**counter
)
3125 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3130 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
3131 ID3D11DeviceContext
**context
)
3133 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3138 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
3141 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
3146 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
3147 UINT
*format_support
)
3149 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3150 struct wined3d_device_creation_parameters params
;
3151 enum wined3d_format_id wined3d_format
;
3152 struct wined3d
*wined3d
;
3157 enum wined3d_resource_type rtype
;
3159 D3D11_FORMAT_SUPPORT flag
;
3163 {WINED3D_RTYPE_TEXTURE_2D
, WINED3DUSAGE_TEXTURE
, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3164 {WINED3D_RTYPE_TEXTURE_3D
, WINED3DUSAGE_TEXTURE
, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3165 {WINED3D_RTYPE_NONE
, WINED3DUSAGE_RENDERTARGET
, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3166 {WINED3D_RTYPE_NONE
, WINED3DUSAGE_DEPTHSTENCIL
, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3170 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3172 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3173 if (format
&& !wined3d_format
)
3175 WARN("Invalid format %#x.\n", format
);
3176 *format_support
= 0;
3180 *format_support
= 0;
3182 wined3d_mutex_lock();
3183 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3184 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3185 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3187 hr
= wined3d_check_device_format(wined3d
, params
.adapter_idx
, params
.device_type
,
3188 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].rtype
, wined3d_format
);
3189 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOAUTOGEN
)
3191 if (hr
!= WINED3D_OK
)
3193 WARN("Failed to check device format support, hr %#x.\n", hr
);
3194 wined3d_mutex_unlock();
3198 *format_support
|= flag_mapping
[i
].flag
;
3200 wined3d_mutex_unlock();
3205 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
3206 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3208 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3209 struct wined3d_device_creation_parameters params
;
3210 struct wined3d
*wined3d
;
3213 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3214 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3216 if (!quality_level_count
)
3217 return E_INVALIDARG
;
3219 *quality_level_count
= 0;
3223 if (sample_count
== 1)
3225 *quality_level_count
= 1;
3228 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3231 wined3d_mutex_lock();
3232 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3233 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3234 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
3235 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3236 wined3d_mutex_unlock();
3238 if (hr
== WINED3DERR_INVALIDCALL
)
3239 return E_INVALIDARG
;
3240 if (hr
== WINED3DERR_NOTAVAILABLE
)
3245 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
3247 FIXME("iface %p, info %p stub!\n", iface
, info
);
3250 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
3251 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3252 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3254 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3255 "units %p, units_length %p, description %p, description_length %p stub!\n",
3256 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3257 units
, units_length
, description
, description_length
);
3262 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
3263 void *feature_support_data
, UINT feature_support_data_size
)
3265 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3266 WINED3DCAPS wined3d_caps
;
3269 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3270 iface
, feature
, feature_support_data
, feature_support_data_size
);
3274 case D3D11_FEATURE_THREADING
:
3276 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
3277 if (feature_support_data_size
!= sizeof(*threading_data
))
3279 WARN("Invalid data size.\n");
3280 return E_INVALIDARG
;
3283 /* We lie about the threading support to make Tomb Raider 2013 and
3284 * Deus Ex: Human Revolution happy. */
3285 FIXME("Returning fake threading support data.\n");
3286 threading_data
->DriverConcurrentCreates
= TRUE
;
3287 threading_data
->DriverCommandLists
= TRUE
;
3291 case D3D11_FEATURE_DOUBLES
:
3293 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
3294 if (feature_support_data_size
!= sizeof(*doubles_data
))
3296 WARN("Invalid data size.\n");
3297 return E_INVALIDARG
;
3300 wined3d_mutex_lock();
3301 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3302 wined3d_mutex_unlock();
3305 WARN("Failed to get device caps, hr %#x.\n", hr
);
3309 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
3313 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
3315 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
3316 if (feature_support_data_size
!= sizeof(*options
))
3318 WARN("Invalid data size.\n");
3319 return E_INVALIDARG
;
3322 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
3327 FIXME("Unhandled feature %#x.\n", feature
);
3332 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
3333 UINT
*data_size
, void *data
)
3335 IDXGIDevice
*dxgi_device
;
3338 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3340 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3342 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
3343 IDXGIDevice_Release(dxgi_device
);
3348 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
3349 UINT data_size
, const void *data
)
3351 IDXGIDevice
*dxgi_device
;
3354 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3356 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3358 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
3359 IDXGIDevice_Release(dxgi_device
);
3364 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
3365 const IUnknown
*data
)
3367 IDXGIDevice
*dxgi_device
;
3370 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
3372 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3374 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
3375 IDXGIDevice_Release(dxgi_device
);
3380 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
3382 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3384 TRACE("iface %p.\n", iface
);
3386 return device
->feature_level
;
3389 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
3391 FIXME("iface %p stub!\n", iface
);
3396 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
3398 FIXME("iface %p stub!\n", iface
);
3403 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
3404 ID3D11DeviceContext
**immediate_context
)
3406 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
3408 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3410 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
3411 ID3D11DeviceContext_AddRef(*immediate_context
);
3414 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
3416 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
3421 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
3423 FIXME("iface %p stub!\n", iface
);
3428 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
3430 /* IUnknown methods */
3431 d3d11_device_QueryInterface
,
3432 d3d11_device_AddRef
,
3433 d3d11_device_Release
,
3434 /* ID3D11Device methods */
3435 d3d11_device_CreateBuffer
,
3436 d3d11_device_CreateTexture1D
,
3437 d3d11_device_CreateTexture2D
,
3438 d3d11_device_CreateTexture3D
,
3439 d3d11_device_CreateShaderResourceView
,
3440 d3d11_device_CreateUnorderedAccessView
,
3441 d3d11_device_CreateRenderTargetView
,
3442 d3d11_device_CreateDepthStencilView
,
3443 d3d11_device_CreateInputLayout
,
3444 d3d11_device_CreateVertexShader
,
3445 d3d11_device_CreateGeometryShader
,
3446 d3d11_device_CreateGeometryShaderWithStreamOutput
,
3447 d3d11_device_CreatePixelShader
,
3448 d3d11_device_CreateHullShader
,
3449 d3d11_device_CreateDomainShader
,
3450 d3d11_device_CreateComputeShader
,
3451 d3d11_device_CreateClassLinkage
,
3452 d3d11_device_CreateBlendState
,
3453 d3d11_device_CreateDepthStencilState
,
3454 d3d11_device_CreateRasterizerState
,
3455 d3d11_device_CreateSamplerState
,
3456 d3d11_device_CreateQuery
,
3457 d3d11_device_CreatePredicate
,
3458 d3d11_device_CreateCounter
,
3459 d3d11_device_CreateDeferredContext
,
3460 d3d11_device_OpenSharedResource
,
3461 d3d11_device_CheckFormatSupport
,
3462 d3d11_device_CheckMultisampleQualityLevels
,
3463 d3d11_device_CheckCounterInfo
,
3464 d3d11_device_CheckCounter
,
3465 d3d11_device_CheckFeatureSupport
,
3466 d3d11_device_GetPrivateData
,
3467 d3d11_device_SetPrivateData
,
3468 d3d11_device_SetPrivateDataInterface
,
3469 d3d11_device_GetFeatureLevel
,
3470 d3d11_device_GetCreationFlags
,
3471 d3d11_device_GetDeviceRemovedReason
,
3472 d3d11_device_GetImmediateContext
,
3473 d3d11_device_SetExceptionMode
,
3474 d3d11_device_GetExceptionMode
,
3477 /* Inner IUnknown methods */
3479 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
3481 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
3484 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
3486 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3488 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
3490 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
3491 || IsEqualGUID(riid
, &IID_IUnknown
))
3493 *out
= &device
->ID3D11Device_iface
;
3495 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
3496 || IsEqualGUID(riid
, &IID_ID3D10Device
))
3498 *out
= &device
->ID3D10Device1_iface
;
3500 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
3502 *out
= &device
->ID3D10Multithread_iface
;
3504 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
3506 *out
= &device
->IWineDXGIDeviceParent_iface
;
3510 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
3512 return E_NOINTERFACE
;
3515 IUnknown_AddRef((IUnknown
*)*out
);
3519 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
3521 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3522 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
3524 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
3529 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
3531 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3532 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
3534 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
3538 d3d11_immediate_context_destroy(&device
->immediate_context
);
3539 if (device
->wined3d_device
)
3541 wined3d_mutex_lock();
3542 wined3d_device_decref(device
->wined3d_device
);
3543 wined3d_mutex_unlock();
3545 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
3546 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3547 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3548 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3554 /* IUnknown methods */
3556 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
3559 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3560 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
3563 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
3565 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3566 return IUnknown_AddRef(device
->outer_unk
);
3569 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
3571 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3572 return IUnknown_Release(device
->outer_unk
);
3575 /* ID3D10Device methods */
3577 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
3578 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3580 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3583 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3584 iface
, start_slot
, buffer_count
, buffers
);
3586 wined3d_mutex_lock();
3587 for (i
= 0; i
< buffer_count
; ++i
)
3589 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3591 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
3592 buffer
? buffer
->wined3d_buffer
: NULL
);
3594 wined3d_mutex_unlock();
3597 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
3598 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3600 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3603 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3604 iface
, start_slot
, view_count
, views
);
3606 wined3d_mutex_lock();
3607 for (i
= 0; i
< view_count
; ++i
)
3609 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3611 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
3612 view
? view
->wined3d_view
: NULL
);
3614 wined3d_mutex_unlock();
3617 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
3618 ID3D10PixelShader
*shader
)
3620 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3621 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
3623 TRACE("iface %p, shader %p\n", iface
, shader
);
3625 wined3d_mutex_lock();
3626 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
3627 wined3d_mutex_unlock();
3630 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
3631 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3633 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3636 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3637 iface
, start_slot
, sampler_count
, samplers
);
3639 wined3d_mutex_lock();
3640 for (i
= 0; i
< sampler_count
; ++i
)
3642 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3644 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
3645 sampler
? sampler
->wined3d_sampler
: NULL
);
3647 wined3d_mutex_unlock();
3650 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
3651 ID3D10VertexShader
*shader
)
3653 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3654 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
3656 TRACE("iface %p, shader %p\n", iface
, shader
);
3658 wined3d_mutex_lock();
3659 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
3660 wined3d_mutex_unlock();
3663 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
3664 UINT start_index_location
, INT base_vertex_location
)
3666 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3668 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
3669 iface
, index_count
, start_index_location
, base_vertex_location
);
3671 wined3d_mutex_lock();
3672 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3673 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
3674 wined3d_mutex_unlock();
3677 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
3678 UINT start_vertex_location
)
3680 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3682 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
3683 iface
, vertex_count
, start_vertex_location
);
3685 wined3d_mutex_lock();
3686 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
3687 wined3d_mutex_unlock();
3690 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
3691 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3693 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3696 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3697 iface
, start_slot
, buffer_count
, buffers
);
3699 wined3d_mutex_lock();
3700 for (i
= 0; i
< buffer_count
; ++i
)
3702 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3704 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
3705 buffer
? buffer
->wined3d_buffer
: NULL
);
3707 wined3d_mutex_unlock();
3710 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
3711 ID3D10InputLayout
*input_layout
)
3713 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3714 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
3716 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
3718 wined3d_mutex_lock();
3719 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
3720 layout
? layout
->wined3d_decl
: NULL
);
3721 wined3d_mutex_unlock();
3724 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
3725 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
3727 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3730 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
3731 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3733 wined3d_mutex_lock();
3734 for (i
= 0; i
< buffer_count
; ++i
)
3736 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3738 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
3739 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3741 wined3d_mutex_unlock();
3744 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3745 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3747 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3748 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3750 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3751 iface
, buffer
, debug_dxgi_format(format
), offset
);
3753 wined3d_mutex_lock();
3754 wined3d_device_set_index_buffer(device
->wined3d_device
,
3755 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3756 wined3dformat_from_dxgi_format(format
), offset
);
3757 wined3d_mutex_unlock();
3760 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3761 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3762 INT base_vertex_location
, UINT start_instance_location
)
3764 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3766 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3767 "base_vertex_location %d, start_instance_location %u.\n",
3768 iface
, instance_index_count
, instance_count
, start_index_location
,
3769 base_vertex_location
, start_instance_location
);
3771 wined3d_mutex_lock();
3772 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3773 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3774 instance_index_count
, start_instance_location
, instance_count
);
3775 wined3d_mutex_unlock();
3778 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3779 UINT instance_vertex_count
, UINT instance_count
,
3780 UINT start_vertex_location
, UINT start_instance_location
)
3782 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3784 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3785 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3786 start_vertex_location
, start_instance_location
);
3788 wined3d_mutex_lock();
3789 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3790 instance_vertex_count
, start_instance_location
, instance_count
);
3791 wined3d_mutex_unlock();
3794 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3795 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3797 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3800 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3801 iface
, start_slot
, buffer_count
, buffers
);
3803 wined3d_mutex_lock();
3804 for (i
= 0; i
< buffer_count
; ++i
)
3806 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3808 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3809 buffer
? buffer
->wined3d_buffer
: NULL
);
3811 wined3d_mutex_unlock();
3814 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3816 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3817 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3819 TRACE("iface %p, shader %p.\n", iface
, shader
);
3821 wined3d_mutex_lock();
3822 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3823 wined3d_mutex_unlock();
3826 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3827 D3D10_PRIMITIVE_TOPOLOGY topology
)
3829 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3831 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
3833 wined3d_mutex_lock();
3834 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
, 0);
3835 wined3d_mutex_unlock();
3838 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3839 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3841 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3844 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3845 iface
, start_slot
, view_count
, views
);
3847 wined3d_mutex_lock();
3848 for (i
= 0; i
< view_count
; ++i
)
3850 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3852 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3853 view
? view
->wined3d_view
: NULL
);
3855 wined3d_mutex_unlock();
3858 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3859 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3861 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3864 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3865 iface
, start_slot
, sampler_count
, samplers
);
3867 wined3d_mutex_lock();
3868 for (i
= 0; i
< sampler_count
; ++i
)
3870 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3872 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3873 sampler
? sampler
->wined3d_sampler
: NULL
);
3875 wined3d_mutex_unlock();
3878 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3880 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3881 struct d3d_query
*query
;
3883 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3885 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3886 wined3d_mutex_lock();
3887 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3888 wined3d_mutex_unlock();
3891 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3892 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3894 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3897 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3898 iface
, start_slot
, view_count
, views
);
3900 wined3d_mutex_lock();
3901 for (i
= 0; i
< view_count
; ++i
)
3903 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3905 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3906 view
? view
->wined3d_view
: NULL
);
3908 wined3d_mutex_unlock();
3911 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3912 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3914 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3917 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3918 iface
, start_slot
, sampler_count
, samplers
);
3920 wined3d_mutex_lock();
3921 for (i
= 0; i
< sampler_count
; ++i
)
3923 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3925 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3926 sampler
? sampler
->wined3d_sampler
: NULL
);
3928 wined3d_mutex_unlock();
3931 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3932 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3933 ID3D10DepthStencilView
*depth_stencil_view
)
3935 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3936 struct d3d_depthstencil_view
*dsv
;
3939 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3940 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3942 wined3d_mutex_lock();
3943 for (i
= 0; i
< render_target_view_count
; ++i
)
3945 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3947 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3948 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3950 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3952 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3955 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3956 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3957 dsv
? dsv
->wined3d_view
: NULL
);
3958 wined3d_mutex_unlock();
3961 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3962 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3964 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3965 struct d3d_blend_state
*blend_state_object
;
3967 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3968 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3970 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3971 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3972 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3975 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3976 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3978 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3979 struct d3d_depthstencil_state
*ds_state_object
;
3981 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3982 iface
, depth_stencil_state
, stencil_ref
);
3984 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3985 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3986 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
3989 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3990 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3992 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3993 unsigned int count
, i
;
3995 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3997 count
= min(target_count
, D3D10_SO_BUFFER_SLOT_COUNT
);
3998 wined3d_mutex_lock();
3999 for (i
= 0; i
< count
; ++i
)
4001 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
4003 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
4004 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
4007 for (i
= count
; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4009 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4011 wined3d_mutex_unlock();
4014 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
4016 FIXME("iface %p stub!\n", iface
);
4019 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
4021 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4022 struct d3d_rasterizer_state
*rasterizer_state_object
;
4024 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4026 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
4027 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4028 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
4031 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
4032 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
4034 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4035 struct wined3d_viewport wined3d_vp
;
4037 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
4039 if (viewport_count
> 1)
4040 FIXME("Multiple viewports not implemented.\n");
4042 if (!viewport_count
)
4045 wined3d_vp
.x
= viewports
[0].TopLeftX
;
4046 wined3d_vp
.y
= viewports
[0].TopLeftY
;
4047 wined3d_vp
.width
= viewports
[0].Width
;
4048 wined3d_vp
.height
= viewports
[0].Height
;
4049 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
4050 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
4052 wined3d_mutex_lock();
4053 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
4054 wined3d_mutex_unlock();
4057 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
4058 UINT rect_count
, const D3D10_RECT
*rects
)
4060 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4062 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
4065 FIXME("Multiple scissor rects not implemented.\n");
4070 wined3d_mutex_lock();
4071 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
4072 wined3d_mutex_unlock();
4075 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
4076 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
4077 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
4079 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4080 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4081 struct wined3d_box wined3d_src_box
;
4083 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
4084 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
4085 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
4086 src_resource
, src_subresource_idx
, src_box
);
4089 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
4090 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
4092 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4093 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4094 wined3d_mutex_lock();
4095 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
4096 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
4097 wined3d_mutex_unlock();
4100 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
4101 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
4103 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4104 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4106 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
4108 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4109 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4110 wined3d_mutex_lock();
4111 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
4112 wined3d_mutex_unlock();
4115 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
4116 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
4117 const void *data
, UINT row_pitch
, UINT depth_pitch
)
4119 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4120 ID3D11Resource
*d3d11_resource
;
4122 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
4123 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
4125 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
4126 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4127 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
4128 ID3D11Resource_Release(d3d11_resource
);
4131 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
4132 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
4134 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4135 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
4136 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
4139 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
4140 iface
, render_target_view
, debug_float4(color_rgba
));
4145 wined3d_mutex_lock();
4146 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4147 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
4148 ERR("Failed to clear view, hr %#x.\n", hr
);
4149 wined3d_mutex_unlock();
4152 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
4153 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
4155 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4156 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4157 DWORD wined3d_flags
;
4160 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
4161 iface
, depth_stencil_view
, flags
, depth
, stencil
);
4166 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
4168 wined3d_mutex_lock();
4169 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4170 wined3d_flags
, NULL
, depth
, stencil
)))
4171 ERR("Failed to clear view, hr %#x.\n", hr
);
4172 wined3d_mutex_unlock();
4175 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
4176 ID3D10ShaderResourceView
*shader_resource_view
)
4178 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
4181 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
4182 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
4183 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
4185 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
4186 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
4187 iface
, dst_resource
, dst_subresource_idx
,
4188 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
4191 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
4192 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4194 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4197 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4198 iface
, start_slot
, buffer_count
, buffers
);
4200 wined3d_mutex_lock();
4201 for (i
= 0; i
< buffer_count
; ++i
)
4203 struct wined3d_buffer
*wined3d_buffer
;
4204 struct d3d_buffer
*buffer_impl
;
4206 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
4212 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4213 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4214 ID3D10Buffer_AddRef(buffers
[i
]);
4216 wined3d_mutex_unlock();
4219 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
4220 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4222 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4225 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4226 iface
, start_slot
, view_count
, views
);
4228 wined3d_mutex_lock();
4229 for (i
= 0; i
< view_count
; ++i
)
4231 struct wined3d_shader_resource_view
*wined3d_view
;
4232 struct d3d_shader_resource_view
*view_impl
;
4234 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4240 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4241 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4242 ID3D10ShaderResourceView_AddRef(views
[i
]);
4244 wined3d_mutex_unlock();
4247 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
4249 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4250 struct d3d_pixel_shader
*shader_impl
;
4251 struct wined3d_shader
*wined3d_shader
;
4253 TRACE("iface %p, shader %p.\n", iface
, shader
);
4255 wined3d_mutex_lock();
4256 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
4258 wined3d_mutex_unlock();
4263 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4264 wined3d_mutex_unlock();
4265 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
4266 ID3D10PixelShader_AddRef(*shader
);
4269 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
4270 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4272 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4275 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4276 iface
, start_slot
, sampler_count
, samplers
);
4278 wined3d_mutex_lock();
4279 for (i
= 0; i
< sampler_count
; ++i
)
4281 struct d3d_sampler_state
*sampler_impl
;
4282 struct wined3d_sampler
*wined3d_sampler
;
4284 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
4290 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4291 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4292 ID3D10SamplerState_AddRef(samplers
[i
]);
4294 wined3d_mutex_unlock();
4297 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
4299 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4300 struct d3d_vertex_shader
*shader_impl
;
4301 struct wined3d_shader
*wined3d_shader
;
4303 TRACE("iface %p, shader %p.\n", iface
, shader
);
4305 wined3d_mutex_lock();
4306 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
4308 wined3d_mutex_unlock();
4313 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4314 wined3d_mutex_unlock();
4315 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
4316 ID3D10VertexShader_AddRef(*shader
);
4319 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
4320 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4322 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4325 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4326 iface
, start_slot
, buffer_count
, buffers
);
4328 wined3d_mutex_lock();
4329 for (i
= 0; i
< buffer_count
; ++i
)
4331 struct wined3d_buffer
*wined3d_buffer
;
4332 struct d3d_buffer
*buffer_impl
;
4334 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
4340 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4341 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4342 ID3D10Buffer_AddRef(buffers
[i
]);
4344 wined3d_mutex_unlock();
4347 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
4349 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4350 struct wined3d_vertex_declaration
*wined3d_declaration
;
4351 struct d3d_input_layout
*input_layout_impl
;
4353 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
4355 wined3d_mutex_lock();
4356 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
4358 wined3d_mutex_unlock();
4359 *input_layout
= NULL
;
4363 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
4364 wined3d_mutex_unlock();
4365 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
4366 ID3D10InputLayout_AddRef(*input_layout
);
4369 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
4370 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
4372 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4375 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
4376 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4378 wined3d_mutex_lock();
4379 for (i
= 0; i
< buffer_count
; ++i
)
4381 struct wined3d_buffer
*wined3d_buffer
= NULL
;
4382 struct d3d_buffer
*buffer_impl
;
4384 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
4385 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
4386 ERR("Failed to get vertex buffer.\n");
4388 if (!wined3d_buffer
)
4394 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4395 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4396 ID3D10Buffer_AddRef(buffers
[i
]);
4398 wined3d_mutex_unlock();
4401 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
4402 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
4404 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4405 enum wined3d_format_id wined3d_format
;
4406 struct wined3d_buffer
*wined3d_buffer
;
4407 struct d3d_buffer
*buffer_impl
;
4409 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
4411 wined3d_mutex_lock();
4412 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
4413 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
4414 if (!wined3d_buffer
)
4416 wined3d_mutex_unlock();
4421 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4422 wined3d_mutex_unlock();
4423 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
4424 ID3D10Buffer_AddRef(*buffer
);
4427 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
4428 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4430 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4433 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4434 iface
, start_slot
, buffer_count
, buffers
);
4436 wined3d_mutex_lock();
4437 for (i
= 0; i
< buffer_count
; ++i
)
4439 struct wined3d_buffer
*wined3d_buffer
;
4440 struct d3d_buffer
*buffer_impl
;
4442 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
4448 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4449 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4450 ID3D10Buffer_AddRef(buffers
[i
]);
4452 wined3d_mutex_unlock();
4455 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
4457 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4458 struct d3d_geometry_shader
*shader_impl
;
4459 struct wined3d_shader
*wined3d_shader
;
4461 TRACE("iface %p, shader %p.\n", iface
, shader
);
4463 wined3d_mutex_lock();
4464 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
4466 wined3d_mutex_unlock();
4471 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4472 wined3d_mutex_unlock();
4473 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
4474 ID3D10GeometryShader_AddRef(*shader
);
4477 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
4478 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
4480 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4482 TRACE("iface %p, topology %p.\n", iface
, topology
);
4484 wined3d_mutex_lock();
4485 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
, NULL
);
4486 wined3d_mutex_unlock();
4489 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
4490 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4492 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4495 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4496 iface
, start_slot
, view_count
, views
);
4498 wined3d_mutex_lock();
4499 for (i
= 0; i
< view_count
; ++i
)
4501 struct wined3d_shader_resource_view
*wined3d_view
;
4502 struct d3d_shader_resource_view
*view_impl
;
4504 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4510 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4511 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4512 ID3D10ShaderResourceView_AddRef(views
[i
]);
4514 wined3d_mutex_unlock();
4517 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
4518 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4520 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4523 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4524 iface
, start_slot
, sampler_count
, samplers
);
4526 wined3d_mutex_lock();
4527 for (i
= 0; i
< sampler_count
; ++i
)
4529 struct d3d_sampler_state
*sampler_impl
;
4530 struct wined3d_sampler
*wined3d_sampler
;
4532 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4538 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4539 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4540 ID3D10SamplerState_AddRef(samplers
[i
]);
4542 wined3d_mutex_unlock();
4545 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
4546 ID3D10Predicate
**predicate
, BOOL
*value
)
4548 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4549 struct wined3d_query
*wined3d_predicate
;
4550 struct d3d_query
*predicate_impl
;
4552 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
4554 wined3d_mutex_lock();
4555 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
4557 wined3d_mutex_unlock();
4562 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
4563 wined3d_mutex_unlock();
4564 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
4565 ID3D10Predicate_AddRef(*predicate
);
4568 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
4569 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4571 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4574 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4575 iface
, start_slot
, view_count
, views
);
4577 wined3d_mutex_lock();
4578 for (i
= 0; i
< view_count
; ++i
)
4580 struct wined3d_shader_resource_view
*wined3d_view
;
4581 struct d3d_shader_resource_view
*view_impl
;
4583 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4589 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4590 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4591 ID3D10ShaderResourceView_AddRef(views
[i
]);
4593 wined3d_mutex_unlock();
4596 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
4597 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4599 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4602 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4603 iface
, start_slot
, sampler_count
, samplers
);
4605 wined3d_mutex_lock();
4606 for (i
= 0; i
< sampler_count
; ++i
)
4608 struct d3d_sampler_state
*sampler_impl
;
4609 struct wined3d_sampler
*wined3d_sampler
;
4611 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4617 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4618 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4619 ID3D10SamplerState_AddRef(samplers
[i
]);
4621 wined3d_mutex_unlock();
4624 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
4625 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
4627 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4628 struct wined3d_rendertarget_view
*wined3d_view
;
4630 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4631 iface
, view_count
, render_target_views
, depth_stencil_view
);
4633 wined3d_mutex_lock();
4634 if (render_target_views
)
4636 struct d3d_rendertarget_view
*view_impl
;
4639 for (i
= 0; i
< view_count
; ++i
)
4641 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
4642 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4644 render_target_views
[i
] = NULL
;
4648 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
4649 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
4653 if (depth_stencil_view
)
4655 struct d3d_depthstencil_view
*view_impl
;
4657 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
4658 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4660 *depth_stencil_view
= NULL
;
4664 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
4665 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
4668 wined3d_mutex_unlock();
4671 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
4672 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
4674 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4675 ID3D11BlendState
*d3d11_blend_state
;
4677 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
4678 iface
, blend_state
, blend_factor
, sample_mask
);
4680 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4681 &d3d11_blend_state
, blend_factor
, sample_mask
);
4683 if (d3d11_blend_state
)
4684 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
4686 *blend_state
= NULL
;
4689 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
4690 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
4692 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4693 ID3D11DepthStencilState
*d3d11_iface
;
4695 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
4696 iface
, depth_stencil_state
, stencil_ref
);
4698 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4699 &d3d11_iface
, stencil_ref
);
4702 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
4704 *depth_stencil_state
= NULL
;
4707 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
4708 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
4710 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4713 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
4714 iface
, buffer_count
, buffers
, offsets
);
4716 wined3d_mutex_lock();
4717 for (i
= 0; i
< buffer_count
; ++i
)
4719 struct wined3d_buffer
*wined3d_buffer
;
4720 struct d3d_buffer
*buffer_impl
;
4722 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
4728 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4729 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4730 ID3D10Buffer_AddRef(buffers
[i
]);
4732 wined3d_mutex_unlock();
4735 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
4737 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4738 struct d3d_rasterizer_state
*rasterizer_state_impl
;
4739 struct wined3d_rasterizer_state
*wined3d_state
;
4741 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4743 wined3d_mutex_lock();
4744 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
4746 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
4747 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
4751 *rasterizer_state
= NULL
;
4753 wined3d_mutex_unlock();
4756 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4757 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4759 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4760 struct wined3d_viewport wined3d_vp
;
4762 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4766 *viewport_count
= 1;
4770 if (!*viewport_count
)
4773 wined3d_mutex_lock();
4774 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4775 wined3d_mutex_unlock();
4777 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4778 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4779 viewports
[0].Width
= wined3d_vp
.width
;
4780 viewports
[0].Height
= wined3d_vp
.height
;
4781 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4782 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4784 if (*viewport_count
> 1)
4785 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4788 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4790 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4792 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4803 wined3d_mutex_lock();
4804 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4805 wined3d_mutex_unlock();
4806 if (*rect_count
> 1)
4807 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4810 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4812 TRACE("iface %p.\n", iface
);
4814 /* In the current implementation the device is never removed, so we can
4815 * just return S_OK here. */
4820 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4822 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4827 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4829 FIXME("iface %p stub!\n", iface
);
4834 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4835 REFGUID guid
, UINT
*data_size
, void *data
)
4837 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4839 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4841 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4844 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4845 REFGUID guid
, UINT data_size
, const void *data
)
4847 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4849 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4851 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4854 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4855 REFGUID guid
, const IUnknown
*data
)
4857 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4859 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4861 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4864 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4866 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4868 TRACE("iface %p.\n", iface
);
4870 d3d11_immediate_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext_iface
);
4873 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4875 FIXME("iface %p stub!\n", iface
);
4878 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4879 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4881 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4882 D3D11_BUFFER_DESC d3d11_desc
;
4883 struct d3d_buffer
*object
;
4886 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4888 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4889 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4890 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4891 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4892 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4893 d3d11_desc
.StructureByteStride
= 0;
4895 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4898 *buffer
= &object
->ID3D10Buffer_iface
;
4903 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4904 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4906 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4911 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4912 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4913 ID3D10Texture2D
**texture
)
4915 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4916 D3D11_TEXTURE2D_DESC d3d11_desc
;
4917 struct d3d_texture2d
*object
;
4920 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4922 d3d11_desc
.Width
= desc
->Width
;
4923 d3d11_desc
.Height
= desc
->Height
;
4924 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4925 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4926 d3d11_desc
.Format
= desc
->Format
;
4927 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4928 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4929 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4930 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4931 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4933 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4936 *texture
= &object
->ID3D10Texture2D_iface
;
4941 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4942 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4943 ID3D10Texture3D
**texture
)
4945 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4946 D3D11_TEXTURE3D_DESC d3d11_desc
;
4947 struct d3d_texture3d
*object
;
4950 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4952 d3d11_desc
.Width
= desc
->Width
;
4953 d3d11_desc
.Height
= desc
->Height
;
4954 d3d11_desc
.Depth
= desc
->Depth
;
4955 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4956 d3d11_desc
.Format
= desc
->Format
;
4957 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4958 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4959 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4960 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4962 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4965 *texture
= &object
->ID3D10Texture3D_iface
;
4970 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4971 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4973 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4974 struct d3d_shader_resource_view
*object
;
4975 ID3D11Resource
*d3d11_resource
;
4978 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4981 return E_INVALIDARG
;
4983 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4985 ERR("Resource does not implement ID3D11Resource.\n");
4989 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4991 ID3D11Resource_Release(d3d11_resource
);
4995 *view
= &object
->ID3D10ShaderResourceView1_iface
;
5000 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
5001 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
5003 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5005 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
5006 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
5009 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
5010 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
5012 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5013 struct d3d_rendertarget_view
*object
;
5014 ID3D11Resource
*d3d11_resource
;
5017 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5020 return E_INVALIDARG
;
5022 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5024 ERR("Resource does not implement ID3D11Resource.\n");
5028 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
5029 ID3D11Resource_Release(d3d11_resource
);
5033 *view
= &object
->ID3D10RenderTargetView_iface
;
5038 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
5039 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
5041 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5042 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
5043 struct d3d_depthstencil_view
*object
;
5044 ID3D11Resource
*d3d11_resource
;
5047 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5051 d3d11_desc
.Format
= desc
->Format
;
5052 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
5053 d3d11_desc
.Flags
= 0;
5054 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
5057 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5059 ERR("Resource does not implement ID3D11Resource.\n");
5063 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
5064 ID3D11Resource_Release(d3d11_resource
);
5068 *view
= &object
->ID3D10DepthStencilView_iface
;
5073 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
5074 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
5075 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
5076 ID3D10InputLayout
**input_layout
)
5078 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5079 struct d3d_input_layout
*object
;
5082 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
5083 "shader_byte_code_length %lu, input_layout %p\n",
5084 iface
, element_descs
, element_count
, shader_byte_code
,
5085 shader_byte_code_length
, input_layout
);
5087 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
5088 shader_byte_code
, shader_byte_code_length
, &object
)))
5091 *input_layout
= &object
->ID3D10InputLayout_iface
;
5096 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
5097 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
5099 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5100 struct d3d_vertex_shader
*object
;
5103 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5104 iface
, byte_code
, byte_code_length
, shader
);
5106 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5109 *shader
= &object
->ID3D10VertexShader_iface
;
5114 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
5115 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
5117 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5118 struct d3d_geometry_shader
*object
;
5121 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5122 iface
, byte_code
, byte_code_length
, shader
);
5124 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5125 NULL
, 0, NULL
, 0, 0, &object
)))
5128 *shader
= &object
->ID3D10GeometryShader_iface
;
5133 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
5134 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
5135 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
5137 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5138 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
5139 struct d3d_geometry_shader
*object
;
5140 unsigned int i
, stride_count
= 1;
5143 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
5144 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
5145 iface
, byte_code
, byte_code_length
, output_stream_decls
,
5146 output_stream_decl_count
, output_stream_stride
, shader
);
5148 if (!output_stream_decl_count
&& output_stream_stride
)
5150 WARN("Stride must be 0 when declaration entry count is 0.\n");
5152 return E_INVALIDARG
;
5155 if (output_stream_decl_count
5156 && !(so_entries
= d3d11_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
5158 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
5160 return E_OUTOFMEMORY
;
5163 for (i
= 0; i
< output_stream_decl_count
; ++i
)
5165 so_entries
[i
].Stream
= 0;
5166 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
5167 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
5168 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
5169 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
5170 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
5172 if (output_stream_decls
[i
].OutputSlot
)
5175 if (output_stream_stride
)
5177 WARN("Stride must be 0 when multiple output slots are used.\n");
5178 HeapFree(GetProcessHeap(), 0, so_entries
);
5180 return E_INVALIDARG
;
5185 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5186 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
5187 HeapFree(GetProcessHeap(), 0, so_entries
);
5194 *shader
= &object
->ID3D10GeometryShader_iface
;
5199 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
5200 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
5202 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5203 struct d3d_pixel_shader
*object
;
5206 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5207 iface
, byte_code
, byte_code_length
, shader
);
5209 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5212 *shader
= &object
->ID3D10PixelShader_iface
;
5217 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
5218 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
5220 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5221 struct d3d_blend_state
*object
;
5224 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5226 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
5229 *blend_state
= &object
->ID3D10BlendState1_iface
;
5234 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
5235 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
5237 D3D10_BLEND_DESC1 d3d10_1_desc
;
5240 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5243 return E_INVALIDARG
;
5245 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
5246 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
5247 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
5249 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
5250 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
5251 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
5254 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5256 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
5257 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
5258 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
5259 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
5260 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
5261 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
5262 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
5263 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
5266 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
5269 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
5270 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
5272 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5273 struct d3d_depthstencil_state
*object
;
5276 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
5278 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
5281 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
5286 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
5287 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
5289 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5290 struct d3d_rasterizer_state
*object
;
5293 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
5295 if (FAILED(hr
= d3d_rasterizer_state_create(device
, (const D3D11_RASTERIZER_DESC
*)desc
, &object
)))
5298 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
5303 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
5304 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
5306 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5307 struct d3d_sampler_state
*object
;
5310 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
5312 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
5315 *sampler_state
= &object
->ID3D10SamplerState_iface
;
5320 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
5321 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
5323 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5324 struct d3d_query
*object
;
5327 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
5329 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
5334 *query
= &object
->ID3D10Query_iface
;
5338 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5342 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
5343 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
5345 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5346 struct d3d_query
*object
;
5349 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
5351 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
5356 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
5360 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5364 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
5365 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
5367 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
5372 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
5373 DXGI_FORMAT format
, UINT
*format_support
)
5375 FIXME("iface %p, format %s, format_support %p stub!\n",
5376 iface
, debug_dxgi_format(format
), format_support
);
5381 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
5382 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
5384 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5386 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
5387 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
5389 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
5390 sample_count
, quality_level_count
);
5393 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
5395 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
5398 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
5399 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
5400 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
5402 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
5403 "units %p, units_length %p, description %p, description_length %p stub!\n",
5404 iface
, desc
, type
, active_counters
, name
, name_length
,
5405 units
, units_length
, description
, description_length
);
5410 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
5412 FIXME("iface %p stub!\n", iface
);
5417 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
5418 HANDLE resource_handle
, REFIID guid
, void **resource
)
5420 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
5421 iface
, resource_handle
, debugstr_guid(guid
), resource
);
5426 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
5428 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
5431 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
5433 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
5436 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
5438 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5440 TRACE("iface %p.\n", iface
);
5442 return device
->feature_level
;
5445 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
5447 /* IUnknown methods */
5448 d3d10_device_QueryInterface
,
5449 d3d10_device_AddRef
,
5450 d3d10_device_Release
,
5451 /* ID3D10Device methods */
5452 d3d10_device_VSSetConstantBuffers
,
5453 d3d10_device_PSSetShaderResources
,
5454 d3d10_device_PSSetShader
,
5455 d3d10_device_PSSetSamplers
,
5456 d3d10_device_VSSetShader
,
5457 d3d10_device_DrawIndexed
,
5459 d3d10_device_PSSetConstantBuffers
,
5460 d3d10_device_IASetInputLayout
,
5461 d3d10_device_IASetVertexBuffers
,
5462 d3d10_device_IASetIndexBuffer
,
5463 d3d10_device_DrawIndexedInstanced
,
5464 d3d10_device_DrawInstanced
,
5465 d3d10_device_GSSetConstantBuffers
,
5466 d3d10_device_GSSetShader
,
5467 d3d10_device_IASetPrimitiveTopology
,
5468 d3d10_device_VSSetShaderResources
,
5469 d3d10_device_VSSetSamplers
,
5470 d3d10_device_SetPredication
,
5471 d3d10_device_GSSetShaderResources
,
5472 d3d10_device_GSSetSamplers
,
5473 d3d10_device_OMSetRenderTargets
,
5474 d3d10_device_OMSetBlendState
,
5475 d3d10_device_OMSetDepthStencilState
,
5476 d3d10_device_SOSetTargets
,
5477 d3d10_device_DrawAuto
,
5478 d3d10_device_RSSetState
,
5479 d3d10_device_RSSetViewports
,
5480 d3d10_device_RSSetScissorRects
,
5481 d3d10_device_CopySubresourceRegion
,
5482 d3d10_device_CopyResource
,
5483 d3d10_device_UpdateSubresource
,
5484 d3d10_device_ClearRenderTargetView
,
5485 d3d10_device_ClearDepthStencilView
,
5486 d3d10_device_GenerateMips
,
5487 d3d10_device_ResolveSubresource
,
5488 d3d10_device_VSGetConstantBuffers
,
5489 d3d10_device_PSGetShaderResources
,
5490 d3d10_device_PSGetShader
,
5491 d3d10_device_PSGetSamplers
,
5492 d3d10_device_VSGetShader
,
5493 d3d10_device_PSGetConstantBuffers
,
5494 d3d10_device_IAGetInputLayout
,
5495 d3d10_device_IAGetVertexBuffers
,
5496 d3d10_device_IAGetIndexBuffer
,
5497 d3d10_device_GSGetConstantBuffers
,
5498 d3d10_device_GSGetShader
,
5499 d3d10_device_IAGetPrimitiveTopology
,
5500 d3d10_device_VSGetShaderResources
,
5501 d3d10_device_VSGetSamplers
,
5502 d3d10_device_GetPredication
,
5503 d3d10_device_GSGetShaderResources
,
5504 d3d10_device_GSGetSamplers
,
5505 d3d10_device_OMGetRenderTargets
,
5506 d3d10_device_OMGetBlendState
,
5507 d3d10_device_OMGetDepthStencilState
,
5508 d3d10_device_SOGetTargets
,
5509 d3d10_device_RSGetState
,
5510 d3d10_device_RSGetViewports
,
5511 d3d10_device_RSGetScissorRects
,
5512 d3d10_device_GetDeviceRemovedReason
,
5513 d3d10_device_SetExceptionMode
,
5514 d3d10_device_GetExceptionMode
,
5515 d3d10_device_GetPrivateData
,
5516 d3d10_device_SetPrivateData
,
5517 d3d10_device_SetPrivateDataInterface
,
5518 d3d10_device_ClearState
,
5520 d3d10_device_CreateBuffer
,
5521 d3d10_device_CreateTexture1D
,
5522 d3d10_device_CreateTexture2D
,
5523 d3d10_device_CreateTexture3D
,
5524 d3d10_device_CreateShaderResourceView
,
5525 d3d10_device_CreateRenderTargetView
,
5526 d3d10_device_CreateDepthStencilView
,
5527 d3d10_device_CreateInputLayout
,
5528 d3d10_device_CreateVertexShader
,
5529 d3d10_device_CreateGeometryShader
,
5530 d3d10_device_CreateGeometryShaderWithStreamOutput
,
5531 d3d10_device_CreatePixelShader
,
5532 d3d10_device_CreateBlendState
,
5533 d3d10_device_CreateDepthStencilState
,
5534 d3d10_device_CreateRasterizerState
,
5535 d3d10_device_CreateSamplerState
,
5536 d3d10_device_CreateQuery
,
5537 d3d10_device_CreatePredicate
,
5538 d3d10_device_CreateCounter
,
5539 d3d10_device_CheckFormatSupport
,
5540 d3d10_device_CheckMultisampleQualityLevels
,
5541 d3d10_device_CheckCounterInfo
,
5542 d3d10_device_CheckCounter
,
5543 d3d10_device_GetCreationFlags
,
5544 d3d10_device_OpenSharedResource
,
5545 d3d10_device_SetTextFilterSize
,
5546 d3d10_device_GetTextFilterSize
,
5547 d3d10_device_CreateShaderResourceView1
,
5548 d3d10_device_CreateBlendState1
,
5549 d3d10_device_GetFeatureLevel
,
5552 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
5554 /* IUnknown methods */
5555 d3d_device_inner_QueryInterface
,
5556 d3d_device_inner_AddRef
,
5557 d3d_device_inner_Release
,
5560 /* ID3D10Multithread methods */
5562 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
5564 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
5567 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
5569 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5571 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
5573 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
5576 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
5578 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5580 TRACE("iface %p.\n", iface
);
5582 return IUnknown_AddRef(device
->outer_unk
);
5585 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
5587 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5589 TRACE("iface %p.\n", iface
);
5591 return IUnknown_Release(device
->outer_unk
);
5594 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
5596 TRACE("iface %p.\n", iface
);
5598 wined3d_mutex_lock();
5601 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
5603 TRACE("iface %p.\n", iface
);
5605 wined3d_mutex_unlock();
5608 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
5610 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
5615 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
5617 FIXME("iface %p stub!\n", iface
);
5622 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
5624 d3d10_multithread_QueryInterface
,
5625 d3d10_multithread_AddRef
,
5626 d3d10_multithread_Release
,
5627 d3d10_multithread_Enter
,
5628 d3d10_multithread_Leave
,
5629 d3d10_multithread_SetMultithreadProtected
,
5630 d3d10_multithread_GetMultithreadProtected
,
5633 /* IWineDXGIDeviceParent IUnknown methods */
5635 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
5637 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
5640 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
5641 REFIID riid
, void **ppv
)
5643 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5644 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
5647 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
5649 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5650 return IUnknown_AddRef(device
->outer_unk
);
5653 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
5655 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5656 return IUnknown_Release(device
->outer_unk
);
5659 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
5660 IWineDXGIDeviceParent
*iface
)
5662 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5663 return &device
->device_parent
;
5666 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
5668 /* IUnknown methods */
5669 dxgi_device_parent_QueryInterface
,
5670 dxgi_device_parent_AddRef
,
5671 dxgi_device_parent_Release
,
5672 /* IWineDXGIDeviceParent methods */
5673 dxgi_device_parent_get_wined3d_device_parent
,
5676 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
5678 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
5681 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
5682 struct wined3d_device
*wined3d_device
)
5684 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5686 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
5688 wined3d_device_incref(wined3d_device
);
5689 device
->wined3d_device
= wined3d_device
;
5692 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
5694 TRACE("device_parent %p.\n", device_parent
);
5697 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
5699 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
5702 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
5703 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
5704 const struct wined3d_parent_ops
**parent_ops
)
5706 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
5707 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
5710 *parent_ops
= &d3d_null_wined3d_parent_ops
;
5715 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
5716 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
5717 struct wined3d_texture
**wined3d_texture
)
5719 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5720 struct d3d_texture2d
*texture
;
5721 ID3D10Texture2D
*texture_iface
;
5722 D3D10_TEXTURE2D_DESC desc
;
5725 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, texture flags %#x, "
5726 "wined3d_texture %p partial stub!\n", device_parent
, container_parent
,
5727 wined3d_desc
, texture_flags
, wined3d_texture
);
5729 FIXME("Implement DXGI<->wined3d usage conversion.\n");
5731 desc
.Width
= wined3d_desc
->width
;
5732 desc
.Height
= wined3d_desc
->height
;
5735 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
5736 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
5737 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
5738 desc
.Usage
= D3D10_USAGE_DEFAULT
;
5739 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5740 desc
.CPUAccessFlags
= 0;
5743 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
5745 desc
.MiscFlags
|= D3D10_RESOURCE_MISC_GDI_COMPATIBLE
;
5746 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
5750 FIXME("Unhandled flags %#x.\n", texture_flags
);
5752 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
5753 &desc
, NULL
, &texture_iface
)))
5755 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
5759 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5761 *wined3d_texture
= texture
->wined3d_texture
;
5762 wined3d_texture_incref(*wined3d_texture
);
5763 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5768 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5769 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5771 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5772 IWineDXGIDevice
*wine_device
;
5775 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5777 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5778 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5780 ERR("Device should implement IWineDXGIDevice.\n");
5784 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, TRUE
, swapchain
);
5785 IWineDXGIDevice_Release(wine_device
);
5788 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5795 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5797 device_parent_wined3d_device_created
,
5798 device_parent_mode_changed
,
5799 device_parent_activate
,
5800 device_parent_sub_resource_created
,
5801 device_parent_sub_resource_created
,
5802 device_parent_create_swapchain_texture
,
5803 device_parent_create_swapchain
,
5806 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5808 const D3D11_SAMPLER_DESC
*ka
= key
;
5809 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5811 return memcmp(ka
, kb
, sizeof(*ka
));
5814 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5816 const D3D11_BLEND_DESC
*ka
= key
;
5817 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5819 return memcmp(ka
, kb
, sizeof(*ka
));
5822 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5824 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5825 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5826 const struct d3d_depthstencil_state
, entry
)->desc
;
5828 return memcmp(ka
, kb
, sizeof(*ka
));
5831 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5833 const D3D11_RASTERIZER_DESC
*ka
= key
;
5834 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5836 return memcmp(ka
, kb
, sizeof(*ka
));
5839 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5841 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5842 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5843 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5844 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5845 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5846 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5847 device
->refcount
= 1;
5848 /* COM aggregation always takes place */
5849 device
->outer_unk
= outer_unknown
;
5851 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5852 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5854 device
->blend_factor
[0] = 1.0f
;
5855 device
->blend_factor
[1] = 1.0f
;
5856 device
->blend_factor
[2] = 1.0f
;
5857 device
->blend_factor
[3] = 1.0f
;
5859 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
5860 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
5861 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
5862 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);