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 #define WINE_NO_NAMELESS_EXTENSION
22 #include "d3d11_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
26 static BOOL
d3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
)
28 SIZE_T max_capacity
, new_capacity
;
31 if (count
<= *capacity
)
34 max_capacity
= ~(SIZE_T
)0 / size
;
35 if (count
> max_capacity
)
38 new_capacity
= max(1, *capacity
);
39 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
41 if (new_capacity
< count
)
44 if (!(new_elements
= realloc(*elements
, new_capacity
* size
)))
47 *elements
= new_elements
;
48 *capacity
= new_capacity
;
52 static void STDMETHODCALLTYPE
d3d_null_wined3d_object_destroyed(void *parent
) {}
54 static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops
=
56 d3d_null_wined3d_object_destroyed
,
59 static inline BOOL
d3d_device_is_d3d10_active(struct d3d_device
*device
)
62 || IsEqualGUID(&device
->state
->emulated_interface
, &IID_ID3D10Device
)
63 || IsEqualGUID(&device
->state
->emulated_interface
, &IID_ID3D10Device1
);
66 static D3D_FEATURE_LEVEL
d3d_feature_level_from_wined3d(enum wined3d_feature_level level
)
68 return (D3D_FEATURE_LEVEL
)level
;
71 /* ID3DDeviceContextState methods */
73 static inline struct d3d_device_context_state
*impl_from_ID3DDeviceContextState(ID3DDeviceContextState
*iface
)
75 return CONTAINING_RECORD(iface
, struct d3d_device_context_state
, ID3DDeviceContextState_iface
);
78 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_QueryInterface(ID3DDeviceContextState
*iface
,
79 REFIID iid
, void **out
)
81 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
83 if (IsEqualGUID(iid
, &IID_ID3DDeviceContextState
)
84 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
85 || IsEqualGUID(iid
, &IID_IUnknown
))
87 ID3DDeviceContextState_AddRef(iface
);
92 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
98 static ULONG
d3d_device_context_state_private_addref(struct d3d_device_context_state
*state
)
100 ULONG refcount
= InterlockedIncrement(&state
->private_refcount
);
102 TRACE("%p increasing private refcount to %lu.\n", state
, refcount
);
107 static ULONG STDMETHODCALLTYPE
d3d_device_context_state_AddRef(ID3DDeviceContextState
*iface
)
109 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
110 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
112 TRACE("%p increasing refcount to %lu.\n", state
, refcount
);
116 d3d_device_context_state_private_addref(state
);
117 ID3D11Device2_AddRef(state
->device
);
123 static void d3d_device_remove_context_state(struct d3d_device
*device
, struct d3d_device_context_state
*state
)
127 for (i
= 0; i
< device
->context_state_count
; ++i
)
129 if (device
->context_states
[i
] != state
)
132 if (i
!= device
->context_state_count
- 1)
133 device
->context_states
[i
] = device
->context_states
[device
->context_state_count
- 1];
134 --device
->context_state_count
;
139 static void d3d_device_context_state_private_release(struct d3d_device_context_state
*state
)
141 ULONG refcount
= InterlockedDecrement(&state
->private_refcount
);
142 struct d3d_device_context_state_entry
*entry
;
143 struct d3d_device
*device
;
146 TRACE("%p decreasing private refcount to %lu.\n", state
, refcount
);
150 wined3d_private_store_cleanup(&state
->private_store
);
151 for (i
= 0; i
< state
->entry_count
; ++i
)
153 entry
= &state
->entries
[i
];
154 device
= entry
->device
;
156 if (entry
->wined3d_state
!= wined3d_device_get_state(device
->wined3d_device
))
157 wined3d_state_destroy(entry
->wined3d_state
);
159 d3d_device_remove_context_state(device
, state
);
161 free(state
->entries
);
162 wined3d_device_decref(state
->wined3d_device
);
167 static ULONG STDMETHODCALLTYPE
d3d_device_context_state_Release(ID3DDeviceContextState
*iface
)
169 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
170 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
172 TRACE("%p decreasing refcount to %lu.\n", state
, refcount
);
176 ID3D11Device2_Release(state
->device
);
177 d3d_device_context_state_private_release(state
);
183 static void STDMETHODCALLTYPE
d3d_device_context_state_GetDevice(ID3DDeviceContextState
*iface
, ID3D11Device
**device
)
185 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
187 TRACE("iface %p, device %p.\n", iface
, device
);
189 *device
= (ID3D11Device
*)state
->device
;
190 ID3D11Device_AddRef(*device
);
193 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_GetPrivateData(ID3DDeviceContextState
*iface
, REFGUID guid
,
194 UINT
*data_size
, void *data
)
196 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
198 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
200 return d3d_get_private_data(&state
->private_store
, guid
, data_size
, data
);
203 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_SetPrivateData(ID3DDeviceContextState
*iface
, REFGUID guid
,
204 UINT data_size
, const void *data
)
206 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
208 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
210 return d3d_set_private_data(&state
->private_store
, guid
, data_size
, data
);
213 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_SetPrivateDataInterface(ID3DDeviceContextState
*iface
,
214 REFGUID guid
, const IUnknown
*data
)
216 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
218 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
220 return d3d_set_private_data_interface(&state
->private_store
, guid
, data
);
223 static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl
=
225 /* IUnknown methods */
226 d3d_device_context_state_QueryInterface
,
227 d3d_device_context_state_AddRef
,
228 d3d_device_context_state_Release
,
229 /* ID3D11DeviceChild methods */
230 d3d_device_context_state_GetDevice
,
231 d3d_device_context_state_GetPrivateData
,
232 d3d_device_context_state_SetPrivateData
,
233 d3d_device_context_state_SetPrivateDataInterface
,
234 /* ID3DDeviceContextState methods */
237 static struct d3d_device_context_state_entry
*d3d_device_context_state_get_entry(
238 struct d3d_device_context_state
*state
, struct d3d_device
*device
)
242 for (i
= 0; i
< state
->entry_count
; ++i
)
244 if (state
->entries
[i
].device
== device
)
245 return &state
->entries
[i
];
251 static BOOL
d3d_device_context_state_add_entry(struct d3d_device_context_state
*state
,
252 struct d3d_device
*device
, struct wined3d_state
*wined3d_state
)
254 struct d3d_device_context_state_entry
*entry
;
256 if (!d3d_array_reserve((void **)&state
->entries
, &state
->entries_size
,
257 state
->entry_count
+ 1, sizeof(*state
->entries
)))
260 if (!d3d_array_reserve((void **)&device
->context_states
, &device
->context_states_size
,
261 device
->context_state_count
+ 1, sizeof(*device
->context_states
)))
264 entry
= &state
->entries
[state
->entry_count
++];
265 entry
->device
= device
;
266 entry
->wined3d_state
= wined3d_state
;
268 device
->context_states
[device
->context_state_count
++] = state
;
273 static void d3d_device_context_state_remove_entry(struct d3d_device_context_state
*state
, struct d3d_device
*device
)
275 struct d3d_device_context_state_entry
*entry
;
278 for (i
= 0; i
< state
->entry_count
; ++i
)
280 entry
= &state
->entries
[i
];
281 if (entry
->device
!= device
)
284 if (entry
->wined3d_state
!= wined3d_device_get_state(device
->wined3d_device
))
285 wined3d_state_destroy(entry
->wined3d_state
);
287 if (i
!= state
->entry_count
)
288 state
->entries
[i
] = state
->entries
[state
->entry_count
- 1];
289 --state
->entry_count
;
295 static struct wined3d_state
*d3d_device_context_state_get_wined3d_state(struct d3d_device_context_state
*state
,
296 struct d3d_device
*device
)
298 struct d3d_device_context_state_entry
*entry
;
299 struct wined3d_state
*wined3d_state
;
301 if ((entry
= d3d_device_context_state_get_entry(state
, device
)))
302 return entry
->wined3d_state
;
304 if (FAILED(wined3d_state_create(device
->wined3d_device
,
305 (enum wined3d_feature_level
*)&state
->feature_level
, 1, &wined3d_state
)))
308 if (!d3d_device_context_state_add_entry(state
, device
, wined3d_state
))
310 wined3d_state_destroy(wined3d_state
);
314 return wined3d_state
;
317 static void d3d_device_context_state_init(struct d3d_device_context_state
*state
,
318 struct d3d_device
*device
, D3D_FEATURE_LEVEL feature_level
, REFIID emulated_interface
)
320 state
->ID3DDeviceContextState_iface
.lpVtbl
= &d3d_device_context_state_vtbl
;
321 state
->refcount
= state
->private_refcount
= 0;
323 wined3d_private_store_init(&state
->private_store
);
325 state
->feature_level
= feature_level
;
326 state
->emulated_interface
= *emulated_interface
;
327 wined3d_device_incref(state
->wined3d_device
= device
->wined3d_device
);
328 state
->device
= &device
->ID3D11Device2_iface
;
330 d3d_device_context_state_AddRef(&state
->ID3DDeviceContextState_iface
);
333 /* ID3D11CommandList methods */
335 static inline struct d3d11_command_list
*impl_from_ID3D11CommandList(ID3D11CommandList
*iface
)
337 return CONTAINING_RECORD(iface
, struct d3d11_command_list
, ID3D11CommandList_iface
);
340 static HRESULT STDMETHODCALLTYPE
d3d11_command_list_QueryInterface(ID3D11CommandList
*iface
, REFIID iid
, void **out
)
342 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
344 if (IsEqualGUID(iid
, &IID_ID3D11CommandList
)
345 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
346 || IsEqualGUID(iid
, &IID_IUnknown
))
348 ID3D11CommandList_AddRef(iface
);
353 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
356 return E_NOINTERFACE
;
359 static ULONG STDMETHODCALLTYPE
d3d11_command_list_AddRef(ID3D11CommandList
*iface
)
361 struct d3d11_command_list
*list
= impl_from_ID3D11CommandList(iface
);
362 ULONG refcount
= InterlockedIncrement(&list
->refcount
);
364 TRACE("%p increasing refcount to %lu.\n", list
, refcount
);
369 static ULONG STDMETHODCALLTYPE
d3d11_command_list_Release(ID3D11CommandList
*iface
)
371 struct d3d11_command_list
*list
= impl_from_ID3D11CommandList(iface
);
372 ULONG refcount
= InterlockedDecrement(&list
->refcount
);
374 TRACE("%p decreasing refcount to %lu.\n", list
, refcount
);
378 wined3d_command_list_decref(list
->wined3d_list
);
379 wined3d_private_store_cleanup(&list
->private_store
);
380 ID3D11Device2_Release(list
->device
);
387 static void STDMETHODCALLTYPE
d3d11_command_list_GetDevice(ID3D11CommandList
*iface
, ID3D11Device
**device
)
389 struct d3d11_command_list
*list
= impl_from_ID3D11CommandList(iface
);
391 TRACE("iface %p, device %p.\n", iface
, device
);
393 *device
= (ID3D11Device
*)list
->device
;
394 ID3D11Device2_AddRef(list
->device
);
397 static HRESULT STDMETHODCALLTYPE
d3d11_command_list_GetPrivateData(ID3D11CommandList
*iface
, REFGUID guid
,
398 UINT
*data_size
, void *data
)
400 struct d3d11_command_list
*list
= impl_from_ID3D11CommandList(iface
);
402 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
404 return d3d_get_private_data(&list
->private_store
, guid
, data_size
, data
);
407 static HRESULT STDMETHODCALLTYPE
d3d11_command_list_SetPrivateData(ID3D11CommandList
*iface
, REFGUID guid
,
408 UINT data_size
, const void *data
)
410 struct d3d11_command_list
*list
= impl_from_ID3D11CommandList(iface
);
412 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
414 return d3d_set_private_data(&list
->private_store
, guid
, data_size
, data
);
417 static HRESULT STDMETHODCALLTYPE
d3d11_command_list_SetPrivateDataInterface(ID3D11CommandList
*iface
,
418 REFGUID guid
, const IUnknown
*data
)
420 struct d3d11_command_list
*list
= impl_from_ID3D11CommandList(iface
);
422 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
424 return d3d_set_private_data_interface(&list
->private_store
, guid
, data
);
427 static UINT STDMETHODCALLTYPE
d3d11_command_list_GetContextFlags(ID3D11CommandList
*iface
)
429 TRACE("iface %p.\n", iface
);
434 static const struct ID3D11CommandListVtbl d3d11_command_list_vtbl
=
436 /* IUnknown methods */
437 d3d11_command_list_QueryInterface
,
438 d3d11_command_list_AddRef
,
439 d3d11_command_list_Release
,
440 /* ID3D11DeviceChild methods */
441 d3d11_command_list_GetDevice
,
442 d3d11_command_list_GetPrivateData
,
443 d3d11_command_list_SetPrivateData
,
444 d3d11_command_list_SetPrivateDataInterface
,
445 /* ID3D11CommandList methods */
446 d3d11_command_list_GetContextFlags
,
449 static struct d3d11_command_list
*unsafe_impl_from_ID3D11CommandList(ID3D11CommandList
*iface
)
453 assert(iface
->lpVtbl
== &d3d11_command_list_vtbl
);
454 return impl_from_ID3D11CommandList(iface
);
457 static void d3d11_device_context_cleanup(struct d3d11_device_context
*context
)
459 wined3d_private_store_cleanup(&context
->private_store
);
462 /* ID3D11DeviceContext - immediate context methods */
464 static inline struct d3d11_device_context
*impl_from_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
466 return CONTAINING_RECORD(iface
, struct d3d11_device_context
, ID3D11DeviceContext1_iface
);
469 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_QueryInterface(ID3D11DeviceContext1
*iface
,
470 REFIID iid
, void **out
)
472 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
474 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
476 if (IsEqualGUID(iid
, &IID_ID3D11DeviceContext1
)
477 || IsEqualGUID(iid
, &IID_ID3D11DeviceContext
)
478 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
479 || IsEqualGUID(iid
, &IID_IUnknown
))
481 *out
= &context
->ID3D11DeviceContext1_iface
;
483 else if (context
->type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
&& IsEqualGUID(iid
, &IID_ID3D11Multithread
))
485 *out
= &context
->ID3D11Multithread_iface
;
487 else if (IsEqualGUID(iid
, &IID_ID3DUserDefinedAnnotation
))
489 *out
= &context
->ID3DUserDefinedAnnotation_iface
;
493 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
495 return E_NOINTERFACE
;
498 ID3D11DeviceContext1_AddRef(iface
);
502 static ULONG STDMETHODCALLTYPE
d3d11_device_context_AddRef(ID3D11DeviceContext1
*iface
)
504 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
505 ULONG refcount
= InterlockedIncrement(&context
->refcount
);
507 TRACE("%p increasing refcount to %lu.\n", context
, refcount
);
511 ID3D11Device2_AddRef(&context
->device
->ID3D11Device2_iface
);
517 static ULONG STDMETHODCALLTYPE
d3d11_device_context_Release(ID3D11DeviceContext1
*iface
)
519 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
520 ULONG refcount
= InterlockedDecrement(&context
->refcount
);
522 TRACE("%p decreasing refcount to %lu.\n", context
, refcount
);
526 ID3D11Device2
*device
= &context
->device
->ID3D11Device2_iface
;
527 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
)
529 wined3d_deferred_context_destroy(context
->wined3d_context
);
530 d3d11_device_context_cleanup(context
);
533 ID3D11Device2_Release(device
);
539 static void d3d11_device_context_get_constant_buffers(ID3D11DeviceContext1
*iface
, enum wined3d_shader_type type
,
540 unsigned int start_slot
, unsigned int buffer_count
, ID3D11Buffer
**buffers
,
541 unsigned int *offsets
, unsigned int *counts
)
543 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
546 wined3d_mutex_lock();
547 for (i
= 0; i
< buffer_count
; ++i
)
549 struct wined3d_constant_buffer_state state
;
550 struct d3d_buffer
*buffer_impl
;
552 wined3d_device_context_get_constant_buffer(context
->wined3d_context
, type
, start_slot
+ i
, &state
);
555 offsets
[i
] = state
.offset
/ sizeof(struct wined3d_vec4
);
557 counts
[i
] = state
.size
/ sizeof(struct wined3d_vec4
);
565 buffer_impl
= wined3d_buffer_get_parent(state
.buffer
);
566 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
567 ID3D11Buffer_AddRef(buffers
[i
]);
569 wined3d_mutex_unlock();
572 static void d3d11_device_context_set_constant_buffers(ID3D11DeviceContext1
*iface
, enum wined3d_shader_type type
,
573 unsigned int start_slot
, unsigned int buffer_count
, ID3D11Buffer
*const *buffers
,
574 const unsigned int *offsets
, const unsigned int *counts
)
576 static const unsigned int alignment
= D3D11_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT
;
577 struct wined3d_constant_buffer_state wined3d_buffers
[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
578 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
581 if (buffer_count
> ARRAY_SIZE(wined3d_buffers
))
583 WARN("Buffer count %u exceeds limit; ignoring call.\n", buffer_count
);
587 if (!offsets
!= !counts
)
589 WARN("Got offsets pointer %p but counts pointer %p; ignoring call.\n", offsets
, counts
);
593 for (i
= 0; i
< buffer_count
; ++i
)
595 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
597 if (offsets
&& (offsets
[i
] & (alignment
- 1)))
599 WARN("Offset %u is not aligned.\n", offsets
[i
]);
603 if (counts
&& (counts
[i
] & (alignment
- 1)))
605 WARN("Count %u is not aligned.\n", counts
[i
]);
609 wined3d_buffers
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
610 wined3d_buffers
[i
].offset
= (offsets
? offsets
[i
] : 0) * sizeof(struct wined3d_vec4
);
611 wined3d_buffers
[i
].size
= (counts
? counts
[i
] : WINED3D_MAX_CONSTANT_BUFFER_SIZE
) * sizeof(struct wined3d_vec4
);
614 wined3d_device_context_set_constant_buffers(context
->wined3d_context
,
615 type
, start_slot
, buffer_count
, wined3d_buffers
);
618 static void d3d11_device_context_set_shader_resource_views(ID3D11DeviceContext1
*iface
, enum wined3d_shader_type type
,
619 unsigned int start_slot
, unsigned int count
, ID3D11ShaderResourceView
*const *views
)
621 struct wined3d_shader_resource_view
*wined3d_views
[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
622 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
625 if (count
> ARRAY_SIZE(wined3d_views
))
627 WARN("View count %u exceeds limit; ignoring call.\n", count
);
631 for (i
= 0; i
< count
; ++i
)
633 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
635 wined3d_views
[i
] = view
? view
->wined3d_view
: NULL
;
638 wined3d_device_context_set_shader_resource_views(context
->wined3d_context
,
639 type
, start_slot
, count
, wined3d_views
);
642 static void d3d11_device_context_set_samplers(ID3D11DeviceContext1
*iface
, enum wined3d_shader_type type
,
643 unsigned int start_slot
, unsigned int count
, ID3D11SamplerState
*const *samplers
)
645 struct wined3d_sampler
*wined3d_samplers
[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
];
646 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
649 if (count
> ARRAY_SIZE(wined3d_samplers
))
651 WARN("Sampler count %u exceeds limit; ignoring call.\n", count
);
655 for (i
= 0; i
< count
; ++i
)
657 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
659 wined3d_samplers
[i
] = sampler
? sampler
->wined3d_sampler
: NULL
;
662 wined3d_device_context_set_samplers(context
->wined3d_context
, type
, start_slot
, count
, wined3d_samplers
);
665 static void STDMETHODCALLTYPE
d3d11_device_context_GetDevice(ID3D11DeviceContext1
*iface
, ID3D11Device
**device
)
667 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
669 TRACE("iface %p, device %p.\n", iface
, device
);
671 *device
= (ID3D11Device
*)&context
->device
->ID3D11Device2_iface
;
672 ID3D11Device_AddRef(*device
);
675 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_GetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
676 UINT
*data_size
, void *data
)
678 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
680 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
682 return d3d_get_private_data(&context
->private_store
, guid
, data_size
, data
);
685 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_SetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
686 UINT data_size
, const void *data
)
688 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
690 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
692 return d3d_set_private_data(&context
->private_store
, guid
, data_size
, data
);
695 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_SetPrivateDataInterface(ID3D11DeviceContext1
*iface
,
696 REFGUID guid
, const IUnknown
*data
)
698 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
700 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
702 return d3d_set_private_data_interface(&context
->private_store
, guid
, data
);
705 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
706 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
708 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
709 iface
, start_slot
, buffer_count
, buffers
);
711 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
712 buffer_count
, buffers
, NULL
, NULL
);
715 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetShaderResources(ID3D11DeviceContext1
*iface
,
716 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
718 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
719 iface
, start_slot
, view_count
, views
);
721 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, view_count
, views
);
724 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetShader(ID3D11DeviceContext1
*iface
,
725 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
727 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
728 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
730 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
731 iface
, shader
, class_instances
, class_instance_count
);
733 if (class_instance_count
)
734 FIXME("Dynamic linking is not implemented yet.\n");
736 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
,
737 ps
? ps
->wined3d_shader
: NULL
);
740 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetSamplers(ID3D11DeviceContext1
*iface
,
741 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
743 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
744 iface
, start_slot
, sampler_count
, samplers
);
746 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, sampler_count
, samplers
);
749 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetShader(ID3D11DeviceContext1
*iface
,
750 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
752 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
753 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
755 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
756 iface
, shader
, class_instances
, class_instance_count
);
758 if (class_instance_count
)
759 FIXME("Dynamic linking is not implemented yet.\n");
761 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
,
762 vs
? vs
->wined3d_shader
: NULL
);
765 static void STDMETHODCALLTYPE
d3d11_device_context_DrawIndexed(ID3D11DeviceContext1
*iface
,
766 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
768 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
770 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
771 iface
, index_count
, start_index_location
, base_vertex_location
);
773 wined3d_device_context_draw_indexed(context
->wined3d_context
,
774 base_vertex_location
, start_index_location
, index_count
, 0, 0);
777 static void STDMETHODCALLTYPE
d3d11_device_context_Draw(ID3D11DeviceContext1
*iface
,
778 UINT vertex_count
, UINT start_vertex_location
)
780 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
782 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
783 iface
, vertex_count
, start_vertex_location
);
785 wined3d_device_context_draw(context
->wined3d_context
, start_vertex_location
, vertex_count
, 0, 0);
788 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_Map(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
789 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
791 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
792 struct wined3d_resource
*wined3d_resource
;
793 struct wined3d_map_desc map_desc
;
796 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
797 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
800 FIXME("Ignoring map_flags %#x.\n", map_flags
);
802 mapped_subresource
->pData
= NULL
;
804 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
805 && map_type
!= D3D11_MAP_WRITE_DISCARD
&& map_type
!= D3D11_MAP_WRITE_NO_OVERWRITE
)
808 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
810 if (SUCCEEDED(hr
= wined3d_device_context_map(context
->wined3d_context
, wined3d_resource
, subresource_idx
,
811 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
))))
813 mapped_subresource
->pData
= map_desc
.data
;
814 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
815 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
821 static void STDMETHODCALLTYPE
d3d11_device_context_Unmap(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
822 UINT subresource_idx
)
824 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
825 struct wined3d_resource
*wined3d_resource
;
827 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
829 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
831 wined3d_device_context_unmap(context
->wined3d_context
, wined3d_resource
, subresource_idx
);
834 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
835 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
837 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
838 iface
, start_slot
, buffer_count
, buffers
);
840 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
841 buffer_count
, buffers
, NULL
, NULL
);
844 static void STDMETHODCALLTYPE
d3d11_device_context_IASetInputLayout(ID3D11DeviceContext1
*iface
,
845 ID3D11InputLayout
*input_layout
)
847 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
848 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
850 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
852 wined3d_device_context_set_vertex_declaration(context
->wined3d_context
, layout
? layout
->wined3d_decl
: NULL
);
855 static void STDMETHODCALLTYPE
d3d11_device_context_IASetVertexBuffers(ID3D11DeviceContext1
*iface
,
856 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
858 struct wined3d_stream_state streams
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
859 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
862 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
863 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
865 if (buffer_count
> ARRAY_SIZE(streams
))
867 WARN("Buffer count %u exceeds limit.\n", buffer_count
);
868 buffer_count
= ARRAY_SIZE(streams
);
871 for (i
= 0; i
< buffer_count
; ++i
)
873 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
875 streams
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
876 streams
[i
].offset
= offsets
[i
];
877 streams
[i
].stride
= strides
[i
];
878 streams
[i
].frequency
= 1;
879 streams
[i
].flags
= 0;
882 wined3d_device_context_set_stream_sources(context
->wined3d_context
, start_slot
, buffer_count
, streams
);
885 static void STDMETHODCALLTYPE
d3d11_device_context_IASetIndexBuffer(ID3D11DeviceContext1
*iface
,
886 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
888 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
889 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
891 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
892 iface
, buffer
, debug_dxgi_format(format
), offset
);
894 wined3d_device_context_set_index_buffer(context
->wined3d_context
,
895 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
896 wined3dformat_from_dxgi_format(format
), offset
);
899 static void STDMETHODCALLTYPE
d3d11_device_context_DrawIndexedInstanced(ID3D11DeviceContext1
*iface
,
900 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
901 UINT start_instance_location
)
903 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
905 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
906 "base_vertex_location %d, start_instance_location %u.\n",
907 iface
, instance_index_count
, instance_count
, start_index_location
,
908 base_vertex_location
, start_instance_location
);
910 wined3d_device_context_draw_indexed(context
->wined3d_context
, base_vertex_location
,
911 start_index_location
, instance_index_count
, start_instance_location
, instance_count
);
914 static void STDMETHODCALLTYPE
d3d11_device_context_DrawInstanced(ID3D11DeviceContext1
*iface
,
915 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
917 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
919 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
920 "start_instance_location %u.\n",
921 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
922 start_instance_location
);
924 wined3d_device_context_draw(context
->wined3d_context
, start_vertex_location
,
925 instance_vertex_count
, start_instance_location
, instance_count
);
928 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
929 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
931 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
932 iface
, start_slot
, buffer_count
, buffers
);
934 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
935 buffer_count
, buffers
, NULL
, NULL
);
938 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetShader(ID3D11DeviceContext1
*iface
,
939 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
941 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
942 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
944 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
945 iface
, shader
, class_instances
, class_instance_count
);
947 if (class_instance_count
)
948 FIXME("Dynamic linking is not implemented yet.\n");
950 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
,
951 gs
? gs
->wined3d_shader
: NULL
);
954 static void STDMETHODCALLTYPE
d3d11_device_context_IASetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
955 D3D11_PRIMITIVE_TOPOLOGY topology
)
957 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
958 enum wined3d_primitive_type primitive_type
;
959 unsigned int patch_vertex_count
;
961 TRACE("iface %p, topology %#x.\n", iface
, topology
);
963 wined3d_primitive_type_from_d3d11_primitive_topology(topology
, &primitive_type
, &patch_vertex_count
);
965 wined3d_device_context_set_primitive_type(context
->wined3d_context
, primitive_type
, patch_vertex_count
);
968 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetShaderResources(ID3D11DeviceContext1
*iface
,
969 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
971 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
973 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, view_count
, views
);
976 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetSamplers(ID3D11DeviceContext1
*iface
,
977 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
979 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
980 iface
, start_slot
, sampler_count
, samplers
);
982 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, sampler_count
, samplers
);
985 static void STDMETHODCALLTYPE
d3d11_device_context_Begin(ID3D11DeviceContext1
*iface
,
986 ID3D11Asynchronous
*asynchronous
)
988 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
989 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
991 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
993 wined3d_device_context_issue_query(context
->wined3d_context
, query
->wined3d_query
, WINED3DISSUE_BEGIN
);
996 static void STDMETHODCALLTYPE
d3d11_device_context_End(ID3D11DeviceContext1
*iface
,
997 ID3D11Asynchronous
*asynchronous
)
999 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1000 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
1002 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
1004 wined3d_device_context_issue_query(context
->wined3d_context
, query
->wined3d_query
, WINED3DISSUE_END
);
1007 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_GetData(ID3D11DeviceContext1
*iface
,
1008 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
1010 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1011 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
1012 unsigned int wined3d_flags
;
1015 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
1016 iface
, asynchronous
, data
, data_size
, data_flags
);
1018 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
)
1019 return DXGI_ERROR_INVALID_CALL
;
1021 if (!data
&& data_size
)
1022 return E_INVALIDARG
;
1024 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
1026 wined3d_mutex_lock();
1027 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
1029 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
1030 if (hr
== WINED3DERR_INVALIDCALL
)
1031 hr
= DXGI_ERROR_INVALID_CALL
;
1035 WARN("Invalid data size %u.\n", data_size
);
1038 wined3d_mutex_unlock();
1043 static void STDMETHODCALLTYPE
d3d11_device_context_SetPredication(ID3D11DeviceContext1
*iface
,
1044 ID3D11Predicate
*predicate
, BOOL value
)
1046 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1047 struct d3d_query
*query
;
1049 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
1051 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
1053 wined3d_device_context_set_predication(context
->wined3d_context
, query
? query
->wined3d_query
: NULL
, value
);
1056 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetShaderResources(ID3D11DeviceContext1
*iface
,
1057 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1059 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1061 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, view_count
, views
);
1064 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetSamplers(ID3D11DeviceContext1
*iface
,
1065 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1067 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1068 iface
, start_slot
, sampler_count
, samplers
);
1070 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, sampler_count
, samplers
);
1073 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetRenderTargets(ID3D11DeviceContext1
*iface
,
1074 UINT rtv_count
, ID3D11RenderTargetView
*const *rtvs
, ID3D11DepthStencilView
*depth_stencil_view
)
1076 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
1077 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1078 struct d3d_depthstencil_view
*dsv
;
1081 TRACE("iface %p, rtv_count %u, rtvs %p, depth_stencil_view %p.\n", iface
, rtv_count
, rtvs
, depth_stencil_view
);
1083 if (rtv_count
> ARRAY_SIZE(wined3d_rtvs
))
1085 WARN("View count %u exceeds limit.\n", rtv_count
);
1086 rtv_count
= ARRAY_SIZE(wined3d_rtvs
);
1089 for (i
= 0; i
< rtv_count
; ++i
)
1091 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(rtvs
[i
]);
1093 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
1096 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1098 wined3d_device_context_set_render_targets_and_unordered_access_views(context
->wined3d_context
,
1099 ARRAY_SIZE(wined3d_rtvs
), wined3d_rtvs
, dsv
? dsv
->wined3d_view
: NULL
, ~0u, NULL
, NULL
);
1102 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetRenderTargetsAndUnorderedAccessViews(
1103 ID3D11DeviceContext1
*iface
, UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
1104 ID3D11DepthStencilView
*depth_stencil_view
, UINT uav_start_idx
, UINT uav_count
,
1105 ID3D11UnorderedAccessView
*const *uavs
, const UINT
*initial_counts
)
1107 struct d3d_depthstencil_view
*dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1108 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
1109 struct wined3d_unordered_access_view
*wined3d_uavs
[D3D11_PS_CS_UAV_REGISTER_COUNT
] = {0};
1110 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1111 unsigned int wined3d_initial_counts
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
1114 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1115 "uav_start_idx %u, uav_count %u, uavs %p, initial_counts %p.\n",
1116 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1117 uav_start_idx
, uav_count
, uavs
, initial_counts
);
1119 if (render_target_view_count
== D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
1120 render_target_view_count
= ~0u;
1123 if (render_target_view_count
> ARRAY_SIZE(wined3d_rtvs
))
1125 WARN("View count %u exceeds limit.\n", render_target_view_count
);
1126 render_target_view_count
= ARRAY_SIZE(wined3d_rtvs
);
1129 for (i
= 0; i
< render_target_view_count
; ++i
)
1131 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
1133 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
1137 if (uav_count
== D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
1141 if (!wined3d_bound_range(uav_start_idx
, uav_count
, ARRAY_SIZE(wined3d_uavs
)))
1143 WARN("View count %u exceeds limit; ignoring call.\n", uav_count
);
1147 memset(wined3d_initial_counts
, 0xff, sizeof(wined3d_initial_counts
));
1149 for (i
= 0; i
< uav_count
; ++i
)
1151 struct d3d11_unordered_access_view
*view
=
1152 unsafe_impl_from_ID3D11UnorderedAccessView(uavs
[i
]);
1154 wined3d_uavs
[uav_start_idx
+ i
] = view
? view
->wined3d_view
: NULL
;
1155 wined3d_initial_counts
[uav_start_idx
+ i
] = initial_counts
? initial_counts
[i
] : ~0u;
1159 wined3d_device_context_set_render_targets_and_unordered_access_views(context
->wined3d_context
,
1160 render_target_view_count
== ~0u ? ~0u : ARRAY_SIZE(wined3d_rtvs
), wined3d_rtvs
,
1161 dsv
? dsv
->wined3d_view
: NULL
, uav_count
== ~0u ? ~0u : ARRAY_SIZE(wined3d_uavs
), wined3d_uavs
,
1162 wined3d_initial_counts
);
1165 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetBlendState(ID3D11DeviceContext1
*iface
,
1166 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
1168 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1169 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
1170 struct d3d_blend_state
*blend_state_impl
;
1172 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
1173 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
1176 blend_factor
= default_blend_factor
;
1178 if (!(blend_state_impl
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
1179 wined3d_device_context_set_blend_state(context
->wined3d_context
, NULL
,
1180 (const struct wined3d_color
*)blend_factor
, sample_mask
);
1182 wined3d_device_context_set_blend_state(context
->wined3d_context
, blend_state_impl
->wined3d_state
,
1183 (const struct wined3d_color
*)blend_factor
, sample_mask
);
1186 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetDepthStencilState(ID3D11DeviceContext1
*iface
,
1187 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
1189 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1190 struct d3d_depthstencil_state
*state_impl
;
1192 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
1193 iface
, depth_stencil_state
, stencil_ref
);
1195 if (!(state_impl
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
1197 wined3d_device_context_set_depth_stencil_state(context
->wined3d_context
, NULL
, stencil_ref
);
1201 wined3d_device_context_set_depth_stencil_state(context
->wined3d_context
, state_impl
->wined3d_state
, stencil_ref
);
1204 static void STDMETHODCALLTYPE
d3d11_device_context_SOSetTargets(ID3D11DeviceContext1
*iface
, UINT buffer_count
,
1205 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
1207 struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
] = {0};
1208 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1209 unsigned int count
, i
;
1211 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
1213 count
= min(buffer_count
, ARRAY_SIZE(outputs
));
1214 for (i
= 0; i
< count
; ++i
)
1216 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1218 outputs
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
1219 outputs
[i
].offset
= offsets
? offsets
[i
] : 0;
1222 wined3d_device_context_set_stream_outputs(context
->wined3d_context
, outputs
);
1225 static void STDMETHODCALLTYPE
d3d11_device_context_DrawAuto(ID3D11DeviceContext1
*iface
)
1227 FIXME("iface %p stub!\n", iface
);
1230 static void STDMETHODCALLTYPE
d3d11_device_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext1
*iface
,
1231 ID3D11Buffer
*buffer
, UINT offset
)
1233 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1234 struct d3d_buffer
*d3d_buffer
;
1236 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1238 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
1240 wined3d_device_context_draw_indirect(context
->wined3d_context
, d3d_buffer
->wined3d_buffer
, offset
, true);
1243 static void STDMETHODCALLTYPE
d3d11_device_context_DrawInstancedIndirect(ID3D11DeviceContext1
*iface
,
1244 ID3D11Buffer
*buffer
, UINT offset
)
1246 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1247 struct d3d_buffer
*d3d_buffer
;
1249 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1251 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
1253 wined3d_device_context_draw_indirect(context
->wined3d_context
, d3d_buffer
->wined3d_buffer
, offset
, false);
1256 static void STDMETHODCALLTYPE
d3d11_device_context_Dispatch(ID3D11DeviceContext1
*iface
,
1257 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
1259 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1261 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
1262 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
1264 wined3d_device_context_dispatch(context
->wined3d_context
,
1265 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
1268 static void STDMETHODCALLTYPE
d3d11_device_context_DispatchIndirect(ID3D11DeviceContext1
*iface
,
1269 ID3D11Buffer
*buffer
, UINT offset
)
1271 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1272 struct d3d_buffer
*buffer_impl
;
1274 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1276 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
1278 wined3d_device_context_dispatch_indirect(context
->wined3d_context
, buffer_impl
->wined3d_buffer
, offset
);
1281 static void STDMETHODCALLTYPE
d3d11_device_context_RSSetState(ID3D11DeviceContext1
*iface
,
1282 ID3D11RasterizerState
*rasterizer_state
)
1284 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1285 struct d3d_rasterizer_state
*rasterizer_state_impl
;
1287 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1289 rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
);
1290 wined3d_device_context_set_rasterizer_state(context
->wined3d_context
,
1291 rasterizer_state_impl
? rasterizer_state_impl
->wined3d_state
: NULL
);
1294 static void STDMETHODCALLTYPE
d3d11_device_context_RSSetViewports(ID3D11DeviceContext1
*iface
,
1295 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
1297 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1298 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
1301 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
1303 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
1306 for (i
= 0; i
< viewport_count
; ++i
)
1308 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
1309 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
1310 wined3d_vp
[i
].width
= viewports
[i
].Width
;
1311 wined3d_vp
[i
].height
= viewports
[i
].Height
;
1312 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
1313 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
1316 wined3d_device_context_set_viewports(context
->wined3d_context
, viewport_count
, wined3d_vp
);
1319 static void STDMETHODCALLTYPE
d3d11_device_context_RSSetScissorRects(ID3D11DeviceContext1
*iface
,
1320 UINT rect_count
, const D3D11_RECT
*rects
)
1322 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1324 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
1326 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
1329 wined3d_device_context_set_scissor_rects(context
->wined3d_context
, rect_count
, rects
);
1332 static void STDMETHODCALLTYPE
d3d11_device_context_CopySubresourceRegion(ID3D11DeviceContext1
*iface
,
1333 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
1334 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
1336 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1337 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1338 struct wined3d_box wined3d_src_box
;
1340 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
1341 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
1342 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
1343 src_resource
, src_subresource_idx
, src_box
);
1345 if (!dst_resource
|| !src_resource
)
1349 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
1350 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
1352 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1353 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1354 wined3d_device_context_copy_sub_resource_region(context
->wined3d_context
, wined3d_dst_resource
, dst_subresource_idx
,
1355 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
1358 static void STDMETHODCALLTYPE
d3d11_device_context_CopyResource(ID3D11DeviceContext1
*iface
,
1359 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
1361 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1362 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1364 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1366 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1367 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1368 wined3d_device_context_copy_resource(context
->wined3d_context
, wined3d_dst_resource
, wined3d_src_resource
);
1371 static void STDMETHODCALLTYPE
d3d11_device_context_UpdateSubresource(ID3D11DeviceContext1
*iface
,
1372 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1373 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1375 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1376 struct wined3d_resource
*wined3d_resource
;
1377 struct wined3d_box wined3d_box
;
1379 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1380 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1383 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1385 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1386 wined3d_device_context_update_sub_resource(context
->wined3d_context
, wined3d_resource
,
1387 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, 0);
1390 static void STDMETHODCALLTYPE
d3d11_device_context_CopyStructureCount(ID3D11DeviceContext1
*iface
,
1391 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1393 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1394 struct d3d11_unordered_access_view
*uav
;
1395 struct d3d_buffer
*buffer_impl
;
1397 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1398 iface
, dst_buffer
, dst_offset
, src_view
);
1400 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1401 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1403 wined3d_device_context_copy_uav_counter(context
->wined3d_context
,
1404 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1407 static void STDMETHODCALLTYPE
d3d11_device_context_ClearRenderTargetView(ID3D11DeviceContext1
*iface
,
1408 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1410 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1411 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1412 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1415 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1416 iface
, render_target_view
, debug_float4(color_rgba
));
1421 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(context
->wined3d_context
, view
->wined3d_view
, NULL
,
1422 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1423 ERR("Failed to clear view, hr %#lx.\n", hr
);
1426 static void STDMETHODCALLTYPE
d3d11_device_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1
*iface
,
1427 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1429 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1430 struct d3d11_unordered_access_view
*view
;
1432 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1433 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1435 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1436 wined3d_device_context_clear_uav_uint(context
->wined3d_context
,
1437 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1440 static void STDMETHODCALLTYPE
d3d11_device_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1
*iface
,
1441 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1443 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1444 struct d3d11_unordered_access_view
*view
;
1446 TRACE("iface %p, unordered_access_view %p, values %s.\n",
1447 iface
, unordered_access_view
, debug_float4(values
));
1449 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1450 wined3d_device_context_clear_uav_float(context
->wined3d_context
,
1451 view
->wined3d_view
, (const struct wined3d_vec4
*)values
);
1454 static void STDMETHODCALLTYPE
d3d11_device_context_ClearDepthStencilView(ID3D11DeviceContext1
*iface
,
1455 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1457 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1458 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1459 DWORD wined3d_flags
;
1462 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1463 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1468 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1470 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(context
->wined3d_context
, view
->wined3d_view
, NULL
,
1471 wined3d_flags
, NULL
, depth
, stencil
)))
1472 ERR("Failed to clear view, hr %#lx.\n", hr
);
1475 static void STDMETHODCALLTYPE
d3d11_device_context_GenerateMips(ID3D11DeviceContext1
*iface
,
1476 ID3D11ShaderResourceView
*view
)
1478 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1479 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D11ShaderResourceView(view
);
1481 TRACE("iface %p, view %p.\n", iface
, view
);
1483 wined3d_device_context_generate_mipmaps(context
->wined3d_context
, srv
->wined3d_view
);
1486 static void STDMETHODCALLTYPE
d3d11_device_context_SetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1487 ID3D11Resource
*resource
, FLOAT min_lod
)
1489 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1492 static FLOAT STDMETHODCALLTYPE
d3d11_device_context_GetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1493 ID3D11Resource
*resource
)
1495 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1500 static void STDMETHODCALLTYPE
d3d11_device_context_ResolveSubresource(ID3D11DeviceContext1
*iface
,
1501 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1502 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1505 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1506 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1507 enum wined3d_format_id wined3d_format
;
1509 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
1510 "src_resource %p, src_subresource_idx %u, format %s.\n",
1511 iface
, dst_resource
, dst_subresource_idx
,
1512 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1514 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1515 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1516 wined3d_format
= wined3dformat_from_dxgi_format(format
);
1517 wined3d_device_context_resolve_sub_resource(context
->wined3d_context
,
1518 wined3d_dst_resource
, dst_subresource_idx
,
1519 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
1522 static void STDMETHODCALLTYPE
d3d11_device_context_ExecuteCommandList(ID3D11DeviceContext1
*iface
,
1523 ID3D11CommandList
*command_list
, BOOL restore_state
)
1525 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1526 struct d3d11_command_list
*list_impl
= unsafe_impl_from_ID3D11CommandList(command_list
);
1528 TRACE("iface %p, command_list %p, restore_state %#x.\n", iface
, command_list
, restore_state
);
1530 wined3d_device_context_execute_command_list(context
->wined3d_context
, list_impl
->wined3d_list
, !!restore_state
);
1533 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetShaderResources(ID3D11DeviceContext1
*iface
,
1534 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1536 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1537 iface
, start_slot
, view_count
, views
);
1539 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
, view_count
, views
);
1542 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetShader(ID3D11DeviceContext1
*iface
,
1543 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1545 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1546 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1548 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1549 iface
, shader
, class_instances
, class_instance_count
);
1551 if (class_instance_count
)
1552 FIXME("Dynamic linking is not implemented yet.\n");
1554 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
,
1555 hs
? hs
->wined3d_shader
: NULL
);
1558 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetSamplers(ID3D11DeviceContext1
*iface
,
1559 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1561 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1562 iface
, start_slot
, sampler_count
, samplers
);
1564 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
, sampler_count
, samplers
);
1567 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1568 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1570 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1571 iface
, start_slot
, buffer_count
, buffers
);
1573 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
1574 buffer_count
, buffers
, NULL
, NULL
);
1577 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetShaderResources(ID3D11DeviceContext1
*iface
,
1578 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1580 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1581 iface
, start_slot
, view_count
, views
);
1583 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
, view_count
, views
);
1586 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetShader(ID3D11DeviceContext1
*iface
,
1587 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1589 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1590 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1592 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1593 iface
, shader
, class_instances
, class_instance_count
);
1595 if (class_instance_count
)
1596 FIXME("Dynamic linking is not implemented yet.\n");
1598 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
,
1599 ds
? ds
->wined3d_shader
: NULL
);
1602 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetSamplers(ID3D11DeviceContext1
*iface
,
1603 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1605 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1606 iface
, start_slot
, sampler_count
, samplers
);
1608 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
, sampler_count
, samplers
);
1611 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1612 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1614 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1615 iface
, start_slot
, buffer_count
, buffers
);
1617 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
1618 buffer_count
, buffers
, NULL
, NULL
);
1621 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetShaderResources(ID3D11DeviceContext1
*iface
,
1622 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1624 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1625 iface
, start_slot
, view_count
, views
);
1627 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
, view_count
, views
);
1630 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
1631 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1633 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1634 struct wined3d_unordered_access_view
*wined3d_views
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
1637 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1638 iface
, start_slot
, view_count
, views
, initial_counts
);
1640 if (view_count
> ARRAY_SIZE(wined3d_views
))
1642 WARN("View count %u exceeds limit; ignoring call.\n", view_count
);
1646 for (i
= 0; i
< view_count
; ++i
)
1648 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1650 wined3d_views
[i
] = view
? view
->wined3d_view
: NULL
;
1653 wined3d_device_context_set_unordered_access_views(context
->wined3d_context
, WINED3D_PIPELINE_COMPUTE
,
1654 start_slot
, view_count
, wined3d_views
, initial_counts
);
1657 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetShader(ID3D11DeviceContext1
*iface
,
1658 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1660 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1661 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1663 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1664 iface
, shader
, class_instances
, class_instance_count
);
1666 if (class_instance_count
)
1667 FIXME("Dynamic linking is not implemented yet.\n");
1669 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
,
1670 cs
? cs
->wined3d_shader
: NULL
);
1673 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetSamplers(ID3D11DeviceContext1
*iface
,
1674 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1676 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1677 iface
, start_slot
, sampler_count
, samplers
);
1679 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
, sampler_count
, samplers
);
1682 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1683 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1685 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1686 iface
, start_slot
, buffer_count
, buffers
);
1688 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
1689 buffer_count
, buffers
, NULL
, NULL
);
1692 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1693 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1695 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1696 iface
, start_slot
, buffer_count
, buffers
);
1698 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
1699 buffer_count
, buffers
, NULL
, NULL
);
1702 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetShaderResources(ID3D11DeviceContext1
*iface
,
1703 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1705 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1708 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1709 iface
, start_slot
, view_count
, views
);
1711 wined3d_mutex_lock();
1712 for (i
= 0; i
< view_count
; ++i
)
1714 struct wined3d_shader_resource_view
*wined3d_view
;
1715 struct d3d_shader_resource_view
*view_impl
;
1717 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
1718 context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
1724 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1725 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1726 ID3D11ShaderResourceView_AddRef(views
[i
]);
1728 wined3d_mutex_unlock();
1731 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetShader(ID3D11DeviceContext1
*iface
,
1732 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1734 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1735 struct wined3d_shader
*wined3d_shader
;
1736 struct d3d_pixel_shader
*shader_impl
;
1738 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1739 iface
, shader
, class_instances
, class_instance_count
);
1741 if (class_instance_count
)
1742 *class_instance_count
= 0;
1744 wined3d_mutex_lock();
1745 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
)))
1747 wined3d_mutex_unlock();
1752 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1753 wined3d_mutex_unlock();
1754 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1755 ID3D11PixelShader_AddRef(*shader
);
1758 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetSamplers(ID3D11DeviceContext1
*iface
,
1759 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1761 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1764 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1765 iface
, start_slot
, sampler_count
, samplers
);
1767 wined3d_mutex_lock();
1768 for (i
= 0; i
< sampler_count
; ++i
)
1770 struct wined3d_sampler
*wined3d_sampler
;
1771 struct d3d_sampler_state
*sampler_impl
;
1773 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
1774 context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
1780 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1781 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1782 ID3D11SamplerState_AddRef(samplers
[i
]);
1784 wined3d_mutex_unlock();
1787 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetShader(ID3D11DeviceContext1
*iface
,
1788 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1790 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1791 struct d3d_vertex_shader
*shader_impl
;
1792 struct wined3d_shader
*wined3d_shader
;
1794 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1795 iface
, shader
, class_instances
, class_instance_count
);
1797 if (class_instance_count
)
1798 *class_instance_count
= 0;
1800 wined3d_mutex_lock();
1801 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
)))
1803 wined3d_mutex_unlock();
1808 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1809 wined3d_mutex_unlock();
1810 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1811 ID3D11VertexShader_AddRef(*shader
);
1814 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1815 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1817 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1818 iface
, start_slot
, buffer_count
, buffers
);
1820 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
1821 buffer_count
, buffers
, NULL
, NULL
);
1824 static void STDMETHODCALLTYPE
d3d11_device_context_IAGetInputLayout(ID3D11DeviceContext1
*iface
,
1825 ID3D11InputLayout
**input_layout
)
1827 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1828 struct wined3d_vertex_declaration
*wined3d_declaration
;
1829 struct d3d_input_layout
*input_layout_impl
;
1831 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1833 wined3d_mutex_lock();
1834 if (!(wined3d_declaration
= wined3d_device_context_get_vertex_declaration(context
->wined3d_context
)))
1836 wined3d_mutex_unlock();
1837 *input_layout
= NULL
;
1841 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1842 wined3d_mutex_unlock();
1843 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1844 ID3D11InputLayout_AddRef(*input_layout
);
1847 static void STDMETHODCALLTYPE
d3d11_device_context_IAGetVertexBuffers(ID3D11DeviceContext1
*iface
,
1848 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1850 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1853 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1854 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1856 wined3d_mutex_lock();
1857 for (i
= 0; i
< buffer_count
; ++i
)
1859 struct wined3d_buffer
*wined3d_buffer
= NULL
;
1860 struct d3d_buffer
*buffer_impl
;
1862 if (FAILED(wined3d_device_context_get_stream_source(context
->wined3d_context
, start_slot
+ i
,
1863 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1865 FIXME("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1872 if (!wined3d_buffer
)
1878 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1879 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1881 wined3d_mutex_unlock();
1884 static void STDMETHODCALLTYPE
d3d11_device_context_IAGetIndexBuffer(ID3D11DeviceContext1
*iface
,
1885 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1887 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1888 enum wined3d_format_id wined3d_format
;
1889 struct wined3d_buffer
*wined3d_buffer
;
1890 struct d3d_buffer
*buffer_impl
;
1892 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1894 wined3d_mutex_lock();
1895 wined3d_buffer
= wined3d_device_context_get_index_buffer(context
->wined3d_context
, &wined3d_format
, offset
);
1896 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1897 if (!wined3d_buffer
)
1899 wined3d_mutex_unlock();
1904 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1905 wined3d_mutex_unlock();
1906 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1909 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1910 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1912 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1913 iface
, start_slot
, buffer_count
, buffers
);
1915 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
1916 buffer_count
, buffers
, NULL
, NULL
);
1919 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetShader(ID3D11DeviceContext1
*iface
,
1920 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1922 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1923 struct d3d_geometry_shader
*shader_impl
;
1924 struct wined3d_shader
*wined3d_shader
;
1926 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1927 iface
, shader
, class_instances
, class_instance_count
);
1929 if (class_instance_count
)
1930 *class_instance_count
= 0;
1932 wined3d_mutex_lock();
1933 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
)))
1935 wined3d_mutex_unlock();
1940 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1941 wined3d_mutex_unlock();
1942 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1943 ID3D11GeometryShader_AddRef(*shader
);
1946 static void STDMETHODCALLTYPE
d3d11_device_context_IAGetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
1947 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1949 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1950 enum wined3d_primitive_type primitive_type
;
1951 unsigned int patch_vertex_count
;
1953 TRACE("iface %p, topology %p.\n", iface
, topology
);
1955 wined3d_mutex_lock();
1956 wined3d_device_context_get_primitive_type(context
->wined3d_context
, &primitive_type
, &patch_vertex_count
);
1957 wined3d_mutex_unlock();
1959 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1962 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetShaderResources(ID3D11DeviceContext1
*iface
,
1963 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1965 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1968 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1970 wined3d_mutex_lock();
1971 for (i
= 0; i
< view_count
; ++i
)
1973 struct wined3d_shader_resource_view
*wined3d_view
;
1974 struct d3d_shader_resource_view
*view_impl
;
1976 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
1977 context
->wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
1983 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1984 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1985 ID3D11ShaderResourceView_AddRef(views
[i
]);
1987 wined3d_mutex_unlock();
1990 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetSamplers(ID3D11DeviceContext1
*iface
,
1991 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1993 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1996 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1997 iface
, start_slot
, sampler_count
, samplers
);
1999 wined3d_mutex_lock();
2000 for (i
= 0; i
< sampler_count
; ++i
)
2002 struct wined3d_sampler
*wined3d_sampler
;
2003 struct d3d_sampler_state
*sampler_impl
;
2005 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2006 context
->wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
2012 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2013 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
2014 ID3D11SamplerState_AddRef(samplers
[i
]);
2016 wined3d_mutex_unlock();
2019 static void STDMETHODCALLTYPE
d3d11_device_context_GetPredication(ID3D11DeviceContext1
*iface
,
2020 ID3D11Predicate
**predicate
, BOOL
*value
)
2022 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2023 struct wined3d_query
*wined3d_predicate
;
2024 struct d3d_query
*predicate_impl
;
2026 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
2028 wined3d_mutex_lock();
2029 if (!(wined3d_predicate
= wined3d_device_context_get_predication(context
->wined3d_context
, value
)))
2031 wined3d_mutex_unlock();
2036 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
2037 wined3d_mutex_unlock();
2038 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
2039 ID3D11Predicate_AddRef(*predicate
);
2042 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetShaderResources(ID3D11DeviceContext1
*iface
,
2043 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2045 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2048 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2050 wined3d_mutex_lock();
2051 for (i
= 0; i
< view_count
; ++i
)
2053 struct wined3d_shader_resource_view
*wined3d_view
;
2054 struct d3d_shader_resource_view
*view_impl
;
2056 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2057 context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
2063 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2064 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
2065 ID3D11ShaderResourceView_AddRef(views
[i
]);
2067 wined3d_mutex_unlock();
2070 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetSamplers(ID3D11DeviceContext1
*iface
,
2071 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2073 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2076 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2077 iface
, start_slot
, sampler_count
, samplers
);
2079 wined3d_mutex_lock();
2080 for (i
= 0; i
< sampler_count
; ++i
)
2082 struct d3d_sampler_state
*sampler_impl
;
2083 struct wined3d_sampler
*wined3d_sampler
;
2085 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2086 context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
2092 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2093 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
2094 ID3D11SamplerState_AddRef(samplers
[i
]);
2096 wined3d_mutex_unlock();
2099 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetRenderTargets(ID3D11DeviceContext1
*iface
,
2100 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
2101 ID3D11DepthStencilView
**depth_stencil_view
)
2103 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2104 struct wined3d_rendertarget_view
*wined3d_view
;
2106 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
2107 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
2109 wined3d_mutex_lock();
2110 if (render_target_views
)
2112 struct d3d_rendertarget_view
*view_impl
;
2115 for (i
= 0; i
< render_target_view_count
; ++i
)
2117 if (!(wined3d_view
= wined3d_device_context_get_rendertarget_view(context
->wined3d_context
, i
))
2118 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
2120 render_target_views
[i
] = NULL
;
2124 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
2125 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
2129 if (depth_stencil_view
)
2131 struct d3d_depthstencil_view
*view_impl
;
2133 if (!(wined3d_view
= wined3d_device_context_get_depth_stencil_view(context
->wined3d_context
))
2134 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
2136 *depth_stencil_view
= NULL
;
2140 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
2141 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
2144 wined3d_mutex_unlock();
2147 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetRenderTargetsAndUnorderedAccessViews(
2148 ID3D11DeviceContext1
*iface
,
2149 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
2150 ID3D11DepthStencilView
**depth_stencil_view
,
2151 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
2152 ID3D11UnorderedAccessView
**unordered_access_views
)
2154 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2155 struct wined3d_unordered_access_view
*wined3d_view
;
2156 struct d3d11_unordered_access_view
*view_impl
;
2159 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
2160 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
2161 "unordered_access_views %p.\n",
2162 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
2163 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
2165 if (render_target_views
|| depth_stencil_view
)
2166 d3d11_device_context_OMGetRenderTargets(iface
, render_target_view_count
,
2167 render_target_views
, depth_stencil_view
);
2169 if (unordered_access_views
)
2171 wined3d_mutex_lock();
2172 for (i
= 0; i
< unordered_access_view_count
; ++i
)
2174 if (!(wined3d_view
= wined3d_device_context_get_unordered_access_view(context
->wined3d_context
,
2175 WINED3D_PIPELINE_GRAPHICS
, unordered_access_view_start_slot
+ i
)))
2177 unordered_access_views
[i
] = NULL
;
2181 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2182 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
2183 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
2185 wined3d_mutex_unlock();
2189 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetBlendState(ID3D11DeviceContext1
*iface
,
2190 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
2192 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2193 struct wined3d_blend_state
*wined3d_state
;
2194 struct d3d_blend_state
*blend_state_impl
;
2195 unsigned int tmp_sample_mask
;
2196 float tmp_blend_factor
[4];
2198 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
2199 iface
, blend_state
, blend_factor
, sample_mask
);
2201 wined3d_mutex_lock();
2202 if (!blend_factor
) blend_factor
= tmp_blend_factor
;
2203 if (!sample_mask
) sample_mask
= &tmp_sample_mask
;
2204 wined3d_state
= wined3d_device_context_get_blend_state(context
->wined3d_context
,
2205 (struct wined3d_color
*)blend_factor
, sample_mask
);
2210 blend_state_impl
= wined3d_blend_state_get_parent(wined3d_state
);
2211 ID3D11BlendState_AddRef(*blend_state
= (ID3D11BlendState
*)&blend_state_impl
->ID3D11BlendState1_iface
);
2214 *blend_state
= NULL
;
2216 wined3d_mutex_unlock();
2219 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetDepthStencilState(ID3D11DeviceContext1
*iface
,
2220 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
2222 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2223 struct wined3d_depth_stencil_state
*wined3d_state
;
2224 struct d3d_depthstencil_state
*state_impl
;
2225 UINT stencil_ref_tmp
;
2227 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
2228 iface
, depth_stencil_state
, stencil_ref
);
2230 wined3d_mutex_lock();
2231 if (!stencil_ref
) stencil_ref
= &stencil_ref_tmp
;
2232 wined3d_state
= wined3d_device_context_get_depth_stencil_state(context
->wined3d_context
, stencil_ref
);
2233 if (depth_stencil_state
)
2237 state_impl
= wined3d_depth_stencil_state_get_parent(wined3d_state
);
2238 ID3D11DepthStencilState_AddRef(*depth_stencil_state
= &state_impl
->ID3D11DepthStencilState_iface
);
2242 *depth_stencil_state
= NULL
;
2245 wined3d_mutex_unlock();
2248 static void STDMETHODCALLTYPE
d3d11_device_context_SOGetTargets(ID3D11DeviceContext1
*iface
,
2249 UINT buffer_count
, ID3D11Buffer
**buffers
)
2251 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2254 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
2256 wined3d_mutex_lock();
2257 for (i
= 0; i
< buffer_count
; ++i
)
2259 struct wined3d_buffer
*wined3d_buffer
;
2260 struct d3d_buffer
*buffer_impl
;
2262 if (!(wined3d_buffer
= wined3d_device_context_get_stream_output(context
->wined3d_context
, i
, NULL
)))
2268 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2269 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
2270 ID3D11Buffer_AddRef(buffers
[i
]);
2272 wined3d_mutex_unlock();
2275 static void STDMETHODCALLTYPE
d3d11_device_context_RSGetState(ID3D11DeviceContext1
*iface
,
2276 ID3D11RasterizerState
**rasterizer_state
)
2278 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2279 struct d3d_rasterizer_state
*rasterizer_state_impl
;
2280 struct wined3d_rasterizer_state
*wined3d_state
;
2282 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
2284 wined3d_mutex_lock();
2285 if ((wined3d_state
= wined3d_device_context_get_rasterizer_state(context
->wined3d_context
)))
2287 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
2288 *rasterizer_state
= (ID3D11RasterizerState
*)&rasterizer_state_impl
->ID3D11RasterizerState1_iface
;
2289 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2293 *rasterizer_state
= NULL
;
2295 wined3d_mutex_unlock();
2298 static void STDMETHODCALLTYPE
d3d11_device_context_RSGetViewports(ID3D11DeviceContext1
*iface
,
2299 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
2301 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2302 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
2303 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
2305 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2307 if (!viewport_count
)
2310 wined3d_mutex_lock();
2311 wined3d_device_context_get_viewports(context
->wined3d_context
, &actual_count
, viewports
? wined3d_vp
: NULL
);
2312 wined3d_mutex_unlock();
2316 *viewport_count
= actual_count
;
2320 if (*viewport_count
> actual_count
)
2321 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
2323 *viewport_count
= min(actual_count
, *viewport_count
);
2324 for (i
= 0; i
< *viewport_count
; ++i
)
2326 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
2327 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
2328 viewports
[i
].Width
= wined3d_vp
[i
].width
;
2329 viewports
[i
].Height
= wined3d_vp
[i
].height
;
2330 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
2331 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
2335 static void STDMETHODCALLTYPE
d3d11_device_context_RSGetScissorRects(ID3D11DeviceContext1
*iface
,
2336 UINT
*rect_count
, D3D11_RECT
*rects
)
2338 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2339 unsigned int actual_count
;
2341 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2346 actual_count
= *rect_count
;
2348 wined3d_mutex_lock();
2349 wined3d_device_context_get_scissor_rects(context
->wined3d_context
, &actual_count
, rects
);
2350 wined3d_mutex_unlock();
2352 if (rects
&& *rect_count
> actual_count
)
2353 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
2354 *rect_count
= actual_count
;
2357 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetShaderResources(ID3D11DeviceContext1
*iface
,
2358 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2360 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2363 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2365 wined3d_mutex_lock();
2366 for (i
= 0; i
< view_count
; ++i
)
2368 struct wined3d_shader_resource_view
*wined3d_view
;
2369 struct d3d_shader_resource_view
*view_impl
;
2371 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2372 context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
, start_slot
+ i
)))
2378 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2379 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2381 wined3d_mutex_unlock();
2384 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetShader(ID3D11DeviceContext1
*iface
,
2385 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2387 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2388 struct d3d11_hull_shader
*shader_impl
;
2389 struct wined3d_shader
*wined3d_shader
;
2391 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2392 iface
, shader
, class_instances
, class_instance_count
);
2394 if (class_instance_count
)
2395 *class_instance_count
= 0;
2397 wined3d_mutex_lock();
2398 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
)))
2400 wined3d_mutex_unlock();
2405 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2406 wined3d_mutex_unlock();
2407 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2410 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetSamplers(ID3D11DeviceContext1
*iface
,
2411 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2413 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2416 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2417 iface
, start_slot
, sampler_count
, samplers
);
2419 wined3d_mutex_lock();
2420 for (i
= 0; i
< sampler_count
; ++i
)
2422 struct wined3d_sampler
*wined3d_sampler
;
2423 struct d3d_sampler_state
*sampler_impl
;
2425 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2426 context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
, start_slot
+ i
)))
2432 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2433 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2435 wined3d_mutex_unlock();
2438 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2439 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2441 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2442 iface
, start_slot
, buffer_count
, buffers
);
2444 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2445 buffer_count
, buffers
, NULL
, NULL
);
2448 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetShaderResources(ID3D11DeviceContext1
*iface
,
2449 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2451 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2454 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2455 iface
, start_slot
, view_count
, views
);
2457 wined3d_mutex_lock();
2458 for (i
= 0; i
< view_count
; ++i
)
2460 struct wined3d_shader_resource_view
*wined3d_view
;
2461 struct d3d_shader_resource_view
*view_impl
;
2463 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2464 context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
+ i
)))
2470 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2471 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2473 wined3d_mutex_unlock();
2476 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetShader(ID3D11DeviceContext1
*iface
,
2477 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2479 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2480 struct d3d11_domain_shader
*shader_impl
;
2481 struct wined3d_shader
*wined3d_shader
;
2483 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2484 iface
, shader
, class_instances
, class_instance_count
);
2486 if (class_instance_count
)
2487 *class_instance_count
= 0;
2489 wined3d_mutex_lock();
2490 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
)))
2492 wined3d_mutex_unlock();
2497 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2498 wined3d_mutex_unlock();
2499 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2502 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetSamplers(ID3D11DeviceContext1
*iface
,
2503 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2505 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2508 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2509 iface
, start_slot
, sampler_count
, samplers
);
2511 wined3d_mutex_lock();
2512 for (i
= 0; i
< sampler_count
; ++i
)
2514 struct wined3d_sampler
*wined3d_sampler
;
2515 struct d3d_sampler_state
*sampler_impl
;
2517 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2518 context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
+ i
)))
2524 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2525 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2527 wined3d_mutex_unlock();
2530 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2531 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2533 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2534 iface
, start_slot
, buffer_count
, buffers
);
2536 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2537 buffer_count
, buffers
, NULL
, NULL
);
2540 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetShaderResources(ID3D11DeviceContext1
*iface
,
2541 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2543 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2546 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2548 wined3d_mutex_lock();
2549 for (i
= 0; i
< view_count
; ++i
)
2551 struct wined3d_shader_resource_view
*wined3d_view
;
2552 struct d3d_shader_resource_view
*view_impl
;
2554 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2555 context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
+ i
)))
2561 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2562 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2564 wined3d_mutex_unlock();
2567 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
2568 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2570 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2573 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2575 wined3d_mutex_lock();
2576 for (i
= 0; i
< view_count
; ++i
)
2578 struct wined3d_unordered_access_view
*wined3d_view
;
2579 struct d3d11_unordered_access_view
*view_impl
;
2581 if (!(wined3d_view
= wined3d_device_context_get_unordered_access_view(
2582 context
->wined3d_context
, WINED3D_PIPELINE_COMPUTE
, start_slot
+ i
)))
2588 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2589 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2591 wined3d_mutex_unlock();
2594 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetShader(ID3D11DeviceContext1
*iface
,
2595 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2597 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2598 struct d3d11_compute_shader
*shader_impl
;
2599 struct wined3d_shader
*wined3d_shader
;
2601 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2602 iface
, shader
, class_instances
, class_instance_count
);
2604 if (class_instance_count
)
2605 *class_instance_count
= 0;
2607 wined3d_mutex_lock();
2608 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
)))
2610 wined3d_mutex_unlock();
2615 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2616 wined3d_mutex_unlock();
2617 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2620 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetSamplers(ID3D11DeviceContext1
*iface
,
2621 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2623 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2626 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2627 iface
, start_slot
, sampler_count
, samplers
);
2629 wined3d_mutex_lock();
2630 for (i
= 0; i
< sampler_count
; ++i
)
2632 struct wined3d_sampler
*wined3d_sampler
;
2633 struct d3d_sampler_state
*sampler_impl
;
2635 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2636 context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
+ i
)))
2642 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2643 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2645 wined3d_mutex_unlock();
2648 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2649 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2651 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2652 iface
, start_slot
, buffer_count
, buffers
);
2654 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2655 buffer_count
, buffers
, NULL
, NULL
);
2658 static void STDMETHODCALLTYPE
d3d11_device_context_ClearState(ID3D11DeviceContext1
*iface
)
2660 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2662 TRACE("iface %p.\n", iface
);
2664 wined3d_device_context_reset_state(context
->wined3d_context
);
2667 static void STDMETHODCALLTYPE
d3d11_device_context_Flush(ID3D11DeviceContext1
*iface
)
2669 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2671 TRACE("iface %p.\n", iface
);
2673 wined3d_device_context_flush(context
->wined3d_context
);
2676 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_device_context_GetType(ID3D11DeviceContext1
*iface
)
2678 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2680 TRACE("iface %p.\n", iface
);
2682 return context
->type
;
2685 static UINT STDMETHODCALLTYPE
d3d11_device_context_GetContextFlags(ID3D11DeviceContext1
*iface
)
2687 TRACE("iface %p.\n", iface
);
2692 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_FinishCommandList(ID3D11DeviceContext1
*iface
,
2693 BOOL restore
, ID3D11CommandList
**command_list
)
2695 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2696 struct d3d11_command_list
*object
;
2699 TRACE("iface %p, restore %#x, command_list %p.\n", iface
, restore
, command_list
);
2701 if (context
->type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
)
2703 WARN("Attempt to record command list on an immediate context; returning DXGI_ERROR_INVALID_CALL.\n");
2704 return DXGI_ERROR_INVALID_CALL
;
2707 if (!(object
= calloc(1, sizeof(*object
))))
2708 return E_OUTOFMEMORY
;
2710 if (FAILED(hr
= wined3d_deferred_context_record_command_list(context
->wined3d_context
,
2711 !!restore
, &object
->wined3d_list
)))
2713 WARN("Failed to record wined3d command list, hr %#lx.\n", hr
);
2718 object
->ID3D11CommandList_iface
.lpVtbl
= &d3d11_command_list_vtbl
;
2719 object
->refcount
= 1;
2720 object
->device
= &context
->device
->ID3D11Device2_iface
;
2721 wined3d_private_store_init(&object
->private_store
);
2723 ID3D11Device2_AddRef(object
->device
);
2725 TRACE("Created command list %p.\n", object
);
2726 *command_list
= &object
->ID3D11CommandList_iface
;
2731 static void STDMETHODCALLTYPE
d3d11_device_context_CopySubresourceRegion1(ID3D11DeviceContext1
*iface
,
2732 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
2733 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
, UINT flags
)
2735 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2736 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
2737 struct wined3d_box wined3d_src_box
;
2739 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
2740 "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n",
2741 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
2742 src_resource
, src_subresource_idx
, src_box
, flags
);
2744 if (!dst_resource
|| !src_resource
)
2748 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
2749 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
2751 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
2752 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
2753 wined3d_device_context_copy_sub_resource_region(context
->wined3d_context
, wined3d_dst_resource
, dst_subresource_idx
,
2754 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, flags
);
2757 static void STDMETHODCALLTYPE
d3d11_device_context_UpdateSubresource1(ID3D11DeviceContext1
*iface
,
2758 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
, const void *data
,
2759 UINT row_pitch
, UINT depth_pitch
, UINT flags
)
2761 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2762 struct wined3d_resource
*wined3d_resource
;
2763 struct wined3d_box wined3d_box
;
2765 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n",
2766 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
, flags
);
2769 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
,
2770 box
->front
, box
->back
);
2772 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
2773 wined3d_device_context_update_sub_resource(context
->wined3d_context
, wined3d_resource
, subresource_idx
,
2774 box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, flags
);
2777 static void STDMETHODCALLTYPE
d3d11_device_context_DiscardResource(ID3D11DeviceContext1
*iface
,
2778 ID3D11Resource
*resource
)
2780 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
2783 static void STDMETHODCALLTYPE
d3d11_device_context_DiscardView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
)
2785 FIXME("iface %p, view %p stub!\n", iface
, view
);
2788 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2789 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2790 const UINT
*num_constants
)
2792 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2793 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2795 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
2796 buffer_count
, buffers
, first_constant
, num_constants
);
2799 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2800 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2801 const UINT
*num_constants
)
2803 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2804 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2806 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2807 buffer_count
, buffers
, first_constant
, num_constants
);
2810 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2811 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2812 const UINT
*num_constants
)
2814 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2815 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2817 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2818 buffer_count
, buffers
, first_constant
, num_constants
);
2821 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2822 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2823 const UINT
*num_constants
)
2825 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2826 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2828 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
2829 buffer_count
, buffers
, first_constant
, num_constants
);
2832 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2833 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2834 const UINT
*num_constants
)
2836 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2837 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2839 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
2840 buffer_count
, buffers
, first_constant
, num_constants
);
2843 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2844 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2845 const UINT
*num_constants
)
2847 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2848 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2850 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2851 buffer_count
, buffers
, first_constant
, num_constants
);
2854 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2855 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2857 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2858 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2860 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
2861 buffer_count
, buffers
, first_constant
, num_constants
);
2864 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2865 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2867 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2868 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2870 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2871 buffer_count
, buffers
, first_constant
, num_constants
);
2874 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2875 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2877 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2878 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2880 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2881 buffer_count
, buffers
, first_constant
, num_constants
);
2884 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2885 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2887 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2888 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2890 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
2891 buffer_count
, buffers
, first_constant
, num_constants
);
2894 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2895 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2897 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2898 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2900 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
2901 buffer_count
, buffers
, first_constant
, num_constants
);
2904 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2905 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2907 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2908 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2910 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2911 buffer_count
, buffers
, first_constant
, num_constants
);
2914 static void STDMETHODCALLTYPE
d3d11_device_context_SwapDeviceContextState(ID3D11DeviceContext1
*iface
,
2915 ID3DDeviceContextState
*state
, ID3DDeviceContextState
**prev
)
2917 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2918 struct d3d_device_context_state
*state_impl
, *prev_impl
;
2919 struct d3d_device
*device
= context
->device
;
2920 struct wined3d_state
*wined3d_state
;
2921 static unsigned int once
;
2923 TRACE("iface %p, state %p, prev %p.\n", iface
, state
, prev
);
2928 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
)
2930 WARN("SwapDeviceContextState is not allowed on a deferred context.\n");
2937 wined3d_mutex_lock();
2939 prev_impl
= device
->state
;
2940 state_impl
= impl_from_ID3DDeviceContextState(state
);
2941 if (!(wined3d_state
= d3d_device_context_state_get_wined3d_state(state_impl
, device
)))
2942 ERR("Failed to get wined3d state for device context state %p.\n", state_impl
);
2943 wined3d_device_context_set_state(context
->wined3d_context
, wined3d_state
);
2946 ID3DDeviceContextState_AddRef(*prev
= &prev_impl
->ID3DDeviceContextState_iface
);
2948 d3d_device_context_state_private_addref(state_impl
);
2949 device
->state
= state_impl
;
2950 d3d_device_context_state_private_release(prev_impl
);
2952 if (d3d_device_is_d3d10_active(device
) && !once
++)
2953 FIXME("D3D10 interface emulation not fully implemented yet!\n");
2954 wined3d_mutex_unlock();
2957 static void STDMETHODCALLTYPE
d3d11_device_context_ClearView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2958 const FLOAT color
[4], const D3D11_RECT
*rect
, UINT num_rects
)
2960 FIXME("iface %p, view %p, color %p, rect %p, num_rects %u stub!\n", iface
, view
, color
, rect
, num_rects
);
2963 static void STDMETHODCALLTYPE
d3d11_device_context_DiscardView1(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2964 const D3D11_RECT
*rects
, UINT num_rects
)
2966 FIXME("iface %p, view %p, rects %p, num_rects %u stub!\n", iface
, view
, rects
, num_rects
);
2969 static const struct ID3D11DeviceContext1Vtbl d3d11_device_context_vtbl
=
2971 /* IUnknown methods */
2972 d3d11_device_context_QueryInterface
,
2973 d3d11_device_context_AddRef
,
2974 d3d11_device_context_Release
,
2975 /* ID3D11DeviceChild methods */
2976 d3d11_device_context_GetDevice
,
2977 d3d11_device_context_GetPrivateData
,
2978 d3d11_device_context_SetPrivateData
,
2979 d3d11_device_context_SetPrivateDataInterface
,
2980 /* ID3D11DeviceContext methods */
2981 d3d11_device_context_VSSetConstantBuffers
,
2982 d3d11_device_context_PSSetShaderResources
,
2983 d3d11_device_context_PSSetShader
,
2984 d3d11_device_context_PSSetSamplers
,
2985 d3d11_device_context_VSSetShader
,
2986 d3d11_device_context_DrawIndexed
,
2987 d3d11_device_context_Draw
,
2988 d3d11_device_context_Map
,
2989 d3d11_device_context_Unmap
,
2990 d3d11_device_context_PSSetConstantBuffers
,
2991 d3d11_device_context_IASetInputLayout
,
2992 d3d11_device_context_IASetVertexBuffers
,
2993 d3d11_device_context_IASetIndexBuffer
,
2994 d3d11_device_context_DrawIndexedInstanced
,
2995 d3d11_device_context_DrawInstanced
,
2996 d3d11_device_context_GSSetConstantBuffers
,
2997 d3d11_device_context_GSSetShader
,
2998 d3d11_device_context_IASetPrimitiveTopology
,
2999 d3d11_device_context_VSSetShaderResources
,
3000 d3d11_device_context_VSSetSamplers
,
3001 d3d11_device_context_Begin
,
3002 d3d11_device_context_End
,
3003 d3d11_device_context_GetData
,
3004 d3d11_device_context_SetPredication
,
3005 d3d11_device_context_GSSetShaderResources
,
3006 d3d11_device_context_GSSetSamplers
,
3007 d3d11_device_context_OMSetRenderTargets
,
3008 d3d11_device_context_OMSetRenderTargetsAndUnorderedAccessViews
,
3009 d3d11_device_context_OMSetBlendState
,
3010 d3d11_device_context_OMSetDepthStencilState
,
3011 d3d11_device_context_SOSetTargets
,
3012 d3d11_device_context_DrawAuto
,
3013 d3d11_device_context_DrawIndexedInstancedIndirect
,
3014 d3d11_device_context_DrawInstancedIndirect
,
3015 d3d11_device_context_Dispatch
,
3016 d3d11_device_context_DispatchIndirect
,
3017 d3d11_device_context_RSSetState
,
3018 d3d11_device_context_RSSetViewports
,
3019 d3d11_device_context_RSSetScissorRects
,
3020 d3d11_device_context_CopySubresourceRegion
,
3021 d3d11_device_context_CopyResource
,
3022 d3d11_device_context_UpdateSubresource
,
3023 d3d11_device_context_CopyStructureCount
,
3024 d3d11_device_context_ClearRenderTargetView
,
3025 d3d11_device_context_ClearUnorderedAccessViewUint
,
3026 d3d11_device_context_ClearUnorderedAccessViewFloat
,
3027 d3d11_device_context_ClearDepthStencilView
,
3028 d3d11_device_context_GenerateMips
,
3029 d3d11_device_context_SetResourceMinLOD
,
3030 d3d11_device_context_GetResourceMinLOD
,
3031 d3d11_device_context_ResolveSubresource
,
3032 d3d11_device_context_ExecuteCommandList
,
3033 d3d11_device_context_HSSetShaderResources
,
3034 d3d11_device_context_HSSetShader
,
3035 d3d11_device_context_HSSetSamplers
,
3036 d3d11_device_context_HSSetConstantBuffers
,
3037 d3d11_device_context_DSSetShaderResources
,
3038 d3d11_device_context_DSSetShader
,
3039 d3d11_device_context_DSSetSamplers
,
3040 d3d11_device_context_DSSetConstantBuffers
,
3041 d3d11_device_context_CSSetShaderResources
,
3042 d3d11_device_context_CSSetUnorderedAccessViews
,
3043 d3d11_device_context_CSSetShader
,
3044 d3d11_device_context_CSSetSamplers
,
3045 d3d11_device_context_CSSetConstantBuffers
,
3046 d3d11_device_context_VSGetConstantBuffers
,
3047 d3d11_device_context_PSGetShaderResources
,
3048 d3d11_device_context_PSGetShader
,
3049 d3d11_device_context_PSGetSamplers
,
3050 d3d11_device_context_VSGetShader
,
3051 d3d11_device_context_PSGetConstantBuffers
,
3052 d3d11_device_context_IAGetInputLayout
,
3053 d3d11_device_context_IAGetVertexBuffers
,
3054 d3d11_device_context_IAGetIndexBuffer
,
3055 d3d11_device_context_GSGetConstantBuffers
,
3056 d3d11_device_context_GSGetShader
,
3057 d3d11_device_context_IAGetPrimitiveTopology
,
3058 d3d11_device_context_VSGetShaderResources
,
3059 d3d11_device_context_VSGetSamplers
,
3060 d3d11_device_context_GetPredication
,
3061 d3d11_device_context_GSGetShaderResources
,
3062 d3d11_device_context_GSGetSamplers
,
3063 d3d11_device_context_OMGetRenderTargets
,
3064 d3d11_device_context_OMGetRenderTargetsAndUnorderedAccessViews
,
3065 d3d11_device_context_OMGetBlendState
,
3066 d3d11_device_context_OMGetDepthStencilState
,
3067 d3d11_device_context_SOGetTargets
,
3068 d3d11_device_context_RSGetState
,
3069 d3d11_device_context_RSGetViewports
,
3070 d3d11_device_context_RSGetScissorRects
,
3071 d3d11_device_context_HSGetShaderResources
,
3072 d3d11_device_context_HSGetShader
,
3073 d3d11_device_context_HSGetSamplers
,
3074 d3d11_device_context_HSGetConstantBuffers
,
3075 d3d11_device_context_DSGetShaderResources
,
3076 d3d11_device_context_DSGetShader
,
3077 d3d11_device_context_DSGetSamplers
,
3078 d3d11_device_context_DSGetConstantBuffers
,
3079 d3d11_device_context_CSGetShaderResources
,
3080 d3d11_device_context_CSGetUnorderedAccessViews
,
3081 d3d11_device_context_CSGetShader
,
3082 d3d11_device_context_CSGetSamplers
,
3083 d3d11_device_context_CSGetConstantBuffers
,
3084 d3d11_device_context_ClearState
,
3085 d3d11_device_context_Flush
,
3086 d3d11_device_context_GetType
,
3087 d3d11_device_context_GetContextFlags
,
3088 d3d11_device_context_FinishCommandList
,
3089 /* ID3D11DeviceContext1 methods */
3090 d3d11_device_context_CopySubresourceRegion1
,
3091 d3d11_device_context_UpdateSubresource1
,
3092 d3d11_device_context_DiscardResource
,
3093 d3d11_device_context_DiscardView
,
3094 d3d11_device_context_VSSetConstantBuffers1
,
3095 d3d11_device_context_HSSetConstantBuffers1
,
3096 d3d11_device_context_DSSetConstantBuffers1
,
3097 d3d11_device_context_GSSetConstantBuffers1
,
3098 d3d11_device_context_PSSetConstantBuffers1
,
3099 d3d11_device_context_CSSetConstantBuffers1
,
3100 d3d11_device_context_VSGetConstantBuffers1
,
3101 d3d11_device_context_HSGetConstantBuffers1
,
3102 d3d11_device_context_DSGetConstantBuffers1
,
3103 d3d11_device_context_GSGetConstantBuffers1
,
3104 d3d11_device_context_PSGetConstantBuffers1
,
3105 d3d11_device_context_CSGetConstantBuffers1
,
3106 d3d11_device_context_SwapDeviceContextState
,
3107 d3d11_device_context_ClearView
,
3108 d3d11_device_context_DiscardView1
,
3111 /* ID3D11Multithread methods */
3113 static inline struct d3d11_device_context
*impl_from_ID3D11Multithread(ID3D11Multithread
*iface
)
3115 return CONTAINING_RECORD(iface
, struct d3d11_device_context
, ID3D11Multithread_iface
);
3118 static HRESULT STDMETHODCALLTYPE
d3d11_multithread_QueryInterface(ID3D11Multithread
*iface
,
3119 REFIID iid
, void **out
)
3121 struct d3d11_device_context
*context
= impl_from_ID3D11Multithread(iface
);
3123 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
3125 return d3d11_device_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
3128 static ULONG STDMETHODCALLTYPE
d3d11_multithread_AddRef(ID3D11Multithread
*iface
)
3130 struct d3d11_device_context
*context
= impl_from_ID3D11Multithread(iface
);
3132 TRACE("iface %p.\n", iface
);
3134 return d3d11_device_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
3137 static ULONG STDMETHODCALLTYPE
d3d11_multithread_Release(ID3D11Multithread
*iface
)
3139 struct d3d11_device_context
*context
= impl_from_ID3D11Multithread(iface
);
3141 TRACE("iface %p.\n", iface
);
3143 return d3d11_device_context_Release(&context
->ID3D11DeviceContext1_iface
);
3146 static void STDMETHODCALLTYPE
d3d11_multithread_Enter(ID3D11Multithread
*iface
)
3148 TRACE("iface %p.\n", iface
);
3150 wined3d_mutex_lock();
3153 static void STDMETHODCALLTYPE
d3d11_multithread_Leave(ID3D11Multithread
*iface
)
3155 TRACE("iface %p.\n", iface
);
3157 wined3d_mutex_unlock();
3160 static BOOL STDMETHODCALLTYPE
d3d11_multithread_SetMultithreadProtected(
3161 ID3D11Multithread
*iface
, BOOL enable
)
3163 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
3168 static BOOL STDMETHODCALLTYPE
d3d11_multithread_GetMultithreadProtected(ID3D11Multithread
*iface
)
3170 FIXME("iface %p stub!\n", iface
);
3175 static const struct ID3D11MultithreadVtbl d3d11_multithread_vtbl
=
3177 d3d11_multithread_QueryInterface
,
3178 d3d11_multithread_AddRef
,
3179 d3d11_multithread_Release
,
3180 d3d11_multithread_Enter
,
3181 d3d11_multithread_Leave
,
3182 d3d11_multithread_SetMultithreadProtected
,
3183 d3d11_multithread_GetMultithreadProtected
,
3186 /* ID3DUserDefinedAnnotation methods */
3188 static inline struct d3d11_device_context
*impl_from_ID3DUserDefinedAnnotation(ID3DUserDefinedAnnotation
*iface
)
3190 return CONTAINING_RECORD(iface
, struct d3d11_device_context
, ID3DUserDefinedAnnotation_iface
);
3193 static HRESULT STDMETHODCALLTYPE
d3d11_user_defined_annotation_QueryInterface(ID3DUserDefinedAnnotation
*iface
,
3194 REFIID iid
, void **out
)
3196 struct d3d11_device_context
*context
= impl_from_ID3DUserDefinedAnnotation(iface
);
3198 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
3200 return d3d11_device_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
3203 static ULONG STDMETHODCALLTYPE
d3d11_user_defined_annotation_AddRef(ID3DUserDefinedAnnotation
*iface
)
3205 struct d3d11_device_context
*context
= impl_from_ID3DUserDefinedAnnotation(iface
);
3207 TRACE("iface %p.\n", iface
);
3209 return d3d11_device_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
3212 static ULONG STDMETHODCALLTYPE
d3d11_user_defined_annotation_Release(ID3DUserDefinedAnnotation
*iface
)
3214 struct d3d11_device_context
*context
= impl_from_ID3DUserDefinedAnnotation(iface
);
3216 TRACE("iface %p.\n", iface
);
3218 return d3d11_device_context_Release(&context
->ID3D11DeviceContext1_iface
);
3221 static int STDMETHODCALLTYPE
d3d11_user_defined_annotation_BeginEvent(ID3DUserDefinedAnnotation
*iface
,
3224 TRACE("iface %p, name %s.\n", iface
, debugstr_w(name
));
3229 static int STDMETHODCALLTYPE
d3d11_user_defined_annotation_EndEvent(ID3DUserDefinedAnnotation
*iface
)
3231 TRACE("iface %p.\n", iface
);
3236 static void STDMETHODCALLTYPE
d3d11_user_defined_annotation_SetMarker(ID3DUserDefinedAnnotation
*iface
,
3239 TRACE("iface %p, name %s.\n", iface
, debugstr_w(name
));
3242 static BOOL STDMETHODCALLTYPE
d3d11_user_defined_annotation_GetStatus(ID3DUserDefinedAnnotation
*iface
)
3244 TRACE("iface %p.\n", iface
);
3249 static const struct ID3DUserDefinedAnnotationVtbl d3d11_user_defined_annotation_vtbl
=
3251 d3d11_user_defined_annotation_QueryInterface
,
3252 d3d11_user_defined_annotation_AddRef
,
3253 d3d11_user_defined_annotation_Release
,
3254 d3d11_user_defined_annotation_BeginEvent
,
3255 d3d11_user_defined_annotation_EndEvent
,
3256 d3d11_user_defined_annotation_SetMarker
,
3257 d3d11_user_defined_annotation_GetStatus
,
3260 static void d3d11_device_context_init(struct d3d11_device_context
*context
, struct d3d_device
*device
,
3261 D3D11_DEVICE_CONTEXT_TYPE type
)
3263 context
->ID3D11DeviceContext1_iface
.lpVtbl
= &d3d11_device_context_vtbl
;
3264 context
->ID3D11Multithread_iface
.lpVtbl
= &d3d11_multithread_vtbl
;
3265 context
->ID3DUserDefinedAnnotation_iface
.lpVtbl
= &d3d11_user_defined_annotation_vtbl
;
3266 context
->refcount
= 1;
3267 context
->type
= type
;
3269 context
->device
= device
;
3270 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
3272 wined3d_private_store_init(&context
->private_store
);
3275 /* ID3D11Device methods */
3277 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device2
*iface
, REFIID iid
, void **out
)
3279 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3280 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
3283 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device2
*iface
)
3285 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3286 return IUnknown_AddRef(device
->outer_unk
);
3289 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device2
*iface
)
3291 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3292 return IUnknown_Release(device
->outer_unk
);
3295 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device2
*iface
, const D3D11_BUFFER_DESC
*desc
,
3296 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
3298 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3299 struct d3d_buffer
*object
;
3302 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
3304 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
3307 *buffer
= &object
->ID3D11Buffer_iface
;
3312 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device2
*iface
,
3313 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
3315 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3316 struct d3d_texture1d
*object
;
3319 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3321 if (FAILED(hr
= d3d_texture1d_create(device
, desc
, data
, &object
)))
3324 *texture
= &object
->ID3D11Texture1D_iface
;
3329 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device2
*iface
,
3330 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
3332 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3333 struct d3d_texture2d
*object
;
3336 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3338 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, NULL
, data
, &object
)))
3341 *texture
= &object
->ID3D11Texture2D_iface
;
3346 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device2
*iface
,
3347 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
3349 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3350 struct d3d_texture3d
*object
;
3353 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3355 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
3358 *texture
= &object
->ID3D11Texture3D_iface
;
3363 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device2
*iface
,
3364 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
3366 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3367 struct d3d_shader_resource_view
*object
;
3370 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3375 return E_INVALIDARG
;
3377 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
3380 *view
= &object
->ID3D11ShaderResourceView_iface
;
3385 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device2
*iface
,
3386 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
3388 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3389 struct d3d11_unordered_access_view
*object
;
3392 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3396 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
3399 *view
= &object
->ID3D11UnorderedAccessView_iface
;
3404 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device2
*iface
,
3405 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
3407 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3408 struct d3d_rendertarget_view
*object
;
3411 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3416 return E_INVALIDARG
;
3418 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
3421 *view
= &object
->ID3D11RenderTargetView_iface
;
3426 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device2
*iface
,
3427 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
3429 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3430 struct d3d_depthstencil_view
*object
;
3433 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3437 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
3440 *view
= &object
->ID3D11DepthStencilView_iface
;
3445 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device2
*iface
,
3446 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
3447 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
3449 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3450 struct d3d_input_layout
*object
;
3453 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %Iu, "
3454 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
3455 shader_byte_code_length
, input_layout
);
3457 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
3458 shader_byte_code
, shader_byte_code_length
, &object
)))
3461 *input_layout
= &object
->ID3D11InputLayout_iface
;
3466 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device2
*iface
, const void *byte_code
,
3467 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
3469 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3470 struct d3d_vertex_shader
*object
;
3473 TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
3474 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3479 FIXME("Class linkage is not implemented yet.\n");
3481 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3484 *shader
= &object
->ID3D11VertexShader_iface
;
3489 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device2
*iface
, const void *byte_code
,
3490 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3492 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3493 struct d3d_geometry_shader
*object
;
3496 TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
3497 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3502 FIXME("Class linkage is not implemented yet.\n");
3504 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3505 NULL
, 0, NULL
, 0, 0, &object
)))
3508 *shader
= &object
->ID3D11GeometryShader_iface
;
3513 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2
*iface
,
3514 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
3515 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
3516 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3518 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3519 struct d3d_geometry_shader
*object
;
3522 TRACE("iface %p, byte_code %p, byte_code_length %Iu, so_entries %p, entry_count %u, "
3523 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
3524 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
3525 rasterizer_stream
, class_linkage
, shader
);
3530 FIXME("Class linkage is not implemented yet.\n");
3532 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3533 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
3538 *shader
= &object
->ID3D11GeometryShader_iface
;
3543 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device2
*iface
, const void *byte_code
,
3544 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
3546 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3547 struct d3d_pixel_shader
*object
;
3550 TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
3551 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3556 FIXME("Class linkage is not implemented yet.\n");
3558 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3561 *shader
= &object
->ID3D11PixelShader_iface
;
3566 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device2
*iface
, const void *byte_code
,
3567 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
3569 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3570 struct d3d11_hull_shader
*object
;
3573 TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
3574 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3579 FIXME("Class linkage is not implemented yet.\n");
3581 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3584 *shader
= &object
->ID3D11HullShader_iface
;
3589 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device2
*iface
, const void *byte_code
,
3590 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
3592 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3593 struct d3d11_domain_shader
*object
;
3596 TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
3597 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3602 FIXME("Class linkage is not implemented yet.\n");
3604 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3607 *shader
= &object
->ID3D11DomainShader_iface
;
3612 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device2
*iface
, const void *byte_code
,
3613 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
3615 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3616 struct d3d11_compute_shader
*object
;
3619 TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
3620 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3625 FIXME("Class linkage is not implemented yet.\n");
3627 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3630 *shader
= &object
->ID3D11ComputeShader_iface
;
3635 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device2
*iface
,
3636 ID3D11ClassLinkage
**class_linkage
)
3638 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3639 struct d3d11_class_linkage
*object
;
3642 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3644 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3647 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3652 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState1(ID3D11Device2
*iface
,
3653 const D3D11_BLEND_DESC1
*desc
, ID3D11BlendState1
**state
)
3655 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3656 struct d3d_blend_state
*object
;
3659 TRACE("iface %p, desc %p, state %p.\n", iface
, desc
, state
);
3661 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3664 *state
= &object
->ID3D11BlendState1_iface
;
3669 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device2
*iface
,
3670 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3672 D3D11_BLEND_DESC1 d3d11_1_desc
;
3675 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3678 return E_INVALIDARG
;
3680 d3d11_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
3681 d3d11_1_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
3682 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3684 d3d11_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[i
].BlendEnable
;
3685 d3d11_1_desc
.RenderTarget
[i
].LogicOpEnable
= FALSE
;
3686 d3d11_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[i
].SrcBlend
;
3687 d3d11_1_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[i
].DestBlend
;
3688 d3d11_1_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[i
].BlendOp
;
3689 d3d11_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[i
].SrcBlendAlpha
;
3690 d3d11_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[i
].DestBlendAlpha
;
3691 d3d11_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[i
].BlendOpAlpha
;
3692 d3d11_1_desc
.RenderTarget
[i
].LogicOp
= D3D11_LOGIC_OP_COPY
;
3693 d3d11_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[i
].RenderTargetWriteMask
;
3696 return d3d11_device_CreateBlendState1(iface
, &d3d11_1_desc
, (ID3D11BlendState1
**)blend_state
);
3699 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device2
*iface
,
3700 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3702 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3703 struct d3d_depthstencil_state
*object
;
3706 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3708 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3711 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3716 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device2
*iface
,
3717 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3719 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3720 struct d3d_rasterizer_state
*object
;
3721 D3D11_RASTERIZER_DESC1 desc1
;
3724 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3727 return E_INVALIDARG
;
3729 memcpy(&desc1
, desc
, sizeof(*desc
));
3730 desc1
.ForcedSampleCount
= 0;
3732 if (FAILED(hr
= d3d_rasterizer_state_create(device
, &desc1
, &object
)))
3735 *rasterizer_state
= (ID3D11RasterizerState
*)&object
->ID3D11RasterizerState1_iface
;
3740 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device2
*iface
,
3741 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3743 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3744 struct d3d_sampler_state
*object
;
3747 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3749 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3752 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3757 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device2
*iface
,
3758 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3760 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3761 struct d3d_query
*object
;
3764 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3766 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3771 *query
= &object
->ID3D11Query_iface
;
3775 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3779 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device2
*iface
, const D3D11_QUERY_DESC
*desc
,
3780 ID3D11Predicate
**predicate
)
3782 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3783 struct d3d_query
*object
;
3786 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3788 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3793 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3797 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3801 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3802 ID3D11Counter
**counter
)
3804 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3809 static HRESULT
d3d11_deferred_context_create(struct d3d_device
*device
,
3810 UINT flags
, struct d3d11_device_context
**context
)
3812 struct d3d11_device_context
*object
;
3816 FIXME("Ignoring flags %#x.\n", flags
);
3818 if (!(object
= calloc(1, sizeof(*object
))))
3819 return E_OUTOFMEMORY
;
3820 d3d11_device_context_init(object
, device
, D3D11_DEVICE_CONTEXT_DEFERRED
);
3822 if (FAILED(hr
= wined3d_deferred_context_create(device
->wined3d_device
, &object
->wined3d_context
)))
3824 WARN("Failed to create wined3d deferred context, hr %#lx.\n", hr
);
3829 TRACE("Created deferred context %p.\n", object
);
3835 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device2
*iface
, UINT flags
,
3836 ID3D11DeviceContext
**context
)
3838 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3839 struct d3d11_device_context
*object
;
3842 TRACE("iface %p, flags %#x, context %p.\n", iface
, flags
, context
);
3844 if (FAILED(hr
= d3d11_deferred_context_create(device
, flags
, &object
)))
3847 *context
= (ID3D11DeviceContext
*)&object
->ID3D11DeviceContext1_iface
;
3851 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device2
*iface
, HANDLE resource
, REFIID iid
,
3854 FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface
, resource
, debugstr_guid(iid
), out
);
3859 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device2
*iface
, DXGI_FORMAT format
,
3860 UINT
*format_support
)
3862 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3863 struct wined3d_device_creation_parameters params
;
3864 struct wined3d_adapter
*wined3d_adapter
;
3865 enum wined3d_format_id wined3d_format
;
3866 D3D_FEATURE_LEVEL feature_level
;
3867 struct wined3d
*wined3d
;
3872 enum wined3d_resource_type rtype
;
3873 unsigned int bind_flags
;
3875 D3D11_FORMAT_SUPPORT flag
;
3879 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_BUFFER
},
3880 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_VERTEX_BUFFER
, 0, D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER
},
3881 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_INDEX_BUFFER
, 0, D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
},
3882 {WINED3D_RTYPE_TEXTURE_1D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE1D
},
3883 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3884 {WINED3D_RTYPE_TEXTURE_3D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3885 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, 0, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3886 {WINED3D_RTYPE_NONE
, WINED3D_BIND_DEPTH_STENCIL
, 0, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3887 {WINED3D_RTYPE_NONE
, WINED3D_BIND_UNORDERED_ACCESS
, 0, D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW
},
3888 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_WRAPANDMIP
, D3D11_FORMAT_SUPPORT_MIP
},
3889 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_GENMIPMAP
, D3D11_FORMAT_SUPPORT_MIP_AUTOGEN
},
3890 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_RENDER_TARGET
, WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
, D3D11_FORMAT_SUPPORT_BLENDABLE
},
3894 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3896 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3897 if (format
&& !wined3d_format
)
3899 WARN("Invalid format %#x.\n", format
);
3900 *format_support
= 0;
3904 *format_support
= 0;
3906 wined3d_mutex_lock();
3907 feature_level
= device
->state
->feature_level
;
3908 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3909 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3910 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3911 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3913 hr
= wined3d_check_device_format(wined3d
, wined3d_adapter
, params
.device_type
,
3914 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].bind_flags
, flag_mapping
[i
].rtype
, wined3d_format
);
3915 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOMIPGEN
)
3917 if (hr
!= WINED3D_OK
)
3919 WARN("Failed to check device format support, hr %#lx.\n", hr
);
3920 wined3d_mutex_unlock();
3924 *format_support
|= flag_mapping
[i
].flag
;
3926 wined3d_mutex_unlock();
3928 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
3929 *format_support
&= ~D3D11_FORMAT_SUPPORT_BUFFER
;
3931 if (*format_support
& (D3D11_FORMAT_SUPPORT_TEXTURE1D
3932 | D3D11_FORMAT_SUPPORT_TEXTURE2D
| D3D11_FORMAT_SUPPORT_TEXTURE3D
))
3934 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_LOAD
;
3935 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
;
3936 *format_support
|= D3D11_FORMAT_SUPPORT_TEXTURECUBE
;
3938 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3939 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER
;
3941 if (*format_support
& D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
)
3943 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
3944 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
;
3946 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3947 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
;
3951 /* d3d11 requires 4 and 8 sample counts support for formats reported to
3952 * support multisample. */
3953 if (wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3954 TRUE
, WINED3D_MULTISAMPLE_4_SAMPLES
, NULL
) == WINED3D_OK
&&
3955 wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3956 TRUE
, WINED3D_MULTISAMPLE_8_SAMPLES
, NULL
) == WINED3D_OK
)
3958 *format_support
|= D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE
3959 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
3960 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
;
3963 return *format_support
? S_OK
: E_FAIL
;
3966 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2
*iface
,
3967 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3969 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3970 struct wined3d_device_creation_parameters params
;
3971 struct wined3d_adapter
*wined3d_adapter
;
3972 struct wined3d
*wined3d
;
3975 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3976 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3978 if (!quality_level_count
)
3979 return E_INVALIDARG
;
3981 *quality_level_count
= 0;
3985 if (sample_count
== 1)
3987 *quality_level_count
= 1;
3990 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3993 wined3d_mutex_lock();
3994 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3995 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3996 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3997 hr
= wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
,
3998 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3999 wined3d_mutex_unlock();
4001 if (hr
== WINED3DERR_INVALIDCALL
)
4002 return E_INVALIDARG
;
4003 if (hr
== WINED3DERR_NOTAVAILABLE
)
4008 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device2
*iface
, D3D11_COUNTER_INFO
*info
)
4010 FIXME("iface %p, info %p stub!\n", iface
, info
);
4013 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
4014 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
4015 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4017 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
4018 "units %p, units_length %p, description %p, description_length %p stub!\n",
4019 iface
, desc
, type
, active_counter_count
, name
, name_length
,
4020 units
, units_length
, description
, description_length
);
4025 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device2
*iface
, D3D11_FEATURE feature
,
4026 void *feature_support_data
, UINT feature_support_data_size
)
4028 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4029 struct wined3d_caps wined3d_caps
;
4032 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
4033 iface
, feature
, feature_support_data
, feature_support_data_size
);
4037 case D3D11_FEATURE_THREADING
:
4039 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
4040 if (feature_support_data_size
!= sizeof(*threading_data
))
4042 WARN("Invalid data size.\n");
4043 return E_INVALIDARG
;
4046 /* We lie about the threading support to make Tomb Raider 2013 and
4047 * Deus Ex: Human Revolution happy. */
4048 FIXME("Returning fake threading support data.\n");
4049 threading_data
->DriverConcurrentCreates
= TRUE
;
4050 threading_data
->DriverCommandLists
= TRUE
;
4054 case D3D11_FEATURE_DOUBLES
:
4056 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
4057 if (feature_support_data_size
!= sizeof(*doubles_data
))
4059 WARN("Invalid data size.\n");
4060 return E_INVALIDARG
;
4063 wined3d_mutex_lock();
4064 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4065 wined3d_mutex_unlock();
4068 WARN("Failed to get device caps, hr %#lx.\n", hr
);
4072 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
4076 case D3D11_FEATURE_D3D9_OPTIONS
:
4078 D3D11_FEATURE_DATA_D3D9_OPTIONS
*options
= feature_support_data
;
4079 if (feature_support_data_size
!= sizeof(*options
))
4081 WARN("Invalid data size.\n");
4082 return E_INVALIDARG
;
4085 wined3d_mutex_lock();
4086 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4087 wined3d_mutex_unlock();
4090 WARN("Failed to get device caps, hr %#lx.\n", hr
);
4094 options
->FullNonPow2TextureSupport
= !(wined3d_caps
.TextureCaps
& WINED3DPTEXTURECAPS_POW2
);
4098 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
4100 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
4101 if (feature_support_data_size
!= sizeof(*options
))
4103 WARN("Invalid data size.\n");
4104 return E_INVALIDARG
;
4107 wined3d_mutex_lock();
4108 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4109 wined3d_mutex_unlock();
4112 WARN("Failed to get device caps, hr %#lx.\n", hr
);
4116 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
4117 = wined3d_caps
.max_feature_level
>= WINED3D_FEATURE_LEVEL_11
;
4121 case D3D11_FEATURE_D3D11_OPTIONS
:
4123 D3D11_FEATURE_DATA_D3D11_OPTIONS
*options
= feature_support_data
;
4124 if (feature_support_data_size
!= sizeof(*options
))
4126 WARN("Invalid data size.\n");
4127 return E_INVALIDARG
;
4130 FIXME("Returning fake Options support data.\n");
4131 options
->OutputMergerLogicOp
= FALSE
;
4132 options
->UAVOnlyRenderingForcedSampleCount
= FALSE
;
4133 options
->DiscardAPIsSeenByDriver
= FALSE
;
4134 options
->FlagsForUpdateAndCopySeenByDriver
= FALSE
;
4135 options
->ClearView
= FALSE
;
4136 options
->CopyWithOverlap
= FALSE
;
4137 options
->ConstantBufferPartialUpdate
= TRUE
;
4138 options
->ConstantBufferOffsetting
= TRUE
;
4139 options
->MapNoOverwriteOnDynamicConstantBuffer
= TRUE
;
4140 options
->MapNoOverwriteOnDynamicBufferSRV
= TRUE
;
4141 options
->MultisampleRTVWithForcedSampleCountOne
= FALSE
;
4142 options
->SAD4ShaderInstructions
= FALSE
;
4143 options
->ExtendedDoublesShaderInstructions
= FALSE
;
4144 options
->ExtendedResourceSharing
= FALSE
;
4148 case D3D11_FEATURE_D3D11_OPTIONS1
:
4150 D3D11_FEATURE_DATA_D3D11_OPTIONS1
*options
= feature_support_data
;
4151 if (feature_support_data_size
!= sizeof(*options
))
4153 WARN("Invalid data size.\n");
4154 return E_INVALIDARG
;
4157 FIXME("Returning fake Options1 support data.\n");
4158 options
->TiledResourcesTier
= D3D11_TILED_RESOURCES_NOT_SUPPORTED
;
4159 options
->MinMaxFiltering
= FALSE
;
4160 options
->ClearViewAlsoSupportsDepthOnlyFormats
= FALSE
;
4161 options
->MapOnDefaultBuffers
= FALSE
;
4165 case D3D11_FEATURE_D3D11_OPTIONS3
:
4167 D3D11_FEATURE_DATA_D3D11_OPTIONS3
*options
= feature_support_data
;
4168 if (feature_support_data_size
!= sizeof(*options
))
4170 WARN("Invalid data size.\n");
4171 return E_INVALIDARG
;
4174 wined3d_mutex_lock();
4175 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4176 wined3d_mutex_unlock();
4179 WARN("Failed to get device caps, hr %#lx.\n", hr
);
4183 options
->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
4184 = wined3d_caps
.viewport_array_index_any_shader
;
4188 case D3D11_FEATURE_ARCHITECTURE_INFO
:
4190 D3D11_FEATURE_DATA_ARCHITECTURE_INFO
*options
= feature_support_data
;
4191 if (feature_support_data_size
!= sizeof(*options
))
4193 WARN("Invalid data size.\n");
4194 return E_INVALIDARG
;
4197 FIXME("Returning fake data architecture info.\n");
4198 options
->TileBasedDeferredRenderer
= FALSE
;
4202 case D3D11_FEATURE_FORMAT_SUPPORT
:
4204 D3D11_FEATURE_DATA_FORMAT_SUPPORT
*data
= feature_support_data
;
4205 if (feature_support_data_size
!= sizeof(*data
))
4207 WARN("Invalid size %u for D3D11_FEATURE_FORMAT_SUPPORT.\n", feature_support_data_size
);
4208 return E_INVALIDARG
;
4211 return d3d11_device_CheckFormatSupport(iface
, data
->InFormat
, &data
->OutFormatSupport
);
4215 FIXME("Unhandled feature %#x.\n", feature
);
4220 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
4221 UINT
*data_size
, void *data
)
4223 IDXGIDevice
*dxgi_device
;
4226 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4228 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4230 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
4231 IDXGIDevice_Release(dxgi_device
);
4236 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
4237 UINT data_size
, const void *data
)
4239 IDXGIDevice
*dxgi_device
;
4242 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4244 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4246 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
4247 IDXGIDevice_Release(dxgi_device
);
4252 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device2
*iface
, REFGUID guid
,
4253 const IUnknown
*data
)
4255 IDXGIDevice
*dxgi_device
;
4258 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4260 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4262 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
4263 IDXGIDevice_Release(dxgi_device
);
4268 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device2
*iface
)
4270 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4272 TRACE("iface %p.\n", iface
);
4274 return device
->state
->feature_level
;
4277 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device2
*iface
)
4279 FIXME("iface %p stub!\n", iface
);
4284 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device2
*iface
)
4286 WARN("iface %p stub!\n", iface
);
4291 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device2
*iface
,
4292 ID3D11DeviceContext
**immediate_context
)
4294 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4296 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
4298 *immediate_context
= (ID3D11DeviceContext
*)&device
->immediate_context
.ID3D11DeviceContext1_iface
;
4299 ID3D11DeviceContext_AddRef(*immediate_context
);
4302 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device2
*iface
, UINT flags
)
4304 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4309 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device2
*iface
)
4311 FIXME("iface %p stub!\n", iface
);
4316 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext1(ID3D11Device2
*iface
,
4317 ID3D11DeviceContext1
**immediate_context
)
4319 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4321 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
4323 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext1_iface
;
4324 ID3D11DeviceContext1_AddRef(*immediate_context
);
4327 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext1(ID3D11Device2
*iface
, UINT flags
,
4328 ID3D11DeviceContext1
**context
)
4330 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4331 struct d3d11_device_context
*object
;
4334 TRACE("iface %p, flags %#x, context %p.\n", iface
, flags
, context
);
4336 if (FAILED(hr
= d3d11_deferred_context_create(device
, flags
, &object
)))
4339 *context
= &object
->ID3D11DeviceContext1_iface
;
4343 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState1(ID3D11Device2
*iface
,
4344 const D3D11_RASTERIZER_DESC1
*desc
, ID3D11RasterizerState1
**state
)
4346 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4347 struct d3d_rasterizer_state
*object
;
4350 TRACE("iface %p, desc %p, state %p.\n", iface
, desc
, state
);
4353 return E_INVALIDARG
;
4355 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
4358 *state
= &object
->ID3D11RasterizerState1_iface
;
4363 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeviceContextState(ID3D11Device2
*iface
, UINT flags
,
4364 const D3D_FEATURE_LEVEL
*feature_levels
, UINT feature_level_count
, UINT sdk_version
,
4365 REFIID emulated_interface
, D3D_FEATURE_LEVEL
*chosen_feature_level
, ID3DDeviceContextState
**state
)
4367 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4368 struct d3d_device_context_state
*state_impl
;
4369 struct wined3d_state
*wined3d_state
;
4370 D3D_FEATURE_LEVEL feature_level
;
4371 HRESULT hr
= E_INVALIDARG
;
4373 TRACE("iface %p, flags %#x, feature_levels %p, feature_level_count %u, "
4374 "sdk_version %u, emulated_interface %s, chosen_feature_level %p, state %p.\n",
4375 iface
, flags
, feature_levels
, feature_level_count
,
4376 sdk_version
, debugstr_guid(emulated_interface
), chosen_feature_level
, state
);
4379 FIXME("Ignoring flags %#x.\n", flags
);
4381 wined3d_mutex_lock();
4383 if (!feature_level_count
)
4386 if (FAILED(hr
= wined3d_state_create(device
->wined3d_device
,
4387 (const enum wined3d_feature_level
*)feature_levels
, feature_level_count
, &wined3d_state
)))
4389 feature_level
= d3d_feature_level_from_wined3d(wined3d_state_get_feature_level(wined3d_state
));
4391 if (chosen_feature_level
)
4392 *chosen_feature_level
= feature_level
;
4396 wined3d_state_destroy(wined3d_state
);
4397 wined3d_mutex_unlock();
4401 if (!(state_impl
= calloc(1, sizeof(*state_impl
))))
4403 wined3d_state_destroy(wined3d_state
);
4408 d3d_device_context_state_init(state_impl
, device
, feature_level
, emulated_interface
);
4409 if (!d3d_device_context_state_add_entry(state_impl
, device
, wined3d_state
))
4411 wined3d_state_destroy(wined3d_state
);
4412 ID3DDeviceContextState_Release(&state_impl
->ID3DDeviceContextState_iface
);
4417 *state
= &state_impl
->ID3DDeviceContextState_iface
;
4418 device
->d3d11_only
= FALSE
;
4419 wined3d_mutex_unlock();
4424 wined3d_mutex_unlock();
4425 if (chosen_feature_level
)
4426 *chosen_feature_level
= 0;
4432 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource1(ID3D11Device2
*iface
, HANDLE handle
,
4433 REFIID iid
, void **resource
)
4435 FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface
, handle
, debugstr_guid(iid
), resource
);
4440 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResourceByName(ID3D11Device2
*iface
, const WCHAR
*name
,
4441 DWORD access
, REFIID iid
, void **resource
)
4443 FIXME("iface %p, name %s, access %#lx, iid %s, resource %p stub!\n", iface
, debugstr_w(name
), access
,
4444 debugstr_guid(iid
), resource
);
4449 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext2(ID3D11Device2
*iface
,
4450 ID3D11DeviceContext2
**context
)
4452 FIXME("iface %p, context %p stub!\n", iface
, context
);
4455 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext2(ID3D11Device2
*iface
,
4456 UINT flags
, ID3D11DeviceContext2
**context
)
4458 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
4463 static void STDMETHODCALLTYPE
d3d11_device_GetResourceTiling(ID3D11Device2
*iface
,
4464 ID3D11Resource
*resource
, UINT
*tile_count
, D3D11_PACKED_MIP_DESC
*mip_desc
,
4465 D3D11_TILE_SHAPE
*tile_shape
, UINT
*subresource_tiling_count
, UINT first_subresource_tiling
,
4466 D3D11_SUBRESOURCE_TILING
*subresource_tiling
)
4468 FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, "
4469 "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n",
4470 iface
, resource
, tile_count
, mip_desc
, tile_shape
,
4471 subresource_tiling_count
, first_subresource_tiling
, subresource_tiling
);
4474 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2
*iface
,
4475 DXGI_FORMAT format
, UINT sample_count
, UINT flags
, UINT
*quality_level_count
)
4477 FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n",
4478 iface
, format
, sample_count
, flags
, quality_level_count
);
4483 static const struct ID3D11Device2Vtbl d3d11_device_vtbl
=
4485 /* IUnknown methods */
4486 d3d11_device_QueryInterface
,
4487 d3d11_device_AddRef
,
4488 d3d11_device_Release
,
4489 /* ID3D11Device methods */
4490 d3d11_device_CreateBuffer
,
4491 d3d11_device_CreateTexture1D
,
4492 d3d11_device_CreateTexture2D
,
4493 d3d11_device_CreateTexture3D
,
4494 d3d11_device_CreateShaderResourceView
,
4495 d3d11_device_CreateUnorderedAccessView
,
4496 d3d11_device_CreateRenderTargetView
,
4497 d3d11_device_CreateDepthStencilView
,
4498 d3d11_device_CreateInputLayout
,
4499 d3d11_device_CreateVertexShader
,
4500 d3d11_device_CreateGeometryShader
,
4501 d3d11_device_CreateGeometryShaderWithStreamOutput
,
4502 d3d11_device_CreatePixelShader
,
4503 d3d11_device_CreateHullShader
,
4504 d3d11_device_CreateDomainShader
,
4505 d3d11_device_CreateComputeShader
,
4506 d3d11_device_CreateClassLinkage
,
4507 d3d11_device_CreateBlendState
,
4508 d3d11_device_CreateDepthStencilState
,
4509 d3d11_device_CreateRasterizerState
,
4510 d3d11_device_CreateSamplerState
,
4511 d3d11_device_CreateQuery
,
4512 d3d11_device_CreatePredicate
,
4513 d3d11_device_CreateCounter
,
4514 d3d11_device_CreateDeferredContext
,
4515 d3d11_device_OpenSharedResource
,
4516 d3d11_device_CheckFormatSupport
,
4517 d3d11_device_CheckMultisampleQualityLevels
,
4518 d3d11_device_CheckCounterInfo
,
4519 d3d11_device_CheckCounter
,
4520 d3d11_device_CheckFeatureSupport
,
4521 d3d11_device_GetPrivateData
,
4522 d3d11_device_SetPrivateData
,
4523 d3d11_device_SetPrivateDataInterface
,
4524 d3d11_device_GetFeatureLevel
,
4525 d3d11_device_GetCreationFlags
,
4526 d3d11_device_GetDeviceRemovedReason
,
4527 d3d11_device_GetImmediateContext
,
4528 d3d11_device_SetExceptionMode
,
4529 d3d11_device_GetExceptionMode
,
4530 /* ID3D11Device1 methods */
4531 d3d11_device_GetImmediateContext1
,
4532 d3d11_device_CreateDeferredContext1
,
4533 d3d11_device_CreateBlendState1
,
4534 d3d11_device_CreateRasterizerState1
,
4535 d3d11_device_CreateDeviceContextState
,
4536 d3d11_device_OpenSharedResource1
,
4537 d3d11_device_OpenSharedResourceByName
,
4538 /* ID3D11Device2 methods */
4539 d3d11_device_GetImmediateContext2
,
4540 d3d11_device_CreateDeferredContext2
,
4541 d3d11_device_GetResourceTiling
,
4542 d3d11_device_CheckMultisampleQualityLevels1
,
4545 /* Inner IUnknown methods */
4547 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
4549 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
4552 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
4554 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4556 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
4558 if (IsEqualGUID(riid
, &IID_ID3D11Device2
)
4559 || IsEqualGUID(riid
, &IID_ID3D11Device1
)
4560 || IsEqualGUID(riid
, &IID_ID3D11Device
)
4561 || IsEqualGUID(riid
, &IID_IUnknown
))
4563 *out
= &device
->ID3D11Device2_iface
;
4565 else if (!device
->d3d11_only
4566 && (IsEqualGUID(riid
, &IID_ID3D10Device1
)
4567 || IsEqualGUID(riid
, &IID_ID3D10Device
)))
4569 *out
= &device
->ID3D10Device1_iface
;
4571 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
4573 *out
= &device
->ID3D10Multithread_iface
;
4575 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
4577 *out
= &device
->IWineDXGIDeviceParent_iface
;
4581 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
4583 return E_NOINTERFACE
;
4586 IUnknown_AddRef((IUnknown
*)*out
);
4590 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
4592 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4593 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
4595 TRACE("%p increasing refcount to %lu.\n", device
, refcount
);
4600 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
4602 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4603 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
4606 TRACE("%p decreasing refcount to %lu.\n", device
, refcount
);
4611 d3d_device_context_state_private_release(device
->state
);
4612 for (i
= 0; i
< device
->context_state_count
; ++i
)
4614 d3d_device_context_state_remove_entry(device
->context_states
[i
], device
);
4616 free(device
->context_states
);
4617 d3d11_device_context_cleanup(&device
->immediate_context
);
4618 if (device
->wined3d_device
)
4620 wined3d_device_decref(device
->wined3d_device
);
4622 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
4623 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
4624 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4625 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4631 /* IUnknown methods */
4633 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID iid
,
4636 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4637 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4640 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
4642 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4643 return IUnknown_AddRef(device
->outer_unk
);
4646 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
4648 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4649 return IUnknown_Release(device
->outer_unk
);
4652 /* ID3D10Device methods */
4654 static void d3d10_device_get_constant_buffers(ID3D10Device1
*iface
,
4655 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4657 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4660 wined3d_mutex_lock();
4661 for (i
= 0; i
< buffer_count
; ++i
)
4663 struct wined3d_constant_buffer_state state
;
4664 struct d3d_buffer
*buffer_impl
;
4666 wined3d_device_context_get_constant_buffer(device
->immediate_context
.wined3d_context
,
4667 type
, start_slot
+ i
, &state
);
4675 buffer_impl
= wined3d_buffer_get_parent(state
.buffer
);
4676 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4677 ID3D10Buffer_AddRef(buffers
[i
]);
4679 wined3d_mutex_unlock();
4682 static void d3d10_device_set_constant_buffers(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4683 unsigned int start_slot
, unsigned int buffer_count
, ID3D10Buffer
*const *buffers
)
4685 struct wined3d_constant_buffer_state wined3d_buffers
[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
4686 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4689 if (buffer_count
> ARRAY_SIZE(wined3d_buffers
))
4691 WARN("Buffer count %u exceeds limit; ignoring call.\n", buffer_count
);
4695 for (i
= 0; i
< buffer_count
; ++i
)
4697 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4699 wined3d_buffers
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
4700 wined3d_buffers
[i
].offset
= 0;
4701 wined3d_buffers
[i
].size
= WINED3D_MAX_CONSTANT_BUFFER_SIZE
* sizeof(struct wined3d_vec4
);
4704 wined3d_device_context_set_constant_buffers(device
->immediate_context
.wined3d_context
,
4705 type
, start_slot
, buffer_count
, wined3d_buffers
);
4708 static void d3d10_device_set_shader_resource_views(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4709 unsigned int start_slot
, unsigned int count
, ID3D10ShaderResourceView
*const *views
)
4711 struct wined3d_shader_resource_view
*wined3d_views
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
4712 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4715 if (count
> ARRAY_SIZE(wined3d_views
))
4717 WARN("View count %u exceeds limit; ignoring call.\n", count
);
4721 for (i
= 0; i
< count
; ++i
)
4723 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4725 wined3d_views
[i
] = view
? view
->wined3d_view
: NULL
;
4728 wined3d_device_context_set_shader_resource_views(device
->immediate_context
.wined3d_context
,
4729 type
, start_slot
, count
, wined3d_views
);
4732 static void d3d10_device_set_samplers(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4733 unsigned int start_slot
, unsigned int count
, ID3D10SamplerState
*const *samplers
)
4735 struct wined3d_sampler
*wined3d_samplers
[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
];
4736 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4739 if (count
> ARRAY_SIZE(wined3d_samplers
))
4741 WARN("Sampler count %u exceeds limit; ignoring call.\n", count
);
4745 for (i
= 0; i
< count
; ++i
)
4747 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4749 wined3d_samplers
[i
] = sampler
? sampler
->wined3d_sampler
: NULL
;
4752 wined3d_device_context_set_samplers(device
->immediate_context
.wined3d_context
,
4753 type
, start_slot
, count
, wined3d_samplers
);
4756 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
4757 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4759 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4760 iface
, start_slot
, buffer_count
, buffers
);
4762 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
4763 buffer_count
, buffers
);
4766 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
4767 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4769 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4770 iface
, start_slot
, view_count
, views
);
4772 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, view_count
, views
);
4775 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
4776 ID3D10PixelShader
*shader
)
4778 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4779 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
4781 TRACE("iface %p, shader %p\n", iface
, shader
);
4783 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4784 WINED3D_SHADER_TYPE_PIXEL
, ps
? ps
->wined3d_shader
: NULL
);
4787 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
4788 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4790 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4791 iface
, start_slot
, sampler_count
, samplers
);
4793 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, sampler_count
, samplers
);
4796 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
4797 ID3D10VertexShader
*shader
)
4799 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4800 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
4802 TRACE("iface %p, shader %p\n", iface
, shader
);
4804 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4805 WINED3D_SHADER_TYPE_VERTEX
, vs
? vs
->wined3d_shader
: NULL
);
4808 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
4809 UINT start_index_location
, INT base_vertex_location
)
4811 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4813 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
4814 iface
, index_count
, start_index_location
, base_vertex_location
);
4816 wined3d_device_context_draw_indexed(device
->immediate_context
.wined3d_context
,
4817 base_vertex_location
, start_index_location
, index_count
, 0, 0);
4820 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
4821 UINT start_vertex_location
)
4823 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4825 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
4826 iface
, vertex_count
, start_vertex_location
);
4828 wined3d_device_context_draw(device
->immediate_context
.wined3d_context
, start_vertex_location
, vertex_count
, 0, 0);
4831 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
4832 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4834 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4835 iface
, start_slot
, buffer_count
, buffers
);
4837 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
4838 buffer_count
, buffers
);
4841 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
4842 ID3D10InputLayout
*input_layout
)
4844 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4845 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
4847 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
4849 wined3d_device_context_set_vertex_declaration(device
->immediate_context
.wined3d_context
,
4850 layout
? layout
->wined3d_decl
: NULL
);
4853 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
4854 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
4856 struct wined3d_stream_state streams
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
4857 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4860 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
4861 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4863 if (buffer_count
> ARRAY_SIZE(streams
))
4865 WARN("Buffer count %u exceeds limit.\n", buffer_count
);
4866 buffer_count
= ARRAY_SIZE(streams
);
4869 for (i
= 0; i
< buffer_count
; ++i
)
4871 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4873 streams
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
4874 streams
[i
].offset
= offsets
[i
];
4875 streams
[i
].stride
= strides
[i
];
4876 streams
[i
].frequency
= 1;
4877 streams
[i
].flags
= 0;
4880 wined3d_device_context_set_stream_sources(device
->immediate_context
.wined3d_context
,
4881 start_slot
, buffer_count
, streams
);
4884 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
4885 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
4887 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4888 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
4890 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
4891 iface
, buffer
, debug_dxgi_format(format
), offset
);
4893 wined3d_device_context_set_index_buffer(device
->immediate_context
.wined3d_context
,
4894 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
4895 wined3dformat_from_dxgi_format(format
), offset
);
4898 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
4899 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
4900 INT base_vertex_location
, UINT start_instance_location
)
4902 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4904 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
4905 "base_vertex_location %d, start_instance_location %u.\n",
4906 iface
, instance_index_count
, instance_count
, start_index_location
,
4907 base_vertex_location
, start_instance_location
);
4909 wined3d_device_context_draw_indexed(device
->immediate_context
.wined3d_context
, base_vertex_location
,
4910 start_index_location
, instance_index_count
, start_instance_location
, instance_count
);
4913 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
4914 UINT instance_vertex_count
, UINT instance_count
,
4915 UINT start_vertex_location
, UINT start_instance_location
)
4917 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4919 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
4920 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
4921 start_vertex_location
, start_instance_location
);
4923 wined3d_device_context_draw(device
->immediate_context
.wined3d_context
, start_vertex_location
,
4924 instance_vertex_count
, start_instance_location
, instance_count
);
4927 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
4928 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4930 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4931 iface
, start_slot
, buffer_count
, buffers
);
4933 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
4934 buffer_count
, buffers
);
4937 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
4939 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4940 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
4942 TRACE("iface %p, shader %p.\n", iface
, shader
);
4944 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4945 WINED3D_SHADER_TYPE_GEOMETRY
, gs
? gs
->wined3d_shader
: NULL
);
4948 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
4949 D3D10_PRIMITIVE_TOPOLOGY topology
)
4951 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4953 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
4955 wined3d_device_context_set_primitive_type(device
->immediate_context
.wined3d_context
,
4956 (enum wined3d_primitive_type
)topology
, 0);
4959 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
4960 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4962 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4963 iface
, start_slot
, view_count
, views
);
4965 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, view_count
, views
);
4968 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
4969 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4971 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4972 iface
, start_slot
, sampler_count
, samplers
);
4974 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, sampler_count
, samplers
);
4977 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
4979 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4980 struct d3d_query
*query
;
4982 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
4984 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
4985 wined3d_device_context_set_predication(device
->immediate_context
.wined3d_context
,
4986 query
? query
->wined3d_query
: NULL
, value
);
4989 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
4990 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4992 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4993 iface
, start_slot
, view_count
, views
);
4995 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, view_count
, views
);
4998 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
4999 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
5001 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5002 iface
, start_slot
, sampler_count
, samplers
);
5004 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, sampler_count
, samplers
);
5007 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
5008 UINT rtv_count
, ID3D10RenderTargetView
*const *rtvs
, ID3D10DepthStencilView
*depth_stencil_view
)
5010 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
5011 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5012 struct d3d_depthstencil_view
*dsv
;
5015 TRACE("iface %p, rtv_count %u, rtvs %p, depth_stencil_view %p.\n", iface
, rtv_count
, rtvs
, depth_stencil_view
);
5017 if (rtv_count
> ARRAY_SIZE(wined3d_rtvs
))
5019 WARN("View count %u exceeds limit.\n", rtv_count
);
5020 rtv_count
= ARRAY_SIZE(wined3d_rtvs
);
5023 for (i
= 0; i
< rtv_count
; ++i
)
5025 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(rtvs
[i
]);
5027 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
5030 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
5032 wined3d_device_context_set_render_targets_and_unordered_access_views(device
->immediate_context
.wined3d_context
,
5033 ARRAY_SIZE(wined3d_rtvs
), wined3d_rtvs
, dsv
? dsv
->wined3d_view
: NULL
, ~0u, NULL
, NULL
);
5036 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
5037 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
5039 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5040 struct d3d_blend_state
*blend_state_object
;
5042 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
5043 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
5045 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
5046 d3d11_device_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5047 blend_state_object
? (ID3D11BlendState
*)&blend_state_object
->ID3D11BlendState1_iface
: NULL
,
5048 blend_factor
, sample_mask
);
5051 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
5052 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
5054 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5055 struct d3d_depthstencil_state
*ds_state_object
;
5057 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
5058 iface
, depth_stencil_state
, stencil_ref
);
5060 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
5061 d3d11_device_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5062 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
5065 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
5066 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
5068 struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
] = {0};
5069 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5070 unsigned int count
, i
;
5072 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
5074 count
= min(target_count
, ARRAY_SIZE(outputs
));
5075 for (i
= 0; i
< count
; ++i
)
5077 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
5079 outputs
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
5080 outputs
[i
].offset
= offsets
? offsets
[i
] : 0;
5083 wined3d_device_context_set_stream_outputs(device
->immediate_context
.wined3d_context
, outputs
);
5086 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
5088 FIXME("iface %p stub!\n", iface
);
5091 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
5093 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5094 struct d3d_rasterizer_state
*rasterizer_state_object
;
5096 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5098 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
5099 d3d11_device_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5100 rasterizer_state_object
? (ID3D11RasterizerState
*)&rasterizer_state_object
->ID3D11RasterizerState1_iface
: NULL
);
5103 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
5104 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
5106 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5107 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5110 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
5112 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
5115 for (i
= 0; i
< viewport_count
; ++i
)
5117 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
5118 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
5119 wined3d_vp
[i
].width
= viewports
[i
].Width
;
5120 wined3d_vp
[i
].height
= viewports
[i
].Height
;
5121 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
5122 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
5125 wined3d_device_context_set_viewports(device
->immediate_context
.wined3d_context
, viewport_count
, wined3d_vp
);
5128 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
5129 UINT rect_count
, const D3D10_RECT
*rects
)
5131 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5133 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
5135 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
5138 wined3d_device_context_set_scissor_rects(device
->immediate_context
.wined3d_context
, rect_count
, rects
);
5141 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
5142 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
5143 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
5145 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5146 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5147 struct wined3d_box wined3d_src_box
;
5149 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
5150 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
5151 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
5152 src_resource
, src_subresource_idx
, src_box
);
5154 if (!dst_resource
|| !src_resource
)
5158 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
5159 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
5161 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5162 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5163 wined3d_device_context_copy_sub_resource_region(device
->immediate_context
.wined3d_context
,
5164 wined3d_dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
5165 wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
5168 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
5169 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
5171 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5172 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5174 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
5176 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5177 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5178 wined3d_device_context_copy_resource(device
->immediate_context
.wined3d_context
,
5179 wined3d_dst_resource
, wined3d_src_resource
);
5182 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
5183 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
5184 const void *data
, UINT row_pitch
, UINT depth_pitch
)
5186 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5187 ID3D11Resource
*d3d11_resource
;
5189 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
5190 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
5192 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
5193 d3d11_device_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5194 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
5195 ID3D11Resource_Release(d3d11_resource
);
5198 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
5199 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
5201 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5202 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
5203 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
5206 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
5207 iface
, render_target_view
, debug_float4(color_rgba
));
5212 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(device
->immediate_context
.wined3d_context
,
5213 view
->wined3d_view
, NULL
, WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
5214 ERR("Failed to clear view, hr %#lx.\n", hr
);
5217 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
5218 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
5220 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5221 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
5222 DWORD wined3d_flags
;
5225 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
5226 iface
, depth_stencil_view
, flags
, depth
, stencil
);
5231 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
5233 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(device
->immediate_context
.wined3d_context
,
5234 view
->wined3d_view
, NULL
, wined3d_flags
, NULL
, depth
, stencil
)))
5235 ERR("Failed to clear view, hr %#lx.\n", hr
);
5238 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
5239 ID3D10ShaderResourceView
*view
)
5241 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5242 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D10ShaderResourceView(view
);
5244 TRACE("iface %p, view %p.\n", iface
, view
);
5246 wined3d_device_context_generate_mipmaps(device
->immediate_context
.wined3d_context
, srv
->wined3d_view
);
5249 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
5250 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
5251 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
5253 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5254 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5255 enum wined3d_format_id wined3d_format
;
5257 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
5258 "src_resource %p, src_subresource_idx %u, format %s.\n",
5259 iface
, dst_resource
, dst_subresource_idx
,
5260 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
5262 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5263 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5264 wined3d_format
= wined3dformat_from_dxgi_format(format
);
5265 wined3d_device_context_resolve_sub_resource(device
->immediate_context
.wined3d_context
,
5266 wined3d_dst_resource
, dst_subresource_idx
,
5267 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
5270 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
5271 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5273 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5274 iface
, start_slot
, buffer_count
, buffers
);
5276 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, buffer_count
,
5280 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
5281 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5283 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5286 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5287 iface
, start_slot
, view_count
, views
);
5289 wined3d_mutex_lock();
5290 for (i
= 0; i
< view_count
; ++i
)
5292 struct wined3d_shader_resource_view
*wined3d_view
;
5293 struct d3d_shader_resource_view
*view_impl
;
5295 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5296 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
5302 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5303 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5304 ID3D10ShaderResourceView_AddRef(views
[i
]);
5306 wined3d_mutex_unlock();
5309 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
5311 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5312 struct d3d_pixel_shader
*shader_impl
;
5313 struct wined3d_shader
*wined3d_shader
;
5315 TRACE("iface %p, shader %p.\n", iface
, shader
);
5317 wined3d_mutex_lock();
5318 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5319 WINED3D_SHADER_TYPE_PIXEL
)))
5321 wined3d_mutex_unlock();
5326 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5327 wined3d_mutex_unlock();
5328 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
5329 ID3D10PixelShader_AddRef(*shader
);
5332 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
5333 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5335 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5338 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5339 iface
, start_slot
, sampler_count
, samplers
);
5341 wined3d_mutex_lock();
5342 for (i
= 0; i
< sampler_count
; ++i
)
5344 struct d3d_sampler_state
*sampler_impl
;
5345 struct wined3d_sampler
*wined3d_sampler
;
5347 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5348 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
5354 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5355 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5356 ID3D10SamplerState_AddRef(samplers
[i
]);
5358 wined3d_mutex_unlock();
5361 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
5363 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5364 struct d3d_vertex_shader
*shader_impl
;
5365 struct wined3d_shader
*wined3d_shader
;
5367 TRACE("iface %p, shader %p.\n", iface
, shader
);
5369 wined3d_mutex_lock();
5370 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5371 WINED3D_SHADER_TYPE_VERTEX
)))
5373 wined3d_mutex_unlock();
5378 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5379 wined3d_mutex_unlock();
5380 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
5381 ID3D10VertexShader_AddRef(*shader
);
5384 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
5385 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5387 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5388 iface
, start_slot
, buffer_count
, buffers
);
5390 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, buffer_count
,
5394 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
5396 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5397 struct wined3d_vertex_declaration
*wined3d_declaration
;
5398 struct d3d_input_layout
*input_layout_impl
;
5400 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
5402 wined3d_mutex_lock();
5403 if (!(wined3d_declaration
= wined3d_device_context_get_vertex_declaration(
5404 device
->immediate_context
.wined3d_context
)))
5406 wined3d_mutex_unlock();
5407 *input_layout
= NULL
;
5411 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
5412 wined3d_mutex_unlock();
5413 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
5414 ID3D10InputLayout_AddRef(*input_layout
);
5417 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
5418 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
5420 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5423 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
5424 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
5426 wined3d_mutex_lock();
5427 for (i
= 0; i
< buffer_count
; ++i
)
5429 struct wined3d_buffer
*wined3d_buffer
= NULL
;
5430 struct d3d_buffer
*buffer_impl
;
5432 if (FAILED(wined3d_device_context_get_stream_source(device
->immediate_context
.wined3d_context
, start_slot
+ i
,
5433 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
5434 ERR("Failed to get vertex buffer.\n");
5436 if (!wined3d_buffer
)
5442 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5443 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5444 ID3D10Buffer_AddRef(buffers
[i
]);
5446 wined3d_mutex_unlock();
5449 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
5450 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
5452 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5453 enum wined3d_format_id wined3d_format
;
5454 struct wined3d_buffer
*wined3d_buffer
;
5455 struct d3d_buffer
*buffer_impl
;
5457 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
5459 wined3d_mutex_lock();
5460 wined3d_buffer
= wined3d_device_context_get_index_buffer(
5461 device
->immediate_context
.wined3d_context
, &wined3d_format
, offset
);
5462 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
5463 if (!wined3d_buffer
)
5465 wined3d_mutex_unlock();
5470 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5471 wined3d_mutex_unlock();
5472 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
5473 ID3D10Buffer_AddRef(*buffer
);
5476 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
5477 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5479 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5480 iface
, start_slot
, buffer_count
, buffers
);
5482 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, buffer_count
,
5486 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
5488 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5489 struct d3d_geometry_shader
*shader_impl
;
5490 struct wined3d_shader
*wined3d_shader
;
5492 TRACE("iface %p, shader %p.\n", iface
, shader
);
5494 wined3d_mutex_lock();
5495 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5496 WINED3D_SHADER_TYPE_GEOMETRY
)))
5498 wined3d_mutex_unlock();
5503 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5504 wined3d_mutex_unlock();
5505 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
5506 ID3D10GeometryShader_AddRef(*shader
);
5509 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
5510 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
5512 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5514 TRACE("iface %p, topology %p.\n", iface
, topology
);
5516 wined3d_mutex_lock();
5517 wined3d_device_context_get_primitive_type(device
->immediate_context
.wined3d_context
,
5518 (enum wined3d_primitive_type
*)topology
, NULL
);
5519 wined3d_mutex_unlock();
5522 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
5523 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5525 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5528 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5529 iface
, start_slot
, view_count
, views
);
5531 wined3d_mutex_lock();
5532 for (i
= 0; i
< view_count
; ++i
)
5534 struct wined3d_shader_resource_view
*wined3d_view
;
5535 struct d3d_shader_resource_view
*view_impl
;
5537 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5538 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
5544 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5545 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5546 ID3D10ShaderResourceView_AddRef(views
[i
]);
5548 wined3d_mutex_unlock();
5551 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
5552 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5554 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5557 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5558 iface
, start_slot
, sampler_count
, samplers
);
5560 wined3d_mutex_lock();
5561 for (i
= 0; i
< sampler_count
; ++i
)
5563 struct d3d_sampler_state
*sampler_impl
;
5564 struct wined3d_sampler
*wined3d_sampler
;
5566 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5567 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
5573 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5574 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5575 ID3D10SamplerState_AddRef(samplers
[i
]);
5577 wined3d_mutex_unlock();
5580 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
5581 ID3D10Predicate
**predicate
, BOOL
*value
)
5583 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5584 struct wined3d_query
*wined3d_predicate
;
5585 struct d3d_query
*predicate_impl
;
5587 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
5589 wined3d_mutex_lock();
5590 if (!(wined3d_predicate
= wined3d_device_context_get_predication(device
->immediate_context
.wined3d_context
, value
)))
5592 wined3d_mutex_unlock();
5597 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
5598 wined3d_mutex_unlock();
5599 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
5600 ID3D10Predicate_AddRef(*predicate
);
5603 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
5604 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5606 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5609 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5610 iface
, start_slot
, view_count
, views
);
5612 wined3d_mutex_lock();
5613 for (i
= 0; i
< view_count
; ++i
)
5615 struct wined3d_shader_resource_view
*wined3d_view
;
5616 struct d3d_shader_resource_view
*view_impl
;
5618 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5619 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
5625 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5626 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5627 ID3D10ShaderResourceView_AddRef(views
[i
]);
5629 wined3d_mutex_unlock();
5632 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
5633 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5635 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5638 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5639 iface
, start_slot
, sampler_count
, samplers
);
5641 wined3d_mutex_lock();
5642 for (i
= 0; i
< sampler_count
; ++i
)
5644 struct d3d_sampler_state
*sampler_impl
;
5645 struct wined3d_sampler
*wined3d_sampler
;
5647 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5648 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
5654 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5655 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5656 ID3D10SamplerState_AddRef(samplers
[i
]);
5658 wined3d_mutex_unlock();
5661 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
5662 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
5664 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5665 struct wined3d_rendertarget_view
*wined3d_view
;
5667 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
5668 iface
, view_count
, render_target_views
, depth_stencil_view
);
5670 wined3d_mutex_lock();
5671 if (render_target_views
)
5673 struct d3d_rendertarget_view
*view_impl
;
5676 for (i
= 0; i
< view_count
; ++i
)
5678 if (!(wined3d_view
= wined3d_device_context_get_rendertarget_view(
5679 device
->immediate_context
.wined3d_context
, i
))
5680 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5682 render_target_views
[i
] = NULL
;
5686 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
5687 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
5691 if (depth_stencil_view
)
5693 struct d3d_depthstencil_view
*view_impl
;
5695 if (!(wined3d_view
= wined3d_device_context_get_depth_stencil_view(device
->immediate_context
.wined3d_context
))
5696 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5698 *depth_stencil_view
= NULL
;
5702 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
5703 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
5706 wined3d_mutex_unlock();
5709 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
5710 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
5712 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5713 ID3D11BlendState
*d3d11_blend_state
;
5715 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
5716 iface
, blend_state
, blend_factor
, sample_mask
);
5718 d3d11_device_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5719 &d3d11_blend_state
, blend_factor
, sample_mask
);
5723 if (d3d11_blend_state
)
5725 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState1(
5726 (ID3D11BlendState1
*)d3d11_blend_state
)->ID3D10BlendState1_iface
;
5727 ID3D10BlendState_AddRef(*blend_state
);
5730 *blend_state
= NULL
;
5733 if (d3d11_blend_state
)
5734 ID3D11BlendState_Release(d3d11_blend_state
);
5737 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
5738 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
5740 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5741 ID3D11DepthStencilState
*d3d11_iface
= NULL
;
5743 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
5744 iface
, depth_stencil_state
, stencil_ref
);
5746 d3d11_device_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5747 &d3d11_iface
, stencil_ref
);
5749 if (depth_stencil_state
)
5753 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
5754 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
5757 *depth_stencil_state
= NULL
;
5761 ID3D11DepthStencilState_Release(d3d11_iface
);
5764 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
5765 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
5767 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5770 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
5771 iface
, buffer_count
, buffers
, offsets
);
5773 wined3d_mutex_lock();
5774 for (i
= 0; i
< buffer_count
; ++i
)
5776 struct wined3d_buffer
*wined3d_buffer
;
5777 struct d3d_buffer
*buffer_impl
;
5779 if (!(wined3d_buffer
= wined3d_device_context_get_stream_output(
5780 device
->immediate_context
.wined3d_context
, i
, &offsets
[i
])))
5786 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5787 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5788 ID3D10Buffer_AddRef(buffers
[i
]);
5790 wined3d_mutex_unlock();
5793 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
5795 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5796 struct d3d_rasterizer_state
*rasterizer_state_impl
;
5797 struct wined3d_rasterizer_state
*wined3d_state
;
5799 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5801 wined3d_mutex_lock();
5802 if ((wined3d_state
= wined3d_device_context_get_rasterizer_state(device
->immediate_context
.wined3d_context
)))
5804 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
5805 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
5809 *rasterizer_state
= NULL
;
5811 wined3d_mutex_unlock();
5814 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
5815 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
5817 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5818 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5819 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
5821 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
5823 if (!viewport_count
)
5826 wined3d_mutex_lock();
5827 wined3d_device_context_get_viewports(device
->immediate_context
.wined3d_context
,
5828 &actual_count
, viewports
? wined3d_vp
: NULL
);
5829 wined3d_mutex_unlock();
5833 *viewport_count
= actual_count
;
5837 if (*viewport_count
> actual_count
)
5838 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
5840 *viewport_count
= min(actual_count
, *viewport_count
);
5841 for (i
= 0; i
< *viewport_count
; ++i
)
5843 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
5844 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
5845 viewports
[i
].Width
= wined3d_vp
[i
].width
;
5846 viewports
[i
].Height
= wined3d_vp
[i
].height
;
5847 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
5848 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
5852 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
5854 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5855 unsigned int actual_count
;
5857 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
5862 actual_count
= *rect_count
;
5864 wined3d_mutex_lock();
5865 wined3d_device_context_get_scissor_rects(device
->immediate_context
.wined3d_context
, &actual_count
, rects
);
5866 wined3d_mutex_unlock();
5870 *rect_count
= actual_count
;
5874 if (*rect_count
> actual_count
)
5875 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
5878 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
5880 TRACE("iface %p.\n", iface
);
5882 /* In the current implementation the device is never removed, so we can
5883 * just return S_OK here. */
5888 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
5890 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
5895 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
5897 FIXME("iface %p stub!\n", iface
);
5902 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
5903 REFGUID guid
, UINT
*data_size
, void *data
)
5905 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5907 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5909 return d3d11_device_GetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5912 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
5913 REFGUID guid
, UINT data_size
, const void *data
)
5915 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5917 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5919 return d3d11_device_SetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5922 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
5923 REFGUID guid
, const IUnknown
*data
)
5925 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5927 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
5929 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device2_iface
, guid
, data
);
5932 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
5934 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5936 TRACE("iface %p.\n", iface
);
5938 d3d11_device_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
5941 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
5943 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5945 TRACE("iface %p.\n", iface
);
5947 wined3d_device_context_flush(device
->immediate_context
.wined3d_context
);
5950 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
5951 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
5953 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5954 D3D11_BUFFER_DESC d3d11_desc
;
5955 struct d3d_buffer
*object
;
5958 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
5960 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
5961 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5962 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5963 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5964 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5965 d3d11_desc
.StructureByteStride
= 0;
5967 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5970 *buffer
= &object
->ID3D10Buffer_iface
;
5975 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
5976 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
5978 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5979 D3D11_TEXTURE1D_DESC d3d11_desc
;
5980 struct d3d_texture1d
*object
;
5983 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5985 d3d11_desc
.Width
= desc
->Width
;
5986 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5987 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5988 d3d11_desc
.Format
= desc
->Format
;
5989 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5990 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5991 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5992 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5994 if (FAILED(hr
= d3d_texture1d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5997 *texture
= &object
->ID3D10Texture1D_iface
;
6002 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
6003 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
6004 ID3D10Texture2D
**texture
)
6006 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6007 D3D11_TEXTURE2D_DESC d3d11_desc
;
6008 struct d3d_texture2d
*object
;
6011 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
6013 d3d11_desc
.Width
= desc
->Width
;
6014 d3d11_desc
.Height
= desc
->Height
;
6015 d3d11_desc
.MipLevels
= desc
->MipLevels
;
6016 d3d11_desc
.ArraySize
= desc
->ArraySize
;
6017 d3d11_desc
.Format
= desc
->Format
;
6018 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
6019 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
6020 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
6021 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
6022 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
6024 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, NULL
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
6027 *texture
= &object
->ID3D10Texture2D_iface
;
6032 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
6033 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
6034 ID3D10Texture3D
**texture
)
6036 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6037 D3D11_TEXTURE3D_DESC d3d11_desc
;
6038 struct d3d_texture3d
*object
;
6041 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
6043 d3d11_desc
.Width
= desc
->Width
;
6044 d3d11_desc
.Height
= desc
->Height
;
6045 d3d11_desc
.Depth
= desc
->Depth
;
6046 d3d11_desc
.MipLevels
= desc
->MipLevels
;
6047 d3d11_desc
.Format
= desc
->Format
;
6048 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
6049 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
6050 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
6051 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
6053 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
6056 *texture
= &object
->ID3D10Texture3D_iface
;
6061 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
6062 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
6064 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6065 struct d3d_shader_resource_view
*object
;
6066 ID3D11Resource
*d3d11_resource
;
6069 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6074 return E_INVALIDARG
;
6076 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6078 ERR("Resource does not implement ID3D11Resource.\n");
6082 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
6084 ID3D11Resource_Release(d3d11_resource
);
6088 *view
= &object
->ID3D10ShaderResourceView1_iface
;
6093 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
6094 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
6096 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6098 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
6099 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
6102 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
6103 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
6105 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6106 struct d3d_rendertarget_view
*object
;
6107 ID3D11Resource
*d3d11_resource
;
6110 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6115 return E_INVALIDARG
;
6117 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6119 ERR("Resource does not implement ID3D11Resource.\n");
6123 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
6124 ID3D11Resource_Release(d3d11_resource
);
6128 *view
= &object
->ID3D10RenderTargetView_iface
;
6133 static D3D11_DSV_DIMENSION
d3d11_dsv_dimension_from_d3d10(D3D10_DSV_DIMENSION dim
)
6135 return (D3D11_DSV_DIMENSION
)dim
;
6138 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
6139 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
6141 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6142 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
6143 struct d3d_depthstencil_view
*object
;
6144 ID3D11Resource
*d3d11_resource
;
6147 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6153 d3d11_desc
.Format
= desc
->Format
;
6154 d3d11_desc
.ViewDimension
= d3d11_dsv_dimension_from_d3d10(desc
->ViewDimension
);
6155 d3d11_desc
.Flags
= 0;
6156 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
6159 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6161 ERR("Resource does not implement ID3D11Resource.\n");
6165 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
6166 ID3D11Resource_Release(d3d11_resource
);
6170 *view
= &object
->ID3D10DepthStencilView_iface
;
6175 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
6176 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
6177 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
6178 ID3D10InputLayout
**input_layout
)
6180 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6181 struct d3d_input_layout
*object
;
6184 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
6185 "shader_byte_code_length %Iu, input_layout %p.\n",
6186 iface
, element_descs
, element_count
, shader_byte_code
,
6187 shader_byte_code_length
, input_layout
);
6189 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
6190 shader_byte_code
, shader_byte_code_length
, &object
)))
6193 *input_layout
= &object
->ID3D10InputLayout_iface
;
6198 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
6199 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
6201 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6202 struct d3d_vertex_shader
*object
;
6205 TRACE("iface %p, byte_code %p, byte_code_length %Iu, shader %p.\n",
6206 iface
, byte_code
, byte_code_length
, shader
);
6210 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
6213 *shader
= &object
->ID3D10VertexShader_iface
;
6218 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
6219 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
6221 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6222 struct d3d_geometry_shader
*object
;
6225 TRACE("iface %p, byte_code %p, byte_code_length %Iu, shader %p.\n",
6226 iface
, byte_code
, byte_code_length
, shader
);
6230 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
6231 NULL
, 0, NULL
, 0, 0, &object
)))
6234 *shader
= &object
->ID3D10GeometryShader_iface
;
6239 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
6240 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
6241 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
6243 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6244 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
6245 struct d3d_geometry_shader
*object
;
6246 unsigned int i
, stride_count
= 1;
6249 TRACE("iface %p, byte_code %p, byte_code_length %Iu, output_stream_decls %p, "
6250 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
6251 iface
, byte_code
, byte_code_length
, output_stream_decls
,
6252 output_stream_decl_count
, output_stream_stride
, shader
);
6256 if (!output_stream_decl_count
&& output_stream_stride
)
6258 WARN("Stride must be 0 when declaration entry count is 0.\n");
6259 return E_INVALIDARG
;
6262 if (output_stream_decl_count
6263 && !(so_entries
= calloc(output_stream_decl_count
, sizeof(*so_entries
))))
6265 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
6266 return E_OUTOFMEMORY
;
6269 for (i
= 0; i
< output_stream_decl_count
; ++i
)
6271 so_entries
[i
].Stream
= 0;
6272 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
6273 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
6274 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
6275 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
6276 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
6278 if (output_stream_decls
[i
].OutputSlot
)
6281 if (output_stream_stride
)
6283 WARN("Stride must be 0 when multiple output slots are used.\n");
6285 return E_INVALIDARG
;
6290 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
6291 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
6296 *shader
= &object
->ID3D10GeometryShader_iface
;
6301 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
6302 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
6304 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6305 struct d3d_pixel_shader
*object
;
6308 TRACE("iface %p, byte_code %p, byte_code_length %Iu, shader %p.\n",
6309 iface
, byte_code
, byte_code_length
, shader
);
6313 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
6316 *shader
= &object
->ID3D10PixelShader_iface
;
6321 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
6322 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
6324 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6325 ID3D11BlendState
*object
;
6328 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
6330 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device2_iface
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
6333 *blend_state
= &impl_from_ID3D11BlendState1((ID3D11BlendState1
*)object
)->ID3D10BlendState1_iface
;
6337 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
6338 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
6340 D3D10_BLEND_DESC1 d3d10_1_desc
;
6343 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
6346 return E_INVALIDARG
;
6348 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
6349 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
6350 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
6352 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
6353 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
6354 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
6357 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
6359 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
6360 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
6361 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
6362 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
6363 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
6364 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
6365 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
6366 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
6369 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
6372 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
6373 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
6375 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6376 struct d3d_depthstencil_state
*object
;
6379 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
6381 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
6384 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
6389 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
6390 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
6392 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6393 struct d3d_rasterizer_state
*object
;
6394 D3D11_RASTERIZER_DESC1 desc1
;
6397 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
6400 return E_INVALIDARG
;
6402 memcpy(&desc1
, desc
, sizeof(*desc
));
6403 desc1
.ForcedSampleCount
= 0;
6405 if (FAILED(hr
= d3d_rasterizer_state_create(device
, &desc1
, &object
)))
6408 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
6413 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
6414 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
6416 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6417 struct d3d_sampler_state
*object
;
6420 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
6422 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
6425 *sampler_state
= &object
->ID3D10SamplerState_iface
;
6430 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
6431 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
6433 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6434 struct d3d_query
*object
;
6437 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
6439 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
6444 *query
= &object
->ID3D10Query_iface
;
6448 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6452 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
6453 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
6455 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6456 struct d3d_query
*object
;
6459 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
6461 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
6466 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
6470 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6474 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
6475 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
6477 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
6482 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
6483 DXGI_FORMAT format
, UINT
*format_support
)
6485 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6487 TRACE("iface %p, format %s, format_support %p.\n",
6488 iface
, debug_dxgi_format(format
), format_support
);
6490 return d3d11_device_CheckFormatSupport(&device
->ID3D11Device2_iface
, format
, format_support
);
6493 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
6494 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
6496 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6498 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
6499 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
6501 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device2_iface
, format
,
6502 sample_count
, quality_level_count
);
6505 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
6507 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
6510 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
6511 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
6512 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
6514 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
6515 "units %p, units_length %p, description %p, description_length %p stub!\n",
6516 iface
, desc
, type
, active_counters
, name
, name_length
,
6517 units
, units_length
, description
, description_length
);
6522 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
6524 FIXME("iface %p stub!\n", iface
);
6529 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
6530 HANDLE resource_handle
, REFIID guid
, void **resource
)
6532 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
6533 iface
, resource_handle
, debugstr_guid(guid
), resource
);
6538 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
6540 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
6543 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
6545 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
6548 static D3D10_FEATURE_LEVEL1
d3d10_feature_level1_from_d3d_feature_level(D3D_FEATURE_LEVEL level
)
6550 return (D3D10_FEATURE_LEVEL1
)level
;
6553 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
6555 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6557 TRACE("iface %p.\n", iface
);
6559 return d3d10_feature_level1_from_d3d_feature_level(device
->state
->feature_level
);
6562 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
6564 /* IUnknown methods */
6565 d3d10_device_QueryInterface
,
6566 d3d10_device_AddRef
,
6567 d3d10_device_Release
,
6568 /* ID3D10Device methods */
6569 d3d10_device_VSSetConstantBuffers
,
6570 d3d10_device_PSSetShaderResources
,
6571 d3d10_device_PSSetShader
,
6572 d3d10_device_PSSetSamplers
,
6573 d3d10_device_VSSetShader
,
6574 d3d10_device_DrawIndexed
,
6576 d3d10_device_PSSetConstantBuffers
,
6577 d3d10_device_IASetInputLayout
,
6578 d3d10_device_IASetVertexBuffers
,
6579 d3d10_device_IASetIndexBuffer
,
6580 d3d10_device_DrawIndexedInstanced
,
6581 d3d10_device_DrawInstanced
,
6582 d3d10_device_GSSetConstantBuffers
,
6583 d3d10_device_GSSetShader
,
6584 d3d10_device_IASetPrimitiveTopology
,
6585 d3d10_device_VSSetShaderResources
,
6586 d3d10_device_VSSetSamplers
,
6587 d3d10_device_SetPredication
,
6588 d3d10_device_GSSetShaderResources
,
6589 d3d10_device_GSSetSamplers
,
6590 d3d10_device_OMSetRenderTargets
,
6591 d3d10_device_OMSetBlendState
,
6592 d3d10_device_OMSetDepthStencilState
,
6593 d3d10_device_SOSetTargets
,
6594 d3d10_device_DrawAuto
,
6595 d3d10_device_RSSetState
,
6596 d3d10_device_RSSetViewports
,
6597 d3d10_device_RSSetScissorRects
,
6598 d3d10_device_CopySubresourceRegion
,
6599 d3d10_device_CopyResource
,
6600 d3d10_device_UpdateSubresource
,
6601 d3d10_device_ClearRenderTargetView
,
6602 d3d10_device_ClearDepthStencilView
,
6603 d3d10_device_GenerateMips
,
6604 d3d10_device_ResolveSubresource
,
6605 d3d10_device_VSGetConstantBuffers
,
6606 d3d10_device_PSGetShaderResources
,
6607 d3d10_device_PSGetShader
,
6608 d3d10_device_PSGetSamplers
,
6609 d3d10_device_VSGetShader
,
6610 d3d10_device_PSGetConstantBuffers
,
6611 d3d10_device_IAGetInputLayout
,
6612 d3d10_device_IAGetVertexBuffers
,
6613 d3d10_device_IAGetIndexBuffer
,
6614 d3d10_device_GSGetConstantBuffers
,
6615 d3d10_device_GSGetShader
,
6616 d3d10_device_IAGetPrimitiveTopology
,
6617 d3d10_device_VSGetShaderResources
,
6618 d3d10_device_VSGetSamplers
,
6619 d3d10_device_GetPredication
,
6620 d3d10_device_GSGetShaderResources
,
6621 d3d10_device_GSGetSamplers
,
6622 d3d10_device_OMGetRenderTargets
,
6623 d3d10_device_OMGetBlendState
,
6624 d3d10_device_OMGetDepthStencilState
,
6625 d3d10_device_SOGetTargets
,
6626 d3d10_device_RSGetState
,
6627 d3d10_device_RSGetViewports
,
6628 d3d10_device_RSGetScissorRects
,
6629 d3d10_device_GetDeviceRemovedReason
,
6630 d3d10_device_SetExceptionMode
,
6631 d3d10_device_GetExceptionMode
,
6632 d3d10_device_GetPrivateData
,
6633 d3d10_device_SetPrivateData
,
6634 d3d10_device_SetPrivateDataInterface
,
6635 d3d10_device_ClearState
,
6637 d3d10_device_CreateBuffer
,
6638 d3d10_device_CreateTexture1D
,
6639 d3d10_device_CreateTexture2D
,
6640 d3d10_device_CreateTexture3D
,
6641 d3d10_device_CreateShaderResourceView
,
6642 d3d10_device_CreateRenderTargetView
,
6643 d3d10_device_CreateDepthStencilView
,
6644 d3d10_device_CreateInputLayout
,
6645 d3d10_device_CreateVertexShader
,
6646 d3d10_device_CreateGeometryShader
,
6647 d3d10_device_CreateGeometryShaderWithStreamOutput
,
6648 d3d10_device_CreatePixelShader
,
6649 d3d10_device_CreateBlendState
,
6650 d3d10_device_CreateDepthStencilState
,
6651 d3d10_device_CreateRasterizerState
,
6652 d3d10_device_CreateSamplerState
,
6653 d3d10_device_CreateQuery
,
6654 d3d10_device_CreatePredicate
,
6655 d3d10_device_CreateCounter
,
6656 d3d10_device_CheckFormatSupport
,
6657 d3d10_device_CheckMultisampleQualityLevels
,
6658 d3d10_device_CheckCounterInfo
,
6659 d3d10_device_CheckCounter
,
6660 d3d10_device_GetCreationFlags
,
6661 d3d10_device_OpenSharedResource
,
6662 d3d10_device_SetTextFilterSize
,
6663 d3d10_device_GetTextFilterSize
,
6664 d3d10_device_CreateShaderResourceView1
,
6665 d3d10_device_CreateBlendState1
,
6666 d3d10_device_GetFeatureLevel
,
6669 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
6671 /* IUnknown methods */
6672 d3d_device_inner_QueryInterface
,
6673 d3d_device_inner_AddRef
,
6674 d3d_device_inner_Release
,
6677 /* ID3D10Multithread methods */
6679 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
6681 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
6684 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
6686 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6688 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
6690 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6693 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
6695 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6697 TRACE("iface %p.\n", iface
);
6699 return IUnknown_AddRef(device
->outer_unk
);
6702 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
6704 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6706 TRACE("iface %p.\n", iface
);
6708 return IUnknown_Release(device
->outer_unk
);
6711 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
6713 TRACE("iface %p.\n", iface
);
6715 wined3d_mutex_lock();
6718 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
6720 TRACE("iface %p.\n", iface
);
6722 wined3d_mutex_unlock();
6725 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL enable
)
6727 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
6732 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
6734 FIXME("iface %p stub!\n", iface
);
6739 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
6741 d3d10_multithread_QueryInterface
,
6742 d3d10_multithread_AddRef
,
6743 d3d10_multithread_Release
,
6744 d3d10_multithread_Enter
,
6745 d3d10_multithread_Leave
,
6746 d3d10_multithread_SetMultithreadProtected
,
6747 d3d10_multithread_GetMultithreadProtected
,
6750 /* IWineDXGIDeviceParent IUnknown methods */
6752 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
6754 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
6757 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
6758 REFIID iid
, void **out
)
6760 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6761 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6764 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
6766 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6767 return IUnknown_AddRef(device
->outer_unk
);
6770 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
6772 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6773 return IUnknown_Release(device
->outer_unk
);
6776 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
6777 IWineDXGIDeviceParent
*iface
)
6779 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6780 return &device
->device_parent
;
6783 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_register_swapchain_texture(IWineDXGIDeviceParent
*iface
,
6784 struct wined3d_texture
*wined3d_texture
, unsigned int texture_flags
, IDXGISurface
**ret_surface
)
6786 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6787 struct wined3d_resource_desc wined3d_desc
;
6788 struct d3d_texture2d
*object
;
6789 D3D11_TEXTURE2D_DESC desc
;
6792 wined3d_resource_get_desc(wined3d_texture_get_resource(wined3d_texture
), &wined3d_desc
);
6794 desc
.Width
= wined3d_desc
.width
;
6795 desc
.Height
= wined3d_desc
.height
;
6798 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
.format
);
6799 desc
.SampleDesc
.Count
= wined3d_desc
.multisample_type
? wined3d_desc
.multisample_type
: 1;
6800 desc
.SampleDesc
.Quality
= wined3d_desc
.multisample_quality
;
6801 desc
.Usage
= D3D11_USAGE_DEFAULT
;
6802 desc
.BindFlags
= d3d11_bind_flags_from_wined3d(wined3d_desc
.bind_flags
);
6803 desc
.CPUAccessFlags
= 0;
6806 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
6808 desc
.MiscFlags
|= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
6809 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
6813 FIXME("Unhandled flags %#x.\n", texture_flags
);
6815 if (FAILED(hr
= d3d_texture2d_create(device
, &desc
, wined3d_texture
, NULL
, &object
)))
6818 hr
= IUnknown_QueryInterface(object
->dxgi_resource
, &IID_IDXGISurface
, (void **)ret_surface
);
6819 ID3D11Texture2D_Release(&object
->ID3D11Texture2D_iface
);
6823 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
6825 /* IUnknown methods */
6826 dxgi_device_parent_QueryInterface
,
6827 dxgi_device_parent_AddRef
,
6828 dxgi_device_parent_Release
,
6829 /* IWineDXGIDeviceParent methods */
6830 dxgi_device_parent_get_wined3d_device_parent
,
6831 dxgi_device_parent_register_swapchain_texture
,
6834 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
6836 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
6839 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
6840 struct wined3d_device
*wined3d_device
)
6842 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6843 struct d3d_device_context_state
*state
;
6844 struct wined3d_state
*wined3d_state
;
6845 D3D_FEATURE_LEVEL feature_level
;
6847 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
6849 wined3d_device_incref(wined3d_device
);
6850 device
->wined3d_device
= wined3d_device
;
6851 device
->immediate_context
.wined3d_context
= wined3d_device_get_immediate_context(wined3d_device
);
6853 wined3d_state
= wined3d_device_get_state(device
->wined3d_device
);
6854 feature_level
= d3d_feature_level_from_wined3d(wined3d_state_get_feature_level(wined3d_state
));
6856 if (!(state
= calloc(1, sizeof(*state
))))
6858 ERR("Failed to create the initial device context state.\n");
6862 d3d_device_context_state_init(state
, device
, feature_level
,
6863 device
->d3d11_only
? &IID_ID3D11Device2
: &IID_ID3D10Device1
);
6865 device
->state
= state
;
6866 if (!d3d_device_context_state_add_entry(state
, device
, wined3d_state
))
6867 ERR("Failed to add entry for wined3d state %p, device %p.\n", wined3d_state
, device
);
6869 d3d_device_context_state_private_addref(state
);
6870 ID3DDeviceContextState_Release(&state
->ID3DDeviceContextState_iface
);
6873 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
6875 TRACE("device_parent %p.\n", device_parent
);
6878 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
6880 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
6883 static HRESULT CDECL
device_parent_texture_sub_resource_created(struct wined3d_device_parent
*device_parent
,
6884 enum wined3d_resource_type type
, struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
,
6885 void **parent
, const struct wined3d_parent_ops
**parent_ops
)
6887 TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
6888 device_parent
, type
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
6891 *parent_ops
= &d3d_null_wined3d_parent_ops
;
6896 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
6898 device_parent_wined3d_device_created
,
6899 device_parent_mode_changed
,
6900 device_parent_activate
,
6901 device_parent_texture_sub_resource_created
,
6904 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6906 const D3D11_SAMPLER_DESC
*ka
= key
;
6907 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
6909 return memcmp(ka
, kb
, sizeof(*ka
));
6912 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6914 const D3D11_BLEND_DESC1
*ka
= key
;
6915 const D3D11_BLEND_DESC1
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
6917 return memcmp(ka
, kb
, sizeof(*ka
));
6920 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6922 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
6923 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
6924 const struct d3d_depthstencil_state
, entry
)->desc
;
6926 return memcmp(ka
, kb
, sizeof(*ka
));
6929 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6931 const D3D11_RASTERIZER_DESC1
*ka
= key
;
6932 const D3D11_RASTERIZER_DESC1
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
6934 return memcmp(ka
, kb
, sizeof(*ka
));
6937 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
6939 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
6940 device
->ID3D11Device2_iface
.lpVtbl
= &d3d11_device_vtbl
;
6941 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
6942 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
6943 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
6944 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
6945 device
->refcount
= 1;
6946 /* COM aggregation always takes place */
6947 device
->outer_unk
= outer_unknown
;
6948 device
->d3d11_only
= FALSE
;
6949 device
->state
= NULL
;
6951 d3d11_device_context_init(&device
->immediate_context
, device
, D3D11_DEVICE_CONTEXT_IMMEDIATE
);
6952 ID3D11DeviceContext1_Release(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
6954 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
6955 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
6956 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
6957 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);