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 if (!data
&& data_size
)
533 wined3d_flags
= wined3d_getdata_flags_from_d3d11_async_getdata_flags(data_flags
);
535 wined3d_mutex_lock();
536 if (!data_size
|| wined3d_query_get_data_size(query
->wined3d_query
) == data_size
)
538 hr
= wined3d_query_get_data(query
->wined3d_query
, data
, data_size
, wined3d_flags
);
542 WARN("Invalid data size %u.\n", data_size
);
545 wined3d_mutex_unlock();
550 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext
*iface
,
551 ID3D11Predicate
*predicate
, BOOL value
)
553 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
554 struct d3d_query
*query
;
556 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
558 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
560 wined3d_mutex_lock();
561 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
562 wined3d_mutex_unlock();
565 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext
*iface
,
566 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
568 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
571 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
573 wined3d_mutex_lock();
574 for (i
= 0; i
< view_count
; ++i
)
576 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
578 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
579 view
? view
->wined3d_view
: NULL
);
581 wined3d_mutex_unlock();
584 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext
*iface
,
585 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
587 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
590 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
591 iface
, start_slot
, sampler_count
, samplers
);
593 wined3d_mutex_lock();
594 for (i
= 0; i
< sampler_count
; ++i
)
596 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
598 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
599 sampler
? sampler
->wined3d_sampler
: NULL
);
601 wined3d_mutex_unlock();
604 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext
*iface
,
605 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
606 ID3D11DepthStencilView
*depth_stencil_view
)
608 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
609 struct d3d_depthstencil_view
*dsv
;
612 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
613 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
615 wined3d_mutex_lock();
616 for (i
= 0; i
< render_target_view_count
; ++i
)
618 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
619 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
621 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
623 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
626 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
627 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
628 wined3d_mutex_unlock();
631 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
632 ID3D11DeviceContext
*iface
, UINT render_target_view_count
,
633 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
634 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
635 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
637 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
640 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
641 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
642 "initial_counts %p.\n",
643 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
644 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
647 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
649 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
653 if (unordered_access_view_count
!= D3D11_KEEP_UNORDERED_ACCESS_VIEWS
)
656 FIXME("Ignoring initial counts.\n");
658 wined3d_mutex_lock();
659 for (i
= 0; i
< unordered_access_view_start_slot
; ++i
)
661 wined3d_device_set_unordered_access_view(device
->wined3d_device
, i
, NULL
);
663 for (i
= 0; i
< unordered_access_view_count
; ++i
)
665 struct d3d11_unordered_access_view
*view
666 = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views
[i
]);
668 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
669 unordered_access_view_start_slot
+ i
,
670 view
? view
->wined3d_view
: NULL
);
672 for (; unordered_access_view_start_slot
+ i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
674 wined3d_device_set_unordered_access_view(device
->wined3d_device
,
675 unordered_access_view_start_slot
+ i
, NULL
);
677 wined3d_mutex_unlock();
681 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
682 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
684 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
685 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
686 const D3D11_BLEND_DESC
*desc
;
688 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
689 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
692 blend_factor
= default_blend_factor
;
694 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
695 FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor
));
697 wined3d_mutex_lock();
698 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
699 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
700 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
702 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
703 wined3d_device_set_render_state(device
->wined3d_device
,
704 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
705 wined3d_device_set_render_state(device
->wined3d_device
,
706 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
707 wined3d_device_set_render_state(device
->wined3d_device
,
708 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
709 wined3d_device_set_render_state(device
->wined3d_device
,
710 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
711 wined3d_mutex_unlock();
715 desc
= &device
->blend_state
->desc
;
716 /* glSampleCoverage() */
717 if (desc
->AlphaToCoverageEnable
)
718 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
719 /* glEnableIndexedEXT(GL_BLEND, ...) */
720 FIXME("Per-rendertarget blend not implemented.\n");
721 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
722 desc
->RenderTarget
[0].BlendEnable
);
723 if (desc
->RenderTarget
[0].BlendEnable
)
725 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
,
726 desc
->RenderTarget
[0].SrcBlend
);
727 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
,
728 desc
->RenderTarget
[0].DestBlend
);
729 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
,
730 desc
->RenderTarget
[0].BlendOp
);
731 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
732 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
,
733 desc
->RenderTarget
[0].SrcBlendAlpha
);
734 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
,
735 desc
->RenderTarget
[0].DestBlendAlpha
);
736 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
,
737 desc
->RenderTarget
[0].BlendOpAlpha
);
739 FIXME("Color mask > 3 not implemented.\n");
740 wined3d_device_set_render_state(device
->wined3d_device
,
741 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
742 wined3d_device_set_render_state(device
->wined3d_device
,
743 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
744 wined3d_device_set_render_state(device
->wined3d_device
,
745 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
746 wined3d_device_set_render_state(device
->wined3d_device
,
747 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
748 wined3d_mutex_unlock();
751 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
752 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
754 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
755 const D3D11_DEPTH_STENCILOP_DESC
*front
, *back
;
756 const D3D11_DEPTH_STENCIL_DESC
*desc
;
758 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
759 iface
, depth_stencil_state
, stencil_ref
);
761 wined3d_mutex_lock();
762 device
->stencil_ref
= stencil_ref
;
763 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
765 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
766 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
767 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, D3D11_COMPARISON_LESS
);
768 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
769 wined3d_mutex_unlock();
773 desc
= &device
->depth_stencil_state
->desc
;
775 front
= &desc
->FrontFace
;
776 back
= &desc
->BackFace
;
778 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
779 if (desc
->DepthEnable
)
781 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
782 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
785 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
786 if (desc
->StencilEnable
)
788 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
789 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
790 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
792 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, front
->StencilFailOp
);
793 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
, front
->StencilDepthFailOp
);
794 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, front
->StencilPassOp
);
795 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, front
->StencilFunc
);
796 if (front
->StencilFailOp
!= back
->StencilFailOp
797 || front
->StencilDepthFailOp
!= back
->StencilDepthFailOp
798 || front
->StencilPassOp
!= back
->StencilPassOp
799 || front
->StencilFunc
!= back
->StencilFunc
)
801 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_TWOSIDEDSTENCILMODE
, TRUE
);
802 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILFAIL
, back
->StencilFailOp
);
803 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILZFAIL
,
804 back
->StencilDepthFailOp
);
805 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILPASS
, back
->StencilPassOp
);
806 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BACK_STENCILFUNC
, back
->StencilFunc
);
810 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_TWOSIDEDSTENCILMODE
, FALSE
);
813 wined3d_mutex_unlock();
816 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
817 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
819 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
820 unsigned int count
, i
;
822 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
824 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
825 wined3d_mutex_lock();
826 for (i
= 0; i
< count
; ++i
)
828 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
830 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
831 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
833 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
835 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
837 wined3d_mutex_unlock();
840 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
842 FIXME("iface %p stub!\n", iface
);
845 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext
*iface
,
846 ID3D11Buffer
*buffer
, UINT offset
)
848 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
851 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
852 ID3D11Buffer
*buffer
, UINT offset
)
854 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
857 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
858 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
860 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
861 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
864 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
865 ID3D11Buffer
*buffer
, UINT offset
)
867 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
870 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
871 ID3D11RasterizerState
*rasterizer_state
)
873 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
874 const D3D11_RASTERIZER_DESC
*desc
;
876 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
878 wined3d_mutex_lock();
879 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
881 wined3d_device_set_rasterizer_state(device
->wined3d_device
, NULL
);
882 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
883 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_BACK
);
884 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
885 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
886 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
887 wined3d_mutex_unlock();
891 wined3d_device_set_rasterizer_state(device
->wined3d_device
, device
->rasterizer_state
->wined3d_state
);
893 desc
= &device
->rasterizer_state
->desc
;
894 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
895 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
896 /* OpenGL style depth bias. */
897 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
898 FIXME("Ignoring depth bias.\n");
900 if (!desc
->DepthClipEnable
)
901 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
902 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
903 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
904 wined3d_device_set_render_state(device
->wined3d_device
,
905 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
906 wined3d_mutex_unlock();
909 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
910 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
912 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
913 struct wined3d_viewport wined3d_vp
;
915 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
917 if (viewport_count
> 1)
918 FIXME("Multiple viewports not implemented.\n");
923 if (viewports
[0].TopLeftX
!= (UINT
)viewports
[0].TopLeftX
924 || viewports
[0].TopLeftY
!= (UINT
)viewports
[0].TopLeftY
925 || viewports
[0].Width
!= (UINT
)viewports
[0].Width
926 || viewports
[0].Height
!= (UINT
)viewports
[0].Height
)
927 FIXME("Floating-point viewports not implemented.\n");
929 wined3d_vp
.x
= viewports
[0].TopLeftX
;
930 wined3d_vp
.y
= viewports
[0].TopLeftY
;
931 wined3d_vp
.width
= viewports
[0].Width
;
932 wined3d_vp
.height
= viewports
[0].Height
;
933 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
934 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
936 wined3d_mutex_lock();
937 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
938 wined3d_mutex_unlock();
941 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
942 UINT rect_count
, const D3D11_RECT
*rects
)
944 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
946 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
949 FIXME("Multiple scissor rects not implemented.\n");
954 wined3d_mutex_lock();
955 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
956 wined3d_mutex_unlock();
959 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
960 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
961 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
963 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
964 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
965 struct wined3d_box wined3d_src_box
;
967 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
968 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
969 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
970 src_resource
, src_subresource_idx
, src_box
);
974 wined3d_src_box
.left
= src_box
->left
;
975 wined3d_src_box
.top
= src_box
->top
;
976 wined3d_src_box
.front
= src_box
->front
;
977 wined3d_src_box
.right
= src_box
->right
;
978 wined3d_src_box
.bottom
= src_box
->bottom
;
979 wined3d_src_box
.back
= src_box
->back
;
982 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
983 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
984 wined3d_mutex_lock();
985 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
986 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
987 wined3d_mutex_unlock();
990 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
991 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
993 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
994 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
996 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
998 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
999 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
1000 wined3d_mutex_lock();
1001 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1002 wined3d_mutex_unlock();
1005 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
1006 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
1007 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1009 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1010 struct wined3d_resource
*wined3d_resource
;
1011 struct wined3d_box wined3d_box
;
1013 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1014 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1018 wined3d_box
.left
= box
->left
;
1019 wined3d_box
.top
= box
->top
;
1020 wined3d_box
.front
= box
->front
;
1021 wined3d_box
.right
= box
->right
;
1022 wined3d_box
.bottom
= box
->bottom
;
1023 wined3d_box
.back
= box
->back
;
1026 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
1027 wined3d_mutex_lock();
1028 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1029 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
1030 wined3d_mutex_unlock();
1033 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
1034 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
1036 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
1037 iface
, dst_buffer
, dst_offset
, src_view
);
1040 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
1041 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
1043 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1044 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
1045 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1048 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
1049 iface
, render_target_view
, debug_float4(color_rgba
));
1054 wined3d_mutex_lock();
1055 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1056 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
1057 ERR("Failed to clear view, hr %#x.\n", hr
);
1058 wined3d_mutex_unlock();
1061 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
1062 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
1064 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
1065 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
1068 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
1069 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
1071 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
1072 iface
, unordered_access_view
, debug_float4(values
));
1075 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
1076 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1078 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1079 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1080 DWORD wined3d_flags
;
1083 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1084 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1089 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1091 wined3d_mutex_lock();
1092 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1093 wined3d_flags
, NULL
, depth
, stencil
)))
1094 ERR("Failed to clear view, hr %#x.\n", hr
);
1095 wined3d_mutex_unlock();
1098 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1099 ID3D11ShaderResourceView
*view
)
1101 FIXME("iface %p, view %p stub!\n", iface
, view
);
1104 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1105 ID3D11Resource
*resource
, FLOAT min_lod
)
1107 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1110 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1111 ID3D11Resource
*resource
)
1113 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1118 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1119 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1120 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1123 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1124 "format %s stub!\n",
1125 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1126 debug_dxgi_format(format
));
1129 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1130 ID3D11CommandList
*command_list
, BOOL restore_state
)
1132 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1135 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1136 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1138 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1139 iface
, start_slot
, view_count
, views
);
1142 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1143 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1145 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1146 iface
, shader
, class_instances
, class_instance_count
);
1149 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1150 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1152 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1153 iface
, start_slot
, sampler_count
, samplers
);
1156 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1157 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1159 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1160 iface
, start_slot
, buffer_count
, buffers
);
1163 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1164 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1166 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1167 iface
, start_slot
, view_count
, views
);
1170 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1171 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1173 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1174 iface
, shader
, class_instances
, class_instance_count
);
1177 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1178 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1180 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1181 iface
, start_slot
, sampler_count
, samplers
);
1184 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1185 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1187 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1188 iface
, start_slot
, buffer_count
, buffers
);
1191 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1192 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1194 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1195 iface
, start_slot
, view_count
, views
);
1198 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1199 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1201 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1202 iface
, start_slot
, view_count
, views
, initial_counts
);
1205 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1206 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1208 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1209 struct d3d11_compute_shader
*cs
= unsafe_impl_from_ID3D11ComputeShader(shader
);
1211 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
1212 iface
, shader
, class_instances
, class_instance_count
);
1214 if (class_instances
)
1215 FIXME("Dynamic linking is not implemented yet.\n");
1217 wined3d_mutex_lock();
1218 wined3d_device_set_compute_shader(device
->wined3d_device
, cs
? cs
->wined3d_shader
: NULL
);
1219 wined3d_mutex_unlock();
1222 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1223 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1225 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1226 iface
, start_slot
, sampler_count
, samplers
);
1229 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1230 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1232 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1233 iface
, start_slot
, buffer_count
, buffers
);
1236 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1237 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1239 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1242 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1243 iface
, start_slot
, buffer_count
, buffers
);
1245 wined3d_mutex_lock();
1246 for (i
= 0; i
< buffer_count
; ++i
)
1248 struct wined3d_buffer
*wined3d_buffer
;
1249 struct d3d_buffer
*buffer_impl
;
1251 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1257 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1258 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1259 ID3D11Buffer_AddRef(buffers
[i
]);
1261 wined3d_mutex_unlock();
1264 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1265 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1267 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1270 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1271 iface
, start_slot
, view_count
, views
);
1273 wined3d_mutex_lock();
1274 for (i
= 0; i
< view_count
; ++i
)
1276 struct wined3d_shader_resource_view
*wined3d_view
;
1277 struct d3d_shader_resource_view
*view_impl
;
1279 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1285 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1286 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1287 ID3D11ShaderResourceView_AddRef(views
[i
]);
1289 wined3d_mutex_unlock();
1292 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1293 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1295 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1296 struct wined3d_shader
*wined3d_shader
;
1297 struct d3d_pixel_shader
*shader_impl
;
1299 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1300 iface
, shader
, class_instances
, class_instance_count
);
1302 if (class_instances
|| class_instance_count
)
1303 FIXME("Dynamic linking not implemented yet.\n");
1305 wined3d_mutex_lock();
1306 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1308 wined3d_mutex_unlock();
1313 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1314 wined3d_mutex_unlock();
1315 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1316 ID3D11PixelShader_AddRef(*shader
);
1319 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1320 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1322 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1325 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1326 iface
, start_slot
, sampler_count
, samplers
);
1328 wined3d_mutex_lock();
1329 for (i
= 0; i
< sampler_count
; ++i
)
1331 struct wined3d_sampler
*wined3d_sampler
;
1332 struct d3d_sampler_state
*sampler_impl
;
1334 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1340 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1341 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1342 ID3D11SamplerState_AddRef(samplers
[i
]);
1344 wined3d_mutex_unlock();
1347 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1348 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1350 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1351 struct d3d_vertex_shader
*shader_impl
;
1352 struct wined3d_shader
*wined3d_shader
;
1354 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1355 iface
, shader
, class_instances
, class_instance_count
);
1357 if (class_instances
|| class_instance_count
)
1358 FIXME("Dynamic linking not implemented yet.\n");
1360 wined3d_mutex_lock();
1361 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1363 wined3d_mutex_unlock();
1368 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1369 wined3d_mutex_unlock();
1370 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1371 ID3D11VertexShader_AddRef(*shader
);
1374 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1375 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1377 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1380 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1381 iface
, start_slot
, buffer_count
, buffers
);
1383 wined3d_mutex_lock();
1384 for (i
= 0; i
< buffer_count
; ++i
)
1386 struct wined3d_buffer
*wined3d_buffer
;
1387 struct d3d_buffer
*buffer_impl
;
1389 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1395 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1396 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1397 ID3D11Buffer_AddRef(buffers
[i
]);
1399 wined3d_mutex_unlock();
1402 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1403 ID3D11InputLayout
**input_layout
)
1405 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1406 struct wined3d_vertex_declaration
*wined3d_declaration
;
1407 struct d3d_input_layout
*input_layout_impl
;
1409 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1411 wined3d_mutex_lock();
1412 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1414 wined3d_mutex_unlock();
1415 *input_layout
= NULL
;
1419 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1420 wined3d_mutex_unlock();
1421 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1422 ID3D11InputLayout_AddRef(*input_layout
);
1425 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1426 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1428 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1431 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1432 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1434 wined3d_mutex_lock();
1435 for (i
= 0; i
< buffer_count
; ++i
)
1437 struct wined3d_buffer
*wined3d_buffer
;
1438 struct d3d_buffer
*buffer_impl
;
1440 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1441 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1442 ERR("Failed to get vertex buffer %u.\n", start_slot
+ i
);
1444 if (!wined3d_buffer
)
1450 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1451 ID3D11Buffer_AddRef(buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
);
1453 wined3d_mutex_unlock();
1456 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1457 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1459 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1460 enum wined3d_format_id wined3d_format
;
1461 struct wined3d_buffer
*wined3d_buffer
;
1462 struct d3d_buffer
*buffer_impl
;
1464 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1466 wined3d_mutex_lock();
1467 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
1468 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1469 if (!wined3d_buffer
)
1471 wined3d_mutex_unlock();
1476 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1477 wined3d_mutex_unlock();
1478 ID3D11Buffer_AddRef(*buffer
= &buffer_impl
->ID3D11Buffer_iface
);
1481 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1482 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1484 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1487 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1488 iface
, start_slot
, buffer_count
, buffers
);
1490 wined3d_mutex_lock();
1491 for (i
= 0; i
< buffer_count
; ++i
)
1493 struct wined3d_buffer
*wined3d_buffer
;
1494 struct d3d_buffer
*buffer_impl
;
1496 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1502 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1503 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1504 ID3D11Buffer_AddRef(buffers
[i
]);
1506 wined3d_mutex_unlock();
1509 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1510 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1512 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1513 struct d3d_geometry_shader
*shader_impl
;
1514 struct wined3d_shader
*wined3d_shader
;
1516 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1517 iface
, shader
, class_instances
, class_instance_count
);
1519 if (class_instances
|| class_instance_count
)
1520 FIXME("Dynamic linking not implemented yet.\n");
1522 wined3d_mutex_lock();
1523 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1525 wined3d_mutex_unlock();
1530 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1531 wined3d_mutex_unlock();
1532 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1533 ID3D11GeometryShader_AddRef(*shader
);
1536 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1537 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1539 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1541 TRACE("iface %p, topology %p.\n", iface
, topology
);
1543 wined3d_mutex_lock();
1544 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1545 wined3d_mutex_unlock();
1548 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1549 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1551 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1554 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1556 wined3d_mutex_lock();
1557 for (i
= 0; i
< view_count
; ++i
)
1559 struct wined3d_shader_resource_view
*wined3d_view
;
1560 struct d3d_shader_resource_view
*view_impl
;
1562 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1568 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1569 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1570 ID3D11ShaderResourceView_AddRef(views
[i
]);
1572 wined3d_mutex_unlock();
1575 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1576 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1578 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1581 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1582 iface
, start_slot
, sampler_count
, samplers
);
1584 wined3d_mutex_lock();
1585 for (i
= 0; i
< sampler_count
; ++i
)
1587 struct wined3d_sampler
*wined3d_sampler
;
1588 struct d3d_sampler_state
*sampler_impl
;
1590 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1596 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1597 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1598 ID3D11SamplerState_AddRef(samplers
[i
]);
1600 wined3d_mutex_unlock();
1603 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1604 ID3D11Predicate
**predicate
, BOOL
*value
)
1606 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1607 struct wined3d_query
*wined3d_predicate
;
1608 struct d3d_query
*predicate_impl
;
1610 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1612 wined3d_mutex_lock();
1613 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1615 wined3d_mutex_unlock();
1620 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1621 wined3d_mutex_unlock();
1622 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1623 ID3D11Predicate_AddRef(*predicate
);
1626 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1627 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1629 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1632 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1634 wined3d_mutex_lock();
1635 for (i
= 0; i
< view_count
; ++i
)
1637 struct wined3d_shader_resource_view
*wined3d_view
;
1638 struct d3d_shader_resource_view
*view_impl
;
1640 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1646 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1647 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1648 ID3D11ShaderResourceView_AddRef(views
[i
]);
1650 wined3d_mutex_unlock();
1653 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1654 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1656 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1659 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1660 iface
, start_slot
, sampler_count
, samplers
);
1662 wined3d_mutex_lock();
1663 for (i
= 0; i
< sampler_count
; ++i
)
1665 struct d3d_sampler_state
*sampler_impl
;
1666 struct wined3d_sampler
*wined3d_sampler
;
1668 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1674 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1675 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1676 ID3D11SamplerState_AddRef(samplers
[i
]);
1678 wined3d_mutex_unlock();
1681 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1682 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1683 ID3D11DepthStencilView
**depth_stencil_view
)
1685 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1686 struct wined3d_rendertarget_view
*wined3d_view
;
1688 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1689 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1691 wined3d_mutex_lock();
1692 if (render_target_views
)
1694 struct d3d_rendertarget_view
*view_impl
;
1697 for (i
= 0; i
< render_target_view_count
; ++i
)
1699 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1700 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1702 render_target_views
[i
] = NULL
;
1706 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1707 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1711 if (depth_stencil_view
)
1713 struct d3d_depthstencil_view
*view_impl
;
1715 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1716 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1718 *depth_stencil_view
= NULL
;
1722 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1723 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1726 wined3d_mutex_unlock();
1729 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1730 ID3D11DeviceContext
*iface
,
1731 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1732 ID3D11DepthStencilView
**depth_stencil_view
,
1733 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1734 ID3D11UnorderedAccessView
**unordered_access_views
)
1736 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1737 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1738 "unordered_access_views %p stub!\n",
1739 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1740 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1743 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1744 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1746 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1748 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1749 iface
, blend_state
, blend_factor
, sample_mask
);
1751 if ((*blend_state
= device
->blend_state
? &device
->blend_state
->ID3D11BlendState_iface
: NULL
))
1752 ID3D11BlendState_AddRef(*blend_state
);
1753 wined3d_mutex_lock();
1754 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
1755 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1756 wined3d_mutex_unlock();
1759 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1760 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1762 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1764 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1765 iface
, depth_stencil_state
, stencil_ref
);
1767 if ((*depth_stencil_state
= device
->depth_stencil_state
1768 ? &device
->depth_stencil_state
->ID3D11DepthStencilState_iface
: NULL
))
1769 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
1770 *stencil_ref
= device
->stencil_ref
;
1773 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1774 UINT buffer_count
, ID3D11Buffer
**buffers
)
1776 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1779 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1781 wined3d_mutex_lock();
1782 for (i
= 0; i
< buffer_count
; ++i
)
1784 struct wined3d_buffer
*wined3d_buffer
;
1785 struct d3d_buffer
*buffer_impl
;
1787 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1793 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1794 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1795 ID3D11Buffer_AddRef(buffers
[i
]);
1797 wined3d_mutex_unlock();
1800 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
1801 ID3D11RasterizerState
**rasterizer_state
)
1803 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1805 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1807 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D11RasterizerState_iface
: NULL
))
1808 ID3D11RasterizerState_AddRef(*rasterizer_state
);
1811 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
1812 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1814 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1815 struct wined3d_viewport wined3d_vp
;
1817 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1821 *viewport_count
= 1;
1825 if (!*viewport_count
)
1828 wined3d_mutex_lock();
1829 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1830 wined3d_mutex_unlock();
1832 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1833 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1834 viewports
[0].Width
= wined3d_vp
.width
;
1835 viewports
[0].Height
= wined3d_vp
.height
;
1836 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1837 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1839 if (*viewport_count
> 1)
1840 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1843 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
1844 UINT
*rect_count
, D3D11_RECT
*rects
)
1846 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1848 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
1859 wined3d_mutex_lock();
1860 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
1861 wined3d_mutex_unlock();
1862 if (*rect_count
> 1)
1863 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
1866 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
1867 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1869 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1872 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
1873 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1875 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1876 iface
, shader
, class_instances
, class_instance_count
);
1879 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
1880 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1882 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1883 iface
, start_slot
, sampler_count
, samplers
);
1886 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1887 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1889 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1890 iface
, start_slot
, buffer_count
, buffers
);
1893 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
1894 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1896 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1897 iface
, start_slot
, view_count
, views
);
1900 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
1901 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1903 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1904 iface
, shader
, class_instances
, class_instance_count
);
1907 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
1908 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1910 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1911 iface
, start_slot
, sampler_count
, samplers
);
1914 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1915 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1917 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1918 iface
, start_slot
, buffer_count
, buffers
);
1921 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
1922 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1924 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1927 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1928 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
1930 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1933 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
1934 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1936 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1937 iface
, shader
, class_instances
, class_instance_count
);
1940 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
1941 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1943 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1944 iface
, start_slot
, sampler_count
, samplers
);
1947 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1948 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1950 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1951 iface
, start_slot
, buffer_count
, buffers
);
1954 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
1956 FIXME("iface %p stub!\n", iface
);
1959 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
1961 FIXME("iface %p stub!\n", iface
);
1964 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
1966 TRACE("iface %p.\n", iface
);
1968 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
1971 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
1973 FIXME("iface %p stub!\n", iface
);
1978 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
1979 BOOL restore
, ID3D11CommandList
**command_list
)
1981 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
1986 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
1988 /* IUnknown methods */
1989 d3d11_immediate_context_QueryInterface
,
1990 d3d11_immediate_context_AddRef
,
1991 d3d11_immediate_context_Release
,
1992 /* ID3D11DeviceChild methods */
1993 d3d11_immediate_context_GetDevice
,
1994 d3d11_immediate_context_GetPrivateData
,
1995 d3d11_immediate_context_SetPrivateData
,
1996 d3d11_immediate_context_SetPrivateDataInterface
,
1997 /* ID3D11DeviceContext methods */
1998 d3d11_immediate_context_VSSetConstantBuffers
,
1999 d3d11_immediate_context_PSSetShaderResources
,
2000 d3d11_immediate_context_PSSetShader
,
2001 d3d11_immediate_context_PSSetSamplers
,
2002 d3d11_immediate_context_VSSetShader
,
2003 d3d11_immediate_context_DrawIndexed
,
2004 d3d11_immediate_context_Draw
,
2005 d3d11_immediate_context_Map
,
2006 d3d11_immediate_context_Unmap
,
2007 d3d11_immediate_context_PSSetConstantBuffers
,
2008 d3d11_immediate_context_IASetInputLayout
,
2009 d3d11_immediate_context_IASetVertexBuffers
,
2010 d3d11_immediate_context_IASetIndexBuffer
,
2011 d3d11_immediate_context_DrawIndexedInstanced
,
2012 d3d11_immediate_context_DrawInstanced
,
2013 d3d11_immediate_context_GSSetConstantBuffers
,
2014 d3d11_immediate_context_GSSetShader
,
2015 d3d11_immediate_context_IASetPrimitiveTopology
,
2016 d3d11_immediate_context_VSSetShaderResources
,
2017 d3d11_immediate_context_VSSetSamplers
,
2018 d3d11_immediate_context_Begin
,
2019 d3d11_immediate_context_End
,
2020 d3d11_immediate_context_GetData
,
2021 d3d11_immediate_context_SetPredication
,
2022 d3d11_immediate_context_GSSetShaderResources
,
2023 d3d11_immediate_context_GSSetSamplers
,
2024 d3d11_immediate_context_OMSetRenderTargets
,
2025 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
2026 d3d11_immediate_context_OMSetBlendState
,
2027 d3d11_immediate_context_OMSetDepthStencilState
,
2028 d3d11_immediate_context_SOSetTargets
,
2029 d3d11_immediate_context_DrawAuto
,
2030 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
2031 d3d11_immediate_context_DrawInstancedIndirect
,
2032 d3d11_immediate_context_Dispatch
,
2033 d3d11_immediate_context_DispatchIndirect
,
2034 d3d11_immediate_context_RSSetState
,
2035 d3d11_immediate_context_RSSetViewports
,
2036 d3d11_immediate_context_RSSetScissorRects
,
2037 d3d11_immediate_context_CopySubresourceRegion
,
2038 d3d11_immediate_context_CopyResource
,
2039 d3d11_immediate_context_UpdateSubresource
,
2040 d3d11_immediate_context_CopyStructureCount
,
2041 d3d11_immediate_context_ClearRenderTargetView
,
2042 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
2043 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
2044 d3d11_immediate_context_ClearDepthStencilView
,
2045 d3d11_immediate_context_GenerateMips
,
2046 d3d11_immediate_context_SetResourceMinLOD
,
2047 d3d11_immediate_context_GetResourceMinLOD
,
2048 d3d11_immediate_context_ResolveSubresource
,
2049 d3d11_immediate_context_ExecuteCommandList
,
2050 d3d11_immediate_context_HSSetShaderResources
,
2051 d3d11_immediate_context_HSSetShader
,
2052 d3d11_immediate_context_HSSetSamplers
,
2053 d3d11_immediate_context_HSSetConstantBuffers
,
2054 d3d11_immediate_context_DSSetShaderResources
,
2055 d3d11_immediate_context_DSSetShader
,
2056 d3d11_immediate_context_DSSetSamplers
,
2057 d3d11_immediate_context_DSSetConstantBuffers
,
2058 d3d11_immediate_context_CSSetShaderResources
,
2059 d3d11_immediate_context_CSSetUnorderedAccessViews
,
2060 d3d11_immediate_context_CSSetShader
,
2061 d3d11_immediate_context_CSSetSamplers
,
2062 d3d11_immediate_context_CSSetConstantBuffers
,
2063 d3d11_immediate_context_VSGetConstantBuffers
,
2064 d3d11_immediate_context_PSGetShaderResources
,
2065 d3d11_immediate_context_PSGetShader
,
2066 d3d11_immediate_context_PSGetSamplers
,
2067 d3d11_immediate_context_VSGetShader
,
2068 d3d11_immediate_context_PSGetConstantBuffers
,
2069 d3d11_immediate_context_IAGetInputLayout
,
2070 d3d11_immediate_context_IAGetVertexBuffers
,
2071 d3d11_immediate_context_IAGetIndexBuffer
,
2072 d3d11_immediate_context_GSGetConstantBuffers
,
2073 d3d11_immediate_context_GSGetShader
,
2074 d3d11_immediate_context_IAGetPrimitiveTopology
,
2075 d3d11_immediate_context_VSGetShaderResources
,
2076 d3d11_immediate_context_VSGetSamplers
,
2077 d3d11_immediate_context_GetPredication
,
2078 d3d11_immediate_context_GSGetShaderResources
,
2079 d3d11_immediate_context_GSGetSamplers
,
2080 d3d11_immediate_context_OMGetRenderTargets
,
2081 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
2082 d3d11_immediate_context_OMGetBlendState
,
2083 d3d11_immediate_context_OMGetDepthStencilState
,
2084 d3d11_immediate_context_SOGetTargets
,
2085 d3d11_immediate_context_RSGetState
,
2086 d3d11_immediate_context_RSGetViewports
,
2087 d3d11_immediate_context_RSGetScissorRects
,
2088 d3d11_immediate_context_HSGetShaderResources
,
2089 d3d11_immediate_context_HSGetShader
,
2090 d3d11_immediate_context_HSGetSamplers
,
2091 d3d11_immediate_context_HSGetConstantBuffers
,
2092 d3d11_immediate_context_DSGetShaderResources
,
2093 d3d11_immediate_context_DSGetShader
,
2094 d3d11_immediate_context_DSGetSamplers
,
2095 d3d11_immediate_context_DSGetConstantBuffers
,
2096 d3d11_immediate_context_CSGetShaderResources
,
2097 d3d11_immediate_context_CSGetUnorderedAccessViews
,
2098 d3d11_immediate_context_CSGetShader
,
2099 d3d11_immediate_context_CSGetSamplers
,
2100 d3d11_immediate_context_CSGetConstantBuffers
,
2101 d3d11_immediate_context_ClearState
,
2102 d3d11_immediate_context_Flush
,
2103 d3d11_immediate_context_GetType
,
2104 d3d11_immediate_context_GetContextFlags
,
2105 d3d11_immediate_context_FinishCommandList
,
2108 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
2110 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
2111 context
->refcount
= 1;
2113 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
2115 wined3d_private_store_init(&context
->private_store
);
2118 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
2120 wined3d_private_store_cleanup(&context
->private_store
);
2123 /* ID3D11Device methods */
2125 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
2127 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2128 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
2131 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
2133 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2134 return IUnknown_AddRef(device
->outer_unk
);
2137 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
2139 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2140 return IUnknown_Release(device
->outer_unk
);
2143 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
2144 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
2146 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2147 struct d3d_buffer
*object
;
2150 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2152 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
2155 *buffer
= &object
->ID3D11Buffer_iface
;
2160 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
2161 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
2163 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2168 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
2169 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2171 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2172 struct d3d_texture2d
*object
;
2175 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2177 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2180 *texture
= &object
->ID3D11Texture2D_iface
;
2185 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2186 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2188 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2189 struct d3d_texture3d
*object
;
2192 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2194 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2197 *texture
= &object
->ID3D11Texture3D_iface
;
2202 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2203 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2205 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2206 struct d3d_shader_resource_view
*object
;
2209 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2212 return E_INVALIDARG
;
2214 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2217 *view
= &object
->ID3D11ShaderResourceView_iface
;
2222 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2223 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2225 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2226 struct d3d11_unordered_access_view
*object
;
2229 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2231 if (FAILED(hr
= d3d11_unordered_access_view_create(device
, resource
, desc
, &object
)))
2234 *view
= &object
->ID3D11UnorderedAccessView_iface
;
2239 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2240 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2242 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2243 struct d3d_rendertarget_view
*object
;
2246 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2249 return E_INVALIDARG
;
2251 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2254 *view
= &object
->ID3D11RenderTargetView_iface
;
2259 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2260 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2262 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2263 struct d3d_depthstencil_view
*object
;
2266 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2268 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2271 *view
= &object
->ID3D11DepthStencilView_iface
;
2276 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2277 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2278 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2280 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2281 struct d3d_input_layout
*object
;
2284 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2285 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2286 shader_byte_code_length
, input_layout
);
2288 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2289 shader_byte_code
, shader_byte_code_length
, &object
)))
2292 *input_layout
= &object
->ID3D11InputLayout_iface
;
2297 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2298 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2300 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2301 struct d3d_vertex_shader
*object
;
2304 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2305 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2308 FIXME("Class linkage is not implemented yet.\n");
2310 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2313 *shader
= &object
->ID3D11VertexShader_iface
;
2318 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2319 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2321 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2322 struct d3d_geometry_shader
*object
;
2325 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2326 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2329 FIXME("Class linkage is not implemented yet.\n");
2331 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2334 *shader
= &object
->ID3D11GeometryShader_iface
;
2339 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2340 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2341 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
2342 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2344 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2345 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2346 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2347 rasterized_stream
, class_linkage
, shader
);
2352 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2353 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2355 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2356 struct d3d_pixel_shader
*object
;
2359 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2360 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2363 FIXME("Class linkage is not implemented yet.\n");
2365 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2368 *shader
= &object
->ID3D11PixelShader_iface
;
2373 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2374 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2376 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2377 struct d3d11_hull_shader
*object
;
2380 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2381 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2384 FIXME("Class linkage is not implemented yet.\n");
2386 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2389 *shader
= &object
->ID3D11HullShader_iface
;
2394 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2395 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2397 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2398 struct d3d11_domain_shader
*object
;
2401 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2402 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2405 FIXME("Class linkage is not implemented yet.\n");
2407 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2410 *shader
= &object
->ID3D11DomainShader_iface
;
2415 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2416 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2418 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2419 struct d3d11_compute_shader
*object
;
2422 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2423 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2426 FIXME("Class linkage is not implemented yet.\n");
2428 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2431 *shader
= &object
->ID3D11ComputeShader_iface
;
2436 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2437 ID3D11ClassLinkage
**class_linkage
)
2439 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2440 struct d3d11_class_linkage
*object
;
2443 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
2445 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
2448 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
2453 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
2454 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
2456 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2457 struct d3d_blend_state
*object
;
2458 struct wine_rb_entry
*entry
;
2459 D3D11_BLEND_DESC tmp_desc
;
2463 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2466 return E_INVALIDARG
;
2468 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2469 * D3D11_BLEND_DESC as a key in the rbtree. */
2470 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2471 tmp_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
2472 tmp_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
2473 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2475 j
= desc
->IndependentBlendEnable
? i
: 0;
2476 tmp_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[j
].BlendEnable
;
2477 tmp_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[j
].SrcBlend
;
2478 tmp_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[j
].DestBlend
;
2479 tmp_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[j
].BlendOp
;
2480 tmp_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[j
].SrcBlendAlpha
;
2481 tmp_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[j
].DestBlendAlpha
;
2482 tmp_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[j
].BlendOpAlpha
;
2483 tmp_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[j
].RenderTargetWriteMask
;
2486 wined3d_mutex_lock();
2487 if ((entry
= wine_rb_get(&device
->blend_states
, &tmp_desc
)))
2489 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_blend_state
, entry
);
2491 TRACE("Returning existing blend state %p.\n", object
);
2492 *blend_state
= &object
->ID3D11BlendState_iface
;
2493 ID3D11BlendState_AddRef(*blend_state
);
2494 wined3d_mutex_unlock();
2498 wined3d_mutex_unlock();
2500 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2501 return E_OUTOFMEMORY
;
2503 if (FAILED(hr
= d3d_blend_state_init(object
, device
, &tmp_desc
)))
2505 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2506 HeapFree(GetProcessHeap(), 0, object
);
2510 TRACE("Created blend state %p.\n", object
);
2511 *blend_state
= &object
->ID3D11BlendState_iface
;
2516 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
2517 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
2519 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2520 struct d3d_depthstencil_state
*object
;
2521 D3D11_DEPTH_STENCIL_DESC tmp_desc
;
2522 struct wine_rb_entry
*entry
;
2525 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2528 return E_INVALIDARG
;
2530 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2531 * it as a key in the rbtree. */
2532 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2533 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2534 if (desc
->DepthEnable
)
2536 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2537 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2541 tmp_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
2542 tmp_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
2544 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2545 if (desc
->StencilEnable
)
2547 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2548 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2549 tmp_desc
.FrontFace
= desc
->FrontFace
;
2550 tmp_desc
.BackFace
= desc
->BackFace
;
2554 tmp_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
2555 tmp_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
2556 tmp_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2557 tmp_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2558 tmp_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2559 tmp_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2560 tmp_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2561 tmp_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2562 tmp_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2563 tmp_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2566 wined3d_mutex_lock();
2567 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2569 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_depthstencil_state
, entry
);
2571 TRACE("Returning existing depthstencil state %p.\n", object
);
2572 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2573 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
2574 wined3d_mutex_unlock();
2578 wined3d_mutex_unlock();
2580 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2581 return E_OUTOFMEMORY
;
2583 if (FAILED(hr
= d3d_depthstencil_state_init(object
, device
, &tmp_desc
)))
2585 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2586 HeapFree(GetProcessHeap(), 0, object
);
2590 TRACE("Created depthstencil state %p.\n", object
);
2591 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2596 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
2597 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
2599 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2600 struct d3d_rasterizer_state
*object
;
2601 struct wine_rb_entry
*entry
;
2604 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2607 return E_INVALIDARG
;
2609 wined3d_mutex_lock();
2610 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2612 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_rasterizer_state
, entry
);
2614 TRACE("Returning existing rasterizer state %p.\n", object
);
2615 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2616 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2617 wined3d_mutex_unlock();
2621 wined3d_mutex_unlock();
2623 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2624 return E_OUTOFMEMORY
;
2626 if (FAILED(hr
= d3d_rasterizer_state_init(object
, device
, desc
)))
2628 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2629 HeapFree(GetProcessHeap(), 0, object
);
2633 TRACE("Created rasterizer state %p.\n", object
);
2634 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2639 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
2640 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
2642 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2643 D3D11_SAMPLER_DESC normalized_desc
;
2644 struct d3d_sampler_state
*object
;
2645 struct wine_rb_entry
*entry
;
2648 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2651 return E_INVALIDARG
;
2653 normalized_desc
= *desc
;
2654 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc
.Filter
))
2655 normalized_desc
.MaxAnisotropy
= 0;
2656 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc
.Filter
))
2657 normalized_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
2658 if (normalized_desc
.AddressU
!= D3D11_TEXTURE_ADDRESS_BORDER
2659 && normalized_desc
.AddressV
!= D3D11_TEXTURE_ADDRESS_BORDER
2660 && normalized_desc
.AddressW
!= D3D11_TEXTURE_ADDRESS_BORDER
)
2661 memset(&normalized_desc
.BorderColor
, 0, sizeof(normalized_desc
.BorderColor
));
2663 wined3d_mutex_lock();
2664 if ((entry
= wine_rb_get(&device
->sampler_states
, &normalized_desc
)))
2666 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_sampler_state
, entry
);
2668 TRACE("Returning existing sampler state %p.\n", object
);
2669 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2670 ID3D11SamplerState_AddRef(*sampler_state
);
2671 wined3d_mutex_unlock();
2675 wined3d_mutex_unlock();
2677 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2678 return E_OUTOFMEMORY
;
2680 if (FAILED(hr
= d3d_sampler_state_init(object
, device
, &normalized_desc
)))
2682 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2683 HeapFree(GetProcessHeap(), 0, object
);
2687 TRACE("Created sampler state %p.\n", object
);
2688 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2693 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
2694 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
2696 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2697 struct d3d_query
*object
;
2700 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2702 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
2707 *query
= &object
->ID3D11Query_iface
;
2711 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2715 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
2716 ID3D11Predicate
**predicate
)
2718 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2719 struct d3d_query
*object
;
2722 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2724 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
2729 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
2733 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2737 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2738 ID3D11Counter
**counter
)
2740 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2745 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
2746 ID3D11DeviceContext
**context
)
2748 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
2753 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
2756 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
2761 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
2762 UINT
*format_support
)
2764 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
2769 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
2770 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2772 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2773 struct wined3d_device_creation_parameters params
;
2774 struct wined3d
*wined3d
;
2777 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
2778 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2780 if (!quality_level_count
)
2781 return E_INVALIDARG
;
2783 *quality_level_count
= 0;
2787 if (sample_count
== 1)
2789 *quality_level_count
= 1;
2792 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
2795 wined3d_mutex_lock();
2796 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
2797 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
2798 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
2799 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
2800 wined3d_mutex_unlock();
2802 if (hr
== WINED3DERR_INVALIDCALL
)
2803 return E_INVALIDARG
;
2804 if (hr
== WINED3DERR_NOTAVAILABLE
)
2809 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
2811 FIXME("iface %p, info %p stub!\n", iface
, info
);
2814 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2815 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
2816 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2818 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2819 "units %p, units_length %p, description %p, description_length %p stub!\n",
2820 iface
, desc
, type
, active_counter_count
, name
, name_length
,
2821 units
, units_length
, description
, description_length
);
2826 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
2827 void *feature_support_data
, UINT feature_support_data_size
)
2829 TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n",
2830 iface
, feature
, feature_support_data
, feature_support_data_size
);
2834 case D3D11_FEATURE_THREADING
:
2836 D3D11_FEATURE_DATA_THREADING
*threading_data
= feature_support_data
;
2837 if (feature_support_data_size
!= sizeof(*threading_data
))
2839 WARN("Invalid data size.\n");
2840 return E_INVALIDARG
;
2843 /* We lie about the threading support to make Tomb Raider 2013 and
2844 * Deus Ex: Human Revolution happy. */
2845 FIXME("Returning fake threading support data.\n");
2846 threading_data
->DriverConcurrentCreates
= TRUE
;
2847 threading_data
->DriverCommandLists
= TRUE
;
2850 case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
:
2852 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
*options
= feature_support_data
;
2853 if (feature_support_data_size
!= sizeof(*options
))
2855 WARN("Invalid data size.\n");
2856 return E_INVALIDARG
;
2859 options
->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
= FALSE
;
2864 FIXME("Unhandled feature %#x.\n", feature
);
2869 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2870 UINT
*data_size
, void *data
)
2872 IDXGIDevice
*dxgi_device
;
2875 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2877 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2879 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
2880 IDXGIDevice_Release(dxgi_device
);
2885 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2886 UINT data_size
, const void *data
)
2888 IDXGIDevice
*dxgi_device
;
2891 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2893 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2895 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
2896 IDXGIDevice_Release(dxgi_device
);
2901 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
2902 const IUnknown
*data
)
2904 IDXGIDevice
*dxgi_device
;
2907 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
2909 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2911 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
2912 IDXGIDevice_Release(dxgi_device
);
2917 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
2919 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2921 TRACE("iface %p.\n", iface
);
2923 return device
->feature_level
;
2926 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
2928 FIXME("iface %p stub!\n", iface
);
2933 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
2935 FIXME("iface %p stub!\n", iface
);
2940 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
2941 ID3D11DeviceContext
**immediate_context
)
2943 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2945 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
2947 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
2948 ID3D11DeviceContext_AddRef(*immediate_context
);
2951 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
2953 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2958 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
2960 FIXME("iface %p stub!\n", iface
);
2965 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
2967 /* IUnknown methods */
2968 d3d11_device_QueryInterface
,
2969 d3d11_device_AddRef
,
2970 d3d11_device_Release
,
2971 /* ID3D11Device methods */
2972 d3d11_device_CreateBuffer
,
2973 d3d11_device_CreateTexture1D
,
2974 d3d11_device_CreateTexture2D
,
2975 d3d11_device_CreateTexture3D
,
2976 d3d11_device_CreateShaderResourceView
,
2977 d3d11_device_CreateUnorderedAccessView
,
2978 d3d11_device_CreateRenderTargetView
,
2979 d3d11_device_CreateDepthStencilView
,
2980 d3d11_device_CreateInputLayout
,
2981 d3d11_device_CreateVertexShader
,
2982 d3d11_device_CreateGeometryShader
,
2983 d3d11_device_CreateGeometryShaderWithStreamOutput
,
2984 d3d11_device_CreatePixelShader
,
2985 d3d11_device_CreateHullShader
,
2986 d3d11_device_CreateDomainShader
,
2987 d3d11_device_CreateComputeShader
,
2988 d3d11_device_CreateClassLinkage
,
2989 d3d11_device_CreateBlendState
,
2990 d3d11_device_CreateDepthStencilState
,
2991 d3d11_device_CreateRasterizerState
,
2992 d3d11_device_CreateSamplerState
,
2993 d3d11_device_CreateQuery
,
2994 d3d11_device_CreatePredicate
,
2995 d3d11_device_CreateCounter
,
2996 d3d11_device_CreateDeferredContext
,
2997 d3d11_device_OpenSharedResource
,
2998 d3d11_device_CheckFormatSupport
,
2999 d3d11_device_CheckMultisampleQualityLevels
,
3000 d3d11_device_CheckCounterInfo
,
3001 d3d11_device_CheckCounter
,
3002 d3d11_device_CheckFeatureSupport
,
3003 d3d11_device_GetPrivateData
,
3004 d3d11_device_SetPrivateData
,
3005 d3d11_device_SetPrivateDataInterface
,
3006 d3d11_device_GetFeatureLevel
,
3007 d3d11_device_GetCreationFlags
,
3008 d3d11_device_GetDeviceRemovedReason
,
3009 d3d11_device_GetImmediateContext
,
3010 d3d11_device_SetExceptionMode
,
3011 d3d11_device_GetExceptionMode
,
3014 /* Inner IUnknown methods */
3016 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
3018 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
3021 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
3023 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3025 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
3027 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
3028 || IsEqualGUID(riid
, &IID_IUnknown
))
3030 *out
= &device
->ID3D11Device_iface
;
3032 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
3033 || IsEqualGUID(riid
, &IID_ID3D10Device
))
3035 *out
= &device
->ID3D10Device1_iface
;
3037 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
3039 *out
= &device
->ID3D10Multithread_iface
;
3041 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
3043 *out
= &device
->IWineDXGIDeviceParent_iface
;
3047 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
3049 return E_NOINTERFACE
;
3052 IUnknown_AddRef((IUnknown
*)*out
);
3056 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
3058 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3059 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
3061 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
3066 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
3068 struct d3d_device
*device
= impl_from_IUnknown(iface
);
3069 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
3071 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
3075 d3d11_immediate_context_destroy(&device
->immediate_context
);
3076 if (device
->wined3d_device
)
3078 wined3d_mutex_lock();
3079 wined3d_device_decref(device
->wined3d_device
);
3080 wined3d_mutex_unlock();
3082 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
3083 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3084 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3085 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3091 /* IUnknown methods */
3093 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
3096 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3097 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
3100 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
3102 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3103 return IUnknown_AddRef(device
->outer_unk
);
3106 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
3108 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3109 return IUnknown_Release(device
->outer_unk
);
3112 /* ID3D10Device methods */
3114 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
3115 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3117 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3120 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3121 iface
, start_slot
, buffer_count
, buffers
);
3123 wined3d_mutex_lock();
3124 for (i
= 0; i
< buffer_count
; ++i
)
3126 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3128 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
3129 buffer
? buffer
->wined3d_buffer
: NULL
);
3131 wined3d_mutex_unlock();
3134 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
3135 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3137 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3140 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3141 iface
, start_slot
, view_count
, views
);
3143 wined3d_mutex_lock();
3144 for (i
= 0; i
< view_count
; ++i
)
3146 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3148 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
3149 view
? view
->wined3d_view
: NULL
);
3151 wined3d_mutex_unlock();
3154 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
3155 ID3D10PixelShader
*shader
)
3157 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3158 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
3160 TRACE("iface %p, shader %p\n", iface
, shader
);
3162 wined3d_mutex_lock();
3163 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
3164 wined3d_mutex_unlock();
3167 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
3168 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3170 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3173 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3174 iface
, start_slot
, sampler_count
, samplers
);
3176 wined3d_mutex_lock();
3177 for (i
= 0; i
< sampler_count
; ++i
)
3179 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3181 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
3182 sampler
? sampler
->wined3d_sampler
: NULL
);
3184 wined3d_mutex_unlock();
3187 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
3188 ID3D10VertexShader
*shader
)
3190 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3191 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
3193 TRACE("iface %p, shader %p\n", iface
, shader
);
3195 wined3d_mutex_lock();
3196 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
3197 wined3d_mutex_unlock();
3200 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
3201 UINT start_index_location
, INT base_vertex_location
)
3203 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3205 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
3206 iface
, index_count
, start_index_location
, base_vertex_location
);
3208 wined3d_mutex_lock();
3209 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3210 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
3211 wined3d_mutex_unlock();
3214 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
3215 UINT start_vertex_location
)
3217 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3219 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
3220 iface
, vertex_count
, start_vertex_location
);
3222 wined3d_mutex_lock();
3223 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
3224 wined3d_mutex_unlock();
3227 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
3228 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3230 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3233 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3234 iface
, start_slot
, buffer_count
, buffers
);
3236 wined3d_mutex_lock();
3237 for (i
= 0; i
< buffer_count
; ++i
)
3239 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3241 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
3242 buffer
? buffer
->wined3d_buffer
: NULL
);
3244 wined3d_mutex_unlock();
3247 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
3248 ID3D10InputLayout
*input_layout
)
3250 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3251 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
3253 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
3255 wined3d_mutex_lock();
3256 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
3257 layout
? layout
->wined3d_decl
: NULL
);
3258 wined3d_mutex_unlock();
3261 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
3262 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
3264 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3267 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
3268 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3270 wined3d_mutex_lock();
3271 for (i
= 0; i
< buffer_count
; ++i
)
3273 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3275 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
3276 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3278 wined3d_mutex_unlock();
3281 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3282 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3284 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3285 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3287 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3288 iface
, buffer
, debug_dxgi_format(format
), offset
);
3290 wined3d_mutex_lock();
3291 wined3d_device_set_index_buffer(device
->wined3d_device
,
3292 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3293 wined3dformat_from_dxgi_format(format
), offset
);
3294 wined3d_mutex_unlock();
3297 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3298 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3299 INT base_vertex_location
, UINT start_instance_location
)
3301 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3303 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3304 "base_vertex_location %d, start_instance_location %u.\n",
3305 iface
, instance_index_count
, instance_count
, start_index_location
,
3306 base_vertex_location
, start_instance_location
);
3308 wined3d_mutex_lock();
3309 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3310 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3311 instance_index_count
, start_instance_location
, instance_count
);
3312 wined3d_mutex_unlock();
3315 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3316 UINT instance_vertex_count
, UINT instance_count
,
3317 UINT start_vertex_location
, UINT start_instance_location
)
3319 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3321 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3322 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3323 start_vertex_location
, start_instance_location
);
3325 wined3d_mutex_lock();
3326 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3327 instance_vertex_count
, start_instance_location
, instance_count
);
3328 wined3d_mutex_unlock();
3331 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3332 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3334 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3337 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3338 iface
, start_slot
, buffer_count
, buffers
);
3340 wined3d_mutex_lock();
3341 for (i
= 0; i
< buffer_count
; ++i
)
3343 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3345 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3346 buffer
? buffer
->wined3d_buffer
: NULL
);
3348 wined3d_mutex_unlock();
3351 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3353 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3354 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3356 TRACE("iface %p, shader %p.\n", iface
, shader
);
3358 wined3d_mutex_lock();
3359 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3360 wined3d_mutex_unlock();
3363 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3364 D3D10_PRIMITIVE_TOPOLOGY topology
)
3366 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3368 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
3370 wined3d_mutex_lock();
3371 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
3372 wined3d_mutex_unlock();
3375 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3376 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3378 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3381 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3382 iface
, start_slot
, view_count
, views
);
3384 wined3d_mutex_lock();
3385 for (i
= 0; i
< view_count
; ++i
)
3387 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3389 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3390 view
? view
->wined3d_view
: NULL
);
3392 wined3d_mutex_unlock();
3395 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3396 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3398 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3401 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3402 iface
, start_slot
, sampler_count
, samplers
);
3404 wined3d_mutex_lock();
3405 for (i
= 0; i
< sampler_count
; ++i
)
3407 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3409 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3410 sampler
? sampler
->wined3d_sampler
: NULL
);
3412 wined3d_mutex_unlock();
3415 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3417 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3418 struct d3d_query
*query
;
3420 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3422 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3423 wined3d_mutex_lock();
3424 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3425 wined3d_mutex_unlock();
3428 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3429 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3431 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3434 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3435 iface
, start_slot
, view_count
, views
);
3437 wined3d_mutex_lock();
3438 for (i
= 0; i
< view_count
; ++i
)
3440 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3442 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3443 view
? view
->wined3d_view
: NULL
);
3445 wined3d_mutex_unlock();
3448 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3449 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3451 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3454 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3455 iface
, start_slot
, sampler_count
, samplers
);
3457 wined3d_mutex_lock();
3458 for (i
= 0; i
< sampler_count
; ++i
)
3460 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3462 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3463 sampler
? sampler
->wined3d_sampler
: NULL
);
3465 wined3d_mutex_unlock();
3468 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3469 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3470 ID3D10DepthStencilView
*depth_stencil_view
)
3472 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3473 struct d3d_depthstencil_view
*dsv
;
3476 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3477 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3479 wined3d_mutex_lock();
3480 for (i
= 0; i
< render_target_view_count
; ++i
)
3482 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3484 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3485 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3487 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3489 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3492 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3493 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3494 dsv
? dsv
->wined3d_view
: NULL
);
3495 wined3d_mutex_unlock();
3498 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3499 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3501 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3502 struct d3d_blend_state
*blend_state_object
;
3504 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3505 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3507 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3508 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3509 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3512 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3513 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3515 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3516 struct d3d_depthstencil_state
*ds_state_object
;
3518 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3519 iface
, depth_stencil_state
, stencil_ref
);
3521 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3522 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3523 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
3526 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3527 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3529 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3530 unsigned int count
, i
;
3532 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3534 count
= min(target_count
, 4);
3535 wined3d_mutex_lock();
3536 for (i
= 0; i
< count
; ++i
)
3538 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
3540 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
3541 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
3544 for (i
= count
; i
< 4; ++i
)
3546 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
3548 wined3d_mutex_unlock();
3551 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
3553 FIXME("iface %p stub!\n", iface
);
3556 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
3558 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3559 struct d3d_rasterizer_state
*rasterizer_state_object
;
3561 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3563 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
3564 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3565 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
3568 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
3569 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
3571 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3572 struct wined3d_viewport wined3d_vp
;
3574 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
3576 if (viewport_count
> 1)
3577 FIXME("Multiple viewports not implemented.\n");
3579 if (!viewport_count
)
3582 wined3d_vp
.x
= viewports
[0].TopLeftX
;
3583 wined3d_vp
.y
= viewports
[0].TopLeftY
;
3584 wined3d_vp
.width
= viewports
[0].Width
;
3585 wined3d_vp
.height
= viewports
[0].Height
;
3586 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
3587 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
3589 wined3d_mutex_lock();
3590 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
3591 wined3d_mutex_unlock();
3594 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
3595 UINT rect_count
, const D3D10_RECT
*rects
)
3597 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3599 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
3602 FIXME("Multiple scissor rects not implemented.\n");
3607 wined3d_mutex_lock();
3608 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
3609 wined3d_mutex_unlock();
3612 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
3613 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
3614 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
3616 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3617 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3618 struct wined3d_box wined3d_src_box
;
3620 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3621 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3622 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
3623 src_resource
, src_subresource_idx
, src_box
);
3627 wined3d_src_box
.left
= src_box
->left
;
3628 wined3d_src_box
.top
= src_box
->top
;
3629 wined3d_src_box
.front
= src_box
->front
;
3630 wined3d_src_box
.right
= src_box
->right
;
3631 wined3d_src_box
.bottom
= src_box
->bottom
;
3632 wined3d_src_box
.back
= src_box
->back
;
3635 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3636 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3637 wined3d_mutex_lock();
3638 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
3639 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
3640 wined3d_mutex_unlock();
3643 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
3644 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
3646 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3647 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3649 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
3651 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3652 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3653 wined3d_mutex_lock();
3654 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
3655 wined3d_mutex_unlock();
3658 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
3659 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
3660 const void *data
, UINT row_pitch
, UINT depth_pitch
)
3662 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3663 ID3D11Resource
*d3d11_resource
;
3665 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3666 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
3668 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
3669 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3670 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
3671 ID3D11Resource_Release(d3d11_resource
);
3674 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
3675 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
3677 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3678 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
3679 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
3682 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
3683 iface
, render_target_view
, debug_float4(color_rgba
));
3688 wined3d_mutex_lock();
3689 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3690 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
3691 ERR("Failed to clear view, hr %#x.\n", hr
);
3692 wined3d_mutex_unlock();
3695 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
3696 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
3698 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3699 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3700 DWORD wined3d_flags
;
3703 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
3704 iface
, depth_stencil_view
, flags
, depth
, stencil
);
3709 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
3711 wined3d_mutex_lock();
3712 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3713 wined3d_flags
, NULL
, depth
, stencil
)))
3714 ERR("Failed to clear view, hr %#x.\n", hr
);
3715 wined3d_mutex_unlock();
3718 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
3719 ID3D10ShaderResourceView
*shader_resource_view
)
3721 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
3724 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
3725 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
3726 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
3728 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3729 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3730 iface
, dst_resource
, dst_subresource_idx
,
3731 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
3734 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
3735 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3737 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3740 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3741 iface
, start_slot
, buffer_count
, buffers
);
3743 wined3d_mutex_lock();
3744 for (i
= 0; i
< buffer_count
; ++i
)
3746 struct wined3d_buffer
*wined3d_buffer
;
3747 struct d3d_buffer
*buffer_impl
;
3749 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
3755 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3756 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3757 ID3D10Buffer_AddRef(buffers
[i
]);
3759 wined3d_mutex_unlock();
3762 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
3763 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3765 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3768 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3769 iface
, start_slot
, view_count
, views
);
3771 wined3d_mutex_lock();
3772 for (i
= 0; i
< view_count
; ++i
)
3774 struct wined3d_shader_resource_view
*wined3d_view
;
3775 struct d3d_shader_resource_view
*view_impl
;
3777 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3783 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3784 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3785 ID3D10ShaderResourceView_AddRef(views
[i
]);
3787 wined3d_mutex_unlock();
3790 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
3792 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3793 struct d3d_pixel_shader
*shader_impl
;
3794 struct wined3d_shader
*wined3d_shader
;
3796 TRACE("iface %p, shader %p.\n", iface
, shader
);
3798 wined3d_mutex_lock();
3799 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
3801 wined3d_mutex_unlock();
3806 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3807 wined3d_mutex_unlock();
3808 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
3809 ID3D10PixelShader_AddRef(*shader
);
3812 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
3813 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3815 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3818 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3819 iface
, start_slot
, sampler_count
, samplers
);
3821 wined3d_mutex_lock();
3822 for (i
= 0; i
< sampler_count
; ++i
)
3824 struct d3d_sampler_state
*sampler_impl
;
3825 struct wined3d_sampler
*wined3d_sampler
;
3827 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
3833 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3834 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3835 ID3D10SamplerState_AddRef(samplers
[i
]);
3837 wined3d_mutex_unlock();
3840 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
3842 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3843 struct d3d_vertex_shader
*shader_impl
;
3844 struct wined3d_shader
*wined3d_shader
;
3846 TRACE("iface %p, shader %p.\n", iface
, shader
);
3848 wined3d_mutex_lock();
3849 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
3851 wined3d_mutex_unlock();
3856 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3857 wined3d_mutex_unlock();
3858 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
3859 ID3D10VertexShader_AddRef(*shader
);
3862 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
3863 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3865 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3868 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3869 iface
, start_slot
, buffer_count
, buffers
);
3871 wined3d_mutex_lock();
3872 for (i
= 0; i
< buffer_count
; ++i
)
3874 struct wined3d_buffer
*wined3d_buffer
;
3875 struct d3d_buffer
*buffer_impl
;
3877 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
3883 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3884 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3885 ID3D10Buffer_AddRef(buffers
[i
]);
3887 wined3d_mutex_unlock();
3890 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
3892 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3893 struct wined3d_vertex_declaration
*wined3d_declaration
;
3894 struct d3d_input_layout
*input_layout_impl
;
3896 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
3898 wined3d_mutex_lock();
3899 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
3901 wined3d_mutex_unlock();
3902 *input_layout
= NULL
;
3906 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
3907 wined3d_mutex_unlock();
3908 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
3909 ID3D10InputLayout_AddRef(*input_layout
);
3912 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
3913 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
3915 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3918 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3919 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3921 wined3d_mutex_lock();
3922 for (i
= 0; i
< buffer_count
; ++i
)
3924 struct wined3d_buffer
*wined3d_buffer
;
3925 struct d3d_buffer
*buffer_impl
;
3927 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
3928 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
3929 ERR("Failed to get vertex buffer.\n");
3931 if (!wined3d_buffer
)
3937 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3938 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3939 ID3D10Buffer_AddRef(buffers
[i
]);
3941 wined3d_mutex_unlock();
3944 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
3945 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
3947 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3948 enum wined3d_format_id wined3d_format
;
3949 struct wined3d_buffer
*wined3d_buffer
;
3950 struct d3d_buffer
*buffer_impl
;
3952 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
3954 wined3d_mutex_lock();
3955 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
3956 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
3957 if (!wined3d_buffer
)
3959 wined3d_mutex_unlock();
3964 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3965 wined3d_mutex_unlock();
3966 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
3967 ID3D10Buffer_AddRef(*buffer
);
3970 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
3971 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3973 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3976 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3977 iface
, start_slot
, buffer_count
, buffers
);
3979 wined3d_mutex_lock();
3980 for (i
= 0; i
< buffer_count
; ++i
)
3982 struct wined3d_buffer
*wined3d_buffer
;
3983 struct d3d_buffer
*buffer_impl
;
3985 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
3991 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3992 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3993 ID3D10Buffer_AddRef(buffers
[i
]);
3995 wined3d_mutex_unlock();
3998 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
4000 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4001 struct d3d_geometry_shader
*shader_impl
;
4002 struct wined3d_shader
*wined3d_shader
;
4004 TRACE("iface %p, shader %p.\n", iface
, shader
);
4006 wined3d_mutex_lock();
4007 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
4009 wined3d_mutex_unlock();
4014 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
4015 wined3d_mutex_unlock();
4016 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
4017 ID3D10GeometryShader_AddRef(*shader
);
4020 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
4021 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
4023 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4025 TRACE("iface %p, topology %p\n", iface
, topology
);
4027 wined3d_mutex_lock();
4028 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
4029 wined3d_mutex_unlock();
4032 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
4033 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4035 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4038 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4039 iface
, start_slot
, view_count
, views
);
4041 wined3d_mutex_lock();
4042 for (i
= 0; i
< view_count
; ++i
)
4044 struct wined3d_shader_resource_view
*wined3d_view
;
4045 struct d3d_shader_resource_view
*view_impl
;
4047 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4053 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4054 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4055 ID3D10ShaderResourceView_AddRef(views
[i
]);
4057 wined3d_mutex_unlock();
4060 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
4061 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4063 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4066 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4067 iface
, start_slot
, sampler_count
, samplers
);
4069 wined3d_mutex_lock();
4070 for (i
= 0; i
< sampler_count
; ++i
)
4072 struct d3d_sampler_state
*sampler_impl
;
4073 struct wined3d_sampler
*wined3d_sampler
;
4075 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4081 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4082 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4083 ID3D10SamplerState_AddRef(samplers
[i
]);
4085 wined3d_mutex_unlock();
4088 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
4089 ID3D10Predicate
**predicate
, BOOL
*value
)
4091 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4092 struct wined3d_query
*wined3d_predicate
;
4093 struct d3d_query
*predicate_impl
;
4095 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
4097 wined3d_mutex_lock();
4098 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
4100 wined3d_mutex_unlock();
4105 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
4106 wined3d_mutex_unlock();
4107 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
4108 ID3D10Predicate_AddRef(*predicate
);
4111 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
4112 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
4114 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4117 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
4118 iface
, start_slot
, view_count
, views
);
4120 wined3d_mutex_lock();
4121 for (i
= 0; i
< view_count
; ++i
)
4123 struct wined3d_shader_resource_view
*wined3d_view
;
4124 struct d3d_shader_resource_view
*view_impl
;
4126 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
4132 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
4133 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
4134 ID3D10ShaderResourceView_AddRef(views
[i
]);
4136 wined3d_mutex_unlock();
4139 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
4140 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
4142 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4145 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
4146 iface
, start_slot
, sampler_count
, samplers
);
4148 wined3d_mutex_lock();
4149 for (i
= 0; i
< sampler_count
; ++i
)
4151 struct d3d_sampler_state
*sampler_impl
;
4152 struct wined3d_sampler
*wined3d_sampler
;
4154 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
4160 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
4161 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
4162 ID3D10SamplerState_AddRef(samplers
[i
]);
4164 wined3d_mutex_unlock();
4167 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
4168 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
4170 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4171 struct wined3d_rendertarget_view
*wined3d_view
;
4173 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
4174 iface
, view_count
, render_target_views
, depth_stencil_view
);
4176 wined3d_mutex_lock();
4177 if (render_target_views
)
4179 struct d3d_rendertarget_view
*view_impl
;
4182 for (i
= 0; i
< view_count
; ++i
)
4184 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
4185 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4187 render_target_views
[i
] = NULL
;
4191 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
4192 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
4196 if (depth_stencil_view
)
4198 struct d3d_depthstencil_view
*view_impl
;
4200 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
4201 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
4203 *depth_stencil_view
= NULL
;
4207 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
4208 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
4211 wined3d_mutex_unlock();
4214 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
4215 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
4217 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4218 ID3D11BlendState
*d3d11_blend_state
;
4220 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
4221 iface
, blend_state
, blend_factor
, sample_mask
);
4223 d3d11_immediate_context_OMGetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4224 &d3d11_blend_state
, blend_factor
, sample_mask
);
4226 if (d3d11_blend_state
)
4227 *blend_state
= (ID3D10BlendState
*)&impl_from_ID3D11BlendState(d3d11_blend_state
)->ID3D10BlendState1_iface
;
4229 *blend_state
= NULL
;
4232 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
4233 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
4235 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4236 ID3D11DepthStencilState
*d3d11_iface
;
4238 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
4239 iface
, depth_stencil_state
, stencil_ref
);
4241 d3d11_immediate_context_OMGetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
4242 &d3d11_iface
, stencil_ref
);
4245 *depth_stencil_state
= &impl_from_ID3D11DepthStencilState(d3d11_iface
)->ID3D10DepthStencilState_iface
;
4247 *depth_stencil_state
= NULL
;
4250 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
4251 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
4253 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4256 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
4257 iface
, buffer_count
, buffers
, offsets
);
4259 wined3d_mutex_lock();
4260 for (i
= 0; i
< buffer_count
; ++i
)
4262 struct wined3d_buffer
*wined3d_buffer
;
4263 struct d3d_buffer
*buffer_impl
;
4265 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
4271 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4272 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4273 ID3D10Buffer_AddRef(buffers
[i
]);
4275 wined3d_mutex_unlock();
4278 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
4280 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4282 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4284 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
4285 ID3D10RasterizerState_AddRef(*rasterizer_state
);
4288 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4289 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4291 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4292 struct wined3d_viewport wined3d_vp
;
4294 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4298 *viewport_count
= 1;
4302 if (!*viewport_count
)
4305 wined3d_mutex_lock();
4306 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4307 wined3d_mutex_unlock();
4309 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4310 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4311 viewports
[0].Width
= wined3d_vp
.width
;
4312 viewports
[0].Height
= wined3d_vp
.height
;
4313 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4314 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4316 if (*viewport_count
> 1)
4317 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4320 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4322 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4324 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4335 wined3d_mutex_lock();
4336 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4337 wined3d_mutex_unlock();
4338 if (*rect_count
> 1)
4339 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4342 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4344 TRACE("iface %p.\n", iface
);
4346 /* In the current implementation the device is never removed, so we can
4347 * just return S_OK here. */
4352 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4354 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4359 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4361 FIXME("iface %p stub!\n", iface
);
4366 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4367 REFGUID guid
, UINT
*data_size
, void *data
)
4369 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4371 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4373 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4376 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4377 REFGUID guid
, UINT data_size
, const void *data
)
4379 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4381 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4383 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4386 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4387 REFGUID guid
, const IUnknown
*data
)
4389 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4391 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4393 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4396 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4398 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4399 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4402 TRACE("iface %p.\n", iface
);
4404 wined3d_mutex_lock();
4405 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
4406 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4408 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
4410 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4412 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
4414 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4416 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
4418 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
4419 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4421 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
4423 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4425 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
4427 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4429 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
4431 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
4432 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4434 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
4436 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4438 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
4440 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4442 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
4444 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4446 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
4448 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
4449 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
4450 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
4451 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4453 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4455 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
4456 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
4457 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4458 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
4459 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
4460 ID3D10Device1_RSSetState(iface
, NULL
);
4461 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4463 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4465 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
4466 wined3d_mutex_unlock();
4469 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4471 FIXME("iface %p stub!\n", iface
);
4474 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4475 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4477 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4478 D3D11_BUFFER_DESC d3d11_desc
;
4479 struct d3d_buffer
*object
;
4482 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4484 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4485 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4486 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4487 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4488 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4489 d3d11_desc
.StructureByteStride
= 0;
4491 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4494 *buffer
= &object
->ID3D10Buffer_iface
;
4499 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4500 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4502 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4507 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4508 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4509 ID3D10Texture2D
**texture
)
4511 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4512 D3D11_TEXTURE2D_DESC d3d11_desc
;
4513 struct d3d_texture2d
*object
;
4516 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4518 d3d11_desc
.Width
= desc
->Width
;
4519 d3d11_desc
.Height
= desc
->Height
;
4520 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4521 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4522 d3d11_desc
.Format
= desc
->Format
;
4523 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4524 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4525 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4526 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4527 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4529 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4532 *texture
= &object
->ID3D10Texture2D_iface
;
4537 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4538 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4539 ID3D10Texture3D
**texture
)
4541 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4542 D3D11_TEXTURE3D_DESC d3d11_desc
;
4543 struct d3d_texture3d
*object
;
4546 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4548 d3d11_desc
.Width
= desc
->Width
;
4549 d3d11_desc
.Height
= desc
->Height
;
4550 d3d11_desc
.Depth
= desc
->Depth
;
4551 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4552 d3d11_desc
.Format
= desc
->Format
;
4553 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4554 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4555 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4556 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4558 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4561 *texture
= &object
->ID3D10Texture3D_iface
;
4566 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4567 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4569 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4570 struct d3d_shader_resource_view
*object
;
4571 ID3D11Resource
*d3d11_resource
;
4574 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4577 return E_INVALIDARG
;
4579 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4581 ERR("Resource does not implement ID3D11Resource.\n");
4585 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4587 ID3D11Resource_Release(d3d11_resource
);
4591 *view
= &object
->ID3D10ShaderResourceView1_iface
;
4596 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
4597 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
4599 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4601 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
4602 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
4605 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
4606 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
4608 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4609 struct d3d_rendertarget_view
*object
;
4610 ID3D11Resource
*d3d11_resource
;
4613 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4616 return E_INVALIDARG
;
4618 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4620 ERR("Resource does not implement ID3D11Resource.\n");
4624 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
4625 ID3D11Resource_Release(d3d11_resource
);
4629 *view
= &object
->ID3D10RenderTargetView_iface
;
4634 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
4635 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
4637 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4638 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
4639 struct d3d_depthstencil_view
*object
;
4640 ID3D11Resource
*d3d11_resource
;
4643 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4647 d3d11_desc
.Format
= desc
->Format
;
4648 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
4649 d3d11_desc
.Flags
= 0;
4650 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
4653 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4655 ERR("Resource does not implement ID3D11Resource.\n");
4659 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
4660 ID3D11Resource_Release(d3d11_resource
);
4664 *view
= &object
->ID3D10DepthStencilView_iface
;
4669 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
4670 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
4671 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
4672 ID3D10InputLayout
**input_layout
)
4674 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4675 struct d3d_input_layout
*object
;
4678 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4679 "shader_byte_code_length %lu, input_layout %p\n",
4680 iface
, element_descs
, element_count
, shader_byte_code
,
4681 shader_byte_code_length
, input_layout
);
4683 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
4684 shader_byte_code
, shader_byte_code_length
, &object
)))
4687 *input_layout
= &object
->ID3D10InputLayout_iface
;
4692 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
4693 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
4695 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4696 struct d3d_vertex_shader
*object
;
4699 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4700 iface
, byte_code
, byte_code_length
, shader
);
4702 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4705 *shader
= &object
->ID3D10VertexShader_iface
;
4710 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
4711 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
4713 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4714 struct d3d_geometry_shader
*object
;
4717 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4718 iface
, byte_code
, byte_code_length
, shader
);
4720 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4723 *shader
= &object
->ID3D10GeometryShader_iface
;
4728 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
4729 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
4730 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
4732 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4733 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4734 iface
, byte_code
, byte_code_length
, output_stream_decls
,
4735 output_stream_decl_count
, output_stream_stride
, shader
);
4740 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
4741 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
4743 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4744 struct d3d_pixel_shader
*object
;
4747 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4748 iface
, byte_code
, byte_code_length
, shader
);
4750 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4753 *shader
= &object
->ID3D10PixelShader_iface
;
4758 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
4759 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
4761 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4762 ID3D11BlendState
*d3d11_blend_state
;
4765 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4767 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device_iface
, (D3D11_BLEND_DESC
*)desc
,
4768 &d3d11_blend_state
)))
4771 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState1
, (void **)blend_state
);
4772 ID3D11BlendState_Release(d3d11_blend_state
);
4776 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
4777 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
4779 D3D10_BLEND_DESC1 d3d10_1_desc
;
4782 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4785 return E_INVALIDARG
;
4787 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
4788 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
4789 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
4791 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
4792 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
4793 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
4796 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4798 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
4799 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
4800 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
4801 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
4802 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
4803 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
4804 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
4805 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
4808 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
4811 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
4812 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
4814 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4815 ID3D11DepthStencilState
*d3d11_depth_stencil_state
;
4818 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
4820 if (FAILED(hr
= d3d11_device_CreateDepthStencilState(&device
->ID3D11Device_iface
,
4821 (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &d3d11_depth_stencil_state
)))
4824 hr
= ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state
, &IID_ID3D10DepthStencilState
,
4825 (void **)depth_stencil_state
);
4826 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state
);
4830 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
4831 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
4833 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4834 ID3D11RasterizerState
*d3d11_rasterizer_state
;
4837 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
4839 if (FAILED(hr
= d3d11_device_CreateRasterizerState(&device
->ID3D11Device_iface
,
4840 (const D3D11_RASTERIZER_DESC
*)desc
, &d3d11_rasterizer_state
)))
4843 hr
= ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state
,
4844 &IID_ID3D10RasterizerState
, (void **)rasterizer_state
);
4845 ID3D11RasterizerState_Release(d3d11_rasterizer_state
);
4849 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
4850 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
4852 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4853 ID3D11SamplerState
*d3d11_sampler_state
;
4856 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
4858 if (FAILED(hr
= d3d11_device_CreateSamplerState(&device
->ID3D11Device_iface
,
4859 (const D3D11_SAMPLER_DESC
*)desc
, &d3d11_sampler_state
)))
4862 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
, (void **)sampler_state
);
4863 ID3D11SamplerState_Release(d3d11_sampler_state
);
4867 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
4868 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
4870 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4871 struct d3d_query
*object
;
4874 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
4876 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
4881 *query
= &object
->ID3D10Query_iface
;
4885 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4889 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
4890 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
4892 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4893 struct d3d_query
*object
;
4896 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
4898 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
4903 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
4907 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4911 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
4912 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
4914 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
4919 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
4920 DXGI_FORMAT format
, UINT
*format_support
)
4922 FIXME("iface %p, format %s, format_support %p stub!\n",
4923 iface
, debug_dxgi_format(format
), format_support
);
4928 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
4929 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
4931 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4933 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
4934 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
4936 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
4937 sample_count
, quality_level_count
);
4940 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
4942 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
4945 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
4946 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
4947 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4949 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4950 "units %p, units_length %p, description %p, description_length %p stub!\n",
4951 iface
, desc
, type
, active_counters
, name
, name_length
,
4952 units
, units_length
, description
, description_length
);
4957 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
4959 FIXME("iface %p stub!\n", iface
);
4964 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
4965 HANDLE resource_handle
, REFIID guid
, void **resource
)
4967 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4968 iface
, resource_handle
, debugstr_guid(guid
), resource
);
4973 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
4975 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
4978 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
4980 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
4983 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
4985 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4987 TRACE("iface %p.\n", iface
);
4989 return device
->feature_level
;
4992 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
4994 /* IUnknown methods */
4995 d3d10_device_QueryInterface
,
4996 d3d10_device_AddRef
,
4997 d3d10_device_Release
,
4998 /* ID3D10Device methods */
4999 d3d10_device_VSSetConstantBuffers
,
5000 d3d10_device_PSSetShaderResources
,
5001 d3d10_device_PSSetShader
,
5002 d3d10_device_PSSetSamplers
,
5003 d3d10_device_VSSetShader
,
5004 d3d10_device_DrawIndexed
,
5006 d3d10_device_PSSetConstantBuffers
,
5007 d3d10_device_IASetInputLayout
,
5008 d3d10_device_IASetVertexBuffers
,
5009 d3d10_device_IASetIndexBuffer
,
5010 d3d10_device_DrawIndexedInstanced
,
5011 d3d10_device_DrawInstanced
,
5012 d3d10_device_GSSetConstantBuffers
,
5013 d3d10_device_GSSetShader
,
5014 d3d10_device_IASetPrimitiveTopology
,
5015 d3d10_device_VSSetShaderResources
,
5016 d3d10_device_VSSetSamplers
,
5017 d3d10_device_SetPredication
,
5018 d3d10_device_GSSetShaderResources
,
5019 d3d10_device_GSSetSamplers
,
5020 d3d10_device_OMSetRenderTargets
,
5021 d3d10_device_OMSetBlendState
,
5022 d3d10_device_OMSetDepthStencilState
,
5023 d3d10_device_SOSetTargets
,
5024 d3d10_device_DrawAuto
,
5025 d3d10_device_RSSetState
,
5026 d3d10_device_RSSetViewports
,
5027 d3d10_device_RSSetScissorRects
,
5028 d3d10_device_CopySubresourceRegion
,
5029 d3d10_device_CopyResource
,
5030 d3d10_device_UpdateSubresource
,
5031 d3d10_device_ClearRenderTargetView
,
5032 d3d10_device_ClearDepthStencilView
,
5033 d3d10_device_GenerateMips
,
5034 d3d10_device_ResolveSubresource
,
5035 d3d10_device_VSGetConstantBuffers
,
5036 d3d10_device_PSGetShaderResources
,
5037 d3d10_device_PSGetShader
,
5038 d3d10_device_PSGetSamplers
,
5039 d3d10_device_VSGetShader
,
5040 d3d10_device_PSGetConstantBuffers
,
5041 d3d10_device_IAGetInputLayout
,
5042 d3d10_device_IAGetVertexBuffers
,
5043 d3d10_device_IAGetIndexBuffer
,
5044 d3d10_device_GSGetConstantBuffers
,
5045 d3d10_device_GSGetShader
,
5046 d3d10_device_IAGetPrimitiveTopology
,
5047 d3d10_device_VSGetShaderResources
,
5048 d3d10_device_VSGetSamplers
,
5049 d3d10_device_GetPredication
,
5050 d3d10_device_GSGetShaderResources
,
5051 d3d10_device_GSGetSamplers
,
5052 d3d10_device_OMGetRenderTargets
,
5053 d3d10_device_OMGetBlendState
,
5054 d3d10_device_OMGetDepthStencilState
,
5055 d3d10_device_SOGetTargets
,
5056 d3d10_device_RSGetState
,
5057 d3d10_device_RSGetViewports
,
5058 d3d10_device_RSGetScissorRects
,
5059 d3d10_device_GetDeviceRemovedReason
,
5060 d3d10_device_SetExceptionMode
,
5061 d3d10_device_GetExceptionMode
,
5062 d3d10_device_GetPrivateData
,
5063 d3d10_device_SetPrivateData
,
5064 d3d10_device_SetPrivateDataInterface
,
5065 d3d10_device_ClearState
,
5067 d3d10_device_CreateBuffer
,
5068 d3d10_device_CreateTexture1D
,
5069 d3d10_device_CreateTexture2D
,
5070 d3d10_device_CreateTexture3D
,
5071 d3d10_device_CreateShaderResourceView
,
5072 d3d10_device_CreateRenderTargetView
,
5073 d3d10_device_CreateDepthStencilView
,
5074 d3d10_device_CreateInputLayout
,
5075 d3d10_device_CreateVertexShader
,
5076 d3d10_device_CreateGeometryShader
,
5077 d3d10_device_CreateGeometryShaderWithStreamOutput
,
5078 d3d10_device_CreatePixelShader
,
5079 d3d10_device_CreateBlendState
,
5080 d3d10_device_CreateDepthStencilState
,
5081 d3d10_device_CreateRasterizerState
,
5082 d3d10_device_CreateSamplerState
,
5083 d3d10_device_CreateQuery
,
5084 d3d10_device_CreatePredicate
,
5085 d3d10_device_CreateCounter
,
5086 d3d10_device_CheckFormatSupport
,
5087 d3d10_device_CheckMultisampleQualityLevels
,
5088 d3d10_device_CheckCounterInfo
,
5089 d3d10_device_CheckCounter
,
5090 d3d10_device_GetCreationFlags
,
5091 d3d10_device_OpenSharedResource
,
5092 d3d10_device_SetTextFilterSize
,
5093 d3d10_device_GetTextFilterSize
,
5094 d3d10_device_CreateShaderResourceView1
,
5095 d3d10_device_CreateBlendState1
,
5096 d3d10_device_GetFeatureLevel
,
5099 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
5101 /* IUnknown methods */
5102 d3d_device_inner_QueryInterface
,
5103 d3d_device_inner_AddRef
,
5104 d3d_device_inner_Release
,
5107 /* ID3D10Multithread methods */
5109 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
5111 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
5114 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
5116 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5118 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
5120 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
5123 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
5125 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5127 TRACE("iface %p.\n", iface
);
5129 return IUnknown_AddRef(device
->outer_unk
);
5132 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
5134 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
5136 TRACE("iface %p.\n", iface
);
5138 return IUnknown_Release(device
->outer_unk
);
5141 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
5143 TRACE("iface %p.\n", iface
);
5145 wined3d_mutex_lock();
5148 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
5150 TRACE("iface %p.\n", iface
);
5152 wined3d_mutex_unlock();
5155 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
5157 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
5162 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
5164 FIXME("iface %p stub!\n", iface
);
5169 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
5171 d3d10_multithread_QueryInterface
,
5172 d3d10_multithread_AddRef
,
5173 d3d10_multithread_Release
,
5174 d3d10_multithread_Enter
,
5175 d3d10_multithread_Leave
,
5176 d3d10_multithread_SetMultithreadProtected
,
5177 d3d10_multithread_GetMultithreadProtected
,
5180 /* IWineDXGIDeviceParent IUnknown methods */
5182 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
5184 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
5187 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
5188 REFIID riid
, void **ppv
)
5190 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5191 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
5194 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
5196 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5197 return IUnknown_AddRef(device
->outer_unk
);
5200 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
5202 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5203 return IUnknown_Release(device
->outer_unk
);
5206 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
5207 IWineDXGIDeviceParent
*iface
)
5209 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
5210 return &device
->device_parent
;
5213 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
5215 /* IUnknown methods */
5216 dxgi_device_parent_QueryInterface
,
5217 dxgi_device_parent_AddRef
,
5218 dxgi_device_parent_Release
,
5219 /* IWineDXGIDeviceParent methods */
5220 dxgi_device_parent_get_wined3d_device_parent
,
5223 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
5225 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
5228 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
5229 struct wined3d_device
*wined3d_device
)
5231 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5233 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
5235 wined3d_device_incref(wined3d_device
);
5236 device
->wined3d_device
= wined3d_device
;
5239 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
5241 TRACE("device_parent %p.\n", device_parent
);
5244 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
5246 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
5249 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
5250 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
5251 const struct wined3d_parent_ops
**parent_ops
)
5253 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
5254 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
5257 *parent_ops
= &d3d_null_wined3d_parent_ops
;
5262 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
5263 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
5264 struct wined3d_texture
**wined3d_texture
)
5266 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5267 struct d3d_texture2d
*texture
;
5268 ID3D10Texture2D
*texture_iface
;
5269 D3D10_TEXTURE2D_DESC desc
;
5272 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
5273 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
5275 FIXME("Implement DXGI<->wined3d usage conversion.\n");
5277 desc
.Width
= wined3d_desc
->width
;
5278 desc
.Height
= wined3d_desc
->height
;
5281 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
5282 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
5283 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
5284 desc
.Usage
= D3D10_USAGE_DEFAULT
;
5285 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5286 desc
.CPUAccessFlags
= 0;
5289 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
5290 &desc
, NULL
, &texture_iface
)))
5292 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
5296 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5298 *wined3d_texture
= texture
->wined3d_texture
;
5299 wined3d_texture_incref(*wined3d_texture
);
5300 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5305 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5306 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5308 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5309 IWineDXGIDevice
*wine_device
;
5312 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5314 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5315 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5317 ERR("Device should implement IWineDXGIDevice.\n");
5321 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, TRUE
, swapchain
);
5322 IWineDXGIDevice_Release(wine_device
);
5325 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5332 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5334 device_parent_wined3d_device_created
,
5335 device_parent_mode_changed
,
5336 device_parent_activate
,
5337 device_parent_sub_resource_created
,
5338 device_parent_sub_resource_created
,
5339 device_parent_create_swapchain_texture
,
5340 device_parent_create_swapchain
,
5343 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5345 const D3D11_SAMPLER_DESC
*ka
= key
;
5346 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5348 return memcmp(ka
, kb
, sizeof(*ka
));
5351 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5353 const D3D11_BLEND_DESC
*ka
= key
;
5354 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5356 return memcmp(ka
, kb
, sizeof(*ka
));
5359 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5361 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5362 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5363 const struct d3d_depthstencil_state
, entry
)->desc
;
5365 return memcmp(ka
, kb
, sizeof(*ka
));
5368 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5370 const D3D11_RASTERIZER_DESC
*ka
= key
;
5371 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5373 return memcmp(ka
, kb
, sizeof(*ka
));
5376 void d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5378 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5379 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5380 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5381 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5382 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5383 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5384 device
->refcount
= 1;
5385 /* COM aggregation always takes place */
5386 device
->outer_unk
= outer_unknown
;
5388 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5389 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5391 device
->blend_factor
[0] = 1.0f
;
5392 device
->blend_factor
[1] = 1.0f
;
5393 device
->blend_factor
[2] = 1.0f
;
5394 device
->blend_factor
[3] = 1.0f
;
5396 wine_rb_init(&device
->blend_states
, d3d_blend_state_compare
);
5397 wine_rb_init(&device
->depthstencil_states
, d3d_depthstencil_state_compare
);
5398 wine_rb_init(&device
->rasterizer_states
, d3d_rasterizer_state_compare
);
5399 wine_rb_init(&device
->sampler_states
, d3d_sampler_state_compare
);