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
);
3383 return E_INVALIDARG
;
3385 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
3388 *view
= &object
->ID3D11ShaderResourceView_iface
;
3393 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device2
*iface
,
3394 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
3396 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3397 struct d3d11_unordered_access_view
*object
;
3400 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3404 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
3407 *view
= &object
->ID3D11UnorderedAccessView_iface
;
3412 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device2
*iface
,
3413 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
3415 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3416 struct d3d_rendertarget_view
*object
;
3419 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3424 return E_INVALIDARG
;
3426 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
3429 *view
= &object
->ID3D11RenderTargetView_iface
;
3434 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device2
*iface
,
3435 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
3437 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3438 struct d3d_depthstencil_view
*object
;
3441 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3445 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
3448 *view
= &object
->ID3D11DepthStencilView_iface
;
3453 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device2
*iface
,
3454 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
3455 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
3457 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3458 struct d3d_input_layout
*object
;
3461 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
3462 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
3463 shader_byte_code_length
, input_layout
);
3465 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
3466 shader_byte_code
, shader_byte_code_length
, &object
)))
3469 *input_layout
= &object
->ID3D11InputLayout_iface
;
3474 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device2
*iface
, const void *byte_code
,
3475 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
3477 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3478 struct d3d_vertex_shader
*object
;
3481 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3482 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3485 FIXME("Class linkage is not implemented yet.\n");
3487 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3490 *shader
= &object
->ID3D11VertexShader_iface
;
3495 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device2
*iface
, const void *byte_code
,
3496 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3498 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3499 struct d3d_geometry_shader
*object
;
3502 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3503 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3506 FIXME("Class linkage is not implemented yet.\n");
3508 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3509 NULL
, 0, NULL
, 0, 0, &object
)))
3512 *shader
= &object
->ID3D11GeometryShader_iface
;
3517 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2
*iface
,
3518 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
3519 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
3520 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3522 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3523 struct d3d_geometry_shader
*object
;
3526 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
3527 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
3528 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
3529 rasterizer_stream
, class_linkage
, shader
);
3532 FIXME("Class linkage is not implemented yet.\n");
3534 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3535 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
3541 *shader
= &object
->ID3D11GeometryShader_iface
;
3546 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device2
*iface
, const void *byte_code
,
3547 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
3549 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3550 struct d3d_pixel_shader
*object
;
3553 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3554 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3557 FIXME("Class linkage is not implemented yet.\n");
3559 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3562 *shader
= &object
->ID3D11PixelShader_iface
;
3567 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device2
*iface
, const void *byte_code
,
3568 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
3570 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3571 struct d3d11_hull_shader
*object
;
3574 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3575 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3578 FIXME("Class linkage is not implemented yet.\n");
3580 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3583 *shader
= &object
->ID3D11HullShader_iface
;
3588 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device2
*iface
, const void *byte_code
,
3589 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
3591 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3592 struct d3d11_domain_shader
*object
;
3595 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3596 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3599 FIXME("Class linkage is not implemented yet.\n");
3601 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3604 *shader
= &object
->ID3D11DomainShader_iface
;
3609 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device2
*iface
, const void *byte_code
,
3610 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
3612 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3613 struct d3d11_compute_shader
*object
;
3616 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3617 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3620 FIXME("Class linkage is not implemented yet.\n");
3622 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3625 *shader
= &object
->ID3D11ComputeShader_iface
;
3630 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device2
*iface
,
3631 ID3D11ClassLinkage
**class_linkage
)
3633 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3634 struct d3d11_class_linkage
*object
;
3637 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3639 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3642 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3647 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device2
*iface
,
3648 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3650 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3651 struct d3d_blend_state
*object
;
3654 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3656 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3659 *blend_state
= &object
->ID3D11BlendState_iface
;
3664 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device2
*iface
,
3665 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3667 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3668 struct d3d_depthstencil_state
*object
;
3671 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3673 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3676 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3681 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device2
*iface
,
3682 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3684 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3685 struct d3d_rasterizer_state
*object
;
3686 D3D11_RASTERIZER_DESC1 desc1
;
3689 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3692 return E_INVALIDARG
;
3694 memcpy(&desc1
, desc
, sizeof(*desc
));
3695 desc1
.ForcedSampleCount
= 0;
3697 if (FAILED(hr
= d3d_rasterizer_state_create(device
, &desc1
, &object
)))
3700 *rasterizer_state
= (ID3D11RasterizerState
*)&object
->ID3D11RasterizerState1_iface
;
3705 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device2
*iface
,
3706 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3708 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3709 struct d3d_sampler_state
*object
;
3712 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3714 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3717 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3722 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device2
*iface
,
3723 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3725 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3726 struct d3d_query
*object
;
3729 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3731 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3736 *query
= &object
->ID3D11Query_iface
;
3740 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3744 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device2
*iface
, const D3D11_QUERY_DESC
*desc
,
3745 ID3D11Predicate
**predicate
)
3747 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3748 struct d3d_query
*object
;
3751 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3753 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3758 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3762 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3766 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3767 ID3D11Counter
**counter
)
3769 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3774 static HRESULT
d3d11_deferred_context_create(struct d3d_device
*device
,
3775 UINT flags
, struct d3d11_device_context
**context
)
3777 struct d3d11_device_context
*object
;
3781 FIXME("Ignoring flags %#x.\n", flags
);
3783 if (!(object
= heap_alloc_zero(sizeof(*object
))))
3784 return E_OUTOFMEMORY
;
3785 d3d11_device_context_init(object
, device
, D3D11_DEVICE_CONTEXT_DEFERRED
);
3787 if (FAILED(hr
= wined3d_deferred_context_create(device
->wined3d_device
, &object
->wined3d_context
)))
3789 WARN("Failed to create wined3d deferred context, hr %#x.\n", hr
);
3794 TRACE("Created deferred context %p.\n", object
);
3800 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device2
*iface
, UINT flags
,
3801 ID3D11DeviceContext
**context
)
3803 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3804 struct d3d11_device_context
*object
;
3807 TRACE("iface %p, flags %#x, context %p.\n", iface
, flags
, context
);
3809 if (FAILED(hr
= d3d11_deferred_context_create(device
, flags
, &object
)))
3812 *context
= (ID3D11DeviceContext
*)&object
->ID3D11DeviceContext1_iface
;
3816 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device2
*iface
, HANDLE resource
, REFIID iid
,
3819 FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface
, resource
, debugstr_guid(iid
), out
);
3824 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device2
*iface
, DXGI_FORMAT format
,
3825 UINT
*format_support
)
3827 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3828 struct wined3d_device_creation_parameters params
;
3829 struct wined3d_adapter
*wined3d_adapter
;
3830 enum wined3d_format_id wined3d_format
;
3831 D3D_FEATURE_LEVEL feature_level
;
3832 struct wined3d
*wined3d
;
3837 enum wined3d_resource_type rtype
;
3838 unsigned int bind_flags
;
3840 D3D11_FORMAT_SUPPORT flag
;
3844 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_BUFFER
},
3845 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_VERTEX_BUFFER
, 0, D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER
},
3846 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_INDEX_BUFFER
, 0, D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
},
3847 {WINED3D_RTYPE_TEXTURE_1D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE1D
},
3848 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3849 {WINED3D_RTYPE_TEXTURE_3D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3850 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, 0, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3851 {WINED3D_RTYPE_NONE
, WINED3D_BIND_DEPTH_STENCIL
, 0, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3852 {WINED3D_RTYPE_NONE
, WINED3D_BIND_UNORDERED_ACCESS
, 0, D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW
},
3853 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_WRAPANDMIP
, D3D11_FORMAT_SUPPORT_MIP
},
3854 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_GENMIPMAP
, D3D11_FORMAT_SUPPORT_MIP_AUTOGEN
},
3855 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
, D3D11_FORMAT_SUPPORT_BLENDABLE
},
3859 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3861 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3862 if (format
&& !wined3d_format
)
3864 WARN("Invalid format %#x.\n", format
);
3865 *format_support
= 0;
3869 *format_support
= 0;
3871 wined3d_mutex_lock();
3872 feature_level
= device
->state
->feature_level
;
3873 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3874 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3875 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3876 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3878 hr
= wined3d_check_device_format(wined3d
, wined3d_adapter
, params
.device_type
,
3879 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].bind_flags
, flag_mapping
[i
].rtype
, wined3d_format
);
3880 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOMIPGEN
)
3882 if (hr
!= WINED3D_OK
)
3884 WARN("Failed to check device format support, hr %#x.\n", hr
);
3885 wined3d_mutex_unlock();
3889 *format_support
|= flag_mapping
[i
].flag
;
3891 wined3d_mutex_unlock();
3893 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
3894 *format_support
&= ~D3D11_FORMAT_SUPPORT_BUFFER
;
3896 if (*format_support
& (D3D11_FORMAT_SUPPORT_TEXTURE1D
3897 | D3D11_FORMAT_SUPPORT_TEXTURE2D
| D3D11_FORMAT_SUPPORT_TEXTURE3D
))
3899 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_LOAD
;
3900 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
;
3901 *format_support
|= D3D11_FORMAT_SUPPORT_TEXTURECUBE
;
3903 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3904 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER
;
3906 if (*format_support
& D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
)
3908 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
3909 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
;
3911 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3912 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
;
3916 /* d3d11 requires 4 and 8 sample counts support for formats reported to
3917 * support multisample. */
3918 if (wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3919 TRUE
, WINED3D_MULTISAMPLE_4_SAMPLES
, NULL
) == WINED3D_OK
&&
3920 wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3921 TRUE
, WINED3D_MULTISAMPLE_8_SAMPLES
, NULL
) == WINED3D_OK
)
3923 *format_support
|= D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE
3924 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
3925 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
;
3931 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2
*iface
,
3932 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3934 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3935 struct wined3d_device_creation_parameters params
;
3936 struct wined3d_adapter
*wined3d_adapter
;
3937 struct wined3d
*wined3d
;
3940 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3941 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3943 if (!quality_level_count
)
3944 return E_INVALIDARG
;
3946 *quality_level_count
= 0;
3950 if (sample_count
== 1)
3952 *quality_level_count
= 1;
3955 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3958 wined3d_mutex_lock();
3959 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3960 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3961 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3962 hr
= wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
,
3963 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3964 wined3d_mutex_unlock();
3966 if (hr
== WINED3DERR_INVALIDCALL
)
3967 return E_INVALIDARG
;
3968 if (hr
== WINED3DERR_NOTAVAILABLE
)
3973 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device2
*iface
, D3D11_COUNTER_INFO
*info
)
3975 FIXME("iface %p, info %p stub!\n", iface
, info
);
3978 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3979 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3980 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3982 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3983 "units %p, units_length %p, description %p, description_length %p stub!\n",
3984 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3985 units
, units_length
, description
, description_length
);
3990 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device2
*iface
, D3D11_FEATURE feature
,
3991 void *feature_support_data
, UINT feature_support_data_size
)
3993 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3994 struct wined3d_caps wined3d_caps
;
3997 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3998 iface
, feature
, feature_support_data
, feature_support_data_size
);
4002 case D3D11_FEATURE_THREADING
:
4004 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
4005 if (feature_support_data_size
!= sizeof(*threading_data
))
4007 WARN("Invalid data size.\n");
4008 return E_INVALIDARG
;
4011 /* We lie about the threading support to make Tomb Raider 2013 and
4012 * Deus Ex: Human Revolution happy. */
4013 FIXME("Returning fake threading support data.\n");
4014 threading_data
->DriverConcurrentCreates
= TRUE
;
4015 threading_data
->DriverCommandLists
= TRUE
;
4019 case D3D11_FEATURE_DOUBLES
:
4021 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
4022 if (feature_support_data_size
!= sizeof(*doubles_data
))
4024 WARN("Invalid data size.\n");
4025 return E_INVALIDARG
;
4028 wined3d_mutex_lock();
4029 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4030 wined3d_mutex_unlock();
4033 WARN("Failed to get device caps, hr %#x.\n", hr
);
4037 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
4041 case D3D11_FEATURE_D3D9_OPTIONS
:
4043 D3D11_FEATURE_DATA_D3D9_OPTIONS
*options
= feature_support_data
;
4044 if (feature_support_data_size
!= sizeof(*options
))
4046 WARN("Invalid data size.\n");
4047 return E_INVALIDARG
;
4050 wined3d_mutex_lock();
4051 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4052 wined3d_mutex_unlock();
4055 WARN("Failed to get device caps, hr %#x.\n", hr
);
4059 options
->FullNonPow2TextureSupport
= !(wined3d_caps
.TextureCaps
& WINED3DPTEXTURECAPS_POW2
);
4063 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
4065 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
4066 if (feature_support_data_size
!= sizeof(*options
))
4068 WARN("Invalid data size.\n");
4069 return E_INVALIDARG
;
4072 wined3d_mutex_lock();
4073 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4074 wined3d_mutex_unlock();
4077 WARN("Failed to get device caps, hr %#x.\n", hr
);
4081 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
4082 = wined3d_caps
.max_feature_level
>= WINED3D_FEATURE_LEVEL_11
;
4086 case D3D11_FEATURE_D3D11_OPTIONS
:
4088 D3D11_FEATURE_DATA_D3D11_OPTIONS
*options
= feature_support_data
;
4089 if (feature_support_data_size
!= sizeof(*options
))
4091 WARN("Invalid data size.\n");
4092 return E_INVALIDARG
;
4095 FIXME("Returning fake Options support data.\n");
4096 options
->OutputMergerLogicOp
= FALSE
;
4097 options
->UAVOnlyRenderingForcedSampleCount
= FALSE
;
4098 options
->DiscardAPIsSeenByDriver
= FALSE
;
4099 options
->FlagsForUpdateAndCopySeenByDriver
= FALSE
;
4100 options
->ClearView
= FALSE
;
4101 options
->CopyWithOverlap
= FALSE
;
4102 options
->ConstantBufferPartialUpdate
= FALSE
;
4103 options
->ConstantBufferOffsetting
= TRUE
;
4104 options
->MapNoOverwriteOnDynamicConstantBuffer
= FALSE
;
4105 options
->MapNoOverwriteOnDynamicBufferSRV
= FALSE
;
4106 options
->MultisampleRTVWithForcedSampleCountOne
= FALSE
;
4107 options
->SAD4ShaderInstructions
= FALSE
;
4108 options
->ExtendedDoublesShaderInstructions
= FALSE
;
4109 options
->ExtendedResourceSharing
= FALSE
;
4113 case D3D11_FEATURE_D3D11_OPTIONS1
:
4115 D3D11_FEATURE_DATA_D3D11_OPTIONS1
*options
= feature_support_data
;
4116 if (feature_support_data_size
!= sizeof(*options
))
4118 WARN("Invalid data size.\n");
4119 return E_INVALIDARG
;
4122 FIXME("Returning fake Options1 support data.\n");
4123 options
->TiledResourcesTier
= D3D11_TILED_RESOURCES_NOT_SUPPORTED
;
4124 options
->MinMaxFiltering
= FALSE
;
4125 options
->ClearViewAlsoSupportsDepthOnlyFormats
= FALSE
;
4126 options
->MapOnDefaultBuffers
= FALSE
;
4130 case D3D11_FEATURE_D3D11_OPTIONS3
:
4132 D3D11_FEATURE_DATA_D3D11_OPTIONS3
*options
= feature_support_data
;
4133 if (feature_support_data_size
!= sizeof(*options
))
4135 WARN("Invalid data size.\n");
4136 return E_INVALIDARG
;
4139 wined3d_mutex_lock();
4140 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
4141 wined3d_mutex_unlock();
4144 WARN("Failed to get device caps, hr %#x.\n", hr
);
4148 options
->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
4149 = wined3d_caps
.viewport_array_index_any_shader
;
4153 case D3D11_FEATURE_ARCHITECTURE_INFO
:
4155 D3D11_FEATURE_DATA_ARCHITECTURE_INFO
*options
= feature_support_data
;
4156 if (feature_support_data_size
!= sizeof(*options
))
4158 WARN("Invalid data size.\n");
4159 return E_INVALIDARG
;
4162 FIXME("Returning fake data architecture info.\n");
4163 options
->TileBasedDeferredRenderer
= FALSE
;
4168 FIXME("Unhandled feature %#x.\n", feature
);
4173 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
4174 UINT
*data_size
, void *data
)
4176 IDXGIDevice
*dxgi_device
;
4179 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4181 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4183 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
4184 IDXGIDevice_Release(dxgi_device
);
4189 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
4190 UINT data_size
, const void *data
)
4192 IDXGIDevice
*dxgi_device
;
4195 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4197 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4199 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
4200 IDXGIDevice_Release(dxgi_device
);
4205 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device2
*iface
, REFGUID guid
,
4206 const IUnknown
*data
)
4208 IDXGIDevice
*dxgi_device
;
4211 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4213 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
4215 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
4216 IDXGIDevice_Release(dxgi_device
);
4221 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device2
*iface
)
4223 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4225 TRACE("iface %p.\n", iface
);
4227 return device
->state
->feature_level
;
4230 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device2
*iface
)
4232 FIXME("iface %p stub!\n", iface
);
4237 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device2
*iface
)
4239 WARN("iface %p stub!\n", iface
);
4244 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device2
*iface
,
4245 ID3D11DeviceContext
**immediate_context
)
4247 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4249 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
4251 *immediate_context
= (ID3D11DeviceContext
*)&device
->immediate_context
.ID3D11DeviceContext1_iface
;
4252 ID3D11DeviceContext_AddRef(*immediate_context
);
4255 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device2
*iface
, UINT flags
)
4257 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4262 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device2
*iface
)
4264 FIXME("iface %p stub!\n", iface
);
4269 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext1(ID3D11Device2
*iface
,
4270 ID3D11DeviceContext1
**immediate_context
)
4272 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4274 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
4276 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext1_iface
;
4277 ID3D11DeviceContext1_AddRef(*immediate_context
);
4280 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext1(ID3D11Device2
*iface
, UINT flags
,
4281 ID3D11DeviceContext1
**context
)
4283 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4284 struct d3d11_device_context
*object
;
4287 TRACE("iface %p, flags %#x, context %p.\n", iface
, flags
, context
);
4289 if (FAILED(hr
= d3d11_deferred_context_create(device
, flags
, &object
)))
4292 *context
= &object
->ID3D11DeviceContext1_iface
;
4296 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState1(ID3D11Device2
*iface
,
4297 const D3D11_BLEND_DESC1
*desc
, ID3D11BlendState1
**state
)
4299 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
4304 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState1(ID3D11Device2
*iface
,
4305 const D3D11_RASTERIZER_DESC1
*desc
, ID3D11RasterizerState1
**state
)
4307 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4308 struct d3d_rasterizer_state
*object
;
4311 TRACE("iface %p, desc %p, state %p.\n", iface
, desc
, state
);
4314 return E_INVALIDARG
;
4316 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
4319 *state
= &object
->ID3D11RasterizerState1_iface
;
4324 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeviceContextState(ID3D11Device2
*iface
, UINT flags
,
4325 const D3D_FEATURE_LEVEL
*feature_levels
, UINT feature_level_count
, UINT sdk_version
,
4326 REFIID emulated_interface
, D3D_FEATURE_LEVEL
*chosen_feature_level
, ID3DDeviceContextState
**state
)
4328 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4329 struct d3d_device_context_state
*state_impl
;
4330 struct wined3d_state
*wined3d_state
;
4331 D3D_FEATURE_LEVEL feature_level
;
4332 HRESULT hr
= E_INVALIDARG
;
4334 TRACE("iface %p, flags %#x, feature_levels %p, feature_level_count %u, "
4335 "sdk_version %u, emulated_interface %s, chosen_feature_level %p, state %p.\n",
4336 iface
, flags
, feature_levels
, feature_level_count
,
4337 sdk_version
, debugstr_guid(emulated_interface
), chosen_feature_level
, state
);
4340 FIXME("Ignoring flags %#x.\n", flags
);
4342 wined3d_mutex_lock();
4344 if (!feature_level_count
)
4347 if (FAILED(hr
= wined3d_state_create(device
->wined3d_device
,
4348 (const enum wined3d_feature_level
*)feature_levels
, feature_level_count
, &wined3d_state
)))
4350 feature_level
= d3d_feature_level_from_wined3d(wined3d_state_get_feature_level(wined3d_state
));
4352 if (chosen_feature_level
)
4353 *chosen_feature_level
= feature_level
;
4357 wined3d_state_destroy(wined3d_state
);
4358 wined3d_mutex_unlock();
4362 if (!(state_impl
= heap_alloc_zero(sizeof(*state_impl
))))
4364 wined3d_state_destroy(wined3d_state
);
4369 d3d_device_context_state_init(state_impl
, device
, feature_level
, emulated_interface
);
4370 if (!d3d_device_context_state_add_entry(state_impl
, device
, wined3d_state
))
4372 wined3d_state_destroy(wined3d_state
);
4373 ID3DDeviceContextState_Release(&state_impl
->ID3DDeviceContextState_iface
);
4378 *state
= &state_impl
->ID3DDeviceContextState_iface
;
4379 device
->d3d11_only
= FALSE
;
4380 wined3d_mutex_unlock();
4385 wined3d_mutex_unlock();
4386 if (chosen_feature_level
)
4387 *chosen_feature_level
= 0;
4393 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource1(ID3D11Device2
*iface
, HANDLE handle
,
4394 REFIID iid
, void **resource
)
4396 FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface
, handle
, debugstr_guid(iid
), resource
);
4401 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResourceByName(ID3D11Device2
*iface
, const WCHAR
*name
,
4402 DWORD access
, REFIID iid
, void **resource
)
4404 FIXME("iface %p, name %s, access %#x, iid %s, resource %p stub!\n", iface
, debugstr_w(name
), access
,
4405 debugstr_guid(iid
), resource
);
4410 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext2(ID3D11Device2
*iface
,
4411 ID3D11DeviceContext2
**context
)
4413 FIXME("iface %p, context %p stub!\n", iface
, context
);
4416 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext2(ID3D11Device2
*iface
,
4417 UINT flags
, ID3D11DeviceContext2
**context
)
4419 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
4424 static void STDMETHODCALLTYPE
d3d11_device_GetResourceTiling(ID3D11Device2
*iface
,
4425 ID3D11Resource
*resource
, UINT
*tile_count
, D3D11_PACKED_MIP_DESC
*mip_desc
,
4426 D3D11_TILE_SHAPE
*tile_shape
, UINT
*subresource_tiling_count
, UINT first_subresource_tiling
,
4427 D3D11_SUBRESOURCE_TILING
*subresource_tiling
)
4429 FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, "
4430 "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n",
4431 iface
, resource
, tile_count
, mip_desc
, tile_shape
,
4432 subresource_tiling_count
, first_subresource_tiling
, subresource_tiling
);
4435 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2
*iface
,
4436 DXGI_FORMAT format
, UINT sample_count
, UINT flags
, UINT
*quality_level_count
)
4438 FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n",
4439 iface
, format
, sample_count
, flags
, quality_level_count
);
4444 static const struct ID3D11Device2Vtbl d3d11_device_vtbl
=
4446 /* IUnknown methods */
4447 d3d11_device_QueryInterface
,
4448 d3d11_device_AddRef
,
4449 d3d11_device_Release
,
4450 /* ID3D11Device methods */
4451 d3d11_device_CreateBuffer
,
4452 d3d11_device_CreateTexture1D
,
4453 d3d11_device_CreateTexture2D
,
4454 d3d11_device_CreateTexture3D
,
4455 d3d11_device_CreateShaderResourceView
,
4456 d3d11_device_CreateUnorderedAccessView
,
4457 d3d11_device_CreateRenderTargetView
,
4458 d3d11_device_CreateDepthStencilView
,
4459 d3d11_device_CreateInputLayout
,
4460 d3d11_device_CreateVertexShader
,
4461 d3d11_device_CreateGeometryShader
,
4462 d3d11_device_CreateGeometryShaderWithStreamOutput
,
4463 d3d11_device_CreatePixelShader
,
4464 d3d11_device_CreateHullShader
,
4465 d3d11_device_CreateDomainShader
,
4466 d3d11_device_CreateComputeShader
,
4467 d3d11_device_CreateClassLinkage
,
4468 d3d11_device_CreateBlendState
,
4469 d3d11_device_CreateDepthStencilState
,
4470 d3d11_device_CreateRasterizerState
,
4471 d3d11_device_CreateSamplerState
,
4472 d3d11_device_CreateQuery
,
4473 d3d11_device_CreatePredicate
,
4474 d3d11_device_CreateCounter
,
4475 d3d11_device_CreateDeferredContext
,
4476 d3d11_device_OpenSharedResource
,
4477 d3d11_device_CheckFormatSupport
,
4478 d3d11_device_CheckMultisampleQualityLevels
,
4479 d3d11_device_CheckCounterInfo
,
4480 d3d11_device_CheckCounter
,
4481 d3d11_device_CheckFeatureSupport
,
4482 d3d11_device_GetPrivateData
,
4483 d3d11_device_SetPrivateData
,
4484 d3d11_device_SetPrivateDataInterface
,
4485 d3d11_device_GetFeatureLevel
,
4486 d3d11_device_GetCreationFlags
,
4487 d3d11_device_GetDeviceRemovedReason
,
4488 d3d11_device_GetImmediateContext
,
4489 d3d11_device_SetExceptionMode
,
4490 d3d11_device_GetExceptionMode
,
4491 /* ID3D11Device1 methods */
4492 d3d11_device_GetImmediateContext1
,
4493 d3d11_device_CreateDeferredContext1
,
4494 d3d11_device_CreateBlendState1
,
4495 d3d11_device_CreateRasterizerState1
,
4496 d3d11_device_CreateDeviceContextState
,
4497 d3d11_device_OpenSharedResource1
,
4498 d3d11_device_OpenSharedResourceByName
,
4499 /* ID3D11Device2 methods */
4500 d3d11_device_GetImmediateContext2
,
4501 d3d11_device_CreateDeferredContext2
,
4502 d3d11_device_GetResourceTiling
,
4503 d3d11_device_CheckMultisampleQualityLevels1
,
4506 /* Inner IUnknown methods */
4508 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
4510 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
4513 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
4515 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4517 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
4519 if (IsEqualGUID(riid
, &IID_ID3D11Device2
)
4520 || IsEqualGUID(riid
, &IID_ID3D11Device1
)
4521 || IsEqualGUID(riid
, &IID_ID3D11Device
)
4522 || IsEqualGUID(riid
, &IID_IUnknown
))
4524 *out
= &device
->ID3D11Device2_iface
;
4526 else if (!device
->d3d11_only
4527 && (IsEqualGUID(riid
, &IID_ID3D10Device1
)
4528 || IsEqualGUID(riid
, &IID_ID3D10Device
)))
4530 *out
= &device
->ID3D10Device1_iface
;
4532 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
4534 *out
= &device
->ID3D10Multithread_iface
;
4536 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
4538 *out
= &device
->IWineDXGIDeviceParent_iface
;
4542 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
4544 return E_NOINTERFACE
;
4547 IUnknown_AddRef((IUnknown
*)*out
);
4551 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
4553 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4554 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
4556 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
4561 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
4563 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4564 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
4567 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
4572 d3d_device_context_state_private_release(device
->state
);
4573 for (i
= 0; i
< device
->context_state_count
; ++i
)
4575 d3d_device_context_state_remove_entry(device
->context_states
[i
], device
);
4577 heap_free(device
->context_states
);
4578 d3d11_device_context_cleanup(&device
->immediate_context
);
4579 if (device
->wined3d_device
)
4581 wined3d_device_decref(device
->wined3d_device
);
4583 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
4584 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
4585 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4586 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4592 /* IUnknown methods */
4594 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID iid
,
4597 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4598 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4601 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
4603 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4604 return IUnknown_AddRef(device
->outer_unk
);
4607 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
4609 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4610 return IUnknown_Release(device
->outer_unk
);
4613 /* ID3D10Device methods */
4615 static void d3d10_device_get_constant_buffers(ID3D10Device1
*iface
,
4616 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4618 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4621 wined3d_mutex_lock();
4622 for (i
= 0; i
< buffer_count
; ++i
)
4624 struct wined3d_constant_buffer_state state
;
4625 struct d3d_buffer
*buffer_impl
;
4627 wined3d_device_context_get_constant_buffer(device
->immediate_context
.wined3d_context
,
4628 type
, start_slot
+ i
, &state
);
4636 buffer_impl
= wined3d_buffer_get_parent(state
.buffer
);
4637 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4638 ID3D10Buffer_AddRef(buffers
[i
]);
4640 wined3d_mutex_unlock();
4643 static void d3d10_device_set_constant_buffers(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4644 unsigned int start_slot
, unsigned int buffer_count
, ID3D10Buffer
*const *buffers
)
4646 struct wined3d_constant_buffer_state wined3d_buffers
[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
4647 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4650 if (buffer_count
> ARRAY_SIZE(wined3d_buffers
))
4652 WARN("Buffer count %u exceeds limit; ignoring call.\n", buffer_count
);
4656 for (i
= 0; i
< buffer_count
; ++i
)
4658 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4660 wined3d_buffers
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
4661 wined3d_buffers
[i
].offset
= 0;
4662 wined3d_buffers
[i
].size
= WINED3D_MAX_CONSTANT_BUFFER_SIZE
* sizeof(struct wined3d_vec4
);
4665 wined3d_device_context_set_constant_buffers(device
->immediate_context
.wined3d_context
,
4666 type
, start_slot
, buffer_count
, wined3d_buffers
);
4669 static void d3d10_device_set_shader_resource_views(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4670 unsigned int start_slot
, unsigned int count
, ID3D10ShaderResourceView
*const *views
)
4672 struct wined3d_shader_resource_view
*wined3d_views
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
4673 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4676 if (count
> ARRAY_SIZE(wined3d_views
))
4678 WARN("View count %u exceeds limit; ignoring call.\n", count
);
4682 for (i
= 0; i
< count
; ++i
)
4684 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4686 wined3d_views
[i
] = view
? view
->wined3d_view
: NULL
;
4689 wined3d_device_context_set_shader_resource_views(device
->immediate_context
.wined3d_context
,
4690 type
, start_slot
, count
, wined3d_views
);
4693 static void d3d10_device_set_samplers(ID3D10Device1
*iface
, enum wined3d_shader_type type
,
4694 unsigned int start_slot
, unsigned int count
, ID3D10SamplerState
*const *samplers
)
4696 struct wined3d_sampler
*wined3d_samplers
[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
];
4697 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4700 if (count
> ARRAY_SIZE(wined3d_samplers
))
4702 WARN("Sampler count %u exceeds limit; ignoring call.\n", count
);
4706 for (i
= 0; i
< count
; ++i
)
4708 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4710 wined3d_samplers
[i
] = sampler
? sampler
->wined3d_sampler
: NULL
;
4713 wined3d_device_context_set_samplers(device
->immediate_context
.wined3d_context
,
4714 type
, start_slot
, count
, wined3d_samplers
);
4717 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
4718 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4720 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4721 iface
, start_slot
, buffer_count
, buffers
);
4723 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
4724 buffer_count
, buffers
);
4727 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
4728 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4730 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4731 iface
, start_slot
, view_count
, views
);
4733 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, view_count
, views
);
4736 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
4737 ID3D10PixelShader
*shader
)
4739 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4740 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
4742 TRACE("iface %p, shader %p\n", iface
, shader
);
4744 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4745 WINED3D_SHADER_TYPE_PIXEL
, ps
? ps
->wined3d_shader
: NULL
);
4748 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
4749 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4751 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4752 iface
, start_slot
, sampler_count
, samplers
);
4754 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, sampler_count
, samplers
);
4757 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
4758 ID3D10VertexShader
*shader
)
4760 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4761 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
4763 TRACE("iface %p, shader %p\n", iface
, shader
);
4765 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4766 WINED3D_SHADER_TYPE_VERTEX
, vs
? vs
->wined3d_shader
: NULL
);
4769 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
4770 UINT start_index_location
, INT base_vertex_location
)
4772 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4774 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
4775 iface
, index_count
, start_index_location
, base_vertex_location
);
4777 wined3d_device_context_draw_indexed(device
->immediate_context
.wined3d_context
,
4778 base_vertex_location
, start_index_location
, index_count
, 0, 0);
4781 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
4782 UINT start_vertex_location
)
4784 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4786 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
4787 iface
, vertex_count
, start_vertex_location
);
4789 wined3d_device_context_draw(device
->immediate_context
.wined3d_context
, start_vertex_location
, vertex_count
, 0, 0);
4792 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
4793 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4795 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4796 iface
, start_slot
, buffer_count
, buffers
);
4798 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
4799 buffer_count
, buffers
);
4802 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
4803 ID3D10InputLayout
*input_layout
)
4805 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4806 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
4808 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
4810 wined3d_device_context_set_vertex_declaration(device
->immediate_context
.wined3d_context
,
4811 layout
? layout
->wined3d_decl
: NULL
);
4814 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
4815 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
4817 struct wined3d_stream_state streams
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
4818 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4821 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
4822 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4824 if (buffer_count
> ARRAY_SIZE(streams
))
4826 WARN("Buffer count %u exceeds limit.\n", buffer_count
);
4827 buffer_count
= ARRAY_SIZE(streams
);
4830 for (i
= 0; i
< buffer_count
; ++i
)
4832 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4834 streams
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
4835 streams
[i
].offset
= offsets
[i
];
4836 streams
[i
].stride
= strides
[i
];
4837 streams
[i
].frequency
= 1;
4838 streams
[i
].flags
= 0;
4841 wined3d_device_context_set_stream_sources(device
->immediate_context
.wined3d_context
,
4842 start_slot
, buffer_count
, streams
);
4845 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
4846 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
4848 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4849 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
4851 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
4852 iface
, buffer
, debug_dxgi_format(format
), offset
);
4854 wined3d_device_context_set_index_buffer(device
->immediate_context
.wined3d_context
,
4855 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
4856 wined3dformat_from_dxgi_format(format
), offset
);
4859 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
4860 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
4861 INT base_vertex_location
, UINT start_instance_location
)
4863 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4865 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
4866 "base_vertex_location %d, start_instance_location %u.\n",
4867 iface
, instance_index_count
, instance_count
, start_index_location
,
4868 base_vertex_location
, start_instance_location
);
4870 wined3d_device_context_draw_indexed(device
->immediate_context
.wined3d_context
, base_vertex_location
,
4871 start_index_location
, instance_index_count
, start_instance_location
, instance_count
);
4874 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
4875 UINT instance_vertex_count
, UINT instance_count
,
4876 UINT start_vertex_location
, UINT start_instance_location
)
4878 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4880 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
4881 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
4882 start_vertex_location
, start_instance_location
);
4884 wined3d_device_context_draw(device
->immediate_context
.wined3d_context
, start_vertex_location
,
4885 instance_vertex_count
, start_instance_location
, instance_count
);
4888 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
4889 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4891 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4892 iface
, start_slot
, buffer_count
, buffers
);
4894 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
4895 buffer_count
, buffers
);
4898 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
4900 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4901 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
4903 TRACE("iface %p, shader %p.\n", iface
, shader
);
4905 wined3d_device_context_set_shader(device
->immediate_context
.wined3d_context
,
4906 WINED3D_SHADER_TYPE_GEOMETRY
, gs
? gs
->wined3d_shader
: NULL
);
4909 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
4910 D3D10_PRIMITIVE_TOPOLOGY topology
)
4912 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4914 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
4916 wined3d_device_context_set_primitive_type(device
->immediate_context
.wined3d_context
,
4917 (enum wined3d_primitive_type
)topology
, 0);
4920 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
4921 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4923 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4924 iface
, start_slot
, view_count
, views
);
4926 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, view_count
, views
);
4929 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
4930 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4932 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4933 iface
, start_slot
, sampler_count
, samplers
);
4935 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, sampler_count
, samplers
);
4938 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
4940 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4941 struct d3d_query
*query
;
4943 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
4945 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
4946 wined3d_device_context_set_predication(device
->immediate_context
.wined3d_context
,
4947 query
? query
->wined3d_query
: NULL
, value
);
4950 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
4951 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4953 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4954 iface
, start_slot
, view_count
, views
);
4956 d3d10_device_set_shader_resource_views(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, view_count
, views
);
4959 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
4960 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4962 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4963 iface
, start_slot
, sampler_count
, samplers
);
4965 d3d10_device_set_samplers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, sampler_count
, samplers
);
4968 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
4969 UINT rtv_count
, ID3D10RenderTargetView
*const *rtvs
, ID3D10DepthStencilView
*depth_stencil_view
)
4971 struct wined3d_rendertarget_view
*wined3d_rtvs
[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
] = {0};
4972 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4973 struct d3d_depthstencil_view
*dsv
;
4976 TRACE("iface %p, rtv_count %u, rtvs %p, depth_stencil_view %p.\n", iface
, rtv_count
, rtvs
, depth_stencil_view
);
4978 if (rtv_count
> ARRAY_SIZE(wined3d_rtvs
))
4980 WARN("View count %u exceeds limit.\n", rtv_count
);
4981 rtv_count
= ARRAY_SIZE(wined3d_rtvs
);
4984 for (i
= 0; i
< rtv_count
; ++i
)
4986 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(rtvs
[i
]);
4988 wined3d_rtvs
[i
] = rtv
? rtv
->wined3d_view
: NULL
;
4991 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4993 wined3d_device_context_set_render_targets_and_unordered_access_views(device
->immediate_context
.wined3d_context
,
4994 ARRAY_SIZE(wined3d_rtvs
), wined3d_rtvs
, dsv
? dsv
->wined3d_view
: NULL
, ~0u, NULL
, NULL
);
4997 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
4998 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
5000 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5001 struct d3d_blend_state
*blend_state_object
;
5003 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
5004 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
5006 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
5007 d3d11_device_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5008 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
5011 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
5012 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
5014 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5015 struct d3d_depthstencil_state
*ds_state_object
;
5017 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
5018 iface
, depth_stencil_state
, stencil_ref
);
5020 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
5021 d3d11_device_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5022 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
5025 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
5026 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
5028 struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
] = {0};
5029 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5030 unsigned int count
, i
;
5032 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
5034 count
= min(target_count
, ARRAY_SIZE(outputs
));
5035 for (i
= 0; i
< count
; ++i
)
5037 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
5039 outputs
[i
].buffer
= buffer
? buffer
->wined3d_buffer
: NULL
;
5040 outputs
[i
].offset
= offsets
? offsets
[i
] : 0;
5043 wined3d_device_context_set_stream_outputs(device
->immediate_context
.wined3d_context
, outputs
);
5046 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
5048 FIXME("iface %p stub!\n", iface
);
5051 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
5053 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5054 struct d3d_rasterizer_state
*rasterizer_state_object
;
5056 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5058 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
5059 d3d11_device_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5060 rasterizer_state_object
? (ID3D11RasterizerState
*)&rasterizer_state_object
->ID3D11RasterizerState1_iface
: NULL
);
5063 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
5064 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
5066 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5067 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5070 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
5072 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
5075 for (i
= 0; i
< viewport_count
; ++i
)
5077 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
5078 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
5079 wined3d_vp
[i
].width
= viewports
[i
].Width
;
5080 wined3d_vp
[i
].height
= viewports
[i
].Height
;
5081 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
5082 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
5085 wined3d_device_context_set_viewports(device
->immediate_context
.wined3d_context
, viewport_count
, wined3d_vp
);
5088 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
5089 UINT rect_count
, const D3D10_RECT
*rects
)
5091 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5093 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
5095 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
5098 wined3d_device_context_set_scissor_rects(device
->immediate_context
.wined3d_context
, rect_count
, rects
);
5101 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
5102 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
5103 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
5105 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5106 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5107 struct wined3d_box wined3d_src_box
;
5109 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
5110 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
5111 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
5112 src_resource
, src_subresource_idx
, src_box
);
5114 if (!dst_resource
|| !src_resource
)
5118 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
5119 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
5121 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5122 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5123 wined3d_device_context_copy_sub_resource_region(device
->immediate_context
.wined3d_context
,
5124 wined3d_dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
5125 wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
5128 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
5129 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
5131 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5132 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5134 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
5136 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5137 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5138 wined3d_device_context_copy_resource(device
->immediate_context
.wined3d_context
,
5139 wined3d_dst_resource
, wined3d_src_resource
);
5142 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
5143 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
5144 const void *data
, UINT row_pitch
, UINT depth_pitch
)
5146 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5147 ID3D11Resource
*d3d11_resource
;
5149 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
5150 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
5152 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
5153 d3d11_device_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5154 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
5155 ID3D11Resource_Release(d3d11_resource
);
5158 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
5159 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
5161 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5162 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
5163 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
5166 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
5167 iface
, render_target_view
, debug_float4(color_rgba
));
5172 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(device
->immediate_context
.wined3d_context
,
5173 view
->wined3d_view
, NULL
, WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
5174 ERR("Failed to clear view, hr %#x.\n", hr
);
5177 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
5178 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
5180 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5181 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
5182 DWORD wined3d_flags
;
5185 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
5186 iface
, depth_stencil_view
, flags
, depth
, stencil
);
5191 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
5193 if (FAILED(hr
= wined3d_device_context_clear_rendertarget_view(device
->immediate_context
.wined3d_context
,
5194 view
->wined3d_view
, NULL
, wined3d_flags
, NULL
, depth
, stencil
)))
5195 ERR("Failed to clear view, hr %#x.\n", hr
);
5198 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
5199 ID3D10ShaderResourceView
*view
)
5201 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5202 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D10ShaderResourceView(view
);
5204 TRACE("iface %p, view %p.\n", iface
, view
);
5206 wined3d_device_context_generate_mipmaps(device
->immediate_context
.wined3d_context
, srv
->wined3d_view
);
5209 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
5210 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
5211 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
5213 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
5214 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5215 enum wined3d_format_id wined3d_format
;
5217 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
5218 "src_resource %p, src_subresource_idx %u, format %s.\n",
5219 iface
, dst_resource
, dst_subresource_idx
,
5220 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
5222 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
5223 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
5224 wined3d_format
= wined3dformat_from_dxgi_format(format
);
5225 wined3d_device_context_resolve_sub_resource(device
->immediate_context
.wined3d_context
,
5226 wined3d_dst_resource
, dst_subresource_idx
,
5227 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
5230 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
5231 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5233 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5234 iface
, start_slot
, buffer_count
, buffers
);
5236 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, buffer_count
,
5240 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
5241 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5243 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5246 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5247 iface
, start_slot
, view_count
, views
);
5249 wined3d_mutex_lock();
5250 for (i
= 0; i
< view_count
; ++i
)
5252 struct wined3d_shader_resource_view
*wined3d_view
;
5253 struct d3d_shader_resource_view
*view_impl
;
5255 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5256 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
5262 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5263 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5264 ID3D10ShaderResourceView_AddRef(views
[i
]);
5266 wined3d_mutex_unlock();
5269 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
5271 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5272 struct d3d_pixel_shader
*shader_impl
;
5273 struct wined3d_shader
*wined3d_shader
;
5275 TRACE("iface %p, shader %p.\n", iface
, shader
);
5277 wined3d_mutex_lock();
5278 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5279 WINED3D_SHADER_TYPE_PIXEL
)))
5281 wined3d_mutex_unlock();
5286 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5287 wined3d_mutex_unlock();
5288 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
5289 ID3D10PixelShader_AddRef(*shader
);
5292 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
5293 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5295 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5298 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5299 iface
, start_slot
, sampler_count
, samplers
);
5301 wined3d_mutex_lock();
5302 for (i
= 0; i
< sampler_count
; ++i
)
5304 struct d3d_sampler_state
*sampler_impl
;
5305 struct wined3d_sampler
*wined3d_sampler
;
5307 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5308 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
+ i
)))
5314 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5315 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5316 ID3D10SamplerState_AddRef(samplers
[i
]);
5318 wined3d_mutex_unlock();
5321 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
5323 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5324 struct d3d_vertex_shader
*shader_impl
;
5325 struct wined3d_shader
*wined3d_shader
;
5327 TRACE("iface %p, shader %p.\n", iface
, shader
);
5329 wined3d_mutex_lock();
5330 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5331 WINED3D_SHADER_TYPE_VERTEX
)))
5333 wined3d_mutex_unlock();
5338 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5339 wined3d_mutex_unlock();
5340 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
5341 ID3D10VertexShader_AddRef(*shader
);
5344 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
5345 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5347 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5348 iface
, start_slot
, buffer_count
, buffers
);
5350 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, buffer_count
,
5354 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
5356 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5357 struct wined3d_vertex_declaration
*wined3d_declaration
;
5358 struct d3d_input_layout
*input_layout_impl
;
5360 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
5362 wined3d_mutex_lock();
5363 if (!(wined3d_declaration
= wined3d_device_context_get_vertex_declaration(
5364 device
->immediate_context
.wined3d_context
)))
5366 wined3d_mutex_unlock();
5367 *input_layout
= NULL
;
5371 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
5372 wined3d_mutex_unlock();
5373 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
5374 ID3D10InputLayout_AddRef(*input_layout
);
5377 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
5378 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
5380 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5383 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
5384 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
5386 wined3d_mutex_lock();
5387 for (i
= 0; i
< buffer_count
; ++i
)
5389 struct wined3d_buffer
*wined3d_buffer
= NULL
;
5390 struct d3d_buffer
*buffer_impl
;
5392 if (FAILED(wined3d_device_context_get_stream_source(device
->immediate_context
.wined3d_context
, start_slot
+ i
,
5393 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
5394 ERR("Failed to get vertex buffer.\n");
5396 if (!wined3d_buffer
)
5402 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5403 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5404 ID3D10Buffer_AddRef(buffers
[i
]);
5406 wined3d_mutex_unlock();
5409 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
5410 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
5412 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5413 enum wined3d_format_id wined3d_format
;
5414 struct wined3d_buffer
*wined3d_buffer
;
5415 struct d3d_buffer
*buffer_impl
;
5417 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
5419 wined3d_mutex_lock();
5420 wined3d_buffer
= wined3d_device_context_get_index_buffer(
5421 device
->immediate_context
.wined3d_context
, &wined3d_format
, offset
);
5422 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
5423 if (!wined3d_buffer
)
5425 wined3d_mutex_unlock();
5430 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5431 wined3d_mutex_unlock();
5432 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
5433 ID3D10Buffer_AddRef(*buffer
);
5436 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
5437 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5439 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5440 iface
, start_slot
, buffer_count
, buffers
);
5442 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, buffer_count
,
5446 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
5448 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5449 struct d3d_geometry_shader
*shader_impl
;
5450 struct wined3d_shader
*wined3d_shader
;
5452 TRACE("iface %p, shader %p.\n", iface
, shader
);
5454 wined3d_mutex_lock();
5455 if (!(wined3d_shader
= wined3d_device_context_get_shader(device
->immediate_context
.wined3d_context
,
5456 WINED3D_SHADER_TYPE_GEOMETRY
)))
5458 wined3d_mutex_unlock();
5463 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5464 wined3d_mutex_unlock();
5465 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
5466 ID3D10GeometryShader_AddRef(*shader
);
5469 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
5470 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
5472 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5474 TRACE("iface %p, topology %p.\n", iface
, topology
);
5476 wined3d_mutex_lock();
5477 wined3d_device_context_get_primitive_type(device
->immediate_context
.wined3d_context
,
5478 (enum wined3d_primitive_type
*)topology
, NULL
);
5479 wined3d_mutex_unlock();
5482 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
5483 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5485 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5488 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5489 iface
, start_slot
, view_count
, views
);
5491 wined3d_mutex_lock();
5492 for (i
= 0; i
< view_count
; ++i
)
5494 struct wined3d_shader_resource_view
*wined3d_view
;
5495 struct d3d_shader_resource_view
*view_impl
;
5497 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5498 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
5504 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5505 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5506 ID3D10ShaderResourceView_AddRef(views
[i
]);
5508 wined3d_mutex_unlock();
5511 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
5512 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5514 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5517 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5518 iface
, start_slot
, sampler_count
, samplers
);
5520 wined3d_mutex_lock();
5521 for (i
= 0; i
< sampler_count
; ++i
)
5523 struct d3d_sampler_state
*sampler_impl
;
5524 struct wined3d_sampler
*wined3d_sampler
;
5526 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5527 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
+ i
)))
5533 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5534 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5535 ID3D10SamplerState_AddRef(samplers
[i
]);
5537 wined3d_mutex_unlock();
5540 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
5541 ID3D10Predicate
**predicate
, BOOL
*value
)
5543 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5544 struct wined3d_query
*wined3d_predicate
;
5545 struct d3d_query
*predicate_impl
;
5547 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
5549 wined3d_mutex_lock();
5550 if (!(wined3d_predicate
= wined3d_device_context_get_predication(device
->immediate_context
.wined3d_context
, value
)))
5552 wined3d_mutex_unlock();
5557 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
5558 wined3d_mutex_unlock();
5559 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
5560 ID3D10Predicate_AddRef(*predicate
);
5563 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
5564 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5566 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5569 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5570 iface
, start_slot
, view_count
, views
);
5572 wined3d_mutex_lock();
5573 for (i
= 0; i
< view_count
; ++i
)
5575 struct wined3d_shader_resource_view
*wined3d_view
;
5576 struct d3d_shader_resource_view
*view_impl
;
5578 if (!(wined3d_view
= wined3d_device_context_get_shader_resource_view(
5579 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
5585 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5586 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5587 ID3D10ShaderResourceView_AddRef(views
[i
]);
5589 wined3d_mutex_unlock();
5592 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
5593 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5595 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5598 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5599 iface
, start_slot
, sampler_count
, samplers
);
5601 wined3d_mutex_lock();
5602 for (i
= 0; i
< sampler_count
; ++i
)
5604 struct d3d_sampler_state
*sampler_impl
;
5605 struct wined3d_sampler
*wined3d_sampler
;
5607 if (!(wined3d_sampler
= wined3d_device_context_get_sampler(
5608 device
->immediate_context
.wined3d_context
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
+ i
)))
5614 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5615 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5616 ID3D10SamplerState_AddRef(samplers
[i
]);
5618 wined3d_mutex_unlock();
5621 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
5622 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
5624 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5625 struct wined3d_rendertarget_view
*wined3d_view
;
5627 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
5628 iface
, view_count
, render_target_views
, depth_stencil_view
);
5630 wined3d_mutex_lock();
5631 if (render_target_views
)
5633 struct d3d_rendertarget_view
*view_impl
;
5636 for (i
= 0; i
< view_count
; ++i
)
5638 if (!(wined3d_view
= wined3d_device_context_get_rendertarget_view(
5639 device
->immediate_context
.wined3d_context
, i
))
5640 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5642 render_target_views
[i
] = NULL
;
5646 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
5647 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
5651 if (depth_stencil_view
)
5653 struct d3d_depthstencil_view
*view_impl
;
5655 if (!(wined3d_view
= wined3d_device_context_get_depth_stencil_view(device
->immediate_context
.wined3d_context
))
5656 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5658 *depth_stencil_view
= NULL
;
5662 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
5663 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
5666 wined3d_mutex_unlock();
5669 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
5670 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
5672 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5673 ID3D11BlendState
*d3d11_blend_state
;
5675 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
5676 iface
, blend_state
, blend_factor
, sample_mask
);
5678 d3d11_device_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5679 &d3d11_blend_state
, blend_factor
, sample_mask
);
5683 if (d3d11_blend_state
)
5685 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
5686 ID3D10BlendState_AddRef(*blend_state
);
5689 *blend_state
= NULL
;
5692 if (d3d11_blend_state
)
5693 ID3D11BlendState_Release(d3d11_blend_state
);
5696 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
5697 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
5699 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5700 ID3D11DepthStencilState
*d3d11_iface
= NULL
;
5702 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
5703 iface
, depth_stencil_state
, stencil_ref
);
5705 d3d11_device_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5706 &d3d11_iface
, stencil_ref
);
5708 if (depth_stencil_state
)
5712 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
5713 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
5716 *depth_stencil_state
= NULL
;
5720 ID3D11DepthStencilState_Release(d3d11_iface
);
5723 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
5724 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
5726 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5729 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
5730 iface
, buffer_count
, buffers
, offsets
);
5732 wined3d_mutex_lock();
5733 for (i
= 0; i
< buffer_count
; ++i
)
5735 struct wined3d_buffer
*wined3d_buffer
;
5736 struct d3d_buffer
*buffer_impl
;
5738 if (!(wined3d_buffer
= wined3d_device_context_get_stream_output(
5739 device
->immediate_context
.wined3d_context
, i
, &offsets
[i
])))
5745 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5746 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5747 ID3D10Buffer_AddRef(buffers
[i
]);
5749 wined3d_mutex_unlock();
5752 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
5754 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5755 struct d3d_rasterizer_state
*rasterizer_state_impl
;
5756 struct wined3d_rasterizer_state
*wined3d_state
;
5758 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5760 wined3d_mutex_lock();
5761 if ((wined3d_state
= wined3d_device_context_get_rasterizer_state(device
->immediate_context
.wined3d_context
)))
5763 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
5764 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
5768 *rasterizer_state
= NULL
;
5770 wined3d_mutex_unlock();
5773 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
5774 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
5776 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5777 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5778 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
5780 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
5782 if (!viewport_count
)
5785 wined3d_mutex_lock();
5786 wined3d_device_context_get_viewports(device
->immediate_context
.wined3d_context
,
5787 &actual_count
, viewports
? wined3d_vp
: NULL
);
5788 wined3d_mutex_unlock();
5792 *viewport_count
= actual_count
;
5796 if (*viewport_count
> actual_count
)
5797 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
5799 *viewport_count
= min(actual_count
, *viewport_count
);
5800 for (i
= 0; i
< *viewport_count
; ++i
)
5802 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
5803 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
5804 viewports
[i
].Width
= wined3d_vp
[i
].width
;
5805 viewports
[i
].Height
= wined3d_vp
[i
].height
;
5806 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
5807 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
5811 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
5813 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5814 unsigned int actual_count
;
5816 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
5821 actual_count
= *rect_count
;
5823 wined3d_mutex_lock();
5824 wined3d_device_context_get_scissor_rects(device
->immediate_context
.wined3d_context
, &actual_count
, rects
);
5825 wined3d_mutex_unlock();
5829 *rect_count
= actual_count
;
5833 if (*rect_count
> actual_count
)
5834 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
5837 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
5839 TRACE("iface %p.\n", iface
);
5841 /* In the current implementation the device is never removed, so we can
5842 * just return S_OK here. */
5847 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
5849 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
5854 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
5856 FIXME("iface %p stub!\n", iface
);
5861 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
5862 REFGUID guid
, UINT
*data_size
, void *data
)
5864 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5866 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5868 return d3d11_device_GetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5871 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
5872 REFGUID guid
, UINT data_size
, const void *data
)
5874 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5876 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5878 return d3d11_device_SetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5881 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
5882 REFGUID guid
, const IUnknown
*data
)
5884 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5886 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
5888 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device2_iface
, guid
, data
);
5891 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
5893 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5895 TRACE("iface %p.\n", iface
);
5897 d3d11_device_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
5900 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
5902 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5904 TRACE("iface %p.\n", iface
);
5906 wined3d_device_context_flush(device
->immediate_context
.wined3d_context
);
5909 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
5910 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
5912 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5913 D3D11_BUFFER_DESC d3d11_desc
;
5914 struct d3d_buffer
*object
;
5917 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
5919 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
5920 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5921 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5922 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5923 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5924 d3d11_desc
.StructureByteStride
= 0;
5926 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5929 *buffer
= &object
->ID3D10Buffer_iface
;
5934 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
5935 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
5937 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5938 D3D11_TEXTURE1D_DESC d3d11_desc
;
5939 struct d3d_texture1d
*object
;
5942 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5944 d3d11_desc
.Width
= desc
->Width
;
5945 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5946 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5947 d3d11_desc
.Format
= desc
->Format
;
5948 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5949 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5950 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5951 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5953 if (FAILED(hr
= d3d_texture1d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5956 *texture
= &object
->ID3D10Texture1D_iface
;
5961 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
5962 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5963 ID3D10Texture2D
**texture
)
5965 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5966 D3D11_TEXTURE2D_DESC d3d11_desc
;
5967 struct d3d_texture2d
*object
;
5970 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5972 d3d11_desc
.Width
= desc
->Width
;
5973 d3d11_desc
.Height
= desc
->Height
;
5974 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5975 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5976 d3d11_desc
.Format
= desc
->Format
;
5977 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
5978 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5979 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5980 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5981 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5983 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5986 *texture
= &object
->ID3D10Texture2D_iface
;
5991 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
5992 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5993 ID3D10Texture3D
**texture
)
5995 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5996 D3D11_TEXTURE3D_DESC d3d11_desc
;
5997 struct d3d_texture3d
*object
;
6000 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
6002 d3d11_desc
.Width
= desc
->Width
;
6003 d3d11_desc
.Height
= desc
->Height
;
6004 d3d11_desc
.Depth
= desc
->Depth
;
6005 d3d11_desc
.MipLevels
= desc
->MipLevels
;
6006 d3d11_desc
.Format
= desc
->Format
;
6007 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
6008 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
6009 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
6010 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
6012 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
6015 *texture
= &object
->ID3D10Texture3D_iface
;
6020 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
6021 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
6023 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6024 struct d3d_shader_resource_view
*object
;
6025 ID3D11Resource
*d3d11_resource
;
6028 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6033 return E_INVALIDARG
;
6035 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6037 ERR("Resource does not implement ID3D11Resource.\n");
6041 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
6043 ID3D11Resource_Release(d3d11_resource
);
6047 *view
= &object
->ID3D10ShaderResourceView1_iface
;
6052 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
6053 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
6055 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6057 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
6058 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
6061 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
6062 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
6064 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6065 struct d3d_rendertarget_view
*object
;
6066 ID3D11Resource
*d3d11_resource
;
6069 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6074 return E_INVALIDARG
;
6076 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6078 ERR("Resource does not implement ID3D11Resource.\n");
6082 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
6083 ID3D11Resource_Release(d3d11_resource
);
6087 *view
= &object
->ID3D10RenderTargetView_iface
;
6092 static D3D11_DSV_DIMENSION
d3d11_dsv_dimension_from_d3d10(D3D10_DSV_DIMENSION dim
)
6094 return (D3D11_DSV_DIMENSION
)dim
;
6097 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
6098 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
6100 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6101 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
6102 struct d3d_depthstencil_view
*object
;
6103 ID3D11Resource
*d3d11_resource
;
6106 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
6112 d3d11_desc
.Format
= desc
->Format
;
6113 d3d11_desc
.ViewDimension
= d3d11_dsv_dimension_from_d3d10(desc
->ViewDimension
);
6114 d3d11_desc
.Flags
= 0;
6115 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
6118 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
6120 ERR("Resource does not implement ID3D11Resource.\n");
6124 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
6125 ID3D11Resource_Release(d3d11_resource
);
6129 *view
= &object
->ID3D10DepthStencilView_iface
;
6134 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
6135 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
6136 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
6137 ID3D10InputLayout
**input_layout
)
6139 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6140 struct d3d_input_layout
*object
;
6143 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
6144 "shader_byte_code_length %lu, input_layout %p\n",
6145 iface
, element_descs
, element_count
, shader_byte_code
,
6146 shader_byte_code_length
, input_layout
);
6148 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
6149 shader_byte_code
, shader_byte_code_length
, &object
)))
6152 *input_layout
= &object
->ID3D10InputLayout_iface
;
6157 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
6158 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
6160 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6161 struct d3d_vertex_shader
*object
;
6164 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
6165 iface
, byte_code
, byte_code_length
, shader
);
6167 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
6170 *shader
= &object
->ID3D10VertexShader_iface
;
6175 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
6176 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
6178 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6179 struct d3d_geometry_shader
*object
;
6182 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
6183 iface
, byte_code
, byte_code_length
, shader
);
6185 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
6186 NULL
, 0, NULL
, 0, 0, &object
)))
6189 *shader
= &object
->ID3D10GeometryShader_iface
;
6194 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
6195 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
6196 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
6198 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6199 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
6200 struct d3d_geometry_shader
*object
;
6201 unsigned int i
, stride_count
= 1;
6204 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
6205 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
6206 iface
, byte_code
, byte_code_length
, output_stream_decls
,
6207 output_stream_decl_count
, output_stream_stride
, shader
);
6209 if (!output_stream_decl_count
&& output_stream_stride
)
6211 WARN("Stride must be 0 when declaration entry count is 0.\n");
6213 return E_INVALIDARG
;
6216 if (output_stream_decl_count
6217 && !(so_entries
= heap_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
6219 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
6221 return E_OUTOFMEMORY
;
6224 for (i
= 0; i
< output_stream_decl_count
; ++i
)
6226 so_entries
[i
].Stream
= 0;
6227 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
6228 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
6229 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
6230 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
6231 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
6233 if (output_stream_decls
[i
].OutputSlot
)
6236 if (output_stream_stride
)
6238 WARN("Stride must be 0 when multiple output slots are used.\n");
6239 heap_free(so_entries
);
6241 return E_INVALIDARG
;
6246 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
6247 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
6248 heap_free(so_entries
);
6255 *shader
= &object
->ID3D10GeometryShader_iface
;
6260 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
6261 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
6263 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6264 struct d3d_pixel_shader
*object
;
6267 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
6268 iface
, byte_code
, byte_code_length
, shader
);
6270 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
6273 *shader
= &object
->ID3D10PixelShader_iface
;
6278 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
6279 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
6281 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6282 struct d3d_blend_state
*object
;
6285 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
6287 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
6290 *blend_state
= &object
->ID3D10BlendState1_iface
;
6295 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
6296 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
6298 D3D10_BLEND_DESC1 d3d10_1_desc
;
6301 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
6304 return E_INVALIDARG
;
6306 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
6307 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
6308 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
6310 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
6311 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
6312 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
6315 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
6317 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
6318 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
6319 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
6320 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
6321 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
6322 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
6323 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
6324 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
6327 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
6330 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
6331 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
6333 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6334 struct d3d_depthstencil_state
*object
;
6337 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
6339 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
6342 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
6347 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
6348 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
6350 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6351 struct d3d_rasterizer_state
*object
;
6352 D3D11_RASTERIZER_DESC1 desc1
;
6355 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
6358 return E_INVALIDARG
;
6360 memcpy(&desc1
, desc
, sizeof(*desc
));
6361 desc1
.ForcedSampleCount
= 0;
6363 if (FAILED(hr
= d3d_rasterizer_state_create(device
, &desc1
, &object
)))
6366 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
6371 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
6372 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
6374 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6375 struct d3d_sampler_state
*object
;
6378 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
6380 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
6383 *sampler_state
= &object
->ID3D10SamplerState_iface
;
6388 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
6389 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
6391 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6392 struct d3d_query
*object
;
6395 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
6397 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
6402 *query
= &object
->ID3D10Query_iface
;
6406 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6410 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
6411 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
6413 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6414 struct d3d_query
*object
;
6417 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
6419 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
6424 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
6428 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6432 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
6433 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
6435 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
6440 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
6441 DXGI_FORMAT format
, UINT
*format_support
)
6443 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6445 TRACE("iface %p, format %s, format_support %p.\n",
6446 iface
, debug_dxgi_format(format
), format_support
);
6448 return d3d11_device_CheckFormatSupport(&device
->ID3D11Device2_iface
, format
, format_support
);
6451 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
6452 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
6454 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6456 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
6457 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
6459 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device2_iface
, format
,
6460 sample_count
, quality_level_count
);
6463 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
6465 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
6468 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
6469 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
6470 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
6472 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
6473 "units %p, units_length %p, description %p, description_length %p stub!\n",
6474 iface
, desc
, type
, active_counters
, name
, name_length
,
6475 units
, units_length
, description
, description_length
);
6480 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
6482 FIXME("iface %p stub!\n", iface
);
6487 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
6488 HANDLE resource_handle
, REFIID guid
, void **resource
)
6490 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
6491 iface
, resource_handle
, debugstr_guid(guid
), resource
);
6496 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
6498 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
6501 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
6503 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
6506 static D3D10_FEATURE_LEVEL1
d3d10_feature_level1_from_d3d_feature_level(D3D_FEATURE_LEVEL level
)
6508 return (D3D10_FEATURE_LEVEL1
)level
;
6511 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
6513 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6515 TRACE("iface %p.\n", iface
);
6517 return d3d10_feature_level1_from_d3d_feature_level(device
->state
->feature_level
);
6520 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
6522 /* IUnknown methods */
6523 d3d10_device_QueryInterface
,
6524 d3d10_device_AddRef
,
6525 d3d10_device_Release
,
6526 /* ID3D10Device methods */
6527 d3d10_device_VSSetConstantBuffers
,
6528 d3d10_device_PSSetShaderResources
,
6529 d3d10_device_PSSetShader
,
6530 d3d10_device_PSSetSamplers
,
6531 d3d10_device_VSSetShader
,
6532 d3d10_device_DrawIndexed
,
6534 d3d10_device_PSSetConstantBuffers
,
6535 d3d10_device_IASetInputLayout
,
6536 d3d10_device_IASetVertexBuffers
,
6537 d3d10_device_IASetIndexBuffer
,
6538 d3d10_device_DrawIndexedInstanced
,
6539 d3d10_device_DrawInstanced
,
6540 d3d10_device_GSSetConstantBuffers
,
6541 d3d10_device_GSSetShader
,
6542 d3d10_device_IASetPrimitiveTopology
,
6543 d3d10_device_VSSetShaderResources
,
6544 d3d10_device_VSSetSamplers
,
6545 d3d10_device_SetPredication
,
6546 d3d10_device_GSSetShaderResources
,
6547 d3d10_device_GSSetSamplers
,
6548 d3d10_device_OMSetRenderTargets
,
6549 d3d10_device_OMSetBlendState
,
6550 d3d10_device_OMSetDepthStencilState
,
6551 d3d10_device_SOSetTargets
,
6552 d3d10_device_DrawAuto
,
6553 d3d10_device_RSSetState
,
6554 d3d10_device_RSSetViewports
,
6555 d3d10_device_RSSetScissorRects
,
6556 d3d10_device_CopySubresourceRegion
,
6557 d3d10_device_CopyResource
,
6558 d3d10_device_UpdateSubresource
,
6559 d3d10_device_ClearRenderTargetView
,
6560 d3d10_device_ClearDepthStencilView
,
6561 d3d10_device_GenerateMips
,
6562 d3d10_device_ResolveSubresource
,
6563 d3d10_device_VSGetConstantBuffers
,
6564 d3d10_device_PSGetShaderResources
,
6565 d3d10_device_PSGetShader
,
6566 d3d10_device_PSGetSamplers
,
6567 d3d10_device_VSGetShader
,
6568 d3d10_device_PSGetConstantBuffers
,
6569 d3d10_device_IAGetInputLayout
,
6570 d3d10_device_IAGetVertexBuffers
,
6571 d3d10_device_IAGetIndexBuffer
,
6572 d3d10_device_GSGetConstantBuffers
,
6573 d3d10_device_GSGetShader
,
6574 d3d10_device_IAGetPrimitiveTopology
,
6575 d3d10_device_VSGetShaderResources
,
6576 d3d10_device_VSGetSamplers
,
6577 d3d10_device_GetPredication
,
6578 d3d10_device_GSGetShaderResources
,
6579 d3d10_device_GSGetSamplers
,
6580 d3d10_device_OMGetRenderTargets
,
6581 d3d10_device_OMGetBlendState
,
6582 d3d10_device_OMGetDepthStencilState
,
6583 d3d10_device_SOGetTargets
,
6584 d3d10_device_RSGetState
,
6585 d3d10_device_RSGetViewports
,
6586 d3d10_device_RSGetScissorRects
,
6587 d3d10_device_GetDeviceRemovedReason
,
6588 d3d10_device_SetExceptionMode
,
6589 d3d10_device_GetExceptionMode
,
6590 d3d10_device_GetPrivateData
,
6591 d3d10_device_SetPrivateData
,
6592 d3d10_device_SetPrivateDataInterface
,
6593 d3d10_device_ClearState
,
6595 d3d10_device_CreateBuffer
,
6596 d3d10_device_CreateTexture1D
,
6597 d3d10_device_CreateTexture2D
,
6598 d3d10_device_CreateTexture3D
,
6599 d3d10_device_CreateShaderResourceView
,
6600 d3d10_device_CreateRenderTargetView
,
6601 d3d10_device_CreateDepthStencilView
,
6602 d3d10_device_CreateInputLayout
,
6603 d3d10_device_CreateVertexShader
,
6604 d3d10_device_CreateGeometryShader
,
6605 d3d10_device_CreateGeometryShaderWithStreamOutput
,
6606 d3d10_device_CreatePixelShader
,
6607 d3d10_device_CreateBlendState
,
6608 d3d10_device_CreateDepthStencilState
,
6609 d3d10_device_CreateRasterizerState
,
6610 d3d10_device_CreateSamplerState
,
6611 d3d10_device_CreateQuery
,
6612 d3d10_device_CreatePredicate
,
6613 d3d10_device_CreateCounter
,
6614 d3d10_device_CheckFormatSupport
,
6615 d3d10_device_CheckMultisampleQualityLevels
,
6616 d3d10_device_CheckCounterInfo
,
6617 d3d10_device_CheckCounter
,
6618 d3d10_device_GetCreationFlags
,
6619 d3d10_device_OpenSharedResource
,
6620 d3d10_device_SetTextFilterSize
,
6621 d3d10_device_GetTextFilterSize
,
6622 d3d10_device_CreateShaderResourceView1
,
6623 d3d10_device_CreateBlendState1
,
6624 d3d10_device_GetFeatureLevel
,
6627 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
6629 /* IUnknown methods */
6630 d3d_device_inner_QueryInterface
,
6631 d3d_device_inner_AddRef
,
6632 d3d_device_inner_Release
,
6635 /* ID3D10Multithread methods */
6637 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
6639 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
6642 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
6644 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6646 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
6648 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6651 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
6653 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6655 TRACE("iface %p.\n", iface
);
6657 return IUnknown_AddRef(device
->outer_unk
);
6660 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
6662 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6664 TRACE("iface %p.\n", iface
);
6666 return IUnknown_Release(device
->outer_unk
);
6669 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
6671 TRACE("iface %p.\n", iface
);
6673 wined3d_mutex_lock();
6676 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
6678 TRACE("iface %p.\n", iface
);
6680 wined3d_mutex_unlock();
6683 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL enable
)
6685 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
6690 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
6692 FIXME("iface %p stub!\n", iface
);
6697 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
6699 d3d10_multithread_QueryInterface
,
6700 d3d10_multithread_AddRef
,
6701 d3d10_multithread_Release
,
6702 d3d10_multithread_Enter
,
6703 d3d10_multithread_Leave
,
6704 d3d10_multithread_SetMultithreadProtected
,
6705 d3d10_multithread_GetMultithreadProtected
,
6708 /* IWineDXGIDeviceParent IUnknown methods */
6710 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
6712 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
6715 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
6716 REFIID iid
, void **out
)
6718 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6719 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6722 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
6724 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6725 return IUnknown_AddRef(device
->outer_unk
);
6728 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
6730 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6731 return IUnknown_Release(device
->outer_unk
);
6734 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
6735 IWineDXGIDeviceParent
*iface
)
6737 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6738 return &device
->device_parent
;
6741 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
6743 /* IUnknown methods */
6744 dxgi_device_parent_QueryInterface
,
6745 dxgi_device_parent_AddRef
,
6746 dxgi_device_parent_Release
,
6747 /* IWineDXGIDeviceParent methods */
6748 dxgi_device_parent_get_wined3d_device_parent
,
6751 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
6753 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
6756 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
6757 struct wined3d_device
*wined3d_device
)
6759 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6760 struct d3d_device_context_state
*state
;
6761 struct wined3d_state
*wined3d_state
;
6762 D3D_FEATURE_LEVEL feature_level
;
6764 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
6766 wined3d_device_incref(wined3d_device
);
6767 device
->wined3d_device
= wined3d_device
;
6768 device
->immediate_context
.wined3d_context
= wined3d_device_get_immediate_context(wined3d_device
);
6770 wined3d_state
= wined3d_device_get_state(device
->wined3d_device
);
6771 feature_level
= d3d_feature_level_from_wined3d(wined3d_state_get_feature_level(wined3d_state
));
6773 if (!(state
= heap_alloc_zero(sizeof(*state
))))
6775 ERR("Failed to create the initial device context state.\n");
6779 d3d_device_context_state_init(state
, device
, feature_level
,
6780 device
->d3d11_only
? &IID_ID3D11Device2
: &IID_ID3D10Device1
);
6782 device
->state
= state
;
6783 if (!d3d_device_context_state_add_entry(state
, device
, wined3d_state
))
6784 ERR("Failed to add entry for wined3d state %p, device %p.\n", wined3d_state
, device
);
6786 d3d_device_context_state_private_addref(state
);
6787 ID3DDeviceContextState_Release(&state
->ID3DDeviceContextState_iface
);
6790 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
6792 TRACE("device_parent %p.\n", device_parent
);
6795 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
6797 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
6800 static HRESULT CDECL
device_parent_texture_sub_resource_created(struct wined3d_device_parent
*device_parent
,
6801 enum wined3d_resource_type type
, struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
,
6802 void **parent
, const struct wined3d_parent_ops
**parent_ops
)
6804 TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
6805 device_parent
, type
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
6808 *parent_ops
= &d3d_null_wined3d_parent_ops
;
6813 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
6814 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
6815 struct wined3d_texture
**wined3d_texture
)
6817 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6818 struct d3d_texture2d
*texture
;
6819 ID3D11Texture2D
*texture_iface
;
6820 D3D11_TEXTURE2D_DESC desc
;
6823 TRACE("device_parent %p, container_parent %p, wined3d_desc %p, texture_flags %#x, wined3d_texture %p.\n",
6824 device_parent
, container_parent
, wined3d_desc
, texture_flags
, wined3d_texture
);
6826 desc
.Width
= wined3d_desc
->width
;
6827 desc
.Height
= wined3d_desc
->height
;
6830 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
6831 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
6832 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
6833 desc
.Usage
= D3D11_USAGE_DEFAULT
;
6834 desc
.BindFlags
= d3d11_bind_flags_from_wined3d(wined3d_desc
->bind_flags
);
6835 desc
.CPUAccessFlags
= 0;
6838 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
6840 desc
.MiscFlags
|= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
6841 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
6845 FIXME("Unhandled flags %#x.\n", texture_flags
);
6847 if (FAILED(hr
= d3d11_device_CreateTexture2D(&device
->ID3D11Device2_iface
,
6848 &desc
, NULL
, &texture_iface
)))
6850 WARN("Failed to create 2D texture, hr %#x.\n", hr
);
6854 texture
= impl_from_ID3D11Texture2D(texture_iface
);
6856 *wined3d_texture
= texture
->wined3d_texture
;
6857 wined3d_texture_incref(*wined3d_texture
);
6858 ID3D11Texture2D_Release(&texture
->ID3D11Texture2D_iface
);
6863 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
6865 device_parent_wined3d_device_created
,
6866 device_parent_mode_changed
,
6867 device_parent_activate
,
6868 device_parent_texture_sub_resource_created
,
6869 device_parent_create_swapchain_texture
,
6872 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6874 const D3D11_SAMPLER_DESC
*ka
= key
;
6875 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
6877 return memcmp(ka
, kb
, sizeof(*ka
));
6880 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6882 const D3D11_BLEND_DESC
*ka
= key
;
6883 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
6885 return memcmp(ka
, kb
, sizeof(*ka
));
6888 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6890 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
6891 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
6892 const struct d3d_depthstencil_state
, entry
)->desc
;
6894 return memcmp(ka
, kb
, sizeof(*ka
));
6897 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6899 const D3D11_RASTERIZER_DESC1
*ka
= key
;
6900 const D3D11_RASTERIZER_DESC1
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
6902 return memcmp(ka
, kb
, sizeof(*ka
));
6905 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
6907 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
6908 device
->ID3D11Device2_iface
.lpVtbl
= &d3d11_device_vtbl
;
6909 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
6910 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
6911 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
6912 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
6913 device
->refcount
= 1;
6914 /* COM aggregation always takes place */
6915 device
->outer_unk
= outer_unknown
;
6916 device
->d3d11_only
= FALSE
;
6917 device
->state
= NULL
;
6919 d3d11_device_context_init(&device
->immediate_context
, device
, D3D11_DEVICE_CONTEXT_IMMEDIATE
);
6920 ID3D11DeviceContext1_Release(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
6922 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
6923 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
6924 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
6925 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);