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
21 #include "wine/port.h"
23 #define NONAMELESSUNION
24 #include "d3d11_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
28 static void STDMETHODCALLTYPE
d3d_null_wined3d_object_destroyed(void *parent
) {}
30 const struct wined3d_parent_ops d3d_null_wined3d_parent_ops
=
32 d3d_null_wined3d_object_destroyed
,
35 /* ID3D11DeviceContext - immediate context methods */
37 static inline struct d3d11_immediate_context
*impl_from_ID3D11DeviceContext(ID3D11DeviceContext
*iface
)
39 return CONTAINING_RECORD(iface
, struct d3d11_immediate_context
, ID3D11DeviceContext_iface
);
42 static inline struct d3d_device
*device_from_immediate_ID3D11DeviceContext(ID3D11DeviceContext
*iface
)
44 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
45 return CONTAINING_RECORD(context
, struct d3d_device
, immediate_context
);
48 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_QueryInterface(ID3D11DeviceContext
*iface
,
49 REFIID riid
, void **out
)
51 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
53 if (IsEqualGUID(riid
, &IID_ID3D11DeviceContext
)
54 || IsEqualGUID(riid
, &IID_ID3D11DeviceChild
)
55 || IsEqualGUID(riid
, &IID_IUnknown
))
57 ID3D11DeviceContext_AddRef(iface
);
62 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
67 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_AddRef(ID3D11DeviceContext
*iface
)
69 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
70 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
71 ULONG refcount
= InterlockedIncrement(&context
->refcount
);
73 TRACE("%p increasing refcount to %u.\n", context
, refcount
);
77 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
83 static ULONG STDMETHODCALLTYPE
d3d11_immediate_context_Release(ID3D11DeviceContext
*iface
)
85 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
86 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
87 ULONG refcount
= InterlockedDecrement(&context
->refcount
);
89 TRACE("%p decreasing refcount to %u.\n", context
, refcount
);
93 ID3D11Device_Release(&device
->ID3D11Device_iface
);
99 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetDevice(ID3D11DeviceContext
*iface
, ID3D11Device
**device
)
101 struct d3d_device
*device_object
= device_from_immediate_ID3D11DeviceContext(iface
);
103 TRACE("iface %p, device %p.\n", iface
, device
);
105 *device
= &device_object
->ID3D11Device_iface
;
106 ID3D11Device_AddRef(*device
);
109 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext
*iface
, REFGUID guid
,
110 UINT
*data_size
, void *data
)
112 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
114 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
116 return d3d_get_private_data(&context
->private_store
, guid
, data_size
, data
);
119 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext
*iface
, REFGUID guid
,
120 UINT data_size
, const void *data
)
122 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
124 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
126 return d3d_set_private_data(&context
->private_store
, guid
, data_size
, data
);
129 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext
*iface
,
130 REFGUID guid
, const IUnknown
*data
)
132 struct d3d11_immediate_context
*context
= impl_from_ID3D11DeviceContext(iface
);
134 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
136 return d3d_set_private_data_interface(&context
->private_store
, guid
, data
);
139 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext
*iface
,
140 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
142 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
145 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
146 iface
, start_slot
, buffer_count
, buffers
);
148 wined3d_mutex_lock();
149 for (i
= 0; i
< buffer_count
; ++i
)
151 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
153 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
154 buffer
? buffer
->wined3d_buffer
: NULL
);
156 wined3d_mutex_unlock();
159 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext
*iface
,
160 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
162 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
165 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
166 iface
, start_slot
, view_count
, views
);
168 wined3d_mutex_lock();
169 for (i
= 0; i
< view_count
; ++i
)
171 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
173 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
174 view
? view
->wined3d_view
: NULL
);
176 wined3d_mutex_unlock();
179 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShader(ID3D11DeviceContext
*iface
,
180 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
182 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
183 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
185 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
186 iface
, shader
, class_instances
, class_instance_count
);
189 FIXME("Dynamic linking is not implemented yet.\n");
191 wined3d_mutex_lock();
192 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
193 wined3d_mutex_unlock();
196 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext
*iface
,
197 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
199 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
202 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
203 iface
, start_slot
, sampler_count
, samplers
);
205 wined3d_mutex_lock();
206 for (i
= 0; i
< sampler_count
; ++i
)
208 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
210 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
211 sampler
? sampler
->wined3d_sampler
: NULL
);
213 wined3d_mutex_unlock();
216 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShader(ID3D11DeviceContext
*iface
,
217 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
219 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
220 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
222 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
223 iface
, shader
, class_instances
, class_instance_count
);
226 FIXME("Dynamic linking is not implemented yet.\n");
228 wined3d_mutex_lock();
229 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
230 wined3d_mutex_unlock();
233 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext
*iface
,
234 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
236 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
238 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
239 iface
, index_count
, start_index_location
, base_vertex_location
);
241 wined3d_mutex_lock();
242 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
243 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
244 wined3d_mutex_unlock();
247 static void STDMETHODCALLTYPE
d3d11_immediate_context_Draw(ID3D11DeviceContext
*iface
,
248 UINT vertex_count
, UINT start_vertex_location
)
250 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
252 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
253 iface
, vertex_count
, start_vertex_location
);
255 wined3d_mutex_lock();
256 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
257 wined3d_mutex_unlock();
260 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_Map(ID3D11DeviceContext
*iface
, ID3D11Resource
*resource
,
261 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
263 struct wined3d_resource
*wined3d_resource
;
264 struct wined3d_map_desc map_desc
;
267 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
268 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
271 FIXME("Ignoring map_flags %#x.\n", map_flags
);
273 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
275 wined3d_mutex_lock();
276 hr
= wined3d_resource_map(wined3d_resource
, subresource_idx
,
277 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
278 wined3d_mutex_unlock();
280 mapped_subresource
->pData
= map_desc
.data
;
281 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
282 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
287 static void STDMETHODCALLTYPE
d3d11_immediate_context_Unmap(ID3D11DeviceContext
*iface
, ID3D11Resource
*resource
,
288 UINT subresource_idx
)
290 struct wined3d_resource
*wined3d_resource
;
292 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
294 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
296 wined3d_mutex_lock();
297 wined3d_resource_unmap(wined3d_resource
, subresource_idx
);
298 wined3d_mutex_unlock();
301 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext
*iface
,
302 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
304 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
307 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
308 iface
, start_slot
, buffer_count
, buffers
);
310 wined3d_mutex_lock();
311 for (i
= 0; i
< buffer_count
; ++i
)
313 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
315 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
316 buffer
? buffer
->wined3d_buffer
: NULL
);
318 wined3d_mutex_unlock();
321 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext
*iface
,
322 ID3D11InputLayout
*input_layout
)
324 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
325 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
327 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
329 wined3d_mutex_lock();
330 wined3d_device_set_vertex_declaration(device
->wined3d_device
, layout
? layout
->wined3d_decl
: NULL
);
331 wined3d_mutex_unlock();
334 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext
*iface
,
335 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
337 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
340 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
341 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
343 wined3d_mutex_lock();
344 for (i
= 0; i
< buffer_count
; ++i
)
346 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
348 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
349 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
351 wined3d_mutex_unlock();
354 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext
*iface
,
355 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
357 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
358 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
360 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
361 iface
, buffer
, debug_dxgi_format(format
), offset
);
363 wined3d_mutex_lock();
364 wined3d_device_set_index_buffer(device
->wined3d_device
,
365 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
366 wined3dformat_from_dxgi_format(format
), offset
);
367 wined3d_mutex_unlock();
370 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext
*iface
,
371 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
372 UINT start_instance_location
)
374 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
376 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
377 "base_vertex_location %d, start_instance_location %u.\n",
378 iface
, instance_index_count
, instance_count
, start_index_location
,
379 base_vertex_location
, start_instance_location
);
381 wined3d_mutex_lock();
382 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
383 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
384 instance_index_count
, start_instance_location
, instance_count
);
385 wined3d_mutex_unlock();
388 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext
*iface
,
389 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
391 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
393 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
394 "start_instance_location %u.\n",
395 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
396 start_instance_location
);
398 wined3d_mutex_lock();
399 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
400 instance_vertex_count
, start_instance_location
, instance_count
);
401 wined3d_mutex_unlock();
404 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext
*iface
,
405 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
407 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
410 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
411 iface
, start_slot
, buffer_count
, buffers
);
413 wined3d_mutex_lock();
414 for (i
= 0; i
< buffer_count
; ++i
)
416 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
418 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
419 buffer
? buffer
->wined3d_buffer
: NULL
);
421 wined3d_mutex_unlock();
424 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext
*iface
,
425 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
427 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
428 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
430 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
431 iface
, shader
, class_instances
, class_instance_count
);
434 FIXME("Dynamic linking is not implemented yet.\n");
436 wined3d_mutex_lock();
437 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
438 wined3d_mutex_unlock();
441 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext
*iface
,
442 D3D11_PRIMITIVE_TOPOLOGY topology
)
444 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
446 TRACE("iface %p, topology %u.\n", iface
, topology
);
448 wined3d_mutex_lock();
449 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
450 wined3d_mutex_unlock();
453 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext
*iface
,
454 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
456 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
459 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
461 wined3d_mutex_lock();
462 for (i
= 0; i
< view_count
; ++i
)
464 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
466 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
467 view
? view
->wined3d_view
: NULL
);
469 wined3d_mutex_unlock();
472 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext
*iface
,
473 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
475 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
478 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
479 iface
, start_slot
, sampler_count
, samplers
);
481 wined3d_mutex_lock();
482 for (i
= 0; i
< sampler_count
; ++i
)
484 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
486 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
487 sampler
? sampler
->wined3d_sampler
: NULL
);
489 wined3d_mutex_unlock();
492 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext
*iface
,
493 ID3D11Asynchronous
*asynchronous
)
495 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
498 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
500 wined3d_mutex_lock();
501 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_BEGIN
)))
502 ERR("Failed to issue query, hr %#x.\n", hr
);
503 wined3d_mutex_unlock();
506 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext
*iface
,
507 ID3D11Asynchronous
*asynchronous
)
509 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
512 TRACE("iface %p, asynchronous %p.\n", iface
, asynchronous
);
514 wined3d_mutex_lock();
515 if (FAILED(hr
= wined3d_query_issue(query
->wined3d_query
, WINED3DISSUE_END
)))
516 ERR("Failed to issue query, hr %#x.\n", hr
);
517 wined3d_mutex_unlock();
520 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext
*iface
,
521 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
523 struct d3d_query
*query
= unsafe_impl_from_ID3D11Asynchronous(asynchronous
);
524 unsigned int wined3d_flags
;
527 TRACE("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x.\n",
528 iface
, asynchronous
, data
, data_size
, data_flags
);
530 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
532 wined3d_mutex_lock();
533 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
535 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
539 WARN("Invalid data size %u.\n", data_size
);
542 wined3d_mutex_unlock();
547 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext
*iface
,
548 ID3D11Predicate
*predicate
, BOOL value
)
550 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
551 struct d3d_query
*query
;
553 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
555 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
557 wined3d_mutex_lock();
558 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
559 wined3d_mutex_unlock();
562 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext
*iface
,
563 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
565 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
568 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
570 wined3d_mutex_lock();
571 for (i
= 0; i
< view_count
; ++i
)
573 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
575 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
576 view
? view
->wined3d_view
: NULL
);
578 wined3d_mutex_unlock();
581 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext
*iface
,
582 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
584 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
587 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
588 iface
, start_slot
, sampler_count
, samplers
);
590 wined3d_mutex_lock();
591 for (i
= 0; i
< sampler_count
; ++i
)
593 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
595 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
596 sampler
? sampler
->wined3d_sampler
: NULL
);
598 wined3d_mutex_unlock();
601 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext
*iface
,
602 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
603 ID3D11DepthStencilView
*depth_stencil_view
)
605 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
606 struct d3d_depthstencil_view
*dsv
;
609 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
610 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
612 wined3d_mutex_lock();
613 for (i
= 0; i
< render_target_view_count
; ++i
)
615 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
616 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
618 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
620 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
623 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
624 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
625 wined3d_mutex_unlock();
628 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
629 ID3D11DeviceContext
*iface
, UINT render_target_view_count
,
630 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
631 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
632 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
634 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
635 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
636 "initial_counts %p partial-stub!\n",
637 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
638 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
641 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
643 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
648 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
649 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
651 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
652 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
653 const D3D11_BLEND_DESC
*desc
;
655 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
656 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
659 blend_factor
= default_blend_factor
;
661 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
662 FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor
));
664 wined3d_mutex_lock();
665 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
666 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
667 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
669 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
670 wined3d_device_set_render_state(device
->wined3d_device
,
671 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
672 wined3d_device_set_render_state(device
->wined3d_device
,
673 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
674 wined3d_device_set_render_state(device
->wined3d_device
,
675 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
676 wined3d_device_set_render_state(device
->wined3d_device
,
677 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
678 wined3d_mutex_unlock();
682 desc
= &device
->blend_state
->desc
;
683 /* glSampleCoverage() */
684 if (desc
->AlphaToCoverageEnable
)
685 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
686 /* glEnableIndexedEXT(GL_BLEND, ...) */
687 FIXME("Per-rendertarget blend not implemented.\n");
688 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
689 desc
->RenderTarget
[0].BlendEnable
);
690 if (desc
->RenderTarget
[0].BlendEnable
)
692 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
,
693 desc
->RenderTarget
[0].SrcBlend
);
694 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
,
695 desc
->RenderTarget
[0].DestBlend
);
696 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
,
697 desc
->RenderTarget
[0].BlendOp
);
698 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
699 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
,
700 desc
->RenderTarget
[0].SrcBlendAlpha
);
701 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
,
702 desc
->RenderTarget
[0].DestBlendAlpha
);
703 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
,
704 desc
->RenderTarget
[0].BlendOpAlpha
);
706 FIXME("Color mask > 3 not implemented.\n");
707 wined3d_device_set_render_state(device
->wined3d_device
,
708 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
709 wined3d_device_set_render_state(device
->wined3d_device
,
710 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
711 wined3d_device_set_render_state(device
->wined3d_device
,
712 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
713 wined3d_device_set_render_state(device
->wined3d_device
,
714 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
715 wined3d_mutex_unlock();
718 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
719 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
721 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
722 const D3D11_DEPTH_STENCILOP_DESC
*stencil_desc
;
723 const D3D11_DEPTH_STENCIL_DESC
*desc
;
725 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
726 iface
, depth_stencil_state
, stencil_ref
);
728 wined3d_mutex_lock();
729 device
->stencil_ref
= stencil_ref
;
730 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
732 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
733 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
734 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, D3D11_COMPARISON_LESS
);
735 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
736 wined3d_mutex_unlock();
740 desc
= &device
->depth_stencil_state
->desc
;
742 if (desc
->FrontFace
.StencilFailOp
!= desc
->BackFace
.StencilFailOp
743 || desc
->FrontFace
.StencilDepthFailOp
!= desc
->BackFace
.StencilDepthFailOp
744 || desc
->FrontFace
.StencilPassOp
!= desc
->BackFace
.StencilPassOp
745 || desc
->FrontFace
.StencilFunc
!= desc
->BackFace
.StencilFunc
)
746 FIXME("Two-sided stencil testing not supported.\n");
748 stencil_desc
= &desc
->FrontFace
;
750 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
751 if (desc
->DepthEnable
)
753 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
754 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
757 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
758 if (desc
->StencilEnable
)
760 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
761 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
762 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, stencil_desc
->StencilFailOp
);
763 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
,
764 stencil_desc
->StencilDepthFailOp
);
765 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, stencil_desc
->StencilPassOp
);
766 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, stencil_desc
->StencilFunc
);
767 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
769 wined3d_mutex_unlock();
772 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
773 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
775 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
776 unsigned int count
, i
;
778 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
780 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
781 wined3d_mutex_lock();
782 for (i
= 0; i
< count
; ++i
)
784 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
786 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
787 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
789 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
791 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
793 wined3d_mutex_unlock();
796 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
798 FIXME("iface %p stub!\n", iface
);
801 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext
*iface
,
802 ID3D11Buffer
*buffer
, UINT offset
)
804 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
807 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
808 ID3D11Buffer
*buffer
, UINT offset
)
810 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
813 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
814 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
816 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
817 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
820 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
821 ID3D11Buffer
*buffer
, UINT offset
)
823 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
826 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
827 ID3D11RasterizerState
*rasterizer_state
)
829 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
830 const D3D11_RASTERIZER_DESC
*desc
;
832 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
834 wined3d_mutex_lock();
835 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
837 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
838 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
839 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_BACK
);
840 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
841 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
842 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
843 wined3d_mutex_unlock();
847 wined3d_device_set_rasterizer_state(device
->wined3d_device
, device
->rasterizer_state
->wined3d_state
);
849 desc
= &device
->rasterizer_state
->desc
;
850 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
851 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
852 /* OpenGL style depth bias. */
853 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
854 FIXME("Ignoring depth bias.\n");
856 if (!desc
->DepthClipEnable
)
857 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
858 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
859 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
860 wined3d_device_set_render_state(device
->wined3d_device
,
861 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
862 wined3d_mutex_unlock();
865 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
866 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
868 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
869 struct wined3d_viewport wined3d_vp
;
871 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
873 if (viewport_count
> 1)
874 FIXME("Multiple viewports not implemented.\n");
879 if (viewports
[0].TopLeftX
!= (UINT
)viewports
[0].TopLeftX
880 || viewports
[0].TopLeftY
!= (UINT
)viewports
[0].TopLeftY
881 || viewports
[0].Width
!= (UINT
)viewports
[0].Width
882 || viewports
[0].Height
!= (UINT
)viewports
[0].Height
)
883 FIXME("Floating-point viewports not implemented.\n");
885 wined3d_vp
.x
= viewports
[0].TopLeftX
;
886 wined3d_vp
.y
= viewports
[0].TopLeftY
;
887 wined3d_vp
.width
= viewports
[0].Width
;
888 wined3d_vp
.height
= viewports
[0].Height
;
889 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
890 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
892 wined3d_mutex_lock();
893 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
894 wined3d_mutex_unlock();
897 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
898 UINT rect_count
, const D3D11_RECT
*rects
)
900 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
902 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
905 FIXME("Multiple scissor rects not implemented.\n");
910 wined3d_mutex_lock();
911 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
912 wined3d_mutex_unlock();
915 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
916 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
917 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
919 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
920 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
921 struct wined3d_box wined3d_src_box
;
923 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
924 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
925 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
926 src_resource
, src_subresource_idx
, src_box
);
930 wined3d_src_box
.left
= src_box
->left
;
931 wined3d_src_box
.top
= src_box
->top
;
932 wined3d_src_box
.front
= src_box
->front
;
933 wined3d_src_box
.right
= src_box
->right
;
934 wined3d_src_box
.bottom
= src_box
->bottom
;
935 wined3d_src_box
.back
= src_box
->back
;
938 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
939 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
940 wined3d_mutex_lock();
941 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
942 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
943 wined3d_mutex_unlock();
946 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
947 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
949 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
950 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
952 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
954 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
955 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
956 wined3d_mutex_lock();
957 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
958 wined3d_mutex_unlock();
961 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
962 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
963 const void *data
, UINT row_pitch
, UINT depth_pitch
)
965 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
966 struct wined3d_resource
*wined3d_resource
;
967 struct wined3d_box wined3d_box
;
969 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
970 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
974 wined3d_box
.left
= box
->left
;
975 wined3d_box
.top
= box
->top
;
976 wined3d_box
.front
= box
->front
;
977 wined3d_box
.right
= box
->right
;
978 wined3d_box
.bottom
= box
->bottom
;
979 wined3d_box
.back
= box
->back
;
982 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
983 wined3d_mutex_lock();
984 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
985 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
986 wined3d_mutex_unlock();
989 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
990 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
992 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
993 iface
, dst_buffer
, dst_offset
, src_view
);
996 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
997 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
999 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1000 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1001 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1004 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1005 iface
, render_target_view
, debug_float4(color_rgba
));
1010 wined3d_mutex_lock();
1011 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1012 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1013 ERR("Failed to clear view, hr %#x.\n", hr
);
1014 wined3d_mutex_unlock();
1017 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
1018 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1020 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
1021 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1024 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
1025 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1027 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1028 iface
, unordered_access_view
, debug_float4(values
));
1031 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
1032 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1034 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1035 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1036 DWORD wined3d_flags
;
1039 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1040 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1045 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1047 wined3d_mutex_lock();
1048 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1049 wined3d_flags
, NULL
, depth
, stencil
)))
1050 ERR("Failed to clear view, hr %#x.\n", hr
);
1051 wined3d_mutex_unlock();
1054 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1055 ID3D11ShaderResourceView
*view
)
1057 FIXME("iface %p, view %p stub!\n", iface
, view
);
1060 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1061 ID3D11Resource
*resource
, FLOAT min_lod
)
1063 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1066 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1067 ID3D11Resource
*resource
)
1069 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1074 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1075 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1076 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1079 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1080 "format %s stub!\n",
1081 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1082 debug_dxgi_format(format
));
1085 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1086 ID3D11CommandList
*command_list
, BOOL restore_state
)
1088 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1091 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1092 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1094 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1095 iface
, start_slot
, view_count
, views
);
1098 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1099 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1101 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1102 iface
, shader
, class_instances
, class_instance_count
);
1105 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1106 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1108 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1109 iface
, start_slot
, sampler_count
, samplers
);
1112 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1113 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1115 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1116 iface
, start_slot
, buffer_count
, buffers
);
1119 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1120 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1122 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1123 iface
, start_slot
, view_count
, views
);
1126 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1127 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1129 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1130 iface
, shader
, class_instances
, class_instance_count
);
1133 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1134 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1136 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1137 iface
, start_slot
, sampler_count
, samplers
);
1140 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1141 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1143 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1144 iface
, start_slot
, buffer_count
, buffers
);
1147 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1148 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1150 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1151 iface
, start_slot
, view_count
, views
);
1154 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1155 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1157 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1158 iface
, start_slot
, view_count
, views
, initial_counts
);
1161 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1162 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1164 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1165 iface
, shader
, class_instances
, class_instance_count
);
1168 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1169 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1171 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1172 iface
, start_slot
, sampler_count
, samplers
);
1175 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1176 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1178 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1179 iface
, start_slot
, buffer_count
, buffers
);
1182 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1183 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1185 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1188 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1189 iface
, start_slot
, buffer_count
, buffers
);
1191 wined3d_mutex_lock();
1192 for (i
= 0; i
< buffer_count
; ++i
)
1194 struct wined3d_buffer
*wined3d_buffer
;
1195 struct d3d_buffer
*buffer_impl
;
1197 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1203 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1204 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1205 ID3D11Buffer_AddRef(buffers
[i
]);
1207 wined3d_mutex_unlock();
1210 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1211 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1213 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1216 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1217 iface
, start_slot
, view_count
, views
);
1219 wined3d_mutex_lock();
1220 for (i
= 0; i
< view_count
; ++i
)
1222 struct wined3d_shader_resource_view
*wined3d_view
;
1223 struct d3d_shader_resource_view
*view_impl
;
1225 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1231 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1232 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1233 ID3D11ShaderResourceView_AddRef(views
[i
]);
1235 wined3d_mutex_unlock();
1238 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1239 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1241 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1242 struct wined3d_shader
*wined3d_shader
;
1243 struct d3d_pixel_shader
*shader_impl
;
1245 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1246 iface
, shader
, class_instances
, class_instance_count
);
1248 if (class_instances
|| class_instance_count
)
1249 FIXME("Dynamic linking not implemented yet.\n");
1251 wined3d_mutex_lock();
1252 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1254 wined3d_mutex_unlock();
1259 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1260 wined3d_mutex_unlock();
1261 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1262 ID3D11PixelShader_AddRef(*shader
);
1265 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1266 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1268 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1271 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1272 iface
, start_slot
, sampler_count
, samplers
);
1274 wined3d_mutex_lock();
1275 for (i
= 0; i
< sampler_count
; ++i
)
1277 struct wined3d_sampler
*wined3d_sampler
;
1278 struct d3d_sampler_state
*sampler_impl
;
1280 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1286 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1287 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1288 ID3D11SamplerState_AddRef(samplers
[i
]);
1290 wined3d_mutex_unlock();
1293 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1294 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1296 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1297 struct d3d_vertex_shader
*shader_impl
;
1298 struct wined3d_shader
*wined3d_shader
;
1300 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1301 iface
, shader
, class_instances
, class_instance_count
);
1303 if (class_instances
|| class_instance_count
)
1304 FIXME("Dynamic linking not implemented yet.\n");
1306 wined3d_mutex_lock();
1307 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1309 wined3d_mutex_unlock();
1314 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1315 wined3d_mutex_unlock();
1316 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1317 ID3D11VertexShader_AddRef(*shader
);
1320 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1321 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1323 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1326 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1327 iface
, start_slot
, buffer_count
, buffers
);
1329 wined3d_mutex_lock();
1330 for (i
= 0; i
< buffer_count
; ++i
)
1332 struct wined3d_buffer
*wined3d_buffer
;
1333 struct d3d_buffer
*buffer_impl
;
1335 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1341 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1342 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1343 ID3D11Buffer_AddRef(buffers
[i
]);
1345 wined3d_mutex_unlock();
1348 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1349 ID3D11InputLayout
**input_layout
)
1351 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1352 struct wined3d_vertex_declaration
*wined3d_declaration
;
1353 struct d3d_input_layout
*input_layout_impl
;
1355 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1357 wined3d_mutex_lock();
1358 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1360 wined3d_mutex_unlock();
1361 *input_layout
= NULL
;
1365 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1366 wined3d_mutex_unlock();
1367 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1368 ID3D11InputLayout_AddRef(*input_layout
);
1371 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1372 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1374 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1377 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1378 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1380 wined3d_mutex_lock();
1381 for (i
= 0; i
< buffer_count
; ++i
)
1383 struct wined3d_buffer
*wined3d_buffer
;
1384 struct d3d_buffer
*buffer_impl
;
1386 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1387 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1388 ERR("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1390 if (!wined3d_buffer
)
1396 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1397 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1399 wined3d_mutex_unlock();
1402 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1403 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1405 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1406 enum wined3d_format_id wined3d_format
;
1407 struct wined3d_buffer
*wined3d_buffer
;
1408 struct d3d_buffer
*buffer_impl
;
1410 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1412 wined3d_mutex_lock();
1413 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1414 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1415 if (!wined3d_buffer
)
1417 wined3d_mutex_unlock();
1422 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1423 wined3d_mutex_unlock();
1424 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1427 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1428 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1430 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1433 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1434 iface
, start_slot
, buffer_count
, buffers
);
1436 wined3d_mutex_lock();
1437 for (i
= 0; i
< buffer_count
; ++i
)
1439 struct wined3d_buffer
*wined3d_buffer
;
1440 struct d3d_buffer
*buffer_impl
;
1442 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1448 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1449 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1450 ID3D11Buffer_AddRef(buffers
[i
]);
1452 wined3d_mutex_unlock();
1455 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1456 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1458 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1459 struct d3d_geometry_shader
*shader_impl
;
1460 struct wined3d_shader
*wined3d_shader
;
1462 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1463 iface
, shader
, class_instances
, class_instance_count
);
1465 if (class_instances
|| class_instance_count
)
1466 FIXME("Dynamic linking not implemented yet.\n");
1468 wined3d_mutex_lock();
1469 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1471 wined3d_mutex_unlock();
1476 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1477 wined3d_mutex_unlock();
1478 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1479 ID3D11GeometryShader_AddRef(*shader
);
1482 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1483 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1485 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1487 TRACE("iface %p, topology %p.\n", iface
, topology
);
1489 wined3d_mutex_lock();
1490 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1491 wined3d_mutex_unlock();
1494 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1495 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1497 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1500 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1502 wined3d_mutex_lock();
1503 for (i
= 0; i
< view_count
; ++i
)
1505 struct wined3d_shader_resource_view
*wined3d_view
;
1506 struct d3d_shader_resource_view
*view_impl
;
1508 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1514 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1515 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1516 ID3D11ShaderResourceView_AddRef(views
[i
]);
1518 wined3d_mutex_unlock();
1521 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1522 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1524 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1527 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1528 iface
, start_slot
, sampler_count
, samplers
);
1530 wined3d_mutex_lock();
1531 for (i
= 0; i
< sampler_count
; ++i
)
1533 struct wined3d_sampler
*wined3d_sampler
;
1534 struct d3d_sampler_state
*sampler_impl
;
1536 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1542 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1543 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1544 ID3D11SamplerState_AddRef(samplers
[i
]);
1546 wined3d_mutex_unlock();
1549 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1550 ID3D11Predicate
**predicate
, BOOL
*value
)
1552 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1553 struct wined3d_query
*wined3d_predicate
;
1554 struct d3d_query
*predicate_impl
;
1556 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1558 wined3d_mutex_lock();
1559 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1561 wined3d_mutex_unlock();
1566 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1567 wined3d_mutex_unlock();
1568 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1569 ID3D11Predicate_AddRef(*predicate
);
1572 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1573 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1575 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1578 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1580 wined3d_mutex_lock();
1581 for (i
= 0; i
< view_count
; ++i
)
1583 struct wined3d_shader_resource_view
*wined3d_view
;
1584 struct d3d_shader_resource_view
*view_impl
;
1586 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1592 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1593 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1594 ID3D11ShaderResourceView_AddRef(views
[i
]);
1596 wined3d_mutex_unlock();
1599 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1600 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1602 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1605 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1606 iface
, start_slot
, sampler_count
, samplers
);
1608 wined3d_mutex_lock();
1609 for (i
= 0; i
< sampler_count
; ++i
)
1611 struct d3d_sampler_state
*sampler_impl
;
1612 struct wined3d_sampler
*wined3d_sampler
;
1614 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1620 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1621 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1622 ID3D11SamplerState_AddRef(samplers
[i
]);
1624 wined3d_mutex_unlock();
1627 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1628 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1629 ID3D11DepthStencilView
**depth_stencil_view
)
1631 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1632 struct wined3d_rendertarget_view
*wined3d_view
;
1634 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1635 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1637 wined3d_mutex_lock();
1638 if (render_target_views
)
1640 struct d3d_rendertarget_view
*view_impl
;
1643 for (i
= 0; i
< render_target_view_count
; ++i
)
1645 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1646 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1648 render_target_views
[i
] = NULL
;
1652 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1653 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1657 if (depth_stencil_view
)
1659 struct d3d_depthstencil_view
*view_impl
;
1661 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1662 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1664 *depth_stencil_view
= NULL
;
1668 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1669 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1672 wined3d_mutex_unlock();
1675 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1676 ID3D11DeviceContext
*iface
,
1677 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1678 ID3D11DepthStencilView
**depth_stencil_view
,
1679 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1680 ID3D11UnorderedAccessView
**unordered_access_views
)
1682 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1683 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1684 "unordered_access_views %p stub!\n",
1685 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1686 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1689 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1690 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1692 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1694 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1695 iface
, blend_state
, blend_factor
, sample_mask
);
1697 if ((*blend_state
= device
->blend_state
? &device
->blend_state
->ID3D11BlendState_iface
: NULL
))
1698 ID3D11BlendState_AddRef(*blend_state
);
1699 wined3d_mutex_lock();
1700 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
1701 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1702 wined3d_mutex_unlock();
1705 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1706 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1708 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1710 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1711 iface
, depth_stencil_state
, stencil_ref
);
1713 if ((*depth_stencil_state
= device
->depth_stencil_state
1714 ? &device
->depth_stencil_state
->ID3D11DepthStencilState_iface
: NULL
))
1715 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
1716 *stencil_ref
= device
->stencil_ref
;
1719 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1720 UINT buffer_count
, ID3D11Buffer
**buffers
)
1722 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1725 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1727 wined3d_mutex_lock();
1728 for (i
= 0; i
< buffer_count
; ++i
)
1730 struct wined3d_buffer
*wined3d_buffer
;
1731 struct d3d_buffer
*buffer_impl
;
1733 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1739 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1740 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1741 ID3D11Buffer_AddRef(buffers
[i
]);
1743 wined3d_mutex_unlock();
1746 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
1747 ID3D11RasterizerState
**rasterizer_state
)
1749 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1751 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1753 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D11RasterizerState_iface
: NULL
))
1754 ID3D11RasterizerState_AddRef(*rasterizer_state
);
1757 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
1758 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1760 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1761 struct wined3d_viewport wined3d_vp
;
1763 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1767 *viewport_count
= 1;
1771 if (!*viewport_count
)
1774 wined3d_mutex_lock();
1775 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1776 wined3d_mutex_unlock();
1778 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1779 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1780 viewports
[0].Width
= wined3d_vp
.width
;
1781 viewports
[0].Height
= wined3d_vp
.height
;
1782 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1783 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1785 if (*viewport_count
> 1)
1786 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1789 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
1790 UINT
*rect_count
, D3D11_RECT
*rects
)
1792 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1794 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
1805 wined3d_mutex_lock();
1806 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
1807 wined3d_mutex_unlock();
1808 if (*rect_count
> 1)
1809 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
1812 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
1813 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1815 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1818 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
1819 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1821 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1822 iface
, shader
, class_instances
, class_instance_count
);
1825 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
1826 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1828 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1829 iface
, start_slot
, sampler_count
, samplers
);
1832 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1833 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1835 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1836 iface
, start_slot
, buffer_count
, buffers
);
1839 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
1840 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1842 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1843 iface
, start_slot
, view_count
, views
);
1846 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
1847 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1849 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1850 iface
, shader
, class_instances
, class_instance_count
);
1853 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
1854 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1856 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1857 iface
, start_slot
, sampler_count
, samplers
);
1860 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1861 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1863 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1864 iface
, start_slot
, buffer_count
, buffers
);
1867 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
1868 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1870 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1873 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1874 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
1876 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1879 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
1880 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1882 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1883 iface
, shader
, class_instances
, class_instance_count
);
1886 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
1887 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1889 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1890 iface
, start_slot
, sampler_count
, samplers
);
1893 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1894 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1896 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1897 iface
, start_slot
, buffer_count
, buffers
);
1900 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
1902 FIXME("iface %p stub!\n", iface
);
1905 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
1907 FIXME("iface %p stub!\n", iface
);
1910 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
1912 TRACE("iface %p.\n", iface
);
1914 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
1917 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
1919 FIXME("iface %p stub!\n", iface
);
1924 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
1925 BOOL restore
, ID3D11CommandList
**command_list
)
1927 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
1932 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
1934 /* IUnknown methods */
1935 d3d11_immediate_context_QueryInterface
,
1936 d3d11_immediate_context_AddRef
,
1937 d3d11_immediate_context_Release
,
1938 /* ID3D11DeviceChild methods */
1939 d3d11_immediate_context_GetDevice
,
1940 d3d11_immediate_context_GetPrivateData
,
1941 d3d11_immediate_context_SetPrivateData
,
1942 d3d11_immediate_context_SetPrivateDataInterface
,
1943 /* ID3D11DeviceContext methods */
1944 d3d11_immediate_context_VSSetConstantBuffers
,
1945 d3d11_immediate_context_PSSetShaderResources
,
1946 d3d11_immediate_context_PSSetShader
,
1947 d3d11_immediate_context_PSSetSamplers
,
1948 d3d11_immediate_context_VSSetShader
,
1949 d3d11_immediate_context_DrawIndexed
,
1950 d3d11_immediate_context_Draw
,
1951 d3d11_immediate_context_Map
,
1952 d3d11_immediate_context_Unmap
,
1953 d3d11_immediate_context_PSSetConstantBuffers
,
1954 d3d11_immediate_context_IASetInputLayout
,
1955 d3d11_immediate_context_IASetVertexBuffers
,
1956 d3d11_immediate_context_IASetIndexBuffer
,
1957 d3d11_immediate_context_DrawIndexedInstanced
,
1958 d3d11_immediate_context_DrawInstanced
,
1959 d3d11_immediate_context_GSSetConstantBuffers
,
1960 d3d11_immediate_context_GSSetShader
,
1961 d3d11_immediate_context_IASetPrimitiveTopology
,
1962 d3d11_immediate_context_VSSetShaderResources
,
1963 d3d11_immediate_context_VSSetSamplers
,
1964 d3d11_immediate_context_Begin
,
1965 d3d11_immediate_context_End
,
1966 d3d11_immediate_context_GetData
,
1967 d3d11_immediate_context_SetPredication
,
1968 d3d11_immediate_context_GSSetShaderResources
,
1969 d3d11_immediate_context_GSSetSamplers
,
1970 d3d11_immediate_context_OMSetRenderTargets
,
1971 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
1972 d3d11_immediate_context_OMSetBlendState
,
1973 d3d11_immediate_context_OMSetDepthStencilState
,
1974 d3d11_immediate_context_SOSetTargets
,
1975 d3d11_immediate_context_DrawAuto
,
1976 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
1977 d3d11_immediate_context_DrawInstancedIndirect
,
1978 d3d11_immediate_context_Dispatch
,
1979 d3d11_immediate_context_DispatchIndirect
,
1980 d3d11_immediate_context_RSSetState
,
1981 d3d11_immediate_context_RSSetViewports
,
1982 d3d11_immediate_context_RSSetScissorRects
,
1983 d3d11_immediate_context_CopySubresourceRegion
,
1984 d3d11_immediate_context_CopyResource
,
1985 d3d11_immediate_context_UpdateSubresource
,
1986 d3d11_immediate_context_CopyStructureCount
,
1987 d3d11_immediate_context_ClearRenderTargetView
,
1988 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
1989 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
1990 d3d11_immediate_context_ClearDepthStencilView
,
1991 d3d11_immediate_context_GenerateMips
,
1992 d3d11_immediate_context_SetResourceMinLOD
,
1993 d3d11_immediate_context_GetResourceMinLOD
,
1994 d3d11_immediate_context_ResolveSubresource
,
1995 d3d11_immediate_context_ExecuteCommandList
,
1996 d3d11_immediate_context_HSSetShaderResources
,
1997 d3d11_immediate_context_HSSetShader
,
1998 d3d11_immediate_context_HSSetSamplers
,
1999 d3d11_immediate_context_HSSetConstantBuffers
,
2000 d3d11_immediate_context_DSSetShaderResources
,
2001 d3d11_immediate_context_DSSetShader
,
2002 d3d11_immediate_context_DSSetSamplers
,
2003 d3d11_immediate_context_DSSetConstantBuffers
,
2004 d3d11_immediate_context_CSSetShaderResources
,
2005 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2006 d3d11_immediate_context_CSSetShader
,
2007 d3d11_immediate_context_CSSetSamplers
,
2008 d3d11_immediate_context_CSSetConstantBuffers
,
2009 d3d11_immediate_context_VSGetConstantBuffers
,
2010 d3d11_immediate_context_PSGetShaderResources
,
2011 d3d11_immediate_context_PSGetShader
,
2012 d3d11_immediate_context_PSGetSamplers
,
2013 d3d11_immediate_context_VSGetShader
,
2014 d3d11_immediate_context_PSGetConstantBuffers
,
2015 d3d11_immediate_context_IAGetInputLayout
,
2016 d3d11_immediate_context_IAGetVertexBuffers
,
2017 d3d11_immediate_context_IAGetIndexBuffer
,
2018 d3d11_immediate_context_GSGetConstantBuffers
,
2019 d3d11_immediate_context_GSGetShader
,
2020 d3d11_immediate_context_IAGetPrimitiveTopology
,
2021 d3d11_immediate_context_VSGetShaderResources
,
2022 d3d11_immediate_context_VSGetSamplers
,
2023 d3d11_immediate_context_GetPredication
,
2024 d3d11_immediate_context_GSGetShaderResources
,
2025 d3d11_immediate_context_GSGetSamplers
,
2026 d3d11_immediate_context_OMGetRenderTargets
,
2027 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2028 d3d11_immediate_context_OMGetBlendState
,
2029 d3d11_immediate_context_OMGetDepthStencilState
,
2030 d3d11_immediate_context_SOGetTargets
,
2031 d3d11_immediate_context_RSGetState
,
2032 d3d11_immediate_context_RSGetViewports
,
2033 d3d11_immediate_context_RSGetScissorRects
,
2034 d3d11_immediate_context_HSGetShaderResources
,
2035 d3d11_immediate_context_HSGetShader
,
2036 d3d11_immediate_context_HSGetSamplers
,
2037 d3d11_immediate_context_HSGetConstantBuffers
,
2038 d3d11_immediate_context_DSGetShaderResources
,
2039 d3d11_immediate_context_DSGetShader
,
2040 d3d11_immediate_context_DSGetSamplers
,
2041 d3d11_immediate_context_DSGetConstantBuffers
,
2042 d3d11_immediate_context_CSGetShaderResources
,
2043 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2044 d3d11_immediate_context_CSGetShader
,
2045 d3d11_immediate_context_CSGetSamplers
,
2046 d3d11_immediate_context_CSGetConstantBuffers
,
2047 d3d11_immediate_context_ClearState
,
2048 d3d11_immediate_context_Flush
,
2049 d3d11_immediate_context_GetType
,
2050 d3d11_immediate_context_GetContextFlags
,
2051 d3d11_immediate_context_FinishCommandList
,
2054 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
2056 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
2057 context
->refcount
= 1;
2059 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
2061 wined3d_private_store_init(&context
->private_store
);
2064 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
2066 wined3d_private_store_cleanup(&context
->private_store
);
2069 /* ID3D11Device methods */
2071 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
2073 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2074 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
2077 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
2079 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2080 return IUnknown_AddRef(device
->outer_unk
);
2083 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
2085 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2086 return IUnknown_Release(device
->outer_unk
);
2089 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
2090 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
2092 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2093 struct d3d_buffer
*object
;
2096 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2098 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
2101 *buffer
= &object
->ID3D11Buffer_iface
;
2106 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
2107 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
2109 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2114 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
2115 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2117 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2118 struct d3d_texture2d
*object
;
2121 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2123 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2126 *texture
= &object
->ID3D11Texture2D_iface
;
2131 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2132 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2134 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2135 struct d3d_texture3d
*object
;
2138 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2140 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2143 *texture
= &object
->ID3D11Texture3D_iface
;
2148 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2149 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2151 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2152 struct d3d_shader_resource_view
*object
;
2155 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2157 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2160 *view
= &object
->ID3D11ShaderResourceView_iface
;
2165 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2166 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2168 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2169 struct d3d11_unordered_access_view
*object
;
2172 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2174 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
2177 *view
= &object
->ID3D11UnorderedAccessView_iface
;
2182 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2183 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2185 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2186 struct d3d_rendertarget_view
*object
;
2189 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2191 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2194 *view
= &object
->ID3D11RenderTargetView_iface
;
2199 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2200 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2202 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2203 struct d3d_depthstencil_view
*object
;
2206 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2208 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2211 *view
= &object
->ID3D11DepthStencilView_iface
;
2216 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2217 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2218 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2220 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2221 struct d3d_input_layout
*object
;
2224 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2225 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2226 shader_byte_code_length
, input_layout
);
2228 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2229 shader_byte_code
, shader_byte_code_length
, &object
)))
2232 *input_layout
= &object
->ID3D11InputLayout_iface
;
2237 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2238 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2240 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2241 struct d3d_vertex_shader
*object
;
2244 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2245 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2248 FIXME("Class linkage is not implemented yet.\n");
2250 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2253 *shader
= &object
->ID3D11VertexShader_iface
;
2258 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2259 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2261 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2262 struct d3d_geometry_shader
*object
;
2265 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2266 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2269 FIXME("Class linkage is not implemented yet.\n");
2271 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2274 *shader
= &object
->ID3D11GeometryShader_iface
;
2279 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2280 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2281 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
2282 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2284 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2285 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2286 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2287 rasterized_stream
, class_linkage
, shader
);
2292 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2293 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2295 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2296 struct d3d_pixel_shader
*object
;
2299 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2300 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2303 FIXME("Class linkage is not implemented yet.\n");
2305 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2308 *shader
= &object
->ID3D11PixelShader_iface
;
2313 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2314 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2316 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2317 struct d3d11_hull_shader
*object
;
2320 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2321 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2324 FIXME("Class linkage is not implemented yet.\n");
2326 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2329 *shader
= &object
->ID3D11HullShader_iface
;
2334 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2335 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2337 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2338 struct d3d11_domain_shader
*object
;
2341 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2342 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2345 FIXME("Class linkage is not implemented yet.\n");
2347 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2350 *shader
= &object
->ID3D11DomainShader_iface
;
2355 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2356 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2358 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2359 struct d3d11_compute_shader
*object
;
2362 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2363 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2366 FIXME("Class linkage is not implemented yet.\n");
2368 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2371 *shader
= &object
->ID3D11ComputeShader_iface
;
2376 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2377 ID3D11ClassLinkage
**class_linkage
)
2379 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2380 struct d3d11_class_linkage
*object
;
2383 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
2385 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
2388 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
2393 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
2394 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
2396 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2397 struct d3d_blend_state
*object
;
2398 struct wine_rb_entry
*entry
;
2399 D3D11_BLEND_DESC tmp_desc
;
2403 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2406 return E_INVALIDARG
;
2408 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2409 * D3D11_BLEND_DESC as a key in the rbtree. */
2410 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2411 tmp_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
2412 tmp_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
2413 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2415 j
= desc
->IndependentBlendEnable
? i
: 0;
2416 tmp_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[j
].BlendEnable
;
2417 tmp_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[j
].SrcBlend
;
2418 tmp_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[j
].DestBlend
;
2419 tmp_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[j
].BlendOp
;
2420 tmp_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[j
].SrcBlendAlpha
;
2421 tmp_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[j
].DestBlendAlpha
;
2422 tmp_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[j
].BlendOpAlpha
;
2423 tmp_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[j
].RenderTargetWriteMask
;
2426 wined3d_mutex_lock();
2427 if ((entry
= wine_rb_get(&device
->blend_states
, &tmp_desc
)))
2429 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_blend_state
, entry
);
2431 TRACE("Returning existing blend state %p.\n", object
);
2432 *blend_state
= &object
->ID3D11BlendState_iface
;
2433 ID3D11BlendState_AddRef(*blend_state
);
2434 wined3d_mutex_unlock();
2438 wined3d_mutex_unlock();
2440 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2441 return E_OUTOFMEMORY
;
2443 if (FAILED(hr
= d3d_blend_state_init(object
, device
, &tmp_desc
)))
2445 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2446 HeapFree(GetProcessHeap(), 0, object
);
2450 TRACE("Created blend state %p.\n", object
);
2451 *blend_state
= &object
->ID3D11BlendState_iface
;
2456 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
2457 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
2459 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2460 struct d3d_depthstencil_state
*object
;
2461 D3D11_DEPTH_STENCIL_DESC tmp_desc
;
2462 struct wine_rb_entry
*entry
;
2465 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2468 return E_INVALIDARG
;
2470 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2471 * it as a key in the rbtree. */
2472 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2473 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2474 if (desc
->DepthEnable
)
2476 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2477 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2481 tmp_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
2482 tmp_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
2484 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2485 if (desc
->StencilEnable
)
2487 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2488 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2489 tmp_desc
.FrontFace
= desc
->FrontFace
;
2490 tmp_desc
.BackFace
= desc
->BackFace
;
2494 tmp_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
2495 tmp_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
2496 tmp_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2497 tmp_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2498 tmp_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2499 tmp_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2500 tmp_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2501 tmp_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2502 tmp_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2503 tmp_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2506 wined3d_mutex_lock();
2507 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2509 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_depthstencil_state
, entry
);
2511 TRACE("Returning existing depthstencil state %p.\n", object
);
2512 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2513 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
2514 wined3d_mutex_unlock();
2518 wined3d_mutex_unlock();
2520 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2521 return E_OUTOFMEMORY
;
2523 if (FAILED(hr
= d3d_depthstencil_state_init(object
, device
, &tmp_desc
)))
2525 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2526 HeapFree(GetProcessHeap(), 0, object
);
2530 TRACE("Created depthstencil state %p.\n", object
);
2531 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2536 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
2537 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
2539 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2540 struct d3d_rasterizer_state
*object
;
2541 struct wine_rb_entry
*entry
;
2544 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2547 return E_INVALIDARG
;
2549 wined3d_mutex_lock();
2550 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2552 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_rasterizer_state
, entry
);
2554 TRACE("Returning existing rasterizer state %p.\n", object
);
2555 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2556 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2557 wined3d_mutex_unlock();
2561 wined3d_mutex_unlock();
2563 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2564 return E_OUTOFMEMORY
;
2566 if (FAILED(hr
= d3d_rasterizer_state_init(object
, device
, desc
)))
2568 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2569 HeapFree(GetProcessHeap(), 0, object
);
2573 TRACE("Created rasterizer state %p.\n", object
);
2574 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2579 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
2580 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
2582 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2583 D3D11_SAMPLER_DESC normalized_desc
;
2584 struct d3d_sampler_state
*object
;
2585 struct wine_rb_entry
*entry
;
2588 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2591 return E_INVALIDARG
;
2593 normalized_desc
= *desc
;
2594 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc
.Filter
))
2595 normalized_desc
.MaxAnisotropy
= 0;
2596 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc
.Filter
))
2597 normalized_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
2598 if (normalized_desc
.AddressU
!= D3D11_TEXTURE_ADDRESS_BORDER
2599 && normalized_desc
.AddressV
!= D3D11_TEXTURE_ADDRESS_BORDER
2600 && normalized_desc
.AddressW
!= D3D11_TEXTURE_ADDRESS_BORDER
)
2601 memset(&normalized_desc
.BorderColor
, 0, sizeof(normalized_desc
.BorderColor
));
2603 wined3d_mutex_lock();
2604 if ((entry
= wine_rb_get(&device
->sampler_states
, &normalized_desc
)))
2606 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_sampler_state
, entry
);
2608 TRACE("Returning existing sampler state %p.\n", object
);
2609 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2610 ID3D11SamplerState_AddRef(*sampler_state
);
2611 wined3d_mutex_unlock();
2615 wined3d_mutex_unlock();
2617 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2618 return E_OUTOFMEMORY
;
2620 if (FAILED(hr
= d3d_sampler_state_init(object
, device
, &normalized_desc
)))
2622 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2623 HeapFree(GetProcessHeap(), 0, object
);
2627 TRACE("Created sampler state %p.\n", object
);
2628 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2633 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
2634 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
2636 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2637 struct d3d_query
*object
;
2640 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2642 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
2647 *query
= &object
->ID3D11Query_iface
;
2651 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2655 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
2656 ID3D11Predicate
**predicate
)
2658 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2659 struct d3d_query
*object
;
2662 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2664 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
2669 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
2673 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2677 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2678 ID3D11Counter
**counter
)
2680 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2685 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
2686 ID3D11DeviceContext
**context
)
2688 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
2693 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
2696 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
2701 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
2702 UINT
*format_support
)
2704 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
2709 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
2710 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2712 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2713 struct wined3d_device_creation_parameters params
;
2714 struct wined3d
*wined3d
;
2717 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
2718 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2720 if (!quality_level_count
)
2721 return E_INVALIDARG
;
2723 *quality_level_count
= 0;
2727 if (sample_count
== 1)
2729 *quality_level_count
= 1;
2732 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
2735 wined3d_mutex_lock();
2736 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
2737 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
2738 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
2739 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
2740 wined3d_mutex_unlock();
2742 if (hr
== WINED3DERR_INVALIDCALL
)
2743 return E_INVALIDARG
;
2744 if (hr
== WINED3DERR_NOTAVAILABLE
)
2749 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
2751 FIXME("iface %p, info %p stub!\n", iface
, info
);
2754 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2755 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
2756 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2758 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2759 "units %p, units_length %p, description %p, description_length %p stub!\n",
2760 iface
, desc
, type
, active_counter_count
, name
, name_length
,
2761 units
, units_length
, description
, description_length
);
2766 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
2767 void *feature_support_data
, UINT feature_support_data_size
)
2769 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
2770 iface
, feature
, feature_support_data
, feature_support_data_size
);
2774 case D3D11_FEATURE_THREADING
:
2776 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
2777 if (feature_support_data_size
!= sizeof(*threading_data
))
2779 WARN("Invalid data size.\n");
2780 return E_INVALIDARG
;
2783 /* We lie about the threading support to make Tomb Raider 2013 and
2784 * Deus Ex: Human Revolution happy. */
2785 FIXME("Returning fake threading support data.\n");
2786 threading_data
->DriverConcurrentCreates
= TRUE
;
2787 threading_data
->DriverCommandLists
= TRUE
;
2790 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
2792 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
2793 if (feature_support_data_size
!= sizeof(*options
))
2795 WARN("Invalid data size.\n");
2796 return E_INVALIDARG
;
2799 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
2804 FIXME("Unhandled feature %#x.\n", feature
);
2809 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2810 UINT
*data_size
, void *data
)
2812 IDXGIDevice
*dxgi_device
;
2815 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2817 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2819 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
2820 IDXGIDevice_Release(dxgi_device
);
2825 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2826 UINT data_size
, const void *data
)
2828 IDXGIDevice
*dxgi_device
;
2831 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2833 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2835 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
2836 IDXGIDevice_Release(dxgi_device
);
2841 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
2842 const IUnknown
*data
)
2844 IDXGIDevice
*dxgi_device
;
2847 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
2849 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2851 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
2852 IDXGIDevice_Release(dxgi_device
);
2857 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
2859 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2861 TRACE("iface %p.\n", iface
);
2863 return device
->feature_level
;
2866 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
2868 FIXME("iface %p stub!\n", iface
);
2873 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
2875 FIXME("iface %p stub!\n", iface
);
2880 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
2881 ID3D11DeviceContext
**immediate_context
)
2883 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2885 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
2887 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
2888 ID3D11DeviceContext_AddRef(*immediate_context
);
2891 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
2893 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2898 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
2900 FIXME("iface %p stub!\n", iface
);
2905 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
2907 /* IUnknown methods */
2908 d3d11_device_QueryInterface
,
2909 d3d11_device_AddRef
,
2910 d3d11_device_Release
,
2911 /* ID3D11Device methods */
2912 d3d11_device_CreateBuffer
,
2913 d3d11_device_CreateTexture1D
,
2914 d3d11_device_CreateTexture2D
,
2915 d3d11_device_CreateTexture3D
,
2916 d3d11_device_CreateShaderResourceView
,
2917 d3d11_device_CreateUnorderedAccessView
,
2918 d3d11_device_CreateRenderTargetView
,
2919 d3d11_device_CreateDepthStencilView
,
2920 d3d11_device_CreateInputLayout
,
2921 d3d11_device_CreateVertexShader
,
2922 d3d11_device_CreateGeometryShader
,
2923 d3d11_device_CreateGeometryShaderWithStreamOutput
,
2924 d3d11_device_CreatePixelShader
,
2925 d3d11_device_CreateHullShader
,
2926 d3d11_device_CreateDomainShader
,
2927 d3d11_device_CreateComputeShader
,
2928 d3d11_device_CreateClassLinkage
,
2929 d3d11_device_CreateBlendState
,
2930 d3d11_device_CreateDepthStencilState
,
2931 d3d11_device_CreateRasterizerState
,
2932 d3d11_device_CreateSamplerState
,
2933 d3d11_device_CreateQuery
,
2934 d3d11_device_CreatePredicate
,
2935 d3d11_device_CreateCounter
,
2936 d3d11_device_CreateDeferredContext
,
2937 d3d11_device_OpenSharedResource
,
2938 d3d11_device_CheckFormatSupport
,
2939 d3d11_device_CheckMultisampleQualityLevels
,
2940 d3d11_device_CheckCounterInfo
,
2941 d3d11_device_CheckCounter
,
2942 d3d11_device_CheckFeatureSupport
,
2943 d3d11_device_GetPrivateData
,
2944 d3d11_device_SetPrivateData
,
2945 d3d11_device_SetPrivateDataInterface
,
2946 d3d11_device_GetFeatureLevel
,
2947 d3d11_device_GetCreationFlags
,
2948 d3d11_device_GetDeviceRemovedReason
,
2949 d3d11_device_GetImmediateContext
,
2950 d3d11_device_SetExceptionMode
,
2951 d3d11_device_GetExceptionMode
,
2954 /* Inner IUnknown methods */
2956 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
2958 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
2961 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
2963 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2965 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
2967 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
2968 || IsEqualGUID(riid
, &IID_IUnknown
))
2970 *out
= &device
->ID3D11Device_iface
;
2972 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
2973 || IsEqualGUID(riid
, &IID_ID3D10Device
))
2975 *out
= &device
->ID3D10Device1_iface
;
2977 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
2979 *out
= &device
->ID3D10Multithread_iface
;
2981 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
2983 *out
= &device
->IWineDXGIDeviceParent_iface
;
2987 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
2989 return E_NOINTERFACE
;
2992 IUnknown_AddRef((IUnknown
*)*out
);
2996 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
2998 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2999 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
3001 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
3006 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
3008 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3009 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
3011 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
3015 d3d11_immediate_context_destroy(&device
->immediate_context
);
3016 if (device
->wined3d_device
)
3018 wined3d_mutex_lock();
3019 wined3d_device_decref(device
->wined3d_device
);
3020 wined3d_mutex_unlock();
3022 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
3023 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3024 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3025 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3031 /* IUnknown methods */
3033 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
3036 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3037 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
3040 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
3042 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3043 return IUnknown_AddRef(device
->outer_unk
);
3046 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
3048 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3049 return IUnknown_Release(device
->outer_unk
);
3052 /* ID3D10Device methods */
3054 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
3055 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3057 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3060 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3061 iface
, start_slot
, buffer_count
, buffers
);
3063 wined3d_mutex_lock();
3064 for (i
= 0; i
< buffer_count
; ++i
)
3066 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3068 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
3069 buffer
? buffer
->wined3d_buffer
: NULL
);
3071 wined3d_mutex_unlock();
3074 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
3075 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3077 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3080 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3081 iface
, start_slot
, view_count
, views
);
3083 wined3d_mutex_lock();
3084 for (i
= 0; i
< view_count
; ++i
)
3086 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3088 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
3089 view
? view
->wined3d_view
: NULL
);
3091 wined3d_mutex_unlock();
3094 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
3095 ID3D10PixelShader
*shader
)
3097 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3098 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
3100 TRACE("iface %p, shader %p\n", iface
, shader
);
3102 wined3d_mutex_lock();
3103 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
3104 wined3d_mutex_unlock();
3107 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
3108 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3110 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3113 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3114 iface
, start_slot
, sampler_count
, samplers
);
3116 wined3d_mutex_lock();
3117 for (i
= 0; i
< sampler_count
; ++i
)
3119 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3121 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
3122 sampler
? sampler
->wined3d_sampler
: NULL
);
3124 wined3d_mutex_unlock();
3127 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
3128 ID3D10VertexShader
*shader
)
3130 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3131 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
3133 TRACE("iface %p, shader %p\n", iface
, shader
);
3135 wined3d_mutex_lock();
3136 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
3137 wined3d_mutex_unlock();
3140 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
3141 UINT start_index_location
, INT base_vertex_location
)
3143 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3145 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
3146 iface
, index_count
, start_index_location
, base_vertex_location
);
3148 wined3d_mutex_lock();
3149 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3150 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
3151 wined3d_mutex_unlock();
3154 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
3155 UINT start_vertex_location
)
3157 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3159 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
3160 iface
, vertex_count
, start_vertex_location
);
3162 wined3d_mutex_lock();
3163 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
3164 wined3d_mutex_unlock();
3167 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
3168 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3170 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3173 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3174 iface
, start_slot
, buffer_count
, buffers
);
3176 wined3d_mutex_lock();
3177 for (i
= 0; i
< buffer_count
; ++i
)
3179 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3181 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
3182 buffer
? buffer
->wined3d_buffer
: NULL
);
3184 wined3d_mutex_unlock();
3187 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
3188 ID3D10InputLayout
*input_layout
)
3190 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3191 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
3193 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
3195 wined3d_mutex_lock();
3196 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
3197 layout
? layout
->wined3d_decl
: NULL
);
3198 wined3d_mutex_unlock();
3201 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
3202 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
3204 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3207 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
3208 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3210 wined3d_mutex_lock();
3211 for (i
= 0; i
< buffer_count
; ++i
)
3213 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3215 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
3216 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3218 wined3d_mutex_unlock();
3221 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3222 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3224 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3225 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3227 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3228 iface
, buffer
, debug_dxgi_format(format
), offset
);
3230 wined3d_mutex_lock();
3231 wined3d_device_set_index_buffer(device
->wined3d_device
,
3232 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3233 wined3dformat_from_dxgi_format(format
), offset
);
3234 wined3d_mutex_unlock();
3237 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3238 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3239 INT base_vertex_location
, UINT start_instance_location
)
3241 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3243 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3244 "base_vertex_location %d, start_instance_location %u.\n",
3245 iface
, instance_index_count
, instance_count
, start_index_location
,
3246 base_vertex_location
, start_instance_location
);
3248 wined3d_mutex_lock();
3249 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3250 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3251 instance_index_count
, start_instance_location
, instance_count
);
3252 wined3d_mutex_unlock();
3255 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3256 UINT instance_vertex_count
, UINT instance_count
,
3257 UINT start_vertex_location
, UINT start_instance_location
)
3259 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3261 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3262 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3263 start_vertex_location
, start_instance_location
);
3265 wined3d_mutex_lock();
3266 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3267 instance_vertex_count
, start_instance_location
, instance_count
);
3268 wined3d_mutex_unlock();
3271 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3272 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3274 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3277 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3278 iface
, start_slot
, buffer_count
, buffers
);
3280 wined3d_mutex_lock();
3281 for (i
= 0; i
< buffer_count
; ++i
)
3283 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3285 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3286 buffer
? buffer
->wined3d_buffer
: NULL
);
3288 wined3d_mutex_unlock();
3291 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3293 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3294 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3296 TRACE("iface %p, shader %p.\n", iface
, shader
);
3298 wined3d_mutex_lock();
3299 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3300 wined3d_mutex_unlock();
3303 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3304 D3D10_PRIMITIVE_TOPOLOGY topology
)
3306 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3308 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
3310 wined3d_mutex_lock();
3311 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
3312 wined3d_mutex_unlock();
3315 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3316 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3318 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3321 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3322 iface
, start_slot
, view_count
, views
);
3324 wined3d_mutex_lock();
3325 for (i
= 0; i
< view_count
; ++i
)
3327 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3329 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3330 view
? view
->wined3d_view
: NULL
);
3332 wined3d_mutex_unlock();
3335 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3336 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3338 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3341 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3342 iface
, start_slot
, sampler_count
, samplers
);
3344 wined3d_mutex_lock();
3345 for (i
= 0; i
< sampler_count
; ++i
)
3347 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3349 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3350 sampler
? sampler
->wined3d_sampler
: NULL
);
3352 wined3d_mutex_unlock();
3355 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3357 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3358 struct d3d_query
*query
;
3360 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3362 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3363 wined3d_mutex_lock();
3364 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3365 wined3d_mutex_unlock();
3368 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3369 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3371 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3374 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3375 iface
, start_slot
, view_count
, views
);
3377 wined3d_mutex_lock();
3378 for (i
= 0; i
< view_count
; ++i
)
3380 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3382 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3383 view
? view
->wined3d_view
: NULL
);
3385 wined3d_mutex_unlock();
3388 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3389 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3391 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3394 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3395 iface
, start_slot
, sampler_count
, samplers
);
3397 wined3d_mutex_lock();
3398 for (i
= 0; i
< sampler_count
; ++i
)
3400 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3402 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3403 sampler
? sampler
->wined3d_sampler
: NULL
);
3405 wined3d_mutex_unlock();
3408 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3409 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3410 ID3D10DepthStencilView
*depth_stencil_view
)
3412 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3413 struct d3d_depthstencil_view
*dsv
;
3416 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3417 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3419 wined3d_mutex_lock();
3420 for (i
= 0; i
< render_target_view_count
; ++i
)
3422 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3424 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3425 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3427 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3429 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3432 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3433 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3434 dsv
? dsv
->wined3d_view
: NULL
);
3435 wined3d_mutex_unlock();
3438 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3439 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3441 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3442 struct d3d_blend_state
*blend_state_object
;
3444 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3445 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3447 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3448 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3449 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3452 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3453 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3455 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3456 struct d3d_depthstencil_state
*ds_state_object
;
3458 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3459 iface
, depth_stencil_state
, stencil_ref
);
3461 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3462 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3463 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
3466 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3467 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3469 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3470 unsigned int count
, i
;
3472 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3474 count
= min(target_count
, 4);
3475 wined3d_mutex_lock();
3476 for (i
= 0; i
< count
; ++i
)
3478 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
3480 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
3481 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
3484 for (i
= count
; i
< 4; ++i
)
3486 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
3488 wined3d_mutex_unlock();
3491 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
3493 FIXME("iface %p stub!\n", iface
);
3496 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
3498 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3499 struct d3d_rasterizer_state
*rasterizer_state_object
;
3501 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3503 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
3504 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3505 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
3508 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
3509 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
3511 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3512 struct wined3d_viewport wined3d_vp
;
3514 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
3516 if (viewport_count
> 1)
3517 FIXME("Multiple viewports not implemented.\n");
3519 if (!viewport_count
)
3522 wined3d_vp
.x
= viewports
[0].TopLeftX
;
3523 wined3d_vp
.y
= viewports
[0].TopLeftY
;
3524 wined3d_vp
.width
= viewports
[0].Width
;
3525 wined3d_vp
.height
= viewports
[0].Height
;
3526 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
3527 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
3529 wined3d_mutex_lock();
3530 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
3531 wined3d_mutex_unlock();
3534 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
3535 UINT rect_count
, const D3D10_RECT
*rects
)
3537 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3539 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
3542 FIXME("Multiple scissor rects not implemented.\n");
3547 wined3d_mutex_lock();
3548 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
3549 wined3d_mutex_unlock();
3552 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
3553 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
3554 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
3556 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3557 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3558 struct wined3d_box wined3d_src_box
;
3560 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3561 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3562 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
3563 src_resource
, src_subresource_idx
, src_box
);
3567 wined3d_src_box
.left
= src_box
->left
;
3568 wined3d_src_box
.top
= src_box
->top
;
3569 wined3d_src_box
.front
= src_box
->front
;
3570 wined3d_src_box
.right
= src_box
->right
;
3571 wined3d_src_box
.bottom
= src_box
->bottom
;
3572 wined3d_src_box
.back
= src_box
->back
;
3575 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3576 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3577 wined3d_mutex_lock();
3578 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
3579 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
3580 wined3d_mutex_unlock();
3583 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
3584 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
3586 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3587 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3589 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
3591 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3592 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3593 wined3d_mutex_lock();
3594 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
3595 wined3d_mutex_unlock();
3598 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
3599 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
3600 const void *data
, UINT row_pitch
, UINT depth_pitch
)
3602 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3603 ID3D11Resource
*d3d11_resource
;
3605 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3606 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
3608 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
3609 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3610 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
3611 ID3D11Resource_Release(d3d11_resource
);
3614 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
3615 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
3617 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3618 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
3619 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
3622 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
3623 iface
, render_target_view
, debug_float4(color_rgba
));
3628 wined3d_mutex_lock();
3629 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3630 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
3631 ERR("Failed to clear view, hr %#x.\n", hr
);
3632 wined3d_mutex_unlock();
3635 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
3636 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
3638 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3639 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3640 DWORD wined3d_flags
;
3643 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
3644 iface
, depth_stencil_view
, flags
, depth
, stencil
);
3649 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
3651 wined3d_mutex_lock();
3652 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3653 wined3d_flags
, NULL
, depth
, stencil
)))
3654 ERR("Failed to clear view, hr %#x.\n", hr
);
3655 wined3d_mutex_unlock();
3658 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
3659 ID3D10ShaderResourceView
*shader_resource_view
)
3661 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
3664 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
3665 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
3666 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
3668 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3669 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3670 iface
, dst_resource
, dst_subresource_idx
,
3671 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
3674 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
3675 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3677 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3680 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3681 iface
, start_slot
, buffer_count
, buffers
);
3683 wined3d_mutex_lock();
3684 for (i
= 0; i
< buffer_count
; ++i
)
3686 struct wined3d_buffer
*wined3d_buffer
;
3687 struct d3d_buffer
*buffer_impl
;
3689 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
3695 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3696 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3697 ID3D10Buffer_AddRef(buffers
[i
]);
3699 wined3d_mutex_unlock();
3702 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
3703 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3705 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3708 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3709 iface
, start_slot
, view_count
, views
);
3711 wined3d_mutex_lock();
3712 for (i
= 0; i
< view_count
; ++i
)
3714 struct wined3d_shader_resource_view
*wined3d_view
;
3715 struct d3d_shader_resource_view
*view_impl
;
3717 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3723 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3724 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3725 ID3D10ShaderResourceView_AddRef(views
[i
]);
3727 wined3d_mutex_unlock();
3730 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
3732 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3733 struct d3d_pixel_shader
*shader_impl
;
3734 struct wined3d_shader
*wined3d_shader
;
3736 TRACE("iface %p, shader %p.\n", iface
, shader
);
3738 wined3d_mutex_lock();
3739 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
3741 wined3d_mutex_unlock();
3746 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3747 wined3d_mutex_unlock();
3748 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
3749 ID3D10PixelShader_AddRef(*shader
);
3752 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
3753 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3755 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3758 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3759 iface
, start_slot
, sampler_count
, samplers
);
3761 wined3d_mutex_lock();
3762 for (i
= 0; i
< sampler_count
; ++i
)
3764 struct d3d_sampler_state
*sampler_impl
;
3765 struct wined3d_sampler
*wined3d_sampler
;
3767 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
3773 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3774 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3775 ID3D10SamplerState_AddRef(samplers
[i
]);
3777 wined3d_mutex_unlock();
3780 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
3782 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3783 struct d3d_vertex_shader
*shader_impl
;
3784 struct wined3d_shader
*wined3d_shader
;
3786 TRACE("iface %p, shader %p.\n", iface
, shader
);
3788 wined3d_mutex_lock();
3789 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
3791 wined3d_mutex_unlock();
3796 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3797 wined3d_mutex_unlock();
3798 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
3799 ID3D10VertexShader_AddRef(*shader
);
3802 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
3803 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3805 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3808 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3809 iface
, start_slot
, buffer_count
, buffers
);
3811 wined3d_mutex_lock();
3812 for (i
= 0; i
< buffer_count
; ++i
)
3814 struct wined3d_buffer
*wined3d_buffer
;
3815 struct d3d_buffer
*buffer_impl
;
3817 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
3823 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3824 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3825 ID3D10Buffer_AddRef(buffers
[i
]);
3827 wined3d_mutex_unlock();
3830 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
3832 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3833 struct wined3d_vertex_declaration
*wined3d_declaration
;
3834 struct d3d_input_layout
*input_layout_impl
;
3836 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
3838 wined3d_mutex_lock();
3839 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
3841 wined3d_mutex_unlock();
3842 *input_layout
= NULL
;
3846 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
3847 wined3d_mutex_unlock();
3848 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
3849 ID3D10InputLayout_AddRef(*input_layout
);
3852 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
3853 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
3855 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3858 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3859 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3861 wined3d_mutex_lock();
3862 for (i
= 0; i
< buffer_count
; ++i
)
3864 struct wined3d_buffer
*wined3d_buffer
;
3865 struct d3d_buffer
*buffer_impl
;
3867 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
3868 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
3869 ERR("Failed to get vertex buffer.\n");
3871 if (!wined3d_buffer
)
3877 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3878 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3879 ID3D10Buffer_AddRef(buffers
[i
]);
3881 wined3d_mutex_unlock();
3884 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
3885 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
3887 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3888 enum wined3d_format_id wined3d_format
;
3889 struct wined3d_buffer
*wined3d_buffer
;
3890 struct d3d_buffer
*buffer_impl
;
3892 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
3894 wined3d_mutex_lock();
3895 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
3896 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
3897 if (!wined3d_buffer
)
3899 wined3d_mutex_unlock();
3904 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3905 wined3d_mutex_unlock();
3906 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
3907 ID3D10Buffer_AddRef(*buffer
);
3910 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
3911 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3913 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3916 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3917 iface
, start_slot
, buffer_count
, buffers
);
3919 wined3d_mutex_lock();
3920 for (i
= 0; i
< buffer_count
; ++i
)
3922 struct wined3d_buffer
*wined3d_buffer
;
3923 struct d3d_buffer
*buffer_impl
;
3925 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
3931 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3932 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3933 ID3D10Buffer_AddRef(buffers
[i
]);
3935 wined3d_mutex_unlock();
3938 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
3940 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3941 struct d3d_geometry_shader
*shader_impl
;
3942 struct wined3d_shader
*wined3d_shader
;
3944 TRACE("iface %p, shader %p.\n", iface
, shader
);
3946 wined3d_mutex_lock();
3947 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
3949 wined3d_mutex_unlock();
3954 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3955 wined3d_mutex_unlock();
3956 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
3957 ID3D10GeometryShader_AddRef(*shader
);
3960 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
3961 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
3963 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3965 TRACE("iface %p, topology %p\n", iface
, topology
);
3967 wined3d_mutex_lock();
3968 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
3969 wined3d_mutex_unlock();
3972 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
3973 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3975 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3978 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3979 iface
, start_slot
, view_count
, views
);
3981 wined3d_mutex_lock();
3982 for (i
= 0; i
< view_count
; ++i
)
3984 struct wined3d_shader_resource_view
*wined3d_view
;
3985 struct d3d_shader_resource_view
*view_impl
;
3987 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3993 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3994 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3995 ID3D10ShaderResourceView_AddRef(views
[i
]);
3997 wined3d_mutex_unlock();
4000 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
4001 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4003 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4006 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4007 iface
, start_slot
, sampler_count
, samplers
);
4009 wined3d_mutex_lock();
4010 for (i
= 0; i
< sampler_count
; ++i
)
4012 struct d3d_sampler_state
*sampler_impl
;
4013 struct wined3d_sampler
*wined3d_sampler
;
4015 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4021 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4022 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4023 ID3D10SamplerState_AddRef(samplers
[i
]);
4025 wined3d_mutex_unlock();
4028 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
4029 ID3D10Predicate
**predicate
, BOOL
*value
)
4031 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4032 struct wined3d_query
*wined3d_predicate
;
4033 struct d3d_query
*predicate_impl
;
4035 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
4037 wined3d_mutex_lock();
4038 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
4040 wined3d_mutex_unlock();
4045 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
4046 wined3d_mutex_unlock();
4047 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
4048 ID3D10Predicate_AddRef(*predicate
);
4051 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
4052 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4054 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4057 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4058 iface
, start_slot
, view_count
, views
);
4060 wined3d_mutex_lock();
4061 for (i
= 0; i
< view_count
; ++i
)
4063 struct wined3d_shader_resource_view
*wined3d_view
;
4064 struct d3d_shader_resource_view
*view_impl
;
4066 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4072 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4073 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4074 ID3D10ShaderResourceView_AddRef(views
[i
]);
4076 wined3d_mutex_unlock();
4079 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
4080 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4082 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4085 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4086 iface
, start_slot
, sampler_count
, samplers
);
4088 wined3d_mutex_lock();
4089 for (i
= 0; i
< sampler_count
; ++i
)
4091 struct d3d_sampler_state
*sampler_impl
;
4092 struct wined3d_sampler
*wined3d_sampler
;
4094 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4100 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4101 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4102 ID3D10SamplerState_AddRef(samplers
[i
]);
4104 wined3d_mutex_unlock();
4107 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
4108 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
4110 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4111 struct wined3d_rendertarget_view
*wined3d_view
;
4113 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4114 iface
, view_count
, render_target_views
, depth_stencil_view
);
4116 wined3d_mutex_lock();
4117 if (render_target_views
)
4119 struct d3d_rendertarget_view
*view_impl
;
4122 for (i
= 0; i
< view_count
; ++i
)
4124 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
4125 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4127 render_target_views
[i
] = NULL
;
4131 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
4132 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
4136 if (depth_stencil_view
)
4138 struct d3d_depthstencil_view
*view_impl
;
4140 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
4141 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4143 *depth_stencil_view
= NULL
;
4147 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
4148 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
4151 wined3d_mutex_unlock();
4154 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
4155 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
4157 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4158 ID3D11BlendState
*d3d11_blend_state
;
4160 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
4161 iface
, blend_state
, blend_factor
, sample_mask
);
4163 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4164 &d3d11_blend_state
, blend_factor
, sample_mask
);
4166 if (d3d11_blend_state
)
4167 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
4169 *blend_state
= NULL
;
4172 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
4173 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
4175 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4176 ID3D11DepthStencilState
*d3d11_iface
;
4178 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
4179 iface
, depth_stencil_state
, stencil_ref
);
4181 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4182 &d3d11_iface
, stencil_ref
);
4185 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
4187 *depth_stencil_state
= NULL
;
4190 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
4191 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
4193 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4196 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
4197 iface
, buffer_count
, buffers
, offsets
);
4199 wined3d_mutex_lock();
4200 for (i
= 0; i
< buffer_count
; ++i
)
4202 struct wined3d_buffer
*wined3d_buffer
;
4203 struct d3d_buffer
*buffer_impl
;
4205 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
4211 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4212 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4213 ID3D10Buffer_AddRef(buffers
[i
]);
4215 wined3d_mutex_unlock();
4218 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
4220 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4222 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4224 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
4225 ID3D10RasterizerState_AddRef(*rasterizer_state
);
4228 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4229 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4231 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4232 struct wined3d_viewport wined3d_vp
;
4234 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4238 *viewport_count
= 1;
4242 if (!*viewport_count
)
4245 wined3d_mutex_lock();
4246 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4247 wined3d_mutex_unlock();
4249 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4250 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4251 viewports
[0].Width
= wined3d_vp
.width
;
4252 viewports
[0].Height
= wined3d_vp
.height
;
4253 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4254 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4256 if (*viewport_count
> 1)
4257 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4260 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4262 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4264 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4275 wined3d_mutex_lock();
4276 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4277 wined3d_mutex_unlock();
4278 if (*rect_count
> 1)
4279 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4282 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4284 TRACE("iface %p.\n", iface
);
4286 /* In the current implementation the device is never removed, so we can
4287 * just return S_OK here. */
4292 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4294 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4299 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4301 FIXME("iface %p stub!\n", iface
);
4306 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4307 REFGUID guid
, UINT
*data_size
, void *data
)
4309 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4311 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4313 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4316 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4317 REFGUID guid
, UINT data_size
, const void *data
)
4319 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4321 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4323 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4326 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4327 REFGUID guid
, const IUnknown
*data
)
4329 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4331 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4333 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4336 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4338 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4339 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4342 TRACE("iface %p.\n", iface
);
4344 wined3d_mutex_lock();
4345 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
4346 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4348 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
4350 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4352 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
4354 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4356 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
4358 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
4359 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4361 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
4363 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4365 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
4367 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4369 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
4371 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
4372 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4374 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
4376 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4378 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
4380 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4382 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
4384 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4386 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
4388 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
4389 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
4390 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
4391 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4393 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4395 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
4396 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
4397 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4398 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
4399 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
4400 ID3D10Device1_RSSetState(iface
, NULL
);
4401 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4403 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4405 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
4406 wined3d_mutex_unlock();
4409 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4411 FIXME("iface %p stub!\n", iface
);
4414 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4415 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4417 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4418 D3D11_BUFFER_DESC d3d11_desc
;
4419 struct d3d_buffer
*object
;
4422 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4424 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4425 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4426 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4427 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4428 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4429 d3d11_desc
.StructureByteStride
= 0;
4431 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4434 *buffer
= &object
->ID3D10Buffer_iface
;
4439 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4440 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4442 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4447 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4448 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4449 ID3D10Texture2D
**texture
)
4451 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4452 D3D11_TEXTURE2D_DESC d3d11_desc
;
4453 struct d3d_texture2d
*object
;
4456 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4458 d3d11_desc
.Width
= desc
->Width
;
4459 d3d11_desc
.Height
= desc
->Height
;
4460 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4461 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4462 d3d11_desc
.Format
= desc
->Format
;
4463 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4464 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4465 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4466 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4467 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4469 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4472 *texture
= &object
->ID3D10Texture2D_iface
;
4477 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4478 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4479 ID3D10Texture3D
**texture
)
4481 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4482 D3D11_TEXTURE3D_DESC d3d11_desc
;
4483 struct d3d_texture3d
*object
;
4486 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4488 d3d11_desc
.Width
= desc
->Width
;
4489 d3d11_desc
.Height
= desc
->Height
;
4490 d3d11_desc
.Depth
= desc
->Depth
;
4491 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4492 d3d11_desc
.Format
= desc
->Format
;
4493 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4494 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4495 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4496 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4498 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4501 *texture
= &object
->ID3D10Texture3D_iface
;
4506 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4507 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4509 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4510 struct d3d_shader_resource_view
*object
;
4511 ID3D11Resource
*d3d11_resource
;
4514 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4516 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4518 ERR("Resource does not implement ID3D11Resource.\n");
4522 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4524 ID3D11Resource_Release(d3d11_resource
);
4528 *view
= &object
->ID3D10ShaderResourceView1_iface
;
4533 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
4534 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
4536 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4538 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
4539 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
4542 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
4543 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
4545 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4546 struct d3d_rendertarget_view
*object
;
4547 ID3D11Resource
*d3d11_resource
;
4550 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4552 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4554 ERR("Resource does not implement ID3D11Resource.\n");
4558 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
4559 ID3D11Resource_Release(d3d11_resource
);
4563 *view
= &object
->ID3D10RenderTargetView_iface
;
4568 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
4569 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
4571 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4572 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
4573 struct d3d_depthstencil_view
*object
;
4574 ID3D11Resource
*d3d11_resource
;
4577 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4581 d3d11_desc
.Format
= desc
->Format
;
4582 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
4583 d3d11_desc
.Flags
= 0;
4584 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
4587 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4589 ERR("Resource does not implement ID3D11Resource.\n");
4593 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
4594 ID3D11Resource_Release(d3d11_resource
);
4598 *view
= &object
->ID3D10DepthStencilView_iface
;
4603 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
4604 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
4605 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
4606 ID3D10InputLayout
**input_layout
)
4608 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4609 struct d3d_input_layout
*object
;
4612 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4613 "shader_byte_code_length %lu, input_layout %p\n",
4614 iface
, element_descs
, element_count
, shader_byte_code
,
4615 shader_byte_code_length
, input_layout
);
4617 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
4618 shader_byte_code
, shader_byte_code_length
, &object
)))
4621 *input_layout
= &object
->ID3D10InputLayout_iface
;
4626 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
4627 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
4629 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4630 struct d3d_vertex_shader
*object
;
4633 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4634 iface
, byte_code
, byte_code_length
, shader
);
4636 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4639 *shader
= &object
->ID3D10VertexShader_iface
;
4644 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
4645 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
4647 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4648 struct d3d_geometry_shader
*object
;
4651 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4652 iface
, byte_code
, byte_code_length
, shader
);
4654 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4657 *shader
= &object
->ID3D10GeometryShader_iface
;
4662 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
4663 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
4664 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
4666 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4667 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4668 iface
, byte_code
, byte_code_length
, output_stream_decls
,
4669 output_stream_decl_count
, output_stream_stride
, shader
);
4674 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
4675 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
4677 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4678 struct d3d_pixel_shader
*object
;
4681 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4682 iface
, byte_code
, byte_code_length
, shader
);
4684 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4687 *shader
= &object
->ID3D10PixelShader_iface
;
4692 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
4693 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
4695 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4696 ID3D11BlendState
*d3d11_blend_state
;
4699 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4701 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device_iface
, (D3D11_BLEND_DESC
*)desc
,
4702 &d3d11_blend_state
)))
4705 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState1
, (void **)blend_state
);
4706 ID3D11BlendState_Release(d3d11_blend_state
);
4710 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
4711 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
4713 D3D10_BLEND_DESC1 d3d10_1_desc
;
4716 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4719 return E_INVALIDARG
;
4721 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
4722 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
4723 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
4725 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
4726 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
4727 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
4730 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4732 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
4733 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
4734 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
4735 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
4736 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
4737 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
4738 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
4739 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
4742 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
4745 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
4746 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
4748 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4749 ID3D11DepthStencilState
*d3d11_depth_stencil_state
;
4752 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
4754 if (FAILED(hr
= d3d11_device_CreateDepthStencilState(&device
->ID3D11Device_iface
,
4755 (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &d3d11_depth_stencil_state
)))
4758 hr
= ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state
, &IID_ID3D10DepthStencilState
,
4759 (void **)depth_stencil_state
);
4760 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state
);
4764 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
4765 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
4767 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4768 ID3D11RasterizerState
*d3d11_rasterizer_state
;
4771 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
4773 if (FAILED(hr
= d3d11_device_CreateRasterizerState(&device
->ID3D11Device_iface
,
4774 (const D3D11_RASTERIZER_DESC
*)desc
, &d3d11_rasterizer_state
)))
4777 hr
= ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state
,
4778 &IID_ID3D10RasterizerState
, (void **)rasterizer_state
);
4779 ID3D11RasterizerState_Release(d3d11_rasterizer_state
);
4783 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
4784 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
4786 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4787 ID3D11SamplerState
*d3d11_sampler_state
;
4790 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
4792 if (FAILED(hr
= d3d11_device_CreateSamplerState(&device
->ID3D11Device_iface
,
4793 (const D3D11_SAMPLER_DESC
*)desc
, &d3d11_sampler_state
)))
4796 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
, (void **)sampler_state
);
4797 ID3D11SamplerState_Release(d3d11_sampler_state
);
4801 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
4802 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
4804 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4805 struct d3d_query
*object
;
4808 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
4810 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
4815 *query
= &object
->ID3D10Query_iface
;
4819 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4823 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
4824 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
4826 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4827 struct d3d_query
*object
;
4830 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
4832 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
4837 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
4841 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4845 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
4846 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
4848 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
4853 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
4854 DXGI_FORMAT format
, UINT
*format_support
)
4856 FIXME("iface %p, format %s, format_support %p stub!\n",
4857 iface
, debug_dxgi_format(format
), format_support
);
4862 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
4863 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
4865 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4867 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
4868 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
4870 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
4871 sample_count
, quality_level_count
);
4874 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
4876 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
4879 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
4880 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
4881 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4883 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4884 "units %p, units_length %p, description %p, description_length %p stub!\n",
4885 iface
, desc
, type
, active_counters
, name
, name_length
,
4886 units
, units_length
, description
, description_length
);
4891 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
4893 FIXME("iface %p stub!\n", iface
);
4898 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
4899 HANDLE resource_handle
, REFIID guid
, void **resource
)
4901 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4902 iface
, resource_handle
, debugstr_guid(guid
), resource
);
4907 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
4909 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
4912 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
4914 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
4917 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
4919 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4921 TRACE("iface %p.\n", iface
);
4923 return device
->feature_level
;
4926 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
4928 /* IUnknown methods */
4929 d3d10_device_QueryInterface
,
4930 d3d10_device_AddRef
,
4931 d3d10_device_Release
,
4932 /* ID3D10Device methods */
4933 d3d10_device_VSSetConstantBuffers
,
4934 d3d10_device_PSSetShaderResources
,
4935 d3d10_device_PSSetShader
,
4936 d3d10_device_PSSetSamplers
,
4937 d3d10_device_VSSetShader
,
4938 d3d10_device_DrawIndexed
,
4940 d3d10_device_PSSetConstantBuffers
,
4941 d3d10_device_IASetInputLayout
,
4942 d3d10_device_IASetVertexBuffers
,
4943 d3d10_device_IASetIndexBuffer
,
4944 d3d10_device_DrawIndexedInstanced
,
4945 d3d10_device_DrawInstanced
,
4946 d3d10_device_GSSetConstantBuffers
,
4947 d3d10_device_GSSetShader
,
4948 d3d10_device_IASetPrimitiveTopology
,
4949 d3d10_device_VSSetShaderResources
,
4950 d3d10_device_VSSetSamplers
,
4951 d3d10_device_SetPredication
,
4952 d3d10_device_GSSetShaderResources
,
4953 d3d10_device_GSSetSamplers
,
4954 d3d10_device_OMSetRenderTargets
,
4955 d3d10_device_OMSetBlendState
,
4956 d3d10_device_OMSetDepthStencilState
,
4957 d3d10_device_SOSetTargets
,
4958 d3d10_device_DrawAuto
,
4959 d3d10_device_RSSetState
,
4960 d3d10_device_RSSetViewports
,
4961 d3d10_device_RSSetScissorRects
,
4962 d3d10_device_CopySubresourceRegion
,
4963 d3d10_device_CopyResource
,
4964 d3d10_device_UpdateSubresource
,
4965 d3d10_device_ClearRenderTargetView
,
4966 d3d10_device_ClearDepthStencilView
,
4967 d3d10_device_GenerateMips
,
4968 d3d10_device_ResolveSubresource
,
4969 d3d10_device_VSGetConstantBuffers
,
4970 d3d10_device_PSGetShaderResources
,
4971 d3d10_device_PSGetShader
,
4972 d3d10_device_PSGetSamplers
,
4973 d3d10_device_VSGetShader
,
4974 d3d10_device_PSGetConstantBuffers
,
4975 d3d10_device_IAGetInputLayout
,
4976 d3d10_device_IAGetVertexBuffers
,
4977 d3d10_device_IAGetIndexBuffer
,
4978 d3d10_device_GSGetConstantBuffers
,
4979 d3d10_device_GSGetShader
,
4980 d3d10_device_IAGetPrimitiveTopology
,
4981 d3d10_device_VSGetShaderResources
,
4982 d3d10_device_VSGetSamplers
,
4983 d3d10_device_GetPredication
,
4984 d3d10_device_GSGetShaderResources
,
4985 d3d10_device_GSGetSamplers
,
4986 d3d10_device_OMGetRenderTargets
,
4987 d3d10_device_OMGetBlendState
,
4988 d3d10_device_OMGetDepthStencilState
,
4989 d3d10_device_SOGetTargets
,
4990 d3d10_device_RSGetState
,
4991 d3d10_device_RSGetViewports
,
4992 d3d10_device_RSGetScissorRects
,
4993 d3d10_device_GetDeviceRemovedReason
,
4994 d3d10_device_SetExceptionMode
,
4995 d3d10_device_GetExceptionMode
,
4996 d3d10_device_GetPrivateData
,
4997 d3d10_device_SetPrivateData
,
4998 d3d10_device_SetPrivateDataInterface
,
4999 d3d10_device_ClearState
,
5001 d3d10_device_CreateBuffer
,
5002 d3d10_device_CreateTexture1D
,
5003 d3d10_device_CreateTexture2D
,
5004 d3d10_device_CreateTexture3D
,
5005 d3d10_device_CreateShaderResourceView
,
5006 d3d10_device_CreateRenderTargetView
,
5007 d3d10_device_CreateDepthStencilView
,
5008 d3d10_device_CreateInputLayout
,
5009 d3d10_device_CreateVertexShader
,
5010 d3d10_device_CreateGeometryShader
,
5011 d3d10_device_CreateGeometryShaderWithStreamOutput
,
5012 d3d10_device_CreatePixelShader
,
5013 d3d10_device_CreateBlendState
,
5014 d3d10_device_CreateDepthStencilState
,
5015 d3d10_device_CreateRasterizerState
,
5016 d3d10_device_CreateSamplerState
,
5017 d3d10_device_CreateQuery
,
5018 d3d10_device_CreatePredicate
,
5019 d3d10_device_CreateCounter
,
5020 d3d10_device_CheckFormatSupport
,
5021 d3d10_device_CheckMultisampleQualityLevels
,
5022 d3d10_device_CheckCounterInfo
,
5023 d3d10_device_CheckCounter
,
5024 d3d10_device_GetCreationFlags
,
5025 d3d10_device_OpenSharedResource
,
5026 d3d10_device_SetTextFilterSize
,
5027 d3d10_device_GetTextFilterSize
,
5028 d3d10_device_CreateShaderResourceView1
,
5029 d3d10_device_CreateBlendState1
,
5030 d3d10_device_GetFeatureLevel
,
5033 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
5035 /* IUnknown methods */
5036 d3d_device_inner_QueryInterface
,
5037 d3d_device_inner_AddRef
,
5038 d3d_device_inner_Release
,
5041 /* ID3D10Multithread methods */
5043 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
5045 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
5048 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
5050 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5052 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
5054 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
5057 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
5059 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5061 TRACE("iface %p.\n", iface
);
5063 return IUnknown_AddRef(device
->outer_unk
);
5066 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
5068 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5070 TRACE("iface %p.\n", iface
);
5072 return IUnknown_Release(device
->outer_unk
);
5075 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
5077 TRACE("iface %p.\n", iface
);
5079 wined3d_mutex_lock();
5082 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
5084 TRACE("iface %p.\n", iface
);
5086 wined3d_mutex_unlock();
5089 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
5091 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
5096 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
5098 FIXME("iface %p stub!\n", iface
);
5103 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
5105 d3d10_multithread_QueryInterface
,
5106 d3d10_multithread_AddRef
,
5107 d3d10_multithread_Release
,
5108 d3d10_multithread_Enter
,
5109 d3d10_multithread_Leave
,
5110 d3d10_multithread_SetMultithreadProtected
,
5111 d3d10_multithread_GetMultithreadProtected
,
5114 /* IWineDXGIDeviceParent IUnknown methods */
5116 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
5118 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
5121 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
5122 REFIID riid
, void **ppv
)
5124 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5125 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
5128 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
5130 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5131 return IUnknown_AddRef(device
->outer_unk
);
5134 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
5136 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5137 return IUnknown_Release(device
->outer_unk
);
5140 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
5141 IWineDXGIDeviceParent
*iface
)
5143 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5144 return &device
->device_parent
;
5147 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
5149 /* IUnknown methods */
5150 dxgi_device_parent_QueryInterface
,
5151 dxgi_device_parent_AddRef
,
5152 dxgi_device_parent_Release
,
5153 /* IWineDXGIDeviceParent methods */
5154 dxgi_device_parent_get_wined3d_device_parent
,
5157 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
5159 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
5162 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
5163 struct wined3d_device
*wined3d_device
)
5165 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5167 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
5169 wined3d_device_incref(wined3d_device
);
5170 device
->wined3d_device
= wined3d_device
;
5173 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
5175 TRACE("device_parent %p.\n", device_parent
);
5178 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
5180 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
5183 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
5184 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
5185 const struct wined3d_parent_ops
**parent_ops
)
5187 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
5188 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
5191 *parent_ops
= &d3d_null_wined3d_parent_ops
;
5196 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
5197 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
5198 struct wined3d_texture
**wined3d_texture
)
5200 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5201 struct d3d_texture2d
*texture
;
5202 ID3D10Texture2D
*texture_iface
;
5203 D3D10_TEXTURE2D_DESC desc
;
5206 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
5207 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
5209 FIXME("Implement DXGI<->wined3d usage conversion.\n");
5211 desc
.Width
= wined3d_desc
->width
;
5212 desc
.Height
= wined3d_desc
->height
;
5215 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
5216 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
5217 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
5218 desc
.Usage
= D3D10_USAGE_DEFAULT
;
5219 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5220 desc
.CPUAccessFlags
= 0;
5223 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
5224 &desc
, NULL
, &texture_iface
)))
5226 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
5230 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5232 *wined3d_texture
= texture
->wined3d_texture
;
5233 wined3d_texture_incref(*wined3d_texture
);
5234 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5239 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5240 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5242 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5243 IWineDXGIDevice
*wine_device
;
5246 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5248 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5249 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5251 ERR("Device should implement IWineDXGIDevice.\n");
5255 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, TRUE
, swapchain
);
5256 IWineDXGIDevice_Release(wine_device
);
5259 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5266 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5268 device_parent_wined3d_device_created
,
5269 device_parent_mode_changed
,
5270 device_parent_activate
,
5271 device_parent_sub_resource_created
,
5272 device_parent_sub_resource_created
,
5273 device_parent_create_swapchain_texture
,
5274 device_parent_create_swapchain
,
5277 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5279 const D3D11_SAMPLER_DESC
*ka
= key
;
5280 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5282 return memcmp(ka
, kb
, sizeof(*ka
));
5285 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5287 const D3D11_BLEND_DESC
*ka
= key
;
5288 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5290 return memcmp(ka
, kb
, sizeof(*ka
));
5293 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5295 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5296 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5297 const struct d3d_depthstencil_state
, entry
)->desc
;
5299 return memcmp(ka
, kb
, sizeof(*ka
));
5302 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5304 const D3D11_RASTERIZER_DESC
*ka
= key
;
5305 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5307 return memcmp(ka
, kb
, sizeof(*ka
));
5310 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5312 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5313 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5314 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5315 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5316 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5317 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5318 device
->refcount
= 1;
5319 /* COM aggregation always takes place */
5320 device
->outer_unk
= outer_unknown
;
5322 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5323 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5325 device
->blend_factor
[0] = 1.0f
;
5326 device
->blend_factor
[1] = 1.0f
;
5327 device
->blend_factor
[2] = 1.0f
;
5328 device
->blend_factor
[3] = 1.0f
;
5330 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
5331 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
5332 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
5333 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);