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 FIXME("iface %p, asynchronous %p stub!\n", iface
, asynchronous
);
498 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext
*iface
,
499 ID3D11Asynchronous
*asynchronous
)
501 FIXME("iface %p, asynchronous %p stub!\n", iface
, asynchronous
);
504 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext
*iface
,
505 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
507 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
508 iface
, asynchronous
, data
, data_size
, data_flags
);
513 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext
*iface
,
514 ID3D11Predicate
*predicate
, BOOL value
)
516 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
517 struct d3d_query
*query
;
519 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
521 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
523 wined3d_mutex_lock();
524 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
525 wined3d_mutex_unlock();
528 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext
*iface
,
529 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
531 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
534 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
536 wined3d_mutex_lock();
537 for (i
= 0; i
< view_count
; ++i
)
539 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
541 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
542 view
? view
->wined3d_view
: NULL
);
544 wined3d_mutex_unlock();
547 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext
*iface
,
548 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
550 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
553 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
554 iface
, start_slot
, sampler_count
, samplers
);
556 wined3d_mutex_lock();
557 for (i
= 0; i
< sampler_count
; ++i
)
559 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
561 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
562 sampler
? sampler
->wined3d_sampler
: NULL
);
564 wined3d_mutex_unlock();
567 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext
*iface
,
568 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
569 ID3D11DepthStencilView
*depth_stencil_view
)
571 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
572 struct d3d_depthstencil_view
*dsv
;
575 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
576 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
578 wined3d_mutex_lock();
579 for (i
= 0; i
< render_target_view_count
; ++i
)
581 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
582 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
584 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
586 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
589 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
590 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
591 wined3d_mutex_unlock();
594 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
595 ID3D11DeviceContext
*iface
, UINT render_target_view_count
,
596 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
597 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
598 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
600 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
601 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
602 "initial_counts %p partial-stub!\n",
603 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
604 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
607 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
609 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
614 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
615 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
617 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
618 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
619 const D3D11_BLEND_DESC
*desc
;
621 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
622 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
625 blend_factor
= default_blend_factor
;
627 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
628 FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor
));
630 wined3d_mutex_lock();
631 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
632 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
633 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
635 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
636 wined3d_device_set_render_state(device
->wined3d_device
,
637 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
638 wined3d_device_set_render_state(device
->wined3d_device
,
639 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
640 wined3d_device_set_render_state(device
->wined3d_device
,
641 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
642 wined3d_device_set_render_state(device
->wined3d_device
,
643 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
644 wined3d_mutex_unlock();
648 desc
= &device
->blend_state
->desc
;
649 /* glSampleCoverage() */
650 if (desc
->AlphaToCoverageEnable
)
651 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
652 /* glEnableIndexedEXT(GL_BLEND, ...) */
653 FIXME("Per-rendertarget blend not implemented.\n");
654 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
655 desc
->RenderTarget
[0].BlendEnable
);
656 if (desc
->RenderTarget
[0].BlendEnable
)
658 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
,
659 desc
->RenderTarget
[0].SrcBlend
);
660 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
,
661 desc
->RenderTarget
[0].DestBlend
);
662 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
,
663 desc
->RenderTarget
[0].BlendOp
);
664 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
665 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
,
666 desc
->RenderTarget
[0].SrcBlendAlpha
);
667 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
,
668 desc
->RenderTarget
[0].DestBlendAlpha
);
669 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
,
670 desc
->RenderTarget
[0].BlendOpAlpha
);
672 FIXME("Color mask > 3 not implemented.\n");
673 wined3d_device_set_render_state(device
->wined3d_device
,
674 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
675 wined3d_device_set_render_state(device
->wined3d_device
,
676 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
677 wined3d_device_set_render_state(device
->wined3d_device
,
678 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
679 wined3d_device_set_render_state(device
->wined3d_device
,
680 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
681 wined3d_mutex_unlock();
684 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
685 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
687 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
688 const D3D11_DEPTH_STENCILOP_DESC
*stencil_desc
;
689 const D3D11_DEPTH_STENCIL_DESC
*desc
;
691 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
692 iface
, depth_stencil_state
, stencil_ref
);
694 wined3d_mutex_lock();
695 device
->stencil_ref
= stencil_ref
;
696 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
698 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
699 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
700 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, D3D11_COMPARISON_LESS
);
701 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
702 wined3d_mutex_unlock();
706 desc
= &device
->depth_stencil_state
->desc
;
708 if (desc
->FrontFace
.StencilFailOp
!= desc
->BackFace
.StencilFailOp
709 || desc
->FrontFace
.StencilDepthFailOp
!= desc
->BackFace
.StencilDepthFailOp
710 || desc
->FrontFace
.StencilPassOp
!= desc
->BackFace
.StencilPassOp
711 || desc
->FrontFace
.StencilFunc
!= desc
->BackFace
.StencilFunc
)
712 FIXME("Two-sided stencil testing not supported.\n");
714 stencil_desc
= &desc
->FrontFace
;
716 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
717 if (desc
->DepthEnable
)
719 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
720 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
723 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
724 if (desc
->StencilEnable
)
726 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
727 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
728 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, stencil_desc
->StencilFailOp
);
729 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
,
730 stencil_desc
->StencilDepthFailOp
);
731 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, stencil_desc
->StencilPassOp
);
732 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, stencil_desc
->StencilFunc
);
733 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
735 wined3d_mutex_unlock();
738 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
739 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
741 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
742 unsigned int count
, i
;
744 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
746 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
747 wined3d_mutex_lock();
748 for (i
= 0; i
< count
; ++i
)
750 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
752 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
753 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
755 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
757 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
759 wined3d_mutex_unlock();
762 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
764 FIXME("iface %p stub!\n", iface
);
767 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext
*iface
,
768 ID3D11Buffer
*buffer
, UINT offset
)
770 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
773 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
774 ID3D11Buffer
*buffer
, UINT offset
)
776 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
779 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
780 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
782 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
783 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
786 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
787 ID3D11Buffer
*buffer
, UINT offset
)
789 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
792 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
793 ID3D11RasterizerState
*rasterizer_state
)
795 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
796 const D3D11_RASTERIZER_DESC
*desc
;
798 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
800 wined3d_mutex_lock();
801 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
803 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
804 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_CCW
);
805 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
806 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
807 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
808 wined3d_mutex_unlock();
812 desc
= &device
->rasterizer_state
->desc
;
813 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
814 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
816 if (desc
->FrontCounterClockwise
)
817 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc
->FrontCounterClockwise
);
818 /* OpenGL style depth bias. */
819 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
820 FIXME("Ignoring depth bias.\n");
822 if (!desc
->DepthClipEnable
)
823 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
824 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
825 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
826 wined3d_device_set_render_state(device
->wined3d_device
,
827 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
828 wined3d_mutex_unlock();
831 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
832 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
834 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
835 struct wined3d_viewport wined3d_vp
;
837 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
839 if (viewport_count
> 1)
840 FIXME("Multiple viewports not implemented.\n");
845 if (viewports
[0].TopLeftX
!= (UINT
)viewports
[0].TopLeftX
846 || viewports
[0].TopLeftY
!= (UINT
)viewports
[0].TopLeftY
847 || viewports
[0].Width
!= (UINT
)viewports
[0].Width
848 || viewports
[0].Height
!= (UINT
)viewports
[0].Height
)
849 FIXME("Floating-point viewports not implemented.\n");
851 wined3d_vp
.x
= viewports
[0].TopLeftX
;
852 wined3d_vp
.y
= viewports
[0].TopLeftY
;
853 wined3d_vp
.width
= viewports
[0].Width
;
854 wined3d_vp
.height
= viewports
[0].Height
;
855 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
856 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
858 wined3d_mutex_lock();
859 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
860 wined3d_mutex_unlock();
863 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
864 UINT rect_count
, const D3D11_RECT
*rects
)
866 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
868 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
871 FIXME("Multiple scissor rects not implemented.\n");
876 wined3d_mutex_lock();
877 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
878 wined3d_mutex_unlock();
881 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
882 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
883 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
885 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
886 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
887 struct wined3d_box wined3d_src_box
;
889 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
890 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
891 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
892 src_resource
, src_subresource_idx
, src_box
);
896 wined3d_src_box
.left
= src_box
->left
;
897 wined3d_src_box
.top
= src_box
->top
;
898 wined3d_src_box
.front
= src_box
->front
;
899 wined3d_src_box
.right
= src_box
->right
;
900 wined3d_src_box
.bottom
= src_box
->bottom
;
901 wined3d_src_box
.back
= src_box
->back
;
904 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
905 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
906 wined3d_mutex_lock();
907 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
908 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
909 wined3d_mutex_unlock();
912 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
913 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
915 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
916 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
918 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
920 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
921 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
922 wined3d_mutex_lock();
923 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
924 wined3d_mutex_unlock();
927 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
928 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
929 const void *data
, UINT row_pitch
, UINT depth_pitch
)
931 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
932 struct wined3d_resource
*wined3d_resource
;
933 struct wined3d_box wined3d_box
;
935 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
936 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
940 wined3d_box
.left
= box
->left
;
941 wined3d_box
.top
= box
->top
;
942 wined3d_box
.front
= box
->front
;
943 wined3d_box
.right
= box
->right
;
944 wined3d_box
.bottom
= box
->bottom
;
945 wined3d_box
.back
= box
->back
;
948 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
949 wined3d_mutex_lock();
950 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
951 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
952 wined3d_mutex_unlock();
955 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
956 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
958 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
959 iface
, dst_buffer
, dst_offset
, src_view
);
962 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
963 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
965 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
966 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
967 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
970 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
971 iface
, render_target_view
, debug_float4(color_rgba
));
976 wined3d_mutex_lock();
977 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
978 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
979 ERR("Failed to clear view, hr %#x.\n", hr
);
980 wined3d_mutex_unlock();
983 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
984 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
986 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
987 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
990 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
991 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
993 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
994 iface
, unordered_access_view
, debug_float4(values
));
997 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
998 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1000 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1001 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1002 DWORD wined3d_flags
;
1005 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1006 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1011 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1013 wined3d_mutex_lock();
1014 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1015 wined3d_flags
, NULL
, depth
, stencil
)))
1016 ERR("Failed to clear view, hr %#x.\n", hr
);
1017 wined3d_mutex_unlock();
1020 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1021 ID3D11ShaderResourceView
*view
)
1023 FIXME("iface %p, view %p stub!\n", iface
, view
);
1026 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1027 ID3D11Resource
*resource
, FLOAT min_lod
)
1029 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1032 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1033 ID3D11Resource
*resource
)
1035 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1040 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1041 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1042 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1045 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1046 "format %s stub!\n",
1047 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1048 debug_dxgi_format(format
));
1051 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1052 ID3D11CommandList
*command_list
, BOOL restore_state
)
1054 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1057 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1058 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1060 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1061 iface
, start_slot
, view_count
, views
);
1064 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1065 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1067 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1068 iface
, shader
, class_instances
, class_instance_count
);
1071 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1072 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1074 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1075 iface
, start_slot
, sampler_count
, samplers
);
1078 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1079 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1081 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1082 iface
, start_slot
, buffer_count
, buffers
);
1085 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1086 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1088 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1089 iface
, start_slot
, view_count
, views
);
1092 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1093 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1095 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1096 iface
, shader
, class_instances
, class_instance_count
);
1099 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1100 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1102 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1103 iface
, start_slot
, sampler_count
, samplers
);
1106 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1107 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1109 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1110 iface
, start_slot
, buffer_count
, buffers
);
1113 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1114 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1116 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1117 iface
, start_slot
, view_count
, views
);
1120 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1121 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1123 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1124 iface
, start_slot
, view_count
, views
, initial_counts
);
1127 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1128 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1130 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1131 iface
, shader
, class_instances
, class_instance_count
);
1134 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1135 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1137 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1138 iface
, start_slot
, sampler_count
, samplers
);
1141 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1142 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1144 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1145 iface
, start_slot
, buffer_count
, buffers
);
1148 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1149 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1151 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1154 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1155 iface
, start_slot
, buffer_count
, buffers
);
1157 wined3d_mutex_lock();
1158 for (i
= 0; i
< buffer_count
; ++i
)
1160 struct wined3d_buffer
*wined3d_buffer
;
1161 struct d3d_buffer
*buffer_impl
;
1163 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1169 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1170 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1171 ID3D11Buffer_AddRef(buffers
[i
]);
1173 wined3d_mutex_unlock();
1176 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1177 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1179 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1182 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1183 iface
, start_slot
, view_count
, views
);
1185 wined3d_mutex_lock();
1186 for (i
= 0; i
< view_count
; ++i
)
1188 struct wined3d_shader_resource_view
*wined3d_view
;
1189 struct d3d_shader_resource_view
*view_impl
;
1191 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1197 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1198 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1199 ID3D11ShaderResourceView_AddRef(views
[i
]);
1201 wined3d_mutex_unlock();
1204 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1205 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1207 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1208 struct wined3d_shader
*wined3d_shader
;
1209 struct d3d_pixel_shader
*shader_impl
;
1211 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1212 iface
, shader
, class_instances
, class_instance_count
);
1214 if (class_instances
|| class_instance_count
)
1215 FIXME("Dynamic linking not implemented yet.\n");
1217 wined3d_mutex_lock();
1218 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1220 wined3d_mutex_unlock();
1225 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1226 wined3d_mutex_unlock();
1227 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1228 ID3D11PixelShader_AddRef(*shader
);
1231 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1232 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1234 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1237 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1238 iface
, start_slot
, sampler_count
, samplers
);
1240 wined3d_mutex_lock();
1241 for (i
= 0; i
< sampler_count
; ++i
)
1243 struct wined3d_sampler
*wined3d_sampler
;
1244 struct d3d_sampler_state
*sampler_impl
;
1246 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1252 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1253 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1254 ID3D11SamplerState_AddRef(samplers
[i
]);
1256 wined3d_mutex_unlock();
1259 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1260 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1262 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1263 struct d3d_vertex_shader
*shader_impl
;
1264 struct wined3d_shader
*wined3d_shader
;
1266 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1267 iface
, shader
, class_instances
, class_instance_count
);
1269 if (class_instances
|| class_instance_count
)
1270 FIXME("Dynamic linking not implemented yet.\n");
1272 wined3d_mutex_lock();
1273 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1275 wined3d_mutex_unlock();
1280 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1281 wined3d_mutex_unlock();
1282 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1283 ID3D11VertexShader_AddRef(*shader
);
1286 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1287 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1289 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1292 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1293 iface
, start_slot
, buffer_count
, buffers
);
1295 wined3d_mutex_lock();
1296 for (i
= 0; i
< buffer_count
; ++i
)
1298 struct wined3d_buffer
*wined3d_buffer
;
1299 struct d3d_buffer
*buffer_impl
;
1301 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1307 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1308 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1309 ID3D11Buffer_AddRef(buffers
[i
]);
1311 wined3d_mutex_unlock();
1314 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1315 ID3D11InputLayout
**input_layout
)
1317 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1318 struct wined3d_vertex_declaration
*wined3d_declaration
;
1319 struct d3d_input_layout
*input_layout_impl
;
1321 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1323 wined3d_mutex_lock();
1324 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1326 wined3d_mutex_unlock();
1327 *input_layout
= NULL
;
1331 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1332 wined3d_mutex_unlock();
1333 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1334 ID3D11InputLayout_AddRef(*input_layout
);
1337 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1338 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1340 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1341 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1344 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1345 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1347 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface
, buffer
, format
, offset
);
1350 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1351 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1353 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1356 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1357 iface
, start_slot
, buffer_count
, buffers
);
1359 wined3d_mutex_lock();
1360 for (i
= 0; i
< buffer_count
; ++i
)
1362 struct wined3d_buffer
*wined3d_buffer
;
1363 struct d3d_buffer
*buffer_impl
;
1365 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1371 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1372 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1373 ID3D11Buffer_AddRef(buffers
[i
]);
1375 wined3d_mutex_unlock();
1378 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1379 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1381 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1382 struct d3d_geometry_shader
*shader_impl
;
1383 struct wined3d_shader
*wined3d_shader
;
1385 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1386 iface
, shader
, class_instances
, class_instance_count
);
1388 if (class_instances
|| class_instance_count
)
1389 FIXME("Dynamic linking not implemented yet.\n");
1391 wined3d_mutex_lock();
1392 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1394 wined3d_mutex_unlock();
1399 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1400 wined3d_mutex_unlock();
1401 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1402 ID3D11GeometryShader_AddRef(*shader
);
1405 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1406 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1408 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1410 TRACE("iface %p, topology %p.\n", iface
, topology
);
1412 wined3d_mutex_lock();
1413 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1414 wined3d_mutex_unlock();
1417 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1418 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1420 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1423 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1425 wined3d_mutex_lock();
1426 for (i
= 0; i
< view_count
; ++i
)
1428 struct wined3d_shader_resource_view
*wined3d_view
;
1429 struct d3d_shader_resource_view
*view_impl
;
1431 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1437 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1438 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1439 ID3D11ShaderResourceView_AddRef(views
[i
]);
1441 wined3d_mutex_unlock();
1444 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1445 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1447 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1450 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1451 iface
, start_slot
, sampler_count
, samplers
);
1453 wined3d_mutex_lock();
1454 for (i
= 0; i
< sampler_count
; ++i
)
1456 struct wined3d_sampler
*wined3d_sampler
;
1457 struct d3d_sampler_state
*sampler_impl
;
1459 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1465 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1466 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1467 ID3D11SamplerState_AddRef(samplers
[i
]);
1469 wined3d_mutex_unlock();
1472 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1473 ID3D11Predicate
**predicate
, BOOL
*value
)
1475 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1476 struct wined3d_query
*wined3d_predicate
;
1477 struct d3d_query
*predicate_impl
;
1479 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1481 wined3d_mutex_lock();
1482 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1484 wined3d_mutex_unlock();
1489 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1490 wined3d_mutex_unlock();
1491 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1492 ID3D11Predicate_AddRef(*predicate
);
1495 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1496 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1498 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1501 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1503 wined3d_mutex_lock();
1504 for (i
= 0; i
< view_count
; ++i
)
1506 struct wined3d_shader_resource_view
*wined3d_view
;
1507 struct d3d_shader_resource_view
*view_impl
;
1509 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1515 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1516 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1517 ID3D11ShaderResourceView_AddRef(views
[i
]);
1519 wined3d_mutex_unlock();
1522 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1523 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1525 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1528 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1529 iface
, start_slot
, sampler_count
, samplers
);
1531 wined3d_mutex_lock();
1532 for (i
= 0; i
< sampler_count
; ++i
)
1534 struct d3d_sampler_state
*sampler_impl
;
1535 struct wined3d_sampler
*wined3d_sampler
;
1537 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1543 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1544 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1545 ID3D11SamplerState_AddRef(samplers
[i
]);
1547 wined3d_mutex_unlock();
1550 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1551 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1552 ID3D11DepthStencilView
**depth_stencil_view
)
1554 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1555 struct wined3d_rendertarget_view
*wined3d_view
;
1557 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1558 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1560 wined3d_mutex_lock();
1561 if (render_target_views
)
1563 struct d3d_rendertarget_view
*view_impl
;
1566 for (i
= 0; i
< render_target_view_count
; ++i
)
1568 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1569 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1571 render_target_views
[i
] = NULL
;
1575 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1576 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1580 if (depth_stencil_view
)
1582 struct d3d_depthstencil_view
*view_impl
;
1584 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1585 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1587 *depth_stencil_view
= NULL
;
1591 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1592 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1595 wined3d_mutex_unlock();
1598 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1599 ID3D11DeviceContext
*iface
,
1600 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1601 ID3D11DepthStencilView
**depth_stencil_view
,
1602 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1603 ID3D11UnorderedAccessView
**unordered_access_views
)
1605 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1606 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1607 "unordered_access_views %p stub!\n",
1608 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1609 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1612 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1613 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1615 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1616 iface
, blend_state
, blend_factor
, sample_mask
);
1619 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1620 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1622 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface
, depth_stencil_state
, stencil_ref
);
1625 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1626 UINT buffer_count
, ID3D11Buffer
**buffers
)
1628 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1631 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1633 wined3d_mutex_lock();
1634 for (i
= 0; i
< buffer_count
; ++i
)
1636 struct wined3d_buffer
*wined3d_buffer
;
1637 struct d3d_buffer
*buffer_impl
;
1639 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1645 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1646 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1647 ID3D11Buffer_AddRef(buffers
[i
]);
1649 wined3d_mutex_unlock();
1652 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
1653 ID3D11RasterizerState
**rasterizer_state
)
1655 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1657 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1659 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D11RasterizerState_iface
: NULL
))
1660 ID3D11RasterizerState_AddRef(*rasterizer_state
);
1663 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
1664 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1666 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1667 struct wined3d_viewport wined3d_vp
;
1669 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1673 *viewport_count
= 1;
1677 if (!*viewport_count
)
1680 wined3d_mutex_lock();
1681 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1682 wined3d_mutex_unlock();
1684 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1685 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1686 viewports
[0].Width
= wined3d_vp
.width
;
1687 viewports
[0].Height
= wined3d_vp
.height
;
1688 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1689 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1691 if (*viewport_count
> 1)
1692 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1695 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
1696 UINT
*rect_count
, D3D11_RECT
*rects
)
1698 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface
, rect_count
, rects
);
1701 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
1702 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1704 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1707 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
1708 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1710 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1711 iface
, shader
, class_instances
, class_instance_count
);
1714 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
1715 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1717 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1718 iface
, start_slot
, sampler_count
, samplers
);
1721 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1722 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1724 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1725 iface
, start_slot
, buffer_count
, buffers
);
1728 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
1729 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1731 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1732 iface
, start_slot
, view_count
, views
);
1735 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
1736 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1738 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1739 iface
, shader
, class_instances
, class_instance_count
);
1742 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
1743 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1745 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1746 iface
, start_slot
, sampler_count
, samplers
);
1749 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1750 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1752 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1753 iface
, start_slot
, buffer_count
, buffers
);
1756 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
1757 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1759 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1762 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1763 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
1765 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1768 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
1769 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1771 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1772 iface
, shader
, class_instances
, class_instance_count
);
1775 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
1776 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1778 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1779 iface
, start_slot
, sampler_count
, samplers
);
1782 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1783 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1785 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1786 iface
, start_slot
, buffer_count
, buffers
);
1789 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
1791 FIXME("iface %p stub!\n", iface
);
1794 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
1796 FIXME("iface %p stub!\n", iface
);
1799 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
1801 TRACE("iface %p.\n", iface
);
1803 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
1806 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
1808 FIXME("iface %p stub!\n", iface
);
1813 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
1814 BOOL restore
, ID3D11CommandList
**command_list
)
1816 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
1821 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
1823 /* IUnknown methods */
1824 d3d11_immediate_context_QueryInterface
,
1825 d3d11_immediate_context_AddRef
,
1826 d3d11_immediate_context_Release
,
1827 /* ID3D11DeviceChild methods */
1828 d3d11_immediate_context_GetDevice
,
1829 d3d11_immediate_context_GetPrivateData
,
1830 d3d11_immediate_context_SetPrivateData
,
1831 d3d11_immediate_context_SetPrivateDataInterface
,
1832 /* ID3D11DeviceContext methods */
1833 d3d11_immediate_context_VSSetConstantBuffers
,
1834 d3d11_immediate_context_PSSetShaderResources
,
1835 d3d11_immediate_context_PSSetShader
,
1836 d3d11_immediate_context_PSSetSamplers
,
1837 d3d11_immediate_context_VSSetShader
,
1838 d3d11_immediate_context_DrawIndexed
,
1839 d3d11_immediate_context_Draw
,
1840 d3d11_immediate_context_Map
,
1841 d3d11_immediate_context_Unmap
,
1842 d3d11_immediate_context_PSSetConstantBuffers
,
1843 d3d11_immediate_context_IASetInputLayout
,
1844 d3d11_immediate_context_IASetVertexBuffers
,
1845 d3d11_immediate_context_IASetIndexBuffer
,
1846 d3d11_immediate_context_DrawIndexedInstanced
,
1847 d3d11_immediate_context_DrawInstanced
,
1848 d3d11_immediate_context_GSSetConstantBuffers
,
1849 d3d11_immediate_context_GSSetShader
,
1850 d3d11_immediate_context_IASetPrimitiveTopology
,
1851 d3d11_immediate_context_VSSetShaderResources
,
1852 d3d11_immediate_context_VSSetSamplers
,
1853 d3d11_immediate_context_Begin
,
1854 d3d11_immediate_context_End
,
1855 d3d11_immediate_context_GetData
,
1856 d3d11_immediate_context_SetPredication
,
1857 d3d11_immediate_context_GSSetShaderResources
,
1858 d3d11_immediate_context_GSSetSamplers
,
1859 d3d11_immediate_context_OMSetRenderTargets
,
1860 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
1861 d3d11_immediate_context_OMSetBlendState
,
1862 d3d11_immediate_context_OMSetDepthStencilState
,
1863 d3d11_immediate_context_SOSetTargets
,
1864 d3d11_immediate_context_DrawAuto
,
1865 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
1866 d3d11_immediate_context_DrawInstancedIndirect
,
1867 d3d11_immediate_context_Dispatch
,
1868 d3d11_immediate_context_DispatchIndirect
,
1869 d3d11_immediate_context_RSSetState
,
1870 d3d11_immediate_context_RSSetViewports
,
1871 d3d11_immediate_context_RSSetScissorRects
,
1872 d3d11_immediate_context_CopySubresourceRegion
,
1873 d3d11_immediate_context_CopyResource
,
1874 d3d11_immediate_context_UpdateSubresource
,
1875 d3d11_immediate_context_CopyStructureCount
,
1876 d3d11_immediate_context_ClearRenderTargetView
,
1877 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
1878 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
1879 d3d11_immediate_context_ClearDepthStencilView
,
1880 d3d11_immediate_context_GenerateMips
,
1881 d3d11_immediate_context_SetResourceMinLOD
,
1882 d3d11_immediate_context_GetResourceMinLOD
,
1883 d3d11_immediate_context_ResolveSubresource
,
1884 d3d11_immediate_context_ExecuteCommandList
,
1885 d3d11_immediate_context_HSSetShaderResources
,
1886 d3d11_immediate_context_HSSetShader
,
1887 d3d11_immediate_context_HSSetSamplers
,
1888 d3d11_immediate_context_HSSetConstantBuffers
,
1889 d3d11_immediate_context_DSSetShaderResources
,
1890 d3d11_immediate_context_DSSetShader
,
1891 d3d11_immediate_context_DSSetSamplers
,
1892 d3d11_immediate_context_DSSetConstantBuffers
,
1893 d3d11_immediate_context_CSSetShaderResources
,
1894 d3d11_immediate_context_CSSetUnorderedAccessViews
,
1895 d3d11_immediate_context_CSSetShader
,
1896 d3d11_immediate_context_CSSetSamplers
,
1897 d3d11_immediate_context_CSSetConstantBuffers
,
1898 d3d11_immediate_context_VSGetConstantBuffers
,
1899 d3d11_immediate_context_PSGetShaderResources
,
1900 d3d11_immediate_context_PSGetShader
,
1901 d3d11_immediate_context_PSGetSamplers
,
1902 d3d11_immediate_context_VSGetShader
,
1903 d3d11_immediate_context_PSGetConstantBuffers
,
1904 d3d11_immediate_context_IAGetInputLayout
,
1905 d3d11_immediate_context_IAGetVertexBuffers
,
1906 d3d11_immediate_context_IAGetIndexBuffer
,
1907 d3d11_immediate_context_GSGetConstantBuffers
,
1908 d3d11_immediate_context_GSGetShader
,
1909 d3d11_immediate_context_IAGetPrimitiveTopology
,
1910 d3d11_immediate_context_VSGetShaderResources
,
1911 d3d11_immediate_context_VSGetSamplers
,
1912 d3d11_immediate_context_GetPredication
,
1913 d3d11_immediate_context_GSGetShaderResources
,
1914 d3d11_immediate_context_GSGetSamplers
,
1915 d3d11_immediate_context_OMGetRenderTargets
,
1916 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
1917 d3d11_immediate_context_OMGetBlendState
,
1918 d3d11_immediate_context_OMGetDepthStencilState
,
1919 d3d11_immediate_context_SOGetTargets
,
1920 d3d11_immediate_context_RSGetState
,
1921 d3d11_immediate_context_RSGetViewports
,
1922 d3d11_immediate_context_RSGetScissorRects
,
1923 d3d11_immediate_context_HSGetShaderResources
,
1924 d3d11_immediate_context_HSGetShader
,
1925 d3d11_immediate_context_HSGetSamplers
,
1926 d3d11_immediate_context_HSGetConstantBuffers
,
1927 d3d11_immediate_context_DSGetShaderResources
,
1928 d3d11_immediate_context_DSGetShader
,
1929 d3d11_immediate_context_DSGetSamplers
,
1930 d3d11_immediate_context_DSGetConstantBuffers
,
1931 d3d11_immediate_context_CSGetShaderResources
,
1932 d3d11_immediate_context_CSGetUnorderedAccessViews
,
1933 d3d11_immediate_context_CSGetShader
,
1934 d3d11_immediate_context_CSGetSamplers
,
1935 d3d11_immediate_context_CSGetConstantBuffers
,
1936 d3d11_immediate_context_ClearState
,
1937 d3d11_immediate_context_Flush
,
1938 d3d11_immediate_context_GetType
,
1939 d3d11_immediate_context_GetContextFlags
,
1940 d3d11_immediate_context_FinishCommandList
,
1943 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
1945 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
1946 context
->refcount
= 1;
1948 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
1950 wined3d_private_store_init(&context
->private_store
);
1953 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
1955 wined3d_private_store_cleanup(&context
->private_store
);
1958 /* ID3D11Device methods */
1960 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
1962 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1963 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
1966 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
1968 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1969 return IUnknown_AddRef(device
->outer_unk
);
1972 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
1974 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1975 return IUnknown_Release(device
->outer_unk
);
1978 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
1979 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
1981 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1982 struct d3d_buffer
*object
;
1985 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
1987 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
1990 *buffer
= &object
->ID3D11Buffer_iface
;
1995 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
1996 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
1998 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2003 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
2004 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2006 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2007 struct d3d_texture2d
*object
;
2010 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2012 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2015 *texture
= &object
->ID3D11Texture2D_iface
;
2020 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2021 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2023 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2024 struct d3d_texture3d
*object
;
2027 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2029 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2032 *texture
= &object
->ID3D11Texture3D_iface
;
2037 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2038 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2040 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2041 struct d3d_shader_resource_view
*object
;
2044 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2046 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2049 *view
= &object
->ID3D11ShaderResourceView_iface
;
2054 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2055 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2057 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
2062 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2063 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2065 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2066 struct d3d_rendertarget_view
*object
;
2069 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2071 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2074 *view
= &object
->ID3D11RenderTargetView_iface
;
2079 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2080 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2082 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2083 struct d3d_depthstencil_view
*object
;
2086 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2088 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2091 *view
= &object
->ID3D11DepthStencilView_iface
;
2096 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2097 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2098 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2100 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2101 struct d3d_input_layout
*object
;
2104 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2105 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2106 shader_byte_code_length
, input_layout
);
2108 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2109 shader_byte_code
, shader_byte_code_length
, &object
)))
2112 *input_layout
= &object
->ID3D11InputLayout_iface
;
2117 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2118 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2120 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2121 struct d3d_vertex_shader
*object
;
2124 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2125 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2128 FIXME("Class linkage is not implemented yet.\n");
2130 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2133 *shader
= &object
->ID3D11VertexShader_iface
;
2138 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2139 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2141 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2142 struct d3d_geometry_shader
*object
;
2145 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2146 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2149 FIXME("Class linkage is not implemented yet.\n");
2151 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2154 *shader
= &object
->ID3D11GeometryShader_iface
;
2159 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2160 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2161 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
2162 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2164 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2165 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2166 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2167 rasterized_stream
, class_linkage
, shader
);
2172 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2173 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2175 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2176 struct d3d_pixel_shader
*object
;
2179 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2180 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2183 FIXME("Class linkage is not implemented yet.\n");
2185 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2188 *shader
= &object
->ID3D11PixelShader_iface
;
2193 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2194 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2196 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2197 struct d3d11_hull_shader
*object
;
2200 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2201 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2204 FIXME("Class linkage is not implemented yet.\n");
2206 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2209 *shader
= &object
->ID3D11HullShader_iface
;
2214 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2215 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2217 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2218 struct d3d11_domain_shader
*object
;
2221 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2222 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2225 FIXME("Class linkage is not implemented yet.\n");
2227 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2230 *shader
= &object
->ID3D11DomainShader_iface
;
2235 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2236 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2238 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2239 struct d3d11_compute_shader
*object
;
2242 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2243 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2246 FIXME("Class linkage is not implemented yet.\n");
2248 if (FAILED(hr
= d3d11_compute_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2251 *shader
= &object
->ID3D11ComputeShader_iface
;
2256 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2257 ID3D11ClassLinkage
**class_linkage
)
2259 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2260 struct d3d11_class_linkage
*object
;
2263 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
2265 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
2268 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
2273 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
2274 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
2276 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2277 struct d3d_blend_state
*object
;
2278 struct wine_rb_entry
*entry
;
2279 D3D11_BLEND_DESC tmp_desc
;
2283 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2286 return E_INVALIDARG
;
2288 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2289 * D3D11_BLEND_DESC as a key in the rbtree. */
2290 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2291 tmp_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
2292 tmp_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
2293 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2295 j
= desc
->IndependentBlendEnable
? i
: 0;
2296 tmp_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[j
].BlendEnable
;
2297 tmp_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[j
].SrcBlend
;
2298 tmp_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[j
].DestBlend
;
2299 tmp_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[j
].BlendOp
;
2300 tmp_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[j
].SrcBlendAlpha
;
2301 tmp_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[j
].DestBlendAlpha
;
2302 tmp_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[j
].BlendOpAlpha
;
2303 tmp_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[j
].RenderTargetWriteMask
;
2306 wined3d_mutex_lock();
2307 if ((entry
= wine_rb_get(&device
->blend_states
, &tmp_desc
)))
2309 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_blend_state
, entry
);
2311 TRACE("Returning existing blend state %p.\n", object
);
2312 *blend_state
= &object
->ID3D11BlendState_iface
;
2313 ID3D11BlendState_AddRef(*blend_state
);
2314 wined3d_mutex_unlock();
2318 wined3d_mutex_unlock();
2320 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2321 return E_OUTOFMEMORY
;
2323 if (FAILED(hr
= d3d_blend_state_init(object
, device
, &tmp_desc
)))
2325 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2326 HeapFree(GetProcessHeap(), 0, object
);
2330 TRACE("Created blend state %p.\n", object
);
2331 *blend_state
= &object
->ID3D11BlendState_iface
;
2336 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
2337 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
2339 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2340 struct d3d_depthstencil_state
*object
;
2341 D3D11_DEPTH_STENCIL_DESC tmp_desc
;
2342 struct wine_rb_entry
*entry
;
2345 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2348 return E_INVALIDARG
;
2350 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2351 * it as a key in the rbtree. */
2352 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2353 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2354 if (desc
->DepthEnable
)
2356 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2357 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2361 tmp_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
2362 tmp_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
2364 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2365 if (desc
->StencilEnable
)
2367 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2368 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2369 tmp_desc
.FrontFace
= desc
->FrontFace
;
2370 tmp_desc
.BackFace
= desc
->BackFace
;
2374 tmp_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
2375 tmp_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
2376 tmp_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2377 tmp_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2378 tmp_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2379 tmp_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2380 tmp_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2381 tmp_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2382 tmp_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2383 tmp_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2386 wined3d_mutex_lock();
2387 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2389 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_depthstencil_state
, entry
);
2391 TRACE("Returning existing depthstencil state %p.\n", object
);
2392 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2393 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
2394 wined3d_mutex_unlock();
2398 wined3d_mutex_unlock();
2400 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2401 return E_OUTOFMEMORY
;
2403 if (FAILED(hr
= d3d_depthstencil_state_init(object
, device
, &tmp_desc
)))
2405 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2406 HeapFree(GetProcessHeap(), 0, object
);
2410 TRACE("Created depthstencil state %p.\n", object
);
2411 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2416 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
2417 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
2419 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2420 struct d3d_rasterizer_state
*object
;
2421 struct wine_rb_entry
*entry
;
2424 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2427 return E_INVALIDARG
;
2429 wined3d_mutex_lock();
2430 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2432 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_rasterizer_state
, entry
);
2434 TRACE("Returning existing rasterizer state %p.\n", object
);
2435 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2436 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2437 wined3d_mutex_unlock();
2441 wined3d_mutex_unlock();
2443 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2444 return E_OUTOFMEMORY
;
2446 if (FAILED(hr
= d3d_rasterizer_state_init(object
, device
, desc
)))
2448 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2449 HeapFree(GetProcessHeap(), 0, object
);
2453 TRACE("Created rasterizer state %p.\n", object
);
2454 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2459 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
2460 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
2462 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2463 D3D11_SAMPLER_DESC normalized_desc
;
2464 struct d3d_sampler_state
*object
;
2465 struct wine_rb_entry
*entry
;
2468 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2471 return E_INVALIDARG
;
2473 normalized_desc
= *desc
;
2474 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc
.Filter
))
2475 normalized_desc
.MaxAnisotropy
= 0;
2476 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc
.Filter
))
2477 normalized_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
2478 if (normalized_desc
.AddressU
!= D3D11_TEXTURE_ADDRESS_BORDER
2479 && normalized_desc
.AddressV
!= D3D11_TEXTURE_ADDRESS_BORDER
2480 && normalized_desc
.AddressW
!= D3D11_TEXTURE_ADDRESS_BORDER
)
2481 memset(&normalized_desc
.BorderColor
, 0, sizeof(normalized_desc
.BorderColor
));
2483 wined3d_mutex_lock();
2484 if ((entry
= wine_rb_get(&device
->sampler_states
, &normalized_desc
)))
2486 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_sampler_state
, entry
);
2488 TRACE("Returning existing sampler state %p.\n", object
);
2489 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2490 ID3D11SamplerState_AddRef(*sampler_state
);
2491 wined3d_mutex_unlock();
2495 wined3d_mutex_unlock();
2497 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2498 return E_OUTOFMEMORY
;
2500 if (FAILED(hr
= d3d_sampler_state_init(object
, device
, &normalized_desc
)))
2502 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2503 HeapFree(GetProcessHeap(), 0, object
);
2507 TRACE("Created sampler state %p.\n", object
);
2508 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2513 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
2514 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
2516 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2517 struct d3d_query
*object
;
2520 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2522 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
2527 *query
= &object
->ID3D11Query_iface
;
2531 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2535 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
2536 ID3D11Predicate
**predicate
)
2538 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2539 struct d3d_query
*object
;
2542 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2544 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
2549 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
2553 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2557 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2558 ID3D11Counter
**counter
)
2560 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2565 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
2566 ID3D11DeviceContext
**context
)
2568 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
2573 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
2576 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
2581 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
2582 UINT
*format_support
)
2584 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
2589 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
2590 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2592 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2593 struct wined3d_device_creation_parameters params
;
2594 struct wined3d
*wined3d
;
2597 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
2598 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2600 if (!quality_level_count
)
2601 return E_INVALIDARG
;
2603 *quality_level_count
= 0;
2607 if (sample_count
== 1)
2609 *quality_level_count
= 1;
2612 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
2615 wined3d_mutex_lock();
2616 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
2617 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
2618 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
2619 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
2620 wined3d_mutex_unlock();
2622 if (hr
== WINED3DERR_INVALIDCALL
)
2623 return E_INVALIDARG
;
2624 if (hr
== WINED3DERR_NOTAVAILABLE
)
2629 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
2631 FIXME("iface %p, info %p stub!\n", iface
, info
);
2634 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2635 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
2636 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2638 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2639 "units %p, units_length %p, description %p, description_length %p stub!\n",
2640 iface
, desc
, type
, active_counter_count
, name
, name_length
,
2641 units
, units_length
, description
, description_length
);
2646 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
2647 void *feature_support_data
, UINT feature_support_data_size
)
2649 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2650 iface
, feature
, feature_support_data
, feature_support_data_size
);
2655 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2656 UINT
*data_size
, void *data
)
2658 IDXGIDevice
*dxgi_device
;
2661 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2663 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2665 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
2666 IDXGIDevice_Release(dxgi_device
);
2671 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2672 UINT data_size
, const void *data
)
2674 IDXGIDevice
*dxgi_device
;
2677 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2679 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2681 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
2682 IDXGIDevice_Release(dxgi_device
);
2687 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
2688 const IUnknown
*data
)
2690 IDXGIDevice
*dxgi_device
;
2693 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
2695 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2697 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
2698 IDXGIDevice_Release(dxgi_device
);
2703 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
2705 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2707 TRACE("iface %p.\n", iface
);
2709 return device
->feature_level
;
2712 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
2714 FIXME("iface %p stub!\n", iface
);
2719 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
2721 FIXME("iface %p stub!\n", iface
);
2726 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
2727 ID3D11DeviceContext
**immediate_context
)
2729 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2731 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
2733 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
2734 ID3D11DeviceContext_AddRef(*immediate_context
);
2737 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
2739 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2744 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
2746 FIXME("iface %p stub!\n", iface
);
2751 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
2753 /* IUnknown methods */
2754 d3d11_device_QueryInterface
,
2755 d3d11_device_AddRef
,
2756 d3d11_device_Release
,
2757 /* ID3D11Device methods */
2758 d3d11_device_CreateBuffer
,
2759 d3d11_device_CreateTexture1D
,
2760 d3d11_device_CreateTexture2D
,
2761 d3d11_device_CreateTexture3D
,
2762 d3d11_device_CreateShaderResourceView
,
2763 d3d11_device_CreateUnorderedAccessView
,
2764 d3d11_device_CreateRenderTargetView
,
2765 d3d11_device_CreateDepthStencilView
,
2766 d3d11_device_CreateInputLayout
,
2767 d3d11_device_CreateVertexShader
,
2768 d3d11_device_CreateGeometryShader
,
2769 d3d11_device_CreateGeometryShaderWithStreamOutput
,
2770 d3d11_device_CreatePixelShader
,
2771 d3d11_device_CreateHullShader
,
2772 d3d11_device_CreateDomainShader
,
2773 d3d11_device_CreateComputeShader
,
2774 d3d11_device_CreateClassLinkage
,
2775 d3d11_device_CreateBlendState
,
2776 d3d11_device_CreateDepthStencilState
,
2777 d3d11_device_CreateRasterizerState
,
2778 d3d11_device_CreateSamplerState
,
2779 d3d11_device_CreateQuery
,
2780 d3d11_device_CreatePredicate
,
2781 d3d11_device_CreateCounter
,
2782 d3d11_device_CreateDeferredContext
,
2783 d3d11_device_OpenSharedResource
,
2784 d3d11_device_CheckFormatSupport
,
2785 d3d11_device_CheckMultisampleQualityLevels
,
2786 d3d11_device_CheckCounterInfo
,
2787 d3d11_device_CheckCounter
,
2788 d3d11_device_CheckFeatureSupport
,
2789 d3d11_device_GetPrivateData
,
2790 d3d11_device_SetPrivateData
,
2791 d3d11_device_SetPrivateDataInterface
,
2792 d3d11_device_GetFeatureLevel
,
2793 d3d11_device_GetCreationFlags
,
2794 d3d11_device_GetDeviceRemovedReason
,
2795 d3d11_device_GetImmediateContext
,
2796 d3d11_device_SetExceptionMode
,
2797 d3d11_device_GetExceptionMode
,
2800 /* Inner IUnknown methods */
2802 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
2804 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
2807 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
2809 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2811 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
2813 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
2814 || IsEqualGUID(riid
, &IID_IUnknown
))
2816 *out
= &device
->ID3D11Device_iface
;
2818 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
2819 || IsEqualGUID(riid
, &IID_ID3D10Device
))
2821 *out
= &device
->ID3D10Device1_iface
;
2823 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
2825 *out
= &device
->ID3D10Multithread_iface
;
2827 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
2829 *out
= &device
->IWineDXGIDeviceParent_iface
;
2833 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
2835 return E_NOINTERFACE
;
2838 IUnknown_AddRef((IUnknown
*)*out
);
2842 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
2844 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2845 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
2847 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
2852 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
2854 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2855 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
2857 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
2861 d3d11_immediate_context_destroy(&device
->immediate_context
);
2862 if (device
->wined3d_device
)
2864 wined3d_mutex_lock();
2865 wined3d_device_decref(device
->wined3d_device
);
2866 wined3d_mutex_unlock();
2868 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
2869 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
2870 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
2871 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
2877 /* IUnknown methods */
2879 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
2882 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2883 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
2886 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
2888 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2889 return IUnknown_AddRef(device
->outer_unk
);
2892 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
2894 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2895 return IUnknown_Release(device
->outer_unk
);
2898 /* ID3D10Device methods */
2900 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
2901 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2903 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2906 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2907 iface
, start_slot
, buffer_count
, buffers
);
2909 wined3d_mutex_lock();
2910 for (i
= 0; i
< buffer_count
; ++i
)
2912 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2914 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
2915 buffer
? buffer
->wined3d_buffer
: NULL
);
2917 wined3d_mutex_unlock();
2920 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
2921 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
2923 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2926 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2927 iface
, start_slot
, view_count
, views
);
2929 wined3d_mutex_lock();
2930 for (i
= 0; i
< view_count
; ++i
)
2932 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
2934 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
2935 view
? view
->wined3d_view
: NULL
);
2937 wined3d_mutex_unlock();
2940 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
2941 ID3D10PixelShader
*shader
)
2943 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2944 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
2946 TRACE("iface %p, shader %p\n", iface
, shader
);
2948 wined3d_mutex_lock();
2949 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
2950 wined3d_mutex_unlock();
2953 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
2954 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
2956 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2959 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2960 iface
, start_slot
, sampler_count
, samplers
);
2962 wined3d_mutex_lock();
2963 for (i
= 0; i
< sampler_count
; ++i
)
2965 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
2967 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
2968 sampler
? sampler
->wined3d_sampler
: NULL
);
2970 wined3d_mutex_unlock();
2973 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
2974 ID3D10VertexShader
*shader
)
2976 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2977 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
2979 TRACE("iface %p, shader %p\n", iface
, shader
);
2981 wined3d_mutex_lock();
2982 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
2983 wined3d_mutex_unlock();
2986 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
2987 UINT start_index_location
, INT base_vertex_location
)
2989 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2991 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2992 iface
, index_count
, start_index_location
, base_vertex_location
);
2994 wined3d_mutex_lock();
2995 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
2996 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
2997 wined3d_mutex_unlock();
3000 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
3001 UINT start_vertex_location
)
3003 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3005 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
3006 iface
, vertex_count
, start_vertex_location
);
3008 wined3d_mutex_lock();
3009 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
3010 wined3d_mutex_unlock();
3013 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
3014 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3016 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3019 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3020 iface
, start_slot
, buffer_count
, buffers
);
3022 wined3d_mutex_lock();
3023 for (i
= 0; i
< buffer_count
; ++i
)
3025 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3027 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
3028 buffer
? buffer
->wined3d_buffer
: NULL
);
3030 wined3d_mutex_unlock();
3033 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
3034 ID3D10InputLayout
*input_layout
)
3036 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3037 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
3039 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
3041 wined3d_mutex_lock();
3042 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
3043 layout
? layout
->wined3d_decl
: NULL
);
3044 wined3d_mutex_unlock();
3047 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
3048 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
3050 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3053 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
3054 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3056 wined3d_mutex_lock();
3057 for (i
= 0; i
< buffer_count
; ++i
)
3059 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3061 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
3062 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3064 wined3d_mutex_unlock();
3067 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3068 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3070 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3071 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3073 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3074 iface
, buffer
, debug_dxgi_format(format
), offset
);
3076 wined3d_mutex_lock();
3077 wined3d_device_set_index_buffer(device
->wined3d_device
,
3078 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3079 wined3dformat_from_dxgi_format(format
), offset
);
3080 wined3d_mutex_unlock();
3083 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3084 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3085 INT base_vertex_location
, UINT start_instance_location
)
3087 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3089 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3090 "base_vertex_location %d, start_instance_location %u.\n",
3091 iface
, instance_index_count
, instance_count
, start_index_location
,
3092 base_vertex_location
, start_instance_location
);
3094 wined3d_mutex_lock();
3095 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3096 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3097 instance_index_count
, start_instance_location
, instance_count
);
3098 wined3d_mutex_unlock();
3101 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3102 UINT instance_vertex_count
, UINT instance_count
,
3103 UINT start_vertex_location
, UINT start_instance_location
)
3105 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3107 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3108 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3109 start_vertex_location
, start_instance_location
);
3111 wined3d_mutex_lock();
3112 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3113 instance_vertex_count
, start_instance_location
, instance_count
);
3114 wined3d_mutex_unlock();
3117 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3118 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3120 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3123 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3124 iface
, start_slot
, buffer_count
, buffers
);
3126 wined3d_mutex_lock();
3127 for (i
= 0; i
< buffer_count
; ++i
)
3129 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3131 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3132 buffer
? buffer
->wined3d_buffer
: NULL
);
3134 wined3d_mutex_unlock();
3137 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3139 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3140 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3142 TRACE("iface %p, shader %p.\n", iface
, shader
);
3144 wined3d_mutex_lock();
3145 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3146 wined3d_mutex_unlock();
3149 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3150 D3D10_PRIMITIVE_TOPOLOGY topology
)
3152 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3154 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
3156 wined3d_mutex_lock();
3157 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
3158 wined3d_mutex_unlock();
3161 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3162 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3164 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3167 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3168 iface
, start_slot
, view_count
, views
);
3170 wined3d_mutex_lock();
3171 for (i
= 0; i
< view_count
; ++i
)
3173 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3175 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3176 view
? view
->wined3d_view
: NULL
);
3178 wined3d_mutex_unlock();
3181 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3182 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3184 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3187 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3188 iface
, start_slot
, sampler_count
, samplers
);
3190 wined3d_mutex_lock();
3191 for (i
= 0; i
< sampler_count
; ++i
)
3193 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3195 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3196 sampler
? sampler
->wined3d_sampler
: NULL
);
3198 wined3d_mutex_unlock();
3201 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3203 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3204 struct d3d_query
*query
;
3206 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3208 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3209 wined3d_mutex_lock();
3210 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3211 wined3d_mutex_unlock();
3214 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3215 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3217 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3220 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3221 iface
, start_slot
, view_count
, views
);
3223 wined3d_mutex_lock();
3224 for (i
= 0; i
< view_count
; ++i
)
3226 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3228 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3229 view
? view
->wined3d_view
: NULL
);
3231 wined3d_mutex_unlock();
3234 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3235 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3237 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3240 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3241 iface
, start_slot
, sampler_count
, samplers
);
3243 wined3d_mutex_lock();
3244 for (i
= 0; i
< sampler_count
; ++i
)
3246 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3248 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3249 sampler
? sampler
->wined3d_sampler
: NULL
);
3251 wined3d_mutex_unlock();
3254 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3255 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3256 ID3D10DepthStencilView
*depth_stencil_view
)
3258 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3259 struct d3d_depthstencil_view
*dsv
;
3262 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3263 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3265 wined3d_mutex_lock();
3266 for (i
= 0; i
< render_target_view_count
; ++i
)
3268 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3270 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3271 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3273 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3275 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3278 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3279 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3280 dsv
? dsv
->wined3d_view
: NULL
);
3281 wined3d_mutex_unlock();
3284 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3285 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3287 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3288 struct d3d_blend_state
*blend_state_object
;
3290 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3291 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3293 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3294 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3295 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3298 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3299 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3301 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3302 struct d3d_depthstencil_state
*ds_state_object
;
3304 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3305 iface
, depth_stencil_state
, stencil_ref
);
3307 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3308 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3309 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
3312 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3313 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3315 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3316 unsigned int count
, i
;
3318 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3320 count
= min(target_count
, 4);
3321 wined3d_mutex_lock();
3322 for (i
= 0; i
< count
; ++i
)
3324 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
3326 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
3327 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
3330 for (i
= count
; i
< 4; ++i
)
3332 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
3334 wined3d_mutex_unlock();
3337 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
3339 FIXME("iface %p stub!\n", iface
);
3342 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
3344 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3345 struct d3d_rasterizer_state
*rasterizer_state_object
;
3347 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3349 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
3350 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3351 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
3354 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
3355 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
3357 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3358 struct wined3d_viewport wined3d_vp
;
3360 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
3362 if (viewport_count
> 1)
3363 FIXME("Multiple viewports not implemented.\n");
3365 if (!viewport_count
)
3368 wined3d_vp
.x
= viewports
[0].TopLeftX
;
3369 wined3d_vp
.y
= viewports
[0].TopLeftY
;
3370 wined3d_vp
.width
= viewports
[0].Width
;
3371 wined3d_vp
.height
= viewports
[0].Height
;
3372 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
3373 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
3375 wined3d_mutex_lock();
3376 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
3377 wined3d_mutex_unlock();
3380 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
3381 UINT rect_count
, const D3D10_RECT
*rects
)
3383 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3385 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
3388 FIXME("Multiple scissor rects not implemented.\n");
3393 wined3d_mutex_lock();
3394 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
3395 wined3d_mutex_unlock();
3398 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
3399 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
3400 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
3402 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3403 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3404 struct wined3d_box wined3d_src_box
;
3406 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3407 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3408 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
3409 src_resource
, src_subresource_idx
, src_box
);
3413 wined3d_src_box
.left
= src_box
->left
;
3414 wined3d_src_box
.top
= src_box
->top
;
3415 wined3d_src_box
.front
= src_box
->front
;
3416 wined3d_src_box
.right
= src_box
->right
;
3417 wined3d_src_box
.bottom
= src_box
->bottom
;
3418 wined3d_src_box
.back
= src_box
->back
;
3421 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3422 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3423 wined3d_mutex_lock();
3424 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
3425 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
3426 wined3d_mutex_unlock();
3429 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
3430 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
3432 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3433 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3435 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
3437 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3438 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3439 wined3d_mutex_lock();
3440 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
3441 wined3d_mutex_unlock();
3444 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
3445 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
3446 const void *data
, UINT row_pitch
, UINT depth_pitch
)
3448 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3449 ID3D11Resource
*d3d11_resource
;
3451 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3452 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
3454 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
3455 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3456 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
3457 ID3D11Resource_Release(d3d11_resource
);
3460 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
3461 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
3463 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3464 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
3465 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
3468 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
3469 iface
, render_target_view
, debug_float4(color_rgba
));
3474 wined3d_mutex_lock();
3475 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3476 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
3477 ERR("Failed to clear view, hr %#x.\n", hr
);
3478 wined3d_mutex_unlock();
3481 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
3482 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
3484 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3485 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3486 DWORD wined3d_flags
;
3489 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
3490 iface
, depth_stencil_view
, flags
, depth
, stencil
);
3495 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
3497 wined3d_mutex_lock();
3498 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3499 wined3d_flags
, NULL
, depth
, stencil
)))
3500 ERR("Failed to clear view, hr %#x.\n", hr
);
3501 wined3d_mutex_unlock();
3504 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
3505 ID3D10ShaderResourceView
*shader_resource_view
)
3507 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
3510 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
3511 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
3512 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
3514 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3515 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3516 iface
, dst_resource
, dst_subresource_idx
,
3517 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
3520 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
3521 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3523 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3526 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3527 iface
, start_slot
, buffer_count
, buffers
);
3529 wined3d_mutex_lock();
3530 for (i
= 0; i
< buffer_count
; ++i
)
3532 struct wined3d_buffer
*wined3d_buffer
;
3533 struct d3d_buffer
*buffer_impl
;
3535 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
3541 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3542 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3543 ID3D10Buffer_AddRef(buffers
[i
]);
3545 wined3d_mutex_unlock();
3548 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
3549 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3551 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3554 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3555 iface
, start_slot
, view_count
, views
);
3557 wined3d_mutex_lock();
3558 for (i
= 0; i
< view_count
; ++i
)
3560 struct wined3d_shader_resource_view
*wined3d_view
;
3561 struct d3d_shader_resource_view
*view_impl
;
3563 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3569 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3570 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3571 ID3D10ShaderResourceView_AddRef(views
[i
]);
3573 wined3d_mutex_unlock();
3576 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
3578 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3579 struct d3d_pixel_shader
*shader_impl
;
3580 struct wined3d_shader
*wined3d_shader
;
3582 TRACE("iface %p, shader %p.\n", iface
, shader
);
3584 wined3d_mutex_lock();
3585 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
3587 wined3d_mutex_unlock();
3592 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3593 wined3d_mutex_unlock();
3594 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
3595 ID3D10PixelShader_AddRef(*shader
);
3598 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
3599 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3601 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3604 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3605 iface
, start_slot
, sampler_count
, samplers
);
3607 wined3d_mutex_lock();
3608 for (i
= 0; i
< sampler_count
; ++i
)
3610 struct d3d_sampler_state
*sampler_impl
;
3611 struct wined3d_sampler
*wined3d_sampler
;
3613 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
3619 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3620 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3621 ID3D10SamplerState_AddRef(samplers
[i
]);
3623 wined3d_mutex_unlock();
3626 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
3628 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3629 struct d3d_vertex_shader
*shader_impl
;
3630 struct wined3d_shader
*wined3d_shader
;
3632 TRACE("iface %p, shader %p.\n", iface
, shader
);
3634 wined3d_mutex_lock();
3635 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
3637 wined3d_mutex_unlock();
3642 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3643 wined3d_mutex_unlock();
3644 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
3645 ID3D10VertexShader_AddRef(*shader
);
3648 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
3649 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3651 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3654 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3655 iface
, start_slot
, buffer_count
, buffers
);
3657 wined3d_mutex_lock();
3658 for (i
= 0; i
< buffer_count
; ++i
)
3660 struct wined3d_buffer
*wined3d_buffer
;
3661 struct d3d_buffer
*buffer_impl
;
3663 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
3669 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3670 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3671 ID3D10Buffer_AddRef(buffers
[i
]);
3673 wined3d_mutex_unlock();
3676 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
3678 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3679 struct wined3d_vertex_declaration
*wined3d_declaration
;
3680 struct d3d_input_layout
*input_layout_impl
;
3682 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
3684 wined3d_mutex_lock();
3685 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
3687 wined3d_mutex_unlock();
3688 *input_layout
= NULL
;
3692 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
3693 wined3d_mutex_unlock();
3694 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
3695 ID3D10InputLayout_AddRef(*input_layout
);
3698 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
3699 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
3701 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3704 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3705 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3707 wined3d_mutex_lock();
3708 for (i
= 0; i
< buffer_count
; ++i
)
3710 struct wined3d_buffer
*wined3d_buffer
;
3711 struct d3d_buffer
*buffer_impl
;
3713 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
3714 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
3715 ERR("Failed to get vertex buffer.\n");
3717 if (!wined3d_buffer
)
3723 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3724 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3725 ID3D10Buffer_AddRef(buffers
[i
]);
3727 wined3d_mutex_unlock();
3730 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
3731 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
3733 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3734 enum wined3d_format_id wined3d_format
;
3735 struct wined3d_buffer
*wined3d_buffer
;
3736 struct d3d_buffer
*buffer_impl
;
3738 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
3740 wined3d_mutex_lock();
3741 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
, offset
);
3742 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
3743 if (!wined3d_buffer
)
3745 wined3d_mutex_unlock();
3750 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3751 wined3d_mutex_unlock();
3752 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
3753 ID3D10Buffer_AddRef(*buffer
);
3756 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
3757 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3759 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3762 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3763 iface
, start_slot
, buffer_count
, buffers
);
3765 wined3d_mutex_lock();
3766 for (i
= 0; i
< buffer_count
; ++i
)
3768 struct wined3d_buffer
*wined3d_buffer
;
3769 struct d3d_buffer
*buffer_impl
;
3771 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
3777 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3778 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3779 ID3D10Buffer_AddRef(buffers
[i
]);
3781 wined3d_mutex_unlock();
3784 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
3786 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3787 struct d3d_geometry_shader
*shader_impl
;
3788 struct wined3d_shader
*wined3d_shader
;
3790 TRACE("iface %p, shader %p.\n", iface
, shader
);
3792 wined3d_mutex_lock();
3793 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
3795 wined3d_mutex_unlock();
3800 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3801 wined3d_mutex_unlock();
3802 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
3803 ID3D10GeometryShader_AddRef(*shader
);
3806 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
3807 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
3809 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3811 TRACE("iface %p, topology %p\n", iface
, topology
);
3813 wined3d_mutex_lock();
3814 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
3815 wined3d_mutex_unlock();
3818 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
3819 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3821 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3824 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3825 iface
, start_slot
, view_count
, views
);
3827 wined3d_mutex_lock();
3828 for (i
= 0; i
< view_count
; ++i
)
3830 struct wined3d_shader_resource_view
*wined3d_view
;
3831 struct d3d_shader_resource_view
*view_impl
;
3833 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3839 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3840 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3841 ID3D10ShaderResourceView_AddRef(views
[i
]);
3843 wined3d_mutex_unlock();
3846 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
3847 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3849 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3852 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3853 iface
, start_slot
, sampler_count
, samplers
);
3855 wined3d_mutex_lock();
3856 for (i
= 0; i
< sampler_count
; ++i
)
3858 struct d3d_sampler_state
*sampler_impl
;
3859 struct wined3d_sampler
*wined3d_sampler
;
3861 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3867 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3868 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3869 ID3D10SamplerState_AddRef(samplers
[i
]);
3871 wined3d_mutex_unlock();
3874 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
3875 ID3D10Predicate
**predicate
, BOOL
*value
)
3877 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3878 struct wined3d_query
*wined3d_predicate
;
3879 struct d3d_query
*predicate_impl
;
3881 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
3883 wined3d_mutex_lock();
3884 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
3886 wined3d_mutex_unlock();
3891 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
3892 wined3d_mutex_unlock();
3893 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
3894 ID3D10Predicate_AddRef(*predicate
);
3897 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
3898 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3900 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3903 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3904 iface
, start_slot
, view_count
, views
);
3906 wined3d_mutex_lock();
3907 for (i
= 0; i
< view_count
; ++i
)
3909 struct wined3d_shader_resource_view
*wined3d_view
;
3910 struct d3d_shader_resource_view
*view_impl
;
3912 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3918 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3919 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3920 ID3D10ShaderResourceView_AddRef(views
[i
]);
3922 wined3d_mutex_unlock();
3925 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
3926 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3928 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3931 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3932 iface
, start_slot
, sampler_count
, samplers
);
3934 wined3d_mutex_lock();
3935 for (i
= 0; i
< sampler_count
; ++i
)
3937 struct d3d_sampler_state
*sampler_impl
;
3938 struct wined3d_sampler
*wined3d_sampler
;
3940 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3946 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3947 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3948 ID3D10SamplerState_AddRef(samplers
[i
]);
3950 wined3d_mutex_unlock();
3953 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
3954 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
3956 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3957 struct wined3d_rendertarget_view
*wined3d_view
;
3959 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3960 iface
, view_count
, render_target_views
, depth_stencil_view
);
3962 wined3d_mutex_lock();
3963 if (render_target_views
)
3965 struct d3d_rendertarget_view
*view_impl
;
3968 for (i
= 0; i
< view_count
; ++i
)
3970 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
3971 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3973 render_target_views
[i
] = NULL
;
3977 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
3978 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
3982 if (depth_stencil_view
)
3984 struct d3d_depthstencil_view
*view_impl
;
3986 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
3987 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3989 *depth_stencil_view
= NULL
;
3993 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
3994 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
3997 wined3d_mutex_unlock();
4000 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
4001 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
4003 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4005 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
4006 iface
, blend_state
, blend_factor
, sample_mask
);
4008 if ((*blend_state
= device
->blend_state
? (ID3D10BlendState
*)&device
->blend_state
->ID3D10BlendState1_iface
: NULL
))
4009 ID3D10BlendState_AddRef(*blend_state
);
4010 wined3d_mutex_lock();
4011 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
4012 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
4013 wined3d_mutex_unlock();
4016 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
4017 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
4019 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4021 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
4022 iface
, depth_stencil_state
, stencil_ref
);
4024 if ((*depth_stencil_state
= device
->depth_stencil_state
4025 ? &device
->depth_stencil_state
->ID3D10DepthStencilState_iface
: NULL
))
4026 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
4027 *stencil_ref
= device
->stencil_ref
;
4030 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
4031 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
4033 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4036 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
4037 iface
, buffer_count
, buffers
, offsets
);
4039 wined3d_mutex_lock();
4040 for (i
= 0; i
< buffer_count
; ++i
)
4042 struct wined3d_buffer
*wined3d_buffer
;
4043 struct d3d_buffer
*buffer_impl
;
4045 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
4051 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4052 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4053 ID3D10Buffer_AddRef(buffers
[i
]);
4055 wined3d_mutex_unlock();
4058 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
4060 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4062 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4064 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
4065 ID3D10RasterizerState_AddRef(*rasterizer_state
);
4068 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4069 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4071 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4072 struct wined3d_viewport wined3d_vp
;
4074 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4078 *viewport_count
= 1;
4082 if (!*viewport_count
)
4085 wined3d_mutex_lock();
4086 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4087 wined3d_mutex_unlock();
4089 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4090 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4091 viewports
[0].Width
= wined3d_vp
.width
;
4092 viewports
[0].Height
= wined3d_vp
.height
;
4093 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4094 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4096 if (*viewport_count
> 1)
4097 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4100 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4102 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4104 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4115 wined3d_mutex_lock();
4116 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4117 wined3d_mutex_unlock();
4118 if (*rect_count
> 1)
4119 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4122 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4124 TRACE("iface %p.\n", iface
);
4126 /* In the current implementation the device is never removed, so we can
4127 * just return S_OK here. */
4132 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4134 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4139 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4141 FIXME("iface %p stub!\n", iface
);
4146 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4147 REFGUID guid
, UINT
*data_size
, void *data
)
4149 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4151 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4153 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4156 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4157 REFGUID guid
, UINT data_size
, const void *data
)
4159 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4161 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4163 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4166 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4167 REFGUID guid
, const IUnknown
*data
)
4169 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4171 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4173 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4176 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4178 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4179 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4182 TRACE("iface %p.\n", iface
);
4184 wined3d_mutex_lock();
4185 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
4186 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4188 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
4190 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4192 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
4194 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4196 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
4198 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
4199 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4201 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
4203 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4205 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
4207 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4209 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
4211 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
4212 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4214 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
4216 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4218 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
4220 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4222 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
4224 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4226 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
4228 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
, 0);
4229 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
4230 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
4231 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4233 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4235 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
4236 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
4237 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4238 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
4239 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
4240 ID3D10Device1_RSSetState(iface
, NULL
);
4241 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4243 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4245 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
4246 wined3d_mutex_unlock();
4249 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4251 FIXME("iface %p stub!\n", iface
);
4254 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4255 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4257 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4258 D3D11_BUFFER_DESC d3d11_desc
;
4259 struct d3d_buffer
*object
;
4262 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4264 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4265 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4266 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4267 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4268 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4269 d3d11_desc
.StructureByteStride
= 0;
4271 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4274 *buffer
= &object
->ID3D10Buffer_iface
;
4279 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4280 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4282 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4287 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4288 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4289 ID3D10Texture2D
**texture
)
4291 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4292 D3D11_TEXTURE2D_DESC d3d11_desc
;
4293 struct d3d_texture2d
*object
;
4296 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4298 d3d11_desc
.Width
= desc
->Width
;
4299 d3d11_desc
.Height
= desc
->Height
;
4300 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4301 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4302 d3d11_desc
.Format
= desc
->Format
;
4303 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4304 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4305 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4306 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4307 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4309 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4312 *texture
= &object
->ID3D10Texture2D_iface
;
4317 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4318 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4319 ID3D10Texture3D
**texture
)
4321 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4322 D3D11_TEXTURE3D_DESC d3d11_desc
;
4323 struct d3d_texture3d
*object
;
4326 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4328 d3d11_desc
.Width
= desc
->Width
;
4329 d3d11_desc
.Height
= desc
->Height
;
4330 d3d11_desc
.Depth
= desc
->Depth
;
4331 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4332 d3d11_desc
.Format
= desc
->Format
;
4333 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4334 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4335 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4336 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4338 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4341 *texture
= &object
->ID3D10Texture3D_iface
;
4346 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4347 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4349 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4350 struct d3d_shader_resource_view
*object
;
4351 ID3D11Resource
*d3d11_resource
;
4354 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4356 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4358 ERR("Resource does not implement ID3D11Resource.\n");
4362 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4364 ID3D11Resource_Release(d3d11_resource
);
4368 *view
= &object
->ID3D10ShaderResourceView1_iface
;
4373 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
4374 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
4376 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4378 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
4379 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
4382 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
4383 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
4385 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4386 struct d3d_rendertarget_view
*object
;
4387 ID3D11Resource
*d3d11_resource
;
4390 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4392 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4394 ERR("Resource does not implement ID3D11Resource.\n");
4398 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
4399 ID3D11Resource_Release(d3d11_resource
);
4403 *view
= &object
->ID3D10RenderTargetView_iface
;
4408 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
4409 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
4411 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4412 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
4413 struct d3d_depthstencil_view
*object
;
4414 ID3D11Resource
*d3d11_resource
;
4417 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4421 d3d11_desc
.Format
= desc
->Format
;
4422 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
4423 d3d11_desc
.Flags
= 0;
4424 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
4427 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4429 ERR("Resource does not implement ID3D11Resource.\n");
4433 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
4434 ID3D11Resource_Release(d3d11_resource
);
4438 *view
= &object
->ID3D10DepthStencilView_iface
;
4443 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
4444 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
4445 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
4446 ID3D10InputLayout
**input_layout
)
4448 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4449 struct d3d_input_layout
*object
;
4452 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4453 "shader_byte_code_length %lu, input_layout %p\n",
4454 iface
, element_descs
, element_count
, shader_byte_code
,
4455 shader_byte_code_length
, input_layout
);
4457 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
4458 shader_byte_code
, shader_byte_code_length
, &object
)))
4461 *input_layout
= &object
->ID3D10InputLayout_iface
;
4466 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
4467 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
4469 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4470 struct d3d_vertex_shader
*object
;
4473 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4474 iface
, byte_code
, byte_code_length
, shader
);
4476 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4479 *shader
= &object
->ID3D10VertexShader_iface
;
4484 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
4485 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
4487 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4488 struct d3d_geometry_shader
*object
;
4491 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4492 iface
, byte_code
, byte_code_length
, shader
);
4494 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4497 *shader
= &object
->ID3D10GeometryShader_iface
;
4502 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
4503 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
4504 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
4506 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4507 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4508 iface
, byte_code
, byte_code_length
, output_stream_decls
,
4509 output_stream_decl_count
, output_stream_stride
, shader
);
4514 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
4515 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
4517 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4518 struct d3d_pixel_shader
*object
;
4521 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4522 iface
, byte_code
, byte_code_length
, shader
);
4524 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4527 *shader
= &object
->ID3D10PixelShader_iface
;
4532 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
4533 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
4535 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4536 ID3D11BlendState
*d3d11_blend_state
;
4539 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4541 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device_iface
, (D3D11_BLEND_DESC
*)desc
,
4542 &d3d11_blend_state
)))
4545 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState1
, (void **)blend_state
);
4546 ID3D11BlendState_Release(d3d11_blend_state
);
4550 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
4551 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
4553 D3D10_BLEND_DESC1 d3d10_1_desc
;
4556 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4559 return E_INVALIDARG
;
4561 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
4562 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
4563 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
4565 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
4566 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
4567 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
4570 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4572 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
4573 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
4574 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
4575 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
4576 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
4577 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
4578 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
4579 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
4582 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
4585 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
4586 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
4588 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4589 ID3D11DepthStencilState
*d3d11_depth_stencil_state
;
4592 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
4594 if (FAILED(hr
= d3d11_device_CreateDepthStencilState(&device
->ID3D11Device_iface
,
4595 (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &d3d11_depth_stencil_state
)))
4598 hr
= ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state
, &IID_ID3D10DepthStencilState
,
4599 (void **)depth_stencil_state
);
4600 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state
);
4604 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
4605 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
4607 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4608 ID3D11RasterizerState
*d3d11_rasterizer_state
;
4611 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
4613 if (FAILED(hr
= d3d11_device_CreateRasterizerState(&device
->ID3D11Device_iface
,
4614 (const D3D11_RASTERIZER_DESC
*)desc
, &d3d11_rasterizer_state
)))
4617 hr
= ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state
,
4618 &IID_ID3D10RasterizerState
, (void **)rasterizer_state
);
4619 ID3D11RasterizerState_Release(d3d11_rasterizer_state
);
4623 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
4624 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
4626 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4627 ID3D11SamplerState
*d3d11_sampler_state
;
4630 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
4632 if (FAILED(hr
= d3d11_device_CreateSamplerState(&device
->ID3D11Device_iface
,
4633 (const D3D11_SAMPLER_DESC
*)desc
, &d3d11_sampler_state
)))
4636 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
, (void **)sampler_state
);
4637 ID3D11SamplerState_Release(d3d11_sampler_state
);
4641 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
4642 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
4644 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4645 struct d3d_query
*object
;
4648 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
4650 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
4655 *query
= &object
->ID3D10Query_iface
;
4659 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4663 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
4664 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
4666 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4667 struct d3d_query
*object
;
4670 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
4672 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
4677 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
4681 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4685 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
4686 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
4688 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
4693 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
4694 DXGI_FORMAT format
, UINT
*format_support
)
4696 FIXME("iface %p, format %s, format_support %p stub!\n",
4697 iface
, debug_dxgi_format(format
), format_support
);
4702 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
4703 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
4705 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4707 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
4708 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
4710 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
4711 sample_count
, quality_level_count
);
4714 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
4716 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
4719 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
4720 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
4721 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4723 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4724 "units %p, units_length %p, description %p, description_length %p stub!\n",
4725 iface
, desc
, type
, active_counters
, name
, name_length
,
4726 units
, units_length
, description
, description_length
);
4731 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
4733 FIXME("iface %p stub!\n", iface
);
4738 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
4739 HANDLE resource_handle
, REFIID guid
, void **resource
)
4741 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4742 iface
, resource_handle
, debugstr_guid(guid
), resource
);
4747 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
4749 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
4752 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
4754 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
4757 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
4759 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4761 TRACE("iface %p.\n", iface
);
4763 return device
->feature_level
;
4766 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
4768 /* IUnknown methods */
4769 d3d10_device_QueryInterface
,
4770 d3d10_device_AddRef
,
4771 d3d10_device_Release
,
4772 /* ID3D10Device methods */
4773 d3d10_device_VSSetConstantBuffers
,
4774 d3d10_device_PSSetShaderResources
,
4775 d3d10_device_PSSetShader
,
4776 d3d10_device_PSSetSamplers
,
4777 d3d10_device_VSSetShader
,
4778 d3d10_device_DrawIndexed
,
4780 d3d10_device_PSSetConstantBuffers
,
4781 d3d10_device_IASetInputLayout
,
4782 d3d10_device_IASetVertexBuffers
,
4783 d3d10_device_IASetIndexBuffer
,
4784 d3d10_device_DrawIndexedInstanced
,
4785 d3d10_device_DrawInstanced
,
4786 d3d10_device_GSSetConstantBuffers
,
4787 d3d10_device_GSSetShader
,
4788 d3d10_device_IASetPrimitiveTopology
,
4789 d3d10_device_VSSetShaderResources
,
4790 d3d10_device_VSSetSamplers
,
4791 d3d10_device_SetPredication
,
4792 d3d10_device_GSSetShaderResources
,
4793 d3d10_device_GSSetSamplers
,
4794 d3d10_device_OMSetRenderTargets
,
4795 d3d10_device_OMSetBlendState
,
4796 d3d10_device_OMSetDepthStencilState
,
4797 d3d10_device_SOSetTargets
,
4798 d3d10_device_DrawAuto
,
4799 d3d10_device_RSSetState
,
4800 d3d10_device_RSSetViewports
,
4801 d3d10_device_RSSetScissorRects
,
4802 d3d10_device_CopySubresourceRegion
,
4803 d3d10_device_CopyResource
,
4804 d3d10_device_UpdateSubresource
,
4805 d3d10_device_ClearRenderTargetView
,
4806 d3d10_device_ClearDepthStencilView
,
4807 d3d10_device_GenerateMips
,
4808 d3d10_device_ResolveSubresource
,
4809 d3d10_device_VSGetConstantBuffers
,
4810 d3d10_device_PSGetShaderResources
,
4811 d3d10_device_PSGetShader
,
4812 d3d10_device_PSGetSamplers
,
4813 d3d10_device_VSGetShader
,
4814 d3d10_device_PSGetConstantBuffers
,
4815 d3d10_device_IAGetInputLayout
,
4816 d3d10_device_IAGetVertexBuffers
,
4817 d3d10_device_IAGetIndexBuffer
,
4818 d3d10_device_GSGetConstantBuffers
,
4819 d3d10_device_GSGetShader
,
4820 d3d10_device_IAGetPrimitiveTopology
,
4821 d3d10_device_VSGetShaderResources
,
4822 d3d10_device_VSGetSamplers
,
4823 d3d10_device_GetPredication
,
4824 d3d10_device_GSGetShaderResources
,
4825 d3d10_device_GSGetSamplers
,
4826 d3d10_device_OMGetRenderTargets
,
4827 d3d10_device_OMGetBlendState
,
4828 d3d10_device_OMGetDepthStencilState
,
4829 d3d10_device_SOGetTargets
,
4830 d3d10_device_RSGetState
,
4831 d3d10_device_RSGetViewports
,
4832 d3d10_device_RSGetScissorRects
,
4833 d3d10_device_GetDeviceRemovedReason
,
4834 d3d10_device_SetExceptionMode
,
4835 d3d10_device_GetExceptionMode
,
4836 d3d10_device_GetPrivateData
,
4837 d3d10_device_SetPrivateData
,
4838 d3d10_device_SetPrivateDataInterface
,
4839 d3d10_device_ClearState
,
4841 d3d10_device_CreateBuffer
,
4842 d3d10_device_CreateTexture1D
,
4843 d3d10_device_CreateTexture2D
,
4844 d3d10_device_CreateTexture3D
,
4845 d3d10_device_CreateShaderResourceView
,
4846 d3d10_device_CreateRenderTargetView
,
4847 d3d10_device_CreateDepthStencilView
,
4848 d3d10_device_CreateInputLayout
,
4849 d3d10_device_CreateVertexShader
,
4850 d3d10_device_CreateGeometryShader
,
4851 d3d10_device_CreateGeometryShaderWithStreamOutput
,
4852 d3d10_device_CreatePixelShader
,
4853 d3d10_device_CreateBlendState
,
4854 d3d10_device_CreateDepthStencilState
,
4855 d3d10_device_CreateRasterizerState
,
4856 d3d10_device_CreateSamplerState
,
4857 d3d10_device_CreateQuery
,
4858 d3d10_device_CreatePredicate
,
4859 d3d10_device_CreateCounter
,
4860 d3d10_device_CheckFormatSupport
,
4861 d3d10_device_CheckMultisampleQualityLevels
,
4862 d3d10_device_CheckCounterInfo
,
4863 d3d10_device_CheckCounter
,
4864 d3d10_device_GetCreationFlags
,
4865 d3d10_device_OpenSharedResource
,
4866 d3d10_device_SetTextFilterSize
,
4867 d3d10_device_GetTextFilterSize
,
4868 d3d10_device_CreateShaderResourceView1
,
4869 d3d10_device_CreateBlendState1
,
4870 d3d10_device_GetFeatureLevel
,
4873 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
4875 /* IUnknown methods */
4876 d3d_device_inner_QueryInterface
,
4877 d3d_device_inner_AddRef
,
4878 d3d_device_inner_Release
,
4881 /* ID3D10Multithread methods */
4883 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
4885 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
4888 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
4890 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4892 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
4894 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4897 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
4899 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4901 TRACE("iface %p.\n", iface
);
4903 return IUnknown_AddRef(device
->outer_unk
);
4906 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
4908 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4910 TRACE("iface %p.\n", iface
);
4912 return IUnknown_Release(device
->outer_unk
);
4915 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
4917 TRACE("iface %p.\n", iface
);
4919 wined3d_mutex_lock();
4922 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
4924 TRACE("iface %p.\n", iface
);
4926 wined3d_mutex_unlock();
4929 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
4931 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
4936 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
4938 FIXME("iface %p stub!\n", iface
);
4943 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
4945 d3d10_multithread_QueryInterface
,
4946 d3d10_multithread_AddRef
,
4947 d3d10_multithread_Release
,
4948 d3d10_multithread_Enter
,
4949 d3d10_multithread_Leave
,
4950 d3d10_multithread_SetMultithreadProtected
,
4951 d3d10_multithread_GetMultithreadProtected
,
4954 /* IWineDXGIDeviceParent IUnknown methods */
4956 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
4958 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
4961 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
4962 REFIID riid
, void **ppv
)
4964 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4965 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
4968 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
4970 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4971 return IUnknown_AddRef(device
->outer_unk
);
4974 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
4976 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4977 return IUnknown_Release(device
->outer_unk
);
4980 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
4981 IWineDXGIDeviceParent
*iface
)
4983 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4984 return &device
->device_parent
;
4987 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
4989 /* IUnknown methods */
4990 dxgi_device_parent_QueryInterface
,
4991 dxgi_device_parent_AddRef
,
4992 dxgi_device_parent_Release
,
4993 /* IWineDXGIDeviceParent methods */
4994 dxgi_device_parent_get_wined3d_device_parent
,
4997 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
4999 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
5002 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
5003 struct wined3d_device
*wined3d_device
)
5005 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5007 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
5009 wined3d_device_incref(wined3d_device
);
5010 device
->wined3d_device
= wined3d_device
;
5013 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
5015 TRACE("device_parent %p.\n", device_parent
);
5018 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
5020 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
5023 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
5024 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
5025 const struct wined3d_parent_ops
**parent_ops
)
5027 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
5028 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
5031 *parent_ops
= &d3d_null_wined3d_parent_ops
;
5036 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
5037 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
5038 struct wined3d_texture
**wined3d_texture
)
5040 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5041 struct d3d_texture2d
*texture
;
5042 ID3D10Texture2D
*texture_iface
;
5043 D3D10_TEXTURE2D_DESC desc
;
5046 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
5047 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
5049 FIXME("Implement DXGI<->wined3d usage conversion.\n");
5051 desc
.Width
= wined3d_desc
->width
;
5052 desc
.Height
= wined3d_desc
->height
;
5055 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
5056 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
5057 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
5058 desc
.Usage
= D3D10_USAGE_DEFAULT
;
5059 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5060 desc
.CPUAccessFlags
= 0;
5063 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
5064 &desc
, NULL
, &texture_iface
)))
5066 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
5070 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5072 *wined3d_texture
= texture
->wined3d_texture
;
5073 wined3d_texture_incref(*wined3d_texture
);
5074 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5079 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5080 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5082 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5083 IWineDXGIDevice
*wine_device
;
5086 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5088 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5089 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5091 ERR("Device should implement IWineDXGIDevice.\n");
5095 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, TRUE
, swapchain
);
5096 IWineDXGIDevice_Release(wine_device
);
5099 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5106 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5108 device_parent_wined3d_device_created
,
5109 device_parent_mode_changed
,
5110 device_parent_activate
,
5111 device_parent_sub_resource_created
,
5112 device_parent_sub_resource_created
,
5113 device_parent_create_swapchain_texture
,
5114 device_parent_create_swapchain
,
5117 static void *d3d_rb_alloc(size_t size
)
5119 return HeapAlloc(GetProcessHeap(), 0, size
);
5122 static void *d3d_rb_realloc(void *ptr
, size_t size
)
5124 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
5127 static void d3d_rb_free(void *ptr
)
5129 HeapFree(GetProcessHeap(), 0, ptr
);
5132 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5134 const D3D11_SAMPLER_DESC
*ka
= key
;
5135 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5137 return memcmp(ka
, kb
, sizeof(*ka
));
5140 static const struct wine_rb_functions d3d_sampler_state_rb_ops
=
5145 d3d_sampler_state_compare
,
5148 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5150 const D3D11_BLEND_DESC
*ka
= key
;
5151 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5153 return memcmp(ka
, kb
, sizeof(*ka
));
5156 static const struct wine_rb_functions d3d_blend_state_rb_ops
=
5161 d3d_blend_state_compare
,
5164 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5166 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5167 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5168 const struct d3d_depthstencil_state
, entry
)->desc
;
5170 return memcmp(ka
, kb
, sizeof(*ka
));
5173 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops
=
5178 d3d_depthstencil_state_compare
,
5181 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5183 const D3D11_RASTERIZER_DESC
*ka
= key
;
5184 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5186 return memcmp(ka
, kb
, sizeof(*ka
));
5189 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops
=
5194 d3d_rasterizer_state_compare
,
5197 HRESULT
d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5199 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5200 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5201 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5202 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5203 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5204 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5205 device
->refcount
= 1;
5206 /* COM aggregation always takes place */
5207 device
->outer_unk
= outer_unknown
;
5209 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5210 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5212 if (wine_rb_init(&device
->blend_states
, &d3d_blend_state_rb_ops
) == -1)
5214 WARN("Failed to initialize blend state rbtree.\n");
5217 device
->blend_factor
[0] = 1.0f
;
5218 device
->blend_factor
[1] = 1.0f
;
5219 device
->blend_factor
[2] = 1.0f
;
5220 device
->blend_factor
[3] = 1.0f
;
5222 if (wine_rb_init(&device
->depthstencil_states
, &d3d_depthstencil_state_rb_ops
) == -1)
5224 WARN("Failed to initialize depthstencil state rbtree.\n");
5225 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
5229 if (wine_rb_init(&device
->rasterizer_states
, &d3d_rasterizer_state_rb_ops
) == -1)
5231 WARN("Failed to initialize rasterizer state rbtree.\n");
5232 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
5233 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
5237 if (wine_rb_init(&device
->sampler_states
, &d3d_sampler_state_rb_ops
) == -1)
5239 WARN("Failed to initialize sampler state rbtree.\n");
5240 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
5241 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
5242 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);