2 * Copyright 2008-2012 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define NONAMELESSUNION
21 #include "d3d11_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
25 static void STDMETHODCALLTYPE
d3d_null_wined3d_object_destroyed(void *parent
) {}
27 static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops
=
29 d3d_null_wined3d_object_destroyed
,
32 static inline BOOL
d3d_device_is_d3d10_active(struct d3d_device
*device
)
35 || IsEqualGUID(&device
->state
->emulated_interface
, &IID_ID3D10Device
)
36 || IsEqualGUID(&device
->state
->emulated_interface
, &IID_ID3D10Device1
);
39 /* ID3DDeviceContextState methods */
41 static inline struct d3d_device_context_state
*impl_from_ID3DDeviceContextState(ID3DDeviceContextState
*iface
)
43 return CONTAINING_RECORD(iface
, struct d3d_device_context_state
, ID3DDeviceContextState_iface
);
46 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_QueryInterface(ID3DDeviceContextState
*iface
,
47 REFIID iid
, void **out
)
49 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
51 if (IsEqualGUID(iid
, &IID_ID3DDeviceContextState
)
52 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
53 || IsEqualGUID(iid
, &IID_IUnknown
))
55 ID3DDeviceContextState_AddRef(iface
);
60 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
66 static ULONG
d3d_device_context_state_private_addref(struct d3d_device_context_state
*state
)
68 ULONG refcount
= InterlockedIncrement(&state
->private_refcount
);
70 TRACE("%p increasing private refcount to %u.\n", state
, refcount
);
75 static ULONG STDMETHODCALLTYPE
d3d_device_context_state_AddRef(ID3DDeviceContextState
*iface
)
77 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
78 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
80 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
84 d3d_device_context_state_private_addref(state
);
85 ID3D11Device2_AddRef(state
->device
);
91 static void d3d_device_context_state_private_release(struct d3d_device_context_state
*state
)
93 ULONG refcount
= InterlockedDecrement(&state
->private_refcount
);
96 TRACE("%p decreasing private refcount to %u.\n", state
, refcount
);
100 wined3d_private_store_cleanup(&state
->private_store
);
101 if (state
->vs
.shader
) ID3D11VertexShader_Release(state
->vs
.shader
);
102 if (state
->gs
.shader
) ID3D11GeometryShader_Release(state
->gs
.shader
);
103 if (state
->ps
.shader
) ID3D11PixelShader_Release(state
->ps
.shader
);
104 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
106 if (state
->vs
.samplers
[i
]) ID3D11SamplerState_Release(state
->vs
.samplers
[i
]);
107 if (state
->gs
.samplers
[i
]) ID3D11SamplerState_Release(state
->gs
.samplers
[i
]);
108 if (state
->ps
.samplers
[i
]) ID3D11SamplerState_Release(state
->ps
.samplers
[i
]);
110 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
112 if (state
->vs
.srvs
[i
]) ID3D11ShaderResourceView_Release(state
->vs
.srvs
[i
]);
113 if (state
->gs
.srvs
[i
]) ID3D11ShaderResourceView_Release(state
->gs
.srvs
[i
]);
114 if (state
->ps
.srvs
[i
]) ID3D11ShaderResourceView_Release(state
->ps
.srvs
[i
]);
116 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
118 if (state
->vs
.cbs
[i
]) ID3D11Buffer_Release(state
->vs
.cbs
[i
]);
119 if (state
->gs
.cbs
[i
]) ID3D11Buffer_Release(state
->gs
.cbs
[i
]);
120 if (state
->ps
.cbs
[i
]) ID3D11Buffer_Release(state
->ps
.cbs
[i
]);
122 wined3d_device_decref(state
->wined3d_device
);
127 static ULONG STDMETHODCALLTYPE
d3d_device_context_state_Release(ID3DDeviceContextState
*iface
)
129 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
130 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
132 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
136 ID3D11Device2_Release(state
->device
);
137 d3d_device_context_state_private_release(state
);
143 static void STDMETHODCALLTYPE
d3d_device_context_state_GetDevice(ID3DDeviceContextState
*iface
, ID3D11Device
**device
)
145 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
147 TRACE("iface %p, device %p.\n", iface
, device
);
149 *device
= (ID3D11Device
*)state
->device
;
150 ID3D11Device_AddRef(*device
);
153 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_GetPrivateData(ID3DDeviceContextState
*iface
, REFGUID guid
,
154 UINT
*data_size
, void *data
)
156 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
158 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
160 return d3d_get_private_data(&state
->private_store
, guid
, data_size
, data
);
163 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_SetPrivateData(ID3DDeviceContextState
*iface
, REFGUID guid
,
164 UINT data_size
, const void *data
)
166 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
168 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
170 return d3d_set_private_data(&state
->private_store
, guid
, data_size
, data
);
173 static HRESULT STDMETHODCALLTYPE
d3d_device_context_state_SetPrivateDataInterface(ID3DDeviceContextState
*iface
,
174 REFGUID guid
, const IUnknown
*data
)
176 struct d3d_device_context_state
*state
= impl_from_ID3DDeviceContextState(iface
);
178 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
180 return d3d_set_private_data_interface(&state
->private_store
, guid
, data
);
183 static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl
=
185 /* IUnknown methods */
186 d3d_device_context_state_QueryInterface
,
187 d3d_device_context_state_AddRef
,
188 d3d_device_context_state_Release
,
189 /* ID3D11DeviceChild methods */
190 d3d_device_context_state_GetDevice
,
191 d3d_device_context_state_GetPrivateData
,
192 d3d_device_context_state_SetPrivateData
,
193 d3d_device_context_state_SetPrivateDataInterface
,
194 /* ID3DDeviceContextState methods */
197 static void d3d_device_context_state_init(struct d3d_device_context_state
*state
, struct d3d_device
*device
,
198 REFIID emulated_interface
)
200 state
->ID3DDeviceContextState_iface
.lpVtbl
= &d3d_device_context_state_vtbl
;
201 state
->refcount
= state
->private_refcount
= 0;
203 wined3d_private_store_init(&state
->private_store
);
204 memset(&state
->vs
, 0, sizeof(state
->vs
));
205 memset(&state
->gs
, 0, sizeof(state
->gs
));
206 memset(&state
->ps
, 0, sizeof(state
->ps
));
208 state
->emulated_interface
= *emulated_interface
;
209 wined3d_device_incref(state
->wined3d_device
= device
->wined3d_device
);
210 state
->device
= &device
->ID3D11Device2_iface
;
212 d3d_device_context_state_AddRef(&state
->ID3DDeviceContextState_iface
);
215 /* ID3D11DeviceContext - immediate context methods */
217 static inline struct d3d11_immediate_context
*impl_from_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
219 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11DeviceContext1_iface
);
222 static inline struct d3d_device
*device_from_immediate_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
224 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
225 return CONTAINING_RECORD(context
, struct d3d_device
, immediate_context
);
228 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_QueryInterface(ID3D11DeviceContext1
*iface
,
229 REFIID iid
, void **out
)
231 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
233 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
235 if (IsEqualGUID(iid
, &IID_ID3D11DeviceContext1
)
236 || IsEqualGUID(iid
, &IID_ID3D11DeviceContext
)
237 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
238 || IsEqualGUID(iid
, &IID_IUnknown
))
240 *out
= &context
->ID3D11DeviceContext1_iface
;
242 else if (IsEqualGUID(iid
, &IID_ID3D11Multithread
))
244 *out
= &context
->ID3D11Multithread_iface
;
248 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
250 return E_NOINTERFACE
;
253 ID3D11DeviceContext1_AddRef(iface
);
257 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_AddRef(ID3D11DeviceContext1
*iface
)
259 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
260 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
261 ULONG refcount
= InterlockedIncrement(&context
->refcount
);
263 TRACE("%p increasing refcount to %u.\n", context
, refcount
);
267 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
273 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_Release(ID3D11DeviceContext1
*iface
)
275 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
276 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
277 ULONG refcount
= InterlockedDecrement(&context
->refcount
);
279 TRACE("%p decreasing refcount to %u.\n", context
, refcount
);
283 ID3D11Device2_Release(&device
->ID3D11Device2_iface
);
289 static void d3d11_immediate_context_get_constant_buffers(ID3D11DeviceContext1
*iface
,
290 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
292 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
295 wined3d_mutex_lock();
296 for (i
= 0; i
< buffer_count
; ++i
)
298 struct wined3d_buffer
*wined3d_buffer
;
299 struct d3d_buffer
*buffer_impl
;
301 if (!(wined3d_buffer
= wined3d_device_get_constant_buffer(device
->wined3d_device
,
302 type
, start_slot
+ i
)))
308 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
309 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
310 ID3D11Buffer_AddRef(buffers
[i
]);
312 wined3d_mutex_unlock();
315 static void d3d11_immediate_context_set_constant_buffers(ID3D11DeviceContext1
*iface
,
316 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
318 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
321 wined3d_mutex_lock();
322 for (i
= 0; i
< buffer_count
; ++i
)
324 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
326 wined3d_device_set_constant_buffer(device
->wined3d_device
, type
, start_slot
+ i
,
327 buffer
? buffer
->wined3d_buffer
: NULL
);
329 wined3d_mutex_unlock();
332 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetDevice(ID3D11DeviceContext1
*iface
, ID3D11Device
**device
)
334 struct d3d_device
*device_object
= device_from_immediate_ID3D11DeviceContext1(iface
);
336 TRACE("iface %p, device %p.\n", iface
, device
);
338 *device
= (ID3D11Device
*)&device_object
->ID3D11Device2_iface
;
339 ID3D11Device_AddRef(*device
);
342 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
343 UINT
*data_size
, void *data
)
345 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
347 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
349 return d3d_get_private_data(&context
->private_store
, guid
, data_size
, data
);
352 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
353 UINT data_size
, const void *data
)
355 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
357 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
359 return d3d_set_private_data(&context
->private_store
, guid
, data_size
, data
);
362 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext1
*iface
,
363 REFGUID guid
, const IUnknown
*data
)
365 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
367 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
369 return d3d_set_private_data_interface(&context
->private_store
, guid
, data
);
372 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
373 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
375 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
376 iface
, start_slot
, buffer_count
, buffers
);
378 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
379 buffer_count
, buffers
);
382 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext1
*iface
,
383 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
385 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
388 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
389 iface
, start_slot
, view_count
, views
);
391 wined3d_mutex_lock();
392 for (i
= 0; i
< view_count
; ++i
)
394 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
396 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
397 view
? view
->wined3d_view
: NULL
);
399 wined3d_mutex_unlock();
402 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShader(ID3D11DeviceContext1
*iface
,
403 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
405 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
406 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
408 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
409 iface
, shader
, class_instances
, class_instance_count
);
412 FIXME("Dynamic linking is not implemented yet.\n");
414 wined3d_mutex_lock();
415 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
416 wined3d_mutex_unlock();
419 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext1
*iface
,
420 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
422 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
425 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
426 iface
, start_slot
, sampler_count
, samplers
);
428 wined3d_mutex_lock();
429 for (i
= 0; i
< sampler_count
; ++i
)
431 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
433 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
434 sampler
? sampler
->wined3d_sampler
: NULL
);
436 wined3d_mutex_unlock();
439 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShader(ID3D11DeviceContext1
*iface
,
440 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
442 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
443 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
445 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
446 iface
, shader
, class_instances
, class_instance_count
);
449 FIXME("Dynamic linking is not implemented yet.\n");
451 wined3d_mutex_lock();
452 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
453 wined3d_mutex_unlock();
456 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext1
*iface
,
457 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
459 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
461 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
462 iface
, index_count
, start_index_location
, base_vertex_location
);
464 wined3d_mutex_lock();
465 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
466 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
467 wined3d_mutex_unlock();
470 static void STDMETHODCALLTYPE
d3d11_immediate_context_Draw(ID3D11DeviceContext1
*iface
,
471 UINT vertex_count
, UINT start_vertex_location
)
473 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
475 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
476 iface
, vertex_count
, start_vertex_location
);
478 wined3d_mutex_lock();
479 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
480 wined3d_mutex_unlock();
483 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_Map(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
484 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
486 struct wined3d_resource
*wined3d_resource
;
487 struct wined3d_map_desc map_desc
;
490 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
491 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
494 FIXME("Ignoring map_flags %#x.\n", map_flags
);
496 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
498 wined3d_mutex_lock();
499 hr
= wined3d_resource_map(wined3d_resource
, subresource_idx
,
500 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
501 wined3d_mutex_unlock();
503 mapped_subresource
->pData
= map_desc
.data
;
504 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
505 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
510 static void STDMETHODCALLTYPE
d3d11_immediate_context_Unmap(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
511 UINT subresource_idx
)
513 struct wined3d_resource
*wined3d_resource
;
515 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
517 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
519 wined3d_mutex_lock();
520 wined3d_resource_unmap(wined3d_resource
, subresource_idx
);
521 wined3d_mutex_unlock();
524 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
525 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
527 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
528 iface
, start_slot
, buffer_count
, buffers
);
530 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
531 buffer_count
, buffers
);
534 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext1
*iface
,
535 ID3D11InputLayout
*input_layout
)
537 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
538 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
540 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
542 wined3d_mutex_lock();
543 wined3d_device_set_vertex_declaration(device
->wined3d_device
, layout
? layout
->wined3d_decl
: NULL
);
544 wined3d_mutex_unlock();
547 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext1
*iface
,
548 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
550 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
553 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
554 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
556 wined3d_mutex_lock();
557 for (i
= 0; i
< buffer_count
; ++i
)
559 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
561 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
562 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
564 wined3d_mutex_unlock();
567 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext1
*iface
,
568 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
570 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
571 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
573 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
574 iface
, buffer
, debug_dxgi_format(format
), offset
);
576 wined3d_mutex_lock();
577 wined3d_device_set_index_buffer(device
->wined3d_device
,
578 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
579 wined3dformat_from_dxgi_format(format
), offset
);
580 wined3d_mutex_unlock();
583 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext1
*iface
,
584 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
585 UINT start_instance_location
)
587 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
589 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
590 "base_vertex_location %d, start_instance_location %u.\n",
591 iface
, instance_index_count
, instance_count
, start_index_location
,
592 base_vertex_location
, start_instance_location
);
594 wined3d_mutex_lock();
595 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
596 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
597 instance_index_count
, start_instance_location
, instance_count
);
598 wined3d_mutex_unlock();
601 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext1
*iface
,
602 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
604 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
606 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
607 "start_instance_location %u.\n",
608 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
609 start_instance_location
);
611 wined3d_mutex_lock();
612 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
613 instance_vertex_count
, start_instance_location
, instance_count
);
614 wined3d_mutex_unlock();
617 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
618 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
620 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
621 iface
, start_slot
, buffer_count
, buffers
);
623 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
624 buffer_count
, buffers
);
627 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext1
*iface
,
628 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
630 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
631 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
633 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
634 iface
, shader
, class_instances
, class_instance_count
);
637 FIXME("Dynamic linking is not implemented yet.\n");
639 wined3d_mutex_lock();
640 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
641 wined3d_mutex_unlock();
644 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
645 D3D11_PRIMITIVE_TOPOLOGY topology
)
647 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
648 enum wined3d_primitive_type primitive_type
;
649 unsigned int patch_vertex_count
;
651 TRACE("iface %p, topology %#x.\n", iface
, topology
);
653 wined3d_primitive_type_from_d3d11_primitive_topology(topology
, &primitive_type
, &patch_vertex_count
);
655 wined3d_mutex_lock();
656 wined3d_device_set_primitive_type(device
->wined3d_device
, primitive_type
, patch_vertex_count
);
657 wined3d_mutex_unlock();
660 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext1
*iface
,
661 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
663 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
666 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
668 wined3d_mutex_lock();
669 for (i
= 0; i
< view_count
; ++i
)
671 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
673 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
674 view
? view
->wined3d_view
: NULL
);
676 wined3d_mutex_unlock();
679 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext1
*iface
,
680 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
682 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
685 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
686 iface
, start_slot
, sampler_count
, samplers
);
688 wined3d_mutex_lock();
689 for (i
= 0; i
< sampler_count
; ++i
)
691 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
693 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
694 sampler
? sampler
->wined3d_sampler
: NULL
);
696 wined3d_mutex_unlock();
699 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext1
*iface
,
700 ID3D11Asynchronous
*asynchronous
)
702 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
705 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
707 wined3d_mutex_lock();
708 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_BEGIN
)))
709 ERR("Failed to issue query, hr %#x.\n", hr
);
710 wined3d_mutex_unlock();
713 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext1
*iface
,
714 ID3D11Asynchronous
*asynchronous
)
716 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
719 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
721 wined3d_mutex_lock();
722 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_END
)))
723 ERR("Failed to issue query, hr %#x.\n", hr
);
724 wined3d_mutex_unlock();
727 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext1
*iface
,
728 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
730 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
731 unsigned int wined3d_flags
;
734 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
735 iface
, asynchronous
, data
, data_size
, data_flags
);
737 if (!data
&& data_size
)
740 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
742 wined3d_mutex_lock();
743 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
745 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
746 if (hr
== WINED3DERR_INVALIDCALL
)
747 hr
= DXGI_ERROR_INVALID_CALL
;
751 WARN("Invalid data size %u.\n", data_size
);
754 wined3d_mutex_unlock();
759 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext1
*iface
,
760 ID3D11Predicate
*predicate
, BOOL value
)
762 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
763 struct d3d_query
*query
;
765 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
767 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
769 wined3d_mutex_lock();
770 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
771 wined3d_mutex_unlock();
774 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext1
*iface
,
775 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
777 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
780 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
782 wined3d_mutex_lock();
783 for (i
= 0; i
< view_count
; ++i
)
785 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
787 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
788 view
? view
->wined3d_view
: NULL
);
790 wined3d_mutex_unlock();
793 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext1
*iface
,
794 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
796 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
799 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
800 iface
, start_slot
, sampler_count
, samplers
);
802 wined3d_mutex_lock();
803 for (i
= 0; i
< sampler_count
; ++i
)
805 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
807 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
808 sampler
? sampler
->wined3d_sampler
: NULL
);
810 wined3d_mutex_unlock();
813 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext1
*iface
,
814 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
815 ID3D11DepthStencilView
*depth_stencil_view
)
817 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
818 struct d3d_depthstencil_view
*dsv
;
821 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
822 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
824 wined3d_mutex_lock();
825 for (i
= 0; i
< render_target_view_count
; ++i
)
827 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
828 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
830 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
832 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
835 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
836 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
837 wined3d_mutex_unlock();
840 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
841 ID3D11DeviceContext1
*iface
, UINT render_target_view_count
,
842 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
843 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
844 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
846 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
849 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
850 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
851 "initial_counts %p.\n",
852 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
853 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
856 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
858 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
862 if (unordered_access_view_count
!= D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
864 wined3d_mutex_lock();
865 for (i
= 0; i
< unordered_access_view_start_slot
; ++i
)
867 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
869 for (i
= 0; i
< unordered_access_view_count
; ++i
)
871 struct d3d11_unordered_access_view
*view
872 = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views
[i
]);
874 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
875 unordered_access_view_start_slot
+ i
,
876 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
878 for (; unordered_access_view_start_slot
+ i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
880 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
881 unordered_access_view_start_slot
+ i
, NULL
, ~0u);
883 wined3d_mutex_unlock();
887 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext1
*iface
,
888 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
890 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
891 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
892 struct d3d_blend_state
*blend_state_impl
;
894 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
895 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
898 blend_factor
= default_blend_factor
;
900 wined3d_mutex_lock();
901 if (!(blend_state_impl
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
902 wined3d_device_set_blend_state(device
->wined3d_device
, NULL
,
903 (const struct wined3d_color
*)blend_factor
, sample_mask
);
905 wined3d_device_set_blend_state(device
->wined3d_device
, blend_state_impl
->wined3d_state
,
906 (const struct wined3d_color
*)blend_factor
, sample_mask
);
907 wined3d_mutex_unlock();
910 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext1
*iface
,
911 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
913 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
914 struct d3d_depthstencil_state
*state_impl
;
916 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
917 iface
, depth_stencil_state
, stencil_ref
);
919 wined3d_mutex_lock();
920 if (!(state_impl
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
922 wined3d_device_set_depth_stencil_state(device
->wined3d_device
, NULL
, stencil_ref
);
923 wined3d_mutex_unlock();
927 wined3d_device_set_depth_stencil_state(device
->wined3d_device
, state_impl
->wined3d_state
, stencil_ref
);
928 wined3d_mutex_unlock();
931 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext1
*iface
, UINT buffer_count
,
932 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
934 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
935 unsigned int count
, i
;
937 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
939 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
940 wined3d_mutex_lock();
941 for (i
= 0; i
< count
; ++i
)
943 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
945 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
946 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
? offsets
[i
] : 0);
948 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
950 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
952 wined3d_mutex_unlock();
955 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext1
*iface
)
957 FIXME("iface %p stub!\n", iface
);
960 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext1
*iface
,
961 ID3D11Buffer
*buffer
, UINT offset
)
963 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
964 struct d3d_buffer
*d3d_buffer
;
966 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
968 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
970 wined3d_mutex_lock();
971 wined3d_device_draw_indexed_primitive_instanced_indirect(device
->wined3d_device
,
972 d3d_buffer
->wined3d_buffer
, offset
);
973 wined3d_mutex_unlock();
976 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext1
*iface
,
977 ID3D11Buffer
*buffer
, UINT offset
)
979 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
980 struct d3d_buffer
*d3d_buffer
;
982 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
984 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
986 wined3d_mutex_lock();
987 wined3d_device_draw_primitive_instanced_indirect(device
->wined3d_device
,
988 d3d_buffer
->wined3d_buffer
, offset
);
989 wined3d_mutex_unlock();
992 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext1
*iface
,
993 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
995 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
997 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
998 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
1000 wined3d_mutex_lock();
1001 wined3d_device_dispatch_compute(device
->wined3d_device
,
1002 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
1003 wined3d_mutex_unlock();
1006 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext1
*iface
,
1007 ID3D11Buffer
*buffer
, UINT offset
)
1009 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1010 struct d3d_buffer
*buffer_impl
;
1012 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
1014 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
1016 wined3d_mutex_lock();
1017 wined3d_device_dispatch_compute_indirect(device
->wined3d_device
,
1018 buffer_impl
->wined3d_buffer
, offset
);
1019 wined3d_mutex_unlock();
1022 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext1
*iface
,
1023 ID3D11RasterizerState
*rasterizer_state
)
1025 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1026 struct d3d_rasterizer_state
*rasterizer_state_impl
;
1027 const D3D11_RASTERIZER_DESC
*desc
;
1029 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1031 wined3d_mutex_lock();
1032 if (!(rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
1034 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
1035 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
1036 wined3d_mutex_unlock();
1040 wined3d_device_set_rasterizer_state(device
->wined3d_device
, rasterizer_state_impl
->wined3d_state
);
1042 desc
= &rasterizer_state_impl
->desc
;
1043 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
1044 wined3d_mutex_unlock();
1047 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext1
*iface
,
1048 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
1050 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1051 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
1054 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
1056 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
1059 for (i
= 0; i
< viewport_count
; ++i
)
1061 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
1062 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
1063 wined3d_vp
[i
].width
= viewports
[i
].Width
;
1064 wined3d_vp
[i
].height
= viewports
[i
].Height
;
1065 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
1066 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
1069 wined3d_mutex_lock();
1070 wined3d_device_set_viewports(device
->wined3d_device
, viewport_count
, wined3d_vp
);
1071 wined3d_mutex_unlock();
1074 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext1
*iface
,
1075 UINT rect_count
, const D3D11_RECT
*rects
)
1077 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1079 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
1081 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
1084 wined3d_mutex_lock();
1085 wined3d_device_set_scissor_rects(device
->wined3d_device
, rect_count
, rects
);
1086 wined3d_mutex_unlock();
1089 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext1
*iface
,
1090 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
1091 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
1093 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1094 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1095 struct wined3d_box wined3d_src_box
;
1097 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
1098 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
1099 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
1100 src_resource
, src_subresource_idx
, src_box
);
1102 if (!dst_resource
|| !src_resource
)
1106 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
1107 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
1109 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1110 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1111 wined3d_mutex_lock();
1112 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
1113 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
1114 wined3d_mutex_unlock();
1117 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext1
*iface
,
1118 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
1120 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1121 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1123 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1125 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1126 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1127 wined3d_mutex_lock();
1128 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1129 wined3d_mutex_unlock();
1132 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext1
*iface
,
1133 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1134 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1136 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1137 struct wined3d_resource
*wined3d_resource
;
1138 struct wined3d_box wined3d_box
;
1140 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1141 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1144 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1146 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1147 wined3d_mutex_lock();
1148 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1149 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, 0);
1150 wined3d_mutex_unlock();
1153 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext1
*iface
,
1154 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1156 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1157 struct d3d11_unordered_access_view
*uav
;
1158 struct d3d_buffer
*buffer_impl
;
1160 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1161 iface
, dst_buffer
, dst_offset
, src_view
);
1163 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1164 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1166 wined3d_mutex_lock();
1167 wined3d_device_copy_uav_counter(device
->wined3d_device
,
1168 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1169 wined3d_mutex_unlock();
1172 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext1
*iface
,
1173 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1175 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1176 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1177 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1180 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1181 iface
, render_target_view
, debug_float4(color_rgba
));
1186 wined3d_mutex_lock();
1187 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1188 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1189 ERR("Failed to clear view, hr %#x.\n", hr
);
1190 wined3d_mutex_unlock();
1193 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1
*iface
,
1194 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1196 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1197 struct d3d11_unordered_access_view
*view
;
1199 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1200 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1202 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1203 wined3d_mutex_lock();
1204 wined3d_device_clear_unordered_access_view_uint(device
->wined3d_device
,
1205 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1206 wined3d_mutex_unlock();
1209 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1
*iface
,
1210 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1212 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1213 iface
, unordered_access_view
, debug_float4(values
));
1216 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext1
*iface
,
1217 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1219 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1220 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1221 DWORD wined3d_flags
;
1224 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1225 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1230 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1232 wined3d_mutex_lock();
1233 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1234 wined3d_flags
, NULL
, depth
, stencil
)))
1235 ERR("Failed to clear view, hr %#x.\n", hr
);
1236 wined3d_mutex_unlock();
1239 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext1
*iface
,
1240 ID3D11ShaderResourceView
*view
)
1242 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D11ShaderResourceView(view
);
1244 TRACE("iface %p, view %p.\n", iface
, view
);
1246 wined3d_mutex_lock();
1247 wined3d_shader_resource_view_generate_mipmaps(srv
->wined3d_view
);
1248 wined3d_mutex_unlock();
1251 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1252 ID3D11Resource
*resource
, FLOAT min_lod
)
1254 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1257 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1258 ID3D11Resource
*resource
)
1260 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1265 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext1
*iface
,
1266 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1267 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1270 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1271 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1272 enum wined3d_format_id wined3d_format
;
1274 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
1275 "src_resource %p, src_subresource_idx %u, format %s.\n",
1276 iface
, dst_resource
, dst_subresource_idx
,
1277 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1279 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1280 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1281 wined3d_format
= wined3dformat_from_dxgi_format(format
);
1282 wined3d_mutex_lock();
1283 wined3d_device_resolve_sub_resource(device
->wined3d_device
,
1284 wined3d_dst_resource
, dst_subresource_idx
,
1285 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
1286 wined3d_mutex_unlock();
1289 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext1
*iface
,
1290 ID3D11CommandList
*command_list
, BOOL restore_state
)
1292 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1295 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext1
*iface
,
1296 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1298 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1301 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1302 iface
, start_slot
, view_count
, views
);
1304 wined3d_mutex_lock();
1305 for (i
= 0; i
< view_count
; ++i
)
1307 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1309 wined3d_device_set_hs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1310 view
? view
->wined3d_view
: NULL
);
1312 wined3d_mutex_unlock();
1315 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext1
*iface
,
1316 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1318 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1319 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1321 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1322 iface
, shader
, class_instances
, class_instance_count
);
1324 if (class_instances
)
1325 FIXME("Dynamic linking is not implemented yet.\n");
1327 wined3d_mutex_lock();
1328 wined3d_device_set_hull_shader(device
->wined3d_device
, hs
? hs
->wined3d_shader
: NULL
);
1329 wined3d_mutex_unlock();
1332 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext1
*iface
,
1333 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1335 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1338 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1339 iface
, start_slot
, sampler_count
, samplers
);
1341 wined3d_mutex_lock();
1342 for (i
= 0; i
< sampler_count
; ++i
)
1344 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1346 wined3d_device_set_hs_sampler(device
->wined3d_device
, start_slot
+ i
,
1347 sampler
? sampler
->wined3d_sampler
: NULL
);
1349 wined3d_mutex_unlock();
1352 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1353 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1355 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1356 iface
, start_slot
, buffer_count
, buffers
);
1358 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
1359 buffer_count
, buffers
);
1362 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext1
*iface
,
1363 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1365 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1368 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1369 iface
, start_slot
, view_count
, views
);
1371 wined3d_mutex_lock();
1372 for (i
= 0; i
< view_count
; ++i
)
1374 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1376 wined3d_device_set_ds_resource_view(device
->wined3d_device
, start_slot
+ i
,
1377 view
? view
->wined3d_view
: NULL
);
1379 wined3d_mutex_unlock();
1382 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext1
*iface
,
1383 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1385 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1386 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1388 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1389 iface
, shader
, class_instances
, class_instance_count
);
1391 if (class_instances
)
1392 FIXME("Dynamic linking is not implemented yet.\n");
1394 wined3d_mutex_lock();
1395 wined3d_device_set_domain_shader(device
->wined3d_device
, ds
? ds
->wined3d_shader
: NULL
);
1396 wined3d_mutex_unlock();
1399 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext1
*iface
,
1400 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1402 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1405 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1406 iface
, start_slot
, sampler_count
, samplers
);
1408 wined3d_mutex_lock();
1409 for (i
= 0; i
< sampler_count
; ++i
)
1411 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1413 wined3d_device_set_ds_sampler(device
->wined3d_device
, start_slot
+ i
,
1414 sampler
? sampler
->wined3d_sampler
: NULL
);
1416 wined3d_mutex_unlock();
1419 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1420 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1422 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1423 iface
, start_slot
, buffer_count
, buffers
);
1425 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
1426 buffer_count
, buffers
);
1429 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext1
*iface
,
1430 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1432 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1435 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1436 iface
, start_slot
, view_count
, views
);
1438 wined3d_mutex_lock();
1439 for (i
= 0; i
< view_count
; ++i
)
1441 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1443 wined3d_device_set_cs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1444 view
? view
->wined3d_view
: NULL
);
1446 wined3d_mutex_unlock();
1449 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
1450 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1452 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1455 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1456 iface
, start_slot
, view_count
, views
, initial_counts
);
1458 wined3d_mutex_lock();
1459 for (i
= 0; i
< view_count
; ++i
)
1461 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1463 wined3d_device_set_cs_uav(device
->wined3d_device
, start_slot
+ i
,
1464 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
1466 wined3d_mutex_unlock();
1469 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext1
*iface
,
1470 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1472 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1473 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1475 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1476 iface
, shader
, class_instances
, class_instance_count
);
1478 if (class_instances
)
1479 FIXME("Dynamic linking is not implemented yet.\n");
1481 wined3d_mutex_lock();
1482 wined3d_device_set_compute_shader(device
->wined3d_device
, cs
? cs
->wined3d_shader
: NULL
);
1483 wined3d_mutex_unlock();
1486 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext1
*iface
,
1487 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1489 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1492 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1493 iface
, start_slot
, sampler_count
, samplers
);
1495 wined3d_mutex_lock();
1496 for (i
= 0; i
< sampler_count
; ++i
)
1498 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1500 wined3d_device_set_cs_sampler(device
->wined3d_device
, start_slot
+ i
,
1501 sampler
? sampler
->wined3d_sampler
: NULL
);
1503 wined3d_mutex_unlock();
1506 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1507 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1509 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1510 iface
, start_slot
, buffer_count
, buffers
);
1512 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
1513 buffer_count
, buffers
);
1516 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1517 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1519 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1520 iface
, start_slot
, buffer_count
, buffers
);
1522 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
1523 buffer_count
, buffers
);
1526 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext1
*iface
,
1527 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1529 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1532 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1533 iface
, start_slot
, view_count
, views
);
1535 wined3d_mutex_lock();
1536 for (i
= 0; i
< view_count
; ++i
)
1538 struct wined3d_shader_resource_view
*wined3d_view
;
1539 struct d3d_shader_resource_view
*view_impl
;
1541 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1547 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1548 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1549 ID3D11ShaderResourceView_AddRef(views
[i
]);
1551 wined3d_mutex_unlock();
1554 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext1
*iface
,
1555 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1557 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1558 struct wined3d_shader
*wined3d_shader
;
1559 struct d3d_pixel_shader
*shader_impl
;
1561 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1562 iface
, shader
, class_instances
, class_instance_count
);
1564 if (class_instances
|| class_instance_count
)
1565 FIXME("Dynamic linking not implemented yet.\n");
1566 if (class_instance_count
)
1567 *class_instance_count
= 0;
1569 wined3d_mutex_lock();
1570 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1572 wined3d_mutex_unlock();
1577 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1578 wined3d_mutex_unlock();
1579 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1580 ID3D11PixelShader_AddRef(*shader
);
1583 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext1
*iface
,
1584 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1586 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1589 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1590 iface
, start_slot
, sampler_count
, samplers
);
1592 wined3d_mutex_lock();
1593 for (i
= 0; i
< sampler_count
; ++i
)
1595 struct wined3d_sampler
*wined3d_sampler
;
1596 struct d3d_sampler_state
*sampler_impl
;
1598 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1604 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1605 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1606 ID3D11SamplerState_AddRef(samplers
[i
]);
1608 wined3d_mutex_unlock();
1611 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext1
*iface
,
1612 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1614 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1615 struct d3d_vertex_shader
*shader_impl
;
1616 struct wined3d_shader
*wined3d_shader
;
1618 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1619 iface
, shader
, class_instances
, class_instance_count
);
1621 if (class_instances
|| class_instance_count
)
1622 FIXME("Dynamic linking not implemented yet.\n");
1623 if (class_instance_count
)
1624 *class_instance_count
= 0;
1626 wined3d_mutex_lock();
1627 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1629 wined3d_mutex_unlock();
1634 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1635 wined3d_mutex_unlock();
1636 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1637 ID3D11VertexShader_AddRef(*shader
);
1640 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1641 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1643 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1644 iface
, start_slot
, buffer_count
, buffers
);
1646 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
1647 buffer_count
, buffers
);
1650 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext1
*iface
,
1651 ID3D11InputLayout
**input_layout
)
1653 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1654 struct wined3d_vertex_declaration
*wined3d_declaration
;
1655 struct d3d_input_layout
*input_layout_impl
;
1657 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1659 wined3d_mutex_lock();
1660 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1662 wined3d_mutex_unlock();
1663 *input_layout
= NULL
;
1667 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1668 wined3d_mutex_unlock();
1669 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1670 ID3D11InputLayout_AddRef(*input_layout
);
1673 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext1
*iface
,
1674 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1676 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1679 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1680 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1682 wined3d_mutex_lock();
1683 for (i
= 0; i
< buffer_count
; ++i
)
1685 struct wined3d_buffer
*wined3d_buffer
= NULL
;
1686 struct d3d_buffer
*buffer_impl
;
1688 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1689 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1691 FIXME("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1698 if (!wined3d_buffer
)
1704 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1705 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1707 wined3d_mutex_unlock();
1710 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext1
*iface
,
1711 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1713 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1714 enum wined3d_format_id wined3d_format
;
1715 struct wined3d_buffer
*wined3d_buffer
;
1716 struct d3d_buffer
*buffer_impl
;
1718 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1720 wined3d_mutex_lock();
1721 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1722 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1723 if (!wined3d_buffer
)
1725 wined3d_mutex_unlock();
1730 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1731 wined3d_mutex_unlock();
1732 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1735 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1736 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1738 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1739 iface
, start_slot
, buffer_count
, buffers
);
1741 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
1742 buffer_count
, buffers
);
1745 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext1
*iface
,
1746 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1748 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1749 struct d3d_geometry_shader
*shader_impl
;
1750 struct wined3d_shader
*wined3d_shader
;
1752 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1753 iface
, shader
, class_instances
, class_instance_count
);
1755 if (class_instances
|| class_instance_count
)
1756 FIXME("Dynamic linking not implemented yet.\n");
1757 if (class_instance_count
)
1758 *class_instance_count
= 0;
1760 wined3d_mutex_lock();
1761 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1763 wined3d_mutex_unlock();
1768 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1769 wined3d_mutex_unlock();
1770 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1771 ID3D11GeometryShader_AddRef(*shader
);
1774 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
1775 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1777 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1778 enum wined3d_primitive_type primitive_type
;
1779 unsigned int patch_vertex_count
;
1781 TRACE("iface %p, topology %p.\n", iface
, topology
);
1783 wined3d_mutex_lock();
1784 wined3d_device_get_primitive_type(device
->wined3d_device
, &primitive_type
, &patch_vertex_count
);
1785 wined3d_mutex_unlock();
1787 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1790 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext1
*iface
,
1791 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1793 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1796 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1798 wined3d_mutex_lock();
1799 for (i
= 0; i
< view_count
; ++i
)
1801 struct wined3d_shader_resource_view
*wined3d_view
;
1802 struct d3d_shader_resource_view
*view_impl
;
1804 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1810 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1811 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1812 ID3D11ShaderResourceView_AddRef(views
[i
]);
1814 wined3d_mutex_unlock();
1817 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext1
*iface
,
1818 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1820 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1823 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1824 iface
, start_slot
, sampler_count
, samplers
);
1826 wined3d_mutex_lock();
1827 for (i
= 0; i
< sampler_count
; ++i
)
1829 struct wined3d_sampler
*wined3d_sampler
;
1830 struct d3d_sampler_state
*sampler_impl
;
1832 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1838 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1839 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1840 ID3D11SamplerState_AddRef(samplers
[i
]);
1842 wined3d_mutex_unlock();
1845 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext1
*iface
,
1846 ID3D11Predicate
**predicate
, BOOL
*value
)
1848 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1849 struct wined3d_query
*wined3d_predicate
;
1850 struct d3d_query
*predicate_impl
;
1852 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1854 wined3d_mutex_lock();
1855 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1857 wined3d_mutex_unlock();
1862 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1863 wined3d_mutex_unlock();
1864 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1865 ID3D11Predicate_AddRef(*predicate
);
1868 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext1
*iface
,
1869 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1871 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1874 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1876 wined3d_mutex_lock();
1877 for (i
= 0; i
< view_count
; ++i
)
1879 struct wined3d_shader_resource_view
*wined3d_view
;
1880 struct d3d_shader_resource_view
*view_impl
;
1882 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1888 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1889 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1890 ID3D11ShaderResourceView_AddRef(views
[i
]);
1892 wined3d_mutex_unlock();
1895 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext1
*iface
,
1896 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1898 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1901 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1902 iface
, start_slot
, sampler_count
, samplers
);
1904 wined3d_mutex_lock();
1905 for (i
= 0; i
< sampler_count
; ++i
)
1907 struct d3d_sampler_state
*sampler_impl
;
1908 struct wined3d_sampler
*wined3d_sampler
;
1910 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1916 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1917 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1918 ID3D11SamplerState_AddRef(samplers
[i
]);
1920 wined3d_mutex_unlock();
1923 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext1
*iface
,
1924 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1925 ID3D11DepthStencilView
**depth_stencil_view
)
1927 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1928 struct wined3d_rendertarget_view
*wined3d_view
;
1930 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1931 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1933 wined3d_mutex_lock();
1934 if (render_target_views
)
1936 struct d3d_rendertarget_view
*view_impl
;
1939 for (i
= 0; i
< render_target_view_count
; ++i
)
1941 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1942 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1944 render_target_views
[i
] = NULL
;
1948 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1949 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1953 if (depth_stencil_view
)
1955 struct d3d_depthstencil_view
*view_impl
;
1957 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1958 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1960 *depth_stencil_view
= NULL
;
1964 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1965 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1968 wined3d_mutex_unlock();
1971 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1972 ID3D11DeviceContext1
*iface
,
1973 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1974 ID3D11DepthStencilView
**depth_stencil_view
,
1975 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1976 ID3D11UnorderedAccessView
**unordered_access_views
)
1978 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1979 struct wined3d_unordered_access_view
*wined3d_view
;
1980 struct d3d11_unordered_access_view
*view_impl
;
1983 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1984 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1985 "unordered_access_views %p.\n",
1986 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1987 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1989 if (render_target_views
|| depth_stencil_view
)
1990 d3d11_immediate_context_OMGetRenderTargets(iface
, render_target_view_count
,
1991 render_target_views
, depth_stencil_view
);
1993 if (unordered_access_views
)
1995 wined3d_mutex_lock();
1996 for (i
= 0; i
< unordered_access_view_count
; ++i
)
1998 if (!(wined3d_view
= wined3d_device_get_unordered_access_view(device
->wined3d_device
,
1999 unordered_access_view_start_slot
+ i
)))
2001 unordered_access_views
[i
] = NULL
;
2005 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2006 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
2007 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
2009 wined3d_mutex_unlock();
2013 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext1
*iface
,
2014 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
2016 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2017 struct wined3d_blend_state
*wined3d_state
;
2018 struct d3d_blend_state
*blend_state_impl
;
2020 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
2021 iface
, blend_state
, blend_factor
, sample_mask
);
2023 wined3d_mutex_lock();
2024 if ((wined3d_state
= wined3d_device_get_blend_state(device
->wined3d_device
,
2025 (struct wined3d_color
*)blend_factor
, sample_mask
)))
2027 blend_state_impl
= wined3d_blend_state_get_parent(wined3d_state
);
2028 ID3D11BlendState_AddRef(*blend_state
= &blend_state_impl
->ID3D11BlendState_iface
);
2032 *blend_state
= NULL
;
2034 wined3d_mutex_unlock();
2037 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext1
*iface
,
2038 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
2040 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2041 struct wined3d_depth_stencil_state
*wined3d_state
;
2042 struct d3d_depthstencil_state
*state_impl
;
2044 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
2045 iface
, depth_stencil_state
, stencil_ref
);
2047 wined3d_mutex_lock();
2048 if ((wined3d_state
= wined3d_device_get_depth_stencil_state(device
->wined3d_device
, stencil_ref
)))
2050 state_impl
= wined3d_depth_stencil_state_get_parent(wined3d_state
);
2051 ID3D11DepthStencilState_AddRef(*depth_stencil_state
= &state_impl
->ID3D11DepthStencilState_iface
);
2055 *depth_stencil_state
= NULL
;
2057 wined3d_mutex_unlock();
2060 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext1
*iface
,
2061 UINT buffer_count
, ID3D11Buffer
**buffers
)
2063 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2066 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
2068 wined3d_mutex_lock();
2069 for (i
= 0; i
< buffer_count
; ++i
)
2071 struct wined3d_buffer
*wined3d_buffer
;
2072 struct d3d_buffer
*buffer_impl
;
2074 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
2080 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
2081 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
2082 ID3D11Buffer_AddRef(buffers
[i
]);
2084 wined3d_mutex_unlock();
2087 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext1
*iface
,
2088 ID3D11RasterizerState
**rasterizer_state
)
2090 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2091 struct d3d_rasterizer_state
*rasterizer_state_impl
;
2092 struct wined3d_rasterizer_state
*wined3d_state
;
2094 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
2096 wined3d_mutex_lock();
2097 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
2099 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
2100 ID3D11RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D11RasterizerState_iface
);
2104 *rasterizer_state
= NULL
;
2106 wined3d_mutex_unlock();
2109 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext1
*iface
,
2110 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
2112 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2113 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
2114 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
2116 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2118 if (!viewport_count
)
2121 wined3d_mutex_lock();
2122 wined3d_device_get_viewports(device
->wined3d_device
, &actual_count
, viewports
? wined3d_vp
: NULL
);
2123 wined3d_mutex_unlock();
2127 *viewport_count
= actual_count
;
2131 if (*viewport_count
> actual_count
)
2132 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
2134 *viewport_count
= min(actual_count
, *viewport_count
);
2135 for (i
= 0; i
< *viewport_count
; ++i
)
2137 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
2138 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
2139 viewports
[i
].Width
= wined3d_vp
[i
].width
;
2140 viewports
[i
].Height
= wined3d_vp
[i
].height
;
2141 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
2142 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
2146 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext1
*iface
,
2147 UINT
*rect_count
, D3D11_RECT
*rects
)
2149 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2150 unsigned int actual_count
;
2152 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2157 actual_count
= *rect_count
;
2159 wined3d_mutex_lock();
2160 wined3d_device_get_scissor_rects(device
->wined3d_device
, &actual_count
, rects
);
2161 wined3d_mutex_unlock();
2165 *rect_count
= actual_count
;
2169 if (*rect_count
> actual_count
)
2170 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
2173 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1
*iface
,
2174 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2176 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2179 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2181 wined3d_mutex_lock();
2182 for (i
= 0; i
< view_count
; ++i
)
2184 struct wined3d_shader_resource_view
*wined3d_view
;
2185 struct d3d_shader_resource_view
*view_impl
;
2187 if (!(wined3d_view
= wined3d_device_get_hs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2193 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2194 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2196 wined3d_mutex_unlock();
2199 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext1
*iface
,
2200 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2202 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2203 struct d3d11_hull_shader
*shader_impl
;
2204 struct wined3d_shader
*wined3d_shader
;
2206 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2207 iface
, shader
, class_instances
, class_instance_count
);
2209 if (class_instances
|| class_instance_count
)
2210 FIXME("Dynamic linking not implemented yet.\n");
2211 if (class_instance_count
)
2212 *class_instance_count
= 0;
2214 wined3d_mutex_lock();
2215 if (!(wined3d_shader
= wined3d_device_get_hull_shader(device
->wined3d_device
)))
2217 wined3d_mutex_unlock();
2222 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2223 wined3d_mutex_unlock();
2224 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2227 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext1
*iface
,
2228 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2230 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2233 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2234 iface
, start_slot
, sampler_count
, samplers
);
2236 wined3d_mutex_lock();
2237 for (i
= 0; i
< sampler_count
; ++i
)
2239 struct wined3d_sampler
*wined3d_sampler
;
2240 struct d3d_sampler_state
*sampler_impl
;
2242 if (!(wined3d_sampler
= wined3d_device_get_hs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2248 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2249 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2251 wined3d_mutex_unlock();
2254 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2255 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2257 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2258 iface
, start_slot
, buffer_count
, buffers
);
2260 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2261 buffer_count
, buffers
);
2264 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext1
*iface
,
2265 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2267 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2270 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2271 iface
, start_slot
, view_count
, views
);
2273 wined3d_mutex_lock();
2274 for (i
= 0; i
< view_count
; ++i
)
2276 struct wined3d_shader_resource_view
*wined3d_view
;
2277 struct d3d_shader_resource_view
*view_impl
;
2279 if (!(wined3d_view
= wined3d_device_get_ds_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2285 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2286 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2288 wined3d_mutex_unlock();
2291 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext1
*iface
,
2292 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2294 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2295 struct d3d11_domain_shader
*shader_impl
;
2296 struct wined3d_shader
*wined3d_shader
;
2298 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2299 iface
, shader
, class_instances
, class_instance_count
);
2301 if (class_instances
|| class_instance_count
)
2302 FIXME("Dynamic linking not implemented yet.\n");
2303 if (class_instance_count
)
2304 *class_instance_count
= 0;
2306 wined3d_mutex_lock();
2307 if (!(wined3d_shader
= wined3d_device_get_domain_shader(device
->wined3d_device
)))
2309 wined3d_mutex_unlock();
2314 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2315 wined3d_mutex_unlock();
2316 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2319 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext1
*iface
,
2320 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2322 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2325 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2326 iface
, start_slot
, sampler_count
, samplers
);
2328 wined3d_mutex_lock();
2329 for (i
= 0; i
< sampler_count
; ++i
)
2331 struct wined3d_sampler
*wined3d_sampler
;
2332 struct d3d_sampler_state
*sampler_impl
;
2334 if (!(wined3d_sampler
= wined3d_device_get_ds_sampler(device
->wined3d_device
, start_slot
+ i
)))
2340 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2341 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2343 wined3d_mutex_unlock();
2346 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2347 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2349 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2350 iface
, start_slot
, buffer_count
, buffers
);
2352 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2353 buffer_count
, buffers
);
2356 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext1
*iface
,
2357 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2359 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2362 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2364 wined3d_mutex_lock();
2365 for (i
= 0; i
< view_count
; ++i
)
2367 struct wined3d_shader_resource_view
*wined3d_view
;
2368 struct d3d_shader_resource_view
*view_impl
;
2370 if (!(wined3d_view
= wined3d_device_get_cs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2376 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2377 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2379 wined3d_mutex_unlock();
2382 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
2383 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2385 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2388 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2390 wined3d_mutex_lock();
2391 for (i
= 0; i
< view_count
; ++i
)
2393 struct wined3d_unordered_access_view
*wined3d_view
;
2394 struct d3d11_unordered_access_view
*view_impl
;
2396 if (!(wined3d_view
= wined3d_device_get_cs_uav(device
->wined3d_device
, start_slot
+ i
)))
2402 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2403 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2405 wined3d_mutex_unlock();
2408 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext1
*iface
,
2409 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2411 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2412 struct d3d11_compute_shader
*shader_impl
;
2413 struct wined3d_shader
*wined3d_shader
;
2415 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2416 iface
, shader
, class_instances
, class_instance_count
);
2418 if (class_instances
|| class_instance_count
)
2419 FIXME("Dynamic linking not implemented yet.\n");
2420 if (class_instance_count
)
2421 *class_instance_count
= 0;
2423 wined3d_mutex_lock();
2424 if (!(wined3d_shader
= wined3d_device_get_compute_shader(device
->wined3d_device
)))
2426 wined3d_mutex_unlock();
2431 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2432 wined3d_mutex_unlock();
2433 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2436 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext1
*iface
,
2437 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2439 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2442 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2443 iface
, start_slot
, sampler_count
, samplers
);
2445 wined3d_mutex_lock();
2446 for (i
= 0; i
< sampler_count
; ++i
)
2448 struct wined3d_sampler
*wined3d_sampler
;
2449 struct d3d_sampler_state
*sampler_impl
;
2451 if (!(wined3d_sampler
= wined3d_device_get_cs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2457 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2458 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2460 wined3d_mutex_unlock();
2463 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2464 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2466 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2467 iface
, start_slot
, buffer_count
, buffers
);
2469 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2470 buffer_count
, buffers
);
2473 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext1
*iface
)
2475 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2476 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
2479 TRACE("iface %p.\n", iface
);
2481 wined3d_mutex_lock();
2482 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
2483 wined3d_device_set_hull_shader(device
->wined3d_device
, NULL
);
2484 wined3d_device_set_domain_shader(device
->wined3d_device
, NULL
);
2485 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
2486 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
2487 wined3d_device_set_compute_shader(device
->wined3d_device
, NULL
);
2488 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
2490 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
2491 wined3d_device_set_hs_sampler(device
->wined3d_device
, i
, NULL
);
2492 wined3d_device_set_ds_sampler(device
->wined3d_device
, i
, NULL
);
2493 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
2494 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
2495 wined3d_device_set_cs_sampler(device
->wined3d_device
, i
, NULL
);
2497 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2499 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
2500 wined3d_device_set_hs_resource_view(device
->wined3d_device
, i
, NULL
);
2501 wined3d_device_set_ds_resource_view(device
->wined3d_device
, i
, NULL
);
2502 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
2503 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
2504 wined3d_device_set_cs_resource_view(device
->wined3d_device
, i
, NULL
);
2506 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
2508 for (j
= 0; j
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++j
)
2509 wined3d_device_set_constant_buffer(device
->wined3d_device
, i
, j
, NULL
);
2511 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2513 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
2515 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
2516 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
2517 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
, 0);
2518 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2520 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
2522 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
2523 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
2525 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
2526 wined3d_device_set_cs_uav(device
->wined3d_device
, i
, NULL
, ~0u);
2528 ID3D11DeviceContext1_OMSetDepthStencilState(iface
, NULL
, 0);
2529 ID3D11DeviceContext1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
2530 ID3D11DeviceContext1_RSSetViewports(iface
, 0, NULL
);
2531 ID3D11DeviceContext1_RSSetScissorRects(iface
, 0, NULL
);
2532 ID3D11DeviceContext1_RSSetState(iface
, NULL
);
2533 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
2535 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
2537 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
2538 wined3d_mutex_unlock();
2541 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext1
*iface
)
2543 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2545 TRACE("iface %p.\n", iface
);
2547 wined3d_mutex_lock();
2548 wined3d_device_flush(device
->wined3d_device
);
2549 wined3d_mutex_unlock();
2552 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext1
*iface
)
2554 TRACE("iface %p.\n", iface
);
2556 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
2559 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext1
*iface
)
2561 TRACE("iface %p.\n", iface
);
2566 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext1
*iface
,
2567 BOOL restore
, ID3D11CommandList
**command_list
)
2569 TRACE("iface %p, restore %#x, command_list %p.\n", iface
, restore
, command_list
);
2571 return DXGI_ERROR_INVALID_CALL
;
2574 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion1(ID3D11DeviceContext1
*iface
,
2575 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
2576 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
, UINT flags
)
2578 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2579 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
2580 struct wined3d_box wined3d_src_box
;
2582 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
2583 "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n",
2584 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
2585 src_resource
, src_subresource_idx
, src_box
, flags
);
2587 if (!dst_resource
|| !src_resource
)
2591 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
2592 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
2594 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
2595 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
2596 wined3d_mutex_lock();
2597 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
2598 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, flags
);
2599 wined3d_mutex_unlock();
2602 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource1(ID3D11DeviceContext1
*iface
,
2603 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
, const void *data
,
2604 UINT row_pitch
, UINT depth_pitch
, UINT flags
)
2606 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2607 struct wined3d_resource
*wined3d_resource
;
2608 struct wined3d_box wined3d_box
;
2610 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n",
2611 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
, flags
);
2614 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
,
2615 box
->front
, box
->back
);
2617 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
2618 wined3d_mutex_lock();
2619 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
, subresource_idx
,
2620 box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, flags
);
2621 wined3d_mutex_unlock();
2624 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardResource(ID3D11DeviceContext1
*iface
,
2625 ID3D11Resource
*resource
)
2627 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
2630 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
)
2632 FIXME("iface %p, view %p stub!\n", iface
, view
);
2635 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2636 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2637 const UINT
*num_constants
)
2639 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2640 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2643 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2644 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2645 const UINT
*num_constants
)
2647 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2648 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2651 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2652 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2653 const UINT
*num_constants
)
2655 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2656 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2659 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2660 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2661 const UINT
*num_constants
)
2663 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2664 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2667 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2668 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2669 const UINT
*num_constants
)
2671 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2672 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2675 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2676 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2677 const UINT
*num_constants
)
2679 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2680 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2683 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2684 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2686 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2687 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2690 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2691 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2693 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2694 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2697 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2698 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2700 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2701 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2704 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2705 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2707 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2708 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2711 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2712 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2714 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2715 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2718 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2719 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2721 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2722 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2725 static void d3d11_immediate_context_capture_state(ID3D11DeviceContext1
*iface
, struct d3d_device_context_state
*state
)
2727 wined3d_mutex_lock();
2729 d3d11_immediate_context_VSGetShader(iface
, &state
->vs
.shader
, NULL
, 0);
2730 d3d11_immediate_context_VSGetSamplers(iface
, 0,
2731 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, state
->vs
.samplers
);
2732 d3d11_immediate_context_VSGetShaderResources(iface
, 0,
2733 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, state
->vs
.srvs
);
2734 d3d11_immediate_context_VSGetConstantBuffers(iface
, 0,
2735 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, state
->vs
.cbs
);
2737 d3d11_immediate_context_GSGetShader(iface
, &state
->gs
.shader
, NULL
, 0);
2738 d3d11_immediate_context_GSGetSamplers(iface
, 0,
2739 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, state
->gs
.samplers
);
2740 d3d11_immediate_context_GSGetShaderResources(iface
, 0,
2741 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, state
->gs
.srvs
);
2742 d3d11_immediate_context_GSGetConstantBuffers(iface
, 0,
2743 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, state
->gs
.cbs
);
2745 d3d11_immediate_context_PSGetShader(iface
, &state
->ps
.shader
, NULL
, 0);
2746 d3d11_immediate_context_PSGetSamplers(iface
, 0,
2747 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, state
->ps
.samplers
);
2748 d3d11_immediate_context_PSGetShaderResources(iface
, 0,
2749 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, state
->ps
.srvs
);
2750 d3d11_immediate_context_PSGetConstantBuffers(iface
, 0,
2751 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, state
->ps
.cbs
);
2753 wined3d_mutex_unlock();
2756 static void d3d11_immediate_context_restore_state(ID3D11DeviceContext1
*iface
, struct d3d_device_context_state
*state
)
2758 wined3d_mutex_lock();
2760 d3d11_immediate_context_VSSetShader(iface
, state
->vs
.shader
, NULL
, 0);
2761 d3d11_immediate_context_VSSetSamplers(iface
, 0,
2762 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, state
->vs
.samplers
);
2763 d3d11_immediate_context_VSSetShaderResources(iface
, 0,
2764 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, state
->vs
.srvs
);
2765 d3d11_immediate_context_VSSetConstantBuffers(iface
, 0,
2766 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, state
->vs
.cbs
);
2768 d3d11_immediate_context_GSSetShader(iface
, state
->gs
.shader
, NULL
, 0);
2769 d3d11_immediate_context_GSSetSamplers(iface
, 0,
2770 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, state
->gs
.samplers
);
2771 d3d11_immediate_context_GSSetShaderResources(iface
, 0,
2772 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, state
->gs
.srvs
);
2773 d3d11_immediate_context_GSSetConstantBuffers(iface
, 0,
2774 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, state
->gs
.cbs
);
2776 d3d11_immediate_context_PSSetShader(iface
, state
->ps
.shader
, NULL
, 0);
2777 d3d11_immediate_context_PSSetSamplers(iface
, 0,
2778 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, state
->ps
.samplers
);
2779 d3d11_immediate_context_PSSetShaderResources(iface
, 0,
2780 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, state
->ps
.srvs
);
2781 d3d11_immediate_context_PSSetConstantBuffers(iface
, 0,
2782 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, state
->ps
.cbs
);
2784 wined3d_mutex_unlock();
2787 static void STDMETHODCALLTYPE
d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1
*iface
,
2788 ID3DDeviceContextState
*state
, ID3DDeviceContextState
**prev_state
)
2790 struct d3d_device_context_state
*state_impl
;
2791 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2793 FIXME("iface %p, state %p, prev_state %p semi-stub!\n", iface
, state
, prev_state
);
2795 if (prev_state
) *prev_state
= NULL
;
2798 wined3d_mutex_lock();
2802 if ((state_impl
= heap_alloc(sizeof(*state_impl
))))
2804 d3d_device_context_state_init(state_impl
, device
, &device
->state
->emulated_interface
);
2805 d3d11_immediate_context_capture_state(iface
, state_impl
);
2806 *prev_state
= &state_impl
->ID3DDeviceContextState_iface
;
2810 if ((state_impl
= impl_from_ID3DDeviceContextState(state
)))
2812 d3d11_immediate_context_restore_state(iface
, state_impl
);
2813 device
->state
->emulated_interface
= state_impl
->emulated_interface
;
2814 if (d3d_device_is_d3d10_active(device
))
2815 FIXME("D3D10 interface emulation not fully implemented yet!\n");
2817 wined3d_mutex_unlock();
2820 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2821 const FLOAT color
[4], const D3D11_RECT
*rect
, UINT num_rects
)
2823 FIXME("iface %p, view %p, color %p, rect %p, num_rects %u stub!\n", iface
, view
, color
, rect
, num_rects
);
2826 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardView1(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2827 const D3D11_RECT
*rects
, UINT num_rects
)
2829 FIXME("iface %p, view %p, rects %p, num_rects %u stub!\n", iface
, view
, rects
, num_rects
);
2832 static const struct ID3D11DeviceContext1Vtbl d3d11_immediate_context_vtbl
=
2834 /* IUnknown methods */
2835 d3d11_immediate_context_QueryInterface
,
2836 d3d11_immediate_context_AddRef
,
2837 d3d11_immediate_context_Release
,
2838 /* ID3D11DeviceChild methods */
2839 d3d11_immediate_context_GetDevice
,
2840 d3d11_immediate_context_GetPrivateData
,
2841 d3d11_immediate_context_SetPrivateData
,
2842 d3d11_immediate_context_SetPrivateDataInterface
,
2843 /* ID3D11DeviceContext methods */
2844 d3d11_immediate_context_VSSetConstantBuffers
,
2845 d3d11_immediate_context_PSSetShaderResources
,
2846 d3d11_immediate_context_PSSetShader
,
2847 d3d11_immediate_context_PSSetSamplers
,
2848 d3d11_immediate_context_VSSetShader
,
2849 d3d11_immediate_context_DrawIndexed
,
2850 d3d11_immediate_context_Draw
,
2851 d3d11_immediate_context_Map
,
2852 d3d11_immediate_context_Unmap
,
2853 d3d11_immediate_context_PSSetConstantBuffers
,
2854 d3d11_immediate_context_IASetInputLayout
,
2855 d3d11_immediate_context_IASetVertexBuffers
,
2856 d3d11_immediate_context_IASetIndexBuffer
,
2857 d3d11_immediate_context_DrawIndexedInstanced
,
2858 d3d11_immediate_context_DrawInstanced
,
2859 d3d11_immediate_context_GSSetConstantBuffers
,
2860 d3d11_immediate_context_GSSetShader
,
2861 d3d11_immediate_context_IASetPrimitiveTopology
,
2862 d3d11_immediate_context_VSSetShaderResources
,
2863 d3d11_immediate_context_VSSetSamplers
,
2864 d3d11_immediate_context_Begin
,
2865 d3d11_immediate_context_End
,
2866 d3d11_immediate_context_GetData
,
2867 d3d11_immediate_context_SetPredication
,
2868 d3d11_immediate_context_GSSetShaderResources
,
2869 d3d11_immediate_context_GSSetSamplers
,
2870 d3d11_immediate_context_OMSetRenderTargets
,
2871 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
2872 d3d11_immediate_context_OMSetBlendState
,
2873 d3d11_immediate_context_OMSetDepthStencilState
,
2874 d3d11_immediate_context_SOSetTargets
,
2875 d3d11_immediate_context_DrawAuto
,
2876 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
2877 d3d11_immediate_context_DrawInstancedIndirect
,
2878 d3d11_immediate_context_Dispatch
,
2879 d3d11_immediate_context_DispatchIndirect
,
2880 d3d11_immediate_context_RSSetState
,
2881 d3d11_immediate_context_RSSetViewports
,
2882 d3d11_immediate_context_RSSetScissorRects
,
2883 d3d11_immediate_context_CopySubresourceRegion
,
2884 d3d11_immediate_context_CopyResource
,
2885 d3d11_immediate_context_UpdateSubresource
,
2886 d3d11_immediate_context_CopyStructureCount
,
2887 d3d11_immediate_context_ClearRenderTargetView
,
2888 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
2889 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
2890 d3d11_immediate_context_ClearDepthStencilView
,
2891 d3d11_immediate_context_GenerateMips
,
2892 d3d11_immediate_context_SetResourceMinLOD
,
2893 d3d11_immediate_context_GetResourceMinLOD
,
2894 d3d11_immediate_context_ResolveSubresource
,
2895 d3d11_immediate_context_ExecuteCommandList
,
2896 d3d11_immediate_context_HSSetShaderResources
,
2897 d3d11_immediate_context_HSSetShader
,
2898 d3d11_immediate_context_HSSetSamplers
,
2899 d3d11_immediate_context_HSSetConstantBuffers
,
2900 d3d11_immediate_context_DSSetShaderResources
,
2901 d3d11_immediate_context_DSSetShader
,
2902 d3d11_immediate_context_DSSetSamplers
,
2903 d3d11_immediate_context_DSSetConstantBuffers
,
2904 d3d11_immediate_context_CSSetShaderResources
,
2905 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2906 d3d11_immediate_context_CSSetShader
,
2907 d3d11_immediate_context_CSSetSamplers
,
2908 d3d11_immediate_context_CSSetConstantBuffers
,
2909 d3d11_immediate_context_VSGetConstantBuffers
,
2910 d3d11_immediate_context_PSGetShaderResources
,
2911 d3d11_immediate_context_PSGetShader
,
2912 d3d11_immediate_context_PSGetSamplers
,
2913 d3d11_immediate_context_VSGetShader
,
2914 d3d11_immediate_context_PSGetConstantBuffers
,
2915 d3d11_immediate_context_IAGetInputLayout
,
2916 d3d11_immediate_context_IAGetVertexBuffers
,
2917 d3d11_immediate_context_IAGetIndexBuffer
,
2918 d3d11_immediate_context_GSGetConstantBuffers
,
2919 d3d11_immediate_context_GSGetShader
,
2920 d3d11_immediate_context_IAGetPrimitiveTopology
,
2921 d3d11_immediate_context_VSGetShaderResources
,
2922 d3d11_immediate_context_VSGetSamplers
,
2923 d3d11_immediate_context_GetPredication
,
2924 d3d11_immediate_context_GSGetShaderResources
,
2925 d3d11_immediate_context_GSGetSamplers
,
2926 d3d11_immediate_context_OMGetRenderTargets
,
2927 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2928 d3d11_immediate_context_OMGetBlendState
,
2929 d3d11_immediate_context_OMGetDepthStencilState
,
2930 d3d11_immediate_context_SOGetTargets
,
2931 d3d11_immediate_context_RSGetState
,
2932 d3d11_immediate_context_RSGetViewports
,
2933 d3d11_immediate_context_RSGetScissorRects
,
2934 d3d11_immediate_context_HSGetShaderResources
,
2935 d3d11_immediate_context_HSGetShader
,
2936 d3d11_immediate_context_HSGetSamplers
,
2937 d3d11_immediate_context_HSGetConstantBuffers
,
2938 d3d11_immediate_context_DSGetShaderResources
,
2939 d3d11_immediate_context_DSGetShader
,
2940 d3d11_immediate_context_DSGetSamplers
,
2941 d3d11_immediate_context_DSGetConstantBuffers
,
2942 d3d11_immediate_context_CSGetShaderResources
,
2943 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2944 d3d11_immediate_context_CSGetShader
,
2945 d3d11_immediate_context_CSGetSamplers
,
2946 d3d11_immediate_context_CSGetConstantBuffers
,
2947 d3d11_immediate_context_ClearState
,
2948 d3d11_immediate_context_Flush
,
2949 d3d11_immediate_context_GetType
,
2950 d3d11_immediate_context_GetContextFlags
,
2951 d3d11_immediate_context_FinishCommandList
,
2952 /* ID3D11DeviceContext1 methods */
2953 d3d11_immediate_context_CopySubresourceRegion1
,
2954 d3d11_immediate_context_UpdateSubresource1
,
2955 d3d11_immediate_context_DiscardResource
,
2956 d3d11_immediate_context_DiscardView
,
2957 d3d11_immediate_context_VSSetConstantBuffers1
,
2958 d3d11_immediate_context_HSSetConstantBuffers1
,
2959 d3d11_immediate_context_DSSetConstantBuffers1
,
2960 d3d11_immediate_context_GSSetConstantBuffers1
,
2961 d3d11_immediate_context_PSSetConstantBuffers1
,
2962 d3d11_immediate_context_CSSetConstantBuffers1
,
2963 d3d11_immediate_context_VSGetConstantBuffers1
,
2964 d3d11_immediate_context_HSGetConstantBuffers1
,
2965 d3d11_immediate_context_DSGetConstantBuffers1
,
2966 d3d11_immediate_context_GSGetConstantBuffers1
,
2967 d3d11_immediate_context_PSGetConstantBuffers1
,
2968 d3d11_immediate_context_CSGetConstantBuffers1
,
2969 d3d11_immediate_context_SwapDeviceContextState
,
2970 d3d11_immediate_context_ClearView
,
2971 d3d11_immediate_context_DiscardView1
,
2974 /* ID3D11Multithread methods */
2976 static inline struct d3d11_immediate_context
*impl_from_ID3D11Multithread(ID3D11Multithread
*iface
)
2978 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11Multithread_iface
);
2981 static HRESULT STDMETHODCALLTYPE
d3d11_multithread_QueryInterface(ID3D11Multithread
*iface
,
2982 REFIID iid
, void **out
)
2984 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2986 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
2988 return d3d11_immediate_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
2991 static ULONG STDMETHODCALLTYPE
d3d11_multithread_AddRef(ID3D11Multithread
*iface
)
2993 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2995 TRACE("iface %p.\n", iface
);
2997 return d3d11_immediate_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
3000 static ULONG STDMETHODCALLTYPE
d3d11_multithread_Release(ID3D11Multithread
*iface
)
3002 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
3004 TRACE("iface %p.\n", iface
);
3006 return d3d11_immediate_context_Release(&context
->ID3D11DeviceContext1_iface
);
3009 static void STDMETHODCALLTYPE
d3d11_multithread_Enter(ID3D11Multithread
*iface
)
3011 TRACE("iface %p.\n", iface
);
3013 wined3d_mutex_lock();
3016 static void STDMETHODCALLTYPE
d3d11_multithread_Leave(ID3D11Multithread
*iface
)
3018 TRACE("iface %p.\n", iface
);
3020 wined3d_mutex_unlock();
3023 static BOOL STDMETHODCALLTYPE
d3d11_multithread_SetMultithreadProtected(
3024 ID3D11Multithread
*iface
, BOOL enable
)
3026 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
3031 static BOOL STDMETHODCALLTYPE
d3d11_multithread_GetMultithreadProtected(ID3D11Multithread
*iface
)
3033 FIXME("iface %p stub!\n", iface
);
3038 static const struct ID3D11MultithreadVtbl d3d11_multithread_vtbl
=
3040 d3d11_multithread_QueryInterface
,
3041 d3d11_multithread_AddRef
,
3042 d3d11_multithread_Release
,
3043 d3d11_multithread_Enter
,
3044 d3d11_multithread_Leave
,
3045 d3d11_multithread_SetMultithreadProtected
,
3046 d3d11_multithread_GetMultithreadProtected
,
3049 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
3051 context
->ID3D11DeviceContext1_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
3052 context
->ID3D11Multithread_iface
.lpVtbl
= &d3d11_multithread_vtbl
;
3053 context
->refcount
= 1;
3055 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
3057 wined3d_private_store_init(&context
->private_store
);
3060 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
3062 wined3d_private_store_cleanup(&context
->private_store
);
3065 /* ID3D11Device methods */
3067 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device2
*iface
, REFIID iid
, void **out
)
3069 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3070 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
3073 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device2
*iface
)
3075 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3076 return IUnknown_AddRef(device
->outer_unk
);
3079 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device2
*iface
)
3081 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3082 return IUnknown_Release(device
->outer_unk
);
3085 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device2
*iface
, const D3D11_BUFFER_DESC
*desc
,
3086 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
3088 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3089 struct d3d_buffer
*object
;
3092 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
3094 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
3097 *buffer
= &object
->ID3D11Buffer_iface
;
3102 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device2
*iface
,
3103 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
3105 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3106 struct d3d_texture1d
*object
;
3109 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3111 if (FAILED(hr
= d3d_texture1d_create(device
, desc
, data
, &object
)))
3114 *texture
= &object
->ID3D11Texture1D_iface
;
3119 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device2
*iface
,
3120 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
3122 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3123 struct d3d_texture2d
*object
;
3126 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3128 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
3131 *texture
= &object
->ID3D11Texture2D_iface
;
3136 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device2
*iface
,
3137 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
3139 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3140 struct d3d_texture3d
*object
;
3143 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
3145 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
3148 *texture
= &object
->ID3D11Texture3D_iface
;
3153 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device2
*iface
,
3154 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
3156 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3157 struct d3d_shader_resource_view
*object
;
3160 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3163 return E_INVALIDARG
;
3165 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
3168 *view
= &object
->ID3D11ShaderResourceView_iface
;
3173 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device2
*iface
,
3174 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
3176 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3177 struct d3d11_unordered_access_view
*object
;
3180 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3182 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
3185 *view
= &object
->ID3D11UnorderedAccessView_iface
;
3190 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device2
*iface
,
3191 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
3193 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3194 struct d3d_rendertarget_view
*object
;
3197 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3200 return E_INVALIDARG
;
3202 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
3205 *view
= &object
->ID3D11RenderTargetView_iface
;
3210 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device2
*iface
,
3211 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
3213 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3214 struct d3d_depthstencil_view
*object
;
3217 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3219 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
3222 *view
= &object
->ID3D11DepthStencilView_iface
;
3227 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device2
*iface
,
3228 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
3229 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
3231 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3232 struct d3d_input_layout
*object
;
3235 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
3236 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
3237 shader_byte_code_length
, input_layout
);
3239 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
3240 shader_byte_code
, shader_byte_code_length
, &object
)))
3243 *input_layout
= &object
->ID3D11InputLayout_iface
;
3248 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device2
*iface
, const void *byte_code
,
3249 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
3251 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3252 struct d3d_vertex_shader
*object
;
3255 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3256 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3259 FIXME("Class linkage is not implemented yet.\n");
3261 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3264 *shader
= &object
->ID3D11VertexShader_iface
;
3269 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device2
*iface
, const void *byte_code
,
3270 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3272 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3273 struct d3d_geometry_shader
*object
;
3276 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3277 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3280 FIXME("Class linkage is not implemented yet.\n");
3282 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3283 NULL
, 0, NULL
, 0, 0, &object
)))
3286 *shader
= &object
->ID3D11GeometryShader_iface
;
3291 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2
*iface
,
3292 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
3293 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
3294 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3296 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3297 struct d3d_geometry_shader
*object
;
3300 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
3301 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
3302 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
3303 rasterizer_stream
, class_linkage
, shader
);
3306 FIXME("Class linkage is not implemented yet.\n");
3308 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3309 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
3315 *shader
= &object
->ID3D11GeometryShader_iface
;
3320 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device2
*iface
, const void *byte_code
,
3321 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
3323 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3324 struct d3d_pixel_shader
*object
;
3327 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3328 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3331 FIXME("Class linkage is not implemented yet.\n");
3333 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3336 *shader
= &object
->ID3D11PixelShader_iface
;
3341 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device2
*iface
, const void *byte_code
,
3342 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
3344 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3345 struct d3d11_hull_shader
*object
;
3348 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3349 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3352 FIXME("Class linkage is not implemented yet.\n");
3354 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3357 *shader
= &object
->ID3D11HullShader_iface
;
3362 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device2
*iface
, const void *byte_code
,
3363 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
3365 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3366 struct d3d11_domain_shader
*object
;
3369 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3370 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3373 FIXME("Class linkage is not implemented yet.\n");
3375 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3378 *shader
= &object
->ID3D11DomainShader_iface
;
3383 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device2
*iface
, const void *byte_code
,
3384 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
3386 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3387 struct d3d11_compute_shader
*object
;
3390 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3391 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3394 FIXME("Class linkage is not implemented yet.\n");
3396 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3399 *shader
= &object
->ID3D11ComputeShader_iface
;
3404 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device2
*iface
,
3405 ID3D11ClassLinkage
**class_linkage
)
3407 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3408 struct d3d11_class_linkage
*object
;
3411 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3413 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3416 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3421 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device2
*iface
,
3422 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3424 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3425 struct d3d_blend_state
*object
;
3428 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3430 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3433 *blend_state
= &object
->ID3D11BlendState_iface
;
3438 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device2
*iface
,
3439 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3441 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3442 struct d3d_depthstencil_state
*object
;
3445 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3447 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3450 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3455 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device2
*iface
,
3456 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3458 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3459 struct d3d_rasterizer_state
*object
;
3462 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3464 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
3467 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
3472 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device2
*iface
,
3473 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3475 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3476 struct d3d_sampler_state
*object
;
3479 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3481 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3484 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3489 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device2
*iface
,
3490 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3492 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3493 struct d3d_query
*object
;
3496 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3498 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3503 *query
= &object
->ID3D11Query_iface
;
3507 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3511 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device2
*iface
, const D3D11_QUERY_DESC
*desc
,
3512 ID3D11Predicate
**predicate
)
3514 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3515 struct d3d_query
*object
;
3518 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3520 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3525 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3529 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3533 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3534 ID3D11Counter
**counter
)
3536 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3541 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device2
*iface
, UINT flags
,
3542 ID3D11DeviceContext
**context
)
3544 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3550 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device2
*iface
, HANDLE resource
, REFIID iid
,
3553 FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface
, resource
, debugstr_guid(iid
), out
);
3558 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device2
*iface
, DXGI_FORMAT format
,
3559 UINT
*format_support
)
3561 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3562 struct wined3d_device_creation_parameters params
;
3563 struct wined3d_adapter
*wined3d_adapter
;
3564 enum wined3d_format_id wined3d_format
;
3565 D3D_FEATURE_LEVEL feature_level
;
3566 struct wined3d
*wined3d
;
3571 enum wined3d_resource_type rtype
;
3572 unsigned int bind_flags
;
3574 D3D11_FORMAT_SUPPORT flag
;
3578 {WINED3D_RTYPE_BUFFER
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_BUFFER
},
3579 {WINED3D_RTYPE_TEXTURE_1D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE1D
},
3580 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3581 {WINED3D_RTYPE_TEXTURE_3D
, WINED3D_BIND_SHADER_RESOURCE
, 0, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3582 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, 0, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3583 {WINED3D_RTYPE_NONE
, WINED3D_BIND_DEPTH_STENCIL
, 0, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3584 {WINED3D_RTYPE_NONE
, WINED3D_BIND_UNORDERED_ACCESS
, 0, D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW
},
3585 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_WRAPANDMIP
, D3D11_FORMAT_SUPPORT_MIP
},
3586 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, WINED3DUSAGE_QUERY_GENMIPMAP
, D3D11_FORMAT_SUPPORT_MIP_AUTOGEN
},
3587 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
, D3D11_FORMAT_SUPPORT_BLENDABLE
},
3591 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3593 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3594 if (format
&& !wined3d_format
)
3596 WARN("Invalid format %#x.\n", format
);
3597 *format_support
= 0;
3601 *format_support
= 0;
3603 wined3d_mutex_lock();
3604 feature_level
= device
->feature_level
;
3605 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3606 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3607 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3608 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3610 hr
= wined3d_check_device_format(wined3d
, wined3d_adapter
, params
.device_type
,
3611 WINED3DFMT_UNKNOWN
, flag_mapping
[i
].usage
, flag_mapping
[i
].bind_flags
, flag_mapping
[i
].rtype
, wined3d_format
);
3612 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOMIPGEN
)
3614 if (hr
!= WINED3D_OK
)
3616 WARN("Failed to check device format support, hr %#x.\n", hr
);
3617 wined3d_mutex_unlock();
3621 *format_support
|= flag_mapping
[i
].flag
;
3623 wined3d_mutex_unlock();
3625 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
3626 *format_support
&= ~D3D11_FORMAT_SUPPORT_BUFFER
;
3628 if (*format_support
& (D3D11_FORMAT_SUPPORT_TEXTURE1D
3629 | D3D11_FORMAT_SUPPORT_TEXTURE2D
| D3D11_FORMAT_SUPPORT_TEXTURE3D
))
3631 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_LOAD
;
3632 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
;
3633 *format_support
|= D3D11_FORMAT_SUPPORT_TEXTURECUBE
;
3635 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3636 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER
;
3638 if (*format_support
& D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
)
3640 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
3641 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
;
3643 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3644 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
;
3648 /* d3d11 requires 4 and 8 sample counts support for formats reported to
3649 * support multisample. */
3650 if (wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3651 TRUE
, WINED3D_MULTISAMPLE_4_SAMPLES
, NULL
) == WINED3D_OK
&&
3652 wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
, wined3d_format
,
3653 TRUE
, WINED3D_MULTISAMPLE_8_SAMPLES
, NULL
) == WINED3D_OK
)
3655 *format_support
|= D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE
3656 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
3657 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
;
3663 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2
*iface
,
3664 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3666 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3667 struct wined3d_device_creation_parameters params
;
3668 struct wined3d_adapter
*wined3d_adapter
;
3669 struct wined3d
*wined3d
;
3672 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3673 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3675 if (!quality_level_count
)
3676 return E_INVALIDARG
;
3678 *quality_level_count
= 0;
3682 if (sample_count
== 1)
3684 *quality_level_count
= 1;
3687 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3690 wined3d_mutex_lock();
3691 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3692 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3693 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3694 hr
= wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
,
3695 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3696 wined3d_mutex_unlock();
3698 if (hr
== WINED3DERR_INVALIDCALL
)
3699 return E_INVALIDARG
;
3700 if (hr
== WINED3DERR_NOTAVAILABLE
)
3705 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device2
*iface
, D3D11_COUNTER_INFO
*info
)
3707 FIXME("iface %p, info %p stub!\n", iface
, info
);
3710 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3711 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3712 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3714 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3715 "units %p, units_length %p, description %p, description_length %p stub!\n",
3716 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3717 units
, units_length
, description
, description_length
);
3722 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device2
*iface
, D3D11_FEATURE feature
,
3723 void *feature_support_data
, UINT feature_support_data_size
)
3725 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3726 struct wined3d_caps wined3d_caps
;
3729 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3730 iface
, feature
, feature_support_data
, feature_support_data_size
);
3734 case D3D11_FEATURE_THREADING
:
3736 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
3737 if (feature_support_data_size
!= sizeof(*threading_data
))
3739 WARN("Invalid data size.\n");
3740 return E_INVALIDARG
;
3743 /* We lie about the threading support to make Tomb Raider 2013 and
3744 * Deus Ex: Human Revolution happy. */
3745 FIXME("Returning fake threading support data.\n");
3746 threading_data
->DriverConcurrentCreates
= TRUE
;
3747 threading_data
->DriverCommandLists
= TRUE
;
3751 case D3D11_FEATURE_DOUBLES
:
3753 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
3754 if (feature_support_data_size
!= sizeof(*doubles_data
))
3756 WARN("Invalid data size.\n");
3757 return E_INVALIDARG
;
3760 wined3d_mutex_lock();
3761 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3762 wined3d_mutex_unlock();
3765 WARN("Failed to get device caps, hr %#x.\n", hr
);
3769 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
3773 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
3775 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
3776 if (feature_support_data_size
!= sizeof(*options
))
3778 WARN("Invalid data size.\n");
3779 return E_INVALIDARG
;
3782 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
3786 case D3D11_FEATURE_D3D11_OPTIONS
:
3788 D3D11_FEATURE_DATA_D3D11_OPTIONS
*options
= feature_support_data
;
3789 if (feature_support_data_size
!= sizeof(*options
))
3791 WARN("Invalid data size.\n");
3792 return E_INVALIDARG
;
3795 FIXME("Returning fake Options support data.\n");
3796 options
->OutputMergerLogicOp
= FALSE
;
3797 options
->UAVOnlyRenderingForcedSampleCount
= FALSE
;
3798 options
->DiscardAPIsSeenByDriver
= FALSE
;
3799 options
->FlagsForUpdateAndCopySeenByDriver
= FALSE
;
3800 options
->ClearView
= FALSE
;
3801 options
->CopyWithOverlap
= FALSE
;
3802 options
->ConstantBufferPartialUpdate
= FALSE
;
3803 options
->ConstantBufferOffsetting
= FALSE
;
3804 options
->MapNoOverwriteOnDynamicConstantBuffer
= FALSE
;
3805 options
->MapNoOverwriteOnDynamicBufferSRV
= FALSE
;
3806 options
->MultisampleRTVWithForcedSampleCountOne
= FALSE
;
3807 options
->SAD4ShaderInstructions
= FALSE
;
3808 options
->ExtendedDoublesShaderInstructions
= FALSE
;
3809 options
->ExtendedResourceSharing
= FALSE
;
3813 case D3D11_FEATURE_D3D11_OPTIONS1
:
3815 D3D11_FEATURE_DATA_D3D11_OPTIONS1
*options
= feature_support_data
;
3816 if (feature_support_data_size
!= sizeof(*options
))
3818 WARN("Invalid data size.\n");
3819 return E_INVALIDARG
;
3822 FIXME("Returning fake Options1 support data.\n");
3823 options
->TiledResourcesTier
= D3D11_TILED_RESOURCES_NOT_SUPPORTED
;
3824 options
->MinMaxFiltering
= FALSE
;
3825 options
->ClearViewAlsoSupportsDepthOnlyFormats
= FALSE
;
3826 options
->MapOnDefaultBuffers
= FALSE
;
3830 case D3D11_FEATURE_D3D11_OPTIONS3
:
3832 D3D11_FEATURE_DATA_D3D11_OPTIONS3
*options
= feature_support_data
;
3833 if (feature_support_data_size
!= sizeof(*options
))
3835 WARN("Invalid data size.\n");
3836 return E_INVALIDARG
;
3839 wined3d_mutex_lock();
3840 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3841 wined3d_mutex_unlock();
3844 WARN("Failed to get device caps, hr %#x.\n", hr
);
3848 options
->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
3849 = wined3d_caps
.viewport_array_index_any_shader
;
3853 case D3D11_FEATURE_ARCHITECTURE_INFO
:
3855 D3D11_FEATURE_DATA_ARCHITECTURE_INFO
*options
= feature_support_data
;
3856 if (feature_support_data_size
!= sizeof(*options
))
3858 WARN("Invalid data size.\n");
3859 return E_INVALIDARG
;
3862 FIXME("Returning fake data architecture info.\n");
3863 options
->TileBasedDeferredRenderer
= FALSE
;
3868 FIXME("Unhandled feature %#x.\n", feature
);
3873 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
3874 UINT
*data_size
, void *data
)
3876 IDXGIDevice
*dxgi_device
;
3879 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3881 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3883 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
3884 IDXGIDevice_Release(dxgi_device
);
3889 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
3890 UINT data_size
, const void *data
)
3892 IDXGIDevice
*dxgi_device
;
3895 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3897 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3899 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
3900 IDXGIDevice_Release(dxgi_device
);
3905 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device2
*iface
, REFGUID guid
,
3906 const IUnknown
*data
)
3908 IDXGIDevice
*dxgi_device
;
3911 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
3913 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3915 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
3916 IDXGIDevice_Release(dxgi_device
);
3921 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device2
*iface
)
3923 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3925 TRACE("iface %p.\n", iface
);
3927 return device
->feature_level
;
3930 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device2
*iface
)
3932 FIXME("iface %p stub!\n", iface
);
3937 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device2
*iface
)
3939 WARN("iface %p stub!\n", iface
);
3944 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device2
*iface
,
3945 ID3D11DeviceContext
**immediate_context
)
3947 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3949 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3951 *immediate_context
= (ID3D11DeviceContext
*)&device
->immediate_context
.ID3D11DeviceContext1_iface
;
3952 ID3D11DeviceContext_AddRef(*immediate_context
);
3955 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device2
*iface
, UINT flags
)
3957 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
3962 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device2
*iface
)
3964 FIXME("iface %p stub!\n", iface
);
3969 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext1(ID3D11Device2
*iface
,
3970 ID3D11DeviceContext1
**immediate_context
)
3972 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3974 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3976 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext1_iface
;
3977 ID3D11DeviceContext1_AddRef(*immediate_context
);
3980 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext1(ID3D11Device2
*iface
, UINT flags
,
3981 ID3D11DeviceContext1
**context
)
3983 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3988 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState1(ID3D11Device2
*iface
,
3989 const D3D11_BLEND_DESC1
*desc
, ID3D11BlendState1
**state
)
3991 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
3996 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState1(ID3D11Device2
*iface
,
3997 const D3D11_RASTERIZER_DESC1
*desc
, ID3D11RasterizerState1
**state
)
3999 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
4004 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeviceContextState(ID3D11Device2
*iface
, UINT flags
,
4005 const D3D_FEATURE_LEVEL
*feature_levels
, UINT feature_levels_count
, UINT sdk_version
,
4006 REFIID emulated_interface
, D3D_FEATURE_LEVEL
*chosen_feature_level
, ID3DDeviceContextState
**state
)
4008 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
4009 struct d3d_device_context_state
*state_impl
;
4011 FIXME("iface %p, flags %#x, feature_levels %p, feature_level_count %u, sdk_version %u, "
4012 "emulated_interface %s, chosen_feature_level %p, state %p semi-stub!\n", iface
, flags
, feature_levels
,
4013 feature_levels_count
, sdk_version
, debugstr_guid(emulated_interface
), chosen_feature_level
, state
);
4015 if (chosen_feature_level
)
4016 FIXME("Device context state feature level not implemented yet.\n");
4021 if (!(state_impl
= heap_alloc(sizeof(*state_impl
))))
4022 return E_OUTOFMEMORY
;
4023 d3d_device_context_state_init(state_impl
, device
, emulated_interface
);
4024 *state
= &state_impl
->ID3DDeviceContextState_iface
;
4027 device
->d3d11_only
= FALSE
;
4028 if (chosen_feature_level
) *chosen_feature_level
= ID3D11Device2_GetFeatureLevel(iface
);
4029 return state
? S_OK
: S_FALSE
;
4032 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource1(ID3D11Device2
*iface
, HANDLE handle
,
4033 REFIID iid
, void **resource
)
4035 FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface
, handle
, debugstr_guid(iid
), resource
);
4040 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResourceByName(ID3D11Device2
*iface
, const WCHAR
*name
,
4041 DWORD access
, REFIID iid
, void **resource
)
4043 FIXME("iface %p, name %s, access %#x, iid %s, resource %p stub!\n", iface
, debugstr_w(name
), access
,
4044 debugstr_guid(iid
), resource
);
4049 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext2(ID3D11Device2
*iface
,
4050 ID3D11DeviceContext2
**context
)
4052 FIXME("iface %p, context %p stub!\n", iface
, context
);
4055 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext2(ID3D11Device2
*iface
,
4056 UINT flags
, ID3D11DeviceContext2
**context
)
4058 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
4063 static void STDMETHODCALLTYPE
d3d11_device_GetResourceTiling(ID3D11Device2
*iface
,
4064 ID3D11Resource
*resource
, UINT
*tile_count
, D3D11_PACKED_MIP_DESC
*mip_desc
,
4065 D3D11_TILE_SHAPE
*tile_shape
, UINT
*subresource_tiling_count
, UINT first_subresource_tiling
,
4066 D3D11_SUBRESOURCE_TILING
*subresource_tiling
)
4068 FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, "
4069 "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n",
4070 iface
, resource
, tile_count
, mip_desc
, tile_shape
,
4071 subresource_tiling_count
, first_subresource_tiling
, subresource_tiling
);
4074 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2
*iface
,
4075 DXGI_FORMAT format
, UINT sample_count
, UINT flags
, UINT
*quality_level_count
)
4077 FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n",
4078 iface
, format
, sample_count
, flags
, quality_level_count
);
4083 static const struct ID3D11Device2Vtbl d3d11_device_vtbl
=
4085 /* IUnknown methods */
4086 d3d11_device_QueryInterface
,
4087 d3d11_device_AddRef
,
4088 d3d11_device_Release
,
4089 /* ID3D11Device methods */
4090 d3d11_device_CreateBuffer
,
4091 d3d11_device_CreateTexture1D
,
4092 d3d11_device_CreateTexture2D
,
4093 d3d11_device_CreateTexture3D
,
4094 d3d11_device_CreateShaderResourceView
,
4095 d3d11_device_CreateUnorderedAccessView
,
4096 d3d11_device_CreateRenderTargetView
,
4097 d3d11_device_CreateDepthStencilView
,
4098 d3d11_device_CreateInputLayout
,
4099 d3d11_device_CreateVertexShader
,
4100 d3d11_device_CreateGeometryShader
,
4101 d3d11_device_CreateGeometryShaderWithStreamOutput
,
4102 d3d11_device_CreatePixelShader
,
4103 d3d11_device_CreateHullShader
,
4104 d3d11_device_CreateDomainShader
,
4105 d3d11_device_CreateComputeShader
,
4106 d3d11_device_CreateClassLinkage
,
4107 d3d11_device_CreateBlendState
,
4108 d3d11_device_CreateDepthStencilState
,
4109 d3d11_device_CreateRasterizerState
,
4110 d3d11_device_CreateSamplerState
,
4111 d3d11_device_CreateQuery
,
4112 d3d11_device_CreatePredicate
,
4113 d3d11_device_CreateCounter
,
4114 d3d11_device_CreateDeferredContext
,
4115 d3d11_device_OpenSharedResource
,
4116 d3d11_device_CheckFormatSupport
,
4117 d3d11_device_CheckMultisampleQualityLevels
,
4118 d3d11_device_CheckCounterInfo
,
4119 d3d11_device_CheckCounter
,
4120 d3d11_device_CheckFeatureSupport
,
4121 d3d11_device_GetPrivateData
,
4122 d3d11_device_SetPrivateData
,
4123 d3d11_device_SetPrivateDataInterface
,
4124 d3d11_device_GetFeatureLevel
,
4125 d3d11_device_GetCreationFlags
,
4126 d3d11_device_GetDeviceRemovedReason
,
4127 d3d11_device_GetImmediateContext
,
4128 d3d11_device_SetExceptionMode
,
4129 d3d11_device_GetExceptionMode
,
4130 /* ID3D11Device1 methods */
4131 d3d11_device_GetImmediateContext1
,
4132 d3d11_device_CreateDeferredContext1
,
4133 d3d11_device_CreateBlendState1
,
4134 d3d11_device_CreateRasterizerState1
,
4135 d3d11_device_CreateDeviceContextState
,
4136 d3d11_device_OpenSharedResource1
,
4137 d3d11_device_OpenSharedResourceByName
,
4138 /* ID3D11Device2 methods */
4139 d3d11_device_GetImmediateContext2
,
4140 d3d11_device_CreateDeferredContext2
,
4141 d3d11_device_GetResourceTiling
,
4142 d3d11_device_CheckMultisampleQualityLevels1
,
4145 /* Inner IUnknown methods */
4147 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
4149 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
4152 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
4154 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4156 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
4158 if (IsEqualGUID(riid
, &IID_ID3D11Device2
)
4159 || IsEqualGUID(riid
, &IID_ID3D11Device1
)
4160 || IsEqualGUID(riid
, &IID_ID3D11Device
)
4161 || IsEqualGUID(riid
, &IID_IUnknown
))
4163 *out
= &device
->ID3D11Device2_iface
;
4165 else if (!device
->d3d11_only
4166 && (IsEqualGUID(riid
, &IID_ID3D10Device1
)
4167 || IsEqualGUID(riid
, &IID_ID3D10Device
)))
4169 *out
= &device
->ID3D10Device1_iface
;
4171 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
4173 *out
= &device
->ID3D10Multithread_iface
;
4175 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
4177 *out
= &device
->IWineDXGIDeviceParent_iface
;
4181 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
4183 return E_NOINTERFACE
;
4186 IUnknown_AddRef((IUnknown
*)*out
);
4190 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
4192 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4193 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
4195 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
4200 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
4202 struct d3d_device
*device
= impl_from_IUnknown(iface
);
4203 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
4205 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
4209 if (device
->state
) d3d_device_context_state_private_release(device
->state
);
4210 d3d11_immediate_context_destroy(&device
->immediate_context
);
4211 if (device
->wined3d_device
)
4213 wined3d_mutex_lock();
4214 wined3d_device_decref(device
->wined3d_device
);
4215 wined3d_mutex_unlock();
4217 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
4218 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
4219 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4220 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4226 /* IUnknown methods */
4228 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID iid
,
4231 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4232 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4235 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
4237 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4238 return IUnknown_AddRef(device
->outer_unk
);
4241 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
4243 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4244 return IUnknown_Release(device
->outer_unk
);
4247 /* ID3D10Device methods */
4249 static void d3d10_device_get_constant_buffers(ID3D10Device1
*iface
,
4250 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4252 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4255 wined3d_mutex_lock();
4256 for (i
= 0; i
< buffer_count
; ++i
)
4258 struct wined3d_buffer
*wined3d_buffer
;
4259 struct d3d_buffer
*buffer_impl
;
4261 if (!(wined3d_buffer
= wined3d_device_get_constant_buffer(device
->wined3d_device
,
4262 type
, start_slot
+ i
)))
4268 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4269 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4270 ID3D10Buffer_AddRef(buffers
[i
]);
4272 wined3d_mutex_unlock();
4275 static void d3d10_device_set_constant_buffers(ID3D10Device1
*iface
,
4276 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4278 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4281 wined3d_mutex_lock();
4282 for (i
= 0; i
< buffer_count
; ++i
)
4284 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4286 wined3d_device_set_constant_buffer(device
->wined3d_device
, type
, start_slot
+ i
,
4287 buffer
? buffer
->wined3d_buffer
: NULL
);
4289 wined3d_mutex_unlock();
4292 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
4293 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4295 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4296 iface
, start_slot
, buffer_count
, buffers
);
4298 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
4299 buffer_count
, buffers
);
4302 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
4303 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4305 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4308 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4309 iface
, start_slot
, view_count
, views
);
4311 wined3d_mutex_lock();
4312 for (i
= 0; i
< view_count
; ++i
)
4314 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4316 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
4317 view
? view
->wined3d_view
: NULL
);
4319 wined3d_mutex_unlock();
4322 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
4323 ID3D10PixelShader
*shader
)
4325 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4326 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
4328 TRACE("iface %p, shader %p\n", iface
, shader
);
4330 wined3d_mutex_lock();
4331 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
4332 wined3d_mutex_unlock();
4335 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
4336 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4338 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4341 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4342 iface
, start_slot
, sampler_count
, samplers
);
4344 wined3d_mutex_lock();
4345 for (i
= 0; i
< sampler_count
; ++i
)
4347 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4349 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
4350 sampler
? sampler
->wined3d_sampler
: NULL
);
4352 wined3d_mutex_unlock();
4355 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
4356 ID3D10VertexShader
*shader
)
4358 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4359 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
4361 TRACE("iface %p, shader %p\n", iface
, shader
);
4363 wined3d_mutex_lock();
4364 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
4365 wined3d_mutex_unlock();
4368 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
4369 UINT start_index_location
, INT base_vertex_location
)
4371 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4373 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
4374 iface
, index_count
, start_index_location
, base_vertex_location
);
4376 wined3d_mutex_lock();
4377 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
4378 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
4379 wined3d_mutex_unlock();
4382 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
4383 UINT start_vertex_location
)
4385 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4387 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
4388 iface
, vertex_count
, start_vertex_location
);
4390 wined3d_mutex_lock();
4391 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
4392 wined3d_mutex_unlock();
4395 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
4396 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4398 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4399 iface
, start_slot
, buffer_count
, buffers
);
4401 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
4402 buffer_count
, buffers
);
4405 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
4406 ID3D10InputLayout
*input_layout
)
4408 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4409 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
4411 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
4413 wined3d_mutex_lock();
4414 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
4415 layout
? layout
->wined3d_decl
: NULL
);
4416 wined3d_mutex_unlock();
4419 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
4420 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
4422 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4425 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
4426 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4428 wined3d_mutex_lock();
4429 for (i
= 0; i
< buffer_count
; ++i
)
4431 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4433 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
4434 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
4436 wined3d_mutex_unlock();
4439 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
4440 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
4442 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4443 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
4445 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
4446 iface
, buffer
, debug_dxgi_format(format
), offset
);
4448 wined3d_mutex_lock();
4449 wined3d_device_set_index_buffer(device
->wined3d_device
,
4450 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
4451 wined3dformat_from_dxgi_format(format
), offset
);
4452 wined3d_mutex_unlock();
4455 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
4456 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
4457 INT base_vertex_location
, UINT start_instance_location
)
4459 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4461 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
4462 "base_vertex_location %d, start_instance_location %u.\n",
4463 iface
, instance_index_count
, instance_count
, start_index_location
,
4464 base_vertex_location
, start_instance_location
);
4466 wined3d_mutex_lock();
4467 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
4468 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
4469 instance_index_count
, start_instance_location
, instance_count
);
4470 wined3d_mutex_unlock();
4473 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
4474 UINT instance_vertex_count
, UINT instance_count
,
4475 UINT start_vertex_location
, UINT start_instance_location
)
4477 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4479 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
4480 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
4481 start_vertex_location
, start_instance_location
);
4483 wined3d_mutex_lock();
4484 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
4485 instance_vertex_count
, start_instance_location
, instance_count
);
4486 wined3d_mutex_unlock();
4489 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
4490 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4492 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4493 iface
, start_slot
, buffer_count
, buffers
);
4495 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
4496 buffer_count
, buffers
);
4499 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
4501 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4502 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
4504 TRACE("iface %p, shader %p.\n", iface
, shader
);
4506 wined3d_mutex_lock();
4507 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
4508 wined3d_mutex_unlock();
4511 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
4512 D3D10_PRIMITIVE_TOPOLOGY topology
)
4514 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4516 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
4518 wined3d_mutex_lock();
4519 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
, 0);
4520 wined3d_mutex_unlock();
4523 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
4524 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4526 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4529 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4530 iface
, start_slot
, view_count
, views
);
4532 wined3d_mutex_lock();
4533 for (i
= 0; i
< view_count
; ++i
)
4535 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4537 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
4538 view
? view
->wined3d_view
: NULL
);
4540 wined3d_mutex_unlock();
4543 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
4544 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4546 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4549 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4550 iface
, start_slot
, sampler_count
, samplers
);
4552 wined3d_mutex_lock();
4553 for (i
= 0; i
< sampler_count
; ++i
)
4555 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4557 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
4558 sampler
? sampler
->wined3d_sampler
: NULL
);
4560 wined3d_mutex_unlock();
4563 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
4565 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4566 struct d3d_query
*query
;
4568 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
4570 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
4571 wined3d_mutex_lock();
4572 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
4573 wined3d_mutex_unlock();
4576 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
4577 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4579 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4582 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4583 iface
, start_slot
, view_count
, views
);
4585 wined3d_mutex_lock();
4586 for (i
= 0; i
< view_count
; ++i
)
4588 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4590 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
4591 view
? view
->wined3d_view
: NULL
);
4593 wined3d_mutex_unlock();
4596 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
4597 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4599 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4602 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4603 iface
, start_slot
, sampler_count
, samplers
);
4605 wined3d_mutex_lock();
4606 for (i
= 0; i
< sampler_count
; ++i
)
4608 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4610 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
4611 sampler
? sampler
->wined3d_sampler
: NULL
);
4613 wined3d_mutex_unlock();
4616 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
4617 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
4618 ID3D10DepthStencilView
*depth_stencil_view
)
4620 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4621 struct d3d_depthstencil_view
*dsv
;
4624 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4625 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
4627 wined3d_mutex_lock();
4628 for (i
= 0; i
< render_target_view_count
; ++i
)
4630 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
4632 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
4633 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
4635 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4637 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4640 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4641 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
4642 dsv
? dsv
->wined3d_view
: NULL
);
4643 wined3d_mutex_unlock();
4646 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
4647 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
4649 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4650 struct d3d_blend_state
*blend_state_object
;
4652 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
4653 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
4655 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
4656 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4657 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
4660 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
4661 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
4663 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4664 struct d3d_depthstencil_state
*ds_state_object
;
4666 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
4667 iface
, depth_stencil_state
, stencil_ref
);
4669 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
4670 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4671 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
4674 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
4675 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
4677 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4678 unsigned int count
, i
;
4680 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
4682 count
= min(target_count
, D3D10_SO_BUFFER_SLOT_COUNT
);
4683 wined3d_mutex_lock();
4684 for (i
= 0; i
< count
; ++i
)
4686 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
4688 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
4689 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
4692 for (i
= count
; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4694 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4696 wined3d_mutex_unlock();
4699 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
4701 FIXME("iface %p stub!\n", iface
);
4704 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
4706 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4707 struct d3d_rasterizer_state
*rasterizer_state_object
;
4709 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4711 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
4712 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4713 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
4716 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
4717 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
4719 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4720 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
4723 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
4725 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
4728 for (i
= 0; i
< viewport_count
; ++i
)
4730 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
4731 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
4732 wined3d_vp
[i
].width
= viewports
[i
].Width
;
4733 wined3d_vp
[i
].height
= viewports
[i
].Height
;
4734 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
4735 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
4738 wined3d_mutex_lock();
4739 wined3d_device_set_viewports(device
->wined3d_device
, viewport_count
, wined3d_vp
);
4740 wined3d_mutex_unlock();
4743 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
4744 UINT rect_count
, const D3D10_RECT
*rects
)
4746 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4748 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
4750 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
4753 wined3d_mutex_lock();
4754 wined3d_device_set_scissor_rects(device
->wined3d_device
, rect_count
, rects
);
4755 wined3d_mutex_unlock();
4758 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
4759 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
4760 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
4762 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4763 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4764 struct wined3d_box wined3d_src_box
;
4766 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
4767 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
4768 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
4769 src_resource
, src_subresource_idx
, src_box
);
4771 if (!dst_resource
|| !src_resource
)
4775 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
4776 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
4778 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4779 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4780 wined3d_mutex_lock();
4781 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
4782 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
4783 wined3d_mutex_unlock();
4786 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
4787 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
4789 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4790 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4792 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
4794 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4795 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4796 wined3d_mutex_lock();
4797 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
4798 wined3d_mutex_unlock();
4801 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
4802 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
4803 const void *data
, UINT row_pitch
, UINT depth_pitch
)
4805 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4806 ID3D11Resource
*d3d11_resource
;
4808 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
4809 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
4811 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
4812 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4813 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
4814 ID3D11Resource_Release(d3d11_resource
);
4817 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
4818 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
4820 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4821 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
4822 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
4825 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
4826 iface
, render_target_view
, debug_float4(color_rgba
));
4831 wined3d_mutex_lock();
4832 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4833 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
4834 ERR("Failed to clear view, hr %#x.\n", hr
);
4835 wined3d_mutex_unlock();
4838 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
4839 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
4841 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4842 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4843 DWORD wined3d_flags
;
4846 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
4847 iface
, depth_stencil_view
, flags
, depth
, stencil
);
4852 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
4854 wined3d_mutex_lock();
4855 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4856 wined3d_flags
, NULL
, depth
, stencil
)))
4857 ERR("Failed to clear view, hr %#x.\n", hr
);
4858 wined3d_mutex_unlock();
4861 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
4862 ID3D10ShaderResourceView
*view
)
4864 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D10ShaderResourceView(view
);
4866 TRACE("iface %p, view %p.\n", iface
, view
);
4868 wined3d_mutex_lock();
4869 wined3d_shader_resource_view_generate_mipmaps(srv
->wined3d_view
);
4870 wined3d_mutex_unlock();
4873 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
4874 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
4875 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
4877 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4878 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4879 enum wined3d_format_id wined3d_format
;
4881 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
4882 "src_resource %p, src_subresource_idx %u, format %s.\n",
4883 iface
, dst_resource
, dst_subresource_idx
,
4884 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
4886 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4887 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4888 wined3d_format
= wined3dformat_from_dxgi_format(format
);
4889 wined3d_mutex_lock();
4890 wined3d_device_resolve_sub_resource(device
->wined3d_device
,
4891 wined3d_dst_resource
, dst_subresource_idx
,
4892 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
4893 wined3d_mutex_unlock();
4896 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
4897 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4899 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4900 iface
, start_slot
, buffer_count
, buffers
);
4902 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, buffer_count
,
4906 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
4907 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4909 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4912 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4913 iface
, start_slot
, view_count
, views
);
4915 wined3d_mutex_lock();
4916 for (i
= 0; i
< view_count
; ++i
)
4918 struct wined3d_shader_resource_view
*wined3d_view
;
4919 struct d3d_shader_resource_view
*view_impl
;
4921 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4927 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4928 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4929 ID3D10ShaderResourceView_AddRef(views
[i
]);
4931 wined3d_mutex_unlock();
4934 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
4936 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4937 struct d3d_pixel_shader
*shader_impl
;
4938 struct wined3d_shader
*wined3d_shader
;
4940 TRACE("iface %p, shader %p.\n", iface
, shader
);
4942 wined3d_mutex_lock();
4943 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
4945 wined3d_mutex_unlock();
4950 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4951 wined3d_mutex_unlock();
4952 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
4953 ID3D10PixelShader_AddRef(*shader
);
4956 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
4957 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4959 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4962 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4963 iface
, start_slot
, sampler_count
, samplers
);
4965 wined3d_mutex_lock();
4966 for (i
= 0; i
< sampler_count
; ++i
)
4968 struct d3d_sampler_state
*sampler_impl
;
4969 struct wined3d_sampler
*wined3d_sampler
;
4971 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
4977 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4978 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4979 ID3D10SamplerState_AddRef(samplers
[i
]);
4981 wined3d_mutex_unlock();
4984 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
4986 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4987 struct d3d_vertex_shader
*shader_impl
;
4988 struct wined3d_shader
*wined3d_shader
;
4990 TRACE("iface %p, shader %p.\n", iface
, shader
);
4992 wined3d_mutex_lock();
4993 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
4995 wined3d_mutex_unlock();
5000 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5001 wined3d_mutex_unlock();
5002 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
5003 ID3D10VertexShader_AddRef(*shader
);
5006 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
5007 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5009 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5010 iface
, start_slot
, buffer_count
, buffers
);
5012 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, buffer_count
,
5016 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
5018 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5019 struct wined3d_vertex_declaration
*wined3d_declaration
;
5020 struct d3d_input_layout
*input_layout_impl
;
5022 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
5024 wined3d_mutex_lock();
5025 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
5027 wined3d_mutex_unlock();
5028 *input_layout
= NULL
;
5032 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
5033 wined3d_mutex_unlock();
5034 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
5035 ID3D10InputLayout_AddRef(*input_layout
);
5038 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
5039 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
5041 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5044 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
5045 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
5047 wined3d_mutex_lock();
5048 for (i
= 0; i
< buffer_count
; ++i
)
5050 struct wined3d_buffer
*wined3d_buffer
= NULL
;
5051 struct d3d_buffer
*buffer_impl
;
5053 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
5054 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
5055 ERR("Failed to get vertex buffer.\n");
5057 if (!wined3d_buffer
)
5063 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5064 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5065 ID3D10Buffer_AddRef(buffers
[i
]);
5067 wined3d_mutex_unlock();
5070 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
5071 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
5073 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5074 enum wined3d_format_id wined3d_format
;
5075 struct wined3d_buffer
*wined3d_buffer
;
5076 struct d3d_buffer
*buffer_impl
;
5078 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
5080 wined3d_mutex_lock();
5081 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
5082 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
5083 if (!wined3d_buffer
)
5085 wined3d_mutex_unlock();
5090 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5091 wined3d_mutex_unlock();
5092 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
5093 ID3D10Buffer_AddRef(*buffer
);
5096 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
5097 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
5099 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
5100 iface
, start_slot
, buffer_count
, buffers
);
5102 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, buffer_count
,
5106 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
5108 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5109 struct d3d_geometry_shader
*shader_impl
;
5110 struct wined3d_shader
*wined3d_shader
;
5112 TRACE("iface %p, shader %p.\n", iface
, shader
);
5114 wined3d_mutex_lock();
5115 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
5117 wined3d_mutex_unlock();
5122 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
5123 wined3d_mutex_unlock();
5124 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
5125 ID3D10GeometryShader_AddRef(*shader
);
5128 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
5129 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
5131 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5133 TRACE("iface %p, topology %p.\n", iface
, topology
);
5135 wined3d_mutex_lock();
5136 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
, NULL
);
5137 wined3d_mutex_unlock();
5140 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
5141 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5143 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5146 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5147 iface
, start_slot
, view_count
, views
);
5149 wined3d_mutex_lock();
5150 for (i
= 0; i
< view_count
; ++i
)
5152 struct wined3d_shader_resource_view
*wined3d_view
;
5153 struct d3d_shader_resource_view
*view_impl
;
5155 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
5161 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5162 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5163 ID3D10ShaderResourceView_AddRef(views
[i
]);
5165 wined3d_mutex_unlock();
5168 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
5169 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5171 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5174 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5175 iface
, start_slot
, sampler_count
, samplers
);
5177 wined3d_mutex_lock();
5178 for (i
= 0; i
< sampler_count
; ++i
)
5180 struct d3d_sampler_state
*sampler_impl
;
5181 struct wined3d_sampler
*wined3d_sampler
;
5183 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
5189 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5190 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5191 ID3D10SamplerState_AddRef(samplers
[i
]);
5193 wined3d_mutex_unlock();
5196 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
5197 ID3D10Predicate
**predicate
, BOOL
*value
)
5199 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5200 struct wined3d_query
*wined3d_predicate
;
5201 struct d3d_query
*predicate_impl
;
5203 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
5205 wined3d_mutex_lock();
5206 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
5208 wined3d_mutex_unlock();
5213 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
5214 wined3d_mutex_unlock();
5215 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
5216 ID3D10Predicate_AddRef(*predicate
);
5219 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
5220 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
5222 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5225 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
5226 iface
, start_slot
, view_count
, views
);
5228 wined3d_mutex_lock();
5229 for (i
= 0; i
< view_count
; ++i
)
5231 struct wined3d_shader_resource_view
*wined3d_view
;
5232 struct d3d_shader_resource_view
*view_impl
;
5234 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
5240 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
5241 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
5242 ID3D10ShaderResourceView_AddRef(views
[i
]);
5244 wined3d_mutex_unlock();
5247 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
5248 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
5250 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5253 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
5254 iface
, start_slot
, sampler_count
, samplers
);
5256 wined3d_mutex_lock();
5257 for (i
= 0; i
< sampler_count
; ++i
)
5259 struct d3d_sampler_state
*sampler_impl
;
5260 struct wined3d_sampler
*wined3d_sampler
;
5262 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
5268 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5269 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5270 ID3D10SamplerState_AddRef(samplers
[i
]);
5272 wined3d_mutex_unlock();
5275 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
5276 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
5278 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5279 struct wined3d_rendertarget_view
*wined3d_view
;
5281 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
5282 iface
, view_count
, render_target_views
, depth_stencil_view
);
5284 wined3d_mutex_lock();
5285 if (render_target_views
)
5287 struct d3d_rendertarget_view
*view_impl
;
5290 for (i
= 0; i
< view_count
; ++i
)
5292 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
5293 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5295 render_target_views
[i
] = NULL
;
5299 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
5300 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
5304 if (depth_stencil_view
)
5306 struct d3d_depthstencil_view
*view_impl
;
5308 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
5309 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5311 *depth_stencil_view
= NULL
;
5315 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
5316 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
5319 wined3d_mutex_unlock();
5322 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
5323 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
5325 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5326 ID3D11BlendState
*d3d11_blend_state
;
5328 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
5329 iface
, blend_state
, blend_factor
, sample_mask
);
5331 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5332 &d3d11_blend_state
, blend_factor
, sample_mask
);
5334 if (d3d11_blend_state
)
5335 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
5337 *blend_state
= NULL
;
5340 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
5341 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
5343 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5344 ID3D11DepthStencilState
*d3d11_iface
;
5346 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
5347 iface
, depth_stencil_state
, stencil_ref
);
5349 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5350 &d3d11_iface
, stencil_ref
);
5353 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
5355 *depth_stencil_state
= NULL
;
5358 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
5359 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
5361 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5364 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
5365 iface
, buffer_count
, buffers
, offsets
);
5367 wined3d_mutex_lock();
5368 for (i
= 0; i
< buffer_count
; ++i
)
5370 struct wined3d_buffer
*wined3d_buffer
;
5371 struct d3d_buffer
*buffer_impl
;
5373 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
5379 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5380 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5381 ID3D10Buffer_AddRef(buffers
[i
]);
5383 wined3d_mutex_unlock();
5386 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
5388 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5389 struct d3d_rasterizer_state
*rasterizer_state_impl
;
5390 struct wined3d_rasterizer_state
*wined3d_state
;
5392 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5394 wined3d_mutex_lock();
5395 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
5397 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
5398 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
5402 *rasterizer_state
= NULL
;
5404 wined3d_mutex_unlock();
5407 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
5408 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
5410 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5411 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5412 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
5414 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
5416 if (!viewport_count
)
5419 wined3d_mutex_lock();
5420 wined3d_device_get_viewports(device
->wined3d_device
, &actual_count
, viewports
? wined3d_vp
: NULL
);
5421 wined3d_mutex_unlock();
5425 *viewport_count
= actual_count
;
5429 if (*viewport_count
> actual_count
)
5430 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
5432 *viewport_count
= min(actual_count
, *viewport_count
);
5433 for (i
= 0; i
< *viewport_count
; ++i
)
5435 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
5436 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
5437 viewports
[i
].Width
= wined3d_vp
[i
].width
;
5438 viewports
[i
].Height
= wined3d_vp
[i
].height
;
5439 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
5440 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
5444 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
5446 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5447 unsigned int actual_count
;
5449 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
5454 actual_count
= *rect_count
;
5456 wined3d_mutex_lock();
5457 wined3d_device_get_scissor_rects(device
->wined3d_device
, &actual_count
, rects
);
5458 wined3d_mutex_unlock();
5462 *rect_count
= actual_count
;
5466 if (*rect_count
> actual_count
)
5467 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
5470 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
5472 TRACE("iface %p.\n", iface
);
5474 /* In the current implementation the device is never removed, so we can
5475 * just return S_OK here. */
5480 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
5482 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
5487 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
5489 FIXME("iface %p stub!\n", iface
);
5494 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
5495 REFGUID guid
, UINT
*data_size
, void *data
)
5497 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5499 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5501 return d3d11_device_GetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5504 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
5505 REFGUID guid
, UINT data_size
, const void *data
)
5507 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5509 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5511 return d3d11_device_SetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5514 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
5515 REFGUID guid
, const IUnknown
*data
)
5517 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5519 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
5521 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device2_iface
, guid
, data
);
5524 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
5526 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5528 TRACE("iface %p.\n", iface
);
5530 d3d11_immediate_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
5533 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
5535 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5537 TRACE("iface %p.\n", iface
);
5539 wined3d_mutex_lock();
5540 wined3d_device_flush(device
->wined3d_device
);
5541 wined3d_mutex_unlock();
5544 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
5545 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
5547 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5548 D3D11_BUFFER_DESC d3d11_desc
;
5549 struct d3d_buffer
*object
;
5552 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
5554 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
5555 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5556 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5557 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5558 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5559 d3d11_desc
.StructureByteStride
= 0;
5561 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5564 *buffer
= &object
->ID3D10Buffer_iface
;
5569 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
5570 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
5572 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5573 D3D11_TEXTURE1D_DESC d3d11_desc
;
5574 struct d3d_texture1d
*object
;
5577 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5579 d3d11_desc
.Width
= desc
->Width
;
5580 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5581 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5582 d3d11_desc
.Format
= desc
->Format
;
5583 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5584 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5585 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5586 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5588 if (FAILED(hr
= d3d_texture1d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5591 *texture
= &object
->ID3D10Texture1D_iface
;
5596 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
5597 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5598 ID3D10Texture2D
**texture
)
5600 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5601 D3D11_TEXTURE2D_DESC d3d11_desc
;
5602 struct d3d_texture2d
*object
;
5605 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5607 d3d11_desc
.Width
= desc
->Width
;
5608 d3d11_desc
.Height
= desc
->Height
;
5609 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5610 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5611 d3d11_desc
.Format
= desc
->Format
;
5612 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
5613 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5614 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5615 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5616 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5618 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5621 *texture
= &object
->ID3D10Texture2D_iface
;
5626 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
5627 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5628 ID3D10Texture3D
**texture
)
5630 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5631 D3D11_TEXTURE3D_DESC d3d11_desc
;
5632 struct d3d_texture3d
*object
;
5635 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5637 d3d11_desc
.Width
= desc
->Width
;
5638 d3d11_desc
.Height
= desc
->Height
;
5639 d3d11_desc
.Depth
= desc
->Depth
;
5640 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5641 d3d11_desc
.Format
= desc
->Format
;
5642 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5643 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5644 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5645 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5647 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5650 *texture
= &object
->ID3D10Texture3D_iface
;
5655 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
5656 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
5658 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5659 struct d3d_shader_resource_view
*object
;
5660 ID3D11Resource
*d3d11_resource
;
5663 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5666 return E_INVALIDARG
;
5668 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5670 ERR("Resource does not implement ID3D11Resource.\n");
5674 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
5676 ID3D11Resource_Release(d3d11_resource
);
5680 *view
= &object
->ID3D10ShaderResourceView1_iface
;
5685 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
5686 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
5688 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5690 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
5691 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
5694 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
5695 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
5697 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5698 struct d3d_rendertarget_view
*object
;
5699 ID3D11Resource
*d3d11_resource
;
5702 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5705 return E_INVALIDARG
;
5707 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5709 ERR("Resource does not implement ID3D11Resource.\n");
5713 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
5714 ID3D11Resource_Release(d3d11_resource
);
5718 *view
= &object
->ID3D10RenderTargetView_iface
;
5723 static D3D11_DSV_DIMENSION
d3d11_dsv_dimension_from_d3d10(D3D10_DSV_DIMENSION dim
)
5725 return (D3D11_DSV_DIMENSION
)dim
;
5728 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
5729 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
5731 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5732 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
5733 struct d3d_depthstencil_view
*object
;
5734 ID3D11Resource
*d3d11_resource
;
5737 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5741 d3d11_desc
.Format
= desc
->Format
;
5742 d3d11_desc
.ViewDimension
= d3d11_dsv_dimension_from_d3d10(desc
->ViewDimension
);
5743 d3d11_desc
.Flags
= 0;
5744 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
5747 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5749 ERR("Resource does not implement ID3D11Resource.\n");
5753 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
5754 ID3D11Resource_Release(d3d11_resource
);
5758 *view
= &object
->ID3D10DepthStencilView_iface
;
5763 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
5764 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
5765 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
5766 ID3D10InputLayout
**input_layout
)
5768 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5769 struct d3d_input_layout
*object
;
5772 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
5773 "shader_byte_code_length %lu, input_layout %p\n",
5774 iface
, element_descs
, element_count
, shader_byte_code
,
5775 shader_byte_code_length
, input_layout
);
5777 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
5778 shader_byte_code
, shader_byte_code_length
, &object
)))
5781 *input_layout
= &object
->ID3D10InputLayout_iface
;
5786 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
5787 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
5789 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5790 struct d3d_vertex_shader
*object
;
5793 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5794 iface
, byte_code
, byte_code_length
, shader
);
5796 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5799 *shader
= &object
->ID3D10VertexShader_iface
;
5804 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
5805 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
5807 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5808 struct d3d_geometry_shader
*object
;
5811 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5812 iface
, byte_code
, byte_code_length
, shader
);
5814 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5815 NULL
, 0, NULL
, 0, 0, &object
)))
5818 *shader
= &object
->ID3D10GeometryShader_iface
;
5823 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
5824 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
5825 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
5827 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5828 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
5829 struct d3d_geometry_shader
*object
;
5830 unsigned int i
, stride_count
= 1;
5833 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
5834 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
5835 iface
, byte_code
, byte_code_length
, output_stream_decls
,
5836 output_stream_decl_count
, output_stream_stride
, shader
);
5838 if (!output_stream_decl_count
&& output_stream_stride
)
5840 WARN("Stride must be 0 when declaration entry count is 0.\n");
5842 return E_INVALIDARG
;
5845 if (output_stream_decl_count
5846 && !(so_entries
= heap_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
5848 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
5850 return E_OUTOFMEMORY
;
5853 for (i
= 0; i
< output_stream_decl_count
; ++i
)
5855 so_entries
[i
].Stream
= 0;
5856 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
5857 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
5858 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
5859 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
5860 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
5862 if (output_stream_decls
[i
].OutputSlot
)
5865 if (output_stream_stride
)
5867 WARN("Stride must be 0 when multiple output slots are used.\n");
5868 heap_free(so_entries
);
5870 return E_INVALIDARG
;
5875 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5876 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
5877 heap_free(so_entries
);
5884 *shader
= &object
->ID3D10GeometryShader_iface
;
5889 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
5890 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
5892 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5893 struct d3d_pixel_shader
*object
;
5896 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5897 iface
, byte_code
, byte_code_length
, shader
);
5899 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5902 *shader
= &object
->ID3D10PixelShader_iface
;
5907 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
5908 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
5910 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5911 struct d3d_blend_state
*object
;
5914 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5916 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
5919 *blend_state
= &object
->ID3D10BlendState1_iface
;
5924 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
5925 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
5927 D3D10_BLEND_DESC1 d3d10_1_desc
;
5930 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5933 return E_INVALIDARG
;
5935 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
5936 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
5937 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
5939 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
5940 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
5941 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
5944 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5946 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
5947 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
5948 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
5949 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
5950 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
5951 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
5952 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
5953 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
5956 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
5959 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
5960 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
5962 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5963 struct d3d_depthstencil_state
*object
;
5966 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
5968 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
5971 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
5976 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
5977 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
5979 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5980 struct d3d_rasterizer_state
*object
;
5983 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
5985 if (FAILED(hr
= d3d_rasterizer_state_create(device
, (const D3D11_RASTERIZER_DESC
*)desc
, &object
)))
5988 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
5993 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
5994 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
5996 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5997 struct d3d_sampler_state
*object
;
6000 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
6002 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
6005 *sampler_state
= &object
->ID3D10SamplerState_iface
;
6010 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
6011 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
6013 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6014 struct d3d_query
*object
;
6017 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
6019 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
6024 *query
= &object
->ID3D10Query_iface
;
6028 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6032 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
6033 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
6035 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6036 struct d3d_query
*object
;
6039 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
6041 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
6046 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
6050 ID3D10Query_Release(&object
->ID3D10Query_iface
);
6054 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
6055 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
6057 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
6062 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
6063 DXGI_FORMAT format
, UINT
*format_support
)
6065 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6067 TRACE("iface %p, format %s, format_support %p.\n",
6068 iface
, debug_dxgi_format(format
), format_support
);
6070 return d3d11_device_CheckFormatSupport(&device
->ID3D11Device2_iface
, format
, format_support
);
6073 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
6074 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
6076 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6078 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
6079 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
6081 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device2_iface
, format
,
6082 sample_count
, quality_level_count
);
6085 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
6087 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
6090 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
6091 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
6092 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
6094 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
6095 "units %p, units_length %p, description %p, description_length %p stub!\n",
6096 iface
, desc
, type
, active_counters
, name
, name_length
,
6097 units
, units_length
, description
, description_length
);
6102 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
6104 FIXME("iface %p stub!\n", iface
);
6109 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
6110 HANDLE resource_handle
, REFIID guid
, void **resource
)
6112 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
6113 iface
, resource_handle
, debugstr_guid(guid
), resource
);
6118 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
6120 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
6123 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
6125 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
6128 static D3D10_FEATURE_LEVEL1
d3d10_feature_level1_from_d3d_feature_level(D3D_FEATURE_LEVEL level
)
6130 return (D3D10_FEATURE_LEVEL1
)level
;
6133 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
6135 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
6137 TRACE("iface %p.\n", iface
);
6139 return d3d10_feature_level1_from_d3d_feature_level(device
->feature_level
);
6142 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
6144 /* IUnknown methods */
6145 d3d10_device_QueryInterface
,
6146 d3d10_device_AddRef
,
6147 d3d10_device_Release
,
6148 /* ID3D10Device methods */
6149 d3d10_device_VSSetConstantBuffers
,
6150 d3d10_device_PSSetShaderResources
,
6151 d3d10_device_PSSetShader
,
6152 d3d10_device_PSSetSamplers
,
6153 d3d10_device_VSSetShader
,
6154 d3d10_device_DrawIndexed
,
6156 d3d10_device_PSSetConstantBuffers
,
6157 d3d10_device_IASetInputLayout
,
6158 d3d10_device_IASetVertexBuffers
,
6159 d3d10_device_IASetIndexBuffer
,
6160 d3d10_device_DrawIndexedInstanced
,
6161 d3d10_device_DrawInstanced
,
6162 d3d10_device_GSSetConstantBuffers
,
6163 d3d10_device_GSSetShader
,
6164 d3d10_device_IASetPrimitiveTopology
,
6165 d3d10_device_VSSetShaderResources
,
6166 d3d10_device_VSSetSamplers
,
6167 d3d10_device_SetPredication
,
6168 d3d10_device_GSSetShaderResources
,
6169 d3d10_device_GSSetSamplers
,
6170 d3d10_device_OMSetRenderTargets
,
6171 d3d10_device_OMSetBlendState
,
6172 d3d10_device_OMSetDepthStencilState
,
6173 d3d10_device_SOSetTargets
,
6174 d3d10_device_DrawAuto
,
6175 d3d10_device_RSSetState
,
6176 d3d10_device_RSSetViewports
,
6177 d3d10_device_RSSetScissorRects
,
6178 d3d10_device_CopySubresourceRegion
,
6179 d3d10_device_CopyResource
,
6180 d3d10_device_UpdateSubresource
,
6181 d3d10_device_ClearRenderTargetView
,
6182 d3d10_device_ClearDepthStencilView
,
6183 d3d10_device_GenerateMips
,
6184 d3d10_device_ResolveSubresource
,
6185 d3d10_device_VSGetConstantBuffers
,
6186 d3d10_device_PSGetShaderResources
,
6187 d3d10_device_PSGetShader
,
6188 d3d10_device_PSGetSamplers
,
6189 d3d10_device_VSGetShader
,
6190 d3d10_device_PSGetConstantBuffers
,
6191 d3d10_device_IAGetInputLayout
,
6192 d3d10_device_IAGetVertexBuffers
,
6193 d3d10_device_IAGetIndexBuffer
,
6194 d3d10_device_GSGetConstantBuffers
,
6195 d3d10_device_GSGetShader
,
6196 d3d10_device_IAGetPrimitiveTopology
,
6197 d3d10_device_VSGetShaderResources
,
6198 d3d10_device_VSGetSamplers
,
6199 d3d10_device_GetPredication
,
6200 d3d10_device_GSGetShaderResources
,
6201 d3d10_device_GSGetSamplers
,
6202 d3d10_device_OMGetRenderTargets
,
6203 d3d10_device_OMGetBlendState
,
6204 d3d10_device_OMGetDepthStencilState
,
6205 d3d10_device_SOGetTargets
,
6206 d3d10_device_RSGetState
,
6207 d3d10_device_RSGetViewports
,
6208 d3d10_device_RSGetScissorRects
,
6209 d3d10_device_GetDeviceRemovedReason
,
6210 d3d10_device_SetExceptionMode
,
6211 d3d10_device_GetExceptionMode
,
6212 d3d10_device_GetPrivateData
,
6213 d3d10_device_SetPrivateData
,
6214 d3d10_device_SetPrivateDataInterface
,
6215 d3d10_device_ClearState
,
6217 d3d10_device_CreateBuffer
,
6218 d3d10_device_CreateTexture1D
,
6219 d3d10_device_CreateTexture2D
,
6220 d3d10_device_CreateTexture3D
,
6221 d3d10_device_CreateShaderResourceView
,
6222 d3d10_device_CreateRenderTargetView
,
6223 d3d10_device_CreateDepthStencilView
,
6224 d3d10_device_CreateInputLayout
,
6225 d3d10_device_CreateVertexShader
,
6226 d3d10_device_CreateGeometryShader
,
6227 d3d10_device_CreateGeometryShaderWithStreamOutput
,
6228 d3d10_device_CreatePixelShader
,
6229 d3d10_device_CreateBlendState
,
6230 d3d10_device_CreateDepthStencilState
,
6231 d3d10_device_CreateRasterizerState
,
6232 d3d10_device_CreateSamplerState
,
6233 d3d10_device_CreateQuery
,
6234 d3d10_device_CreatePredicate
,
6235 d3d10_device_CreateCounter
,
6236 d3d10_device_CheckFormatSupport
,
6237 d3d10_device_CheckMultisampleQualityLevels
,
6238 d3d10_device_CheckCounterInfo
,
6239 d3d10_device_CheckCounter
,
6240 d3d10_device_GetCreationFlags
,
6241 d3d10_device_OpenSharedResource
,
6242 d3d10_device_SetTextFilterSize
,
6243 d3d10_device_GetTextFilterSize
,
6244 d3d10_device_CreateShaderResourceView1
,
6245 d3d10_device_CreateBlendState1
,
6246 d3d10_device_GetFeatureLevel
,
6249 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
6251 /* IUnknown methods */
6252 d3d_device_inner_QueryInterface
,
6253 d3d_device_inner_AddRef
,
6254 d3d_device_inner_Release
,
6257 /* ID3D10Multithread methods */
6259 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
6261 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
6264 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
6266 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6268 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
6270 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6273 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
6275 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6277 TRACE("iface %p.\n", iface
);
6279 return IUnknown_AddRef(device
->outer_unk
);
6282 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
6284 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6286 TRACE("iface %p.\n", iface
);
6288 return IUnknown_Release(device
->outer_unk
);
6291 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
6293 TRACE("iface %p.\n", iface
);
6295 wined3d_mutex_lock();
6298 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
6300 TRACE("iface %p.\n", iface
);
6302 wined3d_mutex_unlock();
6305 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL enable
)
6307 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
6312 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
6314 FIXME("iface %p stub!\n", iface
);
6319 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
6321 d3d10_multithread_QueryInterface
,
6322 d3d10_multithread_AddRef
,
6323 d3d10_multithread_Release
,
6324 d3d10_multithread_Enter
,
6325 d3d10_multithread_Leave
,
6326 d3d10_multithread_SetMultithreadProtected
,
6327 d3d10_multithread_GetMultithreadProtected
,
6330 /* IWineDXGIDeviceParent IUnknown methods */
6332 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
6334 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
6337 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
6338 REFIID iid
, void **out
)
6340 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6341 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6344 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
6346 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6347 return IUnknown_AddRef(device
->outer_unk
);
6350 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
6352 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6353 return IUnknown_Release(device
->outer_unk
);
6356 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
6357 IWineDXGIDeviceParent
*iface
)
6359 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6360 return &device
->device_parent
;
6363 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
6365 /* IUnknown methods */
6366 dxgi_device_parent_QueryInterface
,
6367 dxgi_device_parent_AddRef
,
6368 dxgi_device_parent_Release
,
6369 /* IWineDXGIDeviceParent methods */
6370 dxgi_device_parent_get_wined3d_device_parent
,
6373 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
6375 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
6378 static D3D_FEATURE_LEVEL
d3d_feature_level_from_wined3d(enum wined3d_feature_level level
)
6380 return (D3D_FEATURE_LEVEL
)level
;
6383 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
6384 struct wined3d_device
*wined3d_device
)
6386 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6387 ID3DDeviceContextState
*state
;
6390 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
6392 wined3d_device_incref(wined3d_device
);
6393 device
->wined3d_device
= wined3d_device
;
6395 device
->feature_level
= d3d_feature_level_from_wined3d(wined3d_device_get_feature_level(wined3d_device
));
6397 if (FAILED(hr
= d3d11_device_CreateDeviceContextState(&device
->ID3D11Device2_iface
, 0, &device
->feature_level
,
6398 1, D3D11_SDK_VERSION
, device
->d3d11_only
? &IID_ID3D11Device2
: &IID_ID3D10Device1
, NULL
,
6400 ERR("Failed to create the initial device context state, hr %#x.\n", hr
);
6403 device
->state
= impl_from_ID3DDeviceContextState(state
);
6404 d3d_device_context_state_private_addref(device
->state
);
6405 ID3DDeviceContextState_Release(state
);
6409 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
6411 TRACE("device_parent %p.\n", device_parent
);
6414 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
6416 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
6419 static HRESULT CDECL
device_parent_texture_sub_resource_created(struct wined3d_device_parent
*device_parent
,
6420 enum wined3d_resource_type type
, struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
,
6421 void **parent
, const struct wined3d_parent_ops
**parent_ops
)
6423 TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
6424 device_parent
, type
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
6427 *parent_ops
= &d3d_null_wined3d_parent_ops
;
6432 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
6433 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
6434 struct wined3d_texture
**wined3d_texture
)
6436 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6437 struct d3d_texture2d
*texture
;
6438 ID3D11Texture2D
*texture_iface
;
6439 D3D11_TEXTURE2D_DESC desc
;
6442 TRACE("device_parent %p, container_parent %p, wined3d_desc %p, texture_flags %#x, wined3d_texture %p.\n",
6443 device_parent
, container_parent
, wined3d_desc
, texture_flags
, wined3d_texture
);
6445 desc
.Width
= wined3d_desc
->width
;
6446 desc
.Height
= wined3d_desc
->height
;
6449 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
6450 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
6451 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
6452 desc
.Usage
= D3D11_USAGE_DEFAULT
;
6453 desc
.BindFlags
= d3d11_bind_flags_from_wined3d(wined3d_desc
->bind_flags
);
6454 desc
.CPUAccessFlags
= 0;
6457 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
6459 desc
.MiscFlags
|= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
6460 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
6464 FIXME("Unhandled flags %#x.\n", texture_flags
);
6466 if (FAILED(hr
= d3d11_device_CreateTexture2D(&device
->ID3D11Device2_iface
,
6467 &desc
, NULL
, &texture_iface
)))
6469 WARN("Failed to create 2D texture, hr %#x.\n", hr
);
6473 texture
= impl_from_ID3D11Texture2D(texture_iface
);
6475 *wined3d_texture
= texture
->wined3d_texture
;
6476 wined3d_texture_incref(*wined3d_texture
);
6477 ID3D11Texture2D_Release(&texture
->ID3D11Texture2D_iface
);
6482 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
6484 device_parent_wined3d_device_created
,
6485 device_parent_mode_changed
,
6486 device_parent_activate
,
6487 device_parent_texture_sub_resource_created
,
6488 device_parent_create_swapchain_texture
,
6491 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6493 const D3D11_SAMPLER_DESC
*ka
= key
;
6494 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
6496 return memcmp(ka
, kb
, sizeof(*ka
));
6499 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6501 const D3D11_BLEND_DESC
*ka
= key
;
6502 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
6504 return memcmp(ka
, kb
, sizeof(*ka
));
6507 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6509 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
6510 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
6511 const struct d3d_depthstencil_state
, entry
)->desc
;
6513 return memcmp(ka
, kb
, sizeof(*ka
));
6516 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6518 const D3D11_RASTERIZER_DESC
*ka
= key
;
6519 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
6521 return memcmp(ka
, kb
, sizeof(*ka
));
6524 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
6526 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
6527 device
->ID3D11Device2_iface
.lpVtbl
= &d3d11_device_vtbl
;
6528 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
6529 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
6530 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
6531 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
6532 device
->refcount
= 1;
6533 /* COM aggregation always takes place */
6534 device
->outer_unk
= outer_unknown
;
6535 device
->d3d11_only
= FALSE
;
6536 device
->state
= NULL
;
6538 d3d11_immediate_context_init(&device
->immediate_context
, device
);
6539 ID3D11DeviceContext1_Release(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
6541 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
6542 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
6543 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
6544 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);