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
= heap_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 %u.\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 %u.\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 %u.\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 heap_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 %u.\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 %u.\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 %u.\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 %u.\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 %u.\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
);
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
);
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 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
803 && map_type
!= D3D11_MAP_WRITE_DISCARD
&& map_type
!= D3D11_MAP_WRITE_NO_OVERWRITE
)
806 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
808 hr
= wined3d_device_context_map(context
->wined3d_context
, wined3d_resource
, subresource_idx
,
809 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
811 mapped_subresource
->pData
= map_desc
.data
;
812 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
813 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
818 static void STDMETHODCALLTYPE
d3d11_device_context_Unmap(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
819 UINT subresource_idx
)
821 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
822 struct wined3d_resource
*wined3d_resource
;
824 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
826 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
828 wined3d_device_context_unmap(context
->wined3d_context
, wined3d_resource
, subresource_idx
);
831 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
832 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
834 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
835 iface
, start_slot
, buffer_count
, buffers
);
837 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
838 buffer_count
, buffers
, NULL
, NULL
);
841 static void STDMETHODCALLTYPE
d3d11_device_context_IASetInputLayout(ID3D11DeviceContext1
*iface
,
842 ID3D11InputLayout
*input_layout
)
844 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
845 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
847 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
849 wined3d_device_context_set_vertex_declaration(context
->wined3d_context
, layout
? layout
->wined3d_decl
: NULL
);
852 static void STDMETHODCALLTYPE
d3d11_device_context_IASetVertexBuffers(ID3D11DeviceContext1
*iface
,
853 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
855 struct wined3d_stream_state streams
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
856 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
859 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
860 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
862 if (buffer_count
> ARRAY_SIZE(streams
))
864 WARN("Buffer count %u exceeds limit.\n", buffer_count
);
865 buffer_count
= ARRAY_SIZE(streams
);
868 for (i
= 0; i
< buffer_count
; ++i
)
870 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
872 streams
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
873 streams
[i
].offset
= offsets
[i
];
874 streams
[i
].stride
= strides
[i
];
875 streams
[i
].frequency
= 1;
876 streams
[i
].flags
= 0;
879 wined3d_device_context_set_stream_sources(context
->wined3d_context
, start_slot
, buffer_count
, streams
);
882 static void STDMETHODCALLTYPE
d3d11_device_context_IASetIndexBuffer(ID3D11DeviceContext1
*iface
,
883 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
885 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
886 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
888 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
889 iface
, buffer
, debug_dxgi_format(format
), offset
);
891 wined3d_device_context_set_index_buffer(context
->wined3d_context
,
892 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
893 wined3dformat_from_dxgi_format(format
), offset
);
896 static void STDMETHODCALLTYPE
d3d11_device_context_DrawIndexedInstanced(ID3D11DeviceContext1
*iface
,
897 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
898 UINT start_instance_location
)
900 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
902 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
903 "base_vertex_location %d, start_instance_location %u.\n",
904 iface
, instance_index_count
, instance_count
, start_index_location
,
905 base_vertex_location
, start_instance_location
);
907 wined3d_device_context_draw_indexed(context
->wined3d_context
, base_vertex_location
,
908 start_index_location
, instance_index_count
, start_instance_location
, instance_count
);
911 static void STDMETHODCALLTYPE
d3d11_device_context_DrawInstanced(ID3D11DeviceContext1
*iface
,
912 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
914 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
916 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
917 "start_instance_location %u.\n",
918 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
919 start_instance_location
);
921 wined3d_device_context_draw(context
->wined3d_context
, start_vertex_location
,
922 instance_vertex_count
, start_instance_location
, instance_count
);
925 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
926 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
928 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
929 iface
, start_slot
, buffer_count
, buffers
);
931 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
932 buffer_count
, buffers
, NULL
, NULL
);
935 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetShader(ID3D11DeviceContext1
*iface
,
936 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
938 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
939 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
941 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
942 iface
, shader
, class_instances
, class_instance_count
);
945 FIXME("Dynamic linking is not implemented yet.\n");
947 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
,
948 gs
? gs
->wined3d_shader
: NULL
);
951 static void STDMETHODCALLTYPE
d3d11_device_context_IASetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
952 D3D11_PRIMITIVE_TOPOLOGY topology
)
954 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
955 enum wined3d_primitive_type primitive_type
;
956 unsigned int patch_vertex_count
;
958 TRACE("iface %p, topology %#x.\n", iface
, topology
);
960 wined3d_primitive_type_from_d3d11_primitive_topology(topology
, &primitive_type
, &patch_vertex_count
);
962 wined3d_device_context_set_primitive_type(context
->wined3d_context
, primitive_type
, patch_vertex_count
);
965 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetShaderResources(ID3D11DeviceContext1
*iface
,
966 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
968 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
970 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, view_count
, views
);
973 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetSamplers(ID3D11DeviceContext1
*iface
,
974 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
976 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
977 iface
, start_slot
, sampler_count
, samplers
);
979 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, sampler_count
, samplers
);
982 static void STDMETHODCALLTYPE
d3d11_device_context_Begin(ID3D11DeviceContext1
*iface
,
983 ID3D11Asynchronous
*asynchronous
)
985 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
986 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
988 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
990 wined3d_device_context_issue_query(context
->wined3d_context
, query
->wined3d_query
, WINED3DISSUE_BEGIN
);
993 static void STDMETHODCALLTYPE
d3d11_device_context_End(ID3D11DeviceContext1
*iface
,
994 ID3D11Asynchronous
*asynchronous
)
996 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
997 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
999 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
1001 wined3d_device_context_issue_query(context
->wined3d_context
, query
->wined3d_query
, WINED3DISSUE_END
);
1004 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_GetData(ID3D11DeviceContext1
*iface
,
1005 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
1007 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1008 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
1009 unsigned int wined3d_flags
;
1012 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
1013 iface
, asynchronous
, data
, data_size
, data_flags
);
1015 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
)
1016 return DXGI_ERROR_INVALID_CALL
;
1018 if (!data
&& data_size
)
1019 return E_INVALIDARG
;
1021 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
1023 wined3d_mutex_lock();
1024 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
1026 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
1027 if (hr
== WINED3DERR_INVALIDCALL
)
1028 hr
= DXGI_ERROR_INVALID_CALL
;
1032 WARN("Invalid data size %u.\n", data_size
);
1035 wined3d_mutex_unlock();
1040 static void STDMETHODCALLTYPE
d3d11_device_context_SetPredication(ID3D11DeviceContext1
*iface
,
1041 ID3D11Predicate
*predicate
, BOOL value
)
1043 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1044 struct d3d_query
*query
;
1046 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
1048 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
1050 wined3d_device_context_set_predication(context
->wined3d_context
, query
? query
->wined3d_query
: NULL
, value
);
1053 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetShaderResources(ID3D11DeviceContext1
*iface
,
1054 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1056 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1058 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, view_count
, views
);
1061 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetSamplers(ID3D11DeviceContext1
*iface
,
1062 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1064 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1065 iface
, start_slot
, sampler_count
, samplers
);
1067 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, sampler_count
, samplers
);
1070 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetRenderTargets(ID3D11DeviceContext1
*iface
,
1071 UINT rtv_count
, ID3D11RenderTargetView
*const *rtvs
, ID3D11DepthStencilView
*depth_stencil_view
)
1073 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
1074 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1075 struct d3d_depthstencil_view
*dsv
;
1078 TRACE("iface %p, rtv_count %u, rtvs %p, depth_stencil_view %p.\n", iface
, rtv_count
, rtvs
, depth_stencil_view
);
1080 if (rtv_count
> ARRAY_SIZE(wined3d_rtvs
))
1082 WARN("View count %u exceeds limit.\n", rtv_count
);
1083 rtv_count
= ARRAY_SIZE(wined3d_rtvs
);
1086 for (i
= 0; i
< rtv_count
; ++i
)
1088 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(rtvs
[i
]);
1090 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
1093 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1095 wined3d_device_context_set_render_targets_and_unordered_access_views(context
->wined3d_context
,
1096 ARRAY_SIZE(wined3d_rtvs
), wined3d_rtvs
, dsv
? dsv
->wined3d_view
: NULL
, ~0u, NULL
, NULL
);
1099 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetRenderTargetsAndUnorderedAccessViews(
1100 ID3D11DeviceContext1
*iface
, UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
1101 ID3D11DepthStencilView
*depth_stencil_view
, UINT uav_start_idx
, UINT uav_count
,
1102 ID3D11UnorderedAccessView
*const *uavs
, const UINT
*initial_counts
)
1104 struct d3d_depthstencil_view
*dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1105 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
1106 struct wined3d_unordered_access_view
*wined3d_uavs
[D3D11_PS_CS_UAV_REGISTER_COUNT
] = {0};
1107 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1108 unsigned int wined3d_initial_counts
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
1111 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1112 "uav_start_idx %u, uav_count %u, uavs %p, initial_counts %p.\n",
1113 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1114 uav_start_idx
, uav_count
, uavs
, initial_counts
);
1116 if (render_target_view_count
== D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
1117 render_target_view_count
= ~0u;
1120 if (render_target_view_count
> ARRAY_SIZE(wined3d_rtvs
))
1122 WARN("View count %u exceeds limit.\n", render_target_view_count
);
1123 render_target_view_count
= ARRAY_SIZE(wined3d_rtvs
);
1126 for (i
= 0; i
< render_target_view_count
; ++i
)
1128 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
1130 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
1134 if (uav_count
== D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
1138 if (!wined3d_bound_range(uav_start_idx
, uav_count
, ARRAY_SIZE(wined3d_uavs
)))
1140 WARN("View count %u exceeds limit; ignoring call.\n", uav_count
);
1144 memset(wined3d_initial_counts
, 0xff, sizeof(wined3d_initial_counts
));
1146 for (i
= 0; i
< uav_count
; ++i
)
1148 struct d3d11_unordered_access_view
*view
=
1149 unsafe_impl_from_ID3D11UnorderedAccessView(uavs
[i
]);
1151 wined3d_uavs
[uav_start_idx
+ i
] = view
? view
->wined3d_view
: NULL
;
1152 wined3d_initial_counts
[uav_start_idx
+ i
] = initial_counts
? initial_counts
[i
] : ~0u;
1156 wined3d_device_context_set_render_targets_and_unordered_access_views(context
->wined3d_context
, ARRAY_SIZE(wined3d_rtvs
),
1157 wined3d_rtvs
, dsv
? dsv
->wined3d_view
: NULL
, ARRAY_SIZE(wined3d_uavs
), wined3d_uavs
,
1158 wined3d_initial_counts
);
1161 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetBlendState(ID3D11DeviceContext1
*iface
,
1162 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
1164 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1165 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
1166 struct d3d_blend_state
*blend_state_impl
;
1168 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
1169 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
1172 blend_factor
= default_blend_factor
;
1174 if (!(blend_state_impl
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
1175 wined3d_device_context_set_blend_state(context
->wined3d_context
, NULL
,
1176 (const struct wined3d_color
*)blend_factor
, sample_mask
);
1178 wined3d_device_context_set_blend_state(context
->wined3d_context
, blend_state_impl
->wined3d_state
,
1179 (const struct wined3d_color
*)blend_factor
, sample_mask
);
1182 static void STDMETHODCALLTYPE
d3d11_device_context_OMSetDepthStencilState(ID3D11DeviceContext1
*iface
,
1183 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
1185 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1186 struct d3d_depthstencil_state
*state_impl
;
1188 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
1189 iface
, depth_stencil_state
, stencil_ref
);
1191 if (!(state_impl
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
1193 wined3d_device_context_set_depth_stencil_state(context
->wined3d_context
, NULL
, stencil_ref
);
1197 wined3d_device_context_set_depth_stencil_state(context
->wined3d_context
, state_impl
->wined3d_state
, stencil_ref
);
1200 static void STDMETHODCALLTYPE
d3d11_device_context_SOSetTargets(ID3D11DeviceContext1
*iface
, UINT buffer_count
,
1201 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
1203 struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
] = {0};
1204 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1205 unsigned int count
, i
;
1207 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
1209 count
= min(buffer_count
, ARRAY_SIZE(outputs
));
1210 for (i
= 0; i
< count
; ++i
)
1212 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
1214 outputs
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
1215 outputs
[i
].offset
= offsets
? offsets
[i
] : 0;
1218 wined3d_device_context_set_stream_outputs(context
->wined3d_context
, outputs
);
1221 static void STDMETHODCALLTYPE
d3d11_device_context_DrawAuto(ID3D11DeviceContext1
*iface
)
1223 FIXME("iface %p stub!\n", iface
);
1226 static void STDMETHODCALLTYPE
d3d11_device_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext1
*iface
,
1227 ID3D11Buffer
*buffer
, UINT offset
)
1229 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1230 struct d3d_buffer
*d3d_buffer
;
1232 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1234 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
1236 wined3d_device_context_draw_indirect(context
->wined3d_context
, d3d_buffer
->wined3d_buffer
, offset
, true);
1239 static void STDMETHODCALLTYPE
d3d11_device_context_DrawInstancedIndirect(ID3D11DeviceContext1
*iface
,
1240 ID3D11Buffer
*buffer
, UINT offset
)
1242 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1243 struct d3d_buffer
*d3d_buffer
;
1245 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1247 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
1249 wined3d_device_context_draw_indirect(context
->wined3d_context
, d3d_buffer
->wined3d_buffer
, offset
, false);
1252 static void STDMETHODCALLTYPE
d3d11_device_context_Dispatch(ID3D11DeviceContext1
*iface
,
1253 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
1255 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1257 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
1258 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
1260 wined3d_device_context_dispatch(context
->wined3d_context
,
1261 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
1264 static void STDMETHODCALLTYPE
d3d11_device_context_DispatchIndirect(ID3D11DeviceContext1
*iface
,
1265 ID3D11Buffer
*buffer
, UINT offset
)
1267 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1268 struct d3d_buffer
*buffer_impl
;
1270 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1272 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
1274 wined3d_device_context_dispatch_indirect(context
->wined3d_context
, buffer_impl
->wined3d_buffer
, offset
);
1277 static void STDMETHODCALLTYPE
d3d11_device_context_RSSetState(ID3D11DeviceContext1
*iface
,
1278 ID3D11RasterizerState
*rasterizer_state
)
1280 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1281 struct d3d_rasterizer_state
*rasterizer_state_impl
;
1283 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1285 rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
);
1286 wined3d_device_context_set_rasterizer_state(context
->wined3d_context
,
1287 rasterizer_state_impl
? rasterizer_state_impl
->wined3d_state
: NULL
);
1290 static void STDMETHODCALLTYPE
d3d11_device_context_RSSetViewports(ID3D11DeviceContext1
*iface
,
1291 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
1293 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1294 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
1297 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
1299 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
1302 for (i
= 0; i
< viewport_count
; ++i
)
1304 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
1305 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
1306 wined3d_vp
[i
].width
= viewports
[i
].Width
;
1307 wined3d_vp
[i
].height
= viewports
[i
].Height
;
1308 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
1309 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
1312 wined3d_device_context_set_viewports(context
->wined3d_context
, viewport_count
, wined3d_vp
);
1315 static void STDMETHODCALLTYPE
d3d11_device_context_RSSetScissorRects(ID3D11DeviceContext1
*iface
,
1316 UINT rect_count
, const D3D11_RECT
*rects
)
1318 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1320 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
1322 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
1325 wined3d_device_context_set_scissor_rects(context
->wined3d_context
, rect_count
, rects
);
1328 static void STDMETHODCALLTYPE
d3d11_device_context_CopySubresourceRegion(ID3D11DeviceContext1
*iface
,
1329 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
1330 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
1332 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1333 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1334 struct wined3d_box wined3d_src_box
;
1336 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
1337 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
1338 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
1339 src_resource
, src_subresource_idx
, src_box
);
1341 if (!dst_resource
|| !src_resource
)
1345 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
1346 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
1348 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1349 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1350 wined3d_device_context_copy_sub_resource_region(context
->wined3d_context
, wined3d_dst_resource
, dst_subresource_idx
,
1351 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
1354 static void STDMETHODCALLTYPE
d3d11_device_context_CopyResource(ID3D11DeviceContext1
*iface
,
1355 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
1357 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1358 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1360 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1362 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1363 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1364 wined3d_device_context_copy_resource(context
->wined3d_context
, wined3d_dst_resource
, wined3d_src_resource
);
1367 static void STDMETHODCALLTYPE
d3d11_device_context_UpdateSubresource(ID3D11DeviceContext1
*iface
,
1368 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1369 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1371 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1372 struct wined3d_resource
*wined3d_resource
;
1373 struct wined3d_box wined3d_box
;
1375 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1376 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1379 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1381 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1382 wined3d_device_context_update_sub_resource(context
->wined3d_context
, wined3d_resource
,
1383 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, 0);
1386 static void STDMETHODCALLTYPE
d3d11_device_context_CopyStructureCount(ID3D11DeviceContext1
*iface
,
1387 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1389 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1390 struct d3d11_unordered_access_view
*uav
;
1391 struct d3d_buffer
*buffer_impl
;
1393 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1394 iface
, dst_buffer
, dst_offset
, src_view
);
1396 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1397 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1399 wined3d_device_context_copy_uav_counter(context
->wined3d_context
,
1400 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1403 static void STDMETHODCALLTYPE
d3d11_device_context_ClearRenderTargetView(ID3D11DeviceContext1
*iface
,
1404 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1406 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1407 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1408 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1411 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1412 iface
, render_target_view
, debug_float4(color_rgba
));
1417 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(context
->wined3d_context
, view
->wined3d_view
, NULL
,
1418 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1419 ERR("Failed to clear view, hr %#x.\n", hr
);
1422 static void STDMETHODCALLTYPE
d3d11_device_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1
*iface
,
1423 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1425 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1426 struct d3d11_unordered_access_view
*view
;
1428 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1429 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1431 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1432 wined3d_device_context_clear_uav_uint(context
->wined3d_context
,
1433 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1436 static void STDMETHODCALLTYPE
d3d11_device_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1
*iface
,
1437 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1439 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1440 struct d3d11_unordered_access_view
*view
;
1442 TRACE("iface %p, unordered_access_view %p, values %s.\n",
1443 iface
, unordered_access_view
, debug_float4(values
));
1445 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1446 wined3d_device_context_clear_uav_float(context
->wined3d_context
,
1447 view
->wined3d_view
, (const struct wined3d_vec4
*)values
);
1450 static void STDMETHODCALLTYPE
d3d11_device_context_ClearDepthStencilView(ID3D11DeviceContext1
*iface
,
1451 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1453 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1454 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1455 DWORD wined3d_flags
;
1458 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1459 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1464 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1466 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(context
->wined3d_context
, view
->wined3d_view
, NULL
,
1467 wined3d_flags
, NULL
, depth
, stencil
)))
1468 ERR("Failed to clear view, hr %#x.\n", hr
);
1471 static void STDMETHODCALLTYPE
d3d11_device_context_GenerateMips(ID3D11DeviceContext1
*iface
,
1472 ID3D11ShaderResourceView
*view
)
1474 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1475 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D11ShaderResourceView(view
);
1477 TRACE("iface %p, view %p.\n", iface
, view
);
1479 wined3d_device_context_generate_mipmaps(context
->wined3d_context
, srv
->wined3d_view
);
1482 static void STDMETHODCALLTYPE
d3d11_device_context_SetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1483 ID3D11Resource
*resource
, FLOAT min_lod
)
1485 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1488 static FLOAT STDMETHODCALLTYPE
d3d11_device_context_GetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1489 ID3D11Resource
*resource
)
1491 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1496 static void STDMETHODCALLTYPE
d3d11_device_context_ResolveSubresource(ID3D11DeviceContext1
*iface
,
1497 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1498 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1501 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1502 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1503 enum wined3d_format_id wined3d_format
;
1505 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
1506 "src_resource %p, src_subresource_idx %u, format %s.\n",
1507 iface
, dst_resource
, dst_subresource_idx
,
1508 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1510 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1511 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1512 wined3d_format
= wined3dformat_from_dxgi_format(format
);
1513 wined3d_device_context_resolve_sub_resource(context
->wined3d_context
,
1514 wined3d_dst_resource
, dst_subresource_idx
,
1515 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
1518 static void STDMETHODCALLTYPE
d3d11_device_context_ExecuteCommandList(ID3D11DeviceContext1
*iface
,
1519 ID3D11CommandList
*command_list
, BOOL restore_state
)
1521 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1522 struct d3d11_command_list
*list_impl
= unsafe_impl_from_ID3D11CommandList(command_list
);
1524 TRACE("iface %p, command_list %p, restore_state %#x.\n", iface
, command_list
, restore_state
);
1526 wined3d_device_context_execute_command_list(context
->wined3d_context
, list_impl
->wined3d_list
, !!restore_state
);
1529 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetShaderResources(ID3D11DeviceContext1
*iface
,
1530 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1532 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1533 iface
, start_slot
, view_count
, views
);
1535 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
, view_count
, views
);
1538 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetShader(ID3D11DeviceContext1
*iface
,
1539 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1541 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1542 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1544 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1545 iface
, shader
, class_instances
, class_instance_count
);
1547 if (class_instances
)
1548 FIXME("Dynamic linking is not implemented yet.\n");
1550 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
,
1551 hs
? hs
->wined3d_shader
: NULL
);
1554 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetSamplers(ID3D11DeviceContext1
*iface
,
1555 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1557 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1558 iface
, start_slot
, sampler_count
, samplers
);
1560 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
, sampler_count
, samplers
);
1563 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1564 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1566 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1567 iface
, start_slot
, buffer_count
, buffers
);
1569 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
1570 buffer_count
, buffers
, NULL
, NULL
);
1573 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetShaderResources(ID3D11DeviceContext1
*iface
,
1574 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1576 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1577 iface
, start_slot
, view_count
, views
);
1579 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
, view_count
, views
);
1582 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetShader(ID3D11DeviceContext1
*iface
,
1583 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1585 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1586 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1588 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1589 iface
, shader
, class_instances
, class_instance_count
);
1591 if (class_instances
)
1592 FIXME("Dynamic linking is not implemented yet.\n");
1594 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
,
1595 ds
? ds
->wined3d_shader
: NULL
);
1598 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetSamplers(ID3D11DeviceContext1
*iface
,
1599 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1601 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1602 iface
, start_slot
, sampler_count
, samplers
);
1604 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
, sampler_count
, samplers
);
1607 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1608 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1610 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1611 iface
, start_slot
, buffer_count
, buffers
);
1613 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
1614 buffer_count
, buffers
, NULL
, NULL
);
1617 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetShaderResources(ID3D11DeviceContext1
*iface
,
1618 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1620 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1621 iface
, start_slot
, view_count
, views
);
1623 d3d11_device_context_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
, view_count
, views
);
1626 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
1627 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1629 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1630 struct wined3d_unordered_access_view
*wined3d_views
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
1633 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1634 iface
, start_slot
, view_count
, views
, initial_counts
);
1636 if (view_count
> ARRAY_SIZE(wined3d_views
))
1638 WARN("View count %u exceeds limit; ignoring call.\n", view_count
);
1642 for (i
= 0; i
< view_count
; ++i
)
1644 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1646 wined3d_views
[i
] = view
? view
->wined3d_view
: NULL
;
1649 wined3d_device_context_set_unordered_access_views(context
->wined3d_context
, WINED3D_PIPELINE_COMPUTE
,
1650 start_slot
, view_count
, wined3d_views
, initial_counts
);
1653 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetShader(ID3D11DeviceContext1
*iface
,
1654 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1656 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1657 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1659 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1660 iface
, shader
, class_instances
, class_instance_count
);
1662 if (class_instances
)
1663 FIXME("Dynamic linking is not implemented yet.\n");
1665 wined3d_device_context_set_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
,
1666 cs
? cs
->wined3d_shader
: NULL
);
1669 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetSamplers(ID3D11DeviceContext1
*iface
,
1670 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1672 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1673 iface
, start_slot
, sampler_count
, samplers
);
1675 d3d11_device_context_set_samplers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
, sampler_count
, samplers
);
1678 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1679 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1681 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1682 iface
, start_slot
, buffer_count
, buffers
);
1684 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
1685 buffer_count
, buffers
, NULL
, NULL
);
1688 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1689 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1691 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1692 iface
, start_slot
, buffer_count
, buffers
);
1694 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
1695 buffer_count
, buffers
, NULL
, NULL
);
1698 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetShaderResources(ID3D11DeviceContext1
*iface
,
1699 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1701 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1704 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1705 iface
, start_slot
, view_count
, views
);
1707 wined3d_mutex_lock();
1708 for (i
= 0; i
< view_count
; ++i
)
1710 struct wined3d_shader_resource_view
*wined3d_view
;
1711 struct d3d_shader_resource_view
*view_impl
;
1713 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
1714 context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
1720 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1721 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1722 ID3D11ShaderResourceView_AddRef(views
[i
]);
1724 wined3d_mutex_unlock();
1727 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetShader(ID3D11DeviceContext1
*iface
,
1728 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1730 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1731 struct wined3d_shader
*wined3d_shader
;
1732 struct d3d_pixel_shader
*shader_impl
;
1734 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1735 iface
, shader
, class_instances
, class_instance_count
);
1737 if (class_instances
|| class_instance_count
)
1738 FIXME("Dynamic linking not implemented yet.\n");
1739 if (class_instance_count
)
1740 *class_instance_count
= 0;
1742 wined3d_mutex_lock();
1743 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
)))
1745 wined3d_mutex_unlock();
1750 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1751 wined3d_mutex_unlock();
1752 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1753 ID3D11PixelShader_AddRef(*shader
);
1756 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetSamplers(ID3D11DeviceContext1
*iface
,
1757 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1759 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1762 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1763 iface
, start_slot
, sampler_count
, samplers
);
1765 wined3d_mutex_lock();
1766 for (i
= 0; i
< sampler_count
; ++i
)
1768 struct wined3d_sampler
*wined3d_sampler
;
1769 struct d3d_sampler_state
*sampler_impl
;
1771 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
1772 context
->wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
1778 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1779 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1780 ID3D11SamplerState_AddRef(samplers
[i
]);
1782 wined3d_mutex_unlock();
1785 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetShader(ID3D11DeviceContext1
*iface
,
1786 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1788 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1789 struct d3d_vertex_shader
*shader_impl
;
1790 struct wined3d_shader
*wined3d_shader
;
1792 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1793 iface
, shader
, class_instances
, class_instance_count
);
1795 if (class_instances
|| class_instance_count
)
1796 FIXME("Dynamic linking not implemented yet.\n");
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_instances
|| class_instance_count
)
1930 FIXME("Dynamic linking not implemented yet.\n");
1931 if (class_instance_count
)
1932 *class_instance_count
= 0;
1934 wined3d_mutex_lock();
1935 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
)))
1937 wined3d_mutex_unlock();
1942 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1943 wined3d_mutex_unlock();
1944 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1945 ID3D11GeometryShader_AddRef(*shader
);
1948 static void STDMETHODCALLTYPE
d3d11_device_context_IAGetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
1949 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1951 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1952 enum wined3d_primitive_type primitive_type
;
1953 unsigned int patch_vertex_count
;
1955 TRACE("iface %p, topology %p.\n", iface
, topology
);
1957 wined3d_mutex_lock();
1958 wined3d_device_context_get_primitive_type(context
->wined3d_context
, &primitive_type
, &patch_vertex_count
);
1959 wined3d_mutex_unlock();
1961 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1964 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetShaderResources(ID3D11DeviceContext1
*iface
,
1965 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1967 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1970 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1972 wined3d_mutex_lock();
1973 for (i
= 0; i
< view_count
; ++i
)
1975 struct wined3d_shader_resource_view
*wined3d_view
;
1976 struct d3d_shader_resource_view
*view_impl
;
1978 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
1979 context
->wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
1985 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1986 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1987 ID3D11ShaderResourceView_AddRef(views
[i
]);
1989 wined3d_mutex_unlock();
1992 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetSamplers(ID3D11DeviceContext1
*iface
,
1993 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1995 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
1998 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1999 iface
, start_slot
, sampler_count
, samplers
);
2001 wined3d_mutex_lock();
2002 for (i
= 0; i
< sampler_count
; ++i
)
2004 struct wined3d_sampler
*wined3d_sampler
;
2005 struct d3d_sampler_state
*sampler_impl
;
2007 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2008 context
->wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
2014 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2015 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
2016 ID3D11SamplerState_AddRef(samplers
[i
]);
2018 wined3d_mutex_unlock();
2021 static void STDMETHODCALLTYPE
d3d11_device_context_GetPredication(ID3D11DeviceContext1
*iface
,
2022 ID3D11Predicate
**predicate
, BOOL
*value
)
2024 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2025 struct wined3d_query
*wined3d_predicate
;
2026 struct d3d_query
*predicate_impl
;
2028 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
2030 wined3d_mutex_lock();
2031 if (!(wined3d_predicate
= wined3d_device_context_get_predication(context
->wined3d_context
, value
)))
2033 wined3d_mutex_unlock();
2038 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
2039 wined3d_mutex_unlock();
2040 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
2041 ID3D11Predicate_AddRef(*predicate
);
2044 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetShaderResources(ID3D11DeviceContext1
*iface
,
2045 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2047 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2050 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2052 wined3d_mutex_lock();
2053 for (i
= 0; i
< view_count
; ++i
)
2055 struct wined3d_shader_resource_view
*wined3d_view
;
2056 struct d3d_shader_resource_view
*view_impl
;
2058 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2059 context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
2065 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2066 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
2067 ID3D11ShaderResourceView_AddRef(views
[i
]);
2069 wined3d_mutex_unlock();
2072 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetSamplers(ID3D11DeviceContext1
*iface
,
2073 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2075 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2078 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2079 iface
, start_slot
, sampler_count
, samplers
);
2081 wined3d_mutex_lock();
2082 for (i
= 0; i
< sampler_count
; ++i
)
2084 struct d3d_sampler_state
*sampler_impl
;
2085 struct wined3d_sampler
*wined3d_sampler
;
2087 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2088 context
->wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
2094 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2095 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
2096 ID3D11SamplerState_AddRef(samplers
[i
]);
2098 wined3d_mutex_unlock();
2101 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetRenderTargets(ID3D11DeviceContext1
*iface
,
2102 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
2103 ID3D11DepthStencilView
**depth_stencil_view
)
2105 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2106 struct wined3d_rendertarget_view
*wined3d_view
;
2108 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
2109 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
2111 wined3d_mutex_lock();
2112 if (render_target_views
)
2114 struct d3d_rendertarget_view
*view_impl
;
2117 for (i
= 0; i
< render_target_view_count
; ++i
)
2119 if (!(wined3d_view
= wined3d_device_context_get_rendertarget_view(context
->wined3d_context
, i
))
2120 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
2122 render_target_views
[i
] = NULL
;
2126 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
2127 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
2131 if (depth_stencil_view
)
2133 struct d3d_depthstencil_view
*view_impl
;
2135 if (!(wined3d_view
= wined3d_device_context_get_depth_stencil_view(context
->wined3d_context
))
2136 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
2138 *depth_stencil_view
= NULL
;
2142 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
2143 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
2146 wined3d_mutex_unlock();
2149 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetRenderTargetsAndUnorderedAccessViews(
2150 ID3D11DeviceContext1
*iface
,
2151 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
2152 ID3D11DepthStencilView
**depth_stencil_view
,
2153 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
2154 ID3D11UnorderedAccessView
**unordered_access_views
)
2156 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2157 struct wined3d_unordered_access_view
*wined3d_view
;
2158 struct d3d11_unordered_access_view
*view_impl
;
2161 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
2162 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
2163 "unordered_access_views %p.\n",
2164 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
2165 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
2167 if (render_target_views
|| depth_stencil_view
)
2168 d3d11_device_context_OMGetRenderTargets(iface
, render_target_view_count
,
2169 render_target_views
, depth_stencil_view
);
2171 if (unordered_access_views
)
2173 wined3d_mutex_lock();
2174 for (i
= 0; i
< unordered_access_view_count
; ++i
)
2176 if (!(wined3d_view
= wined3d_device_context_get_unordered_access_view(context
->wined3d_context
,
2177 WINED3D_PIPELINE_GRAPHICS
, unordered_access_view_start_slot
+ i
)))
2179 unordered_access_views
[i
] = NULL
;
2183 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2184 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
2185 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
2187 wined3d_mutex_unlock();
2191 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetBlendState(ID3D11DeviceContext1
*iface
,
2192 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
2194 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2195 struct wined3d_blend_state
*wined3d_state
;
2196 struct d3d_blend_state
*blend_state_impl
;
2197 unsigned int tmp_sample_mask
;
2198 float tmp_blend_factor
[4];
2200 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
2201 iface
, blend_state
, blend_factor
, sample_mask
);
2203 wined3d_mutex_lock();
2204 if (!blend_factor
) blend_factor
= tmp_blend_factor
;
2205 if (!sample_mask
) sample_mask
= &tmp_sample_mask
;
2206 wined3d_state
= wined3d_device_context_get_blend_state(context
->wined3d_context
,
2207 (struct wined3d_color
*)blend_factor
, sample_mask
);
2212 blend_state_impl
= wined3d_blend_state_get_parent(wined3d_state
);
2213 ID3D11BlendState_AddRef(*blend_state
= &blend_state_impl
->ID3D11BlendState_iface
);
2216 *blend_state
= NULL
;
2218 wined3d_mutex_unlock();
2221 static void STDMETHODCALLTYPE
d3d11_device_context_OMGetDepthStencilState(ID3D11DeviceContext1
*iface
,
2222 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
2224 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2225 struct wined3d_depth_stencil_state
*wined3d_state
;
2226 struct d3d_depthstencil_state
*state_impl
;
2227 UINT stencil_ref_tmp
;
2229 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
2230 iface
, depth_stencil_state
, stencil_ref
);
2232 wined3d_mutex_lock();
2233 if (!stencil_ref
) stencil_ref
= &stencil_ref_tmp
;
2234 wined3d_state
= wined3d_device_context_get_depth_stencil_state(context
->wined3d_context
, stencil_ref
);
2235 if (depth_stencil_state
)
2239 state_impl
= wined3d_depth_stencil_state_get_parent(wined3d_state
);
2240 ID3D11DepthStencilState_AddRef(*depth_stencil_state
= &state_impl
->ID3D11DepthStencilState_iface
);
2244 *depth_stencil_state
= NULL
;
2247 wined3d_mutex_unlock();
2250 static void STDMETHODCALLTYPE
d3d11_device_context_SOGetTargets(ID3D11DeviceContext1
*iface
,
2251 UINT buffer_count
, ID3D11Buffer
**buffers
)
2253 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2256 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
2258 wined3d_mutex_lock();
2259 for (i
= 0; i
< buffer_count
; ++i
)
2261 struct wined3d_buffer
*wined3d_buffer
;
2262 struct d3d_buffer
*buffer_impl
;
2264 if (!(wined3d_buffer
= wined3d_device_context_get_stream_output(context
->wined3d_context
, i
, NULL
)))
2270 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2271 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
2272 ID3D11Buffer_AddRef(buffers
[i
]);
2274 wined3d_mutex_unlock();
2277 static void STDMETHODCALLTYPE
d3d11_device_context_RSGetState(ID3D11DeviceContext1
*iface
,
2278 ID3D11RasterizerState
**rasterizer_state
)
2280 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2281 struct d3d_rasterizer_state
*rasterizer_state_impl
;
2282 struct wined3d_rasterizer_state
*wined3d_state
;
2284 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
2286 wined3d_mutex_lock();
2287 if ((wined3d_state
= wined3d_device_context_get_rasterizer_state(context
->wined3d_context
)))
2289 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
2290 *rasterizer_state
= (ID3D11RasterizerState
*)&rasterizer_state_impl
->ID3D11RasterizerState1_iface
;
2291 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2295 *rasterizer_state
= NULL
;
2297 wined3d_mutex_unlock();
2300 static void STDMETHODCALLTYPE
d3d11_device_context_RSGetViewports(ID3D11DeviceContext1
*iface
,
2301 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
2303 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2304 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
2305 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
2307 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2309 if (!viewport_count
)
2312 wined3d_mutex_lock();
2313 wined3d_device_context_get_viewports(context
->wined3d_context
, &actual_count
, viewports
? wined3d_vp
: NULL
);
2314 wined3d_mutex_unlock();
2318 *viewport_count
= actual_count
;
2322 if (*viewport_count
> actual_count
)
2323 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
2325 *viewport_count
= min(actual_count
, *viewport_count
);
2326 for (i
= 0; i
< *viewport_count
; ++i
)
2328 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
2329 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
2330 viewports
[i
].Width
= wined3d_vp
[i
].width
;
2331 viewports
[i
].Height
= wined3d_vp
[i
].height
;
2332 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
2333 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
2337 static void STDMETHODCALLTYPE
d3d11_device_context_RSGetScissorRects(ID3D11DeviceContext1
*iface
,
2338 UINT
*rect_count
, D3D11_RECT
*rects
)
2340 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2341 unsigned int actual_count
;
2343 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2348 actual_count
= *rect_count
;
2350 wined3d_mutex_lock();
2351 wined3d_device_context_get_scissor_rects(context
->wined3d_context
, &actual_count
, rects
);
2352 wined3d_mutex_unlock();
2354 if (rects
&& *rect_count
> actual_count
)
2355 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
2356 *rect_count
= actual_count
;
2359 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetShaderResources(ID3D11DeviceContext1
*iface
,
2360 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2362 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2365 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2367 wined3d_mutex_lock();
2368 for (i
= 0; i
< view_count
; ++i
)
2370 struct wined3d_shader_resource_view
*wined3d_view
;
2371 struct d3d_shader_resource_view
*view_impl
;
2373 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2374 context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
, start_slot
+ i
)))
2380 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2381 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2383 wined3d_mutex_unlock();
2386 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetShader(ID3D11DeviceContext1
*iface
,
2387 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2389 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2390 struct d3d11_hull_shader
*shader_impl
;
2391 struct wined3d_shader
*wined3d_shader
;
2393 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2394 iface
, shader
, class_instances
, class_instance_count
);
2396 if (class_instances
|| class_instance_count
)
2397 FIXME("Dynamic linking not implemented yet.\n");
2398 if (class_instance_count
)
2399 *class_instance_count
= 0;
2401 wined3d_mutex_lock();
2402 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
)))
2404 wined3d_mutex_unlock();
2409 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2410 wined3d_mutex_unlock();
2411 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2414 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetSamplers(ID3D11DeviceContext1
*iface
,
2415 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2417 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2420 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2421 iface
, start_slot
, sampler_count
, samplers
);
2423 wined3d_mutex_lock();
2424 for (i
= 0; i
< sampler_count
; ++i
)
2426 struct wined3d_sampler
*wined3d_sampler
;
2427 struct d3d_sampler_state
*sampler_impl
;
2429 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2430 context
->wined3d_context
, WINED3D_SHADER_TYPE_HULL
, start_slot
+ i
)))
2436 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2437 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2439 wined3d_mutex_unlock();
2442 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2443 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2445 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2446 iface
, start_slot
, buffer_count
, buffers
);
2448 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2449 buffer_count
, buffers
, NULL
, NULL
);
2452 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetShaderResources(ID3D11DeviceContext1
*iface
,
2453 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2455 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2458 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2459 iface
, start_slot
, view_count
, views
);
2461 wined3d_mutex_lock();
2462 for (i
= 0; i
< view_count
; ++i
)
2464 struct wined3d_shader_resource_view
*wined3d_view
;
2465 struct d3d_shader_resource_view
*view_impl
;
2467 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2468 context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
+ i
)))
2474 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2475 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2477 wined3d_mutex_unlock();
2480 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetShader(ID3D11DeviceContext1
*iface
,
2481 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2483 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2484 struct d3d11_domain_shader
*shader_impl
;
2485 struct wined3d_shader
*wined3d_shader
;
2487 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2488 iface
, shader
, class_instances
, class_instance_count
);
2490 if (class_instances
|| class_instance_count
)
2491 FIXME("Dynamic linking not implemented yet.\n");
2492 if (class_instance_count
)
2493 *class_instance_count
= 0;
2495 wined3d_mutex_lock();
2496 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
)))
2498 wined3d_mutex_unlock();
2503 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2504 wined3d_mutex_unlock();
2505 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2508 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetSamplers(ID3D11DeviceContext1
*iface
,
2509 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2511 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2514 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2515 iface
, start_slot
, sampler_count
, samplers
);
2517 wined3d_mutex_lock();
2518 for (i
= 0; i
< sampler_count
; ++i
)
2520 struct wined3d_sampler
*wined3d_sampler
;
2521 struct d3d_sampler_state
*sampler_impl
;
2523 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2524 context
->wined3d_context
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
+ i
)))
2530 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2531 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2533 wined3d_mutex_unlock();
2536 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2537 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2539 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2540 iface
, start_slot
, buffer_count
, buffers
);
2542 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2543 buffer_count
, buffers
, NULL
, NULL
);
2546 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetShaderResources(ID3D11DeviceContext1
*iface
,
2547 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2549 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2552 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2554 wined3d_mutex_lock();
2555 for (i
= 0; i
< view_count
; ++i
)
2557 struct wined3d_shader_resource_view
*wined3d_view
;
2558 struct d3d_shader_resource_view
*view_impl
;
2560 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
2561 context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
+ i
)))
2567 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2568 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2570 wined3d_mutex_unlock();
2573 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
2574 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2576 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2579 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2581 wined3d_mutex_lock();
2582 for (i
= 0; i
< view_count
; ++i
)
2584 struct wined3d_unordered_access_view
*wined3d_view
;
2585 struct d3d11_unordered_access_view
*view_impl
;
2587 if (!(wined3d_view
= wined3d_device_context_get_unordered_access_view(
2588 context
->wined3d_context
, WINED3D_PIPELINE_COMPUTE
, start_slot
+ i
)))
2594 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2595 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2597 wined3d_mutex_unlock();
2600 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetShader(ID3D11DeviceContext1
*iface
,
2601 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2603 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2604 struct d3d11_compute_shader
*shader_impl
;
2605 struct wined3d_shader
*wined3d_shader
;
2607 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2608 iface
, shader
, class_instances
, class_instance_count
);
2610 if (class_instances
|| class_instance_count
)
2611 FIXME("Dynamic linking not implemented yet.\n");
2612 if (class_instance_count
)
2613 *class_instance_count
= 0;
2615 wined3d_mutex_lock();
2616 if (!(wined3d_shader
= wined3d_device_context_get_shader(context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
)))
2618 wined3d_mutex_unlock();
2623 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2624 wined3d_mutex_unlock();
2625 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2628 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetSamplers(ID3D11DeviceContext1
*iface
,
2629 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2631 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2634 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2635 iface
, start_slot
, sampler_count
, samplers
);
2637 wined3d_mutex_lock();
2638 for (i
= 0; i
< sampler_count
; ++i
)
2640 struct wined3d_sampler
*wined3d_sampler
;
2641 struct d3d_sampler_state
*sampler_impl
;
2643 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
2644 context
->wined3d_context
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
+ i
)))
2650 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2651 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2653 wined3d_mutex_unlock();
2656 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2657 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2659 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2660 iface
, start_slot
, buffer_count
, buffers
);
2662 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2663 buffer_count
, buffers
, NULL
, NULL
);
2666 static void STDMETHODCALLTYPE
d3d11_device_context_ClearState(ID3D11DeviceContext1
*iface
)
2668 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2670 TRACE("iface %p.\n", iface
);
2672 wined3d_device_context_reset_state(context
->wined3d_context
);
2675 static void STDMETHODCALLTYPE
d3d11_device_context_Flush(ID3D11DeviceContext1
*iface
)
2677 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2679 TRACE("iface %p.\n", iface
);
2681 wined3d_device_context_flush(context
->wined3d_context
);
2684 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_device_context_GetType(ID3D11DeviceContext1
*iface
)
2686 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2688 TRACE("iface %p.\n", iface
);
2690 return context
->type
;
2693 static UINT STDMETHODCALLTYPE
d3d11_device_context_GetContextFlags(ID3D11DeviceContext1
*iface
)
2695 TRACE("iface %p.\n", iface
);
2700 static HRESULT STDMETHODCALLTYPE
d3d11_device_context_FinishCommandList(ID3D11DeviceContext1
*iface
,
2701 BOOL restore
, ID3D11CommandList
**command_list
)
2703 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2704 struct d3d11_command_list
*object
;
2707 TRACE("iface %p, restore %#x, command_list %p.\n", iface
, restore
, command_list
);
2709 if (context
->type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
)
2711 WARN("Attempt to record command list on an immediate context; returning DXGI_ERROR_INVALID_CALL.\n");
2712 return DXGI_ERROR_INVALID_CALL
;
2715 if (!(object
= heap_alloc_zero(sizeof(*object
))))
2716 return E_OUTOFMEMORY
;
2718 if (FAILED(hr
= wined3d_deferred_context_record_command_list(context
->wined3d_context
,
2719 !!restore
, &object
->wined3d_list
)))
2721 WARN("Failed to record wined3d command list, hr %#x.\n", hr
);
2726 object
->ID3D11CommandList_iface
.lpVtbl
= &d3d11_command_list_vtbl
;
2727 object
->refcount
= 1;
2728 object
->device
= &context
->device
->ID3D11Device2_iface
;
2729 wined3d_private_store_init(&object
->private_store
);
2731 ID3D11Device2_AddRef(object
->device
);
2733 TRACE("Created command list %p.\n", object
);
2734 *command_list
= &object
->ID3D11CommandList_iface
;
2739 static void STDMETHODCALLTYPE
d3d11_device_context_CopySubresourceRegion1(ID3D11DeviceContext1
*iface
,
2740 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
2741 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
, UINT flags
)
2743 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2744 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
2745 struct wined3d_box wined3d_src_box
;
2747 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
2748 "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n",
2749 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
2750 src_resource
, src_subresource_idx
, src_box
, flags
);
2752 if (!dst_resource
|| !src_resource
)
2756 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
2757 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
2759 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
2760 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
2761 wined3d_device_context_copy_sub_resource_region(context
->wined3d_context
, wined3d_dst_resource
, dst_subresource_idx
,
2762 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, flags
);
2765 static void STDMETHODCALLTYPE
d3d11_device_context_UpdateSubresource1(ID3D11DeviceContext1
*iface
,
2766 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
, const void *data
,
2767 UINT row_pitch
, UINT depth_pitch
, UINT flags
)
2769 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2770 struct wined3d_resource
*wined3d_resource
;
2771 struct wined3d_box wined3d_box
;
2773 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n",
2774 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
, flags
);
2777 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
,
2778 box
->front
, box
->back
);
2780 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
2781 wined3d_device_context_update_sub_resource(context
->wined3d_context
, wined3d_resource
, subresource_idx
,
2782 box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, flags
);
2785 static void STDMETHODCALLTYPE
d3d11_device_context_DiscardResource(ID3D11DeviceContext1
*iface
,
2786 ID3D11Resource
*resource
)
2788 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
2791 static void STDMETHODCALLTYPE
d3d11_device_context_DiscardView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
)
2793 FIXME("iface %p, view %p stub!\n", iface
, view
);
2796 static void STDMETHODCALLTYPE
d3d11_device_context_VSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2797 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2798 const UINT
*num_constants
)
2800 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2801 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2803 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
2804 buffer_count
, buffers
, first_constant
, num_constants
);
2807 static void STDMETHODCALLTYPE
d3d11_device_context_HSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2808 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2809 const UINT
*num_constants
)
2811 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2812 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2814 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2815 buffer_count
, buffers
, first_constant
, num_constants
);
2818 static void STDMETHODCALLTYPE
d3d11_device_context_DSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2819 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2820 const UINT
*num_constants
)
2822 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2823 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2825 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2826 buffer_count
, buffers
, first_constant
, num_constants
);
2829 static void STDMETHODCALLTYPE
d3d11_device_context_GSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2830 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2831 const UINT
*num_constants
)
2833 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2834 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2836 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
2837 buffer_count
, buffers
, first_constant
, num_constants
);
2840 static void STDMETHODCALLTYPE
d3d11_device_context_PSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2841 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2842 const UINT
*num_constants
)
2844 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2845 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2847 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
2848 buffer_count
, buffers
, first_constant
, num_constants
);
2851 static void STDMETHODCALLTYPE
d3d11_device_context_CSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2852 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2853 const UINT
*num_constants
)
2855 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2856 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2858 d3d11_device_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2859 buffer_count
, buffers
, first_constant
, num_constants
);
2862 static void STDMETHODCALLTYPE
d3d11_device_context_VSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2863 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2865 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2866 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2868 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
2869 buffer_count
, buffers
, first_constant
, num_constants
);
2872 static void STDMETHODCALLTYPE
d3d11_device_context_HSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2873 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2875 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2876 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2878 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2879 buffer_count
, buffers
, first_constant
, num_constants
);
2882 static void STDMETHODCALLTYPE
d3d11_device_context_DSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2883 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2885 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2886 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2888 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2889 buffer_count
, buffers
, first_constant
, num_constants
);
2892 static void STDMETHODCALLTYPE
d3d11_device_context_GSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2893 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2895 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2896 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2898 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
2899 buffer_count
, buffers
, first_constant
, num_constants
);
2902 static void STDMETHODCALLTYPE
d3d11_device_context_PSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2903 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2905 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2906 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2908 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
2909 buffer_count
, buffers
, first_constant
, num_constants
);
2912 static void STDMETHODCALLTYPE
d3d11_device_context_CSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2913 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2915 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p.\n",
2916 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2918 d3d11_device_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2919 buffer_count
, buffers
, first_constant
, num_constants
);
2922 static void STDMETHODCALLTYPE
d3d11_device_context_SwapDeviceContextState(ID3D11DeviceContext1
*iface
,
2923 ID3DDeviceContextState
*state
, ID3DDeviceContextState
**prev
)
2925 struct d3d11_device_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
2926 struct d3d_device_context_state
*state_impl
, *prev_impl
;
2927 struct d3d_device
*device
= context
->device
;
2928 struct wined3d_state
*wined3d_state
;
2929 static unsigned int once
;
2931 TRACE("iface %p, state %p, prev %p.\n", iface
, state
, prev
);
2936 if (context
->type
!= D3D11_DEVICE_CONTEXT_IMMEDIATE
)
2938 WARN("SwapDeviceContextState is not allowed on a deferred context.\n");
2945 wined3d_mutex_lock();
2947 prev_impl
= device
->state
;
2948 state_impl
= impl_from_ID3DDeviceContextState(state
);
2949 if (!(wined3d_state
= d3d_device_context_state_get_wined3d_state(state_impl
, device
)))
2950 ERR("Failed to get wined3d state for device context state %p.\n", state_impl
);
2951 wined3d_device_context_set_state(context
->wined3d_context
, wined3d_state
);
2954 ID3DDeviceContextState_AddRef(*prev
= &prev_impl
->ID3DDeviceContextState_iface
);
2956 d3d_device_context_state_private_addref(state_impl
);
2957 device
->state
= state_impl
;
2958 d3d_device_context_state_private_release(prev_impl
);
2960 if (d3d_device_is_d3d10_active(device
) && !once
++)
2961 FIXME("D3D10 interface emulation not fully implemented yet!\n");
2962 wined3d_mutex_unlock();
2965 static void STDMETHODCALLTYPE
d3d11_device_context_ClearView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2966 const FLOAT color
[4], const D3D11_RECT
*rect
, UINT num_rects
)
2968 FIXME("iface %p, view %p, color %p, rect %p, num_rects %u stub!\n", iface
, view
, color
, rect
, num_rects
);
2971 static void STDMETHODCALLTYPE
d3d11_device_context_DiscardView1(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2972 const D3D11_RECT
*rects
, UINT num_rects
)
2974 FIXME("iface %p, view %p, rects %p, num_rects %u stub!\n", iface
, view
, rects
, num_rects
);
2977 static const struct ID3D11DeviceContext1Vtbl d3d11_device_context_vtbl
=
2979 /* IUnknown methods */
2980 d3d11_device_context_QueryInterface
,
2981 d3d11_device_context_AddRef
,
2982 d3d11_device_context_Release
,
2983 /* ID3D11DeviceChild methods */
2984 d3d11_device_context_GetDevice
,
2985 d3d11_device_context_GetPrivateData
,
2986 d3d11_device_context_SetPrivateData
,
2987 d3d11_device_context_SetPrivateDataInterface
,
2988 /* ID3D11DeviceContext methods */
2989 d3d11_device_context_VSSetConstantBuffers
,
2990 d3d11_device_context_PSSetShaderResources
,
2991 d3d11_device_context_PSSetShader
,
2992 d3d11_device_context_PSSetSamplers
,
2993 d3d11_device_context_VSSetShader
,
2994 d3d11_device_context_DrawIndexed
,
2995 d3d11_device_context_Draw
,
2996 d3d11_device_context_Map
,
2997 d3d11_device_context_Unmap
,
2998 d3d11_device_context_PSSetConstantBuffers
,
2999 d3d11_device_context_IASetInputLayout
,
3000 d3d11_device_context_IASetVertexBuffers
,
3001 d3d11_device_context_IASetIndexBuffer
,
3002 d3d11_device_context_DrawIndexedInstanced
,
3003 d3d11_device_context_DrawInstanced
,
3004 d3d11_device_context_GSSetConstantBuffers
,
3005 d3d11_device_context_GSSetShader
,
3006 d3d11_device_context_IASetPrimitiveTopology
,
3007 d3d11_device_context_VSSetShaderResources
,
3008 d3d11_device_context_VSSetSamplers
,
3009 d3d11_device_context_Begin
,
3010 d3d11_device_context_End
,
3011 d3d11_device_context_GetData
,
3012 d3d11_device_context_SetPredication
,
3013 d3d11_device_context_GSSetShaderResources
,
3014 d3d11_device_context_GSSetSamplers
,
3015 d3d11_device_context_OMSetRenderTargets
,
3016 d3d11_device_context_OMSetRenderTargetsAndUnorderedAccessViews
,
3017 d3d11_device_context_OMSetBlendState
,
3018 d3d11_device_context_OMSetDepthStencilState
,
3019 d3d11_device_context_SOSetTargets
,
3020 d3d11_device_context_DrawAuto
,
3021 d3d11_device_context_DrawIndexedInstancedIndirect
,
3022 d3d11_device_context_DrawInstancedIndirect
,
3023 d3d11_device_context_Dispatch
,
3024 d3d11_device_context_DispatchIndirect
,
3025 d3d11_device_context_RSSetState
,
3026 d3d11_device_context_RSSetViewports
,
3027 d3d11_device_context_RSSetScissorRects
,
3028 d3d11_device_context_CopySubresourceRegion
,
3029 d3d11_device_context_CopyResource
,
3030 d3d11_device_context_UpdateSubresource
,
3031 d3d11_device_context_CopyStructureCount
,
3032 d3d11_device_context_ClearRenderTargetView
,
3033 d3d11_device_context_ClearUnorderedAccessViewUint
,
3034 d3d11_device_context_ClearUnorderedAccessViewFloat
,
3035 d3d11_device_context_ClearDepthStencilView
,
3036 d3d11_device_context_GenerateMips
,
3037 d3d11_device_context_SetResourceMinLOD
,
3038 d3d11_device_context_GetResourceMinLOD
,
3039 d3d11_device_context_ResolveSubresource
,
3040 d3d11_device_context_ExecuteCommandList
,
3041 d3d11_device_context_HSSetShaderResources
,
3042 d3d11_device_context_HSSetShader
,
3043 d3d11_device_context_HSSetSamplers
,
3044 d3d11_device_context_HSSetConstantBuffers
,
3045 d3d11_device_context_DSSetShaderResources
,
3046 d3d11_device_context_DSSetShader
,
3047 d3d11_device_context_DSSetSamplers
,
3048 d3d11_device_context_DSSetConstantBuffers
,
3049 d3d11_device_context_CSSetShaderResources
,
3050 d3d11_device_context_CSSetUnorderedAccessViews
,
3051 d3d11_device_context_CSSetShader
,
3052 d3d11_device_context_CSSetSamplers
,
3053 d3d11_device_context_CSSetConstantBuffers
,
3054 d3d11_device_context_VSGetConstantBuffers
,
3055 d3d11_device_context_PSGetShaderResources
,
3056 d3d11_device_context_PSGetShader
,
3057 d3d11_device_context_PSGetSamplers
,
3058 d3d11_device_context_VSGetShader
,
3059 d3d11_device_context_PSGetConstantBuffers
,
3060 d3d11_device_context_IAGetInputLayout
,
3061 d3d11_device_context_IAGetVertexBuffers
,
3062 d3d11_device_context_IAGetIndexBuffer
,
3063 d3d11_device_context_GSGetConstantBuffers
,
3064 d3d11_device_context_GSGetShader
,
3065 d3d11_device_context_IAGetPrimitiveTopology
,
3066 d3d11_device_context_VSGetShaderResources
,
3067 d3d11_device_context_VSGetSamplers
,
3068 d3d11_device_context_GetPredication
,
3069 d3d11_device_context_GSGetShaderResources
,
3070 d3d11_device_context_GSGetSamplers
,
3071 d3d11_device_context_OMGetRenderTargets
,
3072 d3d11_device_context_OMGetRenderTargetsAndUnorderedAccessViews
,
3073 d3d11_device_context_OMGetBlendState
,
3074 d3d11_device_context_OMGetDepthStencilState
,
3075 d3d11_device_context_SOGetTargets
,
3076 d3d11_device_context_RSGetState
,
3077 d3d11_device_context_RSGetViewports
,
3078 d3d11_device_context_RSGetScissorRects
,
3079 d3d11_device_context_HSGetShaderResources
,
3080 d3d11_device_context_HSGetShader
,
3081 d3d11_device_context_HSGetSamplers
,
3082 d3d11_device_context_HSGetConstantBuffers
,
3083 d3d11_device_context_DSGetShaderResources
,
3084 d3d11_device_context_DSGetShader
,
3085 d3d11_device_context_DSGetSamplers
,
3086 d3d11_device_context_DSGetConstantBuffers
,
3087 d3d11_device_context_CSGetShaderResources
,
3088 d3d11_device_context_CSGetUnorderedAccessViews
,
3089 d3d11_device_context_CSGetShader
,
3090 d3d11_device_context_CSGetSamplers
,
3091 d3d11_device_context_CSGetConstantBuffers
,
3092 d3d11_device_context_ClearState
,
3093 d3d11_device_context_Flush
,
3094 d3d11_device_context_GetType
,
3095 d3d11_device_context_GetContextFlags
,
3096 d3d11_device_context_FinishCommandList
,
3097 /* ID3D11DeviceContext1 methods */
3098 d3d11_device_context_CopySubresourceRegion1
,
3099 d3d11_device_context_UpdateSubresource1
,
3100 d3d11_device_context_DiscardResource
,
3101 d3d11_device_context_DiscardView
,
3102 d3d11_device_context_VSSetConstantBuffers1
,
3103 d3d11_device_context_HSSetConstantBuffers1
,
3104 d3d11_device_context_DSSetConstantBuffers1
,
3105 d3d11_device_context_GSSetConstantBuffers1
,
3106 d3d11_device_context_PSSetConstantBuffers1
,
3107 d3d11_device_context_CSSetConstantBuffers1
,
3108 d3d11_device_context_VSGetConstantBuffers1
,
3109 d3d11_device_context_HSGetConstantBuffers1
,
3110 d3d11_device_context_DSGetConstantBuffers1
,
3111 d3d11_device_context_GSGetConstantBuffers1
,
3112 d3d11_device_context_PSGetConstantBuffers1
,
3113 d3d11_device_context_CSGetConstantBuffers1
,
3114 d3d11_device_context_SwapDeviceContextState
,
3115 d3d11_device_context_ClearView
,
3116 d3d11_device_context_DiscardView1
,
3119 /* ID3D11Multithread methods */
3121 static inline struct d3d11_device_context
*impl_from_ID3D11Multithread(ID3D11Multithread
*iface
)
3123 return CONTAINING_RECORD(iface
, struct d3d11_device_context
, ID3D11Multithread_iface
);
3126 static HRESULT STDMETHODCALLTYPE
d3d11_multithread_QueryInterface(ID3D11Multithread
*iface
,
3127 REFIID iid
, void **out
)
3129 struct d3d11_device_context
*context
= impl_from_ID3D11Multithread(iface
);
3131 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
3133 return d3d11_device_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
3136 static ULONG STDMETHODCALLTYPE
d3d11_multithread_AddRef(ID3D11Multithread
*iface
)
3138 struct d3d11_device_context
*context
= impl_from_ID3D11Multithread(iface
);
3140 TRACE("iface %p.\n", iface
);
3142 return d3d11_device_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
3145 static ULONG STDMETHODCALLTYPE
d3d11_multithread_Release(ID3D11Multithread
*iface
)
3147 struct d3d11_device_context
*context
= impl_from_ID3D11Multithread(iface
);
3149 TRACE("iface %p.\n", iface
);
3151 return d3d11_device_context_Release(&context
->ID3D11DeviceContext1_iface
);
3154 static void STDMETHODCALLTYPE
d3d11_multithread_Enter(ID3D11Multithread
*iface
)
3156 TRACE("iface %p.\n", iface
);
3158 wined3d_mutex_lock();
3161 static void STDMETHODCALLTYPE
d3d11_multithread_Leave(ID3D11Multithread
*iface
)
3163 TRACE("iface %p.\n", iface
);
3165 wined3d_mutex_unlock();
3168 static BOOL STDMETHODCALLTYPE
d3d11_multithread_SetMultithreadProtected(
3169 ID3D11Multithread
*iface
, BOOL enable
)
3171 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
3176 static BOOL STDMETHODCALLTYPE
d3d11_multithread_GetMultithreadProtected(ID3D11Multithread
*iface
)
3178 FIXME("iface %p stub!\n", iface
);
3183 static const struct ID3D11MultithreadVtbl d3d11_multithread_vtbl
=
3185 d3d11_multithread_QueryInterface
,
3186 d3d11_multithread_AddRef
,
3187 d3d11_multithread_Release
,
3188 d3d11_multithread_Enter
,
3189 d3d11_multithread_Leave
,
3190 d3d11_multithread_SetMultithreadProtected
,
3191 d3d11_multithread_GetMultithreadProtected
,
3194 /* ID3DUserDefinedAnnotation methods */
3196 static inline struct d3d11_device_context
*impl_from_ID3DUserDefinedAnnotation(ID3DUserDefinedAnnotation
*iface
)
3198 return CONTAINING_RECORD(iface
, struct d3d11_device_context
, ID3DUserDefinedAnnotation_iface
);
3201 static HRESULT STDMETHODCALLTYPE
d3d11_user_defined_annotation_QueryInterface(ID3DUserDefinedAnnotation
*iface
,
3202 REFIID iid
, void **out
)
3204 struct d3d11_device_context
*context
= impl_from_ID3DUserDefinedAnnotation(iface
);
3206 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
3208 return d3d11_device_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
3211 static ULONG STDMETHODCALLTYPE
d3d11_user_defined_annotation_AddRef(ID3DUserDefinedAnnotation
*iface
)
3213 struct d3d11_device_context
*context
= impl_from_ID3DUserDefinedAnnotation(iface
);
3215 TRACE("iface %p.\n", iface
);
3217 return d3d11_device_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
3220 static ULONG STDMETHODCALLTYPE
d3d11_user_defined_annotation_Release(ID3DUserDefinedAnnotation
*iface
)
3222 struct d3d11_device_context
*context
= impl_from_ID3DUserDefinedAnnotation(iface
);
3224 TRACE("iface %p.\n", iface
);
3226 return d3d11_device_context_Release(&context
->ID3D11DeviceContext1_iface
);
3229 static int STDMETHODCALLTYPE
d3d11_user_defined_annotation_BeginEvent(ID3DUserDefinedAnnotation
*iface
,
3232 TRACE("iface %p, name %s.\n", iface
, debugstr_w(name
));
3237 static int STDMETHODCALLTYPE
d3d11_user_defined_annotation_EndEvent(ID3DUserDefinedAnnotation
*iface
)
3239 TRACE("iface %p.\n", iface
);
3244 static void STDMETHODCALLTYPE
d3d11_user_defined_annotation_SetMarker(ID3DUserDefinedAnnotation
*iface
,
3247 TRACE("iface %p, name %s.\n", iface
, debugstr_w(name
));
3250 static BOOL STDMETHODCALLTYPE
d3d11_user_defined_annotation_GetStatus(ID3DUserDefinedAnnotation
*iface
)
3252 TRACE("iface %p.\n", iface
);
3257 static const struct ID3DUserDefinedAnnotationVtbl d3d11_user_defined_annotation_vtbl
=
3259 d3d11_user_defined_annotation_QueryInterface
,
3260 d3d11_user_defined_annotation_AddRef
,
3261 d3d11_user_defined_annotation_Release
,
3262 d3d11_user_defined_annotation_BeginEvent
,
3263 d3d11_user_defined_annotation_EndEvent
,
3264 d3d11_user_defined_annotation_SetMarker
,
3265 d3d11_user_defined_annotation_GetStatus
,
3268 static void d3d11_device_context_init(struct d3d11_device_context
*context
, struct d3d_device
*device
,
3269 D3D11_DEVICE_CONTEXT_TYPE type
)
3271 context
->ID3D11DeviceContext1_iface
.lpVtbl
= &d3d11_device_context_vtbl
;
3272 context
->ID3D11Multithread_iface
.lpVtbl
= &d3d11_multithread_vtbl
;
3273 context
->ID3DUserDefinedAnnotation_iface
.lpVtbl
= &d3d11_user_defined_annotation_vtbl
;
3274 context
->refcount
= 1;
3275 context
->type
= type
;
3277 context
->device
= device
;
3278 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
3280 wined3d_private_store_init(&context
->private_store
);
3283 /* ID3D11Device methods */
3285 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device2
*iface
, REFIID iid
, void **out
)
3287 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3288 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
3291 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device2
*iface
)
3293 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3294 return IUnknown_AddRef(device
->outer_unk
);
3297 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device2
*iface
)
3299 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3300 return IUnknown_Release(device
->outer_unk
);
3303 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device2
*iface
, const D3D11_BUFFER_DESC
*desc
,
3304 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
3306 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3307 struct d3d_buffer
*object
;
3310 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
3312 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
3315 *buffer
= &object
->ID3D11Buffer_iface
;
3320 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device2
*iface
,
3321 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
3323 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3324 struct d3d_texture1d
*object
;
3327 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3329 if (FAILED(hr
= d3d_texture1d_create(device
, desc
, data
, &object
)))
3332 *texture
= &object
->ID3D11Texture1D_iface
;
3337 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device2
*iface
,
3338 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
3340 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3341 struct d3d_texture2d
*object
;
3344 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3346 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
3349 *texture
= &object
->ID3D11Texture2D_iface
;
3354 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device2
*iface
,
3355 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
3357 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3358 struct d3d_texture3d
*object
;
3361 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3363 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
3366 *texture
= &object
->ID3D11Texture3D_iface
;
3371 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device2
*iface
,
3372 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
3374 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3375 struct d3d_shader_resource_view
*object
;
3378 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3381 return E_INVALIDARG
;
3383 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
3386 *view
= &object
->ID3D11ShaderResourceView_iface
;
3391 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device2
*iface
,
3392 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
3394 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3395 struct d3d11_unordered_access_view
*object
;
3398 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3400 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
3403 *view
= &object
->ID3D11UnorderedAccessView_iface
;
3408 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device2
*iface
,
3409 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
3411 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3412 struct d3d_rendertarget_view
*object
;
3415 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3420 return E_INVALIDARG
;
3422 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
3425 *view
= &object
->ID3D11RenderTargetView_iface
;
3430 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device2
*iface
,
3431 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
3433 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3434 struct d3d_depthstencil_view
*object
;
3437 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3439 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
3442 *view
= &object
->ID3D11DepthStencilView_iface
;
3447 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device2
*iface
,
3448 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
3449 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
3451 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3452 struct d3d_input_layout
*object
;
3455 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
3456 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
3457 shader_byte_code_length
, input_layout
);
3459 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
3460 shader_byte_code
, shader_byte_code_length
, &object
)))
3463 *input_layout
= &object
->ID3D11InputLayout_iface
;
3468 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device2
*iface
, const void *byte_code
,
3469 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
3471 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3472 struct d3d_vertex_shader
*object
;
3475 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3476 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 %lu, class_linkage %p, shader %p.\n",
3497 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3500 FIXME("Class linkage is not implemented yet.\n");
3502 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3503 NULL
, 0, NULL
, 0, 0, &object
)))
3506 *shader
= &object
->ID3D11GeometryShader_iface
;
3511 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2
*iface
,
3512 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
3513 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
3514 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3516 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3517 struct d3d_geometry_shader
*object
;
3520 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
3521 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
3522 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
3523 rasterizer_stream
, class_linkage
, shader
);
3526 FIXME("Class linkage is not implemented yet.\n");
3528 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3529 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
3535 *shader
= &object
->ID3D11GeometryShader_iface
;
3540 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device2
*iface
, const void *byte_code
,
3541 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
3543 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3544 struct d3d_pixel_shader
*object
;
3547 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3548 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3551 FIXME("Class linkage is not implemented yet.\n");
3553 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3556 *shader
= &object
->ID3D11PixelShader_iface
;
3561 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device2
*iface
, const void *byte_code
,
3562 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
3564 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3565 struct d3d11_hull_shader
*object
;
3568 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3569 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3572 FIXME("Class linkage is not implemented yet.\n");
3574 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3577 *shader
= &object
->ID3D11HullShader_iface
;
3582 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device2
*iface
, const void *byte_code
,
3583 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
3585 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3586 struct d3d11_domain_shader
*object
;
3589 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3590 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3593 FIXME("Class linkage is not implemented yet.\n");
3595 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3598 *shader
= &object
->ID3D11DomainShader_iface
;
3603 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device2
*iface
, const void *byte_code
,
3604 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
3606 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3607 struct d3d11_compute_shader
*object
;
3610 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3611 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3614 FIXME("Class linkage is not implemented yet.\n");
3616 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3619 *shader
= &object
->ID3D11ComputeShader_iface
;
3624 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device2
*iface
,
3625 ID3D11ClassLinkage
**class_linkage
)
3627 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3628 struct d3d11_class_linkage
*object
;
3631 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3633 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3636 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3641 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device2
*iface
,
3642 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3644 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3645 struct d3d_blend_state
*object
;
3648 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3650 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3653 *blend_state
= &object
->ID3D11BlendState_iface
;
3658 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device2
*iface
,
3659 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3661 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3662 struct d3d_depthstencil_state
*object
;
3665 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3667 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3670 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3675 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device2
*iface
,
3676 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3678 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3679 struct d3d_rasterizer_state
*object
;
3680 D3D11_RASTERIZER_DESC1 desc1
;
3683 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3686 return E_INVALIDARG
;
3688 memcpy(&desc1
, desc
, sizeof(*desc
));
3689 desc1
.ForcedSampleCount
= 0;
3691 if (FAILED(hr
= d3d_rasterizer_state_create(device
, &desc1
, &object
)))
3694 *rasterizer_state
= (ID3D11RasterizerState
*)&object
->ID3D11RasterizerState1_iface
;
3699 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device2
*iface
,
3700 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3702 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3703 struct d3d_sampler_state
*object
;
3706 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3708 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3711 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3716 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device2
*iface
,
3717 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3719 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3720 struct d3d_query
*object
;
3723 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3725 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3730 *query
= &object
->ID3D11Query_iface
;
3734 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3738 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device2
*iface
, const D3D11_QUERY_DESC
*desc
,
3739 ID3D11Predicate
**predicate
)
3741 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3742 struct d3d_query
*object
;
3745 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3747 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3752 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3756 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3760 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3761 ID3D11Counter
**counter
)
3763 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3768 static HRESULT
d3d11_deferred_context_create(struct d3d_device
*device
,
3769 UINT flags
, struct d3d11_device_context
**context
)
3771 struct d3d11_device_context
*object
;
3775 FIXME("Ignoring flags %#x.\n", flags
);
3777 if (!(object
= heap_alloc_zero(sizeof(*object
))))
3778 return E_OUTOFMEMORY
;
3779 d3d11_device_context_init(object
, device
, D3D11_DEVICE_CONTEXT_DEFERRED
);
3781 if (FAILED(hr
= wined3d_deferred_context_create(device
->wined3d_device
, &object
->wined3d_context
)))
3783 WARN("Failed to create wined3d deferred context, hr %#x.\n", hr
);
3788 TRACE("Created deferred context %p.\n", object
);
3794 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device2
*iface
, UINT flags
,
3795 ID3D11DeviceContext
**context
)
3797 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3798 struct d3d11_device_context
*object
;
3801 TRACE("iface %p, flags %#x, context %p.\n", iface
, flags
, context
);
3803 if (FAILED(hr
= d3d11_deferred_context_create(device
, flags
, &object
)))
3806 *context
= (ID3D11DeviceContext
*)&object
->ID3D11DeviceContext1_iface
;
3810 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device2
*iface
, HANDLE resource
, REFIID iid
,
3813 FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface
, resource
, debugstr_guid(iid
), out
);
3818 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device2
*iface
, DXGI_FORMAT format
,
3819 UINT
*format_support
)
3821 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3822 struct wined3d_device_creation_parameters params
;
3823 struct wined3d_adapter
*wined3d_adapter
;
3824 enum wined3d_format_id wined3d_format
;
3825 D3D_FEATURE_LEVEL feature_level
;
3826 struct wined3d
*wined3d
;
3831 enum wined3d_resource_type rtype
;
3832 unsigned int bind_flags
;
3834 D3D11_FORMAT_SUPPORT flag
;
3838 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_BUFFER
},
3839 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_VERTEX_BUFFER
, 0, D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER
},
3840 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_INDEX_BUFFER
, 0, D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
},
3841 {WINED3D_RTYPE_TEXTURE_1D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE1D
},
3842 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3843 {WINED3D_RTYPE_TEXTURE_3D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3844 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, 0, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3845 {WINED3D_RTYPE_NONE
, WINED3D_BIND_DEPTH_STENCIL
, 0, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3846 {WINED3D_RTYPE_NONE
, WINED3D_BIND_UNORDERED_ACCESS
, 0, D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW
},
3847 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_WRAPANDMIP
, D3D11_FORMAT_SUPPORT_MIP
},
3848 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_GENMIPMAP
, D3D11_FORMAT_SUPPORT_MIP_AUTOGEN
},
3849 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
, D3D11_FORMAT_SUPPORT_BLENDABLE
},
3853 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3855 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3856 if (format
&& !wined3d_format
)
3858 WARN("Invalid format %#x.\n", format
);
3859 *format_support
= 0;
3863 *format_support
= 0;
3865 wined3d_mutex_lock();
3866 feature_level
= device
->state
->feature_level
;
3867 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3868 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3869 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3870 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3872 hr
= wined3d_check_device_format(wined3d
, wined3d_adapter
, params
.device_type
,
3873 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].bind_flags
, flag_mapping
[i
].rtype
, wined3d_format
);
3874 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOMIPGEN
)
3876 if (hr
!= WINED3D_OK
)
3878 WARN("Failed to check device format support, hr %#x.\n", hr
);
3879 wined3d_mutex_unlock();
3883 *format_support
|= flag_mapping
[i
].flag
;
3885 wined3d_mutex_unlock();
3887 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
3888 *format_support
&= ~D3D11_FORMAT_SUPPORT_BUFFER
;
3890 if (*format_support
& (D3D11_FORMAT_SUPPORT_TEXTURE1D
3891 | D3D11_FORMAT_SUPPORT_TEXTURE2D
| D3D11_FORMAT_SUPPORT_TEXTURE3D
))
3893 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_LOAD
;
3894 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
;
3895 *format_support
|= D3D11_FORMAT_SUPPORT_TEXTURECUBE
;
3897 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3898 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER
;
3900 if (*format_support
& D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
)
3902 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
3903 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
;
3905 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3906 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
;
3910 /* d3d11 requires 4 and 8 sample counts support for formats reported to
3911 * support multisample. */
3912 if (wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3913 TRUE
, WINED3D_MULTISAMPLE_4_SAMPLES
, NULL
) == WINED3D_OK
&&
3914 wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3915 TRUE
, WINED3D_MULTISAMPLE_8_SAMPLES
, NULL
) == WINED3D_OK
)
3917 *format_support
|= D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE
3918 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
3919 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
;
3925 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2
*iface
,
3926 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3928 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3929 struct wined3d_device_creation_parameters params
;
3930 struct wined3d_adapter
*wined3d_adapter
;
3931 struct wined3d
*wined3d
;
3934 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3935 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3937 if (!quality_level_count
)
3938 return E_INVALIDARG
;
3940 *quality_level_count
= 0;
3944 if (sample_count
== 1)
3946 *quality_level_count
= 1;
3949 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3952 wined3d_mutex_lock();
3953 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3954 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3955 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3956 hr
= wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
,
3957 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3958 wined3d_mutex_unlock();
3960 if (hr
== WINED3DERR_INVALIDCALL
)
3961 return E_INVALIDARG
;
3962 if (hr
== WINED3DERR_NOTAVAILABLE
)
3967 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device2
*iface
, D3D11_COUNTER_INFO
*info
)
3969 FIXME("iface %p, info %p stub!\n", iface
, info
);
3972 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3973 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3974 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3976 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3977 "units %p, units_length %p, description %p, description_length %p stub!\n",
3978 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3979 units
, units_length
, description
, description_length
);
3984 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device2
*iface
, D3D11_FEATURE feature
,
3985 void *feature_support_data
, UINT feature_support_data_size
)
3987 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3988 struct wined3d_caps wined3d_caps
;
3991 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3992 iface
, feature
, feature_support_data
, feature_support_data_size
);
3996 case D3D11_FEATURE_THREADING
:
3998 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
3999 if (feature_support_data_size
!= sizeof(*threading_data
))
4001 WARN("Invalid data size.\n");
4002 return E_INVALIDARG
;
4005 /* We lie about the threading support to make Tomb Raider 2013 and
4006 * Deus Ex: Human Revolution happy. */
4007 FIXME("Returning fake threading support data.\n");
4008 threading_data
->DriverConcurrentCreates
= TRUE
;
4009 threading_data
->DriverCommandLists
= TRUE
;
4013 case D3D11_FEATURE_DOUBLES
:
4015 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
4016 if (feature_support_data_size
!= sizeof(*doubles_data
))
4018 WARN("Invalid data size.\n");
4019 return E_INVALIDARG
;
4022 wined3d_mutex_lock();
4023 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4024 wined3d_mutex_unlock();
4027 WARN("Failed to get device caps, hr %#x.\n", hr
);
4031 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
4035 case D3D11_FEATURE_D3D9_OPTIONS
:
4037 D3D11_FEATURE_DATA_D3D9_OPTIONS
*options
= feature_support_data
;
4038 if (feature_support_data_size
!= sizeof(*options
))
4040 WARN("Invalid data size.\n");
4041 return E_INVALIDARG
;
4044 wined3d_mutex_lock();
4045 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4046 wined3d_mutex_unlock();
4049 WARN("Failed to get device caps, hr %#x.\n", hr
);
4053 options
->FullNonPow2TextureSupport
= !(wined3d_caps
.TextureCaps
& WINED3DPTEXTURECAPS_POW2
);
4057 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
4059 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
4060 if (feature_support_data_size
!= sizeof(*options
))
4062 WARN("Invalid data size.\n");
4063 return E_INVALIDARG
;
4066 wined3d_mutex_lock();
4067 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4068 wined3d_mutex_unlock();
4071 WARN("Failed to get device caps, hr %#x.\n", hr
);
4075 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
4076 = wined3d_caps
.max_feature_level
>= WINED3D_FEATURE_LEVEL_11
;
4080 case D3D11_FEATURE_D3D11_OPTIONS
:
4082 D3D11_FEATURE_DATA_D3D11_OPTIONS
*options
= feature_support_data
;
4083 if (feature_support_data_size
!= sizeof(*options
))
4085 WARN("Invalid data size.\n");
4086 return E_INVALIDARG
;
4089 FIXME("Returning fake Options support data.\n");
4090 options
->OutputMergerLogicOp
= FALSE
;
4091 options
->UAVOnlyRenderingForcedSampleCount
= FALSE
;
4092 options
->DiscardAPIsSeenByDriver
= FALSE
;
4093 options
->FlagsForUpdateAndCopySeenByDriver
= FALSE
;
4094 options
->ClearView
= FALSE
;
4095 options
->CopyWithOverlap
= FALSE
;
4096 options
->ConstantBufferPartialUpdate
= FALSE
;
4097 options
->ConstantBufferOffsetting
= TRUE
;
4098 options
->MapNoOverwriteOnDynamicConstantBuffer
= FALSE
;
4099 options
->MapNoOverwriteOnDynamicBufferSRV
= FALSE
;
4100 options
->MultisampleRTVWithForcedSampleCountOne
= FALSE
;
4101 options
->SAD4ShaderInstructions
= FALSE
;
4102 options
->ExtendedDoublesShaderInstructions
= FALSE
;
4103 options
->ExtendedResourceSharing
= FALSE
;
4107 case D3D11_FEATURE_D3D11_OPTIONS1
:
4109 D3D11_FEATURE_DATA_D3D11_OPTIONS1
*options
= feature_support_data
;
4110 if (feature_support_data_size
!= sizeof(*options
))
4112 WARN("Invalid data size.\n");
4113 return E_INVALIDARG
;
4116 FIXME("Returning fake Options1 support data.\n");
4117 options
->TiledResourcesTier
= D3D11_TILED_RESOURCES_NOT_SUPPORTED
;
4118 options
->MinMaxFiltering
= FALSE
;
4119 options
->ClearViewAlsoSupportsDepthOnlyFormats
= FALSE
;
4120 options
->MapOnDefaultBuffers
= FALSE
;
4124 case D3D11_FEATURE_D3D11_OPTIONS3
:
4126 D3D11_FEATURE_DATA_D3D11_OPTIONS3
*options
= feature_support_data
;
4127 if (feature_support_data_size
!= sizeof(*options
))
4129 WARN("Invalid data size.\n");
4130 return E_INVALIDARG
;
4133 wined3d_mutex_lock();
4134 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4135 wined3d_mutex_unlock();
4138 WARN("Failed to get device caps, hr %#x.\n", hr
);
4142 options
->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
4143 = wined3d_caps
.viewport_array_index_any_shader
;
4147 case D3D11_FEATURE_ARCHITECTURE_INFO
:
4149 D3D11_FEATURE_DATA_ARCHITECTURE_INFO
*options
= feature_support_data
;
4150 if (feature_support_data_size
!= sizeof(*options
))
4152 WARN("Invalid data size.\n");
4153 return E_INVALIDARG
;
4156 FIXME("Returning fake data architecture info.\n");
4157 options
->TileBasedDeferredRenderer
= FALSE
;
4162 FIXME("Unhandled feature %#x.\n", feature
);
4167 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
4168 UINT
*data_size
, void *data
)
4170 IDXGIDevice
*dxgi_device
;
4173 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4175 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4177 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
4178 IDXGIDevice_Release(dxgi_device
);
4183 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
4184 UINT data_size
, const void *data
)
4186 IDXGIDevice
*dxgi_device
;
4189 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4191 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4193 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
4194 IDXGIDevice_Release(dxgi_device
);
4199 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device2
*iface
, REFGUID guid
,
4200 const IUnknown
*data
)
4202 IDXGIDevice
*dxgi_device
;
4205 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4207 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4209 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
4210 IDXGIDevice_Release(dxgi_device
);
4215 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device2
*iface
)
4217 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4219 TRACE("iface %p.\n", iface
);
4221 return device
->state
->feature_level
;
4224 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device2
*iface
)
4226 FIXME("iface %p stub!\n", iface
);
4231 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device2
*iface
)
4233 WARN("iface %p stub!\n", iface
);
4238 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device2
*iface
,
4239 ID3D11DeviceContext
**immediate_context
)
4241 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4243 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
4245 *immediate_context
= (ID3D11DeviceContext
*)&device
->immediate_context
.ID3D11DeviceContext1_iface
;
4246 ID3D11DeviceContext_AddRef(*immediate_context
);
4249 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device2
*iface
, UINT flags
)
4251 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4256 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device2
*iface
)
4258 FIXME("iface %p stub!\n", iface
);
4263 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext1(ID3D11Device2
*iface
,
4264 ID3D11DeviceContext1
**immediate_context
)
4266 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4268 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
4270 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext1_iface
;
4271 ID3D11DeviceContext1_AddRef(*immediate_context
);
4274 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext1(ID3D11Device2
*iface
, UINT flags
,
4275 ID3D11DeviceContext1
**context
)
4277 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4278 struct d3d11_device_context
*object
;
4281 TRACE("iface %p, flags %#x, context %p.\n", iface
, flags
, context
);
4283 if (FAILED(hr
= d3d11_deferred_context_create(device
, flags
, &object
)))
4286 *context
= &object
->ID3D11DeviceContext1_iface
;
4290 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState1(ID3D11Device2
*iface
,
4291 const D3D11_BLEND_DESC1
*desc
, ID3D11BlendState1
**state
)
4293 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
4298 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState1(ID3D11Device2
*iface
,
4299 const D3D11_RASTERIZER_DESC1
*desc
, ID3D11RasterizerState1
**state
)
4301 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4302 struct d3d_rasterizer_state
*object
;
4305 TRACE("iface %p, desc %p, state %p.\n", iface
, desc
, state
);
4308 return E_INVALIDARG
;
4310 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
4313 *state
= &object
->ID3D11RasterizerState1_iface
;
4318 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeviceContextState(ID3D11Device2
*iface
, UINT flags
,
4319 const D3D_FEATURE_LEVEL
*feature_levels
, UINT feature_level_count
, UINT sdk_version
,
4320 REFIID emulated_interface
, D3D_FEATURE_LEVEL
*chosen_feature_level
, ID3DDeviceContextState
**state
)
4322 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4323 struct d3d_device_context_state
*state_impl
;
4324 struct wined3d_state
*wined3d_state
;
4325 D3D_FEATURE_LEVEL feature_level
;
4326 HRESULT hr
= E_INVALIDARG
;
4328 TRACE("iface %p, flags %#x, feature_levels %p, feature_level_count %u, "
4329 "sdk_version %u, emulated_interface %s, chosen_feature_level %p, state %p.\n",
4330 iface
, flags
, feature_levels
, feature_level_count
,
4331 sdk_version
, debugstr_guid(emulated_interface
), chosen_feature_level
, state
);
4334 FIXME("Ignoring flags %#x.\n", flags
);
4336 wined3d_mutex_lock();
4338 if (!feature_level_count
)
4341 if (FAILED(hr
= wined3d_state_create(device
->wined3d_device
,
4342 (const enum wined3d_feature_level
*)feature_levels
, feature_level_count
, &wined3d_state
)))
4344 feature_level
= d3d_feature_level_from_wined3d(wined3d_state_get_feature_level(wined3d_state
));
4346 if (chosen_feature_level
)
4347 *chosen_feature_level
= feature_level
;
4351 wined3d_state_destroy(wined3d_state
);
4352 wined3d_mutex_unlock();
4356 if (!(state_impl
= heap_alloc_zero(sizeof(*state_impl
))))
4358 wined3d_state_destroy(wined3d_state
);
4363 d3d_device_context_state_init(state_impl
, device
, feature_level
, emulated_interface
);
4364 if (!d3d_device_context_state_add_entry(state_impl
, device
, wined3d_state
))
4366 wined3d_state_destroy(wined3d_state
);
4367 ID3DDeviceContextState_Release(&state_impl
->ID3DDeviceContextState_iface
);
4372 *state
= &state_impl
->ID3DDeviceContextState_iface
;
4373 device
->d3d11_only
= FALSE
;
4374 wined3d_mutex_unlock();
4379 wined3d_mutex_unlock();
4380 if (chosen_feature_level
)
4381 *chosen_feature_level
= 0;
4387 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource1(ID3D11Device2
*iface
, HANDLE handle
,
4388 REFIID iid
, void **resource
)
4390 FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface
, handle
, debugstr_guid(iid
), resource
);
4395 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResourceByName(ID3D11Device2
*iface
, const WCHAR
*name
,
4396 DWORD access
, REFIID iid
, void **resource
)
4398 FIXME("iface %p, name %s, access %#x, iid %s, resource %p stub!\n", iface
, debugstr_w(name
), access
,
4399 debugstr_guid(iid
), resource
);
4404 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext2(ID3D11Device2
*iface
,
4405 ID3D11DeviceContext2
**context
)
4407 FIXME("iface %p, context %p stub!\n", iface
, context
);
4410 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext2(ID3D11Device2
*iface
,
4411 UINT flags
, ID3D11DeviceContext2
**context
)
4413 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
4418 static void STDMETHODCALLTYPE
d3d11_device_GetResourceTiling(ID3D11Device2
*iface
,
4419 ID3D11Resource
*resource
, UINT
*tile_count
, D3D11_PACKED_MIP_DESC
*mip_desc
,
4420 D3D11_TILE_SHAPE
*tile_shape
, UINT
*subresource_tiling_count
, UINT first_subresource_tiling
,
4421 D3D11_SUBRESOURCE_TILING
*subresource_tiling
)
4423 FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, "
4424 "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n",
4425 iface
, resource
, tile_count
, mip_desc
, tile_shape
,
4426 subresource_tiling_count
, first_subresource_tiling
, subresource_tiling
);
4429 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2
*iface
,
4430 DXGI_FORMAT format
, UINT sample_count
, UINT flags
, UINT
*quality_level_count
)
4432 FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n",
4433 iface
, format
, sample_count
, flags
, quality_level_count
);
4438 static const struct ID3D11Device2Vtbl d3d11_device_vtbl
=
4440 /* IUnknown methods */
4441 d3d11_device_QueryInterface
,
4442 d3d11_device_AddRef
,
4443 d3d11_device_Release
,
4444 /* ID3D11Device methods */
4445 d3d11_device_CreateBuffer
,
4446 d3d11_device_CreateTexture1D
,
4447 d3d11_device_CreateTexture2D
,
4448 d3d11_device_CreateTexture3D
,
4449 d3d11_device_CreateShaderResourceView
,
4450 d3d11_device_CreateUnorderedAccessView
,
4451 d3d11_device_CreateRenderTargetView
,
4452 d3d11_device_CreateDepthStencilView
,
4453 d3d11_device_CreateInputLayout
,
4454 d3d11_device_CreateVertexShader
,
4455 d3d11_device_CreateGeometryShader
,
4456 d3d11_device_CreateGeometryShaderWithStreamOutput
,
4457 d3d11_device_CreatePixelShader
,
4458 d3d11_device_CreateHullShader
,
4459 d3d11_device_CreateDomainShader
,
4460 d3d11_device_CreateComputeShader
,
4461 d3d11_device_CreateClassLinkage
,
4462 d3d11_device_CreateBlendState
,
4463 d3d11_device_CreateDepthStencilState
,
4464 d3d11_device_CreateRasterizerState
,
4465 d3d11_device_CreateSamplerState
,
4466 d3d11_device_CreateQuery
,
4467 d3d11_device_CreatePredicate
,
4468 d3d11_device_CreateCounter
,
4469 d3d11_device_CreateDeferredContext
,
4470 d3d11_device_OpenSharedResource
,
4471 d3d11_device_CheckFormatSupport
,
4472 d3d11_device_CheckMultisampleQualityLevels
,
4473 d3d11_device_CheckCounterInfo
,
4474 d3d11_device_CheckCounter
,
4475 d3d11_device_CheckFeatureSupport
,
4476 d3d11_device_GetPrivateData
,
4477 d3d11_device_SetPrivateData
,
4478 d3d11_device_SetPrivateDataInterface
,
4479 d3d11_device_GetFeatureLevel
,
4480 d3d11_device_GetCreationFlags
,
4481 d3d11_device_GetDeviceRemovedReason
,
4482 d3d11_device_GetImmediateContext
,
4483 d3d11_device_SetExceptionMode
,
4484 d3d11_device_GetExceptionMode
,
4485 /* ID3D11Device1 methods */
4486 d3d11_device_GetImmediateContext1
,
4487 d3d11_device_CreateDeferredContext1
,
4488 d3d11_device_CreateBlendState1
,
4489 d3d11_device_CreateRasterizerState1
,
4490 d3d11_device_CreateDeviceContextState
,
4491 d3d11_device_OpenSharedResource1
,
4492 d3d11_device_OpenSharedResourceByName
,
4493 /* ID3D11Device2 methods */
4494 d3d11_device_GetImmediateContext2
,
4495 d3d11_device_CreateDeferredContext2
,
4496 d3d11_device_GetResourceTiling
,
4497 d3d11_device_CheckMultisampleQualityLevels1
,
4500 /* Inner IUnknown methods */
4502 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
4504 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
4507 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
4509 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4511 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
4513 if (IsEqualGUID(riid
, &IID_ID3D11Device2
)
4514 || IsEqualGUID(riid
, &IID_ID3D11Device1
)
4515 || IsEqualGUID(riid
, &IID_ID3D11Device
)
4516 || IsEqualGUID(riid
, &IID_IUnknown
))
4518 *out
= &device
->ID3D11Device2_iface
;
4520 else if (!device
->d3d11_only
4521 && (IsEqualGUID(riid
, &IID_ID3D10Device1
)
4522 || IsEqualGUID(riid
, &IID_ID3D10Device
)))
4524 *out
= &device
->ID3D10Device1_iface
;
4526 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
4528 *out
= &device
->ID3D10Multithread_iface
;
4530 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
4532 *out
= &device
->IWineDXGIDeviceParent_iface
;
4536 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
4538 return E_NOINTERFACE
;
4541 IUnknown_AddRef((IUnknown
*)*out
);
4545 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
4547 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4548 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
4550 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
4555 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
4557 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4558 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
4561 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
4566 d3d_device_context_state_private_release(device
->state
);
4567 for (i
= 0; i
< device
->context_state_count
; ++i
)
4569 d3d_device_context_state_remove_entry(device
->context_states
[i
], device
);
4571 heap_free(device
->context_states
);
4572 d3d11_device_context_cleanup(&device
->immediate_context
);
4573 if (device
->wined3d_device
)
4575 wined3d_device_decref(device
->wined3d_device
);
4577 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
4578 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
4579 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4580 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4586 /* IUnknown methods */
4588 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID iid
,
4591 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4592 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4595 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
4597 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4598 return IUnknown_AddRef(device
->outer_unk
);
4601 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
4603 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4604 return IUnknown_Release(device
->outer_unk
);
4607 /* ID3D10Device methods */
4609 static void d3d10_device_get_constant_buffers(ID3D10Device1
*iface
,
4610 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4612 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4615 wined3d_mutex_lock();
4616 for (i
= 0; i
< buffer_count
; ++i
)
4618 struct wined3d_constant_buffer_state state
;
4619 struct d3d_buffer
*buffer_impl
;
4621 wined3d_device_context_get_constant_buffer(device
->immediate_context
.wined3d_context
,
4622 type
, start_slot
+ i
, &state
);
4630 buffer_impl
= wined3d_buffer_get_parent(state
.buffer
);
4631 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4632 ID3D10Buffer_AddRef(buffers
[i
]);
4634 wined3d_mutex_unlock();
4637 static void d3d10_device_set_constant_buffers(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4638 unsigned int start_slot
, unsigned int buffer_count
, ID3D10Buffer
*const *buffers
)
4640 struct wined3d_constant_buffer_state wined3d_buffers
[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
4641 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4644 if (buffer_count
> ARRAY_SIZE(wined3d_buffers
))
4646 WARN("Buffer count %u exceeds limit; ignoring call.\n", buffer_count
);
4650 for (i
= 0; i
< buffer_count
; ++i
)
4652 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4654 wined3d_buffers
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
4655 wined3d_buffers
[i
].offset
= 0;
4656 wined3d_buffers
[i
].size
= WINED3D_MAX_CONSTANT_BUFFER_SIZE
* sizeof(struct wined3d_vec4
);
4659 wined3d_device_context_set_constant_buffers(device
->immediate_context
.wined3d_context
,
4660 type
, start_slot
, buffer_count
, wined3d_buffers
);
4663 static void d3d10_device_set_shader_resource_views(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4664 unsigned int start_slot
, unsigned int count
, ID3D10ShaderResourceView
*const *views
)
4666 struct wined3d_shader_resource_view
*wined3d_views
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
4667 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4670 if (count
> ARRAY_SIZE(wined3d_views
))
4672 WARN("View count %u exceeds limit; ignoring call.\n", count
);
4676 for (i
= 0; i
< count
; ++i
)
4678 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4680 wined3d_views
[i
] = view
? view
->wined3d_view
: NULL
;
4683 wined3d_device_context_set_shader_resource_views(device
->immediate_context
.wined3d_context
,
4684 type
, start_slot
, count
, wined3d_views
);
4687 static void d3d10_device_set_samplers(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4688 unsigned int start_slot
, unsigned int count
, ID3D10SamplerState
*const *samplers
)
4690 struct wined3d_sampler
*wined3d_samplers
[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
];
4691 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4694 if (count
> ARRAY_SIZE(wined3d_samplers
))
4696 WARN("Sampler count %u exceeds limit; ignoring call.\n", count
);
4700 for (i
= 0; i
< count
; ++i
)
4702 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4704 wined3d_samplers
[i
] = sampler
? sampler
->wined3d_sampler
: NULL
;
4707 wined3d_device_context_set_samplers(device
->immediate_context
.wined3d_context
,
4708 type
, start_slot
, count
, wined3d_samplers
);
4711 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
4712 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4714 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4715 iface
, start_slot
, buffer_count
, buffers
);
4717 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
4718 buffer_count
, buffers
);
4721 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
4722 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4724 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4725 iface
, start_slot
, view_count
, views
);
4727 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, view_count
, views
);
4730 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
4731 ID3D10PixelShader
*shader
)
4733 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4734 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
4736 TRACE("iface %p, shader %p\n", iface
, shader
);
4738 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4739 WINED3D_SHADER_TYPE_PIXEL
, ps
? ps
->wined3d_shader
: NULL
);
4742 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
4743 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4745 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4746 iface
, start_slot
, sampler_count
, samplers
);
4748 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, sampler_count
, samplers
);
4751 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
4752 ID3D10VertexShader
*shader
)
4754 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4755 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
4757 TRACE("iface %p, shader %p\n", iface
, shader
);
4759 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4760 WINED3D_SHADER_TYPE_VERTEX
, vs
? vs
->wined3d_shader
: NULL
);
4763 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
4764 UINT start_index_location
, INT base_vertex_location
)
4766 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4768 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
4769 iface
, index_count
, start_index_location
, base_vertex_location
);
4771 wined3d_device_context_draw_indexed(device
->immediate_context
.wined3d_context
,
4772 base_vertex_location
, start_index_location
, index_count
, 0, 0);
4775 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
4776 UINT start_vertex_location
)
4778 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4780 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
4781 iface
, vertex_count
, start_vertex_location
);
4783 wined3d_device_context_draw(device
->immediate_context
.wined3d_context
, start_vertex_location
, vertex_count
, 0, 0);
4786 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
4787 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4789 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4790 iface
, start_slot
, buffer_count
, buffers
);
4792 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
4793 buffer_count
, buffers
);
4796 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
4797 ID3D10InputLayout
*input_layout
)
4799 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4800 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
4802 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
4804 wined3d_device_context_set_vertex_declaration(device
->immediate_context
.wined3d_context
,
4805 layout
? layout
->wined3d_decl
: NULL
);
4808 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
4809 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
4811 struct wined3d_stream_state streams
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
4812 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4815 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
4816 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4818 if (buffer_count
> ARRAY_SIZE(streams
))
4820 WARN("Buffer count %u exceeds limit.\n", buffer_count
);
4821 buffer_count
= ARRAY_SIZE(streams
);
4824 for (i
= 0; i
< buffer_count
; ++i
)
4826 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4828 streams
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
4829 streams
[i
].offset
= offsets
[i
];
4830 streams
[i
].stride
= strides
[i
];
4831 streams
[i
].frequency
= 1;
4832 streams
[i
].flags
= 0;
4835 wined3d_device_context_set_stream_sources(device
->immediate_context
.wined3d_context
,
4836 start_slot
, buffer_count
, streams
);
4839 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
4840 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
4842 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4843 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
4845 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
4846 iface
, buffer
, debug_dxgi_format(format
), offset
);
4848 wined3d_device_context_set_index_buffer(device
->immediate_context
.wined3d_context
,
4849 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
4850 wined3dformat_from_dxgi_format(format
), offset
);
4853 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
4854 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
4855 INT base_vertex_location
, UINT start_instance_location
)
4857 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4859 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
4860 "base_vertex_location %d, start_instance_location %u.\n",
4861 iface
, instance_index_count
, instance_count
, start_index_location
,
4862 base_vertex_location
, start_instance_location
);
4864 wined3d_device_context_draw_indexed(device
->immediate_context
.wined3d_context
, base_vertex_location
,
4865 start_index_location
, instance_index_count
, start_instance_location
, instance_count
);
4868 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
4869 UINT instance_vertex_count
, UINT instance_count
,
4870 UINT start_vertex_location
, UINT start_instance_location
)
4872 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4874 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
4875 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
4876 start_vertex_location
, start_instance_location
);
4878 wined3d_device_context_draw(device
->immediate_context
.wined3d_context
, start_vertex_location
,
4879 instance_vertex_count
, start_instance_location
, instance_count
);
4882 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
4883 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4885 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4886 iface
, start_slot
, buffer_count
, buffers
);
4888 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
4889 buffer_count
, buffers
);
4892 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
4894 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4895 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
4897 TRACE("iface %p, shader %p.\n", iface
, shader
);
4899 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4900 WINED3D_SHADER_TYPE_GEOMETRY
, gs
? gs
->wined3d_shader
: NULL
);
4903 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
4904 D3D10_PRIMITIVE_TOPOLOGY topology
)
4906 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4908 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
4910 wined3d_device_context_set_primitive_type(device
->immediate_context
.wined3d_context
,
4911 (enum wined3d_primitive_type
)topology
, 0);
4914 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
4915 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4917 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4918 iface
, start_slot
, view_count
, views
);
4920 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, view_count
, views
);
4923 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
4924 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4926 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4927 iface
, start_slot
, sampler_count
, samplers
);
4929 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, sampler_count
, samplers
);
4932 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
4934 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4935 struct d3d_query
*query
;
4937 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
4939 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
4940 wined3d_device_context_set_predication(device
->immediate_context
.wined3d_context
,
4941 query
? query
->wined3d_query
: NULL
, value
);
4944 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
4945 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4947 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4948 iface
, start_slot
, view_count
, views
);
4950 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, view_count
, views
);
4953 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
4954 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4956 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4957 iface
, start_slot
, sampler_count
, samplers
);
4959 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, sampler_count
, samplers
);
4962 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
4963 UINT rtv_count
, ID3D10RenderTargetView
*const *rtvs
, ID3D10DepthStencilView
*depth_stencil_view
)
4965 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
4966 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4967 struct d3d_depthstencil_view
*dsv
;
4970 TRACE("iface %p, rtv_count %u, rtvs %p, depth_stencil_view %p.\n", iface
, rtv_count
, rtvs
, depth_stencil_view
);
4972 if (rtv_count
> ARRAY_SIZE(wined3d_rtvs
))
4974 WARN("View count %u exceeds limit.\n", rtv_count
);
4975 rtv_count
= ARRAY_SIZE(wined3d_rtvs
);
4978 for (i
= 0; i
< rtv_count
; ++i
)
4980 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(rtvs
[i
]);
4982 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
4985 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4987 wined3d_device_context_set_render_targets_and_unordered_access_views(device
->immediate_context
.wined3d_context
,
4988 ARRAY_SIZE(wined3d_rtvs
), wined3d_rtvs
, dsv
? dsv
->wined3d_view
: NULL
, ~0u, NULL
, NULL
);
4991 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
4992 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
4994 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4995 struct d3d_blend_state
*blend_state_object
;
4997 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
4998 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
5000 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
5001 d3d11_device_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5002 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
5005 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
5006 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
5008 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5009 struct d3d_depthstencil_state
*ds_state_object
;
5011 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
5012 iface
, depth_stencil_state
, stencil_ref
);
5014 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
5015 d3d11_device_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5016 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
5019 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
5020 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
5022 struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
] = {0};
5023 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5024 unsigned int count
, i
;
5026 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
5028 count
= min(target_count
, ARRAY_SIZE(outputs
));
5029 for (i
= 0; i
< count
; ++i
)
5031 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
5033 outputs
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
5034 outputs
[i
].offset
= offsets
? offsets
[i
] : 0;
5037 wined3d_device_context_set_stream_outputs(device
->immediate_context
.wined3d_context
, outputs
);
5040 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
5042 FIXME("iface %p stub!\n", iface
);
5045 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
5047 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5048 struct d3d_rasterizer_state
*rasterizer_state_object
;
5050 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5052 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
5053 d3d11_device_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5054 rasterizer_state_object
? (ID3D11RasterizerState
*)&rasterizer_state_object
->ID3D11RasterizerState1_iface
: NULL
);
5057 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
5058 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
5060 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5061 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5064 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
5066 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
5069 for (i
= 0; i
< viewport_count
; ++i
)
5071 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
5072 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
5073 wined3d_vp
[i
].width
= viewports
[i
].Width
;
5074 wined3d_vp
[i
].height
= viewports
[i
].Height
;
5075 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
5076 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
5079 wined3d_device_context_set_viewports(device
->immediate_context
.wined3d_context
, viewport_count
, wined3d_vp
);
5082 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
5083 UINT rect_count
, const D3D10_RECT
*rects
)
5085 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5087 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
5089 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
5092 wined3d_device_context_set_scissor_rects(device
->immediate_context
.wined3d_context
, rect_count
, rects
);
5095 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
5096 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
5097 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
5099 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5100 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5101 struct wined3d_box wined3d_src_box
;
5103 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
5104 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
5105 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
5106 src_resource
, src_subresource_idx
, src_box
);
5108 if (!dst_resource
|| !src_resource
)
5112 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
5113 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
5115 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5116 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5117 wined3d_device_context_copy_sub_resource_region(device
->immediate_context
.wined3d_context
,
5118 wined3d_dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
5119 wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
5122 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
5123 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
5125 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5126 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5128 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
5130 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5131 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5132 wined3d_device_context_copy_resource(device
->immediate_context
.wined3d_context
,
5133 wined3d_dst_resource
, wined3d_src_resource
);
5136 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
5137 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
5138 const void *data
, UINT row_pitch
, UINT depth_pitch
)
5140 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5141 ID3D11Resource
*d3d11_resource
;
5143 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
5144 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
5146 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
5147 d3d11_device_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5148 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
5149 ID3D11Resource_Release(d3d11_resource
);
5152 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
5153 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
5155 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5156 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
5157 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
5160 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
5161 iface
, render_target_view
, debug_float4(color_rgba
));
5166 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(device
->immediate_context
.wined3d_context
,
5167 view
->wined3d_view
, NULL
, WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
5168 ERR("Failed to clear view, hr %#x.\n", hr
);
5171 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
5172 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
5174 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5175 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
5176 DWORD wined3d_flags
;
5179 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
5180 iface
, depth_stencil_view
, flags
, depth
, stencil
);
5185 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
5187 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(device
->immediate_context
.wined3d_context
,
5188 view
->wined3d_view
, NULL
, wined3d_flags
, NULL
, depth
, stencil
)))
5189 ERR("Failed to clear view, hr %#x.\n", hr
);
5192 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
5193 ID3D10ShaderResourceView
*view
)
5195 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5196 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D10ShaderResourceView(view
);
5198 TRACE("iface %p, view %p.\n", iface
, view
);
5200 wined3d_device_context_generate_mipmaps(device
->immediate_context
.wined3d_context
, srv
->wined3d_view
);
5203 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
5204 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
5205 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
5207 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5208 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5209 enum wined3d_format_id wined3d_format
;
5211 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
5212 "src_resource %p, src_subresource_idx %u, format %s.\n",
5213 iface
, dst_resource
, dst_subresource_idx
,
5214 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
5216 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5217 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5218 wined3d_format
= wined3dformat_from_dxgi_format(format
);
5219 wined3d_device_context_resolve_sub_resource(device
->immediate_context
.wined3d_context
,
5220 wined3d_dst_resource
, dst_subresource_idx
,
5221 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
5224 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
5225 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5227 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5228 iface
, start_slot
, buffer_count
, buffers
);
5230 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, buffer_count
,
5234 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
5235 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5237 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5240 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5241 iface
, start_slot
, view_count
, views
);
5243 wined3d_mutex_lock();
5244 for (i
= 0; i
< view_count
; ++i
)
5246 struct wined3d_shader_resource_view
*wined3d_view
;
5247 struct d3d_shader_resource_view
*view_impl
;
5249 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5250 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
5256 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5257 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5258 ID3D10ShaderResourceView_AddRef(views
[i
]);
5260 wined3d_mutex_unlock();
5263 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
5265 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5266 struct d3d_pixel_shader
*shader_impl
;
5267 struct wined3d_shader
*wined3d_shader
;
5269 TRACE("iface %p, shader %p.\n", iface
, shader
);
5271 wined3d_mutex_lock();
5272 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5273 WINED3D_SHADER_TYPE_PIXEL
)))
5275 wined3d_mutex_unlock();
5280 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5281 wined3d_mutex_unlock();
5282 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
5283 ID3D10PixelShader_AddRef(*shader
);
5286 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
5287 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5289 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5292 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5293 iface
, start_slot
, sampler_count
, samplers
);
5295 wined3d_mutex_lock();
5296 for (i
= 0; i
< sampler_count
; ++i
)
5298 struct d3d_sampler_state
*sampler_impl
;
5299 struct wined3d_sampler
*wined3d_sampler
;
5301 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5302 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
5308 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5309 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5310 ID3D10SamplerState_AddRef(samplers
[i
]);
5312 wined3d_mutex_unlock();
5315 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
5317 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5318 struct d3d_vertex_shader
*shader_impl
;
5319 struct wined3d_shader
*wined3d_shader
;
5321 TRACE("iface %p, shader %p.\n", iface
, shader
);
5323 wined3d_mutex_lock();
5324 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5325 WINED3D_SHADER_TYPE_VERTEX
)))
5327 wined3d_mutex_unlock();
5332 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5333 wined3d_mutex_unlock();
5334 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
5335 ID3D10VertexShader_AddRef(*shader
);
5338 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
5339 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5341 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5342 iface
, start_slot
, buffer_count
, buffers
);
5344 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, buffer_count
,
5348 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
5350 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5351 struct wined3d_vertex_declaration
*wined3d_declaration
;
5352 struct d3d_input_layout
*input_layout_impl
;
5354 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
5356 wined3d_mutex_lock();
5357 if (!(wined3d_declaration
= wined3d_device_context_get_vertex_declaration(
5358 device
->immediate_context
.wined3d_context
)))
5360 wined3d_mutex_unlock();
5361 *input_layout
= NULL
;
5365 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
5366 wined3d_mutex_unlock();
5367 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
5368 ID3D10InputLayout_AddRef(*input_layout
);
5371 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
5372 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
5374 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5377 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
5378 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
5380 wined3d_mutex_lock();
5381 for (i
= 0; i
< buffer_count
; ++i
)
5383 struct wined3d_buffer
*wined3d_buffer
= NULL
;
5384 struct d3d_buffer
*buffer_impl
;
5386 if (FAILED(wined3d_device_context_get_stream_source(device
->immediate_context
.wined3d_context
, start_slot
+ i
,
5387 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
5388 ERR("Failed to get vertex buffer.\n");
5390 if (!wined3d_buffer
)
5396 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5397 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5398 ID3D10Buffer_AddRef(buffers
[i
]);
5400 wined3d_mutex_unlock();
5403 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
5404 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
5406 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5407 enum wined3d_format_id wined3d_format
;
5408 struct wined3d_buffer
*wined3d_buffer
;
5409 struct d3d_buffer
*buffer_impl
;
5411 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
5413 wined3d_mutex_lock();
5414 wined3d_buffer
= wined3d_device_context_get_index_buffer(
5415 device
->immediate_context
.wined3d_context
, &wined3d_format
, offset
);
5416 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
5417 if (!wined3d_buffer
)
5419 wined3d_mutex_unlock();
5424 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5425 wined3d_mutex_unlock();
5426 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
5427 ID3D10Buffer_AddRef(*buffer
);
5430 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
5431 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5433 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5434 iface
, start_slot
, buffer_count
, buffers
);
5436 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, buffer_count
,
5440 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
5442 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5443 struct d3d_geometry_shader
*shader_impl
;
5444 struct wined3d_shader
*wined3d_shader
;
5446 TRACE("iface %p, shader %p.\n", iface
, shader
);
5448 wined3d_mutex_lock();
5449 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5450 WINED3D_SHADER_TYPE_GEOMETRY
)))
5452 wined3d_mutex_unlock();
5457 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5458 wined3d_mutex_unlock();
5459 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
5460 ID3D10GeometryShader_AddRef(*shader
);
5463 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
5464 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
5466 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5468 TRACE("iface %p, topology %p.\n", iface
, topology
);
5470 wined3d_mutex_lock();
5471 wined3d_device_context_get_primitive_type(device
->immediate_context
.wined3d_context
,
5472 (enum wined3d_primitive_type
*)topology
, NULL
);
5473 wined3d_mutex_unlock();
5476 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
5477 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5479 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5482 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5483 iface
, start_slot
, view_count
, views
);
5485 wined3d_mutex_lock();
5486 for (i
= 0; i
< view_count
; ++i
)
5488 struct wined3d_shader_resource_view
*wined3d_view
;
5489 struct d3d_shader_resource_view
*view_impl
;
5491 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5492 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
5498 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5499 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5500 ID3D10ShaderResourceView_AddRef(views
[i
]);
5502 wined3d_mutex_unlock();
5505 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
5506 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5508 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5511 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5512 iface
, start_slot
, sampler_count
, samplers
);
5514 wined3d_mutex_lock();
5515 for (i
= 0; i
< sampler_count
; ++i
)
5517 struct d3d_sampler_state
*sampler_impl
;
5518 struct wined3d_sampler
*wined3d_sampler
;
5520 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5521 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
5527 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5528 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5529 ID3D10SamplerState_AddRef(samplers
[i
]);
5531 wined3d_mutex_unlock();
5534 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
5535 ID3D10Predicate
**predicate
, BOOL
*value
)
5537 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5538 struct wined3d_query
*wined3d_predicate
;
5539 struct d3d_query
*predicate_impl
;
5541 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
5543 wined3d_mutex_lock();
5544 if (!(wined3d_predicate
= wined3d_device_context_get_predication(device
->immediate_context
.wined3d_context
, value
)))
5546 wined3d_mutex_unlock();
5551 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
5552 wined3d_mutex_unlock();
5553 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
5554 ID3D10Predicate_AddRef(*predicate
);
5557 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
5558 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5560 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5563 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5564 iface
, start_slot
, view_count
, views
);
5566 wined3d_mutex_lock();
5567 for (i
= 0; i
< view_count
; ++i
)
5569 struct wined3d_shader_resource_view
*wined3d_view
;
5570 struct d3d_shader_resource_view
*view_impl
;
5572 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5573 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
5579 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5580 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5581 ID3D10ShaderResourceView_AddRef(views
[i
]);
5583 wined3d_mutex_unlock();
5586 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
5587 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5589 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5592 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5593 iface
, start_slot
, sampler_count
, samplers
);
5595 wined3d_mutex_lock();
5596 for (i
= 0; i
< sampler_count
; ++i
)
5598 struct d3d_sampler_state
*sampler_impl
;
5599 struct wined3d_sampler
*wined3d_sampler
;
5601 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5602 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
5608 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5609 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5610 ID3D10SamplerState_AddRef(samplers
[i
]);
5612 wined3d_mutex_unlock();
5615 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
5616 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
5618 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5619 struct wined3d_rendertarget_view
*wined3d_view
;
5621 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
5622 iface
, view_count
, render_target_views
, depth_stencil_view
);
5624 wined3d_mutex_lock();
5625 if (render_target_views
)
5627 struct d3d_rendertarget_view
*view_impl
;
5630 for (i
= 0; i
< view_count
; ++i
)
5632 if (!(wined3d_view
= wined3d_device_context_get_rendertarget_view(
5633 device
->immediate_context
.wined3d_context
, i
))
5634 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5636 render_target_views
[i
] = NULL
;
5640 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
5641 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
5645 if (depth_stencil_view
)
5647 struct d3d_depthstencil_view
*view_impl
;
5649 if (!(wined3d_view
= wined3d_device_context_get_depth_stencil_view(device
->immediate_context
.wined3d_context
))
5650 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5652 *depth_stencil_view
= NULL
;
5656 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
5657 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
5660 wined3d_mutex_unlock();
5663 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
5664 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
5666 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5667 ID3D11BlendState
*d3d11_blend_state
;
5669 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
5670 iface
, blend_state
, blend_factor
, sample_mask
);
5672 d3d11_device_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5673 &d3d11_blend_state
, blend_factor
, sample_mask
);
5677 if (d3d11_blend_state
)
5679 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
5680 ID3D10BlendState_AddRef(*blend_state
);
5683 *blend_state
= NULL
;
5686 if (d3d11_blend_state
)
5687 ID3D11BlendState_Release(d3d11_blend_state
);
5690 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
5691 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
5693 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5694 ID3D11DepthStencilState
*d3d11_iface
= NULL
;
5696 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
5697 iface
, depth_stencil_state
, stencil_ref
);
5699 d3d11_device_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5700 &d3d11_iface
, stencil_ref
);
5702 if (depth_stencil_state
)
5706 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
5707 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
5710 *depth_stencil_state
= NULL
;
5714 ID3D11DepthStencilState_Release(d3d11_iface
);
5717 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
5718 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
5720 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5723 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
5724 iface
, buffer_count
, buffers
, offsets
);
5726 wined3d_mutex_lock();
5727 for (i
= 0; i
< buffer_count
; ++i
)
5729 struct wined3d_buffer
*wined3d_buffer
;
5730 struct d3d_buffer
*buffer_impl
;
5732 if (!(wined3d_buffer
= wined3d_device_context_get_stream_output(
5733 device
->immediate_context
.wined3d_context
, i
, &offsets
[i
])))
5739 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5740 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5741 ID3D10Buffer_AddRef(buffers
[i
]);
5743 wined3d_mutex_unlock();
5746 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
5748 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5749 struct d3d_rasterizer_state
*rasterizer_state_impl
;
5750 struct wined3d_rasterizer_state
*wined3d_state
;
5752 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5754 wined3d_mutex_lock();
5755 if ((wined3d_state
= wined3d_device_context_get_rasterizer_state(device
->immediate_context
.wined3d_context
)))
5757 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
5758 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
5762 *rasterizer_state
= NULL
;
5764 wined3d_mutex_unlock();
5767 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
5768 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
5770 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5771 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5772 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
5774 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
5776 if (!viewport_count
)
5779 wined3d_mutex_lock();
5780 wined3d_device_context_get_viewports(device
->immediate_context
.wined3d_context
,
5781 &actual_count
, viewports
? wined3d_vp
: NULL
);
5782 wined3d_mutex_unlock();
5786 *viewport_count
= actual_count
;
5790 if (*viewport_count
> actual_count
)
5791 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
5793 *viewport_count
= min(actual_count
, *viewport_count
);
5794 for (i
= 0; i
< *viewport_count
; ++i
)
5796 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
5797 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
5798 viewports
[i
].Width
= wined3d_vp
[i
].width
;
5799 viewports
[i
].Height
= wined3d_vp
[i
].height
;
5800 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
5801 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
5805 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
5807 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5808 unsigned int actual_count
;
5810 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
5815 actual_count
= *rect_count
;
5817 wined3d_mutex_lock();
5818 wined3d_device_context_get_scissor_rects(device
->immediate_context
.wined3d_context
, &actual_count
, rects
);
5819 wined3d_mutex_unlock();
5823 *rect_count
= actual_count
;
5827 if (*rect_count
> actual_count
)
5828 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
5831 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
5833 TRACE("iface %p.\n", iface
);
5835 /* In the current implementation the device is never removed, so we can
5836 * just return S_OK here. */
5841 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
5843 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
5848 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
5850 FIXME("iface %p stub!\n", iface
);
5855 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
5856 REFGUID guid
, UINT
*data_size
, void *data
)
5858 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5860 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5862 return d3d11_device_GetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5865 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
5866 REFGUID guid
, UINT data_size
, const void *data
)
5868 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5870 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5872 return d3d11_device_SetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5875 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
5876 REFGUID guid
, const IUnknown
*data
)
5878 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5880 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
5882 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device2_iface
, guid
, data
);
5885 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
5887 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5889 TRACE("iface %p.\n", iface
);
5891 d3d11_device_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
5894 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
5896 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5898 TRACE("iface %p.\n", iface
);
5900 wined3d_device_context_flush(device
->immediate_context
.wined3d_context
);
5903 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
5904 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
5906 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5907 D3D11_BUFFER_DESC d3d11_desc
;
5908 struct d3d_buffer
*object
;
5911 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
5913 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
5914 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5915 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5916 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5917 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5918 d3d11_desc
.StructureByteStride
= 0;
5920 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5923 *buffer
= &object
->ID3D10Buffer_iface
;
5928 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
5929 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
5931 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5932 D3D11_TEXTURE1D_DESC d3d11_desc
;
5933 struct d3d_texture1d
*object
;
5936 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5938 d3d11_desc
.Width
= desc
->Width
;
5939 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5940 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5941 d3d11_desc
.Format
= desc
->Format
;
5942 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5943 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5944 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5945 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5947 if (FAILED(hr
= d3d_texture1d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5950 *texture
= &object
->ID3D10Texture1D_iface
;
5955 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
5956 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5957 ID3D10Texture2D
**texture
)
5959 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5960 D3D11_TEXTURE2D_DESC d3d11_desc
;
5961 struct d3d_texture2d
*object
;
5964 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5966 d3d11_desc
.Width
= desc
->Width
;
5967 d3d11_desc
.Height
= desc
->Height
;
5968 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5969 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5970 d3d11_desc
.Format
= desc
->Format
;
5971 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
5972 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5973 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5974 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5975 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5977 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5980 *texture
= &object
->ID3D10Texture2D_iface
;
5985 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
5986 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5987 ID3D10Texture3D
**texture
)
5989 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5990 D3D11_TEXTURE3D_DESC d3d11_desc
;
5991 struct d3d_texture3d
*object
;
5994 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5996 d3d11_desc
.Width
= desc
->Width
;
5997 d3d11_desc
.Height
= desc
->Height
;
5998 d3d11_desc
.Depth
= desc
->Depth
;
5999 d3d11_desc
.MipLevels
= desc
->MipLevels
;
6000 d3d11_desc
.Format
= desc
->Format
;
6001 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
6002 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
6003 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
6004 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
6006 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
6009 *texture
= &object
->ID3D10Texture3D_iface
;
6014 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
6015 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
6017 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6018 struct d3d_shader_resource_view
*object
;
6019 ID3D11Resource
*d3d11_resource
;
6022 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6025 return E_INVALIDARG
;
6027 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6029 ERR("Resource does not implement ID3D11Resource.\n");
6033 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
6035 ID3D11Resource_Release(d3d11_resource
);
6039 *view
= &object
->ID3D10ShaderResourceView1_iface
;
6044 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
6045 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
6047 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6049 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
6050 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
6053 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
6054 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
6056 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6057 struct d3d_rendertarget_view
*object
;
6058 ID3D11Resource
*d3d11_resource
;
6061 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6066 return E_INVALIDARG
;
6068 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6070 ERR("Resource does not implement ID3D11Resource.\n");
6074 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
6075 ID3D11Resource_Release(d3d11_resource
);
6079 *view
= &object
->ID3D10RenderTargetView_iface
;
6084 static D3D11_DSV_DIMENSION
d3d11_dsv_dimension_from_d3d10(D3D10_DSV_DIMENSION dim
)
6086 return (D3D11_DSV_DIMENSION
)dim
;
6089 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
6090 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
6092 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6093 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
6094 struct d3d_depthstencil_view
*object
;
6095 ID3D11Resource
*d3d11_resource
;
6098 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6102 d3d11_desc
.Format
= desc
->Format
;
6103 d3d11_desc
.ViewDimension
= d3d11_dsv_dimension_from_d3d10(desc
->ViewDimension
);
6104 d3d11_desc
.Flags
= 0;
6105 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
6108 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6110 ERR("Resource does not implement ID3D11Resource.\n");
6114 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
6115 ID3D11Resource_Release(d3d11_resource
);
6119 *view
= &object
->ID3D10DepthStencilView_iface
;
6124 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
6125 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
6126 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
6127 ID3D10InputLayout
**input_layout
)
6129 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6130 struct d3d_input_layout
*object
;
6133 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
6134 "shader_byte_code_length %lu, input_layout %p\n",
6135 iface
, element_descs
, element_count
, shader_byte_code
,
6136 shader_byte_code_length
, input_layout
);
6138 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
6139 shader_byte_code
, shader_byte_code_length
, &object
)))
6142 *input_layout
= &object
->ID3D10InputLayout_iface
;
6147 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
6148 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
6150 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6151 struct d3d_vertex_shader
*object
;
6154 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
6155 iface
, byte_code
, byte_code_length
, shader
);
6157 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
6160 *shader
= &object
->ID3D10VertexShader_iface
;
6165 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
6166 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
6168 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6169 struct d3d_geometry_shader
*object
;
6172 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
6173 iface
, byte_code
, byte_code_length
, shader
);
6175 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
6176 NULL
, 0, NULL
, 0, 0, &object
)))
6179 *shader
= &object
->ID3D10GeometryShader_iface
;
6184 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
6185 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
6186 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
6188 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6189 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
6190 struct d3d_geometry_shader
*object
;
6191 unsigned int i
, stride_count
= 1;
6194 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
6195 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
6196 iface
, byte_code
, byte_code_length
, output_stream_decls
,
6197 output_stream_decl_count
, output_stream_stride
, shader
);
6199 if (!output_stream_decl_count
&& output_stream_stride
)
6201 WARN("Stride must be 0 when declaration entry count is 0.\n");
6203 return E_INVALIDARG
;
6206 if (output_stream_decl_count
6207 && !(so_entries
= heap_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
6209 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
6211 return E_OUTOFMEMORY
;
6214 for (i
= 0; i
< output_stream_decl_count
; ++i
)
6216 so_entries
[i
].Stream
= 0;
6217 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
6218 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
6219 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
6220 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
6221 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
6223 if (output_stream_decls
[i
].OutputSlot
)
6226 if (output_stream_stride
)
6228 WARN("Stride must be 0 when multiple output slots are used.\n");
6229 heap_free(so_entries
);
6231 return E_INVALIDARG
;
6236 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
6237 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
6238 heap_free(so_entries
);
6245 *shader
= &object
->ID3D10GeometryShader_iface
;
6250 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
6251 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
6253 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6254 struct d3d_pixel_shader
*object
;
6257 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
6258 iface
, byte_code
, byte_code_length
, shader
);
6260 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
6263 *shader
= &object
->ID3D10PixelShader_iface
;
6268 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
6269 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
6271 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6272 struct d3d_blend_state
*object
;
6275 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
6277 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
6280 *blend_state
= &object
->ID3D10BlendState1_iface
;
6285 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
6286 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
6288 D3D10_BLEND_DESC1 d3d10_1_desc
;
6291 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
6294 return E_INVALIDARG
;
6296 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
6297 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
6298 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
6300 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
6301 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
6302 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
6305 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
6307 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
6308 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
6309 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
6310 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
6311 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
6312 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
6313 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
6314 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
6317 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
6320 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
6321 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
6323 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6324 struct d3d_depthstencil_state
*object
;
6327 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
6329 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
6332 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
6337 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
6338 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
6340 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6341 struct d3d_rasterizer_state
*object
;
6342 D3D11_RASTERIZER_DESC1 desc1
;
6345 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
6348 return E_INVALIDARG
;
6350 memcpy(&desc1
, desc
, sizeof(*desc
));
6351 desc1
.ForcedSampleCount
= 0;
6353 if (FAILED(hr
= d3d_rasterizer_state_create(device
, &desc1
, &object
)))
6356 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
6361 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
6362 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
6364 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6365 struct d3d_sampler_state
*object
;
6368 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
6370 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
6373 *sampler_state
= &object
->ID3D10SamplerState_iface
;
6378 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
6379 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
6381 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6382 struct d3d_query
*object
;
6385 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
6387 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
6392 *query
= &object
->ID3D10Query_iface
;
6396 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6400 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
6401 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
6403 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6404 struct d3d_query
*object
;
6407 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
6409 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
6414 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
6418 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6422 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
6423 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
6425 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
6430 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
6431 DXGI_FORMAT format
, UINT
*format_support
)
6433 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6435 TRACE("iface %p, format %s, format_support %p.\n",
6436 iface
, debug_dxgi_format(format
), format_support
);
6438 return d3d11_device_CheckFormatSupport(&device
->ID3D11Device2_iface
, format
, format_support
);
6441 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
6442 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
6444 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6446 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
6447 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
6449 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device2_iface
, format
,
6450 sample_count
, quality_level_count
);
6453 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
6455 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
6458 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
6459 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
6460 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
6462 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
6463 "units %p, units_length %p, description %p, description_length %p stub!\n",
6464 iface
, desc
, type
, active_counters
, name
, name_length
,
6465 units
, units_length
, description
, description_length
);
6470 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
6472 FIXME("iface %p stub!\n", iface
);
6477 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
6478 HANDLE resource_handle
, REFIID guid
, void **resource
)
6480 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
6481 iface
, resource_handle
, debugstr_guid(guid
), resource
);
6486 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
6488 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
6491 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
6493 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
6496 static D3D10_FEATURE_LEVEL1
d3d10_feature_level1_from_d3d_feature_level(D3D_FEATURE_LEVEL level
)
6498 return (D3D10_FEATURE_LEVEL1
)level
;
6501 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
6503 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6505 TRACE("iface %p.\n", iface
);
6507 return d3d10_feature_level1_from_d3d_feature_level(device
->state
->feature_level
);
6510 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
6512 /* IUnknown methods */
6513 d3d10_device_QueryInterface
,
6514 d3d10_device_AddRef
,
6515 d3d10_device_Release
,
6516 /* ID3D10Device methods */
6517 d3d10_device_VSSetConstantBuffers
,
6518 d3d10_device_PSSetShaderResources
,
6519 d3d10_device_PSSetShader
,
6520 d3d10_device_PSSetSamplers
,
6521 d3d10_device_VSSetShader
,
6522 d3d10_device_DrawIndexed
,
6524 d3d10_device_PSSetConstantBuffers
,
6525 d3d10_device_IASetInputLayout
,
6526 d3d10_device_IASetVertexBuffers
,
6527 d3d10_device_IASetIndexBuffer
,
6528 d3d10_device_DrawIndexedInstanced
,
6529 d3d10_device_DrawInstanced
,
6530 d3d10_device_GSSetConstantBuffers
,
6531 d3d10_device_GSSetShader
,
6532 d3d10_device_IASetPrimitiveTopology
,
6533 d3d10_device_VSSetShaderResources
,
6534 d3d10_device_VSSetSamplers
,
6535 d3d10_device_SetPredication
,
6536 d3d10_device_GSSetShaderResources
,
6537 d3d10_device_GSSetSamplers
,
6538 d3d10_device_OMSetRenderTargets
,
6539 d3d10_device_OMSetBlendState
,
6540 d3d10_device_OMSetDepthStencilState
,
6541 d3d10_device_SOSetTargets
,
6542 d3d10_device_DrawAuto
,
6543 d3d10_device_RSSetState
,
6544 d3d10_device_RSSetViewports
,
6545 d3d10_device_RSSetScissorRects
,
6546 d3d10_device_CopySubresourceRegion
,
6547 d3d10_device_CopyResource
,
6548 d3d10_device_UpdateSubresource
,
6549 d3d10_device_ClearRenderTargetView
,
6550 d3d10_device_ClearDepthStencilView
,
6551 d3d10_device_GenerateMips
,
6552 d3d10_device_ResolveSubresource
,
6553 d3d10_device_VSGetConstantBuffers
,
6554 d3d10_device_PSGetShaderResources
,
6555 d3d10_device_PSGetShader
,
6556 d3d10_device_PSGetSamplers
,
6557 d3d10_device_VSGetShader
,
6558 d3d10_device_PSGetConstantBuffers
,
6559 d3d10_device_IAGetInputLayout
,
6560 d3d10_device_IAGetVertexBuffers
,
6561 d3d10_device_IAGetIndexBuffer
,
6562 d3d10_device_GSGetConstantBuffers
,
6563 d3d10_device_GSGetShader
,
6564 d3d10_device_IAGetPrimitiveTopology
,
6565 d3d10_device_VSGetShaderResources
,
6566 d3d10_device_VSGetSamplers
,
6567 d3d10_device_GetPredication
,
6568 d3d10_device_GSGetShaderResources
,
6569 d3d10_device_GSGetSamplers
,
6570 d3d10_device_OMGetRenderTargets
,
6571 d3d10_device_OMGetBlendState
,
6572 d3d10_device_OMGetDepthStencilState
,
6573 d3d10_device_SOGetTargets
,
6574 d3d10_device_RSGetState
,
6575 d3d10_device_RSGetViewports
,
6576 d3d10_device_RSGetScissorRects
,
6577 d3d10_device_GetDeviceRemovedReason
,
6578 d3d10_device_SetExceptionMode
,
6579 d3d10_device_GetExceptionMode
,
6580 d3d10_device_GetPrivateData
,
6581 d3d10_device_SetPrivateData
,
6582 d3d10_device_SetPrivateDataInterface
,
6583 d3d10_device_ClearState
,
6585 d3d10_device_CreateBuffer
,
6586 d3d10_device_CreateTexture1D
,
6587 d3d10_device_CreateTexture2D
,
6588 d3d10_device_CreateTexture3D
,
6589 d3d10_device_CreateShaderResourceView
,
6590 d3d10_device_CreateRenderTargetView
,
6591 d3d10_device_CreateDepthStencilView
,
6592 d3d10_device_CreateInputLayout
,
6593 d3d10_device_CreateVertexShader
,
6594 d3d10_device_CreateGeometryShader
,
6595 d3d10_device_CreateGeometryShaderWithStreamOutput
,
6596 d3d10_device_CreatePixelShader
,
6597 d3d10_device_CreateBlendState
,
6598 d3d10_device_CreateDepthStencilState
,
6599 d3d10_device_CreateRasterizerState
,
6600 d3d10_device_CreateSamplerState
,
6601 d3d10_device_CreateQuery
,
6602 d3d10_device_CreatePredicate
,
6603 d3d10_device_CreateCounter
,
6604 d3d10_device_CheckFormatSupport
,
6605 d3d10_device_CheckMultisampleQualityLevels
,
6606 d3d10_device_CheckCounterInfo
,
6607 d3d10_device_CheckCounter
,
6608 d3d10_device_GetCreationFlags
,
6609 d3d10_device_OpenSharedResource
,
6610 d3d10_device_SetTextFilterSize
,
6611 d3d10_device_GetTextFilterSize
,
6612 d3d10_device_CreateShaderResourceView1
,
6613 d3d10_device_CreateBlendState1
,
6614 d3d10_device_GetFeatureLevel
,
6617 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
6619 /* IUnknown methods */
6620 d3d_device_inner_QueryInterface
,
6621 d3d_device_inner_AddRef
,
6622 d3d_device_inner_Release
,
6625 /* ID3D10Multithread methods */
6627 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
6629 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
6632 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
6634 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6636 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
6638 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6641 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
6643 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6645 TRACE("iface %p.\n", iface
);
6647 return IUnknown_AddRef(device
->outer_unk
);
6650 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
6652 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6654 TRACE("iface %p.\n", iface
);
6656 return IUnknown_Release(device
->outer_unk
);
6659 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
6661 TRACE("iface %p.\n", iface
);
6663 wined3d_mutex_lock();
6666 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
6668 TRACE("iface %p.\n", iface
);
6670 wined3d_mutex_unlock();
6673 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL enable
)
6675 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
6680 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
6682 FIXME("iface %p stub!\n", iface
);
6687 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
6689 d3d10_multithread_QueryInterface
,
6690 d3d10_multithread_AddRef
,
6691 d3d10_multithread_Release
,
6692 d3d10_multithread_Enter
,
6693 d3d10_multithread_Leave
,
6694 d3d10_multithread_SetMultithreadProtected
,
6695 d3d10_multithread_GetMultithreadProtected
,
6698 /* IWineDXGIDeviceParent IUnknown methods */
6700 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
6702 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
6705 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
6706 REFIID iid
, void **out
)
6708 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6709 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6712 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
6714 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6715 return IUnknown_AddRef(device
->outer_unk
);
6718 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
6720 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6721 return IUnknown_Release(device
->outer_unk
);
6724 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
6725 IWineDXGIDeviceParent
*iface
)
6727 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6728 return &device
->device_parent
;
6731 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
6733 /* IUnknown methods */
6734 dxgi_device_parent_QueryInterface
,
6735 dxgi_device_parent_AddRef
,
6736 dxgi_device_parent_Release
,
6737 /* IWineDXGIDeviceParent methods */
6738 dxgi_device_parent_get_wined3d_device_parent
,
6741 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
6743 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
6746 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
6747 struct wined3d_device
*wined3d_device
)
6749 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6750 struct d3d_device_context_state
*state
;
6751 struct wined3d_state
*wined3d_state
;
6752 D3D_FEATURE_LEVEL feature_level
;
6754 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
6756 wined3d_device_incref(wined3d_device
);
6757 device
->wined3d_device
= wined3d_device
;
6758 device
->immediate_context
.wined3d_context
= wined3d_device_get_immediate_context(wined3d_device
);
6760 wined3d_state
= wined3d_device_get_state(device
->wined3d_device
);
6761 feature_level
= d3d_feature_level_from_wined3d(wined3d_state_get_feature_level(wined3d_state
));
6763 if (!(state
= heap_alloc_zero(sizeof(*state
))))
6765 ERR("Failed to create the initial device context state.\n");
6769 d3d_device_context_state_init(state
, device
, feature_level
,
6770 device
->d3d11_only
? &IID_ID3D11Device2
: &IID_ID3D10Device1
);
6772 device
->state
= state
;
6773 if (!d3d_device_context_state_add_entry(state
, device
, wined3d_state
))
6774 ERR("Failed to add entry for wined3d state %p, device %p.\n", wined3d_state
, device
);
6776 d3d_device_context_state_private_addref(state
);
6777 ID3DDeviceContextState_Release(&state
->ID3DDeviceContextState_iface
);
6780 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
6782 TRACE("device_parent %p.\n", device_parent
);
6785 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
6787 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
6790 static HRESULT CDECL
device_parent_texture_sub_resource_created(struct wined3d_device_parent
*device_parent
,
6791 enum wined3d_resource_type type
, struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
,
6792 void **parent
, const struct wined3d_parent_ops
**parent_ops
)
6794 TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
6795 device_parent
, type
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
6798 *parent_ops
= &d3d_null_wined3d_parent_ops
;
6803 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
6804 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
6805 struct wined3d_texture
**wined3d_texture
)
6807 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6808 struct d3d_texture2d
*texture
;
6809 ID3D11Texture2D
*texture_iface
;
6810 D3D11_TEXTURE2D_DESC desc
;
6813 TRACE("device_parent %p, container_parent %p, wined3d_desc %p, texture_flags %#x, wined3d_texture %p.\n",
6814 device_parent
, container_parent
, wined3d_desc
, texture_flags
, wined3d_texture
);
6816 desc
.Width
= wined3d_desc
->width
;
6817 desc
.Height
= wined3d_desc
->height
;
6820 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
6821 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
6822 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
6823 desc
.Usage
= D3D11_USAGE_DEFAULT
;
6824 desc
.BindFlags
= d3d11_bind_flags_from_wined3d(wined3d_desc
->bind_flags
);
6825 desc
.CPUAccessFlags
= 0;
6828 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
6830 desc
.MiscFlags
|= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
6831 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
6835 FIXME("Unhandled flags %#x.\n", texture_flags
);
6837 if (FAILED(hr
= d3d11_device_CreateTexture2D(&device
->ID3D11Device2_iface
,
6838 &desc
, NULL
, &texture_iface
)))
6840 WARN("Failed to create 2D texture, hr %#x.\n", hr
);
6844 texture
= impl_from_ID3D11Texture2D(texture_iface
);
6846 *wined3d_texture
= texture
->wined3d_texture
;
6847 wined3d_texture_incref(*wined3d_texture
);
6848 ID3D11Texture2D_Release(&texture
->ID3D11Texture2D_iface
);
6853 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
6855 device_parent_wined3d_device_created
,
6856 device_parent_mode_changed
,
6857 device_parent_activate
,
6858 device_parent_texture_sub_resource_created
,
6859 device_parent_create_swapchain_texture
,
6862 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6864 const D3D11_SAMPLER_DESC
*ka
= key
;
6865 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
6867 return memcmp(ka
, kb
, sizeof(*ka
));
6870 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6872 const D3D11_BLEND_DESC
*ka
= key
;
6873 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
6875 return memcmp(ka
, kb
, sizeof(*ka
));
6878 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6880 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
6881 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
6882 const struct d3d_depthstencil_state
, entry
)->desc
;
6884 return memcmp(ka
, kb
, sizeof(*ka
));
6887 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6889 const D3D11_RASTERIZER_DESC1
*ka
= key
;
6890 const D3D11_RASTERIZER_DESC1
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
6892 return memcmp(ka
, kb
, sizeof(*ka
));
6895 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
6897 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
6898 device
->ID3D11Device2_iface
.lpVtbl
= &d3d11_device_vtbl
;
6899 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
6900 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
6901 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
6902 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
6903 device
->refcount
= 1;
6904 /* COM aggregation always takes place */
6905 device
->outer_unk
= outer_unknown
;
6906 device
->d3d11_only
= FALSE
;
6907 device
->state
= NULL
;
6909 d3d11_device_context_init(&device
->immediate_context
, device
, D3D11_DEVICE_CONTEXT_IMMEDIATE
);
6910 ID3D11DeviceContext1_Release(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
6912 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
6913 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
6914 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
6915 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);