2 * Copyright 2008-2012 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define NONAMELESSUNION
21 #include "d3d11_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
25 static void STDMETHODCALLTYPE
d3d_null_wined3d_object_destroyed(void *parent
) {}
27 static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops
=
29 d3d_null_wined3d_object_destroyed
,
32 /* ID3DDeviceContextState methods */
34 static inline struct d3d_device_context_state
*impl_from_ID3DDeviceContextState(ID3DDeviceContextState
*iface
)
36 return CONTAINING_RECORD(iface
, struct d3d_device_context_state
, ID3DDeviceContextState_iface
);
39 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_QueryInterface(ID3DDeviceContextState
*iface
,
40 REFIID iid
, void **out
)
42 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
44 if (IsEqualGUID(iid
, &IID_ID3DDeviceContextState
)
45 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
46 || IsEqualGUID(iid
, &IID_IUnknown
))
48 ID3DDeviceContextState_AddRef(iface
);
53 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
59 static ULONG STDMETHODCALLTYPE
d3d_device_context_state_AddRef(ID3DDeviceContextState
*iface
)
61 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
62 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
64 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
69 static ULONG STDMETHODCALLTYPE
d3d_device_context_state_Release(ID3DDeviceContextState
*iface
)
71 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
72 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
74 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
78 wined3d_private_store_cleanup(&state
->private_store
);
79 ID3D11Device2_Release(state
->device
);
86 static void STDMETHODCALLTYPE
d3d_device_context_state_GetDevice(ID3DDeviceContextState
*iface
, ID3D11Device
**device
)
88 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
90 TRACE("iface %p, device %p.\n", iface
, device
);
92 *device
= (ID3D11Device
*)state
->device
;
93 ID3D11Device_AddRef(*device
);
96 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_GetPrivateData(ID3DDeviceContextState
*iface
, REFGUID guid
,
97 UINT
*data_size
, void *data
)
99 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
101 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
103 return d3d_get_private_data(&state
->private_store
, guid
, data_size
, data
);
106 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_SetPrivateData(ID3DDeviceContextState
*iface
, REFGUID guid
,
107 UINT data_size
, const void *data
)
109 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
111 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
113 return d3d_set_private_data(&state
->private_store
, guid
, data_size
, data
);
116 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_SetPrivateDataInterface(ID3DDeviceContextState
*iface
,
117 REFGUID guid
, const IUnknown
*data
)
119 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
121 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
123 return d3d_set_private_data_interface(&state
->private_store
, guid
, data
);
126 static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl
=
128 /* IUnknown methods */
129 d3d_device_context_state_QueryInterface
,
130 d3d_device_context_state_AddRef
,
131 d3d_device_context_state_Release
,
132 /* ID3D11DeviceChild methods */
133 d3d_device_context_state_GetDevice
,
134 d3d_device_context_state_GetPrivateData
,
135 d3d_device_context_state_SetPrivateData
,
136 d3d_device_context_state_SetPrivateDataInterface
,
137 /* ID3DDeviceContextState methods */
140 static void d3d_device_context_state_init(struct d3d_device_context_state
*state
, struct d3d_device
*device
,
141 REFIID emulated_interface
)
143 state
->ID3DDeviceContextState_iface
.lpVtbl
= &d3d_device_context_state_vtbl
;
146 wined3d_private_store_init(&state
->private_store
);
148 state
->emulated_interface
= *emulated_interface
;
149 state
->device
= &device
->ID3D11Device2_iface
;
150 ID3D11Device2_AddRef(state
->device
);
153 /* ID3D11DeviceContext - immediate context methods */
155 static inline struct d3d11_immediate_context
*impl_from_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
157 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11DeviceContext1_iface
);
160 static inline struct d3d_device
*device_from_immediate_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
162 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
163 return CONTAINING_RECORD(context
, struct d3d_device
, immediate_context
);
166 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_QueryInterface(ID3D11DeviceContext1
*iface
,
167 REFIID iid
, void **out
)
169 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
171 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
173 if (IsEqualGUID(iid
, &IID_ID3D11DeviceContext1
)
174 || IsEqualGUID(iid
, &IID_ID3D11DeviceContext
)
175 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
176 || IsEqualGUID(iid
, &IID_IUnknown
))
178 *out
= &context
->ID3D11DeviceContext1_iface
;
180 else if (IsEqualGUID(iid
, &IID_ID3D11Multithread
))
182 *out
= &context
->ID3D11Multithread_iface
;
186 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
188 return E_NOINTERFACE
;
191 ID3D11DeviceContext1_AddRef(iface
);
195 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_AddRef(ID3D11DeviceContext1
*iface
)
197 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
198 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
199 ULONG refcount
= InterlockedIncrement(&context
->refcount
);
201 TRACE("%p increasing refcount to %u.\n", context
, refcount
);
205 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
211 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_Release(ID3D11DeviceContext1
*iface
)
213 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
214 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
215 ULONG refcount
= InterlockedDecrement(&context
->refcount
);
217 TRACE("%p decreasing refcount to %u.\n", context
, refcount
);
221 ID3D11Device2_Release(&device
->ID3D11Device2_iface
);
227 static void d3d11_immediate_context_get_constant_buffers(ID3D11DeviceContext1
*iface
,
228 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
230 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
233 wined3d_mutex_lock();
234 for (i
= 0; i
< buffer_count
; ++i
)
236 struct wined3d_buffer
*wined3d_buffer
;
237 struct d3d_buffer
*buffer_impl
;
239 if (!(wined3d_buffer
= wined3d_device_get_constant_buffer(device
->wined3d_device
,
240 type
, start_slot
+ i
)))
246 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
247 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
248 ID3D11Buffer_AddRef(buffers
[i
]);
250 wined3d_mutex_unlock();
253 static void d3d11_immediate_context_set_constant_buffers(ID3D11DeviceContext1
*iface
,
254 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
256 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
259 wined3d_mutex_lock();
260 for (i
= 0; i
< buffer_count
; ++i
)
262 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
264 wined3d_device_set_constant_buffer(device
->wined3d_device
, type
, start_slot
+ i
,
265 buffer
? buffer
->wined3d_buffer
: NULL
);
267 wined3d_mutex_unlock();
270 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetDevice(ID3D11DeviceContext1
*iface
, ID3D11Device
**device
)
272 struct d3d_device
*device_object
= device_from_immediate_ID3D11DeviceContext1(iface
);
274 TRACE("iface %p, device %p.\n", iface
, device
);
276 *device
= (ID3D11Device
*)&device_object
->ID3D11Device2_iface
;
277 ID3D11Device_AddRef(*device
);
280 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
281 UINT
*data_size
, void *data
)
283 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
285 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
287 return d3d_get_private_data(&context
->private_store
, guid
, data_size
, data
);
290 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
291 UINT data_size
, const void *data
)
293 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
295 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
297 return d3d_set_private_data(&context
->private_store
, guid
, data_size
, data
);
300 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext1
*iface
,
301 REFGUID guid
, const IUnknown
*data
)
303 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
305 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
307 return d3d_set_private_data_interface(&context
->private_store
, guid
, data
);
310 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
311 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
313 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
314 iface
, start_slot
, buffer_count
, buffers
);
316 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
317 buffer_count
, buffers
);
320 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext1
*iface
,
321 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
323 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
326 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
327 iface
, start_slot
, view_count
, views
);
329 wined3d_mutex_lock();
330 for (i
= 0; i
< view_count
; ++i
)
332 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
334 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
335 view
? view
->wined3d_view
: NULL
);
337 wined3d_mutex_unlock();
340 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShader(ID3D11DeviceContext1
*iface
,
341 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
343 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
344 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
346 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
347 iface
, shader
, class_instances
, class_instance_count
);
350 FIXME("Dynamic linking is not implemented yet.\n");
352 wined3d_mutex_lock();
353 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
354 wined3d_mutex_unlock();
357 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext1
*iface
,
358 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
360 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
363 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
364 iface
, start_slot
, sampler_count
, samplers
);
366 wined3d_mutex_lock();
367 for (i
= 0; i
< sampler_count
; ++i
)
369 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
371 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
372 sampler
? sampler
->wined3d_sampler
: NULL
);
374 wined3d_mutex_unlock();
377 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShader(ID3D11DeviceContext1
*iface
,
378 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
380 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
381 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
383 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
384 iface
, shader
, class_instances
, class_instance_count
);
387 FIXME("Dynamic linking is not implemented yet.\n");
389 wined3d_mutex_lock();
390 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
391 wined3d_mutex_unlock();
394 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext1
*iface
,
395 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
397 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
399 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
400 iface
, index_count
, start_index_location
, base_vertex_location
);
402 wined3d_mutex_lock();
403 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
404 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
405 wined3d_mutex_unlock();
408 static void STDMETHODCALLTYPE
d3d11_immediate_context_Draw(ID3D11DeviceContext1
*iface
,
409 UINT vertex_count
, UINT start_vertex_location
)
411 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
413 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
414 iface
, vertex_count
, start_vertex_location
);
416 wined3d_mutex_lock();
417 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
418 wined3d_mutex_unlock();
421 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_Map(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
422 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
424 struct wined3d_resource
*wined3d_resource
;
425 struct wined3d_map_desc map_desc
;
428 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
429 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
432 FIXME("Ignoring map_flags %#x.\n", map_flags
);
434 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
436 wined3d_mutex_lock();
437 hr
= wined3d_resource_map(wined3d_resource
, subresource_idx
,
438 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
439 wined3d_mutex_unlock();
441 mapped_subresource
->pData
= map_desc
.data
;
442 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
443 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
448 static void STDMETHODCALLTYPE
d3d11_immediate_context_Unmap(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
449 UINT subresource_idx
)
451 struct wined3d_resource
*wined3d_resource
;
453 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
455 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
457 wined3d_mutex_lock();
458 wined3d_resource_unmap(wined3d_resource
, subresource_idx
);
459 wined3d_mutex_unlock();
462 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
463 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
465 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
466 iface
, start_slot
, buffer_count
, buffers
);
468 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
469 buffer_count
, buffers
);
472 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext1
*iface
,
473 ID3D11InputLayout
*input_layout
)
475 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
476 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
478 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
480 wined3d_mutex_lock();
481 wined3d_device_set_vertex_declaration(device
->wined3d_device
, layout
? layout
->wined3d_decl
: NULL
);
482 wined3d_mutex_unlock();
485 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext1
*iface
,
486 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
488 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
491 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
492 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
494 wined3d_mutex_lock();
495 for (i
= 0; i
< buffer_count
; ++i
)
497 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
499 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
500 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
502 wined3d_mutex_unlock();
505 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext1
*iface
,
506 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
508 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
509 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
511 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
512 iface
, buffer
, debug_dxgi_format(format
), offset
);
514 wined3d_mutex_lock();
515 wined3d_device_set_index_buffer(device
->wined3d_device
,
516 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
517 wined3dformat_from_dxgi_format(format
), offset
);
518 wined3d_mutex_unlock();
521 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext1
*iface
,
522 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
523 UINT start_instance_location
)
525 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
527 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
528 "base_vertex_location %d, start_instance_location %u.\n",
529 iface
, instance_index_count
, instance_count
, start_index_location
,
530 base_vertex_location
, start_instance_location
);
532 wined3d_mutex_lock();
533 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
534 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
535 instance_index_count
, start_instance_location
, instance_count
);
536 wined3d_mutex_unlock();
539 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext1
*iface
,
540 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
542 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
544 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
545 "start_instance_location %u.\n",
546 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
547 start_instance_location
);
549 wined3d_mutex_lock();
550 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
551 instance_vertex_count
, start_instance_location
, instance_count
);
552 wined3d_mutex_unlock();
555 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
556 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
558 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
559 iface
, start_slot
, buffer_count
, buffers
);
561 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
562 buffer_count
, buffers
);
565 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext1
*iface
,
566 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
568 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
569 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
571 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
572 iface
, shader
, class_instances
, class_instance_count
);
575 FIXME("Dynamic linking is not implemented yet.\n");
577 wined3d_mutex_lock();
578 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
579 wined3d_mutex_unlock();
582 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
583 D3D11_PRIMITIVE_TOPOLOGY topology
)
585 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
586 enum wined3d_primitive_type primitive_type
;
587 unsigned int patch_vertex_count
;
589 TRACE("iface %p, topology %#x.\n", iface
, topology
);
591 wined3d_primitive_type_from_d3d11_primitive_topology(topology
, &primitive_type
, &patch_vertex_count
);
593 wined3d_mutex_lock();
594 wined3d_device_set_primitive_type(device
->wined3d_device
, primitive_type
, patch_vertex_count
);
595 wined3d_mutex_unlock();
598 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext1
*iface
,
599 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
601 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
604 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
606 wined3d_mutex_lock();
607 for (i
= 0; i
< view_count
; ++i
)
609 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
611 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
612 view
? view
->wined3d_view
: NULL
);
614 wined3d_mutex_unlock();
617 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext1
*iface
,
618 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
620 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
623 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
624 iface
, start_slot
, sampler_count
, samplers
);
626 wined3d_mutex_lock();
627 for (i
= 0; i
< sampler_count
; ++i
)
629 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
631 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
632 sampler
? sampler
->wined3d_sampler
: NULL
);
634 wined3d_mutex_unlock();
637 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext1
*iface
,
638 ID3D11Asynchronous
*asynchronous
)
640 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
643 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
645 wined3d_mutex_lock();
646 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_BEGIN
)))
647 ERR("Failed to issue query, hr %#x.\n", hr
);
648 wined3d_mutex_unlock();
651 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext1
*iface
,
652 ID3D11Asynchronous
*asynchronous
)
654 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
657 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
659 wined3d_mutex_lock();
660 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_END
)))
661 ERR("Failed to issue query, hr %#x.\n", hr
);
662 wined3d_mutex_unlock();
665 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext1
*iface
,
666 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
668 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
669 unsigned int wined3d_flags
;
672 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
673 iface
, asynchronous
, data
, data_size
, data_flags
);
675 if (!data
&& data_size
)
678 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
680 wined3d_mutex_lock();
681 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
683 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
684 if (hr
== WINED3DERR_INVALIDCALL
)
685 hr
= DXGI_ERROR_INVALID_CALL
;
689 WARN("Invalid data size %u.\n", data_size
);
692 wined3d_mutex_unlock();
697 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext1
*iface
,
698 ID3D11Predicate
*predicate
, BOOL value
)
700 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
701 struct d3d_query
*query
;
703 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
705 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
707 wined3d_mutex_lock();
708 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
709 wined3d_mutex_unlock();
712 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext1
*iface
,
713 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
715 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
718 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
720 wined3d_mutex_lock();
721 for (i
= 0; i
< view_count
; ++i
)
723 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
725 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
726 view
? view
->wined3d_view
: NULL
);
728 wined3d_mutex_unlock();
731 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext1
*iface
,
732 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
734 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
737 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
738 iface
, start_slot
, sampler_count
, samplers
);
740 wined3d_mutex_lock();
741 for (i
= 0; i
< sampler_count
; ++i
)
743 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
745 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
746 sampler
? sampler
->wined3d_sampler
: NULL
);
748 wined3d_mutex_unlock();
751 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext1
*iface
,
752 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
753 ID3D11DepthStencilView
*depth_stencil_view
)
755 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
756 struct d3d_depthstencil_view
*dsv
;
759 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
760 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
762 wined3d_mutex_lock();
763 for (i
= 0; i
< render_target_view_count
; ++i
)
765 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
766 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
768 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
770 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
773 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
774 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
775 wined3d_mutex_unlock();
778 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
779 ID3D11DeviceContext1
*iface
, UINT render_target_view_count
,
780 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
781 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
782 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
784 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
787 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
788 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
789 "initial_counts %p.\n",
790 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
791 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
794 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
796 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
800 if (unordered_access_view_count
!= D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
802 wined3d_mutex_lock();
803 for (i
= 0; i
< unordered_access_view_start_slot
; ++i
)
805 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
807 for (i
= 0; i
< unordered_access_view_count
; ++i
)
809 struct d3d11_unordered_access_view
*view
810 = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views
[i
]);
812 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
813 unordered_access_view_start_slot
+ i
,
814 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
816 for (; unordered_access_view_start_slot
+ i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
818 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
819 unordered_access_view_start_slot
+ i
, NULL
, ~0u);
821 wined3d_mutex_unlock();
825 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext1
*iface
,
826 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
828 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
829 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
830 struct d3d_blend_state
*blend_state_impl
;
832 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
833 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
836 blend_factor
= default_blend_factor
;
838 wined3d_mutex_lock();
839 if (!(blend_state_impl
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
840 wined3d_device_set_blend_state(device
->wined3d_device
, NULL
,
841 (const struct wined3d_color
*)blend_factor
, sample_mask
);
843 wined3d_device_set_blend_state(device
->wined3d_device
, blend_state_impl
->wined3d_state
,
844 (const struct wined3d_color
*)blend_factor
, sample_mask
);
845 wined3d_mutex_unlock();
848 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext1
*iface
,
849 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
851 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
852 struct d3d_depthstencil_state
*state_impl
;
853 const D3D11_DEPTH_STENCIL_DESC
*desc
;
855 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
856 iface
, depth_stencil_state
, stencil_ref
);
858 wined3d_mutex_lock();
859 device
->stencil_ref
= stencil_ref
;
860 if (!(state_impl
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
862 wined3d_device_set_depth_stencil_state(device
->wined3d_device
, NULL
);
863 wined3d_mutex_unlock();
867 wined3d_device_set_depth_stencil_state(device
->wined3d_device
, state_impl
->wined3d_state
);
868 desc
= &state_impl
->desc
;
870 if (desc
->StencilEnable
)
872 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
874 wined3d_mutex_unlock();
877 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext1
*iface
, UINT buffer_count
,
878 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
880 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
881 unsigned int count
, i
;
883 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
885 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
886 wined3d_mutex_lock();
887 for (i
= 0; i
< count
; ++i
)
889 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
891 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
892 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
? offsets
[i
] : 0);
894 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
896 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
898 wined3d_mutex_unlock();
901 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext1
*iface
)
903 FIXME("iface %p stub!\n", iface
);
906 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext1
*iface
,
907 ID3D11Buffer
*buffer
, UINT offset
)
909 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
910 struct d3d_buffer
*d3d_buffer
;
912 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
914 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
916 wined3d_mutex_lock();
917 wined3d_device_draw_indexed_primitive_instanced_indirect(device
->wined3d_device
,
918 d3d_buffer
->wined3d_buffer
, offset
);
919 wined3d_mutex_unlock();
922 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext1
*iface
,
923 ID3D11Buffer
*buffer
, UINT offset
)
925 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
926 struct d3d_buffer
*d3d_buffer
;
928 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
930 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
932 wined3d_mutex_lock();
933 wined3d_device_draw_primitive_instanced_indirect(device
->wined3d_device
,
934 d3d_buffer
->wined3d_buffer
, offset
);
935 wined3d_mutex_unlock();
938 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext1
*iface
,
939 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
941 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
943 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
944 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
946 wined3d_mutex_lock();
947 wined3d_device_dispatch_compute(device
->wined3d_device
,
948 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
949 wined3d_mutex_unlock();
952 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext1
*iface
,
953 ID3D11Buffer
*buffer
, UINT offset
)
955 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
956 struct d3d_buffer
*buffer_impl
;
958 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
960 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
962 wined3d_mutex_lock();
963 wined3d_device_dispatch_compute_indirect(device
->wined3d_device
,
964 buffer_impl
->wined3d_buffer
, offset
);
965 wined3d_mutex_unlock();
968 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext1
*iface
,
969 ID3D11RasterizerState
*rasterizer_state
)
971 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
972 struct d3d_rasterizer_state
*rasterizer_state_impl
;
973 const D3D11_RASTERIZER_DESC
*desc
;
975 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
977 wined3d_mutex_lock();
978 if (!(rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
980 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
981 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
982 wined3d_mutex_unlock();
986 wined3d_device_set_rasterizer_state(device
->wined3d_device
, rasterizer_state_impl
->wined3d_state
);
988 desc
= &rasterizer_state_impl
->desc
;
989 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
990 wined3d_mutex_unlock();
993 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext1
*iface
,
994 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
996 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
997 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
1000 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
1002 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
1005 for (i
= 0; i
< viewport_count
; ++i
)
1007 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
1008 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
1009 wined3d_vp
[i
].width
= viewports
[i
].Width
;
1010 wined3d_vp
[i
].height
= viewports
[i
].Height
;
1011 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
1012 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
1015 wined3d_mutex_lock();
1016 wined3d_device_set_viewports(device
->wined3d_device
, viewport_count
, wined3d_vp
);
1017 wined3d_mutex_unlock();
1020 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext1
*iface
,
1021 UINT rect_count
, const D3D11_RECT
*rects
)
1023 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1025 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
1027 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
1030 wined3d_mutex_lock();
1031 wined3d_device_set_scissor_rects(device
->wined3d_device
, rect_count
, rects
);
1032 wined3d_mutex_unlock();
1035 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext1
*iface
,
1036 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
1037 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
1039 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1040 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1041 struct wined3d_box wined3d_src_box
;
1043 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
1044 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
1045 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
1046 src_resource
, src_subresource_idx
, src_box
);
1048 if (!dst_resource
|| !src_resource
)
1052 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
1053 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
1055 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1056 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1057 wined3d_mutex_lock();
1058 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
1059 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
1060 wined3d_mutex_unlock();
1063 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext1
*iface
,
1064 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
1066 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1067 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1069 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1071 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1072 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1073 wined3d_mutex_lock();
1074 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1075 wined3d_mutex_unlock();
1078 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext1
*iface
,
1079 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1080 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1082 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1083 struct wined3d_resource
*wined3d_resource
;
1084 struct wined3d_box wined3d_box
;
1086 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1087 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1090 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1092 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1093 wined3d_mutex_lock();
1094 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1095 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, 0);
1096 wined3d_mutex_unlock();
1099 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext1
*iface
,
1100 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1102 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1103 struct d3d11_unordered_access_view
*uav
;
1104 struct d3d_buffer
*buffer_impl
;
1106 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1107 iface
, dst_buffer
, dst_offset
, src_view
);
1109 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1110 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1112 wined3d_mutex_lock();
1113 wined3d_device_copy_uav_counter(device
->wined3d_device
,
1114 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1115 wined3d_mutex_unlock();
1118 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext1
*iface
,
1119 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1121 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1122 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1123 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1126 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1127 iface
, render_target_view
, debug_float4(color_rgba
));
1132 wined3d_mutex_lock();
1133 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1134 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1135 ERR("Failed to clear view, hr %#x.\n", hr
);
1136 wined3d_mutex_unlock();
1139 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1
*iface
,
1140 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1142 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1143 struct d3d11_unordered_access_view
*view
;
1145 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1146 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1148 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1149 wined3d_mutex_lock();
1150 wined3d_device_clear_unordered_access_view_uint(device
->wined3d_device
,
1151 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1152 wined3d_mutex_unlock();
1155 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1
*iface
,
1156 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1158 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1159 iface
, unordered_access_view
, debug_float4(values
));
1162 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext1
*iface
,
1163 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1165 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1166 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1167 DWORD wined3d_flags
;
1170 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1171 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1176 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1178 wined3d_mutex_lock();
1179 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1180 wined3d_flags
, NULL
, depth
, stencil
)))
1181 ERR("Failed to clear view, hr %#x.\n", hr
);
1182 wined3d_mutex_unlock();
1185 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext1
*iface
,
1186 ID3D11ShaderResourceView
*view
)
1188 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D11ShaderResourceView(view
);
1190 TRACE("iface %p, view %p.\n", iface
, view
);
1192 wined3d_mutex_lock();
1193 wined3d_shader_resource_view_generate_mipmaps(srv
->wined3d_view
);
1194 wined3d_mutex_unlock();
1197 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1198 ID3D11Resource
*resource
, FLOAT min_lod
)
1200 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1203 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1204 ID3D11Resource
*resource
)
1206 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1211 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext1
*iface
,
1212 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1213 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1216 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1217 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1218 enum wined3d_format_id wined3d_format
;
1220 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
1221 "src_resource %p, src_subresource_idx %u, format %s.\n",
1222 iface
, dst_resource
, dst_subresource_idx
,
1223 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1225 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1226 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1227 wined3d_format
= wined3dformat_from_dxgi_format(format
);
1228 wined3d_mutex_lock();
1229 wined3d_device_resolve_sub_resource(device
->wined3d_device
,
1230 wined3d_dst_resource
, dst_subresource_idx
,
1231 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
1232 wined3d_mutex_unlock();
1235 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext1
*iface
,
1236 ID3D11CommandList
*command_list
, BOOL restore_state
)
1238 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1241 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext1
*iface
,
1242 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1244 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1247 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1248 iface
, start_slot
, view_count
, views
);
1250 wined3d_mutex_lock();
1251 for (i
= 0; i
< view_count
; ++i
)
1253 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1255 wined3d_device_set_hs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1256 view
? view
->wined3d_view
: NULL
);
1258 wined3d_mutex_unlock();
1261 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext1
*iface
,
1262 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1264 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1265 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1267 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1268 iface
, shader
, class_instances
, class_instance_count
);
1270 if (class_instances
)
1271 FIXME("Dynamic linking is not implemented yet.\n");
1273 wined3d_mutex_lock();
1274 wined3d_device_set_hull_shader(device
->wined3d_device
, hs
? hs
->wined3d_shader
: NULL
);
1275 wined3d_mutex_unlock();
1278 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext1
*iface
,
1279 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1281 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1284 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1285 iface
, start_slot
, sampler_count
, samplers
);
1287 wined3d_mutex_lock();
1288 for (i
= 0; i
< sampler_count
; ++i
)
1290 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1292 wined3d_device_set_hs_sampler(device
->wined3d_device
, start_slot
+ i
,
1293 sampler
? sampler
->wined3d_sampler
: NULL
);
1295 wined3d_mutex_unlock();
1298 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1299 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1301 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1302 iface
, start_slot
, buffer_count
, buffers
);
1304 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
1305 buffer_count
, buffers
);
1308 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext1
*iface
,
1309 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1311 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1314 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1315 iface
, start_slot
, view_count
, views
);
1317 wined3d_mutex_lock();
1318 for (i
= 0; i
< view_count
; ++i
)
1320 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1322 wined3d_device_set_ds_resource_view(device
->wined3d_device
, start_slot
+ i
,
1323 view
? view
->wined3d_view
: NULL
);
1325 wined3d_mutex_unlock();
1328 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext1
*iface
,
1329 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1331 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1332 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1334 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1335 iface
, shader
, class_instances
, class_instance_count
);
1337 if (class_instances
)
1338 FIXME("Dynamic linking is not implemented yet.\n");
1340 wined3d_mutex_lock();
1341 wined3d_device_set_domain_shader(device
->wined3d_device
, ds
? ds
->wined3d_shader
: NULL
);
1342 wined3d_mutex_unlock();
1345 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext1
*iface
,
1346 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1348 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1351 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1352 iface
, start_slot
, sampler_count
, samplers
);
1354 wined3d_mutex_lock();
1355 for (i
= 0; i
< sampler_count
; ++i
)
1357 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1359 wined3d_device_set_ds_sampler(device
->wined3d_device
, start_slot
+ i
,
1360 sampler
? sampler
->wined3d_sampler
: NULL
);
1362 wined3d_mutex_unlock();
1365 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1366 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1368 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1369 iface
, start_slot
, buffer_count
, buffers
);
1371 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
1372 buffer_count
, buffers
);
1375 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext1
*iface
,
1376 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1378 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1381 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1382 iface
, start_slot
, view_count
, views
);
1384 wined3d_mutex_lock();
1385 for (i
= 0; i
< view_count
; ++i
)
1387 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1389 wined3d_device_set_cs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1390 view
? view
->wined3d_view
: NULL
);
1392 wined3d_mutex_unlock();
1395 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
1396 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1398 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1401 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1402 iface
, start_slot
, view_count
, views
, initial_counts
);
1404 wined3d_mutex_lock();
1405 for (i
= 0; i
< view_count
; ++i
)
1407 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1409 wined3d_device_set_cs_uav(device
->wined3d_device
, start_slot
+ i
,
1410 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
1412 wined3d_mutex_unlock();
1415 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext1
*iface
,
1416 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1418 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1419 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1421 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1422 iface
, shader
, class_instances
, class_instance_count
);
1424 if (class_instances
)
1425 FIXME("Dynamic linking is not implemented yet.\n");
1427 wined3d_mutex_lock();
1428 wined3d_device_set_compute_shader(device
->wined3d_device
, cs
? cs
->wined3d_shader
: NULL
);
1429 wined3d_mutex_unlock();
1432 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext1
*iface
,
1433 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1435 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1438 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1439 iface
, start_slot
, sampler_count
, samplers
);
1441 wined3d_mutex_lock();
1442 for (i
= 0; i
< sampler_count
; ++i
)
1444 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1446 wined3d_device_set_cs_sampler(device
->wined3d_device
, start_slot
+ i
,
1447 sampler
? sampler
->wined3d_sampler
: NULL
);
1449 wined3d_mutex_unlock();
1452 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1453 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1455 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1456 iface
, start_slot
, buffer_count
, buffers
);
1458 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
1459 buffer_count
, buffers
);
1462 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1463 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1465 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1466 iface
, start_slot
, buffer_count
, buffers
);
1468 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
1469 buffer_count
, buffers
);
1472 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext1
*iface
,
1473 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1475 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1478 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1479 iface
, start_slot
, view_count
, views
);
1481 wined3d_mutex_lock();
1482 for (i
= 0; i
< view_count
; ++i
)
1484 struct wined3d_shader_resource_view
*wined3d_view
;
1485 struct d3d_shader_resource_view
*view_impl
;
1487 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1493 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1494 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1495 ID3D11ShaderResourceView_AddRef(views
[i
]);
1497 wined3d_mutex_unlock();
1500 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext1
*iface
,
1501 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1503 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1504 struct wined3d_shader
*wined3d_shader
;
1505 struct d3d_pixel_shader
*shader_impl
;
1507 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1508 iface
, shader
, class_instances
, class_instance_count
);
1510 if (class_instances
|| class_instance_count
)
1511 FIXME("Dynamic linking not implemented yet.\n");
1512 if (class_instance_count
)
1513 *class_instance_count
= 0;
1515 wined3d_mutex_lock();
1516 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1518 wined3d_mutex_unlock();
1523 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1524 wined3d_mutex_unlock();
1525 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1526 ID3D11PixelShader_AddRef(*shader
);
1529 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext1
*iface
,
1530 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1532 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1535 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1536 iface
, start_slot
, sampler_count
, samplers
);
1538 wined3d_mutex_lock();
1539 for (i
= 0; i
< sampler_count
; ++i
)
1541 struct wined3d_sampler
*wined3d_sampler
;
1542 struct d3d_sampler_state
*sampler_impl
;
1544 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1550 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1551 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1552 ID3D11SamplerState_AddRef(samplers
[i
]);
1554 wined3d_mutex_unlock();
1557 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext1
*iface
,
1558 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1560 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1561 struct d3d_vertex_shader
*shader_impl
;
1562 struct wined3d_shader
*wined3d_shader
;
1564 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1565 iface
, shader
, class_instances
, class_instance_count
);
1567 if (class_instances
|| class_instance_count
)
1568 FIXME("Dynamic linking not implemented yet.\n");
1569 if (class_instance_count
)
1570 *class_instance_count
= 0;
1572 wined3d_mutex_lock();
1573 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1575 wined3d_mutex_unlock();
1580 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1581 wined3d_mutex_unlock();
1582 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1583 ID3D11VertexShader_AddRef(*shader
);
1586 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1587 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1589 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1590 iface
, start_slot
, buffer_count
, buffers
);
1592 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
1593 buffer_count
, buffers
);
1596 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext1
*iface
,
1597 ID3D11InputLayout
**input_layout
)
1599 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1600 struct wined3d_vertex_declaration
*wined3d_declaration
;
1601 struct d3d_input_layout
*input_layout_impl
;
1603 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1605 wined3d_mutex_lock();
1606 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1608 wined3d_mutex_unlock();
1609 *input_layout
= NULL
;
1613 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1614 wined3d_mutex_unlock();
1615 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1616 ID3D11InputLayout_AddRef(*input_layout
);
1619 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext1
*iface
,
1620 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1622 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1625 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1626 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1628 wined3d_mutex_lock();
1629 for (i
= 0; i
< buffer_count
; ++i
)
1631 struct wined3d_buffer
*wined3d_buffer
= NULL
;
1632 struct d3d_buffer
*buffer_impl
;
1634 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1635 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1637 FIXME("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1644 if (!wined3d_buffer
)
1650 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1651 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1653 wined3d_mutex_unlock();
1656 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext1
*iface
,
1657 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1659 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1660 enum wined3d_format_id wined3d_format
;
1661 struct wined3d_buffer
*wined3d_buffer
;
1662 struct d3d_buffer
*buffer_impl
;
1664 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1666 wined3d_mutex_lock();
1667 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1668 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1669 if (!wined3d_buffer
)
1671 wined3d_mutex_unlock();
1676 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1677 wined3d_mutex_unlock();
1678 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1681 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1682 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1684 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1685 iface
, start_slot
, buffer_count
, buffers
);
1687 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
1688 buffer_count
, buffers
);
1691 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext1
*iface
,
1692 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1694 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1695 struct d3d_geometry_shader
*shader_impl
;
1696 struct wined3d_shader
*wined3d_shader
;
1698 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1699 iface
, shader
, class_instances
, class_instance_count
);
1701 if (class_instances
|| class_instance_count
)
1702 FIXME("Dynamic linking not implemented yet.\n");
1703 if (class_instance_count
)
1704 *class_instance_count
= 0;
1706 wined3d_mutex_lock();
1707 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1709 wined3d_mutex_unlock();
1714 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1715 wined3d_mutex_unlock();
1716 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1717 ID3D11GeometryShader_AddRef(*shader
);
1720 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
1721 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1723 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1724 enum wined3d_primitive_type primitive_type
;
1725 unsigned int patch_vertex_count
;
1727 TRACE("iface %p, topology %p.\n", iface
, topology
);
1729 wined3d_mutex_lock();
1730 wined3d_device_get_primitive_type(device
->wined3d_device
, &primitive_type
, &patch_vertex_count
);
1731 wined3d_mutex_unlock();
1733 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1736 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext1
*iface
,
1737 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1739 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1742 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1744 wined3d_mutex_lock();
1745 for (i
= 0; i
< view_count
; ++i
)
1747 struct wined3d_shader_resource_view
*wined3d_view
;
1748 struct d3d_shader_resource_view
*view_impl
;
1750 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1756 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1757 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1758 ID3D11ShaderResourceView_AddRef(views
[i
]);
1760 wined3d_mutex_unlock();
1763 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext1
*iface
,
1764 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1766 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1769 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1770 iface
, start_slot
, sampler_count
, samplers
);
1772 wined3d_mutex_lock();
1773 for (i
= 0; i
< sampler_count
; ++i
)
1775 struct wined3d_sampler
*wined3d_sampler
;
1776 struct d3d_sampler_state
*sampler_impl
;
1778 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1784 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1785 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1786 ID3D11SamplerState_AddRef(samplers
[i
]);
1788 wined3d_mutex_unlock();
1791 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext1
*iface
,
1792 ID3D11Predicate
**predicate
, BOOL
*value
)
1794 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1795 struct wined3d_query
*wined3d_predicate
;
1796 struct d3d_query
*predicate_impl
;
1798 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1800 wined3d_mutex_lock();
1801 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1803 wined3d_mutex_unlock();
1808 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1809 wined3d_mutex_unlock();
1810 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1811 ID3D11Predicate_AddRef(*predicate
);
1814 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext1
*iface
,
1815 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1817 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1820 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1822 wined3d_mutex_lock();
1823 for (i
= 0; i
< view_count
; ++i
)
1825 struct wined3d_shader_resource_view
*wined3d_view
;
1826 struct d3d_shader_resource_view
*view_impl
;
1828 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1834 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1835 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1836 ID3D11ShaderResourceView_AddRef(views
[i
]);
1838 wined3d_mutex_unlock();
1841 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext1
*iface
,
1842 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1844 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1847 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1848 iface
, start_slot
, sampler_count
, samplers
);
1850 wined3d_mutex_lock();
1851 for (i
= 0; i
< sampler_count
; ++i
)
1853 struct d3d_sampler_state
*sampler_impl
;
1854 struct wined3d_sampler
*wined3d_sampler
;
1856 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1862 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1863 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1864 ID3D11SamplerState_AddRef(samplers
[i
]);
1866 wined3d_mutex_unlock();
1869 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext1
*iface
,
1870 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1871 ID3D11DepthStencilView
**depth_stencil_view
)
1873 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1874 struct wined3d_rendertarget_view
*wined3d_view
;
1876 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1877 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1879 wined3d_mutex_lock();
1880 if (render_target_views
)
1882 struct d3d_rendertarget_view
*view_impl
;
1885 for (i
= 0; i
< render_target_view_count
; ++i
)
1887 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1888 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1890 render_target_views
[i
] = NULL
;
1894 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1895 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1899 if (depth_stencil_view
)
1901 struct d3d_depthstencil_view
*view_impl
;
1903 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1904 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1906 *depth_stencil_view
= NULL
;
1910 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1911 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1914 wined3d_mutex_unlock();
1917 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1918 ID3D11DeviceContext1
*iface
,
1919 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1920 ID3D11DepthStencilView
**depth_stencil_view
,
1921 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1922 ID3D11UnorderedAccessView
**unordered_access_views
)
1924 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1925 struct wined3d_unordered_access_view
*wined3d_view
;
1926 struct d3d11_unordered_access_view
*view_impl
;
1929 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1930 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1931 "unordered_access_views %p.\n",
1932 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1933 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1935 if (render_target_views
|| depth_stencil_view
)
1936 d3d11_immediate_context_OMGetRenderTargets(iface
, render_target_view_count
,
1937 render_target_views
, depth_stencil_view
);
1939 if (unordered_access_views
)
1941 wined3d_mutex_lock();
1942 for (i
= 0; i
< unordered_access_view_count
; ++i
)
1944 if (!(wined3d_view
= wined3d_device_get_unordered_access_view(device
->wined3d_device
,
1945 unordered_access_view_start_slot
+ i
)))
1947 unordered_access_views
[i
] = NULL
;
1951 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
1952 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
1953 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
1955 wined3d_mutex_unlock();
1959 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext1
*iface
,
1960 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1962 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1963 struct wined3d_blend_state
*wined3d_state
;
1964 struct d3d_blend_state
*blend_state_impl
;
1966 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1967 iface
, blend_state
, blend_factor
, sample_mask
);
1969 wined3d_mutex_lock();
1970 if ((wined3d_state
= wined3d_device_get_blend_state(device
->wined3d_device
,
1971 (struct wined3d_color
*)blend_factor
, sample_mask
)))
1973 blend_state_impl
= wined3d_blend_state_get_parent(wined3d_state
);
1974 ID3D11BlendState_AddRef(*blend_state
= &blend_state_impl
->ID3D11BlendState_iface
);
1978 *blend_state
= NULL
;
1980 wined3d_mutex_unlock();
1983 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext1
*iface
,
1984 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1986 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1987 struct wined3d_depth_stencil_state
*wined3d_state
;
1988 struct d3d_depthstencil_state
*state_impl
;
1990 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1991 iface
, depth_stencil_state
, stencil_ref
);
1993 wined3d_mutex_lock();
1994 if ((wined3d_state
= wined3d_device_get_depth_stencil_state(device
->wined3d_device
)))
1996 state_impl
= wined3d_depth_stencil_state_get_parent(wined3d_state
);
1997 ID3D11DepthStencilState_AddRef(*depth_stencil_state
= &state_impl
->ID3D11DepthStencilState_iface
);
2001 *depth_stencil_state
= NULL
;
2003 *stencil_ref
= device
->stencil_ref
;
2004 wined3d_mutex_unlock();
2007 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext1
*iface
,
2008 UINT buffer_count
, ID3D11Buffer
**buffers
)
2010 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2013 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
2015 wined3d_mutex_lock();
2016 for (i
= 0; i
< buffer_count
; ++i
)
2018 struct wined3d_buffer
*wined3d_buffer
;
2019 struct d3d_buffer
*buffer_impl
;
2021 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
2027 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2028 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
2029 ID3D11Buffer_AddRef(buffers
[i
]);
2031 wined3d_mutex_unlock();
2034 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext1
*iface
,
2035 ID3D11RasterizerState
**rasterizer_state
)
2037 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2038 struct d3d_rasterizer_state
*rasterizer_state_impl
;
2039 struct wined3d_rasterizer_state
*wined3d_state
;
2041 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
2043 wined3d_mutex_lock();
2044 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
2046 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
2047 ID3D11RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D11RasterizerState_iface
);
2051 *rasterizer_state
= NULL
;
2053 wined3d_mutex_unlock();
2056 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext1
*iface
,
2057 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
2059 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2060 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
2061 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
2063 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2065 if (!viewport_count
)
2068 wined3d_mutex_lock();
2069 wined3d_device_get_viewports(device
->wined3d_device
, &actual_count
, viewports
? wined3d_vp
: NULL
);
2070 wined3d_mutex_unlock();
2074 *viewport_count
= actual_count
;
2078 if (*viewport_count
> actual_count
)
2079 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
2081 *viewport_count
= min(actual_count
, *viewport_count
);
2082 for (i
= 0; i
< *viewport_count
; ++i
)
2084 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
2085 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
2086 viewports
[i
].Width
= wined3d_vp
[i
].width
;
2087 viewports
[i
].Height
= wined3d_vp
[i
].height
;
2088 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
2089 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
2093 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext1
*iface
,
2094 UINT
*rect_count
, D3D11_RECT
*rects
)
2096 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2097 unsigned int actual_count
;
2099 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2104 actual_count
= *rect_count
;
2106 wined3d_mutex_lock();
2107 wined3d_device_get_scissor_rects(device
->wined3d_device
, &actual_count
, rects
);
2108 wined3d_mutex_unlock();
2112 *rect_count
= actual_count
;
2116 if (*rect_count
> actual_count
)
2117 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
2120 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1
*iface
,
2121 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2123 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2126 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2128 wined3d_mutex_lock();
2129 for (i
= 0; i
< view_count
; ++i
)
2131 struct wined3d_shader_resource_view
*wined3d_view
;
2132 struct d3d_shader_resource_view
*view_impl
;
2134 if (!(wined3d_view
= wined3d_device_get_hs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2140 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2141 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2143 wined3d_mutex_unlock();
2146 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext1
*iface
,
2147 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2149 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2150 struct d3d11_hull_shader
*shader_impl
;
2151 struct wined3d_shader
*wined3d_shader
;
2153 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2154 iface
, shader
, class_instances
, class_instance_count
);
2156 if (class_instances
|| class_instance_count
)
2157 FIXME("Dynamic linking not implemented yet.\n");
2158 if (class_instance_count
)
2159 *class_instance_count
= 0;
2161 wined3d_mutex_lock();
2162 if (!(wined3d_shader
= wined3d_device_get_hull_shader(device
->wined3d_device
)))
2164 wined3d_mutex_unlock();
2169 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2170 wined3d_mutex_unlock();
2171 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2174 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext1
*iface
,
2175 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2177 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2180 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2181 iface
, start_slot
, sampler_count
, samplers
);
2183 wined3d_mutex_lock();
2184 for (i
= 0; i
< sampler_count
; ++i
)
2186 struct wined3d_sampler
*wined3d_sampler
;
2187 struct d3d_sampler_state
*sampler_impl
;
2189 if (!(wined3d_sampler
= wined3d_device_get_hs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2195 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2196 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2198 wined3d_mutex_unlock();
2201 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2202 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2204 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2205 iface
, start_slot
, buffer_count
, buffers
);
2207 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2208 buffer_count
, buffers
);
2211 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext1
*iface
,
2212 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2214 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2217 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2218 iface
, start_slot
, view_count
, views
);
2220 wined3d_mutex_lock();
2221 for (i
= 0; i
< view_count
; ++i
)
2223 struct wined3d_shader_resource_view
*wined3d_view
;
2224 struct d3d_shader_resource_view
*view_impl
;
2226 if (!(wined3d_view
= wined3d_device_get_ds_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2232 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2233 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2235 wined3d_mutex_unlock();
2238 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext1
*iface
,
2239 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2241 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2242 struct d3d11_domain_shader
*shader_impl
;
2243 struct wined3d_shader
*wined3d_shader
;
2245 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2246 iface
, shader
, class_instances
, class_instance_count
);
2248 if (class_instances
|| class_instance_count
)
2249 FIXME("Dynamic linking not implemented yet.\n");
2250 if (class_instance_count
)
2251 *class_instance_count
= 0;
2253 wined3d_mutex_lock();
2254 if (!(wined3d_shader
= wined3d_device_get_domain_shader(device
->wined3d_device
)))
2256 wined3d_mutex_unlock();
2261 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2262 wined3d_mutex_unlock();
2263 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2266 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext1
*iface
,
2267 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2269 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2272 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2273 iface
, start_slot
, sampler_count
, samplers
);
2275 wined3d_mutex_lock();
2276 for (i
= 0; i
< sampler_count
; ++i
)
2278 struct wined3d_sampler
*wined3d_sampler
;
2279 struct d3d_sampler_state
*sampler_impl
;
2281 if (!(wined3d_sampler
= wined3d_device_get_ds_sampler(device
->wined3d_device
, start_slot
+ i
)))
2287 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2288 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2290 wined3d_mutex_unlock();
2293 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2294 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2296 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2297 iface
, start_slot
, buffer_count
, buffers
);
2299 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2300 buffer_count
, buffers
);
2303 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext1
*iface
,
2304 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2306 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2309 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2311 wined3d_mutex_lock();
2312 for (i
= 0; i
< view_count
; ++i
)
2314 struct wined3d_shader_resource_view
*wined3d_view
;
2315 struct d3d_shader_resource_view
*view_impl
;
2317 if (!(wined3d_view
= wined3d_device_get_cs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2323 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2324 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2326 wined3d_mutex_unlock();
2329 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
2330 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2332 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2335 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2337 wined3d_mutex_lock();
2338 for (i
= 0; i
< view_count
; ++i
)
2340 struct wined3d_unordered_access_view
*wined3d_view
;
2341 struct d3d11_unordered_access_view
*view_impl
;
2343 if (!(wined3d_view
= wined3d_device_get_cs_uav(device
->wined3d_device
, start_slot
+ i
)))
2349 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2350 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2352 wined3d_mutex_unlock();
2355 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext1
*iface
,
2356 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2358 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2359 struct d3d11_compute_shader
*shader_impl
;
2360 struct wined3d_shader
*wined3d_shader
;
2362 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2363 iface
, shader
, class_instances
, class_instance_count
);
2365 if (class_instances
|| class_instance_count
)
2366 FIXME("Dynamic linking not implemented yet.\n");
2367 if (class_instance_count
)
2368 *class_instance_count
= 0;
2370 wined3d_mutex_lock();
2371 if (!(wined3d_shader
= wined3d_device_get_compute_shader(device
->wined3d_device
)))
2373 wined3d_mutex_unlock();
2378 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2379 wined3d_mutex_unlock();
2380 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2383 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext1
*iface
,
2384 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2386 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2389 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2390 iface
, start_slot
, sampler_count
, samplers
);
2392 wined3d_mutex_lock();
2393 for (i
= 0; i
< sampler_count
; ++i
)
2395 struct wined3d_sampler
*wined3d_sampler
;
2396 struct d3d_sampler_state
*sampler_impl
;
2398 if (!(wined3d_sampler
= wined3d_device_get_cs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2404 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2405 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2407 wined3d_mutex_unlock();
2410 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2411 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2413 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2414 iface
, start_slot
, buffer_count
, buffers
);
2416 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2417 buffer_count
, buffers
);
2420 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext1
*iface
)
2422 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2423 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
2426 TRACE("iface %p.\n", iface
);
2428 wined3d_mutex_lock();
2429 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
2430 wined3d_device_set_hull_shader(device
->wined3d_device
, NULL
);
2431 wined3d_device_set_domain_shader(device
->wined3d_device
, NULL
);
2432 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
2433 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
2434 wined3d_device_set_compute_shader(device
->wined3d_device
, NULL
);
2435 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
2437 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
2438 wined3d_device_set_hs_sampler(device
->wined3d_device
, i
, NULL
);
2439 wined3d_device_set_ds_sampler(device
->wined3d_device
, i
, NULL
);
2440 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
2441 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
2442 wined3d_device_set_cs_sampler(device
->wined3d_device
, i
, NULL
);
2444 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2446 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
2447 wined3d_device_set_hs_resource_view(device
->wined3d_device
, i
, NULL
);
2448 wined3d_device_set_ds_resource_view(device
->wined3d_device
, i
, NULL
);
2449 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
2450 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
2451 wined3d_device_set_cs_resource_view(device
->wined3d_device
, i
, NULL
);
2453 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
2455 for (j
= 0; j
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++j
)
2456 wined3d_device_set_constant_buffer(device
->wined3d_device
, i
, j
, NULL
);
2458 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2460 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
2462 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
2463 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
2464 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
, 0);
2465 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2467 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
2469 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
2470 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
2472 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
2473 wined3d_device_set_cs_uav(device
->wined3d_device
, i
, NULL
, ~0u);
2475 ID3D11DeviceContext1_OMSetDepthStencilState(iface
, NULL
, 0);
2476 ID3D11DeviceContext1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
2477 ID3D11DeviceContext1_RSSetViewports(iface
, 0, NULL
);
2478 ID3D11DeviceContext1_RSSetScissorRects(iface
, 0, NULL
);
2479 ID3D11DeviceContext1_RSSetState(iface
, NULL
);
2480 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
2482 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
2484 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
2485 wined3d_mutex_unlock();
2488 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext1
*iface
)
2490 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2492 TRACE("iface %p.\n", iface
);
2494 wined3d_mutex_lock();
2495 wined3d_device_flush(device
->wined3d_device
);
2496 wined3d_mutex_unlock();
2499 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext1
*iface
)
2501 TRACE("iface %p.\n", iface
);
2503 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
2506 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext1
*iface
)
2508 TRACE("iface %p.\n", iface
);
2513 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext1
*iface
,
2514 BOOL restore
, ID3D11CommandList
**command_list
)
2516 TRACE("iface %p, restore %#x, command_list %p.\n", iface
, restore
, command_list
);
2518 return DXGI_ERROR_INVALID_CALL
;
2521 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion1(ID3D11DeviceContext1
*iface
,
2522 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
2523 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
, UINT flags
)
2525 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2526 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
2527 struct wined3d_box wined3d_src_box
;
2529 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
2530 "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n",
2531 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
2532 src_resource
, src_subresource_idx
, src_box
, flags
);
2534 if (!dst_resource
|| !src_resource
)
2538 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
2539 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
2541 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
2542 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
2543 wined3d_mutex_lock();
2544 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
2545 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, flags
);
2546 wined3d_mutex_unlock();
2549 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource1(ID3D11DeviceContext1
*iface
,
2550 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
, const void *data
,
2551 UINT row_pitch
, UINT depth_pitch
, UINT flags
)
2553 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2554 struct wined3d_resource
*wined3d_resource
;
2555 struct wined3d_box wined3d_box
;
2557 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n",
2558 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
, flags
);
2561 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
,
2562 box
->front
, box
->back
);
2564 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
2565 wined3d_mutex_lock();
2566 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
, subresource_idx
,
2567 box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, flags
);
2568 wined3d_mutex_unlock();
2571 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardResource(ID3D11DeviceContext1
*iface
,
2572 ID3D11Resource
*resource
)
2574 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
2577 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
)
2579 FIXME("iface %p, view %p stub!\n", iface
, view
);
2582 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2583 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2584 const UINT
*num_constants
)
2586 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2587 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2590 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2591 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2592 const UINT
*num_constants
)
2594 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2595 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2598 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2599 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2600 const UINT
*num_constants
)
2602 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2603 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2606 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2607 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2608 const UINT
*num_constants
)
2610 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2611 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2614 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2615 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2616 const UINT
*num_constants
)
2618 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2619 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2622 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2623 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2624 const UINT
*num_constants
)
2626 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2627 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2630 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2631 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2633 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2634 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2637 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2638 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2640 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2641 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2644 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2645 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2647 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2648 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2651 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2652 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2654 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2655 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2658 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2659 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2661 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2662 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2665 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2666 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2668 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2669 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2672 static void STDMETHODCALLTYPE
d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1
*iface
,
2673 ID3DDeviceContextState
*state
, ID3DDeviceContextState
**prev_state
)
2675 FIXME("iface %p, state %p, prev_state %p stub!\n", iface
, state
, prev_state
);
2678 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2679 const FLOAT color
[4], const D3D11_RECT
*rect
, UINT num_rects
)
2681 FIXME("iface %p, view %p, color %p, rect %p, num_rects %u stub!\n", iface
, view
, color
, rect
, num_rects
);
2684 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardView1(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2685 const D3D11_RECT
*rects
, UINT num_rects
)
2687 FIXME("iface %p, view %p, rects %p, num_rects %u stub!\n", iface
, view
, rects
, num_rects
);
2690 static const struct ID3D11DeviceContext1Vtbl d3d11_immediate_context_vtbl
=
2692 /* IUnknown methods */
2693 d3d11_immediate_context_QueryInterface
,
2694 d3d11_immediate_context_AddRef
,
2695 d3d11_immediate_context_Release
,
2696 /* ID3D11DeviceChild methods */
2697 d3d11_immediate_context_GetDevice
,
2698 d3d11_immediate_context_GetPrivateData
,
2699 d3d11_immediate_context_SetPrivateData
,
2700 d3d11_immediate_context_SetPrivateDataInterface
,
2701 /* ID3D11DeviceContext methods */
2702 d3d11_immediate_context_VSSetConstantBuffers
,
2703 d3d11_immediate_context_PSSetShaderResources
,
2704 d3d11_immediate_context_PSSetShader
,
2705 d3d11_immediate_context_PSSetSamplers
,
2706 d3d11_immediate_context_VSSetShader
,
2707 d3d11_immediate_context_DrawIndexed
,
2708 d3d11_immediate_context_Draw
,
2709 d3d11_immediate_context_Map
,
2710 d3d11_immediate_context_Unmap
,
2711 d3d11_immediate_context_PSSetConstantBuffers
,
2712 d3d11_immediate_context_IASetInputLayout
,
2713 d3d11_immediate_context_IASetVertexBuffers
,
2714 d3d11_immediate_context_IASetIndexBuffer
,
2715 d3d11_immediate_context_DrawIndexedInstanced
,
2716 d3d11_immediate_context_DrawInstanced
,
2717 d3d11_immediate_context_GSSetConstantBuffers
,
2718 d3d11_immediate_context_GSSetShader
,
2719 d3d11_immediate_context_IASetPrimitiveTopology
,
2720 d3d11_immediate_context_VSSetShaderResources
,
2721 d3d11_immediate_context_VSSetSamplers
,
2722 d3d11_immediate_context_Begin
,
2723 d3d11_immediate_context_End
,
2724 d3d11_immediate_context_GetData
,
2725 d3d11_immediate_context_SetPredication
,
2726 d3d11_immediate_context_GSSetShaderResources
,
2727 d3d11_immediate_context_GSSetSamplers
,
2728 d3d11_immediate_context_OMSetRenderTargets
,
2729 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
2730 d3d11_immediate_context_OMSetBlendState
,
2731 d3d11_immediate_context_OMSetDepthStencilState
,
2732 d3d11_immediate_context_SOSetTargets
,
2733 d3d11_immediate_context_DrawAuto
,
2734 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
2735 d3d11_immediate_context_DrawInstancedIndirect
,
2736 d3d11_immediate_context_Dispatch
,
2737 d3d11_immediate_context_DispatchIndirect
,
2738 d3d11_immediate_context_RSSetState
,
2739 d3d11_immediate_context_RSSetViewports
,
2740 d3d11_immediate_context_RSSetScissorRects
,
2741 d3d11_immediate_context_CopySubresourceRegion
,
2742 d3d11_immediate_context_CopyResource
,
2743 d3d11_immediate_context_UpdateSubresource
,
2744 d3d11_immediate_context_CopyStructureCount
,
2745 d3d11_immediate_context_ClearRenderTargetView
,
2746 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
2747 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
2748 d3d11_immediate_context_ClearDepthStencilView
,
2749 d3d11_immediate_context_GenerateMips
,
2750 d3d11_immediate_context_SetResourceMinLOD
,
2751 d3d11_immediate_context_GetResourceMinLOD
,
2752 d3d11_immediate_context_ResolveSubresource
,
2753 d3d11_immediate_context_ExecuteCommandList
,
2754 d3d11_immediate_context_HSSetShaderResources
,
2755 d3d11_immediate_context_HSSetShader
,
2756 d3d11_immediate_context_HSSetSamplers
,
2757 d3d11_immediate_context_HSSetConstantBuffers
,
2758 d3d11_immediate_context_DSSetShaderResources
,
2759 d3d11_immediate_context_DSSetShader
,
2760 d3d11_immediate_context_DSSetSamplers
,
2761 d3d11_immediate_context_DSSetConstantBuffers
,
2762 d3d11_immediate_context_CSSetShaderResources
,
2763 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2764 d3d11_immediate_context_CSSetShader
,
2765 d3d11_immediate_context_CSSetSamplers
,
2766 d3d11_immediate_context_CSSetConstantBuffers
,
2767 d3d11_immediate_context_VSGetConstantBuffers
,
2768 d3d11_immediate_context_PSGetShaderResources
,
2769 d3d11_immediate_context_PSGetShader
,
2770 d3d11_immediate_context_PSGetSamplers
,
2771 d3d11_immediate_context_VSGetShader
,
2772 d3d11_immediate_context_PSGetConstantBuffers
,
2773 d3d11_immediate_context_IAGetInputLayout
,
2774 d3d11_immediate_context_IAGetVertexBuffers
,
2775 d3d11_immediate_context_IAGetIndexBuffer
,
2776 d3d11_immediate_context_GSGetConstantBuffers
,
2777 d3d11_immediate_context_GSGetShader
,
2778 d3d11_immediate_context_IAGetPrimitiveTopology
,
2779 d3d11_immediate_context_VSGetShaderResources
,
2780 d3d11_immediate_context_VSGetSamplers
,
2781 d3d11_immediate_context_GetPredication
,
2782 d3d11_immediate_context_GSGetShaderResources
,
2783 d3d11_immediate_context_GSGetSamplers
,
2784 d3d11_immediate_context_OMGetRenderTargets
,
2785 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2786 d3d11_immediate_context_OMGetBlendState
,
2787 d3d11_immediate_context_OMGetDepthStencilState
,
2788 d3d11_immediate_context_SOGetTargets
,
2789 d3d11_immediate_context_RSGetState
,
2790 d3d11_immediate_context_RSGetViewports
,
2791 d3d11_immediate_context_RSGetScissorRects
,
2792 d3d11_immediate_context_HSGetShaderResources
,
2793 d3d11_immediate_context_HSGetShader
,
2794 d3d11_immediate_context_HSGetSamplers
,
2795 d3d11_immediate_context_HSGetConstantBuffers
,
2796 d3d11_immediate_context_DSGetShaderResources
,
2797 d3d11_immediate_context_DSGetShader
,
2798 d3d11_immediate_context_DSGetSamplers
,
2799 d3d11_immediate_context_DSGetConstantBuffers
,
2800 d3d11_immediate_context_CSGetShaderResources
,
2801 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2802 d3d11_immediate_context_CSGetShader
,
2803 d3d11_immediate_context_CSGetSamplers
,
2804 d3d11_immediate_context_CSGetConstantBuffers
,
2805 d3d11_immediate_context_ClearState
,
2806 d3d11_immediate_context_Flush
,
2807 d3d11_immediate_context_GetType
,
2808 d3d11_immediate_context_GetContextFlags
,
2809 d3d11_immediate_context_FinishCommandList
,
2810 /* ID3D11DeviceContext1 methods */
2811 d3d11_immediate_context_CopySubresourceRegion1
,
2812 d3d11_immediate_context_UpdateSubresource1
,
2813 d3d11_immediate_context_DiscardResource
,
2814 d3d11_immediate_context_DiscardView
,
2815 d3d11_immediate_context_VSSetConstantBuffers1
,
2816 d3d11_immediate_context_HSSetConstantBuffers1
,
2817 d3d11_immediate_context_DSSetConstantBuffers1
,
2818 d3d11_immediate_context_GSSetConstantBuffers1
,
2819 d3d11_immediate_context_PSSetConstantBuffers1
,
2820 d3d11_immediate_context_CSSetConstantBuffers1
,
2821 d3d11_immediate_context_VSGetConstantBuffers1
,
2822 d3d11_immediate_context_HSGetConstantBuffers1
,
2823 d3d11_immediate_context_DSGetConstantBuffers1
,
2824 d3d11_immediate_context_GSGetConstantBuffers1
,
2825 d3d11_immediate_context_PSGetConstantBuffers1
,
2826 d3d11_immediate_context_CSGetConstantBuffers1
,
2827 d3d11_immediate_context_SwapDeviceContextState
,
2828 d3d11_immediate_context_ClearView
,
2829 d3d11_immediate_context_DiscardView1
,
2832 /* ID3D11Multithread methods */
2834 static inline struct d3d11_immediate_context
*impl_from_ID3D11Multithread(ID3D11Multithread
*iface
)
2836 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11Multithread_iface
);
2839 static HRESULT STDMETHODCALLTYPE
d3d11_multithread_QueryInterface(ID3D11Multithread
*iface
,
2840 REFIID iid
, void **out
)
2842 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2844 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
2846 return d3d11_immediate_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
2849 static ULONG STDMETHODCALLTYPE
d3d11_multithread_AddRef(ID3D11Multithread
*iface
)
2851 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2853 TRACE("iface %p.\n", iface
);
2855 return d3d11_immediate_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
2858 static ULONG STDMETHODCALLTYPE
d3d11_multithread_Release(ID3D11Multithread
*iface
)
2860 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2862 TRACE("iface %p.\n", iface
);
2864 return d3d11_immediate_context_Release(&context
->ID3D11DeviceContext1_iface
);
2867 static void STDMETHODCALLTYPE
d3d11_multithread_Enter(ID3D11Multithread
*iface
)
2869 TRACE("iface %p.\n", iface
);
2871 wined3d_mutex_lock();
2874 static void STDMETHODCALLTYPE
d3d11_multithread_Leave(ID3D11Multithread
*iface
)
2876 TRACE("iface %p.\n", iface
);
2878 wined3d_mutex_unlock();
2881 static BOOL STDMETHODCALLTYPE
d3d11_multithread_SetMultithreadProtected(
2882 ID3D11Multithread
*iface
, BOOL enable
)
2884 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
2889 static BOOL STDMETHODCALLTYPE
d3d11_multithread_GetMultithreadProtected(ID3D11Multithread
*iface
)
2891 FIXME("iface %p stub!\n", iface
);
2896 static const struct ID3D11MultithreadVtbl d3d11_multithread_vtbl
=
2898 d3d11_multithread_QueryInterface
,
2899 d3d11_multithread_AddRef
,
2900 d3d11_multithread_Release
,
2901 d3d11_multithread_Enter
,
2902 d3d11_multithread_Leave
,
2903 d3d11_multithread_SetMultithreadProtected
,
2904 d3d11_multithread_GetMultithreadProtected
,
2907 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
2909 context
->ID3D11DeviceContext1_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
2910 context
->ID3D11Multithread_iface
.lpVtbl
= &d3d11_multithread_vtbl
;
2911 context
->refcount
= 1;
2913 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
2915 wined3d_private_store_init(&context
->private_store
);
2918 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
2920 wined3d_private_store_cleanup(&context
->private_store
);
2923 /* ID3D11Device methods */
2925 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device2
*iface
, REFIID iid
, void **out
)
2927 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2928 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
2931 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device2
*iface
)
2933 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2934 return IUnknown_AddRef(device
->outer_unk
);
2937 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device2
*iface
)
2939 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2940 return IUnknown_Release(device
->outer_unk
);
2943 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device2
*iface
, const D3D11_BUFFER_DESC
*desc
,
2944 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
2946 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2947 struct d3d_buffer
*object
;
2950 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2952 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
2955 *buffer
= &object
->ID3D11Buffer_iface
;
2960 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device2
*iface
,
2961 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
2963 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2964 struct d3d_texture1d
*object
;
2967 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2969 if (FAILED(hr
= d3d_texture1d_create(device
, desc
, data
, &object
)))
2972 *texture
= &object
->ID3D11Texture1D_iface
;
2977 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device2
*iface
,
2978 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2980 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2981 struct d3d_texture2d
*object
;
2984 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2986 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2989 *texture
= &object
->ID3D11Texture2D_iface
;
2994 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device2
*iface
,
2995 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2997 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2998 struct d3d_texture3d
*object
;
3001 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3003 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
3006 *texture
= &object
->ID3D11Texture3D_iface
;
3011 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device2
*iface
,
3012 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
3014 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3015 struct d3d_shader_resource_view
*object
;
3018 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3021 return E_INVALIDARG
;
3023 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
3026 *view
= &object
->ID3D11ShaderResourceView_iface
;
3031 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device2
*iface
,
3032 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
3034 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3035 struct d3d11_unordered_access_view
*object
;
3038 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3040 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
3043 *view
= &object
->ID3D11UnorderedAccessView_iface
;
3048 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device2
*iface
,
3049 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
3051 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3052 struct d3d_rendertarget_view
*object
;
3055 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3058 return E_INVALIDARG
;
3060 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
3063 *view
= &object
->ID3D11RenderTargetView_iface
;
3068 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device2
*iface
,
3069 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
3071 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3072 struct d3d_depthstencil_view
*object
;
3075 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3077 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
3080 *view
= &object
->ID3D11DepthStencilView_iface
;
3085 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device2
*iface
,
3086 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
3087 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
3089 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3090 struct d3d_input_layout
*object
;
3093 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
3094 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
3095 shader_byte_code_length
, input_layout
);
3097 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
3098 shader_byte_code
, shader_byte_code_length
, &object
)))
3101 *input_layout
= &object
->ID3D11InputLayout_iface
;
3106 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device2
*iface
, const void *byte_code
,
3107 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
3109 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3110 struct d3d_vertex_shader
*object
;
3113 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3114 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3117 FIXME("Class linkage is not implemented yet.\n");
3119 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3122 *shader
= &object
->ID3D11VertexShader_iface
;
3127 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device2
*iface
, const void *byte_code
,
3128 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3130 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3131 struct d3d_geometry_shader
*object
;
3134 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3135 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3138 FIXME("Class linkage is not implemented yet.\n");
3140 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3141 NULL
, 0, NULL
, 0, 0, &object
)))
3144 *shader
= &object
->ID3D11GeometryShader_iface
;
3149 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2
*iface
,
3150 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
3151 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
3152 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3154 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3155 struct d3d_geometry_shader
*object
;
3158 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
3159 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
3160 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
3161 rasterizer_stream
, class_linkage
, shader
);
3164 FIXME("Class linkage is not implemented yet.\n");
3166 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3167 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
3173 *shader
= &object
->ID3D11GeometryShader_iface
;
3178 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device2
*iface
, const void *byte_code
,
3179 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
3181 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3182 struct d3d_pixel_shader
*object
;
3185 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3186 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3189 FIXME("Class linkage is not implemented yet.\n");
3191 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3194 *shader
= &object
->ID3D11PixelShader_iface
;
3199 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device2
*iface
, const void *byte_code
,
3200 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
3202 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3203 struct d3d11_hull_shader
*object
;
3206 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3207 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3210 FIXME("Class linkage is not implemented yet.\n");
3212 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3215 *shader
= &object
->ID3D11HullShader_iface
;
3220 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device2
*iface
, const void *byte_code
,
3221 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
3223 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3224 struct d3d11_domain_shader
*object
;
3227 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3228 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3231 FIXME("Class linkage is not implemented yet.\n");
3233 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3236 *shader
= &object
->ID3D11DomainShader_iface
;
3241 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device2
*iface
, const void *byte_code
,
3242 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
3244 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3245 struct d3d11_compute_shader
*object
;
3248 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3249 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3252 FIXME("Class linkage is not implemented yet.\n");
3254 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3257 *shader
= &object
->ID3D11ComputeShader_iface
;
3262 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device2
*iface
,
3263 ID3D11ClassLinkage
**class_linkage
)
3265 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3266 struct d3d11_class_linkage
*object
;
3269 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3271 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3274 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3279 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device2
*iface
,
3280 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3282 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3283 struct d3d_blend_state
*object
;
3286 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3288 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3291 *blend_state
= &object
->ID3D11BlendState_iface
;
3296 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device2
*iface
,
3297 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3299 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3300 struct d3d_depthstencil_state
*object
;
3303 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3305 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3308 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3313 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device2
*iface
,
3314 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3316 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3317 struct d3d_rasterizer_state
*object
;
3320 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3322 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
3325 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
3330 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device2
*iface
,
3331 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3333 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3334 struct d3d_sampler_state
*object
;
3337 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3339 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3342 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3347 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device2
*iface
,
3348 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3350 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3351 struct d3d_query
*object
;
3354 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3356 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3361 *query
= &object
->ID3D11Query_iface
;
3365 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3369 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device2
*iface
, const D3D11_QUERY_DESC
*desc
,
3370 ID3D11Predicate
**predicate
)
3372 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3373 struct d3d_query
*object
;
3376 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3378 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3383 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3387 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3391 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3392 ID3D11Counter
**counter
)
3394 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3399 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device2
*iface
, UINT flags
,
3400 ID3D11DeviceContext
**context
)
3402 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3408 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device2
*iface
, HANDLE resource
, REFIID iid
,
3411 FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface
, resource
, debugstr_guid(iid
), out
);
3416 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device2
*iface
, DXGI_FORMAT format
,
3417 UINT
*format_support
)
3419 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3420 struct wined3d_device_creation_parameters params
;
3421 struct wined3d_adapter
*wined3d_adapter
;
3422 enum wined3d_format_id wined3d_format
;
3423 D3D_FEATURE_LEVEL feature_level
;
3424 struct wined3d
*wined3d
;
3429 enum wined3d_resource_type rtype
;
3430 unsigned int bind_flags
;
3432 D3D11_FORMAT_SUPPORT flag
;
3436 {WINED3D_RTYPE_TEXTURE_1D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE1D
},
3437 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3438 {WINED3D_RTYPE_TEXTURE_3D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3439 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, 0, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3440 {WINED3D_RTYPE_NONE
, WINED3D_BIND_DEPTH_STENCIL
, 0, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3441 {WINED3D_RTYPE_NONE
, WINED3D_BIND_UNORDERED_ACCESS
, 0, D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW
},
3442 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_WRAPANDMIP
, D3D11_FORMAT_SUPPORT_MIP
},
3443 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_GENMIPMAP
, D3D11_FORMAT_SUPPORT_MIP_AUTOGEN
},
3444 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
, D3D11_FORMAT_SUPPORT_BLENDABLE
},
3448 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3450 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3451 if (format
&& !wined3d_format
)
3453 WARN("Invalid format %#x.\n", format
);
3454 *format_support
= 0;
3458 *format_support
= 0;
3460 wined3d_mutex_lock();
3461 feature_level
= device
->feature_level
;
3462 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3463 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3464 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3465 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3467 hr
= wined3d_check_device_format(wined3d
, wined3d_adapter
, params
.device_type
,
3468 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].bind_flags
, flag_mapping
[i
].rtype
, wined3d_format
);
3469 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOMIPGEN
)
3471 if (hr
!= WINED3D_OK
)
3473 WARN("Failed to check device format support, hr %#x.\n", hr
);
3474 wined3d_mutex_unlock();
3478 *format_support
|= flag_mapping
[i
].flag
;
3480 wined3d_mutex_unlock();
3482 if (*format_support
& (D3D11_FORMAT_SUPPORT_TEXTURE1D
3483 | D3D11_FORMAT_SUPPORT_TEXTURE2D
| D3D11_FORMAT_SUPPORT_TEXTURE3D
))
3485 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_LOAD
;
3486 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
;
3487 *format_support
|= D3D11_FORMAT_SUPPORT_TEXTURECUBE
;
3489 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3490 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER
;
3492 if (*format_support
& D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
)
3494 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
3495 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
;
3497 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3498 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
;
3502 /* d3d11 requires 4 and 8 sample counts support for formats reported to
3503 * support multisample. */
3504 if (wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3505 TRUE
, WINED3D_MULTISAMPLE_4_SAMPLES
, NULL
) == WINED3D_OK
&&
3506 wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3507 TRUE
, WINED3D_MULTISAMPLE_8_SAMPLES
, NULL
) == WINED3D_OK
)
3509 *format_support
|= D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE
3510 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
3511 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
;
3517 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2
*iface
,
3518 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3520 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3521 struct wined3d_device_creation_parameters params
;
3522 struct wined3d_adapter
*wined3d_adapter
;
3523 struct wined3d
*wined3d
;
3526 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3527 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3529 if (!quality_level_count
)
3530 return E_INVALIDARG
;
3532 *quality_level_count
= 0;
3536 if (sample_count
== 1)
3538 *quality_level_count
= 1;
3541 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3544 wined3d_mutex_lock();
3545 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3546 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3547 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3548 hr
= wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
,
3549 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3550 wined3d_mutex_unlock();
3552 if (hr
== WINED3DERR_INVALIDCALL
)
3553 return E_INVALIDARG
;
3554 if (hr
== WINED3DERR_NOTAVAILABLE
)
3559 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device2
*iface
, D3D11_COUNTER_INFO
*info
)
3561 FIXME("iface %p, info %p stub!\n", iface
, info
);
3564 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3565 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3566 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3568 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3569 "units %p, units_length %p, description %p, description_length %p stub!\n",
3570 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3571 units
, units_length
, description
, description_length
);
3576 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device2
*iface
, D3D11_FEATURE feature
,
3577 void *feature_support_data
, UINT feature_support_data_size
)
3579 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3580 struct wined3d_caps wined3d_caps
;
3583 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3584 iface
, feature
, feature_support_data
, feature_support_data_size
);
3588 case D3D11_FEATURE_THREADING
:
3590 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
3591 if (feature_support_data_size
!= sizeof(*threading_data
))
3593 WARN("Invalid data size.\n");
3594 return E_INVALIDARG
;
3597 /* We lie about the threading support to make Tomb Raider 2013 and
3598 * Deus Ex: Human Revolution happy. */
3599 FIXME("Returning fake threading support data.\n");
3600 threading_data
->DriverConcurrentCreates
= TRUE
;
3601 threading_data
->DriverCommandLists
= TRUE
;
3605 case D3D11_FEATURE_DOUBLES
:
3607 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
3608 if (feature_support_data_size
!= sizeof(*doubles_data
))
3610 WARN("Invalid data size.\n");
3611 return E_INVALIDARG
;
3614 wined3d_mutex_lock();
3615 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3616 wined3d_mutex_unlock();
3619 WARN("Failed to get device caps, hr %#x.\n", hr
);
3623 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
3627 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
3629 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
3630 if (feature_support_data_size
!= sizeof(*options
))
3632 WARN("Invalid data size.\n");
3633 return E_INVALIDARG
;
3636 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
3640 case D3D11_FEATURE_D3D11_OPTIONS
:
3642 D3D11_FEATURE_DATA_D3D11_OPTIONS
*options
= feature_support_data
;
3643 if (feature_support_data_size
!= sizeof(*options
))
3645 WARN("Invalid data size.\n");
3646 return E_INVALIDARG
;
3649 FIXME("Returning fake Options support data.\n");
3650 options
->OutputMergerLogicOp
= FALSE
;
3651 options
->UAVOnlyRenderingForcedSampleCount
= FALSE
;
3652 options
->DiscardAPIsSeenByDriver
= FALSE
;
3653 options
->FlagsForUpdateAndCopySeenByDriver
= FALSE
;
3654 options
->ClearView
= FALSE
;
3655 options
->CopyWithOverlap
= FALSE
;
3656 options
->ConstantBufferPartialUpdate
= FALSE
;
3657 options
->ConstantBufferOffsetting
= FALSE
;
3658 options
->MapNoOverwriteOnDynamicConstantBuffer
= FALSE
;
3659 options
->MapNoOverwriteOnDynamicBufferSRV
= FALSE
;
3660 options
->MultisampleRTVWithForcedSampleCountOne
= FALSE
;
3661 options
->SAD4ShaderInstructions
= FALSE
;
3662 options
->ExtendedDoublesShaderInstructions
= FALSE
;
3663 options
->ExtendedResourceSharing
= FALSE
;
3667 case D3D11_FEATURE_D3D11_OPTIONS1
:
3669 D3D11_FEATURE_DATA_D3D11_OPTIONS1
*options
= feature_support_data
;
3670 if (feature_support_data_size
!= sizeof(*options
))
3672 WARN("Invalid data size.\n");
3673 return E_INVALIDARG
;
3676 FIXME("Returning fake Options1 support data.\n");
3677 options
->TiledResourcesTier
= D3D11_TILED_RESOURCES_NOT_SUPPORTED
;
3678 options
->MinMaxFiltering
= FALSE
;
3679 options
->ClearViewAlsoSupportsDepthOnlyFormats
= FALSE
;
3680 options
->MapOnDefaultBuffers
= FALSE
;
3684 case D3D11_FEATURE_D3D11_OPTIONS3
:
3686 D3D11_FEATURE_DATA_D3D11_OPTIONS3
*options
= feature_support_data
;
3687 if (feature_support_data_size
!= sizeof(*options
))
3689 WARN("Invalid data size.\n");
3690 return E_INVALIDARG
;
3693 wined3d_mutex_lock();
3694 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3695 wined3d_mutex_unlock();
3698 WARN("Failed to get device caps, hr %#x.\n", hr
);
3702 options
->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
3703 = wined3d_caps
.viewport_array_index_any_shader
;
3707 case D3D11_FEATURE_ARCHITECTURE_INFO
:
3709 D3D11_FEATURE_DATA_ARCHITECTURE_INFO
*options
= feature_support_data
;
3710 if (feature_support_data_size
!= sizeof(*options
))
3712 WARN("Invalid data size.\n");
3713 return E_INVALIDARG
;
3716 FIXME("Returning fake data architecture info.\n");
3717 options
->TileBasedDeferredRenderer
= FALSE
;
3722 FIXME("Unhandled feature %#x.\n", feature
);
3727 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
3728 UINT
*data_size
, void *data
)
3730 IDXGIDevice
*dxgi_device
;
3733 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3735 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3737 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
3738 IDXGIDevice_Release(dxgi_device
);
3743 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
3744 UINT data_size
, const void *data
)
3746 IDXGIDevice
*dxgi_device
;
3749 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3751 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3753 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
3754 IDXGIDevice_Release(dxgi_device
);
3759 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device2
*iface
, REFGUID guid
,
3760 const IUnknown
*data
)
3762 IDXGIDevice
*dxgi_device
;
3765 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
3767 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3769 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
3770 IDXGIDevice_Release(dxgi_device
);
3775 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device2
*iface
)
3777 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3779 TRACE("iface %p.\n", iface
);
3781 return device
->feature_level
;
3784 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device2
*iface
)
3786 FIXME("iface %p stub!\n", iface
);
3791 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device2
*iface
)
3793 WARN("iface %p stub!\n", iface
);
3798 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device2
*iface
,
3799 ID3D11DeviceContext
**immediate_context
)
3801 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3803 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3805 *immediate_context
= (ID3D11DeviceContext
*)&device
->immediate_context
.ID3D11DeviceContext1_iface
;
3806 ID3D11DeviceContext_AddRef(*immediate_context
);
3809 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device2
*iface
, UINT flags
)
3811 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
3816 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device2
*iface
)
3818 FIXME("iface %p stub!\n", iface
);
3823 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext1(ID3D11Device2
*iface
,
3824 ID3D11DeviceContext1
**immediate_context
)
3826 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3828 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3830 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext1_iface
;
3831 ID3D11DeviceContext1_AddRef(*immediate_context
);
3834 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext1(ID3D11Device2
*iface
, UINT flags
,
3835 ID3D11DeviceContext1
**context
)
3837 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3842 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState1(ID3D11Device2
*iface
,
3843 const D3D11_BLEND_DESC1
*desc
, ID3D11BlendState1
**state
)
3845 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
3850 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState1(ID3D11Device2
*iface
,
3851 const D3D11_RASTERIZER_DESC1
*desc
, ID3D11RasterizerState1
**state
)
3853 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
3858 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeviceContextState(ID3D11Device2
*iface
, UINT flags
,
3859 const D3D_FEATURE_LEVEL
*feature_levels
, UINT feature_levels_count
, UINT sdk_version
,
3860 REFIID emulated_interface
, D3D_FEATURE_LEVEL
*chosen_feature_level
, ID3DDeviceContextState
**state
)
3862 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3863 struct d3d_device_context_state
*state_impl
;
3865 FIXME("iface %p, flags %#x, feature_levels %p, feature_level_count %u, sdk_version %u, "
3866 "emulated_interface %s, chosen_feature_level %p, state %p semi-stub!\n", iface
, flags
, feature_levels
,
3867 feature_levels_count
, sdk_version
, debugstr_guid(emulated_interface
), chosen_feature_level
, state
);
3869 if (chosen_feature_level
)
3870 FIXME("Device context state feature level not implemented yet.\n");
3875 if (!(state_impl
= heap_alloc(sizeof(*state_impl
))))
3876 return E_OUTOFMEMORY
;
3877 d3d_device_context_state_init(state_impl
, device
, emulated_interface
);
3878 *state
= &state_impl
->ID3DDeviceContextState_iface
;
3881 device
->d3d11_only
= FALSE
;
3882 if (chosen_feature_level
) *chosen_feature_level
= ID3D11Device2_GetFeatureLevel(iface
);
3883 return state
? S_OK
: S_FALSE
;
3886 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource1(ID3D11Device2
*iface
, HANDLE handle
,
3887 REFIID iid
, void **resource
)
3889 FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface
, handle
, debugstr_guid(iid
), resource
);
3894 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResourceByName(ID3D11Device2
*iface
, const WCHAR
*name
,
3895 DWORD access
, REFIID iid
, void **resource
)
3897 FIXME("iface %p, name %s, access %#x, iid %s, resource %p stub!\n", iface
, debugstr_w(name
), access
,
3898 debugstr_guid(iid
), resource
);
3903 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext2(ID3D11Device2
*iface
,
3904 ID3D11DeviceContext2
**context
)
3906 FIXME("iface %p, context %p stub!\n", iface
, context
);
3909 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext2(ID3D11Device2
*iface
,
3910 UINT flags
, ID3D11DeviceContext2
**context
)
3912 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3917 static void STDMETHODCALLTYPE
d3d11_device_GetResourceTiling(ID3D11Device2
*iface
,
3918 ID3D11Resource
*resource
, UINT
*tile_count
, D3D11_PACKED_MIP_DESC
*mip_desc
,
3919 D3D11_TILE_SHAPE
*tile_shape
, UINT
*subresource_tiling_count
, UINT first_subresource_tiling
,
3920 D3D11_SUBRESOURCE_TILING
*subresource_tiling
)
3922 FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, "
3923 "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n",
3924 iface
, resource
, tile_count
, mip_desc
, tile_shape
,
3925 subresource_tiling_count
, first_subresource_tiling
, subresource_tiling
);
3928 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2
*iface
,
3929 DXGI_FORMAT format
, UINT sample_count
, UINT flags
, UINT
*quality_level_count
)
3931 FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n",
3932 iface
, format
, sample_count
, flags
, quality_level_count
);
3937 static const struct ID3D11Device2Vtbl d3d11_device_vtbl
=
3939 /* IUnknown methods */
3940 d3d11_device_QueryInterface
,
3941 d3d11_device_AddRef
,
3942 d3d11_device_Release
,
3943 /* ID3D11Device methods */
3944 d3d11_device_CreateBuffer
,
3945 d3d11_device_CreateTexture1D
,
3946 d3d11_device_CreateTexture2D
,
3947 d3d11_device_CreateTexture3D
,
3948 d3d11_device_CreateShaderResourceView
,
3949 d3d11_device_CreateUnorderedAccessView
,
3950 d3d11_device_CreateRenderTargetView
,
3951 d3d11_device_CreateDepthStencilView
,
3952 d3d11_device_CreateInputLayout
,
3953 d3d11_device_CreateVertexShader
,
3954 d3d11_device_CreateGeometryShader
,
3955 d3d11_device_CreateGeometryShaderWithStreamOutput
,
3956 d3d11_device_CreatePixelShader
,
3957 d3d11_device_CreateHullShader
,
3958 d3d11_device_CreateDomainShader
,
3959 d3d11_device_CreateComputeShader
,
3960 d3d11_device_CreateClassLinkage
,
3961 d3d11_device_CreateBlendState
,
3962 d3d11_device_CreateDepthStencilState
,
3963 d3d11_device_CreateRasterizerState
,
3964 d3d11_device_CreateSamplerState
,
3965 d3d11_device_CreateQuery
,
3966 d3d11_device_CreatePredicate
,
3967 d3d11_device_CreateCounter
,
3968 d3d11_device_CreateDeferredContext
,
3969 d3d11_device_OpenSharedResource
,
3970 d3d11_device_CheckFormatSupport
,
3971 d3d11_device_CheckMultisampleQualityLevels
,
3972 d3d11_device_CheckCounterInfo
,
3973 d3d11_device_CheckCounter
,
3974 d3d11_device_CheckFeatureSupport
,
3975 d3d11_device_GetPrivateData
,
3976 d3d11_device_SetPrivateData
,
3977 d3d11_device_SetPrivateDataInterface
,
3978 d3d11_device_GetFeatureLevel
,
3979 d3d11_device_GetCreationFlags
,
3980 d3d11_device_GetDeviceRemovedReason
,
3981 d3d11_device_GetImmediateContext
,
3982 d3d11_device_SetExceptionMode
,
3983 d3d11_device_GetExceptionMode
,
3984 /* ID3D11Device1 methods */
3985 d3d11_device_GetImmediateContext1
,
3986 d3d11_device_CreateDeferredContext1
,
3987 d3d11_device_CreateBlendState1
,
3988 d3d11_device_CreateRasterizerState1
,
3989 d3d11_device_CreateDeviceContextState
,
3990 d3d11_device_OpenSharedResource1
,
3991 d3d11_device_OpenSharedResourceByName
,
3992 /* ID3D11Device2 methods */
3993 d3d11_device_GetImmediateContext2
,
3994 d3d11_device_CreateDeferredContext2
,
3995 d3d11_device_GetResourceTiling
,
3996 d3d11_device_CheckMultisampleQualityLevels1
,
3999 /* Inner IUnknown methods */
4001 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
4003 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
4006 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
4008 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4010 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
4012 if (IsEqualGUID(riid
, &IID_ID3D11Device2
)
4013 || IsEqualGUID(riid
, &IID_ID3D11Device1
)
4014 || IsEqualGUID(riid
, &IID_ID3D11Device
)
4015 || IsEqualGUID(riid
, &IID_IUnknown
))
4017 *out
= &device
->ID3D11Device2_iface
;
4019 else if (!device
->d3d11_only
4020 && (IsEqualGUID(riid
, &IID_ID3D10Device1
)
4021 || IsEqualGUID(riid
, &IID_ID3D10Device
)))
4023 *out
= &device
->ID3D10Device1_iface
;
4025 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
4027 *out
= &device
->ID3D10Multithread_iface
;
4029 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
4031 *out
= &device
->IWineDXGIDeviceParent_iface
;
4035 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
4037 return E_NOINTERFACE
;
4040 IUnknown_AddRef((IUnknown
*)*out
);
4044 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
4046 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4047 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
4049 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
4054 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
4056 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4057 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
4059 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
4063 d3d11_immediate_context_destroy(&device
->immediate_context
);
4064 if (device
->wined3d_device
)
4066 wined3d_mutex_lock();
4067 wined3d_device_decref(device
->wined3d_device
);
4068 wined3d_mutex_unlock();
4070 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
4071 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
4072 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4073 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4079 /* IUnknown methods */
4081 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID iid
,
4084 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4085 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4088 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
4090 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4091 return IUnknown_AddRef(device
->outer_unk
);
4094 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
4096 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4097 return IUnknown_Release(device
->outer_unk
);
4100 /* ID3D10Device methods */
4102 static void d3d10_device_get_constant_buffers(ID3D10Device1
*iface
,
4103 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4105 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4108 wined3d_mutex_lock();
4109 for (i
= 0; i
< buffer_count
; ++i
)
4111 struct wined3d_buffer
*wined3d_buffer
;
4112 struct d3d_buffer
*buffer_impl
;
4114 if (!(wined3d_buffer
= wined3d_device_get_constant_buffer(device
->wined3d_device
,
4115 type
, start_slot
+ i
)))
4121 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4122 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4123 ID3D10Buffer_AddRef(buffers
[i
]);
4125 wined3d_mutex_unlock();
4128 static void d3d10_device_set_constant_buffers(ID3D10Device1
*iface
,
4129 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4131 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4134 wined3d_mutex_lock();
4135 for (i
= 0; i
< buffer_count
; ++i
)
4137 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4139 wined3d_device_set_constant_buffer(device
->wined3d_device
, type
, start_slot
+ i
,
4140 buffer
? buffer
->wined3d_buffer
: NULL
);
4142 wined3d_mutex_unlock();
4145 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
4146 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4148 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4149 iface
, start_slot
, buffer_count
, buffers
);
4151 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
4152 buffer_count
, buffers
);
4155 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
4156 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4158 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4161 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4162 iface
, start_slot
, view_count
, views
);
4164 wined3d_mutex_lock();
4165 for (i
= 0; i
< view_count
; ++i
)
4167 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4169 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
4170 view
? view
->wined3d_view
: NULL
);
4172 wined3d_mutex_unlock();
4175 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
4176 ID3D10PixelShader
*shader
)
4178 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4179 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
4181 TRACE("iface %p, shader %p\n", iface
, shader
);
4183 wined3d_mutex_lock();
4184 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
4185 wined3d_mutex_unlock();
4188 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
4189 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4191 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4194 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4195 iface
, start_slot
, sampler_count
, samplers
);
4197 wined3d_mutex_lock();
4198 for (i
= 0; i
< sampler_count
; ++i
)
4200 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4202 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
4203 sampler
? sampler
->wined3d_sampler
: NULL
);
4205 wined3d_mutex_unlock();
4208 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
4209 ID3D10VertexShader
*shader
)
4211 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4212 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
4214 TRACE("iface %p, shader %p\n", iface
, shader
);
4216 wined3d_mutex_lock();
4217 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
4218 wined3d_mutex_unlock();
4221 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
4222 UINT start_index_location
, INT base_vertex_location
)
4224 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4226 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
4227 iface
, index_count
, start_index_location
, base_vertex_location
);
4229 wined3d_mutex_lock();
4230 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
4231 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
4232 wined3d_mutex_unlock();
4235 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
4236 UINT start_vertex_location
)
4238 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4240 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
4241 iface
, vertex_count
, start_vertex_location
);
4243 wined3d_mutex_lock();
4244 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
4245 wined3d_mutex_unlock();
4248 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
4249 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4251 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4252 iface
, start_slot
, buffer_count
, buffers
);
4254 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
4255 buffer_count
, buffers
);
4258 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
4259 ID3D10InputLayout
*input_layout
)
4261 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4262 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
4264 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
4266 wined3d_mutex_lock();
4267 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
4268 layout
? layout
->wined3d_decl
: NULL
);
4269 wined3d_mutex_unlock();
4272 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
4273 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
4275 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4278 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
4279 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4281 wined3d_mutex_lock();
4282 for (i
= 0; i
< buffer_count
; ++i
)
4284 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4286 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
4287 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
4289 wined3d_mutex_unlock();
4292 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
4293 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
4295 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4296 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
4298 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
4299 iface
, buffer
, debug_dxgi_format(format
), offset
);
4301 wined3d_mutex_lock();
4302 wined3d_device_set_index_buffer(device
->wined3d_device
,
4303 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
4304 wined3dformat_from_dxgi_format(format
), offset
);
4305 wined3d_mutex_unlock();
4308 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
4309 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
4310 INT base_vertex_location
, UINT start_instance_location
)
4312 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4314 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
4315 "base_vertex_location %d, start_instance_location %u.\n",
4316 iface
, instance_index_count
, instance_count
, start_index_location
,
4317 base_vertex_location
, start_instance_location
);
4319 wined3d_mutex_lock();
4320 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
4321 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
4322 instance_index_count
, start_instance_location
, instance_count
);
4323 wined3d_mutex_unlock();
4326 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
4327 UINT instance_vertex_count
, UINT instance_count
,
4328 UINT start_vertex_location
, UINT start_instance_location
)
4330 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4332 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
4333 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
4334 start_vertex_location
, start_instance_location
);
4336 wined3d_mutex_lock();
4337 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
4338 instance_vertex_count
, start_instance_location
, instance_count
);
4339 wined3d_mutex_unlock();
4342 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
4343 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4345 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4346 iface
, start_slot
, buffer_count
, buffers
);
4348 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
4349 buffer_count
, buffers
);
4352 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
4354 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4355 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
4357 TRACE("iface %p, shader %p.\n", iface
, shader
);
4359 wined3d_mutex_lock();
4360 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
4361 wined3d_mutex_unlock();
4364 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
4365 D3D10_PRIMITIVE_TOPOLOGY topology
)
4367 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4369 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
4371 wined3d_mutex_lock();
4372 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
, 0);
4373 wined3d_mutex_unlock();
4376 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
4377 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4379 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4382 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4383 iface
, start_slot
, view_count
, views
);
4385 wined3d_mutex_lock();
4386 for (i
= 0; i
< view_count
; ++i
)
4388 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4390 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
4391 view
? view
->wined3d_view
: NULL
);
4393 wined3d_mutex_unlock();
4396 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
4397 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4399 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4402 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4403 iface
, start_slot
, sampler_count
, samplers
);
4405 wined3d_mutex_lock();
4406 for (i
= 0; i
< sampler_count
; ++i
)
4408 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4410 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
4411 sampler
? sampler
->wined3d_sampler
: NULL
);
4413 wined3d_mutex_unlock();
4416 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
4418 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4419 struct d3d_query
*query
;
4421 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
4423 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
4424 wined3d_mutex_lock();
4425 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
4426 wined3d_mutex_unlock();
4429 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
4430 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4432 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4435 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4436 iface
, start_slot
, view_count
, views
);
4438 wined3d_mutex_lock();
4439 for (i
= 0; i
< view_count
; ++i
)
4441 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4443 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
4444 view
? view
->wined3d_view
: NULL
);
4446 wined3d_mutex_unlock();
4449 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
4450 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4452 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4455 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4456 iface
, start_slot
, sampler_count
, samplers
);
4458 wined3d_mutex_lock();
4459 for (i
= 0; i
< sampler_count
; ++i
)
4461 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4463 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
4464 sampler
? sampler
->wined3d_sampler
: NULL
);
4466 wined3d_mutex_unlock();
4469 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
4470 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
4471 ID3D10DepthStencilView
*depth_stencil_view
)
4473 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4474 struct d3d_depthstencil_view
*dsv
;
4477 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4478 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
4480 wined3d_mutex_lock();
4481 for (i
= 0; i
< render_target_view_count
; ++i
)
4483 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
4485 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
4486 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
4488 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4490 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4493 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4494 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
4495 dsv
? dsv
->wined3d_view
: NULL
);
4496 wined3d_mutex_unlock();
4499 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
4500 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
4502 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4503 struct d3d_blend_state
*blend_state_object
;
4505 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
4506 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
4508 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
4509 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4510 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
4513 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
4514 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
4516 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4517 struct d3d_depthstencil_state
*ds_state_object
;
4519 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
4520 iface
, depth_stencil_state
, stencil_ref
);
4522 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
4523 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4524 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
4527 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
4528 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
4530 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4531 unsigned int count
, i
;
4533 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
4535 count
= min(target_count
, D3D10_SO_BUFFER_SLOT_COUNT
);
4536 wined3d_mutex_lock();
4537 for (i
= 0; i
< count
; ++i
)
4539 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
4541 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
4542 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
4545 for (i
= count
; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4547 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4549 wined3d_mutex_unlock();
4552 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
4554 FIXME("iface %p stub!\n", iface
);
4557 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
4559 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4560 struct d3d_rasterizer_state
*rasterizer_state_object
;
4562 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4564 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
4565 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4566 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
4569 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
4570 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
4572 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4573 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
4576 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
4578 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
4581 for (i
= 0; i
< viewport_count
; ++i
)
4583 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
4584 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
4585 wined3d_vp
[i
].width
= viewports
[i
].Width
;
4586 wined3d_vp
[i
].height
= viewports
[i
].Height
;
4587 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
4588 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
4591 wined3d_mutex_lock();
4592 wined3d_device_set_viewports(device
->wined3d_device
, viewport_count
, wined3d_vp
);
4593 wined3d_mutex_unlock();
4596 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
4597 UINT rect_count
, const D3D10_RECT
*rects
)
4599 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4601 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
4603 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
4606 wined3d_mutex_lock();
4607 wined3d_device_set_scissor_rects(device
->wined3d_device
, rect_count
, rects
);
4608 wined3d_mutex_unlock();
4611 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
4612 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
4613 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
4615 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4616 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4617 struct wined3d_box wined3d_src_box
;
4619 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
4620 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
4621 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
4622 src_resource
, src_subresource_idx
, src_box
);
4624 if (!dst_resource
|| !src_resource
)
4628 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
4629 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
4631 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4632 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4633 wined3d_mutex_lock();
4634 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
4635 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
4636 wined3d_mutex_unlock();
4639 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
4640 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
4642 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4643 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4645 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
4647 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4648 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4649 wined3d_mutex_lock();
4650 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
4651 wined3d_mutex_unlock();
4654 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
4655 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
4656 const void *data
, UINT row_pitch
, UINT depth_pitch
)
4658 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4659 ID3D11Resource
*d3d11_resource
;
4661 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
4662 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
4664 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
4665 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4666 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
4667 ID3D11Resource_Release(d3d11_resource
);
4670 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
4671 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
4673 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4674 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
4675 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
4678 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
4679 iface
, render_target_view
, debug_float4(color_rgba
));
4684 wined3d_mutex_lock();
4685 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4686 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
4687 ERR("Failed to clear view, hr %#x.\n", hr
);
4688 wined3d_mutex_unlock();
4691 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
4692 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
4694 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4695 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4696 DWORD wined3d_flags
;
4699 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
4700 iface
, depth_stencil_view
, flags
, depth
, stencil
);
4705 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
4707 wined3d_mutex_lock();
4708 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4709 wined3d_flags
, NULL
, depth
, stencil
)))
4710 ERR("Failed to clear view, hr %#x.\n", hr
);
4711 wined3d_mutex_unlock();
4714 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
4715 ID3D10ShaderResourceView
*view
)
4717 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D10ShaderResourceView(view
);
4719 TRACE("iface %p, view %p.\n", iface
, view
);
4721 wined3d_mutex_lock();
4722 wined3d_shader_resource_view_generate_mipmaps(srv
->wined3d_view
);
4723 wined3d_mutex_unlock();
4726 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
4727 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
4728 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
4730 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4731 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4732 enum wined3d_format_id wined3d_format
;
4734 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
4735 "src_resource %p, src_subresource_idx %u, format %s.\n",
4736 iface
, dst_resource
, dst_subresource_idx
,
4737 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
4739 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4740 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4741 wined3d_format
= wined3dformat_from_dxgi_format(format
);
4742 wined3d_mutex_lock();
4743 wined3d_device_resolve_sub_resource(device
->wined3d_device
,
4744 wined3d_dst_resource
, dst_subresource_idx
,
4745 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
4746 wined3d_mutex_unlock();
4749 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
4750 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4752 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4753 iface
, start_slot
, buffer_count
, buffers
);
4755 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, buffer_count
,
4759 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
4760 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4762 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4765 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4766 iface
, start_slot
, view_count
, views
);
4768 wined3d_mutex_lock();
4769 for (i
= 0; i
< view_count
; ++i
)
4771 struct wined3d_shader_resource_view
*wined3d_view
;
4772 struct d3d_shader_resource_view
*view_impl
;
4774 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4780 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4781 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4782 ID3D10ShaderResourceView_AddRef(views
[i
]);
4784 wined3d_mutex_unlock();
4787 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
4789 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4790 struct d3d_pixel_shader
*shader_impl
;
4791 struct wined3d_shader
*wined3d_shader
;
4793 TRACE("iface %p, shader %p.\n", iface
, shader
);
4795 wined3d_mutex_lock();
4796 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
4798 wined3d_mutex_unlock();
4803 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4804 wined3d_mutex_unlock();
4805 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
4806 ID3D10PixelShader_AddRef(*shader
);
4809 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
4810 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4812 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4815 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4816 iface
, start_slot
, sampler_count
, samplers
);
4818 wined3d_mutex_lock();
4819 for (i
= 0; i
< sampler_count
; ++i
)
4821 struct d3d_sampler_state
*sampler_impl
;
4822 struct wined3d_sampler
*wined3d_sampler
;
4824 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
4830 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4831 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4832 ID3D10SamplerState_AddRef(samplers
[i
]);
4834 wined3d_mutex_unlock();
4837 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
4839 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4840 struct d3d_vertex_shader
*shader_impl
;
4841 struct wined3d_shader
*wined3d_shader
;
4843 TRACE("iface %p, shader %p.\n", iface
, shader
);
4845 wined3d_mutex_lock();
4846 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
4848 wined3d_mutex_unlock();
4853 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4854 wined3d_mutex_unlock();
4855 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
4856 ID3D10VertexShader_AddRef(*shader
);
4859 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
4860 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4862 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4863 iface
, start_slot
, buffer_count
, buffers
);
4865 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, buffer_count
,
4869 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
4871 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4872 struct wined3d_vertex_declaration
*wined3d_declaration
;
4873 struct d3d_input_layout
*input_layout_impl
;
4875 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
4877 wined3d_mutex_lock();
4878 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
4880 wined3d_mutex_unlock();
4881 *input_layout
= NULL
;
4885 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
4886 wined3d_mutex_unlock();
4887 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
4888 ID3D10InputLayout_AddRef(*input_layout
);
4891 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
4892 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
4894 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4897 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
4898 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4900 wined3d_mutex_lock();
4901 for (i
= 0; i
< buffer_count
; ++i
)
4903 struct wined3d_buffer
*wined3d_buffer
= NULL
;
4904 struct d3d_buffer
*buffer_impl
;
4906 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
4907 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
4908 ERR("Failed to get vertex buffer.\n");
4910 if (!wined3d_buffer
)
4916 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4917 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4918 ID3D10Buffer_AddRef(buffers
[i
]);
4920 wined3d_mutex_unlock();
4923 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
4924 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
4926 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4927 enum wined3d_format_id wined3d_format
;
4928 struct wined3d_buffer
*wined3d_buffer
;
4929 struct d3d_buffer
*buffer_impl
;
4931 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
4933 wined3d_mutex_lock();
4934 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
4935 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
4936 if (!wined3d_buffer
)
4938 wined3d_mutex_unlock();
4943 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4944 wined3d_mutex_unlock();
4945 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
4946 ID3D10Buffer_AddRef(*buffer
);
4949 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
4950 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4952 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4953 iface
, start_slot
, buffer_count
, buffers
);
4955 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, buffer_count
,
4959 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
4961 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4962 struct d3d_geometry_shader
*shader_impl
;
4963 struct wined3d_shader
*wined3d_shader
;
4965 TRACE("iface %p, shader %p.\n", iface
, shader
);
4967 wined3d_mutex_lock();
4968 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
4970 wined3d_mutex_unlock();
4975 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4976 wined3d_mutex_unlock();
4977 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
4978 ID3D10GeometryShader_AddRef(*shader
);
4981 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
4982 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
4984 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4986 TRACE("iface %p, topology %p.\n", iface
, topology
);
4988 wined3d_mutex_lock();
4989 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
, NULL
);
4990 wined3d_mutex_unlock();
4993 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
4994 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4996 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4999 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5000 iface
, start_slot
, view_count
, views
);
5002 wined3d_mutex_lock();
5003 for (i
= 0; i
< view_count
; ++i
)
5005 struct wined3d_shader_resource_view
*wined3d_view
;
5006 struct d3d_shader_resource_view
*view_impl
;
5008 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
5014 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5015 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5016 ID3D10ShaderResourceView_AddRef(views
[i
]);
5018 wined3d_mutex_unlock();
5021 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
5022 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5024 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5027 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5028 iface
, start_slot
, sampler_count
, samplers
);
5030 wined3d_mutex_lock();
5031 for (i
= 0; i
< sampler_count
; ++i
)
5033 struct d3d_sampler_state
*sampler_impl
;
5034 struct wined3d_sampler
*wined3d_sampler
;
5036 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
5042 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5043 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5044 ID3D10SamplerState_AddRef(samplers
[i
]);
5046 wined3d_mutex_unlock();
5049 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
5050 ID3D10Predicate
**predicate
, BOOL
*value
)
5052 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5053 struct wined3d_query
*wined3d_predicate
;
5054 struct d3d_query
*predicate_impl
;
5056 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
5058 wined3d_mutex_lock();
5059 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
5061 wined3d_mutex_unlock();
5066 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
5067 wined3d_mutex_unlock();
5068 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
5069 ID3D10Predicate_AddRef(*predicate
);
5072 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
5073 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5075 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5078 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5079 iface
, start_slot
, view_count
, views
);
5081 wined3d_mutex_lock();
5082 for (i
= 0; i
< view_count
; ++i
)
5084 struct wined3d_shader_resource_view
*wined3d_view
;
5085 struct d3d_shader_resource_view
*view_impl
;
5087 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
5093 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5094 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5095 ID3D10ShaderResourceView_AddRef(views
[i
]);
5097 wined3d_mutex_unlock();
5100 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
5101 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5103 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5106 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5107 iface
, start_slot
, sampler_count
, samplers
);
5109 wined3d_mutex_lock();
5110 for (i
= 0; i
< sampler_count
; ++i
)
5112 struct d3d_sampler_state
*sampler_impl
;
5113 struct wined3d_sampler
*wined3d_sampler
;
5115 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
5121 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5122 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5123 ID3D10SamplerState_AddRef(samplers
[i
]);
5125 wined3d_mutex_unlock();
5128 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
5129 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
5131 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5132 struct wined3d_rendertarget_view
*wined3d_view
;
5134 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
5135 iface
, view_count
, render_target_views
, depth_stencil_view
);
5137 wined3d_mutex_lock();
5138 if (render_target_views
)
5140 struct d3d_rendertarget_view
*view_impl
;
5143 for (i
= 0; i
< view_count
; ++i
)
5145 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
5146 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5148 render_target_views
[i
] = NULL
;
5152 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
5153 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
5157 if (depth_stencil_view
)
5159 struct d3d_depthstencil_view
*view_impl
;
5161 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
5162 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5164 *depth_stencil_view
= NULL
;
5168 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
5169 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
5172 wined3d_mutex_unlock();
5175 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
5176 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
5178 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5179 ID3D11BlendState
*d3d11_blend_state
;
5181 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
5182 iface
, blend_state
, blend_factor
, sample_mask
);
5184 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5185 &d3d11_blend_state
, blend_factor
, sample_mask
);
5187 if (d3d11_blend_state
)
5188 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
5190 *blend_state
= NULL
;
5193 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
5194 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
5196 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5197 ID3D11DepthStencilState
*d3d11_iface
;
5199 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
5200 iface
, depth_stencil_state
, stencil_ref
);
5202 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5203 &d3d11_iface
, stencil_ref
);
5206 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
5208 *depth_stencil_state
= NULL
;
5211 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
5212 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
5214 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5217 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
5218 iface
, buffer_count
, buffers
, offsets
);
5220 wined3d_mutex_lock();
5221 for (i
= 0; i
< buffer_count
; ++i
)
5223 struct wined3d_buffer
*wined3d_buffer
;
5224 struct d3d_buffer
*buffer_impl
;
5226 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
5232 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5233 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5234 ID3D10Buffer_AddRef(buffers
[i
]);
5236 wined3d_mutex_unlock();
5239 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
5241 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5242 struct d3d_rasterizer_state
*rasterizer_state_impl
;
5243 struct wined3d_rasterizer_state
*wined3d_state
;
5245 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5247 wined3d_mutex_lock();
5248 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
5250 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
5251 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
5255 *rasterizer_state
= NULL
;
5257 wined3d_mutex_unlock();
5260 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
5261 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
5263 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5264 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5265 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
5267 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
5269 if (!viewport_count
)
5272 wined3d_mutex_lock();
5273 wined3d_device_get_viewports(device
->wined3d_device
, &actual_count
, viewports
? wined3d_vp
: NULL
);
5274 wined3d_mutex_unlock();
5278 *viewport_count
= actual_count
;
5282 if (*viewport_count
> actual_count
)
5283 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
5285 *viewport_count
= min(actual_count
, *viewport_count
);
5286 for (i
= 0; i
< *viewport_count
; ++i
)
5288 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
5289 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
5290 viewports
[i
].Width
= wined3d_vp
[i
].width
;
5291 viewports
[i
].Height
= wined3d_vp
[i
].height
;
5292 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
5293 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
5297 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
5299 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5300 unsigned int actual_count
;
5302 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
5307 actual_count
= *rect_count
;
5309 wined3d_mutex_lock();
5310 wined3d_device_get_scissor_rects(device
->wined3d_device
, &actual_count
, rects
);
5311 wined3d_mutex_unlock();
5315 *rect_count
= actual_count
;
5319 if (*rect_count
> actual_count
)
5320 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
5323 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
5325 TRACE("iface %p.\n", iface
);
5327 /* In the current implementation the device is never removed, so we can
5328 * just return S_OK here. */
5333 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
5335 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
5340 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
5342 FIXME("iface %p stub!\n", iface
);
5347 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
5348 REFGUID guid
, UINT
*data_size
, void *data
)
5350 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5352 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5354 return d3d11_device_GetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5357 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
5358 REFGUID guid
, UINT data_size
, const void *data
)
5360 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5362 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5364 return d3d11_device_SetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5367 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
5368 REFGUID guid
, const IUnknown
*data
)
5370 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5372 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
5374 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device2_iface
, guid
, data
);
5377 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
5379 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5381 TRACE("iface %p.\n", iface
);
5383 d3d11_immediate_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
5386 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
5388 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5390 TRACE("iface %p.\n", iface
);
5392 wined3d_mutex_lock();
5393 wined3d_device_flush(device
->wined3d_device
);
5394 wined3d_mutex_unlock();
5397 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
5398 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
5400 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5401 D3D11_BUFFER_DESC d3d11_desc
;
5402 struct d3d_buffer
*object
;
5405 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
5407 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
5408 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5409 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5410 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5411 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5412 d3d11_desc
.StructureByteStride
= 0;
5414 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5417 *buffer
= &object
->ID3D10Buffer_iface
;
5422 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
5423 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
5425 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5426 D3D11_TEXTURE1D_DESC d3d11_desc
;
5427 struct d3d_texture1d
*object
;
5430 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5432 d3d11_desc
.Width
= desc
->Width
;
5433 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5434 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5435 d3d11_desc
.Format
= desc
->Format
;
5436 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5437 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5438 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5439 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5441 if (FAILED(hr
= d3d_texture1d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5444 *texture
= &object
->ID3D10Texture1D_iface
;
5449 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
5450 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5451 ID3D10Texture2D
**texture
)
5453 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5454 D3D11_TEXTURE2D_DESC d3d11_desc
;
5455 struct d3d_texture2d
*object
;
5458 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5460 d3d11_desc
.Width
= desc
->Width
;
5461 d3d11_desc
.Height
= desc
->Height
;
5462 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5463 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5464 d3d11_desc
.Format
= desc
->Format
;
5465 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
5466 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5467 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5468 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5469 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5471 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5474 *texture
= &object
->ID3D10Texture2D_iface
;
5479 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
5480 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5481 ID3D10Texture3D
**texture
)
5483 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5484 D3D11_TEXTURE3D_DESC d3d11_desc
;
5485 struct d3d_texture3d
*object
;
5488 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5490 d3d11_desc
.Width
= desc
->Width
;
5491 d3d11_desc
.Height
= desc
->Height
;
5492 d3d11_desc
.Depth
= desc
->Depth
;
5493 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5494 d3d11_desc
.Format
= desc
->Format
;
5495 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5496 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5497 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5498 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5500 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5503 *texture
= &object
->ID3D10Texture3D_iface
;
5508 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
5509 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
5511 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5512 struct d3d_shader_resource_view
*object
;
5513 ID3D11Resource
*d3d11_resource
;
5516 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5519 return E_INVALIDARG
;
5521 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5523 ERR("Resource does not implement ID3D11Resource.\n");
5527 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
5529 ID3D11Resource_Release(d3d11_resource
);
5533 *view
= &object
->ID3D10ShaderResourceView1_iface
;
5538 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
5539 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
5541 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5543 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
5544 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
5547 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
5548 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
5550 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5551 struct d3d_rendertarget_view
*object
;
5552 ID3D11Resource
*d3d11_resource
;
5555 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5558 return E_INVALIDARG
;
5560 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5562 ERR("Resource does not implement ID3D11Resource.\n");
5566 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
5567 ID3D11Resource_Release(d3d11_resource
);
5571 *view
= &object
->ID3D10RenderTargetView_iface
;
5576 static D3D11_DSV_DIMENSION
d3d11_dsv_dimension_from_d3d10(D3D10_DSV_DIMENSION dim
)
5578 return (D3D11_DSV_DIMENSION
)dim
;
5581 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
5582 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
5584 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5585 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
5586 struct d3d_depthstencil_view
*object
;
5587 ID3D11Resource
*d3d11_resource
;
5590 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5594 d3d11_desc
.Format
= desc
->Format
;
5595 d3d11_desc
.ViewDimension
= d3d11_dsv_dimension_from_d3d10(desc
->ViewDimension
);
5596 d3d11_desc
.Flags
= 0;
5597 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
5600 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5602 ERR("Resource does not implement ID3D11Resource.\n");
5606 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
5607 ID3D11Resource_Release(d3d11_resource
);
5611 *view
= &object
->ID3D10DepthStencilView_iface
;
5616 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
5617 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
5618 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
5619 ID3D10InputLayout
**input_layout
)
5621 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5622 struct d3d_input_layout
*object
;
5625 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
5626 "shader_byte_code_length %lu, input_layout %p\n",
5627 iface
, element_descs
, element_count
, shader_byte_code
,
5628 shader_byte_code_length
, input_layout
);
5630 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
5631 shader_byte_code
, shader_byte_code_length
, &object
)))
5634 *input_layout
= &object
->ID3D10InputLayout_iface
;
5639 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
5640 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
5642 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5643 struct d3d_vertex_shader
*object
;
5646 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5647 iface
, byte_code
, byte_code_length
, shader
);
5649 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5652 *shader
= &object
->ID3D10VertexShader_iface
;
5657 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
5658 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
5660 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5661 struct d3d_geometry_shader
*object
;
5664 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5665 iface
, byte_code
, byte_code_length
, shader
);
5667 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5668 NULL
, 0, NULL
, 0, 0, &object
)))
5671 *shader
= &object
->ID3D10GeometryShader_iface
;
5676 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
5677 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
5678 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
5680 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5681 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
5682 struct d3d_geometry_shader
*object
;
5683 unsigned int i
, stride_count
= 1;
5686 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
5687 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
5688 iface
, byte_code
, byte_code_length
, output_stream_decls
,
5689 output_stream_decl_count
, output_stream_stride
, shader
);
5691 if (!output_stream_decl_count
&& output_stream_stride
)
5693 WARN("Stride must be 0 when declaration entry count is 0.\n");
5695 return E_INVALIDARG
;
5698 if (output_stream_decl_count
5699 && !(so_entries
= heap_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
5701 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
5703 return E_OUTOFMEMORY
;
5706 for (i
= 0; i
< output_stream_decl_count
; ++i
)
5708 so_entries
[i
].Stream
= 0;
5709 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
5710 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
5711 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
5712 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
5713 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
5715 if (output_stream_decls
[i
].OutputSlot
)
5718 if (output_stream_stride
)
5720 WARN("Stride must be 0 when multiple output slots are used.\n");
5721 heap_free(so_entries
);
5723 return E_INVALIDARG
;
5728 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5729 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
5730 heap_free(so_entries
);
5737 *shader
= &object
->ID3D10GeometryShader_iface
;
5742 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
5743 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
5745 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5746 struct d3d_pixel_shader
*object
;
5749 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5750 iface
, byte_code
, byte_code_length
, shader
);
5752 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5755 *shader
= &object
->ID3D10PixelShader_iface
;
5760 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
5761 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
5763 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5764 struct d3d_blend_state
*object
;
5767 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5769 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
5772 *blend_state
= &object
->ID3D10BlendState1_iface
;
5777 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
5778 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
5780 D3D10_BLEND_DESC1 d3d10_1_desc
;
5783 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5786 return E_INVALIDARG
;
5788 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
5789 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
5790 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
5792 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
5793 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
5794 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
5797 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5799 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
5800 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
5801 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
5802 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
5803 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
5804 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
5805 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
5806 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
5809 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
5812 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
5813 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
5815 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5816 struct d3d_depthstencil_state
*object
;
5819 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
5821 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
5824 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
5829 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
5830 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
5832 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5833 struct d3d_rasterizer_state
*object
;
5836 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
5838 if (FAILED(hr
= d3d_rasterizer_state_create(device
, (const D3D11_RASTERIZER_DESC
*)desc
, &object
)))
5841 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
5846 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
5847 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
5849 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5850 struct d3d_sampler_state
*object
;
5853 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
5855 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
5858 *sampler_state
= &object
->ID3D10SamplerState_iface
;
5863 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
5864 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
5866 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5867 struct d3d_query
*object
;
5870 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
5872 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
5877 *query
= &object
->ID3D10Query_iface
;
5881 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5885 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
5886 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
5888 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5889 struct d3d_query
*object
;
5892 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
5894 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
5899 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
5903 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5907 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
5908 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
5910 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
5915 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
5916 DXGI_FORMAT format
, UINT
*format_support
)
5918 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5920 TRACE("iface %p, format %s, format_support %p.\n",
5921 iface
, debug_dxgi_format(format
), format_support
);
5923 return d3d11_device_CheckFormatSupport(&device
->ID3D11Device2_iface
, format
, format_support
);
5926 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
5927 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
5929 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5931 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
5932 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
5934 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device2_iface
, format
,
5935 sample_count
, quality_level_count
);
5938 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
5940 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
5943 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
5944 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
5945 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
5947 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
5948 "units %p, units_length %p, description %p, description_length %p stub!\n",
5949 iface
, desc
, type
, active_counters
, name
, name_length
,
5950 units
, units_length
, description
, description_length
);
5955 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
5957 FIXME("iface %p stub!\n", iface
);
5962 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
5963 HANDLE resource_handle
, REFIID guid
, void **resource
)
5965 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
5966 iface
, resource_handle
, debugstr_guid(guid
), resource
);
5971 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
5973 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
5976 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
5978 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
5981 static D3D10_FEATURE_LEVEL1
d3d10_feature_level1_from_d3d_feature_level(D3D_FEATURE_LEVEL level
)
5983 return (D3D10_FEATURE_LEVEL1
)level
;
5986 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
5988 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5990 TRACE("iface %p.\n", iface
);
5992 return d3d10_feature_level1_from_d3d_feature_level(device
->feature_level
);
5995 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
5997 /* IUnknown methods */
5998 d3d10_device_QueryInterface
,
5999 d3d10_device_AddRef
,
6000 d3d10_device_Release
,
6001 /* ID3D10Device methods */
6002 d3d10_device_VSSetConstantBuffers
,
6003 d3d10_device_PSSetShaderResources
,
6004 d3d10_device_PSSetShader
,
6005 d3d10_device_PSSetSamplers
,
6006 d3d10_device_VSSetShader
,
6007 d3d10_device_DrawIndexed
,
6009 d3d10_device_PSSetConstantBuffers
,
6010 d3d10_device_IASetInputLayout
,
6011 d3d10_device_IASetVertexBuffers
,
6012 d3d10_device_IASetIndexBuffer
,
6013 d3d10_device_DrawIndexedInstanced
,
6014 d3d10_device_DrawInstanced
,
6015 d3d10_device_GSSetConstantBuffers
,
6016 d3d10_device_GSSetShader
,
6017 d3d10_device_IASetPrimitiveTopology
,
6018 d3d10_device_VSSetShaderResources
,
6019 d3d10_device_VSSetSamplers
,
6020 d3d10_device_SetPredication
,
6021 d3d10_device_GSSetShaderResources
,
6022 d3d10_device_GSSetSamplers
,
6023 d3d10_device_OMSetRenderTargets
,
6024 d3d10_device_OMSetBlendState
,
6025 d3d10_device_OMSetDepthStencilState
,
6026 d3d10_device_SOSetTargets
,
6027 d3d10_device_DrawAuto
,
6028 d3d10_device_RSSetState
,
6029 d3d10_device_RSSetViewports
,
6030 d3d10_device_RSSetScissorRects
,
6031 d3d10_device_CopySubresourceRegion
,
6032 d3d10_device_CopyResource
,
6033 d3d10_device_UpdateSubresource
,
6034 d3d10_device_ClearRenderTargetView
,
6035 d3d10_device_ClearDepthStencilView
,
6036 d3d10_device_GenerateMips
,
6037 d3d10_device_ResolveSubresource
,
6038 d3d10_device_VSGetConstantBuffers
,
6039 d3d10_device_PSGetShaderResources
,
6040 d3d10_device_PSGetShader
,
6041 d3d10_device_PSGetSamplers
,
6042 d3d10_device_VSGetShader
,
6043 d3d10_device_PSGetConstantBuffers
,
6044 d3d10_device_IAGetInputLayout
,
6045 d3d10_device_IAGetVertexBuffers
,
6046 d3d10_device_IAGetIndexBuffer
,
6047 d3d10_device_GSGetConstantBuffers
,
6048 d3d10_device_GSGetShader
,
6049 d3d10_device_IAGetPrimitiveTopology
,
6050 d3d10_device_VSGetShaderResources
,
6051 d3d10_device_VSGetSamplers
,
6052 d3d10_device_GetPredication
,
6053 d3d10_device_GSGetShaderResources
,
6054 d3d10_device_GSGetSamplers
,
6055 d3d10_device_OMGetRenderTargets
,
6056 d3d10_device_OMGetBlendState
,
6057 d3d10_device_OMGetDepthStencilState
,
6058 d3d10_device_SOGetTargets
,
6059 d3d10_device_RSGetState
,
6060 d3d10_device_RSGetViewports
,
6061 d3d10_device_RSGetScissorRects
,
6062 d3d10_device_GetDeviceRemovedReason
,
6063 d3d10_device_SetExceptionMode
,
6064 d3d10_device_GetExceptionMode
,
6065 d3d10_device_GetPrivateData
,
6066 d3d10_device_SetPrivateData
,
6067 d3d10_device_SetPrivateDataInterface
,
6068 d3d10_device_ClearState
,
6070 d3d10_device_CreateBuffer
,
6071 d3d10_device_CreateTexture1D
,
6072 d3d10_device_CreateTexture2D
,
6073 d3d10_device_CreateTexture3D
,
6074 d3d10_device_CreateShaderResourceView
,
6075 d3d10_device_CreateRenderTargetView
,
6076 d3d10_device_CreateDepthStencilView
,
6077 d3d10_device_CreateInputLayout
,
6078 d3d10_device_CreateVertexShader
,
6079 d3d10_device_CreateGeometryShader
,
6080 d3d10_device_CreateGeometryShaderWithStreamOutput
,
6081 d3d10_device_CreatePixelShader
,
6082 d3d10_device_CreateBlendState
,
6083 d3d10_device_CreateDepthStencilState
,
6084 d3d10_device_CreateRasterizerState
,
6085 d3d10_device_CreateSamplerState
,
6086 d3d10_device_CreateQuery
,
6087 d3d10_device_CreatePredicate
,
6088 d3d10_device_CreateCounter
,
6089 d3d10_device_CheckFormatSupport
,
6090 d3d10_device_CheckMultisampleQualityLevels
,
6091 d3d10_device_CheckCounterInfo
,
6092 d3d10_device_CheckCounter
,
6093 d3d10_device_GetCreationFlags
,
6094 d3d10_device_OpenSharedResource
,
6095 d3d10_device_SetTextFilterSize
,
6096 d3d10_device_GetTextFilterSize
,
6097 d3d10_device_CreateShaderResourceView1
,
6098 d3d10_device_CreateBlendState1
,
6099 d3d10_device_GetFeatureLevel
,
6102 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
6104 /* IUnknown methods */
6105 d3d_device_inner_QueryInterface
,
6106 d3d_device_inner_AddRef
,
6107 d3d_device_inner_Release
,
6110 /* ID3D10Multithread methods */
6112 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
6114 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
6117 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
6119 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6121 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
6123 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6126 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
6128 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6130 TRACE("iface %p.\n", iface
);
6132 return IUnknown_AddRef(device
->outer_unk
);
6135 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
6137 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6139 TRACE("iface %p.\n", iface
);
6141 return IUnknown_Release(device
->outer_unk
);
6144 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
6146 TRACE("iface %p.\n", iface
);
6148 wined3d_mutex_lock();
6151 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
6153 TRACE("iface %p.\n", iface
);
6155 wined3d_mutex_unlock();
6158 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL enable
)
6160 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
6165 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
6167 FIXME("iface %p stub!\n", iface
);
6172 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
6174 d3d10_multithread_QueryInterface
,
6175 d3d10_multithread_AddRef
,
6176 d3d10_multithread_Release
,
6177 d3d10_multithread_Enter
,
6178 d3d10_multithread_Leave
,
6179 d3d10_multithread_SetMultithreadProtected
,
6180 d3d10_multithread_GetMultithreadProtected
,
6183 /* IWineDXGIDeviceParent IUnknown methods */
6185 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
6187 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
6190 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
6191 REFIID iid
, void **out
)
6193 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6194 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6197 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
6199 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6200 return IUnknown_AddRef(device
->outer_unk
);
6203 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
6205 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6206 return IUnknown_Release(device
->outer_unk
);
6209 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
6210 IWineDXGIDeviceParent
*iface
)
6212 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6213 return &device
->device_parent
;
6216 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
6218 /* IUnknown methods */
6219 dxgi_device_parent_QueryInterface
,
6220 dxgi_device_parent_AddRef
,
6221 dxgi_device_parent_Release
,
6222 /* IWineDXGIDeviceParent methods */
6223 dxgi_device_parent_get_wined3d_device_parent
,
6226 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
6228 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
6231 static D3D_FEATURE_LEVEL
d3d_feature_level_from_wined3d(enum wined3d_feature_level level
)
6233 return (D3D_FEATURE_LEVEL
)level
;
6236 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
6237 struct wined3d_device
*wined3d_device
)
6239 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6241 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
6243 wined3d_device_incref(wined3d_device
);
6244 device
->wined3d_device
= wined3d_device
;
6246 device
->feature_level
= d3d_feature_level_from_wined3d(wined3d_device_get_feature_level(wined3d_device
));
6249 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
6251 TRACE("device_parent %p.\n", device_parent
);
6254 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
6256 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
6259 static HRESULT CDECL
device_parent_texture_sub_resource_created(struct wined3d_device_parent
*device_parent
,
6260 enum wined3d_resource_type type
, struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
,
6261 void **parent
, const struct wined3d_parent_ops
**parent_ops
)
6263 TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
6264 device_parent
, type
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
6267 *parent_ops
= &d3d_null_wined3d_parent_ops
;
6272 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
6273 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
6274 struct wined3d_texture
**wined3d_texture
)
6276 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6277 struct d3d_texture2d
*texture
;
6278 ID3D11Texture2D
*texture_iface
;
6279 D3D11_TEXTURE2D_DESC desc
;
6282 TRACE("device_parent %p, container_parent %p, wined3d_desc %p, texture_flags %#x, wined3d_texture %p.\n",
6283 device_parent
, container_parent
, wined3d_desc
, texture_flags
, wined3d_texture
);
6285 desc
.Width
= wined3d_desc
->width
;
6286 desc
.Height
= wined3d_desc
->height
;
6289 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
6290 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
6291 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
6292 desc
.Usage
= D3D11_USAGE_DEFAULT
;
6293 desc
.BindFlags
= d3d11_bind_flags_from_wined3d(wined3d_desc
->bind_flags
);
6294 desc
.CPUAccessFlags
= 0;
6297 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
6299 desc
.MiscFlags
|= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
6300 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
6304 FIXME("Unhandled flags %#x.\n", texture_flags
);
6306 if (FAILED(hr
= d3d11_device_CreateTexture2D(&device
->ID3D11Device2_iface
,
6307 &desc
, NULL
, &texture_iface
)))
6309 WARN("Failed to create 2D texture, hr %#x.\n", hr
);
6313 texture
= impl_from_ID3D11Texture2D(texture_iface
);
6315 *wined3d_texture
= texture
->wined3d_texture
;
6316 wined3d_texture_incref(*wined3d_texture
);
6317 ID3D11Texture2D_Release(&texture
->ID3D11Texture2D_iface
);
6322 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
6324 device_parent_wined3d_device_created
,
6325 device_parent_mode_changed
,
6326 device_parent_activate
,
6327 device_parent_texture_sub_resource_created
,
6328 device_parent_create_swapchain_texture
,
6331 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6333 const D3D11_SAMPLER_DESC
*ka
= key
;
6334 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
6336 return memcmp(ka
, kb
, sizeof(*ka
));
6339 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6341 const D3D11_BLEND_DESC
*ka
= key
;
6342 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
6344 return memcmp(ka
, kb
, sizeof(*ka
));
6347 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6349 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
6350 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
6351 const struct d3d_depthstencil_state
, entry
)->desc
;
6353 return memcmp(ka
, kb
, sizeof(*ka
));
6356 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6358 const D3D11_RASTERIZER_DESC
*ka
= key
;
6359 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
6361 return memcmp(ka
, kb
, sizeof(*ka
));
6364 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
6366 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
6367 device
->ID3D11Device2_iface
.lpVtbl
= &d3d11_device_vtbl
;
6368 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
6369 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
6370 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
6371 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
6372 device
->refcount
= 1;
6373 /* COM aggregation always takes place */
6374 device
->outer_unk
= outer_unknown
;
6375 device
->d3d11_only
= FALSE
;
6377 d3d11_immediate_context_init(&device
->immediate_context
, device
);
6378 ID3D11DeviceContext1_Release(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
6380 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
6381 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
6382 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
6383 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);