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 /* ID3D11DeviceContext - immediate context methods */
34 static inline struct d3d11_immediate_context
*impl_from_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
36 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11DeviceContext1_iface
);
39 static inline struct d3d_device
*device_from_immediate_ID3D11DeviceContext1(ID3D11DeviceContext1
*iface
)
41 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
42 return CONTAINING_RECORD(context
, struct d3d_device
, immediate_context
);
45 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_QueryInterface(ID3D11DeviceContext1
*iface
,
46 REFIID iid
, void **out
)
48 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
50 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
52 if (IsEqualGUID(iid
, &IID_ID3D11DeviceContext1
)
53 || IsEqualGUID(iid
, &IID_ID3D11DeviceContext
)
54 || IsEqualGUID(iid
, &IID_ID3D11DeviceChild
)
55 || IsEqualGUID(iid
, &IID_IUnknown
))
57 *out
= &context
->ID3D11DeviceContext1_iface
;
59 else if (IsEqualGUID(iid
, &IID_ID3D11Multithread
))
61 *out
= &context
->ID3D11Multithread_iface
;
65 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
70 ID3D11DeviceContext1_AddRef(iface
);
74 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_AddRef(ID3D11DeviceContext1
*iface
)
76 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
77 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
78 ULONG refcount
= InterlockedIncrement(&context
->refcount
);
80 TRACE("%p increasing refcount to %u.\n", context
, refcount
);
84 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
90 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_Release(ID3D11DeviceContext1
*iface
)
92 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
93 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
94 ULONG refcount
= InterlockedDecrement(&context
->refcount
);
96 TRACE("%p decreasing refcount to %u.\n", context
, refcount
);
100 ID3D11Device2_Release(&device
->ID3D11Device2_iface
);
106 static void d3d11_immediate_context_get_constant_buffers(ID3D11DeviceContext1
*iface
,
107 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
109 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
112 wined3d_mutex_lock();
113 for (i
= 0; i
< buffer_count
; ++i
)
115 struct wined3d_buffer
*wined3d_buffer
;
116 struct d3d_buffer
*buffer_impl
;
118 if (!(wined3d_buffer
= wined3d_device_get_constant_buffer(device
->wined3d_device
,
119 type
, start_slot
+ i
)))
125 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
126 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
127 ID3D11Buffer_AddRef(buffers
[i
]);
129 wined3d_mutex_unlock();
132 static void d3d11_immediate_context_set_constant_buffers(ID3D11DeviceContext1
*iface
,
133 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
135 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
138 wined3d_mutex_lock();
139 for (i
= 0; i
< buffer_count
; ++i
)
141 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
143 wined3d_device_set_constant_buffer(device
->wined3d_device
, type
, start_slot
+ i
,
144 buffer
? buffer
->wined3d_buffer
: NULL
);
146 wined3d_mutex_unlock();
149 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetDevice(ID3D11DeviceContext1
*iface
, ID3D11Device
**device
)
151 struct d3d_device
*device_object
= device_from_immediate_ID3D11DeviceContext1(iface
);
153 TRACE("iface %p, device %p.\n", iface
, device
);
155 *device
= (ID3D11Device
*)&device_object
->ID3D11Device2_iface
;
156 ID3D11Device_AddRef(*device
);
159 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
160 UINT
*data_size
, void *data
)
162 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
164 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
166 return d3d_get_private_data(&context
->private_store
, guid
, data_size
, data
);
169 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext1
*iface
, REFGUID guid
,
170 UINT data_size
, const void *data
)
172 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
174 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
176 return d3d_set_private_data(&context
->private_store
, guid
, data_size
, data
);
179 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext1
*iface
,
180 REFGUID guid
, const IUnknown
*data
)
182 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext1(iface
);
184 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
186 return d3d_set_private_data_interface(&context
->private_store
, guid
, data
);
189 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
190 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
192 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
193 iface
, start_slot
, buffer_count
, buffers
);
195 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
196 buffer_count
, buffers
);
199 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext1
*iface
,
200 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
202 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
205 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
206 iface
, start_slot
, view_count
, views
);
208 wined3d_mutex_lock();
209 for (i
= 0; i
< view_count
; ++i
)
211 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
213 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
214 view
? view
->wined3d_view
: NULL
);
216 wined3d_mutex_unlock();
219 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShader(ID3D11DeviceContext1
*iface
,
220 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
222 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
223 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
225 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
226 iface
, shader
, class_instances
, class_instance_count
);
229 FIXME("Dynamic linking is not implemented yet.\n");
231 wined3d_mutex_lock();
232 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
233 wined3d_mutex_unlock();
236 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext1
*iface
,
237 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
239 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
242 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
243 iface
, start_slot
, sampler_count
, samplers
);
245 wined3d_mutex_lock();
246 for (i
= 0; i
< sampler_count
; ++i
)
248 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
250 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
251 sampler
? sampler
->wined3d_sampler
: NULL
);
253 wined3d_mutex_unlock();
256 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShader(ID3D11DeviceContext1
*iface
,
257 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
259 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
260 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
262 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
263 iface
, shader
, class_instances
, class_instance_count
);
266 FIXME("Dynamic linking is not implemented yet.\n");
268 wined3d_mutex_lock();
269 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
270 wined3d_mutex_unlock();
273 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext1
*iface
,
274 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
276 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
278 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
279 iface
, index_count
, start_index_location
, base_vertex_location
);
281 wined3d_mutex_lock();
282 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
283 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
284 wined3d_mutex_unlock();
287 static void STDMETHODCALLTYPE
d3d11_immediate_context_Draw(ID3D11DeviceContext1
*iface
,
288 UINT vertex_count
, UINT start_vertex_location
)
290 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
292 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
293 iface
, vertex_count
, start_vertex_location
);
295 wined3d_mutex_lock();
296 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
297 wined3d_mutex_unlock();
300 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_Map(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
301 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
303 struct wined3d_resource
*wined3d_resource
;
304 struct wined3d_map_desc map_desc
;
307 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
308 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
311 FIXME("Ignoring map_flags %#x.\n", map_flags
);
313 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
315 wined3d_mutex_lock();
316 hr
= wined3d_resource_map(wined3d_resource
, subresource_idx
,
317 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
318 wined3d_mutex_unlock();
320 mapped_subresource
->pData
= map_desc
.data
;
321 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
322 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
327 static void STDMETHODCALLTYPE
d3d11_immediate_context_Unmap(ID3D11DeviceContext1
*iface
, ID3D11Resource
*resource
,
328 UINT subresource_idx
)
330 struct wined3d_resource
*wined3d_resource
;
332 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
334 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
336 wined3d_mutex_lock();
337 wined3d_resource_unmap(wined3d_resource
, subresource_idx
);
338 wined3d_mutex_unlock();
341 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
342 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
344 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
345 iface
, start_slot
, buffer_count
, buffers
);
347 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
348 buffer_count
, buffers
);
351 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext1
*iface
,
352 ID3D11InputLayout
*input_layout
)
354 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
355 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
357 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
359 wined3d_mutex_lock();
360 wined3d_device_set_vertex_declaration(device
->wined3d_device
, layout
? layout
->wined3d_decl
: NULL
);
361 wined3d_mutex_unlock();
364 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext1
*iface
,
365 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
367 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
370 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
371 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
373 wined3d_mutex_lock();
374 for (i
= 0; i
< buffer_count
; ++i
)
376 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
378 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
379 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
381 wined3d_mutex_unlock();
384 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext1
*iface
,
385 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
387 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
388 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
390 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
391 iface
, buffer
, debug_dxgi_format(format
), offset
);
393 wined3d_mutex_lock();
394 wined3d_device_set_index_buffer(device
->wined3d_device
,
395 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
396 wined3dformat_from_dxgi_format(format
), offset
);
397 wined3d_mutex_unlock();
400 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext1
*iface
,
401 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
402 UINT start_instance_location
)
404 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
406 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
407 "base_vertex_location %d, start_instance_location %u.\n",
408 iface
, instance_index_count
, instance_count
, start_index_location
,
409 base_vertex_location
, start_instance_location
);
411 wined3d_mutex_lock();
412 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
413 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
414 instance_index_count
, start_instance_location
, instance_count
);
415 wined3d_mutex_unlock();
418 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext1
*iface
,
419 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
421 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
423 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
424 "start_instance_location %u.\n",
425 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
426 start_instance_location
);
428 wined3d_mutex_lock();
429 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
430 instance_vertex_count
, start_instance_location
, instance_count
);
431 wined3d_mutex_unlock();
434 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
435 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
437 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
438 iface
, start_slot
, buffer_count
, buffers
);
440 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
441 buffer_count
, buffers
);
444 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext1
*iface
,
445 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
447 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
448 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
450 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
451 iface
, shader
, class_instances
, class_instance_count
);
454 FIXME("Dynamic linking is not implemented yet.\n");
456 wined3d_mutex_lock();
457 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
458 wined3d_mutex_unlock();
461 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
462 D3D11_PRIMITIVE_TOPOLOGY topology
)
464 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
465 enum wined3d_primitive_type primitive_type
;
466 unsigned int patch_vertex_count
;
468 TRACE("iface %p, topology %#x.\n", iface
, topology
);
470 wined3d_primitive_type_from_d3d11_primitive_topology(topology
, &primitive_type
, &patch_vertex_count
);
472 wined3d_mutex_lock();
473 wined3d_device_set_primitive_type(device
->wined3d_device
, primitive_type
, patch_vertex_count
);
474 wined3d_mutex_unlock();
477 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext1
*iface
,
478 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
480 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
483 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
485 wined3d_mutex_lock();
486 for (i
= 0; i
< view_count
; ++i
)
488 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
490 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
491 view
? view
->wined3d_view
: NULL
);
493 wined3d_mutex_unlock();
496 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext1
*iface
,
497 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
499 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
502 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
503 iface
, start_slot
, sampler_count
, samplers
);
505 wined3d_mutex_lock();
506 for (i
= 0; i
< sampler_count
; ++i
)
508 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
510 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
511 sampler
? sampler
->wined3d_sampler
: NULL
);
513 wined3d_mutex_unlock();
516 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext1
*iface
,
517 ID3D11Asynchronous
*asynchronous
)
519 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
522 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
524 wined3d_mutex_lock();
525 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_BEGIN
)))
526 ERR("Failed to issue query, hr %#x.\n", hr
);
527 wined3d_mutex_unlock();
530 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext1
*iface
,
531 ID3D11Asynchronous
*asynchronous
)
533 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
536 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
538 wined3d_mutex_lock();
539 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_END
)))
540 ERR("Failed to issue query, hr %#x.\n", hr
);
541 wined3d_mutex_unlock();
544 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext1
*iface
,
545 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
547 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
548 unsigned int wined3d_flags
;
551 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
552 iface
, asynchronous
, data
, data_size
, data_flags
);
554 if (!data
&& data_size
)
557 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
559 wined3d_mutex_lock();
560 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
562 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
563 if (hr
== WINED3DERR_INVALIDCALL
)
564 hr
= DXGI_ERROR_INVALID_CALL
;
568 WARN("Invalid data size %u.\n", data_size
);
571 wined3d_mutex_unlock();
576 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext1
*iface
,
577 ID3D11Predicate
*predicate
, BOOL value
)
579 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
580 struct d3d_query
*query
;
582 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
584 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
586 wined3d_mutex_lock();
587 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
588 wined3d_mutex_unlock();
591 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext1
*iface
,
592 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
594 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
597 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
599 wined3d_mutex_lock();
600 for (i
= 0; i
< view_count
; ++i
)
602 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
604 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
605 view
? view
->wined3d_view
: NULL
);
607 wined3d_mutex_unlock();
610 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext1
*iface
,
611 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
613 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
616 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
617 iface
, start_slot
, sampler_count
, samplers
);
619 wined3d_mutex_lock();
620 for (i
= 0; i
< sampler_count
; ++i
)
622 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
624 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
625 sampler
? sampler
->wined3d_sampler
: NULL
);
627 wined3d_mutex_unlock();
630 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext1
*iface
,
631 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
632 ID3D11DepthStencilView
*depth_stencil_view
)
634 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
635 struct d3d_depthstencil_view
*dsv
;
638 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
639 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
641 wined3d_mutex_lock();
642 for (i
= 0; i
< render_target_view_count
; ++i
)
644 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
645 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
647 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
649 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
652 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
653 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
654 wined3d_mutex_unlock();
657 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
658 ID3D11DeviceContext1
*iface
, UINT render_target_view_count
,
659 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
660 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
661 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
663 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
666 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
667 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
668 "initial_counts %p.\n",
669 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
670 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
673 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
675 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
679 if (unordered_access_view_count
!= D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
681 wined3d_mutex_lock();
682 for (i
= 0; i
< unordered_access_view_start_slot
; ++i
)
684 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
686 for (i
= 0; i
< unordered_access_view_count
; ++i
)
688 struct d3d11_unordered_access_view
*view
689 = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views
[i
]);
691 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
692 unordered_access_view_start_slot
+ i
,
693 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
695 for (; unordered_access_view_start_slot
+ i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
697 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
698 unordered_access_view_start_slot
+ i
, NULL
, ~0u);
700 wined3d_mutex_unlock();
704 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext1
*iface
,
705 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
707 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
708 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
709 struct d3d_blend_state
*blend_state_impl
;
710 const D3D11_BLEND_DESC
*desc
;
712 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
713 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
716 blend_factor
= default_blend_factor
;
718 wined3d_mutex_lock();
719 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
720 if (!(blend_state_impl
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
722 wined3d_device_set_blend_state(device
->wined3d_device
, NULL
,
723 (const struct wined3d_color
*)blend_factor
);
724 wined3d_device_set_render_state(device
->wined3d_device
,
725 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
726 wined3d_device_set_render_state(device
->wined3d_device
,
727 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
728 wined3d_device_set_render_state(device
->wined3d_device
,
729 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
730 wined3d_device_set_render_state(device
->wined3d_device
,
731 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
732 wined3d_mutex_unlock();
736 wined3d_device_set_blend_state(device
->wined3d_device
, blend_state_impl
->wined3d_state
,
737 (const struct wined3d_color
*)blend_factor
);
738 desc
= &blend_state_impl
->desc
;
739 if (desc
->RenderTarget
[0].BlendEnable
)
741 const D3D11_RENDER_TARGET_BLEND_DESC
*d
= &desc
->RenderTarget
[0];
743 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
744 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
, d
->BlendOpAlpha
);
746 wined3d_device_set_render_state(device
->wined3d_device
,
747 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
748 wined3d_device_set_render_state(device
->wined3d_device
,
749 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
750 wined3d_device_set_render_state(device
->wined3d_device
,
751 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
752 wined3d_device_set_render_state(device
->wined3d_device
,
753 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
754 wined3d_mutex_unlock();
757 static void set_default_depth_stencil_state(struct wined3d_device
*wined3d_device
)
759 wined3d_device_set_render_state(wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
760 wined3d_device_set_render_state(wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
761 wined3d_device_set_render_state(wined3d_device
, WINED3D_RS_ZFUNC
, WINED3D_CMP_LESS
);
762 wined3d_device_set_render_state(wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
765 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext1
*iface
,
766 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
768 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
769 const D3D11_DEPTH_STENCILOP_DESC
*front
, *back
;
770 const D3D11_DEPTH_STENCIL_DESC
*desc
;
772 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
773 iface
, depth_stencil_state
, stencil_ref
);
775 wined3d_mutex_lock();
776 device
->stencil_ref
= stencil_ref
;
777 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
779 set_default_depth_stencil_state(device
->wined3d_device
);
780 wined3d_mutex_unlock();
784 desc
= &device
->depth_stencil_state
->desc
;
786 front
= &desc
->FrontFace
;
787 back
= &desc
->BackFace
;
789 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
790 if (desc
->DepthEnable
)
792 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
793 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
796 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
797 if (desc
->StencilEnable
)
799 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
800 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
801 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
803 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, front
->StencilFailOp
);
804 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
, front
->StencilDepthFailOp
);
805 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, front
->StencilPassOp
);
806 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, front
->StencilFunc
);
807 if (front
->StencilFailOp
!= back
->StencilFailOp
808 || front
->StencilDepthFailOp
!= back
->StencilDepthFailOp
809 || front
->StencilPassOp
!= back
->StencilPassOp
810 || front
->StencilFunc
!= back
->StencilFunc
)
812 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_TWOSIDEDSTENCILMODE
, TRUE
);
813 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILFAIL
, back
->StencilFailOp
);
814 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILZFAIL
,
815 back
->StencilDepthFailOp
);
816 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILPASS
, back
->StencilPassOp
);
817 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILFUNC
, back
->StencilFunc
);
821 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_TWOSIDEDSTENCILMODE
, FALSE
);
824 wined3d_mutex_unlock();
827 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext1
*iface
, UINT buffer_count
,
828 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
830 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
831 unsigned int count
, i
;
833 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
835 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
836 wined3d_mutex_lock();
837 for (i
= 0; i
< count
; ++i
)
839 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
841 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
842 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
? offsets
[i
] : 0);
844 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
846 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
848 wined3d_mutex_unlock();
851 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext1
*iface
)
853 FIXME("iface %p stub!\n", iface
);
856 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext1
*iface
,
857 ID3D11Buffer
*buffer
, UINT offset
)
859 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
860 struct d3d_buffer
*d3d_buffer
;
862 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
864 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
866 wined3d_mutex_lock();
867 wined3d_device_draw_indexed_primitive_instanced_indirect(device
->wined3d_device
,
868 d3d_buffer
->wined3d_buffer
, offset
);
869 wined3d_mutex_unlock();
872 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext1
*iface
,
873 ID3D11Buffer
*buffer
, UINT offset
)
875 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
876 struct d3d_buffer
*d3d_buffer
;
878 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
880 d3d_buffer
= unsafe_impl_from_ID3D11Buffer(buffer
);
882 wined3d_mutex_lock();
883 wined3d_device_draw_primitive_instanced_indirect(device
->wined3d_device
,
884 d3d_buffer
->wined3d_buffer
, offset
);
885 wined3d_mutex_unlock();
888 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext1
*iface
,
889 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
891 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
893 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
894 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
896 wined3d_mutex_lock();
897 wined3d_device_dispatch_compute(device
->wined3d_device
,
898 thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
899 wined3d_mutex_unlock();
902 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext1
*iface
,
903 ID3D11Buffer
*buffer
, UINT offset
)
905 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
906 struct d3d_buffer
*buffer_impl
;
908 TRACE("iface %p, buffer %p, offset %u.\n", iface
, buffer
, offset
);
910 buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
912 wined3d_mutex_lock();
913 wined3d_device_dispatch_compute_indirect(device
->wined3d_device
,
914 buffer_impl
->wined3d_buffer
, offset
);
915 wined3d_mutex_unlock();
918 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext1
*iface
,
919 ID3D11RasterizerState
*rasterizer_state
)
921 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
922 struct d3d_rasterizer_state
*rasterizer_state_impl
;
923 const D3D11_RASTERIZER_DESC
*desc
;
925 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
927 wined3d_mutex_lock();
928 if (!(rasterizer_state_impl
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
930 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
931 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
932 wined3d_mutex_unlock();
936 wined3d_device_set_rasterizer_state(device
->wined3d_device
, rasterizer_state_impl
->wined3d_state
);
938 desc
= &rasterizer_state_impl
->desc
;
939 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
940 wined3d_mutex_unlock();
943 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext1
*iface
,
944 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
946 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
947 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
950 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
952 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
955 for (i
= 0; i
< viewport_count
; ++i
)
957 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
958 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
959 wined3d_vp
[i
].width
= viewports
[i
].Width
;
960 wined3d_vp
[i
].height
= viewports
[i
].Height
;
961 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
962 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
965 wined3d_mutex_lock();
966 wined3d_device_set_viewports(device
->wined3d_device
, viewport_count
, wined3d_vp
);
967 wined3d_mutex_unlock();
970 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext1
*iface
,
971 UINT rect_count
, const D3D11_RECT
*rects
)
973 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
975 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
977 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
980 wined3d_mutex_lock();
981 wined3d_device_set_scissor_rects(device
->wined3d_device
, rect_count
, rects
);
982 wined3d_mutex_unlock();
985 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext1
*iface
,
986 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
987 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
989 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
990 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
991 struct wined3d_box wined3d_src_box
;
993 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
994 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
995 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
996 src_resource
, src_subresource_idx
, src_box
);
999 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
1000 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
1002 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1003 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1004 wined3d_mutex_lock();
1005 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
1006 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
1007 wined3d_mutex_unlock();
1010 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext1
*iface
,
1011 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
1013 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1014 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1016 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1018 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1019 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1020 wined3d_mutex_lock();
1021 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1022 wined3d_mutex_unlock();
1025 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext1
*iface
,
1026 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1027 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1029 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1030 struct wined3d_resource
*wined3d_resource
;
1031 struct wined3d_box wined3d_box
;
1033 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1034 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1037 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
, box
->front
, box
->back
);
1039 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1040 wined3d_mutex_lock();
1041 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1042 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, 0);
1043 wined3d_mutex_unlock();
1046 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext1
*iface
,
1047 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1049 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1050 struct d3d11_unordered_access_view
*uav
;
1051 struct d3d_buffer
*buffer_impl
;
1053 TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
1054 iface
, dst_buffer
, dst_offset
, src_view
);
1056 buffer_impl
= unsafe_impl_from_ID3D11Buffer(dst_buffer
);
1057 uav
= unsafe_impl_from_ID3D11UnorderedAccessView(src_view
);
1059 wined3d_mutex_lock();
1060 wined3d_device_copy_uav_counter(device
->wined3d_device
,
1061 buffer_impl
->wined3d_buffer
, dst_offset
, uav
->wined3d_view
);
1062 wined3d_mutex_unlock();
1065 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext1
*iface
,
1066 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1068 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1069 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1070 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1073 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1074 iface
, render_target_view
, debug_float4(color_rgba
));
1079 wined3d_mutex_lock();
1080 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1081 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1082 ERR("Failed to clear view, hr %#x.\n", hr
);
1083 wined3d_mutex_unlock();
1086 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1
*iface
,
1087 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1089 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1090 struct d3d11_unordered_access_view
*view
;
1092 TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n",
1093 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1095 view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view
);
1096 wined3d_mutex_lock();
1097 wined3d_device_clear_unordered_access_view_uint(device
->wined3d_device
,
1098 view
->wined3d_view
, (const struct wined3d_uvec4
*)values
);
1099 wined3d_mutex_unlock();
1102 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1
*iface
,
1103 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1105 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1106 iface
, unordered_access_view
, debug_float4(values
));
1109 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext1
*iface
,
1110 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1112 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1113 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1114 DWORD wined3d_flags
;
1117 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1118 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1123 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1125 wined3d_mutex_lock();
1126 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1127 wined3d_flags
, NULL
, depth
, stencil
)))
1128 ERR("Failed to clear view, hr %#x.\n", hr
);
1129 wined3d_mutex_unlock();
1132 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext1
*iface
,
1133 ID3D11ShaderResourceView
*view
)
1135 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D11ShaderResourceView(view
);
1137 TRACE("iface %p, view %p.\n", iface
, view
);
1139 wined3d_mutex_lock();
1140 wined3d_shader_resource_view_generate_mipmaps(srv
->wined3d_view
);
1141 wined3d_mutex_unlock();
1144 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1145 ID3D11Resource
*resource
, FLOAT min_lod
)
1147 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1150 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext1
*iface
,
1151 ID3D11Resource
*resource
)
1153 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1158 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext1
*iface
,
1159 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1160 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1163 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1164 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1165 enum wined3d_format_id wined3d_format
;
1167 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
1168 "src_resource %p, src_subresource_idx %u, format %s.\n",
1169 iface
, dst_resource
, dst_subresource_idx
,
1170 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1172 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
1173 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1174 wined3d_format
= wined3dformat_from_dxgi_format(format
);
1175 wined3d_mutex_lock();
1176 wined3d_device_resolve_sub_resource(device
->wined3d_device
,
1177 wined3d_dst_resource
, dst_subresource_idx
,
1178 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
1179 wined3d_mutex_unlock();
1182 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext1
*iface
,
1183 ID3D11CommandList
*command_list
, BOOL restore_state
)
1185 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1188 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext1
*iface
,
1189 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1191 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1194 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1195 iface
, start_slot
, view_count
, views
);
1197 wined3d_mutex_lock();
1198 for (i
= 0; i
< view_count
; ++i
)
1200 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1202 wined3d_device_set_hs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1203 view
? view
->wined3d_view
: NULL
);
1205 wined3d_mutex_unlock();
1208 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext1
*iface
,
1209 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1211 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1212 struct d3d11_hull_shader
*hs
= unsafe_impl_from_ID3D11HullShader(shader
);
1214 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1215 iface
, shader
, class_instances
, class_instance_count
);
1217 if (class_instances
)
1218 FIXME("Dynamic linking is not implemented yet.\n");
1220 wined3d_mutex_lock();
1221 wined3d_device_set_hull_shader(device
->wined3d_device
, hs
? hs
->wined3d_shader
: NULL
);
1222 wined3d_mutex_unlock();
1225 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext1
*iface
,
1226 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1228 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1231 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1232 iface
, start_slot
, sampler_count
, samplers
);
1234 wined3d_mutex_lock();
1235 for (i
= 0; i
< sampler_count
; ++i
)
1237 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1239 wined3d_device_set_hs_sampler(device
->wined3d_device
, start_slot
+ i
,
1240 sampler
? sampler
->wined3d_sampler
: NULL
);
1242 wined3d_mutex_unlock();
1245 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1246 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1248 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1249 iface
, start_slot
, buffer_count
, buffers
);
1251 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
1252 buffer_count
, buffers
);
1255 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext1
*iface
,
1256 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1258 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1261 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1262 iface
, start_slot
, view_count
, views
);
1264 wined3d_mutex_lock();
1265 for (i
= 0; i
< view_count
; ++i
)
1267 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1269 wined3d_device_set_ds_resource_view(device
->wined3d_device
, start_slot
+ i
,
1270 view
? view
->wined3d_view
: NULL
);
1272 wined3d_mutex_unlock();
1275 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext1
*iface
,
1276 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1278 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1279 struct d3d11_domain_shader
*ds
= unsafe_impl_from_ID3D11DomainShader(shader
);
1281 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1282 iface
, shader
, class_instances
, class_instance_count
);
1284 if (class_instances
)
1285 FIXME("Dynamic linking is not implemented yet.\n");
1287 wined3d_mutex_lock();
1288 wined3d_device_set_domain_shader(device
->wined3d_device
, ds
? ds
->wined3d_shader
: NULL
);
1289 wined3d_mutex_unlock();
1292 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext1
*iface
,
1293 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1295 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1298 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1299 iface
, start_slot
, sampler_count
, samplers
);
1301 wined3d_mutex_lock();
1302 for (i
= 0; i
< sampler_count
; ++i
)
1304 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1306 wined3d_device_set_ds_sampler(device
->wined3d_device
, start_slot
+ i
,
1307 sampler
? sampler
->wined3d_sampler
: NULL
);
1309 wined3d_mutex_unlock();
1312 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1313 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1315 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1316 iface
, start_slot
, buffer_count
, buffers
);
1318 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
1319 buffer_count
, buffers
);
1322 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext1
*iface
,
1323 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1325 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1328 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1329 iface
, start_slot
, view_count
, views
);
1331 wined3d_mutex_lock();
1332 for (i
= 0; i
< view_count
; ++i
)
1334 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
1336 wined3d_device_set_cs_resource_view(device
->wined3d_device
, start_slot
+ i
,
1337 view
? view
->wined3d_view
: NULL
);
1339 wined3d_mutex_unlock();
1342 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
1343 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1345 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1348 TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n",
1349 iface
, start_slot
, view_count
, views
, initial_counts
);
1351 wined3d_mutex_lock();
1352 for (i
= 0; i
< view_count
; ++i
)
1354 struct d3d11_unordered_access_view
*view
= unsafe_impl_from_ID3D11UnorderedAccessView(views
[i
]);
1356 wined3d_device_set_cs_uav(device
->wined3d_device
, start_slot
+ i
,
1357 view
? view
->wined3d_view
: NULL
, initial_counts
? initial_counts
[i
] : ~0u);
1359 wined3d_mutex_unlock();
1362 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext1
*iface
,
1363 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1365 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1366 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1368 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1369 iface
, shader
, class_instances
, class_instance_count
);
1371 if (class_instances
)
1372 FIXME("Dynamic linking is not implemented yet.\n");
1374 wined3d_mutex_lock();
1375 wined3d_device_set_compute_shader(device
->wined3d_device
, cs
? cs
->wined3d_shader
: NULL
);
1376 wined3d_mutex_unlock();
1379 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext1
*iface
,
1380 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1382 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1385 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1386 iface
, start_slot
, sampler_count
, samplers
);
1388 wined3d_mutex_lock();
1389 for (i
= 0; i
< sampler_count
; ++i
)
1391 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
1393 wined3d_device_set_cs_sampler(device
->wined3d_device
, start_slot
+ i
,
1394 sampler
? sampler
->wined3d_sampler
: NULL
);
1396 wined3d_mutex_unlock();
1399 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext1
*iface
,
1400 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1402 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1403 iface
, start_slot
, buffer_count
, buffers
);
1405 d3d11_immediate_context_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
1406 buffer_count
, buffers
);
1409 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1410 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1412 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1413 iface
, start_slot
, buffer_count
, buffers
);
1415 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
1416 buffer_count
, buffers
);
1419 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext1
*iface
,
1420 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1422 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1425 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1426 iface
, start_slot
, view_count
, views
);
1428 wined3d_mutex_lock();
1429 for (i
= 0; i
< view_count
; ++i
)
1431 struct wined3d_shader_resource_view
*wined3d_view
;
1432 struct d3d_shader_resource_view
*view_impl
;
1434 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1440 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1441 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1442 ID3D11ShaderResourceView_AddRef(views
[i
]);
1444 wined3d_mutex_unlock();
1447 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext1
*iface
,
1448 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1450 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1451 struct wined3d_shader
*wined3d_shader
;
1452 struct d3d_pixel_shader
*shader_impl
;
1454 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1455 iface
, shader
, class_instances
, class_instance_count
);
1457 if (class_instances
|| class_instance_count
)
1458 FIXME("Dynamic linking not implemented yet.\n");
1459 if (class_instance_count
)
1460 *class_instance_count
= 0;
1462 wined3d_mutex_lock();
1463 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1465 wined3d_mutex_unlock();
1470 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1471 wined3d_mutex_unlock();
1472 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1473 ID3D11PixelShader_AddRef(*shader
);
1476 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext1
*iface
,
1477 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1479 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1482 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1483 iface
, start_slot
, sampler_count
, samplers
);
1485 wined3d_mutex_lock();
1486 for (i
= 0; i
< sampler_count
; ++i
)
1488 struct wined3d_sampler
*wined3d_sampler
;
1489 struct d3d_sampler_state
*sampler_impl
;
1491 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1497 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1498 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1499 ID3D11SamplerState_AddRef(samplers
[i
]);
1501 wined3d_mutex_unlock();
1504 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext1
*iface
,
1505 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1507 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1508 struct d3d_vertex_shader
*shader_impl
;
1509 struct wined3d_shader
*wined3d_shader
;
1511 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1512 iface
, shader
, class_instances
, class_instance_count
);
1514 if (class_instances
|| class_instance_count
)
1515 FIXME("Dynamic linking not implemented yet.\n");
1516 if (class_instance_count
)
1517 *class_instance_count
= 0;
1519 wined3d_mutex_lock();
1520 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1522 wined3d_mutex_unlock();
1527 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1528 wined3d_mutex_unlock();
1529 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1530 ID3D11VertexShader_AddRef(*shader
);
1533 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1534 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1536 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1537 iface
, start_slot
, buffer_count
, buffers
);
1539 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
1540 buffer_count
, buffers
);
1543 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext1
*iface
,
1544 ID3D11InputLayout
**input_layout
)
1546 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1547 struct wined3d_vertex_declaration
*wined3d_declaration
;
1548 struct d3d_input_layout
*input_layout_impl
;
1550 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1552 wined3d_mutex_lock();
1553 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1555 wined3d_mutex_unlock();
1556 *input_layout
= NULL
;
1560 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1561 wined3d_mutex_unlock();
1562 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1563 ID3D11InputLayout_AddRef(*input_layout
);
1566 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext1
*iface
,
1567 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1569 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1572 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1573 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1575 wined3d_mutex_lock();
1576 for (i
= 0; i
< buffer_count
; ++i
)
1578 struct wined3d_buffer
*wined3d_buffer
= NULL
;
1579 struct d3d_buffer
*buffer_impl
;
1581 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1582 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1584 FIXME("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1591 if (!wined3d_buffer
)
1597 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1598 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1600 wined3d_mutex_unlock();
1603 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext1
*iface
,
1604 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1606 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1607 enum wined3d_format_id wined3d_format
;
1608 struct wined3d_buffer
*wined3d_buffer
;
1609 struct d3d_buffer
*buffer_impl
;
1611 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1613 wined3d_mutex_lock();
1614 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1615 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1616 if (!wined3d_buffer
)
1618 wined3d_mutex_unlock();
1623 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1624 wined3d_mutex_unlock();
1625 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1628 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
1629 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1631 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1632 iface
, start_slot
, buffer_count
, buffers
);
1634 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
1635 buffer_count
, buffers
);
1638 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext1
*iface
,
1639 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1641 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1642 struct d3d_geometry_shader
*shader_impl
;
1643 struct wined3d_shader
*wined3d_shader
;
1645 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1646 iface
, shader
, class_instances
, class_instance_count
);
1648 if (class_instances
|| class_instance_count
)
1649 FIXME("Dynamic linking not implemented yet.\n");
1650 if (class_instance_count
)
1651 *class_instance_count
= 0;
1653 wined3d_mutex_lock();
1654 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1656 wined3d_mutex_unlock();
1661 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1662 wined3d_mutex_unlock();
1663 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1664 ID3D11GeometryShader_AddRef(*shader
);
1667 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext1
*iface
,
1668 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1670 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1671 enum wined3d_primitive_type primitive_type
;
1672 unsigned int patch_vertex_count
;
1674 TRACE("iface %p, topology %p.\n", iface
, topology
);
1676 wined3d_mutex_lock();
1677 wined3d_device_get_primitive_type(device
->wined3d_device
, &primitive_type
, &patch_vertex_count
);
1678 wined3d_mutex_unlock();
1680 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type
, patch_vertex_count
, topology
);
1683 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext1
*iface
,
1684 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1686 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1689 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1691 wined3d_mutex_lock();
1692 for (i
= 0; i
< view_count
; ++i
)
1694 struct wined3d_shader_resource_view
*wined3d_view
;
1695 struct d3d_shader_resource_view
*view_impl
;
1697 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1703 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1704 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1705 ID3D11ShaderResourceView_AddRef(views
[i
]);
1707 wined3d_mutex_unlock();
1710 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext1
*iface
,
1711 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1713 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1716 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1717 iface
, start_slot
, sampler_count
, samplers
);
1719 wined3d_mutex_lock();
1720 for (i
= 0; i
< sampler_count
; ++i
)
1722 struct wined3d_sampler
*wined3d_sampler
;
1723 struct d3d_sampler_state
*sampler_impl
;
1725 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1731 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1732 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1733 ID3D11SamplerState_AddRef(samplers
[i
]);
1735 wined3d_mutex_unlock();
1738 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext1
*iface
,
1739 ID3D11Predicate
**predicate
, BOOL
*value
)
1741 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1742 struct wined3d_query
*wined3d_predicate
;
1743 struct d3d_query
*predicate_impl
;
1745 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1747 wined3d_mutex_lock();
1748 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1750 wined3d_mutex_unlock();
1755 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1756 wined3d_mutex_unlock();
1757 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1758 ID3D11Predicate_AddRef(*predicate
);
1761 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext1
*iface
,
1762 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1764 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1767 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1769 wined3d_mutex_lock();
1770 for (i
= 0; i
< view_count
; ++i
)
1772 struct wined3d_shader_resource_view
*wined3d_view
;
1773 struct d3d_shader_resource_view
*view_impl
;
1775 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1781 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1782 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1783 ID3D11ShaderResourceView_AddRef(views
[i
]);
1785 wined3d_mutex_unlock();
1788 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext1
*iface
,
1789 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1791 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1794 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1795 iface
, start_slot
, sampler_count
, samplers
);
1797 wined3d_mutex_lock();
1798 for (i
= 0; i
< sampler_count
; ++i
)
1800 struct d3d_sampler_state
*sampler_impl
;
1801 struct wined3d_sampler
*wined3d_sampler
;
1803 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1809 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1810 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1811 ID3D11SamplerState_AddRef(samplers
[i
]);
1813 wined3d_mutex_unlock();
1816 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext1
*iface
,
1817 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1818 ID3D11DepthStencilView
**depth_stencil_view
)
1820 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1821 struct wined3d_rendertarget_view
*wined3d_view
;
1823 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1824 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1826 wined3d_mutex_lock();
1827 if (render_target_views
)
1829 struct d3d_rendertarget_view
*view_impl
;
1832 for (i
= 0; i
< render_target_view_count
; ++i
)
1834 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1835 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1837 render_target_views
[i
] = NULL
;
1841 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1842 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1846 if (depth_stencil_view
)
1848 struct d3d_depthstencil_view
*view_impl
;
1850 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1851 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1853 *depth_stencil_view
= NULL
;
1857 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1858 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1861 wined3d_mutex_unlock();
1864 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1865 ID3D11DeviceContext1
*iface
,
1866 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1867 ID3D11DepthStencilView
**depth_stencil_view
,
1868 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1869 ID3D11UnorderedAccessView
**unordered_access_views
)
1871 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1872 struct wined3d_unordered_access_view
*wined3d_view
;
1873 struct d3d11_unordered_access_view
*view_impl
;
1876 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1877 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1878 "unordered_access_views %p.\n",
1879 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1880 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1882 if (render_target_views
|| depth_stencil_view
)
1883 d3d11_immediate_context_OMGetRenderTargets(iface
, render_target_view_count
,
1884 render_target_views
, depth_stencil_view
);
1886 if (unordered_access_views
)
1888 wined3d_mutex_lock();
1889 for (i
= 0; i
< unordered_access_view_count
; ++i
)
1891 if (!(wined3d_view
= wined3d_device_get_unordered_access_view(device
->wined3d_device
,
1892 unordered_access_view_start_slot
+ i
)))
1894 unordered_access_views
[i
] = NULL
;
1898 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
1899 unordered_access_views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
;
1900 ID3D11UnorderedAccessView_AddRef(unordered_access_views
[i
]);
1902 wined3d_mutex_unlock();
1906 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext1
*iface
,
1907 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1909 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1910 struct wined3d_blend_state
*wined3d_state
;
1911 struct d3d_blend_state
*blend_state_impl
;
1913 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1914 iface
, blend_state
, blend_factor
, sample_mask
);
1916 wined3d_mutex_lock();
1917 if ((wined3d_state
= wined3d_device_get_blend_state(device
->wined3d_device
,
1918 (struct wined3d_color
*)blend_factor
)))
1920 blend_state_impl
= wined3d_blend_state_get_parent(wined3d_state
);
1921 ID3D11BlendState_AddRef(*blend_state
= &blend_state_impl
->ID3D11BlendState_iface
);
1925 *blend_state
= NULL
;
1927 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1928 wined3d_mutex_unlock();
1931 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext1
*iface
,
1932 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1934 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1936 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1937 iface
, depth_stencil_state
, stencil_ref
);
1939 if ((*depth_stencil_state
= device
->depth_stencil_state
1940 ? &device
->depth_stencil_state
->ID3D11DepthStencilState_iface
: NULL
))
1941 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
1942 *stencil_ref
= device
->stencil_ref
;
1945 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext1
*iface
,
1946 UINT buffer_count
, ID3D11Buffer
**buffers
)
1948 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1951 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1953 wined3d_mutex_lock();
1954 for (i
= 0; i
< buffer_count
; ++i
)
1956 struct wined3d_buffer
*wined3d_buffer
;
1957 struct d3d_buffer
*buffer_impl
;
1959 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1965 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1966 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1967 ID3D11Buffer_AddRef(buffers
[i
]);
1969 wined3d_mutex_unlock();
1972 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext1
*iface
,
1973 ID3D11RasterizerState
**rasterizer_state
)
1975 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1976 struct d3d_rasterizer_state
*rasterizer_state_impl
;
1977 struct wined3d_rasterizer_state
*wined3d_state
;
1979 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1981 wined3d_mutex_lock();
1982 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
1984 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
1985 ID3D11RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D11RasterizerState_iface
);
1989 *rasterizer_state
= NULL
;
1991 wined3d_mutex_unlock();
1994 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext1
*iface
,
1995 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1997 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
1998 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
1999 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
2001 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
2003 if (!viewport_count
)
2006 wined3d_mutex_lock();
2007 wined3d_device_get_viewports(device
->wined3d_device
, &actual_count
, viewports
? wined3d_vp
: NULL
);
2008 wined3d_mutex_unlock();
2012 *viewport_count
= actual_count
;
2016 if (*viewport_count
> actual_count
)
2017 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
2019 *viewport_count
= min(actual_count
, *viewport_count
);
2020 for (i
= 0; i
< *viewport_count
; ++i
)
2022 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
2023 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
2024 viewports
[i
].Width
= wined3d_vp
[i
].width
;
2025 viewports
[i
].Height
= wined3d_vp
[i
].height
;
2026 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
2027 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
2031 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext1
*iface
,
2032 UINT
*rect_count
, D3D11_RECT
*rects
)
2034 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2035 unsigned int actual_count
;
2037 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
2042 actual_count
= *rect_count
;
2044 wined3d_mutex_lock();
2045 wined3d_device_get_scissor_rects(device
->wined3d_device
, &actual_count
, rects
);
2046 wined3d_mutex_unlock();
2050 *rect_count
= actual_count
;
2054 if (*rect_count
> actual_count
)
2055 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
2058 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1
*iface
,
2059 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2061 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2064 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2066 wined3d_mutex_lock();
2067 for (i
= 0; i
< view_count
; ++i
)
2069 struct wined3d_shader_resource_view
*wined3d_view
;
2070 struct d3d_shader_resource_view
*view_impl
;
2072 if (!(wined3d_view
= wined3d_device_get_hs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2078 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2079 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2081 wined3d_mutex_unlock();
2084 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext1
*iface
,
2085 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2087 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2088 struct d3d11_hull_shader
*shader_impl
;
2089 struct wined3d_shader
*wined3d_shader
;
2091 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2092 iface
, shader
, class_instances
, class_instance_count
);
2094 if (class_instances
|| class_instance_count
)
2095 FIXME("Dynamic linking not implemented yet.\n");
2096 if (class_instance_count
)
2097 *class_instance_count
= 0;
2099 wined3d_mutex_lock();
2100 if (!(wined3d_shader
= wined3d_device_get_hull_shader(device
->wined3d_device
)))
2102 wined3d_mutex_unlock();
2107 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2108 wined3d_mutex_unlock();
2109 ID3D11HullShader_AddRef(*shader
= &shader_impl
->ID3D11HullShader_iface
);
2112 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext1
*iface
,
2113 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2115 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2118 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2119 iface
, start_slot
, sampler_count
, samplers
);
2121 wined3d_mutex_lock();
2122 for (i
= 0; i
< sampler_count
; ++i
)
2124 struct wined3d_sampler
*wined3d_sampler
;
2125 struct d3d_sampler_state
*sampler_impl
;
2127 if (!(wined3d_sampler
= wined3d_device_get_hs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2133 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2134 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2136 wined3d_mutex_unlock();
2139 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2140 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2142 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2143 iface
, start_slot
, buffer_count
, buffers
);
2145 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_HULL
, start_slot
,
2146 buffer_count
, buffers
);
2149 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext1
*iface
,
2150 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2152 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2155 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2156 iface
, start_slot
, view_count
, views
);
2158 wined3d_mutex_lock();
2159 for (i
= 0; i
< view_count
; ++i
)
2161 struct wined3d_shader_resource_view
*wined3d_view
;
2162 struct d3d_shader_resource_view
*view_impl
;
2164 if (!(wined3d_view
= wined3d_device_get_ds_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2170 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2171 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2173 wined3d_mutex_unlock();
2176 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext1
*iface
,
2177 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2179 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2180 struct d3d11_domain_shader
*shader_impl
;
2181 struct wined3d_shader
*wined3d_shader
;
2183 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2184 iface
, shader
, class_instances
, class_instance_count
);
2186 if (class_instances
|| class_instance_count
)
2187 FIXME("Dynamic linking not implemented yet.\n");
2188 if (class_instance_count
)
2189 *class_instance_count
= 0;
2191 wined3d_mutex_lock();
2192 if (!(wined3d_shader
= wined3d_device_get_domain_shader(device
->wined3d_device
)))
2194 wined3d_mutex_unlock();
2199 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2200 wined3d_mutex_unlock();
2201 ID3D11DomainShader_AddRef(*shader
= &shader_impl
->ID3D11DomainShader_iface
);
2204 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext1
*iface
,
2205 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2207 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2210 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2211 iface
, start_slot
, sampler_count
, samplers
);
2213 wined3d_mutex_lock();
2214 for (i
= 0; i
< sampler_count
; ++i
)
2216 struct wined3d_sampler
*wined3d_sampler
;
2217 struct d3d_sampler_state
*sampler_impl
;
2219 if (!(wined3d_sampler
= wined3d_device_get_ds_sampler(device
->wined3d_device
, start_slot
+ i
)))
2225 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2226 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2228 wined3d_mutex_unlock();
2231 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2232 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2234 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2235 iface
, start_slot
, buffer_count
, buffers
);
2237 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_DOMAIN
, start_slot
,
2238 buffer_count
, buffers
);
2241 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext1
*iface
,
2242 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
2244 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2247 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2249 wined3d_mutex_lock();
2250 for (i
= 0; i
< view_count
; ++i
)
2252 struct wined3d_shader_resource_view
*wined3d_view
;
2253 struct d3d_shader_resource_view
*view_impl
;
2255 if (!(wined3d_view
= wined3d_device_get_cs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
2261 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
2262 ID3D11ShaderResourceView_AddRef(views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
);
2264 wined3d_mutex_unlock();
2267 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext1
*iface
,
2268 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
2270 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2273 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
2275 wined3d_mutex_lock();
2276 for (i
= 0; i
< view_count
; ++i
)
2278 struct wined3d_unordered_access_view
*wined3d_view
;
2279 struct d3d11_unordered_access_view
*view_impl
;
2281 if (!(wined3d_view
= wined3d_device_get_cs_uav(device
->wined3d_device
, start_slot
+ i
)))
2287 view_impl
= wined3d_unordered_access_view_get_parent(wined3d_view
);
2288 ID3D11UnorderedAccessView_AddRef(views
[i
] = &view_impl
->ID3D11UnorderedAccessView_iface
);
2290 wined3d_mutex_unlock();
2293 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext1
*iface
,
2294 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
2296 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2297 struct d3d11_compute_shader
*shader_impl
;
2298 struct wined3d_shader
*wined3d_shader
;
2300 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
2301 iface
, shader
, class_instances
, class_instance_count
);
2303 if (class_instances
|| class_instance_count
)
2304 FIXME("Dynamic linking not implemented yet.\n");
2305 if (class_instance_count
)
2306 *class_instance_count
= 0;
2308 wined3d_mutex_lock();
2309 if (!(wined3d_shader
= wined3d_device_get_compute_shader(device
->wined3d_device
)))
2311 wined3d_mutex_unlock();
2316 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
2317 wined3d_mutex_unlock();
2318 ID3D11ComputeShader_AddRef(*shader
= &shader_impl
->ID3D11ComputeShader_iface
);
2321 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext1
*iface
,
2322 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
2324 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2327 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2328 iface
, start_slot
, sampler_count
, samplers
);
2330 wined3d_mutex_lock();
2331 for (i
= 0; i
< sampler_count
; ++i
)
2333 struct wined3d_sampler
*wined3d_sampler
;
2334 struct d3d_sampler_state
*sampler_impl
;
2336 if (!(wined3d_sampler
= wined3d_device_get_cs_sampler(device
->wined3d_device
, start_slot
+ i
)))
2342 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
2343 ID3D11SamplerState_AddRef(samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
);
2345 wined3d_mutex_unlock();
2348 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext1
*iface
,
2349 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
2351 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2352 iface
, start_slot
, buffer_count
, buffers
);
2354 d3d11_immediate_context_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_COMPUTE
, start_slot
,
2355 buffer_count
, buffers
);
2358 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext1
*iface
)
2360 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2361 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
2364 TRACE("iface %p.\n", iface
);
2366 wined3d_mutex_lock();
2367 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
2368 wined3d_device_set_hull_shader(device
->wined3d_device
, NULL
);
2369 wined3d_device_set_domain_shader(device
->wined3d_device
, NULL
);
2370 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
2371 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
2372 wined3d_device_set_compute_shader(device
->wined3d_device
, NULL
);
2373 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
2375 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
2376 wined3d_device_set_hs_sampler(device
->wined3d_device
, i
, NULL
);
2377 wined3d_device_set_ds_sampler(device
->wined3d_device
, i
, NULL
);
2378 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
2379 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
2380 wined3d_device_set_cs_sampler(device
->wined3d_device
, i
, NULL
);
2382 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2384 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
2385 wined3d_device_set_hs_resource_view(device
->wined3d_device
, i
, NULL
);
2386 wined3d_device_set_ds_resource_view(device
->wined3d_device
, i
, NULL
);
2387 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
2388 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
2389 wined3d_device_set_cs_resource_view(device
->wined3d_device
, i
, NULL
);
2391 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
2393 for (j
= 0; j
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++j
)
2394 wined3d_device_set_constant_buffer(device
->wined3d_device
, i
, j
, NULL
);
2396 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
2398 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
2400 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
2401 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
2402 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
, 0);
2403 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2405 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
2407 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
2408 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
2410 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
, ~0u);
2411 wined3d_device_set_cs_uav(device
->wined3d_device
, i
, NULL
, ~0u);
2413 ID3D11DeviceContext1_OMSetDepthStencilState(iface
, NULL
, 0);
2414 ID3D11DeviceContext1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
2415 ID3D11DeviceContext1_RSSetViewports(iface
, 0, NULL
);
2416 ID3D11DeviceContext1_RSSetScissorRects(iface
, 0, NULL
);
2417 ID3D11DeviceContext1_RSSetState(iface
, NULL
);
2418 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
2420 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
2422 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
2423 wined3d_mutex_unlock();
2426 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext1
*iface
)
2428 FIXME("iface %p stub!\n", iface
);
2431 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext1
*iface
)
2433 TRACE("iface %p.\n", iface
);
2435 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
2438 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext1
*iface
)
2440 FIXME("iface %p stub!\n", iface
);
2445 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext1
*iface
,
2446 BOOL restore
, ID3D11CommandList
**command_list
)
2448 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
2453 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion1(ID3D11DeviceContext1
*iface
,
2454 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
2455 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
, UINT flags
)
2457 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2458 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
2459 struct wined3d_box wined3d_src_box
;
2461 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
2462 "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n",
2463 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
2464 src_resource
, src_subresource_idx
, src_box
, flags
);
2467 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
2468 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
2470 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
2471 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
2472 wined3d_mutex_lock();
2473 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
2474 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, flags
);
2475 wined3d_mutex_unlock();
2478 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource1(ID3D11DeviceContext1
*iface
,
2479 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
, const void *data
,
2480 UINT row_pitch
, UINT depth_pitch
, UINT flags
)
2482 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext1(iface
);
2483 struct wined3d_resource
*wined3d_resource
;
2484 struct wined3d_box wined3d_box
;
2486 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n",
2487 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
, flags
);
2490 wined3d_box_set(&wined3d_box
, box
->left
, box
->top
, box
->right
, box
->bottom
,
2491 box
->front
, box
->back
);
2493 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
2494 wined3d_mutex_lock();
2495 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
, subresource_idx
,
2496 box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
, flags
);
2497 wined3d_mutex_unlock();
2500 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardResource(ID3D11DeviceContext1
*iface
,
2501 ID3D11Resource
*resource
)
2503 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
2506 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
)
2508 FIXME("iface %p, view %p stub!\n", iface
, view
);
2511 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2512 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2513 const UINT
*num_constants
)
2515 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2516 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2519 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2520 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2521 const UINT
*num_constants
)
2523 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2524 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2527 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2528 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2529 const UINT
*num_constants
)
2531 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2532 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2535 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2536 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2537 const UINT
*num_constants
)
2539 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2540 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2543 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2544 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2545 const UINT
*num_constants
)
2547 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2548 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2551 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2552 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
* const *buffers
, const UINT
*first_constant
,
2553 const UINT
*num_constants
)
2555 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2556 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2559 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2560 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2562 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2563 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2566 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2567 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2569 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2570 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2573 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2574 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2576 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2577 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2580 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2581 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2583 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2584 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2587 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2588 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2590 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2591 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2594 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers1(ID3D11DeviceContext1
*iface
,
2595 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*first_constant
, UINT
*num_constants
)
2597 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n",
2598 iface
, start_slot
, buffer_count
, buffers
, first_constant
, num_constants
);
2601 static void STDMETHODCALLTYPE
d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1
*iface
,
2602 ID3DDeviceContextState
*state
, ID3DDeviceContextState
**prev_state
)
2604 FIXME("iface %p, state %p, prev_state %p stub!\n", iface
, state
, prev_state
);
2607 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearView(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2608 const FLOAT color
[4], const D3D11_RECT
*rect
, UINT num_rects
)
2610 FIXME("iface %p, view %p, color %p, rect %p, num_rects %u stub!\n", iface
, view
, color
, rect
, num_rects
);
2613 static void STDMETHODCALLTYPE
d3d11_immediate_context_DiscardView1(ID3D11DeviceContext1
*iface
, ID3D11View
*view
,
2614 const D3D11_RECT
*rects
, UINT num_rects
)
2616 FIXME("iface %p, view %p, rects %p, num_rects %u stub!\n", iface
, view
, rects
, num_rects
);
2619 static const struct ID3D11DeviceContext1Vtbl d3d11_immediate_context_vtbl
=
2621 /* IUnknown methods */
2622 d3d11_immediate_context_QueryInterface
,
2623 d3d11_immediate_context_AddRef
,
2624 d3d11_immediate_context_Release
,
2625 /* ID3D11DeviceChild methods */
2626 d3d11_immediate_context_GetDevice
,
2627 d3d11_immediate_context_GetPrivateData
,
2628 d3d11_immediate_context_SetPrivateData
,
2629 d3d11_immediate_context_SetPrivateDataInterface
,
2630 /* ID3D11DeviceContext methods */
2631 d3d11_immediate_context_VSSetConstantBuffers
,
2632 d3d11_immediate_context_PSSetShaderResources
,
2633 d3d11_immediate_context_PSSetShader
,
2634 d3d11_immediate_context_PSSetSamplers
,
2635 d3d11_immediate_context_VSSetShader
,
2636 d3d11_immediate_context_DrawIndexed
,
2637 d3d11_immediate_context_Draw
,
2638 d3d11_immediate_context_Map
,
2639 d3d11_immediate_context_Unmap
,
2640 d3d11_immediate_context_PSSetConstantBuffers
,
2641 d3d11_immediate_context_IASetInputLayout
,
2642 d3d11_immediate_context_IASetVertexBuffers
,
2643 d3d11_immediate_context_IASetIndexBuffer
,
2644 d3d11_immediate_context_DrawIndexedInstanced
,
2645 d3d11_immediate_context_DrawInstanced
,
2646 d3d11_immediate_context_GSSetConstantBuffers
,
2647 d3d11_immediate_context_GSSetShader
,
2648 d3d11_immediate_context_IASetPrimitiveTopology
,
2649 d3d11_immediate_context_VSSetShaderResources
,
2650 d3d11_immediate_context_VSSetSamplers
,
2651 d3d11_immediate_context_Begin
,
2652 d3d11_immediate_context_End
,
2653 d3d11_immediate_context_GetData
,
2654 d3d11_immediate_context_SetPredication
,
2655 d3d11_immediate_context_GSSetShaderResources
,
2656 d3d11_immediate_context_GSSetSamplers
,
2657 d3d11_immediate_context_OMSetRenderTargets
,
2658 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
2659 d3d11_immediate_context_OMSetBlendState
,
2660 d3d11_immediate_context_OMSetDepthStencilState
,
2661 d3d11_immediate_context_SOSetTargets
,
2662 d3d11_immediate_context_DrawAuto
,
2663 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
2664 d3d11_immediate_context_DrawInstancedIndirect
,
2665 d3d11_immediate_context_Dispatch
,
2666 d3d11_immediate_context_DispatchIndirect
,
2667 d3d11_immediate_context_RSSetState
,
2668 d3d11_immediate_context_RSSetViewports
,
2669 d3d11_immediate_context_RSSetScissorRects
,
2670 d3d11_immediate_context_CopySubresourceRegion
,
2671 d3d11_immediate_context_CopyResource
,
2672 d3d11_immediate_context_UpdateSubresource
,
2673 d3d11_immediate_context_CopyStructureCount
,
2674 d3d11_immediate_context_ClearRenderTargetView
,
2675 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
2676 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
2677 d3d11_immediate_context_ClearDepthStencilView
,
2678 d3d11_immediate_context_GenerateMips
,
2679 d3d11_immediate_context_SetResourceMinLOD
,
2680 d3d11_immediate_context_GetResourceMinLOD
,
2681 d3d11_immediate_context_ResolveSubresource
,
2682 d3d11_immediate_context_ExecuteCommandList
,
2683 d3d11_immediate_context_HSSetShaderResources
,
2684 d3d11_immediate_context_HSSetShader
,
2685 d3d11_immediate_context_HSSetSamplers
,
2686 d3d11_immediate_context_HSSetConstantBuffers
,
2687 d3d11_immediate_context_DSSetShaderResources
,
2688 d3d11_immediate_context_DSSetShader
,
2689 d3d11_immediate_context_DSSetSamplers
,
2690 d3d11_immediate_context_DSSetConstantBuffers
,
2691 d3d11_immediate_context_CSSetShaderResources
,
2692 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2693 d3d11_immediate_context_CSSetShader
,
2694 d3d11_immediate_context_CSSetSamplers
,
2695 d3d11_immediate_context_CSSetConstantBuffers
,
2696 d3d11_immediate_context_VSGetConstantBuffers
,
2697 d3d11_immediate_context_PSGetShaderResources
,
2698 d3d11_immediate_context_PSGetShader
,
2699 d3d11_immediate_context_PSGetSamplers
,
2700 d3d11_immediate_context_VSGetShader
,
2701 d3d11_immediate_context_PSGetConstantBuffers
,
2702 d3d11_immediate_context_IAGetInputLayout
,
2703 d3d11_immediate_context_IAGetVertexBuffers
,
2704 d3d11_immediate_context_IAGetIndexBuffer
,
2705 d3d11_immediate_context_GSGetConstantBuffers
,
2706 d3d11_immediate_context_GSGetShader
,
2707 d3d11_immediate_context_IAGetPrimitiveTopology
,
2708 d3d11_immediate_context_VSGetShaderResources
,
2709 d3d11_immediate_context_VSGetSamplers
,
2710 d3d11_immediate_context_GetPredication
,
2711 d3d11_immediate_context_GSGetShaderResources
,
2712 d3d11_immediate_context_GSGetSamplers
,
2713 d3d11_immediate_context_OMGetRenderTargets
,
2714 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2715 d3d11_immediate_context_OMGetBlendState
,
2716 d3d11_immediate_context_OMGetDepthStencilState
,
2717 d3d11_immediate_context_SOGetTargets
,
2718 d3d11_immediate_context_RSGetState
,
2719 d3d11_immediate_context_RSGetViewports
,
2720 d3d11_immediate_context_RSGetScissorRects
,
2721 d3d11_immediate_context_HSGetShaderResources
,
2722 d3d11_immediate_context_HSGetShader
,
2723 d3d11_immediate_context_HSGetSamplers
,
2724 d3d11_immediate_context_HSGetConstantBuffers
,
2725 d3d11_immediate_context_DSGetShaderResources
,
2726 d3d11_immediate_context_DSGetShader
,
2727 d3d11_immediate_context_DSGetSamplers
,
2728 d3d11_immediate_context_DSGetConstantBuffers
,
2729 d3d11_immediate_context_CSGetShaderResources
,
2730 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2731 d3d11_immediate_context_CSGetShader
,
2732 d3d11_immediate_context_CSGetSamplers
,
2733 d3d11_immediate_context_CSGetConstantBuffers
,
2734 d3d11_immediate_context_ClearState
,
2735 d3d11_immediate_context_Flush
,
2736 d3d11_immediate_context_GetType
,
2737 d3d11_immediate_context_GetContextFlags
,
2738 d3d11_immediate_context_FinishCommandList
,
2739 /* ID3D11DeviceContext1 methods */
2740 d3d11_immediate_context_CopySubresourceRegion1
,
2741 d3d11_immediate_context_UpdateSubresource1
,
2742 d3d11_immediate_context_DiscardResource
,
2743 d3d11_immediate_context_DiscardView
,
2744 d3d11_immediate_context_VSSetConstantBuffers1
,
2745 d3d11_immediate_context_HSSetConstantBuffers1
,
2746 d3d11_immediate_context_DSSetConstantBuffers1
,
2747 d3d11_immediate_context_GSSetConstantBuffers1
,
2748 d3d11_immediate_context_PSSetConstantBuffers1
,
2749 d3d11_immediate_context_CSSetConstantBuffers1
,
2750 d3d11_immediate_context_VSGetConstantBuffers1
,
2751 d3d11_immediate_context_HSGetConstantBuffers1
,
2752 d3d11_immediate_context_DSGetConstantBuffers1
,
2753 d3d11_immediate_context_GSGetConstantBuffers1
,
2754 d3d11_immediate_context_PSGetConstantBuffers1
,
2755 d3d11_immediate_context_CSGetConstantBuffers1
,
2756 d3d11_immediate_context_SwapDeviceContextState
,
2757 d3d11_immediate_context_ClearView
,
2758 d3d11_immediate_context_DiscardView1
,
2761 /* ID3D11Multithread methods */
2763 static inline struct d3d11_immediate_context
*impl_from_ID3D11Multithread(ID3D11Multithread
*iface
)
2765 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11Multithread_iface
);
2768 static HRESULT STDMETHODCALLTYPE
d3d11_multithread_QueryInterface(ID3D11Multithread
*iface
,
2769 REFIID iid
, void **out
)
2771 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2773 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
2775 return d3d11_immediate_context_QueryInterface(&context
->ID3D11DeviceContext1_iface
, iid
, out
);
2778 static ULONG STDMETHODCALLTYPE
d3d11_multithread_AddRef(ID3D11Multithread
*iface
)
2780 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2782 TRACE("iface %p.\n", iface
);
2784 return d3d11_immediate_context_AddRef(&context
->ID3D11DeviceContext1_iface
);
2787 static ULONG STDMETHODCALLTYPE
d3d11_multithread_Release(ID3D11Multithread
*iface
)
2789 struct d3d11_immediate_context
*context
= impl_from_ID3D11Multithread(iface
);
2791 TRACE("iface %p.\n", iface
);
2793 return d3d11_immediate_context_Release(&context
->ID3D11DeviceContext1_iface
);
2796 static void STDMETHODCALLTYPE
d3d11_multithread_Enter(ID3D11Multithread
*iface
)
2798 TRACE("iface %p.\n", iface
);
2800 wined3d_mutex_lock();
2803 static void STDMETHODCALLTYPE
d3d11_multithread_Leave(ID3D11Multithread
*iface
)
2805 TRACE("iface %p.\n", iface
);
2807 wined3d_mutex_unlock();
2810 static BOOL STDMETHODCALLTYPE
d3d11_multithread_SetMultithreadProtected(
2811 ID3D11Multithread
*iface
, BOOL enable
)
2813 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
2818 static BOOL STDMETHODCALLTYPE
d3d11_multithread_GetMultithreadProtected(ID3D11Multithread
*iface
)
2820 FIXME("iface %p stub!\n", iface
);
2825 static const struct ID3D11MultithreadVtbl d3d11_multithread_vtbl
=
2827 d3d11_multithread_QueryInterface
,
2828 d3d11_multithread_AddRef
,
2829 d3d11_multithread_Release
,
2830 d3d11_multithread_Enter
,
2831 d3d11_multithread_Leave
,
2832 d3d11_multithread_SetMultithreadProtected
,
2833 d3d11_multithread_GetMultithreadProtected
,
2836 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
2838 context
->ID3D11DeviceContext1_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
2839 context
->ID3D11Multithread_iface
.lpVtbl
= &d3d11_multithread_vtbl
;
2840 context
->refcount
= 1;
2842 ID3D11Device2_AddRef(&device
->ID3D11Device2_iface
);
2844 wined3d_private_store_init(&context
->private_store
);
2847 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
2849 wined3d_private_store_cleanup(&context
->private_store
);
2852 /* ID3D11Device methods */
2854 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device2
*iface
, REFIID iid
, void **out
)
2856 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2857 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
2860 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device2
*iface
)
2862 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2863 return IUnknown_AddRef(device
->outer_unk
);
2866 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device2
*iface
)
2868 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2869 return IUnknown_Release(device
->outer_unk
);
2872 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device2
*iface
, const D3D11_BUFFER_DESC
*desc
,
2873 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
2875 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2876 struct d3d_buffer
*object
;
2879 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2881 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
2884 *buffer
= &object
->ID3D11Buffer_iface
;
2889 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device2
*iface
,
2890 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
2892 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2893 struct d3d_texture1d
*object
;
2896 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2898 if (FAILED(hr
= d3d_texture1d_create(device
, desc
, data
, &object
)))
2901 *texture
= &object
->ID3D11Texture1D_iface
;
2906 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device2
*iface
,
2907 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2909 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2910 struct d3d_texture2d
*object
;
2913 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2915 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2918 *texture
= &object
->ID3D11Texture2D_iface
;
2923 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device2
*iface
,
2924 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2926 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2927 struct d3d_texture3d
*object
;
2930 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2932 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2935 *texture
= &object
->ID3D11Texture3D_iface
;
2940 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device2
*iface
,
2941 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2943 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2944 struct d3d_shader_resource_view
*object
;
2947 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2950 return E_INVALIDARG
;
2952 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2955 *view
= &object
->ID3D11ShaderResourceView_iface
;
2960 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device2
*iface
,
2961 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2963 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2964 struct d3d11_unordered_access_view
*object
;
2967 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2969 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
2972 *view
= &object
->ID3D11UnorderedAccessView_iface
;
2977 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device2
*iface
,
2978 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2980 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
2981 struct d3d_rendertarget_view
*object
;
2984 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2987 return E_INVALIDARG
;
2989 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2992 *view
= &object
->ID3D11RenderTargetView_iface
;
2997 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device2
*iface
,
2998 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
3000 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3001 struct d3d_depthstencil_view
*object
;
3004 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
3006 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
3009 *view
= &object
->ID3D11DepthStencilView_iface
;
3014 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device2
*iface
,
3015 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
3016 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
3018 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3019 struct d3d_input_layout
*object
;
3022 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
3023 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
3024 shader_byte_code_length
, input_layout
);
3026 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
3027 shader_byte_code
, shader_byte_code_length
, &object
)))
3030 *input_layout
= &object
->ID3D11InputLayout_iface
;
3035 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device2
*iface
, const void *byte_code
,
3036 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
3038 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3039 struct d3d_vertex_shader
*object
;
3042 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3043 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3046 FIXME("Class linkage is not implemented yet.\n");
3048 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3051 *shader
= &object
->ID3D11VertexShader_iface
;
3056 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device2
*iface
, const void *byte_code
,
3057 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3059 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3060 struct d3d_geometry_shader
*object
;
3063 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3064 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3067 FIXME("Class linkage is not implemented yet.\n");
3069 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3070 NULL
, 0, NULL
, 0, 0, &object
)))
3073 *shader
= &object
->ID3D11GeometryShader_iface
;
3078 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2
*iface
,
3079 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
3080 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterizer_stream
,
3081 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
3083 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3084 struct d3d_geometry_shader
*object
;
3087 TRACE("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
3088 "buffer_strides %p, strides_count %u, rasterizer_stream %u, class_linkage %p, shader %p.\n",
3089 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
3090 rasterizer_stream
, class_linkage
, shader
);
3093 FIXME("Class linkage is not implemented yet.\n");
3095 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
3096 so_entries
, entry_count
, buffer_strides
, strides_count
, rasterizer_stream
, &object
)))
3102 *shader
= &object
->ID3D11GeometryShader_iface
;
3107 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device2
*iface
, const void *byte_code
,
3108 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
3110 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3111 struct d3d_pixel_shader
*object
;
3114 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3115 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3118 FIXME("Class linkage is not implemented yet.\n");
3120 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3123 *shader
= &object
->ID3D11PixelShader_iface
;
3128 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device2
*iface
, const void *byte_code
,
3129 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
3131 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3132 struct d3d11_hull_shader
*object
;
3135 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3136 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3139 FIXME("Class linkage is not implemented yet.\n");
3141 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3144 *shader
= &object
->ID3D11HullShader_iface
;
3149 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device2
*iface
, const void *byte_code
,
3150 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
3152 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3153 struct d3d11_domain_shader
*object
;
3156 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3157 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3160 FIXME("Class linkage is not implemented yet.\n");
3162 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3165 *shader
= &object
->ID3D11DomainShader_iface
;
3170 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device2
*iface
, const void *byte_code
,
3171 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
3173 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3174 struct d3d11_compute_shader
*object
;
3177 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
3178 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
3181 FIXME("Class linkage is not implemented yet.\n");
3183 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
3186 *shader
= &object
->ID3D11ComputeShader_iface
;
3191 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device2
*iface
,
3192 ID3D11ClassLinkage
**class_linkage
)
3194 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3195 struct d3d11_class_linkage
*object
;
3198 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
3200 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
3203 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
3208 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device2
*iface
,
3209 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
3211 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3212 struct d3d_blend_state
*object
;
3215 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
3217 if (FAILED(hr
= d3d_blend_state_create(device
, desc
, &object
)))
3220 *blend_state
= &object
->ID3D11BlendState_iface
;
3225 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device2
*iface
,
3226 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
3228 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3229 struct d3d_depthstencil_state
*object
;
3232 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
3234 if (FAILED(hr
= d3d_depthstencil_state_create(device
, desc
, &object
)))
3237 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
3242 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device2
*iface
,
3243 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
3245 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3246 struct d3d_rasterizer_state
*object
;
3249 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
3251 if (FAILED(hr
= d3d_rasterizer_state_create(device
, desc
, &object
)))
3254 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
3259 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device2
*iface
,
3260 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
3262 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3263 struct d3d_sampler_state
*object
;
3266 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
3268 if (FAILED(hr
= d3d_sampler_state_create(device
, desc
, &object
)))
3271 *sampler_state
= &object
->ID3D11SamplerState_iface
;
3276 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device2
*iface
,
3277 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
3279 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3280 struct d3d_query
*object
;
3283 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
3285 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
3290 *query
= &object
->ID3D11Query_iface
;
3294 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3298 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device2
*iface
, const D3D11_QUERY_DESC
*desc
,
3299 ID3D11Predicate
**predicate
)
3301 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3302 struct d3d_query
*object
;
3305 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
3307 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
3312 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
3316 ID3D11Query_Release(&object
->ID3D11Query_iface
);
3320 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3321 ID3D11Counter
**counter
)
3323 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
3328 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device2
*iface
, UINT flags
,
3329 ID3D11DeviceContext
**context
)
3331 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3337 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device2
*iface
, HANDLE resource
, REFIID iid
,
3340 FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface
, resource
, debugstr_guid(iid
), out
);
3345 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device2
*iface
, DXGI_FORMAT format
,
3346 UINT
*format_support
)
3348 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3349 struct wined3d_device_creation_parameters params
;
3350 struct wined3d_adapter
*wined3d_adapter
;
3351 enum wined3d_format_id wined3d_format
;
3352 D3D_FEATURE_LEVEL feature_level
;
3353 struct wined3d
*wined3d
;
3358 enum wined3d_resource_type rtype
;
3359 unsigned int bind_flags
;
3360 D3D11_FORMAT_SUPPORT flag
;
3364 {WINED3D_RTYPE_TEXTURE_1D
, WINED3D_BIND_SHADER_RESOURCE
, D3D11_FORMAT_SUPPORT_TEXTURE1D
},
3365 {WINED3D_RTYPE_TEXTURE_2D
, WINED3D_BIND_SHADER_RESOURCE
, D3D11_FORMAT_SUPPORT_TEXTURE2D
},
3366 {WINED3D_RTYPE_TEXTURE_3D
, WINED3D_BIND_SHADER_RESOURCE
, D3D11_FORMAT_SUPPORT_TEXTURE3D
},
3367 {WINED3D_RTYPE_NONE
, WINED3D_BIND_RENDER_TARGET
, D3D11_FORMAT_SUPPORT_RENDER_TARGET
},
3368 {WINED3D_RTYPE_NONE
, WINED3D_BIND_DEPTH_STENCIL
, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
},
3372 FIXME("iface %p, format %u, format_support %p partial-stub!\n", iface
, format
, format_support
);
3374 wined3d_format
= wined3dformat_from_dxgi_format(format
);
3375 if (format
&& !wined3d_format
)
3377 WARN("Invalid format %#x.\n", format
);
3378 *format_support
= 0;
3382 *format_support
= 0;
3384 wined3d_mutex_lock();
3385 feature_level
= device
->feature_level
;
3386 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3387 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3388 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3389 for (i
= 0; i
< ARRAY_SIZE(flag_mapping
); ++i
)
3391 hr
= wined3d_check_device_format(wined3d
, wined3d_adapter
, params
.device_type
,
3392 WINED3DFMT_UNKNOWN
, 0, flag_mapping
[i
].bind_flags
, flag_mapping
[i
].rtype
, wined3d_format
);
3393 if (hr
== WINED3DERR_NOTAVAILABLE
|| hr
== WINED3DOK_NOMIPGEN
)
3395 if (hr
!= WINED3D_OK
)
3397 WARN("Failed to check device format support, hr %#x.\n", hr
);
3398 wined3d_mutex_unlock();
3402 *format_support
|= flag_mapping
[i
].flag
;
3404 wined3d_mutex_unlock();
3406 if (*format_support
& (D3D11_FORMAT_SUPPORT_TEXTURE1D
3407 | D3D11_FORMAT_SUPPORT_TEXTURE2D
| D3D11_FORMAT_SUPPORT_TEXTURE3D
))
3409 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_LOAD
;
3410 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
;
3412 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3413 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER
;
3415 if (*format_support
& D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
)
3417 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
3418 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
;
3420 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
3421 *format_support
|= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
;
3428 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2
*iface
,
3429 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
3431 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3432 struct wined3d_device_creation_parameters params
;
3433 struct wined3d_adapter
*wined3d_adapter
;
3434 struct wined3d
*wined3d
;
3437 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
3438 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
3440 if (!quality_level_count
)
3441 return E_INVALIDARG
;
3443 *quality_level_count
= 0;
3447 if (sample_count
== 1)
3449 *quality_level_count
= 1;
3452 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
3455 wined3d_mutex_lock();
3456 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
3457 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
3458 wined3d_adapter
= wined3d_get_adapter(wined3d
, params
.adapter_idx
);
3459 hr
= wined3d_check_device_multisample_type(wined3d_adapter
, params
.device_type
,
3460 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
3461 wined3d_mutex_unlock();
3463 if (hr
== WINED3DERR_INVALIDCALL
)
3464 return E_INVALIDARG
;
3465 if (hr
== WINED3DERR_NOTAVAILABLE
)
3470 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device2
*iface
, D3D11_COUNTER_INFO
*info
)
3472 FIXME("iface %p, info %p stub!\n", iface
, info
);
3475 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device2
*iface
, const D3D11_COUNTER_DESC
*desc
,
3476 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
3477 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
3479 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
3480 "units %p, units_length %p, description %p, description_length %p stub!\n",
3481 iface
, desc
, type
, active_counter_count
, name
, name_length
,
3482 units
, units_length
, description
, description_length
);
3487 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device2
*iface
, D3D11_FEATURE feature
,
3488 void *feature_support_data
, UINT feature_support_data_size
)
3490 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3491 struct wined3d_caps wined3d_caps
;
3494 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
3495 iface
, feature
, feature_support_data
, feature_support_data_size
);
3499 case D3D11_FEATURE_THREADING
:
3501 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
3502 if (feature_support_data_size
!= sizeof(*threading_data
))
3504 WARN("Invalid data size.\n");
3505 return E_INVALIDARG
;
3508 /* We lie about the threading support to make Tomb Raider 2013 and
3509 * Deus Ex: Human Revolution happy. */
3510 FIXME("Returning fake threading support data.\n");
3511 threading_data
->DriverConcurrentCreates
= TRUE
;
3512 threading_data
->DriverCommandLists
= TRUE
;
3516 case D3D11_FEATURE_DOUBLES
:
3518 D3D11_FEATURE_DATA_DOUBLES
*doubles_data
= feature_support_data
;
3519 if (feature_support_data_size
!= sizeof(*doubles_data
))
3521 WARN("Invalid data size.\n");
3522 return E_INVALIDARG
;
3525 wined3d_mutex_lock();
3526 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3527 wined3d_mutex_unlock();
3530 WARN("Failed to get device caps, hr %#x.\n", hr
);
3534 doubles_data
->DoublePrecisionFloatShaderOps
= wined3d_caps
.shader_double_precision
;
3538 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
3540 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
3541 if (feature_support_data_size
!= sizeof(*options
))
3543 WARN("Invalid data size.\n");
3544 return E_INVALIDARG
;
3547 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
3551 case D3D11_FEATURE_D3D11_OPTIONS
:
3553 D3D11_FEATURE_DATA_D3D11_OPTIONS
*options
= feature_support_data
;
3554 if (feature_support_data_size
!= sizeof(*options
))
3556 WARN("Invalid data size.\n");
3557 return E_INVALIDARG
;
3560 FIXME("Returning fake Options support data.\n");
3561 options
->OutputMergerLogicOp
= FALSE
;
3562 options
->UAVOnlyRenderingForcedSampleCount
= FALSE
;
3563 options
->DiscardAPIsSeenByDriver
= FALSE
;
3564 options
->FlagsForUpdateAndCopySeenByDriver
= FALSE
;
3565 options
->ClearView
= FALSE
;
3566 options
->CopyWithOverlap
= FALSE
;
3567 options
->ConstantBufferPartialUpdate
= FALSE
;
3568 options
->ConstantBufferOffsetting
= FALSE
;
3569 options
->MapNoOverwriteOnDynamicConstantBuffer
= FALSE
;
3570 options
->MapNoOverwriteOnDynamicBufferSRV
= FALSE
;
3571 options
->MultisampleRTVWithForcedSampleCountOne
= FALSE
;
3572 options
->SAD4ShaderInstructions
= FALSE
;
3573 options
->ExtendedDoublesShaderInstructions
= FALSE
;
3574 options
->ExtendedResourceSharing
= FALSE
;
3578 case D3D11_FEATURE_D3D11_OPTIONS1
:
3580 D3D11_FEATURE_DATA_D3D11_OPTIONS1
*options
= feature_support_data
;
3581 if (feature_support_data_size
!= sizeof(*options
))
3583 WARN("Invalid data size.\n");
3584 return E_INVALIDARG
;
3587 FIXME("Returning fake Options1 support data.\n");
3588 options
->TiledResourcesTier
= D3D11_TILED_RESOURCES_NOT_SUPPORTED
;
3589 options
->MinMaxFiltering
= FALSE
;
3590 options
->ClearViewAlsoSupportsDepthOnlyFormats
= FALSE
;
3591 options
->MapOnDefaultBuffers
= FALSE
;
3595 case D3D11_FEATURE_D3D11_OPTIONS3
:
3597 D3D11_FEATURE_DATA_D3D11_OPTIONS3
*options
= feature_support_data
;
3598 if (feature_support_data_size
!= sizeof(*options
))
3600 WARN("Invalid data size.\n");
3601 return E_INVALIDARG
;
3604 wined3d_mutex_lock();
3605 hr
= wined3d_device_get_device_caps(device
->wined3d_device
, &wined3d_caps
);
3606 wined3d_mutex_unlock();
3609 WARN("Failed to get device caps, hr %#x.\n", hr
);
3613 options
->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
3614 = wined3d_caps
.viewport_array_index_any_shader
;
3618 case D3D11_FEATURE_ARCHITECTURE_INFO
:
3620 D3D11_FEATURE_DATA_ARCHITECTURE_INFO
*options
= feature_support_data
;
3621 if (feature_support_data_size
!= sizeof(*options
))
3623 WARN("Invalid data size.\n");
3624 return E_INVALIDARG
;
3627 FIXME("Returning fake data architecture info.\n");
3628 options
->TileBasedDeferredRenderer
= FALSE
;
3633 FIXME("Unhandled feature %#x.\n", feature
);
3638 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
3639 UINT
*data_size
, void *data
)
3641 IDXGIDevice
*dxgi_device
;
3644 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3646 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3648 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
3649 IDXGIDevice_Release(dxgi_device
);
3654 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device2
*iface
, REFGUID guid
,
3655 UINT data_size
, const void *data
)
3657 IDXGIDevice
*dxgi_device
;
3660 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3662 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3664 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
3665 IDXGIDevice_Release(dxgi_device
);
3670 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device2
*iface
, REFGUID guid
,
3671 const IUnknown
*data
)
3673 IDXGIDevice
*dxgi_device
;
3676 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
3678 if (FAILED(hr
= ID3D11Device2_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
3680 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
3681 IDXGIDevice_Release(dxgi_device
);
3686 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device2
*iface
)
3688 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3690 TRACE("iface %p.\n", iface
);
3692 return device
->feature_level
;
3695 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device2
*iface
)
3697 FIXME("iface %p stub!\n", iface
);
3702 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device2
*iface
)
3704 WARN("iface %p stub!\n", iface
);
3709 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device2
*iface
,
3710 ID3D11DeviceContext
**immediate_context
)
3712 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3714 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3716 *immediate_context
= (ID3D11DeviceContext
*)&device
->immediate_context
.ID3D11DeviceContext1_iface
;
3717 ID3D11DeviceContext_AddRef(*immediate_context
);
3720 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device2
*iface
, UINT flags
)
3722 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
3727 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device2
*iface
)
3729 FIXME("iface %p stub!\n", iface
);
3734 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext1(ID3D11Device2
*iface
,
3735 ID3D11DeviceContext1
**immediate_context
)
3737 struct d3d_device
*device
= impl_from_ID3D11Device2(iface
);
3739 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
3741 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext1_iface
;
3742 ID3D11DeviceContext1_AddRef(*immediate_context
);
3745 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext1(ID3D11Device2
*iface
, UINT flags
,
3746 ID3D11DeviceContext1
**context
)
3748 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3753 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState1(ID3D11Device2
*iface
,
3754 const D3D11_BLEND_DESC1
*desc
, ID3D11BlendState1
**state
)
3756 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
3761 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState1(ID3D11Device2
*iface
,
3762 const D3D11_RASTERIZER_DESC1
*desc
, ID3D11RasterizerState1
**state
)
3764 FIXME("iface %p, desc %p, state %p stub!\n", iface
, desc
, state
);
3769 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeviceContextState(ID3D11Device2
*iface
, UINT flags
,
3770 const D3D_FEATURE_LEVEL
*feature_levels
, UINT feature_levels_count
, UINT sdk_version
,
3771 REFIID emulated_interface
, D3D_FEATURE_LEVEL
*chosen_feature_level
, ID3DDeviceContextState
**state
)
3773 FIXME("iface %p, flags %#x, feature_levels %p, feature_level_count %u, sdk_version %u, "
3774 "emulated_interface %s, chosen_feature_level %p, state %p stub!\n", iface
, flags
, feature_levels
,
3775 feature_levels_count
, sdk_version
, debugstr_guid(emulated_interface
), chosen_feature_level
, state
);
3780 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource1(ID3D11Device2
*iface
, HANDLE handle
,
3781 REFIID iid
, void **resource
)
3783 FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface
, handle
, debugstr_guid(iid
), resource
);
3788 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResourceByName(ID3D11Device2
*iface
, const WCHAR
*name
,
3789 DWORD access
, REFIID iid
, void **resource
)
3791 FIXME("iface %p, name %s, access %#x, iid %s, resource %p stub!\n", iface
, debugstr_w(name
), access
,
3792 debugstr_guid(iid
), resource
);
3797 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext2(ID3D11Device2
*iface
,
3798 ID3D11DeviceContext2
**context
)
3800 FIXME("iface %p, context %p stub!\n", iface
, context
);
3803 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext2(ID3D11Device2
*iface
,
3804 UINT flags
, ID3D11DeviceContext2
**context
)
3806 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
3811 static void STDMETHODCALLTYPE
d3d11_device_GetResourceTiling(ID3D11Device2
*iface
,
3812 ID3D11Resource
*resource
, UINT
*tile_count
, D3D11_PACKED_MIP_DESC
*mip_desc
,
3813 D3D11_TILE_SHAPE
*tile_shape
, UINT
*subresource_tiling_count
, UINT first_subresource_tiling
,
3814 D3D11_SUBRESOURCE_TILING
*subresource_tiling
)
3816 FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, "
3817 "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n",
3818 iface
, resource
, tile_count
, mip_desc
, tile_shape
,
3819 subresource_tiling_count
, first_subresource_tiling
, subresource_tiling
);
3822 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2
*iface
,
3823 DXGI_FORMAT format
, UINT sample_count
, UINT flags
, UINT
*quality_level_count
)
3825 FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n",
3826 iface
, format
, sample_count
, flags
, quality_level_count
);
3831 static const struct ID3D11Device2Vtbl d3d11_device_vtbl
=
3833 /* IUnknown methods */
3834 d3d11_device_QueryInterface
,
3835 d3d11_device_AddRef
,
3836 d3d11_device_Release
,
3837 /* ID3D11Device methods */
3838 d3d11_device_CreateBuffer
,
3839 d3d11_device_CreateTexture1D
,
3840 d3d11_device_CreateTexture2D
,
3841 d3d11_device_CreateTexture3D
,
3842 d3d11_device_CreateShaderResourceView
,
3843 d3d11_device_CreateUnorderedAccessView
,
3844 d3d11_device_CreateRenderTargetView
,
3845 d3d11_device_CreateDepthStencilView
,
3846 d3d11_device_CreateInputLayout
,
3847 d3d11_device_CreateVertexShader
,
3848 d3d11_device_CreateGeometryShader
,
3849 d3d11_device_CreateGeometryShaderWithStreamOutput
,
3850 d3d11_device_CreatePixelShader
,
3851 d3d11_device_CreateHullShader
,
3852 d3d11_device_CreateDomainShader
,
3853 d3d11_device_CreateComputeShader
,
3854 d3d11_device_CreateClassLinkage
,
3855 d3d11_device_CreateBlendState
,
3856 d3d11_device_CreateDepthStencilState
,
3857 d3d11_device_CreateRasterizerState
,
3858 d3d11_device_CreateSamplerState
,
3859 d3d11_device_CreateQuery
,
3860 d3d11_device_CreatePredicate
,
3861 d3d11_device_CreateCounter
,
3862 d3d11_device_CreateDeferredContext
,
3863 d3d11_device_OpenSharedResource
,
3864 d3d11_device_CheckFormatSupport
,
3865 d3d11_device_CheckMultisampleQualityLevels
,
3866 d3d11_device_CheckCounterInfo
,
3867 d3d11_device_CheckCounter
,
3868 d3d11_device_CheckFeatureSupport
,
3869 d3d11_device_GetPrivateData
,
3870 d3d11_device_SetPrivateData
,
3871 d3d11_device_SetPrivateDataInterface
,
3872 d3d11_device_GetFeatureLevel
,
3873 d3d11_device_GetCreationFlags
,
3874 d3d11_device_GetDeviceRemovedReason
,
3875 d3d11_device_GetImmediateContext
,
3876 d3d11_device_SetExceptionMode
,
3877 d3d11_device_GetExceptionMode
,
3878 /* ID3D11Device1 methods */
3879 d3d11_device_GetImmediateContext1
,
3880 d3d11_device_CreateDeferredContext1
,
3881 d3d11_device_CreateBlendState1
,
3882 d3d11_device_CreateRasterizerState1
,
3883 d3d11_device_CreateDeviceContextState
,
3884 d3d11_device_OpenSharedResource1
,
3885 d3d11_device_OpenSharedResourceByName
,
3886 /* ID3D11Device2 methods */
3887 d3d11_device_GetImmediateContext2
,
3888 d3d11_device_CreateDeferredContext2
,
3889 d3d11_device_GetResourceTiling
,
3890 d3d11_device_CheckMultisampleQualityLevels1
,
3893 /* Inner IUnknown methods */
3895 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
3897 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
3900 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
3902 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3904 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
3906 if (IsEqualGUID(riid
, &IID_ID3D11Device2
)
3907 || IsEqualGUID(riid
, &IID_ID3D11Device1
)
3908 || IsEqualGUID(riid
, &IID_ID3D11Device
)
3909 || IsEqualGUID(riid
, &IID_IUnknown
))
3911 *out
= &device
->ID3D11Device2_iface
;
3913 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
3914 || IsEqualGUID(riid
, &IID_ID3D10Device
))
3916 *out
= &device
->ID3D10Device1_iface
;
3918 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
3920 *out
= &device
->ID3D10Multithread_iface
;
3922 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
3924 *out
= &device
->IWineDXGIDeviceParent_iface
;
3928 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
3930 return E_NOINTERFACE
;
3933 IUnknown_AddRef((IUnknown
*)*out
);
3937 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
3939 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3940 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
3942 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
3947 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
3949 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3950 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
3952 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
3956 d3d11_immediate_context_destroy(&device
->immediate_context
);
3957 if (device
->wined3d_device
)
3959 wined3d_mutex_lock();
3960 wined3d_device_decref(device
->wined3d_device
);
3961 wined3d_mutex_unlock();
3963 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
3964 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3965 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3966 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3972 /* IUnknown methods */
3974 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID iid
,
3977 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3978 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
3981 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
3983 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3984 return IUnknown_AddRef(device
->outer_unk
);
3987 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
3989 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3990 return IUnknown_Release(device
->outer_unk
);
3993 /* ID3D10Device methods */
3995 static void d3d10_device_get_constant_buffers(ID3D10Device1
*iface
,
3996 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3998 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4001 wined3d_mutex_lock();
4002 for (i
= 0; i
< buffer_count
; ++i
)
4004 struct wined3d_buffer
*wined3d_buffer
;
4005 struct d3d_buffer
*buffer_impl
;
4007 if (!(wined3d_buffer
= wined3d_device_get_constant_buffer(device
->wined3d_device
,
4008 type
, start_slot
+ i
)))
4014 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4015 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4016 ID3D10Buffer_AddRef(buffers
[i
]);
4018 wined3d_mutex_unlock();
4021 static void d3d10_device_set_constant_buffers(ID3D10Device1
*iface
,
4022 enum wined3d_shader_type type
, UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4024 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4027 wined3d_mutex_lock();
4028 for (i
= 0; i
< buffer_count
; ++i
)
4030 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4032 wined3d_device_set_constant_buffer(device
->wined3d_device
, type
, start_slot
+ i
,
4033 buffer
? buffer
->wined3d_buffer
: NULL
);
4035 wined3d_mutex_unlock();
4038 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
4039 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4041 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4042 iface
, start_slot
, buffer_count
, buffers
);
4044 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
,
4045 buffer_count
, buffers
);
4048 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
4049 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4051 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4054 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4055 iface
, start_slot
, view_count
, views
);
4057 wined3d_mutex_lock();
4058 for (i
= 0; i
< view_count
; ++i
)
4060 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4062 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
4063 view
? view
->wined3d_view
: NULL
);
4065 wined3d_mutex_unlock();
4068 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
4069 ID3D10PixelShader
*shader
)
4071 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4072 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
4074 TRACE("iface %p, shader %p\n", iface
, shader
);
4076 wined3d_mutex_lock();
4077 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
4078 wined3d_mutex_unlock();
4081 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
4082 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4084 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4087 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4088 iface
, start_slot
, sampler_count
, samplers
);
4090 wined3d_mutex_lock();
4091 for (i
= 0; i
< sampler_count
; ++i
)
4093 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4095 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
4096 sampler
? sampler
->wined3d_sampler
: NULL
);
4098 wined3d_mutex_unlock();
4101 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
4102 ID3D10VertexShader
*shader
)
4104 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4105 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
4107 TRACE("iface %p, shader %p\n", iface
, shader
);
4109 wined3d_mutex_lock();
4110 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
4111 wined3d_mutex_unlock();
4114 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
4115 UINT start_index_location
, INT base_vertex_location
)
4117 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4119 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
4120 iface
, index_count
, start_index_location
, base_vertex_location
);
4122 wined3d_mutex_lock();
4123 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
4124 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
4125 wined3d_mutex_unlock();
4128 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
4129 UINT start_vertex_location
)
4131 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4133 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
4134 iface
, vertex_count
, start_vertex_location
);
4136 wined3d_mutex_lock();
4137 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
4138 wined3d_mutex_unlock();
4141 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
4142 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4144 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4145 iface
, start_slot
, buffer_count
, buffers
);
4147 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
,
4148 buffer_count
, buffers
);
4151 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
4152 ID3D10InputLayout
*input_layout
)
4154 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4155 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
4157 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
4159 wined3d_mutex_lock();
4160 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
4161 layout
? layout
->wined3d_decl
: NULL
);
4162 wined3d_mutex_unlock();
4165 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
4166 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
4168 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4171 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
4172 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4174 wined3d_mutex_lock();
4175 for (i
= 0; i
< buffer_count
; ++i
)
4177 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
4179 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
4180 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
4182 wined3d_mutex_unlock();
4185 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
4186 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
4188 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4189 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
4191 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
4192 iface
, buffer
, debug_dxgi_format(format
), offset
);
4194 wined3d_mutex_lock();
4195 wined3d_device_set_index_buffer(device
->wined3d_device
,
4196 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
4197 wined3dformat_from_dxgi_format(format
), offset
);
4198 wined3d_mutex_unlock();
4201 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
4202 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
4203 INT base_vertex_location
, UINT start_instance_location
)
4205 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4207 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
4208 "base_vertex_location %d, start_instance_location %u.\n",
4209 iface
, instance_index_count
, instance_count
, start_index_location
,
4210 base_vertex_location
, start_instance_location
);
4212 wined3d_mutex_lock();
4213 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
4214 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
4215 instance_index_count
, start_instance_location
, instance_count
);
4216 wined3d_mutex_unlock();
4219 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
4220 UINT instance_vertex_count
, UINT instance_count
,
4221 UINT start_vertex_location
, UINT start_instance_location
)
4223 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4225 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
4226 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
4227 start_vertex_location
, start_instance_location
);
4229 wined3d_mutex_lock();
4230 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
4231 instance_vertex_count
, start_instance_location
, instance_count
);
4232 wined3d_mutex_unlock();
4235 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
4236 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
4238 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4239 iface
, start_slot
, buffer_count
, buffers
);
4241 d3d10_device_set_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
,
4242 buffer_count
, buffers
);
4245 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
4247 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4248 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
4250 TRACE("iface %p, shader %p.\n", iface
, shader
);
4252 wined3d_mutex_lock();
4253 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
4254 wined3d_mutex_unlock();
4257 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
4258 D3D10_PRIMITIVE_TOPOLOGY topology
)
4260 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4262 TRACE("iface %p, topology %s.\n", iface
, debug_d3d10_primitive_topology(topology
));
4264 wined3d_mutex_lock();
4265 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
, 0);
4266 wined3d_mutex_unlock();
4269 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
4270 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4272 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4275 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4276 iface
, start_slot
, view_count
, views
);
4278 wined3d_mutex_lock();
4279 for (i
= 0; i
< view_count
; ++i
)
4281 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4283 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
4284 view
? view
->wined3d_view
: NULL
);
4286 wined3d_mutex_unlock();
4289 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
4290 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4292 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4295 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4296 iface
, start_slot
, sampler_count
, samplers
);
4298 wined3d_mutex_lock();
4299 for (i
= 0; i
< sampler_count
; ++i
)
4301 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4303 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
4304 sampler
? sampler
->wined3d_sampler
: NULL
);
4306 wined3d_mutex_unlock();
4309 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
4311 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4312 struct d3d_query
*query
;
4314 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
4316 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
4317 wined3d_mutex_lock();
4318 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
4319 wined3d_mutex_unlock();
4322 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
4323 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
4325 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4328 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4329 iface
, start_slot
, view_count
, views
);
4331 wined3d_mutex_lock();
4332 for (i
= 0; i
< view_count
; ++i
)
4334 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
4336 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
4337 view
? view
->wined3d_view
: NULL
);
4339 wined3d_mutex_unlock();
4342 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
4343 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
4345 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4348 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4349 iface
, start_slot
, sampler_count
, samplers
);
4351 wined3d_mutex_lock();
4352 for (i
= 0; i
< sampler_count
; ++i
)
4354 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
4356 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
4357 sampler
? sampler
->wined3d_sampler
: NULL
);
4359 wined3d_mutex_unlock();
4362 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
4363 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
4364 ID3D10DepthStencilView
*depth_stencil_view
)
4366 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4367 struct d3d_depthstencil_view
*dsv
;
4370 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4371 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
4373 wined3d_mutex_lock();
4374 for (i
= 0; i
< render_target_view_count
; ++i
)
4376 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
4378 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
4379 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
4381 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4383 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4386 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4387 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
4388 dsv
? dsv
->wined3d_view
: NULL
);
4389 wined3d_mutex_unlock();
4392 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
4393 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
4395 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4396 struct d3d_blend_state
*blend_state_object
;
4398 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
4399 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
4401 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
4402 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4403 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
4406 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
4407 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
4409 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4410 struct d3d_depthstencil_state
*ds_state_object
;
4412 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
4413 iface
, depth_stencil_state
, stencil_ref
);
4415 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
4416 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4417 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
4420 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
4421 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
4423 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4424 unsigned int count
, i
;
4426 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
4428 count
= min(target_count
, D3D10_SO_BUFFER_SLOT_COUNT
);
4429 wined3d_mutex_lock();
4430 for (i
= 0; i
< count
; ++i
)
4432 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
4434 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
4435 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
4438 for (i
= count
; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4440 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4442 wined3d_mutex_unlock();
4445 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
4447 FIXME("iface %p stub!\n", iface
);
4450 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
4452 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4453 struct d3d_rasterizer_state
*rasterizer_state_object
;
4455 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4457 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
4458 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4459 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
4462 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
4463 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
4465 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4466 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
4469 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
4471 if (viewport_count
> ARRAY_SIZE(wined3d_vp
))
4474 for (i
= 0; i
< viewport_count
; ++i
)
4476 wined3d_vp
[i
].x
= viewports
[i
].TopLeftX
;
4477 wined3d_vp
[i
].y
= viewports
[i
].TopLeftY
;
4478 wined3d_vp
[i
].width
= viewports
[i
].Width
;
4479 wined3d_vp
[i
].height
= viewports
[i
].Height
;
4480 wined3d_vp
[i
].min_z
= viewports
[i
].MinDepth
;
4481 wined3d_vp
[i
].max_z
= viewports
[i
].MaxDepth
;
4484 wined3d_mutex_lock();
4485 wined3d_device_set_viewports(device
->wined3d_device
, viewport_count
, wined3d_vp
);
4486 wined3d_mutex_unlock();
4489 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
4490 UINT rect_count
, const D3D10_RECT
*rects
)
4492 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4494 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
4496 if (rect_count
> WINED3D_MAX_VIEWPORTS
)
4499 wined3d_mutex_lock();
4500 wined3d_device_set_scissor_rects(device
->wined3d_device
, rect_count
, rects
);
4501 wined3d_mutex_unlock();
4504 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
4505 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
4506 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
4508 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4509 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4510 struct wined3d_box wined3d_src_box
;
4512 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
4513 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
4514 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
4515 src_resource
, src_subresource_idx
, src_box
);
4518 wined3d_box_set(&wined3d_src_box
, src_box
->left
, src_box
->top
,
4519 src_box
->right
, src_box
->bottom
, src_box
->front
, src_box
->back
);
4521 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4522 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4523 wined3d_mutex_lock();
4524 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
4525 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
, 0);
4526 wined3d_mutex_unlock();
4529 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
4530 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
4532 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4533 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4535 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
4537 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4538 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4539 wined3d_mutex_lock();
4540 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
4541 wined3d_mutex_unlock();
4544 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
4545 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
4546 const void *data
, UINT row_pitch
, UINT depth_pitch
)
4548 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4549 ID3D11Resource
*d3d11_resource
;
4551 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
4552 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
4554 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
4555 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
4556 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
4557 ID3D11Resource_Release(d3d11_resource
);
4560 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
4561 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
4563 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4564 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
4565 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
4568 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
4569 iface
, render_target_view
, debug_float4(color_rgba
));
4574 wined3d_mutex_lock();
4575 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4576 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
4577 ERR("Failed to clear view, hr %#x.\n", hr
);
4578 wined3d_mutex_unlock();
4581 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
4582 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
4584 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4585 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
4586 DWORD wined3d_flags
;
4589 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
4590 iface
, depth_stencil_view
, flags
, depth
, stencil
);
4595 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
4597 wined3d_mutex_lock();
4598 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
4599 wined3d_flags
, NULL
, depth
, stencil
)))
4600 ERR("Failed to clear view, hr %#x.\n", hr
);
4601 wined3d_mutex_unlock();
4604 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
4605 ID3D10ShaderResourceView
*view
)
4607 struct d3d_shader_resource_view
*srv
= unsafe_impl_from_ID3D10ShaderResourceView(view
);
4609 TRACE("iface %p, view %p.\n", iface
, view
);
4611 wined3d_mutex_lock();
4612 wined3d_shader_resource_view_generate_mipmaps(srv
->wined3d_view
);
4613 wined3d_mutex_unlock();
4616 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
4617 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
4618 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
4620 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
4621 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4622 enum wined3d_format_id wined3d_format
;
4624 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, "
4625 "src_resource %p, src_subresource_idx %u, format %s.\n",
4626 iface
, dst_resource
, dst_subresource_idx
,
4627 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
4629 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
4630 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
4631 wined3d_format
= wined3dformat_from_dxgi_format(format
);
4632 wined3d_mutex_lock();
4633 wined3d_device_resolve_sub_resource(device
->wined3d_device
,
4634 wined3d_dst_resource
, dst_subresource_idx
,
4635 wined3d_src_resource
, src_subresource_idx
, wined3d_format
);
4636 wined3d_mutex_unlock();
4639 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
4640 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4642 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4643 iface
, start_slot
, buffer_count
, buffers
);
4645 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_VERTEX
, start_slot
, buffer_count
,
4649 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
4650 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4652 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4655 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4656 iface
, start_slot
, view_count
, views
);
4658 wined3d_mutex_lock();
4659 for (i
= 0; i
< view_count
; ++i
)
4661 struct wined3d_shader_resource_view
*wined3d_view
;
4662 struct d3d_shader_resource_view
*view_impl
;
4664 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4670 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4671 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4672 ID3D10ShaderResourceView_AddRef(views
[i
]);
4674 wined3d_mutex_unlock();
4677 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
4679 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4680 struct d3d_pixel_shader
*shader_impl
;
4681 struct wined3d_shader
*wined3d_shader
;
4683 TRACE("iface %p, shader %p.\n", iface
, shader
);
4685 wined3d_mutex_lock();
4686 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
4688 wined3d_mutex_unlock();
4693 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4694 wined3d_mutex_unlock();
4695 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
4696 ID3D10PixelShader_AddRef(*shader
);
4699 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
4700 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4702 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4705 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4706 iface
, start_slot
, sampler_count
, samplers
);
4708 wined3d_mutex_lock();
4709 for (i
= 0; i
< sampler_count
; ++i
)
4711 struct d3d_sampler_state
*sampler_impl
;
4712 struct wined3d_sampler
*wined3d_sampler
;
4714 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
4720 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4721 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4722 ID3D10SamplerState_AddRef(samplers
[i
]);
4724 wined3d_mutex_unlock();
4727 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
4729 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4730 struct d3d_vertex_shader
*shader_impl
;
4731 struct wined3d_shader
*wined3d_shader
;
4733 TRACE("iface %p, shader %p.\n", iface
, shader
);
4735 wined3d_mutex_lock();
4736 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
4738 wined3d_mutex_unlock();
4743 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4744 wined3d_mutex_unlock();
4745 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
4746 ID3D10VertexShader_AddRef(*shader
);
4749 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
4750 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4752 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4753 iface
, start_slot
, buffer_count
, buffers
);
4755 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_PIXEL
, start_slot
, buffer_count
,
4759 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
4761 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4762 struct wined3d_vertex_declaration
*wined3d_declaration
;
4763 struct d3d_input_layout
*input_layout_impl
;
4765 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
4767 wined3d_mutex_lock();
4768 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
4770 wined3d_mutex_unlock();
4771 *input_layout
= NULL
;
4775 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
4776 wined3d_mutex_unlock();
4777 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
4778 ID3D10InputLayout_AddRef(*input_layout
);
4781 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
4782 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
4784 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4787 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
4788 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
4790 wined3d_mutex_lock();
4791 for (i
= 0; i
< buffer_count
; ++i
)
4793 struct wined3d_buffer
*wined3d_buffer
= NULL
;
4794 struct d3d_buffer
*buffer_impl
;
4796 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
4797 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
4798 ERR("Failed to get vertex buffer.\n");
4800 if (!wined3d_buffer
)
4806 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4807 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4808 ID3D10Buffer_AddRef(buffers
[i
]);
4810 wined3d_mutex_unlock();
4813 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
4814 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
4816 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4817 enum wined3d_format_id wined3d_format
;
4818 struct wined3d_buffer
*wined3d_buffer
;
4819 struct d3d_buffer
*buffer_impl
;
4821 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
4823 wined3d_mutex_lock();
4824 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
4825 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
4826 if (!wined3d_buffer
)
4828 wined3d_mutex_unlock();
4833 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4834 wined3d_mutex_unlock();
4835 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
4836 ID3D10Buffer_AddRef(*buffer
);
4839 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
4840 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
4842 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
4843 iface
, start_slot
, buffer_count
, buffers
);
4845 d3d10_device_get_constant_buffers(iface
, WINED3D_SHADER_TYPE_GEOMETRY
, start_slot
, buffer_count
,
4849 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
4851 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4852 struct d3d_geometry_shader
*shader_impl
;
4853 struct wined3d_shader
*wined3d_shader
;
4855 TRACE("iface %p, shader %p.\n", iface
, shader
);
4857 wined3d_mutex_lock();
4858 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
4860 wined3d_mutex_unlock();
4865 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4866 wined3d_mutex_unlock();
4867 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
4868 ID3D10GeometryShader_AddRef(*shader
);
4871 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
4872 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
4874 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4876 TRACE("iface %p, topology %p.\n", iface
, topology
);
4878 wined3d_mutex_lock();
4879 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
, NULL
);
4880 wined3d_mutex_unlock();
4883 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
4884 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4886 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4889 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4890 iface
, start_slot
, view_count
, views
);
4892 wined3d_mutex_lock();
4893 for (i
= 0; i
< view_count
; ++i
)
4895 struct wined3d_shader_resource_view
*wined3d_view
;
4896 struct d3d_shader_resource_view
*view_impl
;
4898 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4904 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4905 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4906 ID3D10ShaderResourceView_AddRef(views
[i
]);
4908 wined3d_mutex_unlock();
4911 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
4912 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4914 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4917 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4918 iface
, start_slot
, sampler_count
, samplers
);
4920 wined3d_mutex_lock();
4921 for (i
= 0; i
< sampler_count
; ++i
)
4923 struct d3d_sampler_state
*sampler_impl
;
4924 struct wined3d_sampler
*wined3d_sampler
;
4926 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4932 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4933 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4934 ID3D10SamplerState_AddRef(samplers
[i
]);
4936 wined3d_mutex_unlock();
4939 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
4940 ID3D10Predicate
**predicate
, BOOL
*value
)
4942 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4943 struct wined3d_query
*wined3d_predicate
;
4944 struct d3d_query
*predicate_impl
;
4946 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
4948 wined3d_mutex_lock();
4949 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
4951 wined3d_mutex_unlock();
4956 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
4957 wined3d_mutex_unlock();
4958 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
4959 ID3D10Predicate_AddRef(*predicate
);
4962 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
4963 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4965 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4968 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4969 iface
, start_slot
, view_count
, views
);
4971 wined3d_mutex_lock();
4972 for (i
= 0; i
< view_count
; ++i
)
4974 struct wined3d_shader_resource_view
*wined3d_view
;
4975 struct d3d_shader_resource_view
*view_impl
;
4977 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4983 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4984 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4985 ID3D10ShaderResourceView_AddRef(views
[i
]);
4987 wined3d_mutex_unlock();
4990 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
4991 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4993 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4996 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4997 iface
, start_slot
, sampler_count
, samplers
);
4999 wined3d_mutex_lock();
5000 for (i
= 0; i
< sampler_count
; ++i
)
5002 struct d3d_sampler_state
*sampler_impl
;
5003 struct wined3d_sampler
*wined3d_sampler
;
5005 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
5011 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
5012 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
5013 ID3D10SamplerState_AddRef(samplers
[i
]);
5015 wined3d_mutex_unlock();
5018 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
5019 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
5021 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5022 struct wined3d_rendertarget_view
*wined3d_view
;
5024 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
5025 iface
, view_count
, render_target_views
, depth_stencil_view
);
5027 wined3d_mutex_lock();
5028 if (render_target_views
)
5030 struct d3d_rendertarget_view
*view_impl
;
5033 for (i
= 0; i
< view_count
; ++i
)
5035 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
5036 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5038 render_target_views
[i
] = NULL
;
5042 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
5043 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
5047 if (depth_stencil_view
)
5049 struct d3d_depthstencil_view
*view_impl
;
5051 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
5052 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
5054 *depth_stencil_view
= NULL
;
5058 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
5059 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
5062 wined3d_mutex_unlock();
5065 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
5066 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
5068 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5069 ID3D11BlendState
*d3d11_blend_state
;
5071 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
5072 iface
, blend_state
, blend_factor
, sample_mask
);
5074 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5075 &d3d11_blend_state
, blend_factor
, sample_mask
);
5077 if (d3d11_blend_state
)
5078 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
5080 *blend_state
= NULL
;
5083 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
5084 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
5086 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5087 ID3D11DepthStencilState
*d3d11_iface
;
5089 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
5090 iface
, depth_stencil_state
, stencil_ref
);
5092 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext1_iface
,
5093 &d3d11_iface
, stencil_ref
);
5096 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
5098 *depth_stencil_state
= NULL
;
5101 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
5102 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
5104 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5107 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
5108 iface
, buffer_count
, buffers
, offsets
);
5110 wined3d_mutex_lock();
5111 for (i
= 0; i
< buffer_count
; ++i
)
5113 struct wined3d_buffer
*wined3d_buffer
;
5114 struct d3d_buffer
*buffer_impl
;
5116 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
5122 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
5123 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
5124 ID3D10Buffer_AddRef(buffers
[i
]);
5126 wined3d_mutex_unlock();
5129 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
5131 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5132 struct d3d_rasterizer_state
*rasterizer_state_impl
;
5133 struct wined3d_rasterizer_state
*wined3d_state
;
5135 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
5137 wined3d_mutex_lock();
5138 if ((wined3d_state
= wined3d_device_get_rasterizer_state(device
->wined3d_device
)))
5140 rasterizer_state_impl
= wined3d_rasterizer_state_get_parent(wined3d_state
);
5141 ID3D10RasterizerState_AddRef(*rasterizer_state
= &rasterizer_state_impl
->ID3D10RasterizerState_iface
);
5145 *rasterizer_state
= NULL
;
5147 wined3d_mutex_unlock();
5150 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
5151 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
5153 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5154 struct wined3d_viewport wined3d_vp
[WINED3D_MAX_VIEWPORTS
];
5155 unsigned int actual_count
= ARRAY_SIZE(wined3d_vp
), i
;
5157 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
5159 if (!viewport_count
)
5162 wined3d_mutex_lock();
5163 wined3d_device_get_viewports(device
->wined3d_device
, &actual_count
, viewports
? wined3d_vp
: NULL
);
5164 wined3d_mutex_unlock();
5168 *viewport_count
= actual_count
;
5172 if (*viewport_count
> actual_count
)
5173 memset(&viewports
[actual_count
], 0, (*viewport_count
- actual_count
) * sizeof(*viewports
));
5175 *viewport_count
= min(actual_count
, *viewport_count
);
5176 for (i
= 0; i
< *viewport_count
; ++i
)
5178 viewports
[i
].TopLeftX
= wined3d_vp
[i
].x
;
5179 viewports
[i
].TopLeftY
= wined3d_vp
[i
].y
;
5180 viewports
[i
].Width
= wined3d_vp
[i
].width
;
5181 viewports
[i
].Height
= wined3d_vp
[i
].height
;
5182 viewports
[i
].MinDepth
= wined3d_vp
[i
].min_z
;
5183 viewports
[i
].MaxDepth
= wined3d_vp
[i
].max_z
;
5187 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
5189 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5190 unsigned int actual_count
;
5192 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
5197 actual_count
= *rect_count
;
5199 wined3d_mutex_lock();
5200 wined3d_device_get_scissor_rects(device
->wined3d_device
, &actual_count
, rects
);
5201 wined3d_mutex_unlock();
5205 *rect_count
= actual_count
;
5209 if (*rect_count
> actual_count
)
5210 memset(&rects
[actual_count
], 0, (*rect_count
- actual_count
) * sizeof(*rects
));
5213 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
5215 TRACE("iface %p.\n", iface
);
5217 /* In the current implementation the device is never removed, so we can
5218 * just return S_OK here. */
5223 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
5225 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
5230 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
5232 FIXME("iface %p stub!\n", iface
);
5237 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
5238 REFGUID guid
, UINT
*data_size
, void *data
)
5240 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5242 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5244 return d3d11_device_GetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5247 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
5248 REFGUID guid
, UINT data_size
, const void *data
)
5250 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5252 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
5254 return d3d11_device_SetPrivateData(&device
->ID3D11Device2_iface
, guid
, data_size
, data
);
5257 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
5258 REFGUID guid
, const IUnknown
*data
)
5260 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5262 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
5264 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device2_iface
, guid
, data
);
5267 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
5269 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5271 TRACE("iface %p.\n", iface
);
5273 d3d11_immediate_context_ClearState(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
5276 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
5278 FIXME("iface %p stub!\n", iface
);
5281 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
5282 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
5284 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5285 D3D11_BUFFER_DESC d3d11_desc
;
5286 struct d3d_buffer
*object
;
5289 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
5291 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
5292 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5293 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5294 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5295 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5296 d3d11_desc
.StructureByteStride
= 0;
5298 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5301 *buffer
= &object
->ID3D10Buffer_iface
;
5306 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
5307 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
5309 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5310 D3D11_TEXTURE1D_DESC d3d11_desc
;
5311 struct d3d_texture1d
*object
;
5314 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5316 d3d11_desc
.Width
= desc
->Width
;
5317 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5318 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5319 d3d11_desc
.Format
= desc
->Format
;
5320 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5321 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5322 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5323 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5325 if (FAILED(hr
= d3d_texture1d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5328 *texture
= &object
->ID3D10Texture1D_iface
;
5333 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
5334 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5335 ID3D10Texture2D
**texture
)
5337 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5338 D3D11_TEXTURE2D_DESC d3d11_desc
;
5339 struct d3d_texture2d
*object
;
5342 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5344 d3d11_desc
.Width
= desc
->Width
;
5345 d3d11_desc
.Height
= desc
->Height
;
5346 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5347 d3d11_desc
.ArraySize
= desc
->ArraySize
;
5348 d3d11_desc
.Format
= desc
->Format
;
5349 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
5350 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5351 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5352 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5353 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5355 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5358 *texture
= &object
->ID3D10Texture2D_iface
;
5363 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
5364 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
5365 ID3D10Texture3D
**texture
)
5367 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5368 D3D11_TEXTURE3D_DESC d3d11_desc
;
5369 struct d3d_texture3d
*object
;
5372 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
5374 d3d11_desc
.Width
= desc
->Width
;
5375 d3d11_desc
.Height
= desc
->Height
;
5376 d3d11_desc
.Depth
= desc
->Depth
;
5377 d3d11_desc
.MipLevels
= desc
->MipLevels
;
5378 d3d11_desc
.Format
= desc
->Format
;
5379 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
5380 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
5381 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
5382 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
5384 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
5387 *texture
= &object
->ID3D10Texture3D_iface
;
5392 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
5393 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
5395 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5396 struct d3d_shader_resource_view
*object
;
5397 ID3D11Resource
*d3d11_resource
;
5400 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5403 return E_INVALIDARG
;
5405 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5407 ERR("Resource does not implement ID3D11Resource.\n");
5411 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
5413 ID3D11Resource_Release(d3d11_resource
);
5417 *view
= &object
->ID3D10ShaderResourceView1_iface
;
5422 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
5423 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
5425 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5427 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
5428 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
5431 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
5432 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
5434 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5435 struct d3d_rendertarget_view
*object
;
5436 ID3D11Resource
*d3d11_resource
;
5439 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5442 return E_INVALIDARG
;
5444 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5446 ERR("Resource does not implement ID3D11Resource.\n");
5450 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
5451 ID3D11Resource_Release(d3d11_resource
);
5455 *view
= &object
->ID3D10RenderTargetView_iface
;
5460 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
5461 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
5463 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5464 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
5465 struct d3d_depthstencil_view
*object
;
5466 ID3D11Resource
*d3d11_resource
;
5469 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
5473 d3d11_desc
.Format
= desc
->Format
;
5474 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
5475 d3d11_desc
.Flags
= 0;
5476 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
5479 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
5481 ERR("Resource does not implement ID3D11Resource.\n");
5485 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
5486 ID3D11Resource_Release(d3d11_resource
);
5490 *view
= &object
->ID3D10DepthStencilView_iface
;
5495 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
5496 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
5497 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
5498 ID3D10InputLayout
**input_layout
)
5500 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5501 struct d3d_input_layout
*object
;
5504 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
5505 "shader_byte_code_length %lu, input_layout %p\n",
5506 iface
, element_descs
, element_count
, shader_byte_code
,
5507 shader_byte_code_length
, input_layout
);
5509 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
5510 shader_byte_code
, shader_byte_code_length
, &object
)))
5513 *input_layout
= &object
->ID3D10InputLayout_iface
;
5518 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
5519 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
5521 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5522 struct d3d_vertex_shader
*object
;
5525 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5526 iface
, byte_code
, byte_code_length
, shader
);
5528 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5531 *shader
= &object
->ID3D10VertexShader_iface
;
5536 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
5537 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
5539 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5540 struct d3d_geometry_shader
*object
;
5543 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5544 iface
, byte_code
, byte_code_length
, shader
);
5546 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5547 NULL
, 0, NULL
, 0, 0, &object
)))
5550 *shader
= &object
->ID3D10GeometryShader_iface
;
5555 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
5556 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
5557 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
5559 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5560 D3D11_SO_DECLARATION_ENTRY
*so_entries
= NULL
;
5561 struct d3d_geometry_shader
*object
;
5562 unsigned int i
, stride_count
= 1;
5565 TRACE("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
5566 "output_stream_decl_count %u, output_stream_stride %u, shader %p.\n",
5567 iface
, byte_code
, byte_code_length
, output_stream_decls
,
5568 output_stream_decl_count
, output_stream_stride
, shader
);
5570 if (!output_stream_decl_count
&& output_stream_stride
)
5572 WARN("Stride must be 0 when declaration entry count is 0.\n");
5574 return E_INVALIDARG
;
5577 if (output_stream_decl_count
5578 && !(so_entries
= heap_calloc(output_stream_decl_count
, sizeof(*so_entries
))))
5580 ERR("Failed to allocate D3D11 SO declaration array memory.\n");
5582 return E_OUTOFMEMORY
;
5585 for (i
= 0; i
< output_stream_decl_count
; ++i
)
5587 so_entries
[i
].Stream
= 0;
5588 so_entries
[i
].SemanticName
= output_stream_decls
[i
].SemanticName
;
5589 so_entries
[i
].SemanticIndex
= output_stream_decls
[i
].SemanticIndex
;
5590 so_entries
[i
].StartComponent
= output_stream_decls
[i
].StartComponent
;
5591 so_entries
[i
].ComponentCount
= output_stream_decls
[i
].ComponentCount
;
5592 so_entries
[i
].OutputSlot
= output_stream_decls
[i
].OutputSlot
;
5594 if (output_stream_decls
[i
].OutputSlot
)
5597 if (output_stream_stride
)
5599 WARN("Stride must be 0 when multiple output slots are used.\n");
5600 heap_free(so_entries
);
5602 return E_INVALIDARG
;
5607 hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
,
5608 so_entries
, output_stream_decl_count
, &output_stream_stride
, stride_count
, 0, &object
);
5609 heap_free(so_entries
);
5616 *shader
= &object
->ID3D10GeometryShader_iface
;
5621 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
5622 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
5624 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5625 struct d3d_pixel_shader
*object
;
5628 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
5629 iface
, byte_code
, byte_code_length
, shader
);
5631 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
5634 *shader
= &object
->ID3D10PixelShader_iface
;
5639 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
5640 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
5642 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5643 struct d3d_blend_state
*object
;
5646 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5648 if (FAILED(hr
= d3d_blend_state_create(device
, (const D3D11_BLEND_DESC
*)desc
, &object
)))
5651 *blend_state
= &object
->ID3D10BlendState1_iface
;
5656 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
5657 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
5659 D3D10_BLEND_DESC1 d3d10_1_desc
;
5662 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
5665 return E_INVALIDARG
;
5667 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
5668 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
5669 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
5671 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
5672 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
5673 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
5676 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5678 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
5679 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
5680 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
5681 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
5682 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
5683 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
5684 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
5685 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
5688 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
5691 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
5692 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
5694 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5695 struct d3d_depthstencil_state
*object
;
5698 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
5700 if (FAILED(hr
= d3d_depthstencil_state_create(device
, (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &object
)))
5703 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
5708 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
5709 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
5711 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5712 struct d3d_rasterizer_state
*object
;
5715 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
5717 if (FAILED(hr
= d3d_rasterizer_state_create(device
, (const D3D11_RASTERIZER_DESC
*)desc
, &object
)))
5720 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
5725 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
5726 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
5728 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5729 struct d3d_sampler_state
*object
;
5732 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
5734 if (FAILED(hr
= d3d_sampler_state_create(device
, (const D3D11_SAMPLER_DESC
*)desc
, &object
)))
5737 *sampler_state
= &object
->ID3D10SamplerState_iface
;
5742 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
5743 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
5745 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5746 struct d3d_query
*object
;
5749 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
5751 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
5756 *query
= &object
->ID3D10Query_iface
;
5760 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5764 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
5765 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
5767 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5768 struct d3d_query
*object
;
5771 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
5773 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
5778 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
5782 ID3D10Query_Release(&object
->ID3D10Query_iface
);
5786 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
5787 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
5789 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
5794 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
5795 DXGI_FORMAT format
, UINT
*format_support
)
5797 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5799 TRACE("iface %p, format %s, format_support %p.\n",
5800 iface
, debug_dxgi_format(format
), format_support
);
5802 return d3d11_device_CheckFormatSupport(&device
->ID3D11Device2_iface
, format
, format_support
);
5805 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
5806 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
5808 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5810 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
5811 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
5813 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device2_iface
, format
,
5814 sample_count
, quality_level_count
);
5817 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
5819 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
5822 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
5823 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
5824 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
5826 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
5827 "units %p, units_length %p, description %p, description_length %p stub!\n",
5828 iface
, desc
, type
, active_counters
, name
, name_length
,
5829 units
, units_length
, description
, description_length
);
5834 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
5836 FIXME("iface %p stub!\n", iface
);
5841 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
5842 HANDLE resource_handle
, REFIID guid
, void **resource
)
5844 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
5845 iface
, resource_handle
, debugstr_guid(guid
), resource
);
5850 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
5852 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
5855 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
5857 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
5860 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
5862 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
5864 TRACE("iface %p.\n", iface
);
5866 return device
->feature_level
;
5869 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
5871 /* IUnknown methods */
5872 d3d10_device_QueryInterface
,
5873 d3d10_device_AddRef
,
5874 d3d10_device_Release
,
5875 /* ID3D10Device methods */
5876 d3d10_device_VSSetConstantBuffers
,
5877 d3d10_device_PSSetShaderResources
,
5878 d3d10_device_PSSetShader
,
5879 d3d10_device_PSSetSamplers
,
5880 d3d10_device_VSSetShader
,
5881 d3d10_device_DrawIndexed
,
5883 d3d10_device_PSSetConstantBuffers
,
5884 d3d10_device_IASetInputLayout
,
5885 d3d10_device_IASetVertexBuffers
,
5886 d3d10_device_IASetIndexBuffer
,
5887 d3d10_device_DrawIndexedInstanced
,
5888 d3d10_device_DrawInstanced
,
5889 d3d10_device_GSSetConstantBuffers
,
5890 d3d10_device_GSSetShader
,
5891 d3d10_device_IASetPrimitiveTopology
,
5892 d3d10_device_VSSetShaderResources
,
5893 d3d10_device_VSSetSamplers
,
5894 d3d10_device_SetPredication
,
5895 d3d10_device_GSSetShaderResources
,
5896 d3d10_device_GSSetSamplers
,
5897 d3d10_device_OMSetRenderTargets
,
5898 d3d10_device_OMSetBlendState
,
5899 d3d10_device_OMSetDepthStencilState
,
5900 d3d10_device_SOSetTargets
,
5901 d3d10_device_DrawAuto
,
5902 d3d10_device_RSSetState
,
5903 d3d10_device_RSSetViewports
,
5904 d3d10_device_RSSetScissorRects
,
5905 d3d10_device_CopySubresourceRegion
,
5906 d3d10_device_CopyResource
,
5907 d3d10_device_UpdateSubresource
,
5908 d3d10_device_ClearRenderTargetView
,
5909 d3d10_device_ClearDepthStencilView
,
5910 d3d10_device_GenerateMips
,
5911 d3d10_device_ResolveSubresource
,
5912 d3d10_device_VSGetConstantBuffers
,
5913 d3d10_device_PSGetShaderResources
,
5914 d3d10_device_PSGetShader
,
5915 d3d10_device_PSGetSamplers
,
5916 d3d10_device_VSGetShader
,
5917 d3d10_device_PSGetConstantBuffers
,
5918 d3d10_device_IAGetInputLayout
,
5919 d3d10_device_IAGetVertexBuffers
,
5920 d3d10_device_IAGetIndexBuffer
,
5921 d3d10_device_GSGetConstantBuffers
,
5922 d3d10_device_GSGetShader
,
5923 d3d10_device_IAGetPrimitiveTopology
,
5924 d3d10_device_VSGetShaderResources
,
5925 d3d10_device_VSGetSamplers
,
5926 d3d10_device_GetPredication
,
5927 d3d10_device_GSGetShaderResources
,
5928 d3d10_device_GSGetSamplers
,
5929 d3d10_device_OMGetRenderTargets
,
5930 d3d10_device_OMGetBlendState
,
5931 d3d10_device_OMGetDepthStencilState
,
5932 d3d10_device_SOGetTargets
,
5933 d3d10_device_RSGetState
,
5934 d3d10_device_RSGetViewports
,
5935 d3d10_device_RSGetScissorRects
,
5936 d3d10_device_GetDeviceRemovedReason
,
5937 d3d10_device_SetExceptionMode
,
5938 d3d10_device_GetExceptionMode
,
5939 d3d10_device_GetPrivateData
,
5940 d3d10_device_SetPrivateData
,
5941 d3d10_device_SetPrivateDataInterface
,
5942 d3d10_device_ClearState
,
5944 d3d10_device_CreateBuffer
,
5945 d3d10_device_CreateTexture1D
,
5946 d3d10_device_CreateTexture2D
,
5947 d3d10_device_CreateTexture3D
,
5948 d3d10_device_CreateShaderResourceView
,
5949 d3d10_device_CreateRenderTargetView
,
5950 d3d10_device_CreateDepthStencilView
,
5951 d3d10_device_CreateInputLayout
,
5952 d3d10_device_CreateVertexShader
,
5953 d3d10_device_CreateGeometryShader
,
5954 d3d10_device_CreateGeometryShaderWithStreamOutput
,
5955 d3d10_device_CreatePixelShader
,
5956 d3d10_device_CreateBlendState
,
5957 d3d10_device_CreateDepthStencilState
,
5958 d3d10_device_CreateRasterizerState
,
5959 d3d10_device_CreateSamplerState
,
5960 d3d10_device_CreateQuery
,
5961 d3d10_device_CreatePredicate
,
5962 d3d10_device_CreateCounter
,
5963 d3d10_device_CheckFormatSupport
,
5964 d3d10_device_CheckMultisampleQualityLevels
,
5965 d3d10_device_CheckCounterInfo
,
5966 d3d10_device_CheckCounter
,
5967 d3d10_device_GetCreationFlags
,
5968 d3d10_device_OpenSharedResource
,
5969 d3d10_device_SetTextFilterSize
,
5970 d3d10_device_GetTextFilterSize
,
5971 d3d10_device_CreateShaderResourceView1
,
5972 d3d10_device_CreateBlendState1
,
5973 d3d10_device_GetFeatureLevel
,
5976 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
5978 /* IUnknown methods */
5979 d3d_device_inner_QueryInterface
,
5980 d3d_device_inner_AddRef
,
5981 d3d_device_inner_Release
,
5984 /* ID3D10Multithread methods */
5986 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
5988 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
5991 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
5993 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5995 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
5997 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6000 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
6002 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6004 TRACE("iface %p.\n", iface
);
6006 return IUnknown_AddRef(device
->outer_unk
);
6009 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
6011 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
6013 TRACE("iface %p.\n", iface
);
6015 return IUnknown_Release(device
->outer_unk
);
6018 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
6020 TRACE("iface %p.\n", iface
);
6022 wined3d_mutex_lock();
6025 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
6027 TRACE("iface %p.\n", iface
);
6029 wined3d_mutex_unlock();
6032 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL enable
)
6034 FIXME("iface %p, enable %#x stub!\n", iface
, enable
);
6039 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
6041 FIXME("iface %p stub!\n", iface
);
6046 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
6048 d3d10_multithread_QueryInterface
,
6049 d3d10_multithread_AddRef
,
6050 d3d10_multithread_Release
,
6051 d3d10_multithread_Enter
,
6052 d3d10_multithread_Leave
,
6053 d3d10_multithread_SetMultithreadProtected
,
6054 d3d10_multithread_GetMultithreadProtected
,
6057 /* IWineDXGIDeviceParent IUnknown methods */
6059 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
6061 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
6064 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
6065 REFIID iid
, void **out
)
6067 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6068 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
6071 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
6073 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6074 return IUnknown_AddRef(device
->outer_unk
);
6077 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
6079 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6080 return IUnknown_Release(device
->outer_unk
);
6083 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
6084 IWineDXGIDeviceParent
*iface
)
6086 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
6087 return &device
->device_parent
;
6090 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
6092 /* IUnknown methods */
6093 dxgi_device_parent_QueryInterface
,
6094 dxgi_device_parent_AddRef
,
6095 dxgi_device_parent_Release
,
6096 /* IWineDXGIDeviceParent methods */
6097 dxgi_device_parent_get_wined3d_device_parent
,
6100 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
6102 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
6105 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
6106 struct wined3d_device
*wined3d_device
)
6108 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6110 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
6112 wined3d_device_incref(wined3d_device
);
6113 device
->wined3d_device
= wined3d_device
;
6115 device
->feature_level
= wined3d_device_get_feature_level(wined3d_device
);
6117 set_default_depth_stencil_state(wined3d_device
);
6120 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
6122 TRACE("device_parent %p.\n", device_parent
);
6125 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
6127 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
6130 static HRESULT CDECL
device_parent_texture_sub_resource_created(struct wined3d_device_parent
*device_parent
,
6131 enum wined3d_resource_type type
, struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
,
6132 void **parent
, const struct wined3d_parent_ops
**parent_ops
)
6134 TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
6135 device_parent
, type
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
6138 *parent_ops
= &d3d_null_wined3d_parent_ops
;
6143 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
6144 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
, DWORD texture_flags
,
6145 struct wined3d_texture
**wined3d_texture
)
6147 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
6148 struct d3d_texture2d
*texture
;
6149 ID3D11Texture2D
*texture_iface
;
6150 D3D11_TEXTURE2D_DESC desc
;
6153 TRACE("device_parent %p, container_parent %p, wined3d_desc %p, texture_flags %#x, wined3d_texture %p.\n",
6154 device_parent
, container_parent
, wined3d_desc
, texture_flags
, wined3d_texture
);
6156 desc
.Width
= wined3d_desc
->width
;
6157 desc
.Height
= wined3d_desc
->height
;
6160 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
6161 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
6162 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
6163 desc
.Usage
= D3D11_USAGE_DEFAULT
;
6164 desc
.BindFlags
= d3d11_bind_flags_from_wined3d(wined3d_desc
->bind_flags
);
6165 desc
.CPUAccessFlags
= 0;
6168 if (texture_flags
& WINED3D_TEXTURE_CREATE_GET_DC
)
6170 desc
.MiscFlags
|= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
6171 texture_flags
&= ~WINED3D_TEXTURE_CREATE_GET_DC
;
6175 FIXME("Unhandled flags %#x.\n", texture_flags
);
6177 if (FAILED(hr
= d3d11_device_CreateTexture2D(&device
->ID3D11Device2_iface
,
6178 &desc
, NULL
, &texture_iface
)))
6180 WARN("Failed to create 2D texture, hr %#x.\n", hr
);
6184 texture
= impl_from_ID3D11Texture2D(texture_iface
);
6186 *wined3d_texture
= texture
->wined3d_texture
;
6187 wined3d_texture_incref(*wined3d_texture
);
6188 ID3D11Texture2D_Release(&texture
->ID3D11Texture2D_iface
);
6193 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
6195 device_parent_wined3d_device_created
,
6196 device_parent_mode_changed
,
6197 device_parent_activate
,
6198 device_parent_texture_sub_resource_created
,
6199 device_parent_create_swapchain_texture
,
6202 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6204 const D3D11_SAMPLER_DESC
*ka
= key
;
6205 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
6207 return memcmp(ka
, kb
, sizeof(*ka
));
6210 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6212 const D3D11_BLEND_DESC
*ka
= key
;
6213 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
6215 return memcmp(ka
, kb
, sizeof(*ka
));
6218 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6220 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
6221 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
6222 const struct d3d_depthstencil_state
, entry
)->desc
;
6224 return memcmp(ka
, kb
, sizeof(*ka
));
6227 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
6229 const D3D11_RASTERIZER_DESC
*ka
= key
;
6230 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
6232 return memcmp(ka
, kb
, sizeof(*ka
));
6235 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
6237 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
6238 device
->ID3D11Device2_iface
.lpVtbl
= &d3d11_device_vtbl
;
6239 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
6240 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
6241 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
6242 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
6243 device
->refcount
= 1;
6244 /* COM aggregation always takes place */
6245 device
->outer_unk
= outer_unknown
;
6247 d3d11_immediate_context_init(&device
->immediate_context
, device
);
6248 ID3D11DeviceContext1_Release(&device
->immediate_context
.ID3D11DeviceContext1_iface
);
6250 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
6251 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
6252 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
6253 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);