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
);
364 FIXME("offset %u not supported.\n", offset
);
366 wined3d_mutex_lock();
367 wined3d_device_set_index_buffer(device
->wined3d_device
,
368 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
369 wined3dformat_from_dxgi_format(format
));
370 wined3d_mutex_unlock();
373 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext
*iface
,
374 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
375 UINT start_instance_location
)
377 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
379 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
380 "base_vertex_location %d, start_instance_location %u.\n",
381 iface
, instance_index_count
, instance_count
, start_index_location
,
382 base_vertex_location
, start_instance_location
);
384 wined3d_mutex_lock();
385 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
386 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
387 instance_index_count
, start_instance_location
, instance_count
);
388 wined3d_mutex_unlock();
391 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext
*iface
,
392 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
394 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
396 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
397 "start_instance_location %u.\n",
398 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
399 start_instance_location
);
401 wined3d_mutex_lock();
402 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
403 instance_vertex_count
, start_instance_location
, instance_count
);
404 wined3d_mutex_unlock();
407 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext
*iface
,
408 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
410 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
413 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
414 iface
, start_slot
, buffer_count
, buffers
);
416 wined3d_mutex_lock();
417 for (i
= 0; i
< buffer_count
; ++i
)
419 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
421 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
422 buffer
? buffer
->wined3d_buffer
: NULL
);
424 wined3d_mutex_unlock();
427 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext
*iface
,
428 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
430 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
431 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
433 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
434 iface
, shader
, class_instances
, class_instance_count
);
437 FIXME("Dynamic linking is not implemented yet.\n");
439 wined3d_mutex_lock();
440 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
441 wined3d_mutex_unlock();
444 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext
*iface
,
445 D3D11_PRIMITIVE_TOPOLOGY topology
)
447 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
449 TRACE("iface %p, topology %u.\n", iface
, topology
);
451 wined3d_mutex_lock();
452 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
453 wined3d_mutex_unlock();
456 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext
*iface
,
457 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
459 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
462 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
464 wined3d_mutex_lock();
465 for (i
= 0; i
< view_count
; ++i
)
467 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
469 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
470 view
? view
->wined3d_view
: NULL
);
472 wined3d_mutex_unlock();
475 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext
*iface
,
476 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
478 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
481 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
482 iface
, start_slot
, sampler_count
, samplers
);
484 wined3d_mutex_lock();
485 for (i
= 0; i
< sampler_count
; ++i
)
487 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
489 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
490 sampler
? sampler
->wined3d_sampler
: NULL
);
492 wined3d_mutex_unlock();
495 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext
*iface
,
496 ID3D11Asynchronous
*asynchronous
)
498 FIXME("iface %p, asynchronous %p stub!\n", iface
, asynchronous
);
501 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext
*iface
,
502 ID3D11Asynchronous
*asynchronous
)
504 FIXME("iface %p, asynchronous %p stub!\n", iface
, asynchronous
);
507 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext
*iface
,
508 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
510 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
511 iface
, asynchronous
, data
, data_size
, data_flags
);
516 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext
*iface
,
517 ID3D11Predicate
*predicate
, BOOL value
)
519 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
520 struct d3d_query
*query
;
522 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
524 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
526 wined3d_mutex_lock();
527 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
528 wined3d_mutex_unlock();
531 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext
*iface
,
532 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
534 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
537 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
539 wined3d_mutex_lock();
540 for (i
= 0; i
< view_count
; ++i
)
542 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
544 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
545 view
? view
->wined3d_view
: NULL
);
547 wined3d_mutex_unlock();
550 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext
*iface
,
551 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
553 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
556 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
557 iface
, start_slot
, sampler_count
, samplers
);
559 wined3d_mutex_lock();
560 for (i
= 0; i
< sampler_count
; ++i
)
562 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
564 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
565 sampler
? sampler
->wined3d_sampler
: NULL
);
567 wined3d_mutex_unlock();
570 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext
*iface
,
571 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
572 ID3D11DepthStencilView
*depth_stencil_view
)
574 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
575 struct d3d_depthstencil_view
*dsv
;
578 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
579 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
581 wined3d_mutex_lock();
582 for (i
= 0; i
< render_target_view_count
; ++i
)
584 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
585 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
587 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
589 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
592 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
593 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
594 wined3d_mutex_unlock();
597 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
598 ID3D11DeviceContext
*iface
, UINT render_target_view_count
,
599 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
600 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
601 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
603 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
604 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
605 "initial_counts %p stub!\n",
606 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
607 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
611 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
612 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
614 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
615 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
616 const D3D11_BLEND_DESC
*desc
;
618 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
619 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
622 blend_factor
= default_blend_factor
;
624 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
625 FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor
));
627 wined3d_mutex_lock();
628 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
629 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
630 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
632 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
633 wined3d_device_set_render_state(device
->wined3d_device
,
634 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
635 wined3d_device_set_render_state(device
->wined3d_device
,
636 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
637 wined3d_device_set_render_state(device
->wined3d_device
,
638 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
639 wined3d_device_set_render_state(device
->wined3d_device
,
640 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
641 wined3d_mutex_unlock();
645 desc
= &device
->blend_state
->desc
;
646 /* glSampleCoverage() */
647 if (desc
->AlphaToCoverageEnable
)
648 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
649 /* glEnableIndexedEXT(GL_BLEND, ...) */
650 FIXME("Per-rendertarget blend not implemented.\n");
651 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
652 desc
->RenderTarget
[0].BlendEnable
);
653 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
, desc
->RenderTarget
[0].SrcBlend
);
654 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
, desc
->RenderTarget
[0].DestBlend
);
655 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
, desc
->RenderTarget
[0].BlendOp
);
656 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
657 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
,
658 desc
->RenderTarget
[0].SrcBlendAlpha
);
659 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
,
660 desc
->RenderTarget
[0].DestBlendAlpha
);
661 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
,
662 desc
->RenderTarget
[0].BlendOpAlpha
);
663 FIXME("Color mask > 3 not implemented.\n");
664 wined3d_device_set_render_state(device
->wined3d_device
,
665 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
666 wined3d_device_set_render_state(device
->wined3d_device
,
667 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
668 wined3d_device_set_render_state(device
->wined3d_device
,
669 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
670 wined3d_device_set_render_state(device
->wined3d_device
,
671 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
672 wined3d_mutex_unlock();
675 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
676 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
678 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
679 const D3D11_DEPTH_STENCILOP_DESC
*stencil_desc
;
680 const D3D11_DEPTH_STENCIL_DESC
*desc
;
682 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
683 iface
, depth_stencil_state
, stencil_ref
);
685 wined3d_mutex_lock();
686 device
->stencil_ref
= stencil_ref
;
687 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
689 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
690 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
691 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, D3D11_COMPARISON_LESS
);
692 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
693 wined3d_mutex_unlock();
697 desc
= &device
->depth_stencil_state
->desc
;
699 if (desc
->FrontFace
.StencilFailOp
!= desc
->BackFace
.StencilFailOp
700 || desc
->FrontFace
.StencilDepthFailOp
!= desc
->BackFace
.StencilDepthFailOp
701 || desc
->FrontFace
.StencilPassOp
!= desc
->BackFace
.StencilPassOp
702 || desc
->FrontFace
.StencilFunc
!= desc
->BackFace
.StencilFunc
)
703 FIXME("Two-sided stencil testing not supported.\n");
705 stencil_desc
= &desc
->FrontFace
;
707 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
708 if (desc
->DepthEnable
)
710 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
711 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
714 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
715 if (desc
->StencilEnable
)
717 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
718 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
719 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, stencil_desc
->StencilFailOp
);
720 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
,
721 stencil_desc
->StencilDepthFailOp
);
722 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, stencil_desc
->StencilPassOp
);
723 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, stencil_desc
->StencilFunc
);
724 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
726 wined3d_mutex_unlock();
729 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
730 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
732 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
733 unsigned int count
, i
;
735 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
737 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
738 wined3d_mutex_lock();
739 for (i
= 0; i
< count
; ++i
)
741 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
743 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
744 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
746 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
748 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
750 wined3d_mutex_unlock();
753 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
755 FIXME("iface %p stub!\n", iface
);
758 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext
*iface
,
759 ID3D11Buffer
*buffer
, UINT offset
)
761 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
764 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
765 ID3D11Buffer
*buffer
, UINT offset
)
767 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
770 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
771 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
773 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
774 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
777 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
778 ID3D11Buffer
*buffer
, UINT offset
)
780 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
783 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
784 ID3D11RasterizerState
*rasterizer_state
)
786 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
787 const D3D11_RASTERIZER_DESC
*desc
;
789 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
791 wined3d_mutex_lock();
792 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
794 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
795 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_CCW
);
796 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
797 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
798 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
799 wined3d_mutex_unlock();
803 desc
= &device
->rasterizer_state
->desc
;
804 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
805 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
807 if (desc
->FrontCounterClockwise
)
808 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc
->FrontCounterClockwise
);
809 /* OpenGL style depth bias. */
810 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
811 FIXME("Ignoring depth bias.\n");
813 if (!desc
->DepthClipEnable
)
814 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
815 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
816 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
817 wined3d_device_set_render_state(device
->wined3d_device
,
818 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
819 wined3d_mutex_unlock();
822 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
823 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
825 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
826 struct wined3d_viewport wined3d_vp
;
828 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
830 if (viewport_count
> 1)
831 FIXME("Multiple viewports not implemented.\n");
836 if (viewports
[0].TopLeftX
!= (UINT
)viewports
[0].TopLeftX
837 || viewports
[0].TopLeftY
!= (UINT
)viewports
[0].TopLeftY
838 || viewports
[0].Width
!= (UINT
)viewports
[0].Width
839 || viewports
[0].Height
!= (UINT
)viewports
[0].Height
)
840 FIXME("Floating-point viewports not implemented.\n");
842 wined3d_vp
.x
= viewports
[0].TopLeftX
;
843 wined3d_vp
.y
= viewports
[0].TopLeftY
;
844 wined3d_vp
.width
= viewports
[0].Width
;
845 wined3d_vp
.height
= viewports
[0].Height
;
846 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
847 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
849 wined3d_mutex_lock();
850 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
851 wined3d_mutex_unlock();
854 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
855 UINT rect_count
, const D3D11_RECT
*rects
)
857 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
859 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
862 FIXME("Multiple scissor rects not implemented.\n");
867 wined3d_mutex_lock();
868 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
869 wined3d_mutex_unlock();
872 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
873 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
874 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
876 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
877 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
878 struct wined3d_box wined3d_src_box
;
880 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
881 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
882 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
883 src_resource
, src_subresource_idx
, src_box
);
887 wined3d_src_box
.left
= src_box
->left
;
888 wined3d_src_box
.top
= src_box
->top
;
889 wined3d_src_box
.front
= src_box
->front
;
890 wined3d_src_box
.right
= src_box
->right
;
891 wined3d_src_box
.bottom
= src_box
->bottom
;
892 wined3d_src_box
.back
= src_box
->back
;
895 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
896 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
897 wined3d_mutex_lock();
898 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
899 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
900 wined3d_mutex_unlock();
903 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
904 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
906 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
907 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
909 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
911 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
912 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
913 wined3d_mutex_lock();
914 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
915 wined3d_mutex_unlock();
918 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
919 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
920 const void *data
, UINT row_pitch
, UINT depth_pitch
)
922 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
923 struct wined3d_resource
*wined3d_resource
;
924 struct wined3d_box wined3d_box
;
926 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
927 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
931 wined3d_box
.left
= box
->left
;
932 wined3d_box
.top
= box
->top
;
933 wined3d_box
.front
= box
->front
;
934 wined3d_box
.right
= box
->right
;
935 wined3d_box
.bottom
= box
->bottom
;
936 wined3d_box
.back
= box
->back
;
939 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
940 wined3d_mutex_lock();
941 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
942 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
943 wined3d_mutex_unlock();
946 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
947 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
949 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
950 iface
, dst_buffer
, dst_offset
, src_view
);
953 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
954 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
956 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
957 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
958 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
961 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
962 iface
, render_target_view
, debug_float4(color_rgba
));
964 wined3d_mutex_lock();
965 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
966 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
967 ERR("Failed to clear view, hr %#x.\n", hr
);
968 wined3d_mutex_unlock();
971 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
972 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
974 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
975 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
978 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
979 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
981 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
982 iface
, unordered_access_view
, debug_float4(values
));
985 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
986 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
988 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
989 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
993 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
994 iface
, depth_stencil_view
, flags
, depth
, stencil
);
996 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
998 wined3d_mutex_lock();
999 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1000 wined3d_flags
, NULL
, depth
, stencil
)))
1001 ERR("Failed to clear view, hr %#x.\n", hr
);
1002 wined3d_mutex_unlock();
1005 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1006 ID3D11ShaderResourceView
*view
)
1008 FIXME("iface %p, view %p stub!\n", iface
, view
);
1011 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1012 ID3D11Resource
*resource
, FLOAT min_lod
)
1014 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1017 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1018 ID3D11Resource
*resource
)
1020 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1025 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1026 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1027 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1030 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1031 "format %s stub!\n",
1032 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1033 debug_dxgi_format(format
));
1036 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1037 ID3D11CommandList
*command_list
, BOOL restore_state
)
1039 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1042 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1043 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1045 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1046 iface
, start_slot
, view_count
, views
);
1049 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1050 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1052 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1053 iface
, shader
, class_instances
, class_instance_count
);
1056 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1057 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1059 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1060 iface
, start_slot
, sampler_count
, samplers
);
1063 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1064 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1066 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1067 iface
, start_slot
, buffer_count
, buffers
);
1070 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1071 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1073 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1074 iface
, start_slot
, view_count
, views
);
1077 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1078 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1080 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1081 iface
, shader
, class_instances
, class_instance_count
);
1084 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1085 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1087 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1088 iface
, start_slot
, sampler_count
, samplers
);
1091 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1092 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1094 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1095 iface
, start_slot
, buffer_count
, buffers
);
1098 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1099 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1101 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1102 iface
, start_slot
, view_count
, views
);
1105 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1106 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1108 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1109 iface
, start_slot
, view_count
, views
, initial_counts
);
1112 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1113 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1115 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1116 iface
, shader
, class_instances
, class_instance_count
);
1119 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1120 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1122 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1123 iface
, start_slot
, sampler_count
, samplers
);
1126 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1127 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1129 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1130 iface
, start_slot
, buffer_count
, buffers
);
1133 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1134 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1136 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1139 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1140 iface
, start_slot
, buffer_count
, buffers
);
1142 wined3d_mutex_lock();
1143 for (i
= 0; i
< buffer_count
; ++i
)
1145 struct wined3d_buffer
*wined3d_buffer
;
1146 struct d3d_buffer
*buffer_impl
;
1148 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1154 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1155 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1156 ID3D11Buffer_AddRef(buffers
[i
]);
1158 wined3d_mutex_unlock();
1161 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1162 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1164 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1167 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1168 iface
, start_slot
, view_count
, views
);
1170 wined3d_mutex_lock();
1171 for (i
= 0; i
< view_count
; ++i
)
1173 struct wined3d_shader_resource_view
*wined3d_view
;
1174 struct d3d_shader_resource_view
*view_impl
;
1176 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1182 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1183 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1184 ID3D11ShaderResourceView_AddRef(views
[i
]);
1186 wined3d_mutex_unlock();
1189 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1190 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1192 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1193 struct wined3d_shader
*wined3d_shader
;
1194 struct d3d_pixel_shader
*shader_impl
;
1196 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1197 iface
, shader
, class_instances
, class_instance_count
);
1199 if (class_instances
|| class_instance_count
)
1200 FIXME("Dynamic linking not implemented yet.\n");
1202 wined3d_mutex_lock();
1203 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1205 wined3d_mutex_unlock();
1210 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1211 wined3d_mutex_unlock();
1212 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1213 ID3D11PixelShader_AddRef(*shader
);
1216 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1217 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1219 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1222 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1223 iface
, start_slot
, sampler_count
, samplers
);
1225 wined3d_mutex_lock();
1226 for (i
= 0; i
< sampler_count
; ++i
)
1228 struct wined3d_sampler
*wined3d_sampler
;
1229 struct d3d_sampler_state
*sampler_impl
;
1231 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1237 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1238 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1239 ID3D11SamplerState_AddRef(samplers
[i
]);
1241 wined3d_mutex_unlock();
1244 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1245 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1247 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1248 struct d3d_vertex_shader
*shader_impl
;
1249 struct wined3d_shader
*wined3d_shader
;
1251 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1252 iface
, shader
, class_instances
, class_instance_count
);
1254 if (class_instances
|| class_instance_count
)
1255 FIXME("Dynamic linking not implemented yet.\n");
1257 wined3d_mutex_lock();
1258 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1260 wined3d_mutex_unlock();
1265 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1266 wined3d_mutex_unlock();
1267 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1268 ID3D11VertexShader_AddRef(*shader
);
1271 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1272 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1274 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1277 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1278 iface
, start_slot
, buffer_count
, buffers
);
1280 wined3d_mutex_lock();
1281 for (i
= 0; i
< buffer_count
; ++i
)
1283 struct wined3d_buffer
*wined3d_buffer
;
1284 struct d3d_buffer
*buffer_impl
;
1286 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1292 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1293 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1294 ID3D11Buffer_AddRef(buffers
[i
]);
1296 wined3d_mutex_unlock();
1299 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1300 ID3D11InputLayout
**input_layout
)
1302 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1303 struct wined3d_vertex_declaration
*wined3d_declaration
;
1304 struct d3d_input_layout
*input_layout_impl
;
1306 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1308 wined3d_mutex_lock();
1309 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1311 wined3d_mutex_unlock();
1312 *input_layout
= NULL
;
1316 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1317 wined3d_mutex_unlock();
1318 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1319 ID3D11InputLayout_AddRef(*input_layout
);
1322 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1323 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1325 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1326 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1329 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1330 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1332 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface
, buffer
, format
, offset
);
1335 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1336 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1338 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1341 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1342 iface
, start_slot
, buffer_count
, buffers
);
1344 wined3d_mutex_lock();
1345 for (i
= 0; i
< buffer_count
; ++i
)
1347 struct wined3d_buffer
*wined3d_buffer
;
1348 struct d3d_buffer
*buffer_impl
;
1350 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1356 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1357 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1358 ID3D11Buffer_AddRef(buffers
[i
]);
1360 wined3d_mutex_unlock();
1363 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1364 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1366 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1367 struct d3d_geometry_shader
*shader_impl
;
1368 struct wined3d_shader
*wined3d_shader
;
1370 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1371 iface
, shader
, class_instances
, class_instance_count
);
1373 if (class_instances
|| class_instance_count
)
1374 FIXME("Dynamic linking not implemented yet.\n");
1376 wined3d_mutex_lock();
1377 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1379 wined3d_mutex_unlock();
1384 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1385 wined3d_mutex_unlock();
1386 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1387 ID3D11GeometryShader_AddRef(*shader
);
1390 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1391 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1393 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1395 TRACE("iface %p, topology %p.\n", iface
, topology
);
1397 wined3d_mutex_lock();
1398 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1399 wined3d_mutex_unlock();
1402 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1403 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1405 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1408 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1410 wined3d_mutex_lock();
1411 for (i
= 0; i
< view_count
; ++i
)
1413 struct wined3d_shader_resource_view
*wined3d_view
;
1414 struct d3d_shader_resource_view
*view_impl
;
1416 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1422 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1423 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1424 ID3D11ShaderResourceView_AddRef(views
[i
]);
1426 wined3d_mutex_unlock();
1429 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1430 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1432 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1435 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1436 iface
, start_slot
, sampler_count
, samplers
);
1438 wined3d_mutex_lock();
1439 for (i
= 0; i
< sampler_count
; ++i
)
1441 struct wined3d_sampler
*wined3d_sampler
;
1442 struct d3d_sampler_state
*sampler_impl
;
1444 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1450 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1451 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1452 ID3D11SamplerState_AddRef(samplers
[i
]);
1454 wined3d_mutex_unlock();
1457 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1458 ID3D11Predicate
**predicate
, BOOL
*value
)
1460 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1461 struct wined3d_query
*wined3d_predicate
;
1462 struct d3d_query
*predicate_impl
;
1464 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1466 wined3d_mutex_lock();
1467 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1469 wined3d_mutex_unlock();
1474 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1475 wined3d_mutex_unlock();
1476 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1477 ID3D11Predicate_AddRef(*predicate
);
1480 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1481 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1483 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1486 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1488 wined3d_mutex_lock();
1489 for (i
= 0; i
< view_count
; ++i
)
1491 struct wined3d_shader_resource_view
*wined3d_view
;
1492 struct d3d_shader_resource_view
*view_impl
;
1494 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1500 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1501 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1502 ID3D11ShaderResourceView_AddRef(views
[i
]);
1504 wined3d_mutex_unlock();
1507 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1508 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1510 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1513 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1514 iface
, start_slot
, sampler_count
, samplers
);
1516 wined3d_mutex_lock();
1517 for (i
= 0; i
< sampler_count
; ++i
)
1519 struct d3d_sampler_state
*sampler_impl
;
1520 struct wined3d_sampler
*wined3d_sampler
;
1522 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1528 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1529 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1530 ID3D11SamplerState_AddRef(samplers
[i
]);
1532 wined3d_mutex_unlock();
1535 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1536 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1537 ID3D11DepthStencilView
**depth_stencil_view
)
1539 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1540 struct wined3d_rendertarget_view
*wined3d_view
;
1542 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1543 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1545 wined3d_mutex_lock();
1546 if (render_target_views
)
1548 struct d3d_rendertarget_view
*view_impl
;
1551 for (i
= 0; i
< render_target_view_count
; ++i
)
1553 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1554 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1556 render_target_views
[i
] = NULL
;
1560 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1561 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1565 if (depth_stencil_view
)
1567 struct d3d_depthstencil_view
*view_impl
;
1569 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1570 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1572 *depth_stencil_view
= NULL
;
1576 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1577 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1580 wined3d_mutex_unlock();
1583 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1584 ID3D11DeviceContext
*iface
,
1585 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1586 ID3D11DepthStencilView
**depth_stencil_view
,
1587 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1588 ID3D11UnorderedAccessView
**unordered_access_views
)
1590 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1591 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1592 "unordered_access_views %p stub!\n",
1593 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1594 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1597 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1598 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1600 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1601 iface
, blend_state
, blend_factor
, sample_mask
);
1604 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1605 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1607 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface
, depth_stencil_state
, stencil_ref
);
1610 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1611 UINT buffer_count
, ID3D11Buffer
**buffers
)
1613 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1616 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1618 wined3d_mutex_lock();
1619 for (i
= 0; i
< buffer_count
; ++i
)
1621 struct wined3d_buffer
*wined3d_buffer
;
1622 struct d3d_buffer
*buffer_impl
;
1624 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1630 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1631 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1632 ID3D11Buffer_AddRef(buffers
[i
]);
1634 wined3d_mutex_unlock();
1637 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
1638 ID3D11RasterizerState
**rasterizer_state
)
1640 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1642 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1644 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D11RasterizerState_iface
: NULL
))
1645 ID3D11RasterizerState_AddRef(*rasterizer_state
);
1648 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
1649 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1651 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1652 struct wined3d_viewport wined3d_vp
;
1654 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1658 *viewport_count
= 1;
1662 if (!*viewport_count
)
1665 wined3d_mutex_lock();
1666 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1667 wined3d_mutex_unlock();
1669 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1670 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1671 viewports
[0].Width
= wined3d_vp
.width
;
1672 viewports
[0].Height
= wined3d_vp
.height
;
1673 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1674 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1676 if (*viewport_count
> 1)
1677 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1680 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
1681 UINT
*rect_count
, D3D11_RECT
*rects
)
1683 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface
, rect_count
, rects
);
1686 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
1687 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1689 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1692 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
1693 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1695 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1696 iface
, shader
, class_instances
, class_instance_count
);
1699 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
1700 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1702 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1703 iface
, start_slot
, sampler_count
, samplers
);
1706 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1707 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1709 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1710 iface
, start_slot
, buffer_count
, buffers
);
1713 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
1714 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1716 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1717 iface
, start_slot
, view_count
, views
);
1720 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
1721 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1723 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1724 iface
, shader
, class_instances
, class_instance_count
);
1727 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
1728 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1730 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1731 iface
, start_slot
, sampler_count
, samplers
);
1734 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1735 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1737 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1738 iface
, start_slot
, buffer_count
, buffers
);
1741 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
1742 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1744 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1747 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1748 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
1750 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1753 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
1754 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1756 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1757 iface
, shader
, class_instances
, class_instance_count
);
1760 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
1761 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1763 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1764 iface
, start_slot
, sampler_count
, samplers
);
1767 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1768 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1770 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1771 iface
, start_slot
, buffer_count
, buffers
);
1774 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
1776 FIXME("iface %p stub!\n", iface
);
1779 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
1781 FIXME("iface %p stub!\n", iface
);
1784 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
1786 TRACE("iface %p.\n", iface
);
1788 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
1791 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
1793 FIXME("iface %p stub!\n", iface
);
1798 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
1799 BOOL restore
, ID3D11CommandList
**command_list
)
1801 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
1806 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
1808 /* IUnknown methods */
1809 d3d11_immediate_context_QueryInterface
,
1810 d3d11_immediate_context_AddRef
,
1811 d3d11_immediate_context_Release
,
1812 /* ID3D11DeviceChild methods */
1813 d3d11_immediate_context_GetDevice
,
1814 d3d11_immediate_context_GetPrivateData
,
1815 d3d11_immediate_context_SetPrivateData
,
1816 d3d11_immediate_context_SetPrivateDataInterface
,
1817 /* ID3D11DeviceContext methods */
1818 d3d11_immediate_context_VSSetConstantBuffers
,
1819 d3d11_immediate_context_PSSetShaderResources
,
1820 d3d11_immediate_context_PSSetShader
,
1821 d3d11_immediate_context_PSSetSamplers
,
1822 d3d11_immediate_context_VSSetShader
,
1823 d3d11_immediate_context_DrawIndexed
,
1824 d3d11_immediate_context_Draw
,
1825 d3d11_immediate_context_Map
,
1826 d3d11_immediate_context_Unmap
,
1827 d3d11_immediate_context_PSSetConstantBuffers
,
1828 d3d11_immediate_context_IASetInputLayout
,
1829 d3d11_immediate_context_IASetVertexBuffers
,
1830 d3d11_immediate_context_IASetIndexBuffer
,
1831 d3d11_immediate_context_DrawIndexedInstanced
,
1832 d3d11_immediate_context_DrawInstanced
,
1833 d3d11_immediate_context_GSSetConstantBuffers
,
1834 d3d11_immediate_context_GSSetShader
,
1835 d3d11_immediate_context_IASetPrimitiveTopology
,
1836 d3d11_immediate_context_VSSetShaderResources
,
1837 d3d11_immediate_context_VSSetSamplers
,
1838 d3d11_immediate_context_Begin
,
1839 d3d11_immediate_context_End
,
1840 d3d11_immediate_context_GetData
,
1841 d3d11_immediate_context_SetPredication
,
1842 d3d11_immediate_context_GSSetShaderResources
,
1843 d3d11_immediate_context_GSSetSamplers
,
1844 d3d11_immediate_context_OMSetRenderTargets
,
1845 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
1846 d3d11_immediate_context_OMSetBlendState
,
1847 d3d11_immediate_context_OMSetDepthStencilState
,
1848 d3d11_immediate_context_SOSetTargets
,
1849 d3d11_immediate_context_DrawAuto
,
1850 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
1851 d3d11_immediate_context_DrawInstancedIndirect
,
1852 d3d11_immediate_context_Dispatch
,
1853 d3d11_immediate_context_DispatchIndirect
,
1854 d3d11_immediate_context_RSSetState
,
1855 d3d11_immediate_context_RSSetViewports
,
1856 d3d11_immediate_context_RSSetScissorRects
,
1857 d3d11_immediate_context_CopySubresourceRegion
,
1858 d3d11_immediate_context_CopyResource
,
1859 d3d11_immediate_context_UpdateSubresource
,
1860 d3d11_immediate_context_CopyStructureCount
,
1861 d3d11_immediate_context_ClearRenderTargetView
,
1862 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
1863 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
1864 d3d11_immediate_context_ClearDepthStencilView
,
1865 d3d11_immediate_context_GenerateMips
,
1866 d3d11_immediate_context_SetResourceMinLOD
,
1867 d3d11_immediate_context_GetResourceMinLOD
,
1868 d3d11_immediate_context_ResolveSubresource
,
1869 d3d11_immediate_context_ExecuteCommandList
,
1870 d3d11_immediate_context_HSSetShaderResources
,
1871 d3d11_immediate_context_HSSetShader
,
1872 d3d11_immediate_context_HSSetSamplers
,
1873 d3d11_immediate_context_HSSetConstantBuffers
,
1874 d3d11_immediate_context_DSSetShaderResources
,
1875 d3d11_immediate_context_DSSetShader
,
1876 d3d11_immediate_context_DSSetSamplers
,
1877 d3d11_immediate_context_DSSetConstantBuffers
,
1878 d3d11_immediate_context_CSSetShaderResources
,
1879 d3d11_immediate_context_CSSetUnorderedAccessViews
,
1880 d3d11_immediate_context_CSSetShader
,
1881 d3d11_immediate_context_CSSetSamplers
,
1882 d3d11_immediate_context_CSSetConstantBuffers
,
1883 d3d11_immediate_context_VSGetConstantBuffers
,
1884 d3d11_immediate_context_PSGetShaderResources
,
1885 d3d11_immediate_context_PSGetShader
,
1886 d3d11_immediate_context_PSGetSamplers
,
1887 d3d11_immediate_context_VSGetShader
,
1888 d3d11_immediate_context_PSGetConstantBuffers
,
1889 d3d11_immediate_context_IAGetInputLayout
,
1890 d3d11_immediate_context_IAGetVertexBuffers
,
1891 d3d11_immediate_context_IAGetIndexBuffer
,
1892 d3d11_immediate_context_GSGetConstantBuffers
,
1893 d3d11_immediate_context_GSGetShader
,
1894 d3d11_immediate_context_IAGetPrimitiveTopology
,
1895 d3d11_immediate_context_VSGetShaderResources
,
1896 d3d11_immediate_context_VSGetSamplers
,
1897 d3d11_immediate_context_GetPredication
,
1898 d3d11_immediate_context_GSGetShaderResources
,
1899 d3d11_immediate_context_GSGetSamplers
,
1900 d3d11_immediate_context_OMGetRenderTargets
,
1901 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
1902 d3d11_immediate_context_OMGetBlendState
,
1903 d3d11_immediate_context_OMGetDepthStencilState
,
1904 d3d11_immediate_context_SOGetTargets
,
1905 d3d11_immediate_context_RSGetState
,
1906 d3d11_immediate_context_RSGetViewports
,
1907 d3d11_immediate_context_RSGetScissorRects
,
1908 d3d11_immediate_context_HSGetShaderResources
,
1909 d3d11_immediate_context_HSGetShader
,
1910 d3d11_immediate_context_HSGetSamplers
,
1911 d3d11_immediate_context_HSGetConstantBuffers
,
1912 d3d11_immediate_context_DSGetShaderResources
,
1913 d3d11_immediate_context_DSGetShader
,
1914 d3d11_immediate_context_DSGetSamplers
,
1915 d3d11_immediate_context_DSGetConstantBuffers
,
1916 d3d11_immediate_context_CSGetShaderResources
,
1917 d3d11_immediate_context_CSGetUnorderedAccessViews
,
1918 d3d11_immediate_context_CSGetShader
,
1919 d3d11_immediate_context_CSGetSamplers
,
1920 d3d11_immediate_context_CSGetConstantBuffers
,
1921 d3d11_immediate_context_ClearState
,
1922 d3d11_immediate_context_Flush
,
1923 d3d11_immediate_context_GetType
,
1924 d3d11_immediate_context_GetContextFlags
,
1925 d3d11_immediate_context_FinishCommandList
,
1928 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
1930 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
1931 context
->refcount
= 1;
1933 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
1935 wined3d_private_store_init(&context
->private_store
);
1938 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
1940 wined3d_private_store_cleanup(&context
->private_store
);
1943 /* ID3D11Device methods */
1945 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
1947 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1948 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
1951 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
1953 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1954 return IUnknown_AddRef(device
->outer_unk
);
1957 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
1959 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1960 return IUnknown_Release(device
->outer_unk
);
1963 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
1964 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
1966 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1967 struct d3d_buffer
*object
;
1970 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
1972 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
1975 *buffer
= &object
->ID3D11Buffer_iface
;
1980 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
1981 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
1983 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
1988 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
1989 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
1991 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1992 struct d3d_texture2d
*object
;
1995 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
1997 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2000 *texture
= &object
->ID3D11Texture2D_iface
;
2005 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2006 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2008 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2009 struct d3d_texture3d
*object
;
2012 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2014 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2017 *texture
= &object
->ID3D11Texture3D_iface
;
2022 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2023 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2025 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2026 struct d3d_shader_resource_view
*object
;
2029 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2031 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2034 *view
= &object
->ID3D11ShaderResourceView_iface
;
2039 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2040 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2042 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
2047 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2048 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2050 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2051 struct d3d_rendertarget_view
*object
;
2054 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2056 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2059 *view
= &object
->ID3D11RenderTargetView_iface
;
2064 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2065 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2067 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2068 struct d3d_depthstencil_view
*object
;
2071 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2073 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2076 *view
= &object
->ID3D11DepthStencilView_iface
;
2081 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2082 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2083 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2085 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2086 struct d3d_input_layout
*object
;
2089 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2090 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2091 shader_byte_code_length
, input_layout
);
2093 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2094 shader_byte_code
, shader_byte_code_length
, &object
)))
2097 *input_layout
= &object
->ID3D11InputLayout_iface
;
2102 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2103 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2105 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2106 struct d3d_vertex_shader
*object
;
2109 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2110 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2113 FIXME("Class linkage is not implemented yet.\n");
2115 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2118 *shader
= &object
->ID3D11VertexShader_iface
;
2123 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2124 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2126 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2127 struct d3d_geometry_shader
*object
;
2130 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2131 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2134 FIXME("Class linkage is not implemented yet.\n");
2136 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2139 *shader
= &object
->ID3D11GeometryShader_iface
;
2144 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2145 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2146 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
2147 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2149 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2150 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2151 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2152 rasterized_stream
, class_linkage
, shader
);
2157 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2158 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2160 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2161 struct d3d_pixel_shader
*object
;
2164 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2165 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2168 FIXME("Class linkage is not implemented yet.\n");
2170 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2173 *shader
= &object
->ID3D11PixelShader_iface
;
2178 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2179 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2181 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2182 struct d3d11_hull_shader
*object
;
2185 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2186 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2189 FIXME("Class linkage is not implemented yet.\n");
2191 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2194 *shader
= &object
->ID3D11HullShader_iface
;
2199 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2200 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2202 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2203 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2208 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2209 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2211 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2212 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2217 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2218 ID3D11ClassLinkage
**class_linkage
)
2220 FIXME("iface %p, class_linkage %p stub!\n", iface
, class_linkage
);
2225 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
2226 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
2228 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2229 struct d3d_blend_state
*object
;
2230 struct wine_rb_entry
*entry
;
2231 D3D11_BLEND_DESC tmp_desc
;
2235 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2238 return E_INVALIDARG
;
2240 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2241 * D3D11_BLEND_DESC as a key in the rbtree. */
2242 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2243 tmp_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
2244 tmp_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
2245 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2247 j
= desc
->IndependentBlendEnable
? i
: 0;
2248 tmp_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[j
].BlendEnable
;
2249 tmp_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[j
].SrcBlend
;
2250 tmp_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[j
].DestBlend
;
2251 tmp_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[j
].BlendOp
;
2252 tmp_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[j
].SrcBlendAlpha
;
2253 tmp_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[j
].DestBlendAlpha
;
2254 tmp_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[j
].BlendOpAlpha
;
2255 tmp_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[j
].RenderTargetWriteMask
;
2258 wined3d_mutex_lock();
2259 if ((entry
= wine_rb_get(&device
->blend_states
, &tmp_desc
)))
2261 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_blend_state
, entry
);
2263 TRACE("Returning existing blend state %p.\n", object
);
2264 *blend_state
= &object
->ID3D11BlendState_iface
;
2265 ID3D11BlendState_AddRef(*blend_state
);
2266 wined3d_mutex_unlock();
2270 wined3d_mutex_unlock();
2272 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2273 return E_OUTOFMEMORY
;
2275 if (FAILED(hr
= d3d_blend_state_init(object
, device
, &tmp_desc
)))
2277 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2278 HeapFree(GetProcessHeap(), 0, object
);
2282 TRACE("Created blend state %p.\n", object
);
2283 *blend_state
= &object
->ID3D11BlendState_iface
;
2288 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
2289 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
2291 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2292 struct d3d_depthstencil_state
*object
;
2293 D3D11_DEPTH_STENCIL_DESC tmp_desc
;
2294 struct wine_rb_entry
*entry
;
2297 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2300 return E_INVALIDARG
;
2302 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2303 * it as a key in the rbtree. */
2304 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2305 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2306 if (desc
->DepthEnable
)
2308 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2309 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2313 tmp_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
2314 tmp_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
2316 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2317 if (desc
->StencilEnable
)
2319 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2320 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2321 tmp_desc
.FrontFace
= desc
->FrontFace
;
2322 tmp_desc
.BackFace
= desc
->BackFace
;
2326 tmp_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
2327 tmp_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
2328 tmp_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2329 tmp_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2330 tmp_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2331 tmp_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2332 tmp_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2333 tmp_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2334 tmp_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2335 tmp_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2338 wined3d_mutex_lock();
2339 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2341 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_depthstencil_state
, entry
);
2343 TRACE("Returning existing depthstencil state %p.\n", object
);
2344 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2345 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
2346 wined3d_mutex_unlock();
2350 wined3d_mutex_unlock();
2352 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2353 return E_OUTOFMEMORY
;
2355 if (FAILED(hr
= d3d_depthstencil_state_init(object
, device
, &tmp_desc
)))
2357 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2358 HeapFree(GetProcessHeap(), 0, object
);
2362 TRACE("Created depthstencil state %p.\n", object
);
2363 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2368 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
2369 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
2371 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2372 struct d3d_rasterizer_state
*object
;
2373 struct wine_rb_entry
*entry
;
2376 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2379 return E_INVALIDARG
;
2381 wined3d_mutex_lock();
2382 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2384 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_rasterizer_state
, entry
);
2386 TRACE("Returning existing rasterizer state %p.\n", object
);
2387 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2388 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2389 wined3d_mutex_unlock();
2393 wined3d_mutex_unlock();
2395 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2396 return E_OUTOFMEMORY
;
2398 if (FAILED(hr
= d3d_rasterizer_state_init(object
, device
, desc
)))
2400 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2401 HeapFree(GetProcessHeap(), 0, object
);
2405 TRACE("Created rasterizer state %p.\n", object
);
2406 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2411 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
2412 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
2414 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2415 D3D11_SAMPLER_DESC normalized_desc
;
2416 struct d3d_sampler_state
*object
;
2417 struct wine_rb_entry
*entry
;
2420 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2423 return E_INVALIDARG
;
2425 normalized_desc
= *desc
;
2426 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc
.Filter
))
2427 normalized_desc
.MaxAnisotropy
= 0;
2428 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc
.Filter
))
2429 normalized_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
2430 if (normalized_desc
.AddressU
!= D3D11_TEXTURE_ADDRESS_BORDER
2431 && normalized_desc
.AddressV
!= D3D11_TEXTURE_ADDRESS_BORDER
2432 && normalized_desc
.AddressW
!= D3D11_TEXTURE_ADDRESS_BORDER
)
2433 memset(&normalized_desc
.BorderColor
, 0, sizeof(normalized_desc
.BorderColor
));
2435 wined3d_mutex_lock();
2436 if ((entry
= wine_rb_get(&device
->sampler_states
, &normalized_desc
)))
2438 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_sampler_state
, entry
);
2440 TRACE("Returning existing sampler state %p.\n", object
);
2441 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2442 ID3D11SamplerState_AddRef(*sampler_state
);
2443 wined3d_mutex_unlock();
2447 wined3d_mutex_unlock();
2449 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2450 return E_OUTOFMEMORY
;
2452 if (FAILED(hr
= d3d_sampler_state_init(object
, device
, &normalized_desc
)))
2454 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2455 HeapFree(GetProcessHeap(), 0, object
);
2459 TRACE("Created sampler state %p.\n", object
);
2460 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2465 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
2466 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
2468 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2469 struct d3d_query
*object
;
2472 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2474 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
2477 *query
= &object
->ID3D11Query_iface
;
2482 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
2483 ID3D11Predicate
**predicate
)
2485 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2486 struct d3d_query
*object
;
2489 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2491 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
2494 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
2499 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2500 ID3D11Counter
**counter
)
2502 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2507 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
2508 ID3D11DeviceContext
**context
)
2510 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
2515 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
2518 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
2523 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
2524 UINT
*format_support
)
2526 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
2531 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
2532 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2534 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2535 struct wined3d_device_creation_parameters params
;
2536 struct wined3d
*wined3d
;
2539 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
2540 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2542 if (!quality_level_count
)
2543 return E_INVALIDARG
;
2545 *quality_level_count
= 0;
2549 if (sample_count
== 1)
2551 *quality_level_count
= 1;
2554 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
2557 wined3d_mutex_lock();
2558 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
2559 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
2560 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
2561 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
2562 wined3d_mutex_unlock();
2564 if (hr
== WINED3DERR_INVALIDCALL
)
2565 return E_INVALIDARG
;
2566 if (hr
== WINED3DERR_NOTAVAILABLE
)
2571 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
2573 FIXME("iface %p, info %p stub!\n", iface
, info
);
2576 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2577 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
2578 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2580 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2581 "units %p, units_length %p, description %p, description_length %p stub!\n",
2582 iface
, desc
, type
, active_counter_count
, name
, name_length
,
2583 units
, units_length
, description
, description_length
);
2588 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
2589 void *feature_support_data
, UINT feature_support_data_size
)
2591 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2592 iface
, feature
, feature_support_data
, feature_support_data_size
);
2597 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2598 UINT
*data_size
, void *data
)
2600 IDXGIDevice
*dxgi_device
;
2603 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2605 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2607 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
2608 IDXGIDevice_Release(dxgi_device
);
2613 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2614 UINT data_size
, const void *data
)
2616 IDXGIDevice
*dxgi_device
;
2619 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2621 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2623 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
2624 IDXGIDevice_Release(dxgi_device
);
2629 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
2630 const IUnknown
*data
)
2632 IDXGIDevice
*dxgi_device
;
2635 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
2637 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2639 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
2640 IDXGIDevice_Release(dxgi_device
);
2645 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
2647 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2649 TRACE("iface %p.\n", iface
);
2651 return device
->feature_level
;
2654 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
2656 FIXME("iface %p stub!\n", iface
);
2661 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
2663 FIXME("iface %p stub!\n", iface
);
2668 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
2669 ID3D11DeviceContext
**immediate_context
)
2671 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2673 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
2675 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
2676 ID3D11DeviceContext_AddRef(*immediate_context
);
2679 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
2681 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2686 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
2688 FIXME("iface %p stub!\n", iface
);
2693 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
2695 /* IUnknown methods */
2696 d3d11_device_QueryInterface
,
2697 d3d11_device_AddRef
,
2698 d3d11_device_Release
,
2699 /* ID3D11Device methods */
2700 d3d11_device_CreateBuffer
,
2701 d3d11_device_CreateTexture1D
,
2702 d3d11_device_CreateTexture2D
,
2703 d3d11_device_CreateTexture3D
,
2704 d3d11_device_CreateShaderResourceView
,
2705 d3d11_device_CreateUnorderedAccessView
,
2706 d3d11_device_CreateRenderTargetView
,
2707 d3d11_device_CreateDepthStencilView
,
2708 d3d11_device_CreateInputLayout
,
2709 d3d11_device_CreateVertexShader
,
2710 d3d11_device_CreateGeometryShader
,
2711 d3d11_device_CreateGeometryShaderWithStreamOutput
,
2712 d3d11_device_CreatePixelShader
,
2713 d3d11_device_CreateHullShader
,
2714 d3d11_device_CreateDomainShader
,
2715 d3d11_device_CreateComputeShader
,
2716 d3d11_device_CreateClassLinkage
,
2717 d3d11_device_CreateBlendState
,
2718 d3d11_device_CreateDepthStencilState
,
2719 d3d11_device_CreateRasterizerState
,
2720 d3d11_device_CreateSamplerState
,
2721 d3d11_device_CreateQuery
,
2722 d3d11_device_CreatePredicate
,
2723 d3d11_device_CreateCounter
,
2724 d3d11_device_CreateDeferredContext
,
2725 d3d11_device_OpenSharedResource
,
2726 d3d11_device_CheckFormatSupport
,
2727 d3d11_device_CheckMultisampleQualityLevels
,
2728 d3d11_device_CheckCounterInfo
,
2729 d3d11_device_CheckCounter
,
2730 d3d11_device_CheckFeatureSupport
,
2731 d3d11_device_GetPrivateData
,
2732 d3d11_device_SetPrivateData
,
2733 d3d11_device_SetPrivateDataInterface
,
2734 d3d11_device_GetFeatureLevel
,
2735 d3d11_device_GetCreationFlags
,
2736 d3d11_device_GetDeviceRemovedReason
,
2737 d3d11_device_GetImmediateContext
,
2738 d3d11_device_SetExceptionMode
,
2739 d3d11_device_GetExceptionMode
,
2742 /* Inner IUnknown methods */
2744 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
2746 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
2749 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
2751 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2753 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
2755 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
2756 || IsEqualGUID(riid
, &IID_IUnknown
))
2758 *out
= &device
->ID3D11Device_iface
;
2760 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
2761 || IsEqualGUID(riid
, &IID_ID3D10Device
))
2763 *out
= &device
->ID3D10Device1_iface
;
2765 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
2767 *out
= &device
->ID3D10Multithread_iface
;
2769 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
2771 *out
= &device
->IWineDXGIDeviceParent_iface
;
2775 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
2777 return E_NOINTERFACE
;
2780 IUnknown_AddRef((IUnknown
*)*out
);
2784 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
2786 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2787 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
2789 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
2794 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
2796 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2797 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
2799 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
2803 d3d11_immediate_context_destroy(&device
->immediate_context
);
2804 if (device
->wined3d_device
)
2806 wined3d_mutex_lock();
2807 wined3d_device_decref(device
->wined3d_device
);
2808 wined3d_mutex_unlock();
2810 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
2811 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
2812 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
2813 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
2819 /* IUnknown methods */
2821 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
2824 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2825 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
2828 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
2830 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2831 return IUnknown_AddRef(This
->outer_unk
);
2834 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
2836 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2837 return IUnknown_Release(This
->outer_unk
);
2840 /* ID3D10Device methods */
2842 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
2843 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2845 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2848 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2849 iface
, start_slot
, buffer_count
, buffers
);
2851 wined3d_mutex_lock();
2852 for (i
= 0; i
< buffer_count
; ++i
)
2854 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2856 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
2857 buffer
? buffer
->wined3d_buffer
: NULL
);
2859 wined3d_mutex_unlock();
2862 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
2863 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
2865 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2868 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2869 iface
, start_slot
, view_count
, views
);
2871 wined3d_mutex_lock();
2872 for (i
= 0; i
< view_count
; ++i
)
2874 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
2876 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
2877 view
? view
->wined3d_view
: NULL
);
2879 wined3d_mutex_unlock();
2882 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
2883 ID3D10PixelShader
*shader
)
2885 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2886 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
2888 TRACE("iface %p, shader %p\n", iface
, shader
);
2890 wined3d_mutex_lock();
2891 wined3d_device_set_pixel_shader(This
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
2892 wined3d_mutex_unlock();
2895 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
2896 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
2898 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2901 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2902 iface
, start_slot
, sampler_count
, samplers
);
2904 wined3d_mutex_lock();
2905 for (i
= 0; i
< sampler_count
; ++i
)
2907 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
2909 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
2910 sampler
? sampler
->wined3d_sampler
: NULL
);
2912 wined3d_mutex_unlock();
2915 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
2916 ID3D10VertexShader
*shader
)
2918 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2919 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
2921 TRACE("iface %p, shader %p\n", iface
, shader
);
2923 wined3d_mutex_lock();
2924 wined3d_device_set_vertex_shader(This
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
2925 wined3d_mutex_unlock();
2928 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
2929 UINT start_index_location
, INT base_vertex_location
)
2931 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2933 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2934 iface
, index_count
, start_index_location
, base_vertex_location
);
2936 wined3d_mutex_lock();
2937 wined3d_device_set_base_vertex_index(This
->wined3d_device
, base_vertex_location
);
2938 wined3d_device_draw_indexed_primitive(This
->wined3d_device
, start_index_location
, index_count
);
2939 wined3d_mutex_unlock();
2942 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
2943 UINT start_vertex_location
)
2945 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2947 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2948 iface
, vertex_count
, start_vertex_location
);
2950 wined3d_mutex_lock();
2951 wined3d_device_draw_primitive(This
->wined3d_device
, start_vertex_location
, vertex_count
);
2952 wined3d_mutex_unlock();
2955 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
2956 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2958 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2961 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2962 iface
, start_slot
, buffer_count
, buffers
);
2964 wined3d_mutex_lock();
2965 for (i
= 0; i
< buffer_count
; ++i
)
2967 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2969 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
2970 buffer
? buffer
->wined3d_buffer
: NULL
);
2972 wined3d_mutex_unlock();
2975 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
2976 ID3D10InputLayout
*input_layout
)
2978 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2979 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
2981 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
2983 wined3d_mutex_lock();
2984 wined3d_device_set_vertex_declaration(This
->wined3d_device
,
2985 layout
? layout
->wined3d_decl
: NULL
);
2986 wined3d_mutex_unlock();
2989 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
2990 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
2992 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2995 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
2996 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
2998 wined3d_mutex_lock();
2999 for (i
= 0; i
< buffer_count
; ++i
)
3001 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3003 wined3d_device_set_stream_source(This
->wined3d_device
, start_slot
+ i
,
3004 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3006 wined3d_mutex_unlock();
3009 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3010 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3012 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3013 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3015 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3016 iface
, buffer
, debug_dxgi_format(format
), offset
);
3018 wined3d_mutex_lock();
3019 wined3d_device_set_index_buffer(This
->wined3d_device
,
3020 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3021 wined3dformat_from_dxgi_format(format
));
3022 wined3d_mutex_unlock();
3023 if (offset
) FIXME("offset %u not supported.\n", offset
);
3026 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3027 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3028 INT base_vertex_location
, UINT start_instance_location
)
3030 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3032 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3033 "base_vertex_location %d, start_instance_location %u.\n",
3034 iface
, instance_index_count
, instance_count
, start_index_location
,
3035 base_vertex_location
, start_instance_location
);
3037 wined3d_mutex_lock();
3038 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3039 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3040 instance_index_count
, start_instance_location
, instance_count
);
3041 wined3d_mutex_unlock();
3044 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3045 UINT instance_vertex_count
, UINT instance_count
,
3046 UINT start_vertex_location
, UINT start_instance_location
)
3048 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3050 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3051 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3052 start_vertex_location
, start_instance_location
);
3054 wined3d_mutex_lock();
3055 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3056 instance_vertex_count
, start_instance_location
, instance_count
);
3057 wined3d_mutex_unlock();
3060 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3061 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3063 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3066 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3067 iface
, start_slot
, buffer_count
, buffers
);
3069 wined3d_mutex_lock();
3070 for (i
= 0; i
< buffer_count
; ++i
)
3072 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3074 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3075 buffer
? buffer
->wined3d_buffer
: NULL
);
3077 wined3d_mutex_unlock();
3080 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3082 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3083 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3085 TRACE("iface %p, shader %p.\n", iface
, shader
);
3087 wined3d_mutex_lock();
3088 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3089 wined3d_mutex_unlock();
3092 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3093 D3D10_PRIMITIVE_TOPOLOGY topology
)
3095 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3097 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
3099 wined3d_mutex_lock();
3100 wined3d_device_set_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
3101 wined3d_mutex_unlock();
3104 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3105 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3107 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3110 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3111 iface
, start_slot
, view_count
, views
);
3113 wined3d_mutex_lock();
3114 for (i
= 0; i
< view_count
; ++i
)
3116 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3118 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3119 view
? view
->wined3d_view
: NULL
);
3121 wined3d_mutex_unlock();
3124 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3125 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3127 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3130 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3131 iface
, start_slot
, sampler_count
, samplers
);
3133 wined3d_mutex_lock();
3134 for (i
= 0; i
< sampler_count
; ++i
)
3136 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3138 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3139 sampler
? sampler
->wined3d_sampler
: NULL
);
3141 wined3d_mutex_unlock();
3144 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3146 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3147 struct d3d_query
*query
;
3149 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3151 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3152 wined3d_mutex_lock();
3153 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3154 wined3d_mutex_unlock();
3157 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3158 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3160 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3163 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3164 iface
, start_slot
, view_count
, views
);
3166 wined3d_mutex_lock();
3167 for (i
= 0; i
< view_count
; ++i
)
3169 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3171 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3172 view
? view
->wined3d_view
: NULL
);
3174 wined3d_mutex_unlock();
3177 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3178 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3180 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3183 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3184 iface
, start_slot
, sampler_count
, samplers
);
3186 wined3d_mutex_lock();
3187 for (i
= 0; i
< sampler_count
; ++i
)
3189 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3191 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3192 sampler
? sampler
->wined3d_sampler
: NULL
);
3194 wined3d_mutex_unlock();
3197 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3198 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3199 ID3D10DepthStencilView
*depth_stencil_view
)
3201 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3202 struct d3d_depthstencil_view
*dsv
;
3205 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3206 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3208 wined3d_mutex_lock();
3209 for (i
= 0; i
< render_target_view_count
; ++i
)
3211 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3213 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3214 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3216 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3218 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3221 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3222 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3223 dsv
? dsv
->wined3d_view
: NULL
);
3224 wined3d_mutex_unlock();
3227 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3228 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3230 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3231 struct d3d_blend_state
*blend_state_object
;
3233 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3234 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3236 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3237 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3238 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3241 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3242 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3244 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3245 struct d3d_depthstencil_state
*ds_state_object
;
3247 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3248 iface
, depth_stencil_state
, stencil_ref
);
3250 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3251 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3252 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
3255 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3256 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3258 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3259 unsigned int count
, i
;
3261 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3263 count
= min(target_count
, 4);
3264 wined3d_mutex_lock();
3265 for (i
= 0; i
< count
; ++i
)
3267 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
3269 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
3270 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
3273 for (i
= count
; i
< 4; ++i
)
3275 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
3277 wined3d_mutex_unlock();
3280 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
3282 FIXME("iface %p stub!\n", iface
);
3285 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
3287 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3288 struct d3d_rasterizer_state
*rasterizer_state_object
;
3290 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3292 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
3293 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3294 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
3297 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
3298 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
3300 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3301 struct wined3d_viewport wined3d_vp
;
3303 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
3305 if (viewport_count
> 1)
3306 FIXME("Multiple viewports not implemented.\n");
3308 if (!viewport_count
)
3311 wined3d_vp
.x
= viewports
[0].TopLeftX
;
3312 wined3d_vp
.y
= viewports
[0].TopLeftY
;
3313 wined3d_vp
.width
= viewports
[0].Width
;
3314 wined3d_vp
.height
= viewports
[0].Height
;
3315 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
3316 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
3318 wined3d_mutex_lock();
3319 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
3320 wined3d_mutex_unlock();
3323 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
3324 UINT rect_count
, const D3D10_RECT
*rects
)
3326 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3328 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
3331 FIXME("Multiple scissor rects not implemented.\n");
3336 wined3d_mutex_lock();
3337 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
3338 wined3d_mutex_unlock();
3341 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
3342 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
3343 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
3345 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3346 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3347 struct wined3d_box wined3d_src_box
;
3349 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3350 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3351 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
3352 src_resource
, src_subresource_idx
, src_box
);
3356 wined3d_src_box
.left
= src_box
->left
;
3357 wined3d_src_box
.top
= src_box
->top
;
3358 wined3d_src_box
.front
= src_box
->front
;
3359 wined3d_src_box
.right
= src_box
->right
;
3360 wined3d_src_box
.bottom
= src_box
->bottom
;
3361 wined3d_src_box
.back
= src_box
->back
;
3364 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3365 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3366 wined3d_mutex_lock();
3367 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
3368 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
3369 wined3d_mutex_unlock();
3372 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
3373 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
3375 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3376 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3378 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
3380 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3381 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3382 wined3d_mutex_lock();
3383 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
3384 wined3d_mutex_unlock();
3387 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
3388 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
3389 const void *data
, UINT row_pitch
, UINT depth_pitch
)
3391 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3392 ID3D11Resource
*d3d11_resource
;
3394 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3395 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
3397 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
3398 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3399 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
3400 ID3D11Resource_Release(d3d11_resource
);
3403 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
3404 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
3406 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3407 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
3408 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
3411 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
3412 iface
, render_target_view
, debug_float4(color_rgba
));
3414 wined3d_mutex_lock();
3415 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3416 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
3417 ERR("Failed to clear view, hr %#x.\n", hr
);
3418 wined3d_mutex_unlock();
3421 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
3422 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
3424 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3425 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3426 DWORD wined3d_flags
;
3429 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
3430 iface
, depth_stencil_view
, flags
, depth
, stencil
);
3432 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
3434 wined3d_mutex_lock();
3435 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3436 wined3d_flags
, NULL
, depth
, stencil
)))
3437 ERR("Failed to clear view, hr %#x.\n", hr
);
3438 wined3d_mutex_unlock();
3441 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
3442 ID3D10ShaderResourceView
*shader_resource_view
)
3444 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
3447 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
3448 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
3449 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
3451 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3452 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3453 iface
, dst_resource
, dst_subresource_idx
,
3454 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
3457 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
3458 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3460 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3463 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3464 iface
, start_slot
, buffer_count
, buffers
);
3466 wined3d_mutex_lock();
3467 for (i
= 0; i
< buffer_count
; ++i
)
3469 struct wined3d_buffer
*wined3d_buffer
;
3470 struct d3d_buffer
*buffer_impl
;
3472 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
3478 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3479 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3480 ID3D10Buffer_AddRef(buffers
[i
]);
3482 wined3d_mutex_unlock();
3485 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
3486 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3488 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3491 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3492 iface
, start_slot
, view_count
, views
);
3494 wined3d_mutex_lock();
3495 for (i
= 0; i
< view_count
; ++i
)
3497 struct wined3d_shader_resource_view
*wined3d_view
;
3498 struct d3d_shader_resource_view
*view_impl
;
3500 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3506 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3507 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3508 ID3D10ShaderResourceView_AddRef(views
[i
]);
3510 wined3d_mutex_unlock();
3513 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
3515 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3516 struct d3d_pixel_shader
*shader_impl
;
3517 struct wined3d_shader
*wined3d_shader
;
3519 TRACE("iface %p, shader %p.\n", iface
, shader
);
3521 wined3d_mutex_lock();
3522 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
3524 wined3d_mutex_unlock();
3529 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3530 wined3d_mutex_unlock();
3531 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
3532 ID3D10PixelShader_AddRef(*shader
);
3535 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
3536 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3538 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3541 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3542 iface
, start_slot
, sampler_count
, samplers
);
3544 wined3d_mutex_lock();
3545 for (i
= 0; i
< sampler_count
; ++i
)
3547 struct d3d_sampler_state
*sampler_impl
;
3548 struct wined3d_sampler
*wined3d_sampler
;
3550 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
3556 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3557 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3558 ID3D10SamplerState_AddRef(samplers
[i
]);
3560 wined3d_mutex_unlock();
3563 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
3565 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3566 struct d3d_vertex_shader
*shader_impl
;
3567 struct wined3d_shader
*wined3d_shader
;
3569 TRACE("iface %p, shader %p.\n", iface
, shader
);
3571 wined3d_mutex_lock();
3572 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
3574 wined3d_mutex_unlock();
3579 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3580 wined3d_mutex_unlock();
3581 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
3582 ID3D10VertexShader_AddRef(*shader
);
3585 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
3586 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3588 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3591 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3592 iface
, start_slot
, buffer_count
, buffers
);
3594 wined3d_mutex_lock();
3595 for (i
= 0; i
< buffer_count
; ++i
)
3597 struct wined3d_buffer
*wined3d_buffer
;
3598 struct d3d_buffer
*buffer_impl
;
3600 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
3606 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3607 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3608 ID3D10Buffer_AddRef(buffers
[i
]);
3610 wined3d_mutex_unlock();
3613 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
3615 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3616 struct wined3d_vertex_declaration
*wined3d_declaration
;
3617 struct d3d_input_layout
*input_layout_impl
;
3619 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
3621 wined3d_mutex_lock();
3622 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
3624 wined3d_mutex_unlock();
3625 *input_layout
= NULL
;
3629 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
3630 wined3d_mutex_unlock();
3631 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
3632 ID3D10InputLayout_AddRef(*input_layout
);
3635 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
3636 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
3638 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3641 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3642 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3644 wined3d_mutex_lock();
3645 for (i
= 0; i
< buffer_count
; ++i
)
3647 struct wined3d_buffer
*wined3d_buffer
;
3648 struct d3d_buffer
*buffer_impl
;
3650 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
3651 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
3652 ERR("Failed to get vertex buffer.\n");
3654 if (!wined3d_buffer
)
3660 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3661 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3662 ID3D10Buffer_AddRef(buffers
[i
]);
3664 wined3d_mutex_unlock();
3667 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
3668 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
3670 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3671 enum wined3d_format_id wined3d_format
;
3672 struct wined3d_buffer
*wined3d_buffer
;
3673 struct d3d_buffer
*buffer_impl
;
3675 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
3677 wined3d_mutex_lock();
3678 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
);
3679 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
3680 *offset
= 0; /* FIXME */
3681 if (!wined3d_buffer
)
3683 wined3d_mutex_unlock();
3688 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3689 wined3d_mutex_unlock();
3690 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
3691 ID3D10Buffer_AddRef(*buffer
);
3694 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
3695 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3697 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3700 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3701 iface
, start_slot
, buffer_count
, buffers
);
3703 wined3d_mutex_lock();
3704 for (i
= 0; i
< buffer_count
; ++i
)
3706 struct wined3d_buffer
*wined3d_buffer
;
3707 struct d3d_buffer
*buffer_impl
;
3709 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
3715 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3716 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3717 ID3D10Buffer_AddRef(buffers
[i
]);
3719 wined3d_mutex_unlock();
3722 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
3724 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3725 struct d3d_geometry_shader
*shader_impl
;
3726 struct wined3d_shader
*wined3d_shader
;
3728 TRACE("iface %p, shader %p.\n", iface
, shader
);
3730 wined3d_mutex_lock();
3731 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
3733 wined3d_mutex_unlock();
3738 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3739 wined3d_mutex_unlock();
3740 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
3741 ID3D10GeometryShader_AddRef(*shader
);
3744 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
3745 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
3747 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3749 TRACE("iface %p, topology %p\n", iface
, topology
);
3751 wined3d_mutex_lock();
3752 wined3d_device_get_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
3753 wined3d_mutex_unlock();
3756 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
3757 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3759 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3762 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3763 iface
, start_slot
, view_count
, views
);
3765 wined3d_mutex_lock();
3766 for (i
= 0; i
< view_count
; ++i
)
3768 struct wined3d_shader_resource_view
*wined3d_view
;
3769 struct d3d_shader_resource_view
*view_impl
;
3771 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3777 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3778 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3779 ID3D10ShaderResourceView_AddRef(views
[i
]);
3781 wined3d_mutex_unlock();
3784 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
3785 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3787 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3790 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3791 iface
, start_slot
, sampler_count
, samplers
);
3793 wined3d_mutex_lock();
3794 for (i
= 0; i
< sampler_count
; ++i
)
3796 struct d3d_sampler_state
*sampler_impl
;
3797 struct wined3d_sampler
*wined3d_sampler
;
3799 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3805 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3806 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3807 ID3D10SamplerState_AddRef(samplers
[i
]);
3809 wined3d_mutex_unlock();
3812 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
3813 ID3D10Predicate
**predicate
, BOOL
*value
)
3815 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3816 struct wined3d_query
*wined3d_predicate
;
3817 struct d3d_query
*predicate_impl
;
3819 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
3821 wined3d_mutex_lock();
3822 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
3824 wined3d_mutex_unlock();
3829 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
3830 wined3d_mutex_unlock();
3831 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
3832 ID3D10Predicate_AddRef(*predicate
);
3835 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
3836 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3838 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3841 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3842 iface
, start_slot
, view_count
, views
);
3844 wined3d_mutex_lock();
3845 for (i
= 0; i
< view_count
; ++i
)
3847 struct wined3d_shader_resource_view
*wined3d_view
;
3848 struct d3d_shader_resource_view
*view_impl
;
3850 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3856 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3857 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3858 ID3D10ShaderResourceView_AddRef(views
[i
]);
3860 wined3d_mutex_unlock();
3863 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
3864 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3866 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3869 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3870 iface
, start_slot
, sampler_count
, samplers
);
3872 wined3d_mutex_lock();
3873 for (i
= 0; i
< sampler_count
; ++i
)
3875 struct d3d_sampler_state
*sampler_impl
;
3876 struct wined3d_sampler
*wined3d_sampler
;
3878 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3884 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3885 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3886 ID3D10SamplerState_AddRef(samplers
[i
]);
3888 wined3d_mutex_unlock();
3891 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
3892 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
3894 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3895 struct wined3d_rendertarget_view
*wined3d_view
;
3897 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3898 iface
, view_count
, render_target_views
, depth_stencil_view
);
3900 wined3d_mutex_lock();
3901 if (render_target_views
)
3903 struct d3d_rendertarget_view
*view_impl
;
3906 for (i
= 0; i
< view_count
; ++i
)
3908 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
3909 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3911 render_target_views
[i
] = NULL
;
3915 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
3916 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
3920 if (depth_stencil_view
)
3922 struct d3d_depthstencil_view
*view_impl
;
3924 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
3925 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3927 *depth_stencil_view
= NULL
;
3931 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
3932 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
3935 wined3d_mutex_unlock();
3938 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
3939 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
3941 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3943 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3944 iface
, blend_state
, blend_factor
, sample_mask
);
3946 if ((*blend_state
= device
->blend_state
? (ID3D10BlendState
*)&device
->blend_state
->ID3D10BlendState1_iface
: NULL
))
3947 ID3D10BlendState_AddRef(*blend_state
);
3948 wined3d_mutex_lock();
3949 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
3950 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
3951 wined3d_mutex_unlock();
3954 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
3955 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
3957 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3959 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
3960 iface
, depth_stencil_state
, stencil_ref
);
3962 if ((*depth_stencil_state
= device
->depth_stencil_state
3963 ? &device
->depth_stencil_state
->ID3D10DepthStencilState_iface
: NULL
))
3964 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
3965 *stencil_ref
= device
->stencil_ref
;
3968 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
3969 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
3971 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3974 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
3975 iface
, buffer_count
, buffers
, offsets
);
3977 wined3d_mutex_lock();
3978 for (i
= 0; i
< buffer_count
; ++i
)
3980 struct wined3d_buffer
*wined3d_buffer
;
3981 struct d3d_buffer
*buffer_impl
;
3983 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
3989 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3990 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3991 ID3D10Buffer_AddRef(buffers
[i
]);
3993 wined3d_mutex_unlock();
3996 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
3998 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4000 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4002 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
4003 ID3D10RasterizerState_AddRef(*rasterizer_state
);
4006 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4007 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4009 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4010 struct wined3d_viewport wined3d_vp
;
4012 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4016 *viewport_count
= 1;
4020 if (!*viewport_count
)
4023 wined3d_mutex_lock();
4024 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4025 wined3d_mutex_unlock();
4027 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4028 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4029 viewports
[0].Width
= wined3d_vp
.width
;
4030 viewports
[0].Height
= wined3d_vp
.height
;
4031 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4032 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4034 if (*viewport_count
> 1)
4035 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4038 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4040 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4042 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4053 wined3d_mutex_lock();
4054 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4055 wined3d_mutex_unlock();
4056 if (*rect_count
> 1)
4057 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4060 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4062 TRACE("iface %p.\n", iface
);
4064 /* In the current implementation the device is never removed, so we can
4065 * just return S_OK here. */
4070 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4072 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4077 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4079 FIXME("iface %p stub!\n", iface
);
4084 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4085 REFGUID guid
, UINT
*data_size
, void *data
)
4087 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4089 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4091 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4094 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4095 REFGUID guid
, UINT data_size
, const void *data
)
4097 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4099 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4101 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4104 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4105 REFGUID guid
, const IUnknown
*data
)
4107 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4109 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4111 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4114 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4116 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4117 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4120 TRACE("iface %p.\n", iface
);
4122 wined3d_mutex_lock();
4123 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
4124 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4126 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
4128 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4130 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
4132 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4134 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
4136 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
4137 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4139 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
4141 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4143 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
4145 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4147 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
4149 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
4150 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4152 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
4154 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4156 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
4158 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4160 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
4162 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4164 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
4166 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
);
4167 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
4168 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
4169 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4171 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4173 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
4174 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
4175 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4176 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
4177 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
4178 ID3D10Device1_RSSetState(iface
, NULL
);
4179 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4181 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4183 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
4184 wined3d_mutex_unlock();
4187 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4189 FIXME("iface %p stub!\n", iface
);
4192 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4193 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4195 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4196 D3D11_BUFFER_DESC d3d11_desc
;
4197 struct d3d_buffer
*object
;
4200 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4202 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4203 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4204 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4205 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4206 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4207 d3d11_desc
.StructureByteStride
= 0;
4209 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4212 *buffer
= &object
->ID3D10Buffer_iface
;
4217 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4218 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4220 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4225 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4226 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4227 ID3D10Texture2D
**texture
)
4229 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4230 D3D11_TEXTURE2D_DESC d3d11_desc
;
4231 struct d3d_texture2d
*object
;
4234 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4236 d3d11_desc
.Width
= desc
->Width
;
4237 d3d11_desc
.Height
= desc
->Height
;
4238 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4239 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4240 d3d11_desc
.Format
= desc
->Format
;
4241 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4242 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4243 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4244 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4245 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4247 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4250 *texture
= &object
->ID3D10Texture2D_iface
;
4255 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4256 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4257 ID3D10Texture3D
**texture
)
4259 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4260 D3D11_TEXTURE3D_DESC d3d11_desc
;
4261 struct d3d_texture3d
*object
;
4264 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4266 d3d11_desc
.Width
= desc
->Width
;
4267 d3d11_desc
.Height
= desc
->Height
;
4268 d3d11_desc
.Depth
= desc
->Depth
;
4269 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4270 d3d11_desc
.Format
= desc
->Format
;
4271 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4272 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4273 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4274 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4276 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4279 *texture
= &object
->ID3D10Texture3D_iface
;
4284 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4285 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4287 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4288 struct d3d_shader_resource_view
*object
;
4289 ID3D11Resource
*d3d11_resource
;
4292 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4294 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4296 ERR("Resource does not implement ID3D11Resource.\n");
4300 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4302 ID3D11Resource_Release(d3d11_resource
);
4306 *view
= &object
->ID3D10ShaderResourceView1_iface
;
4311 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
4312 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
4314 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4316 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
4317 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
4320 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
4321 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
4323 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4324 struct d3d_rendertarget_view
*object
;
4325 ID3D11Resource
*d3d11_resource
;
4328 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4330 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4332 ERR("Resource does not implement ID3D11Resource.\n");
4336 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
4337 ID3D11Resource_Release(d3d11_resource
);
4341 *view
= &object
->ID3D10RenderTargetView_iface
;
4346 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
4347 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
4349 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4350 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
4351 struct d3d_depthstencil_view
*object
;
4352 ID3D11Resource
*d3d11_resource
;
4355 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4359 d3d11_desc
.Format
= desc
->Format
;
4360 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
4361 d3d11_desc
.Flags
= 0;
4362 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
4365 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4367 ERR("Resource does not implement ID3D11Resource.\n");
4371 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
4372 ID3D11Resource_Release(d3d11_resource
);
4376 *view
= &object
->ID3D10DepthStencilView_iface
;
4381 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
4382 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
4383 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
4384 ID3D10InputLayout
**input_layout
)
4386 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4387 struct d3d_input_layout
*object
;
4390 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4391 "shader_byte_code_length %lu, input_layout %p\n",
4392 iface
, element_descs
, element_count
, shader_byte_code
,
4393 shader_byte_code_length
, input_layout
);
4395 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
4396 shader_byte_code
, shader_byte_code_length
, &object
)))
4399 *input_layout
= &object
->ID3D10InputLayout_iface
;
4404 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
4405 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
4407 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4408 struct d3d_vertex_shader
*object
;
4411 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4412 iface
, byte_code
, byte_code_length
, shader
);
4414 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4417 *shader
= &object
->ID3D10VertexShader_iface
;
4422 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
4423 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
4425 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4426 struct d3d_geometry_shader
*object
;
4429 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4430 iface
, byte_code
, byte_code_length
, shader
);
4432 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4435 *shader
= &object
->ID3D10GeometryShader_iface
;
4440 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
4441 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
4442 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
4444 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4445 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4446 iface
, byte_code
, byte_code_length
, output_stream_decls
,
4447 output_stream_decl_count
, output_stream_stride
, shader
);
4452 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
4453 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
4455 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4456 struct d3d_pixel_shader
*object
;
4459 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4460 iface
, byte_code
, byte_code_length
, shader
);
4462 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4465 *shader
= &object
->ID3D10PixelShader_iface
;
4470 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
4471 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
4473 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4474 ID3D11BlendState
*d3d11_blend_state
;
4477 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4479 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device_iface
, (D3D11_BLEND_DESC
*)desc
,
4480 &d3d11_blend_state
)))
4483 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState1
, (void **)blend_state
);
4484 ID3D11BlendState_Release(d3d11_blend_state
);
4488 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
4489 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
4491 D3D10_BLEND_DESC1 d3d10_1_desc
;
4494 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4497 return E_INVALIDARG
;
4499 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
4500 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
4501 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
4503 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
4504 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
4505 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
4508 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4510 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
4511 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
4512 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
4513 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
4514 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
4515 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
4516 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
4517 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
4520 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
4523 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
4524 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
4526 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4527 ID3D11DepthStencilState
*d3d11_depth_stencil_state
;
4530 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
4532 if (FAILED(hr
= d3d11_device_CreateDepthStencilState(&device
->ID3D11Device_iface
,
4533 (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &d3d11_depth_stencil_state
)))
4536 hr
= ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state
, &IID_ID3D10DepthStencilState
,
4537 (void **)depth_stencil_state
);
4538 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state
);
4542 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
4543 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
4545 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4546 ID3D11RasterizerState
*d3d11_rasterizer_state
;
4549 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
4551 if (FAILED(hr
= d3d11_device_CreateRasterizerState(&device
->ID3D11Device_iface
,
4552 (const D3D11_RASTERIZER_DESC
*)desc
, &d3d11_rasterizer_state
)))
4555 hr
= ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state
,
4556 &IID_ID3D10RasterizerState
, (void **)rasterizer_state
);
4557 ID3D11RasterizerState_Release(d3d11_rasterizer_state
);
4561 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
4562 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
4564 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4565 ID3D11SamplerState
*d3d11_sampler_state
;
4568 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
4570 if (FAILED(hr
= d3d11_device_CreateSamplerState(&device
->ID3D11Device_iface
,
4571 (const D3D11_SAMPLER_DESC
*)desc
, &d3d11_sampler_state
)))
4574 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
, (void **)sampler_state
);
4575 ID3D11SamplerState_Release(d3d11_sampler_state
);
4579 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
4580 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
4582 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4583 struct d3d_query
*object
;
4586 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
4588 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
4591 *query
= &object
->ID3D10Query_iface
;
4596 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
4597 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
4599 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4600 struct d3d_query
*object
;
4603 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
4605 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
4608 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
4613 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
4614 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
4616 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
4621 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
4622 DXGI_FORMAT format
, UINT
*format_support
)
4624 FIXME("iface %p, format %s, format_support %p stub!\n",
4625 iface
, debug_dxgi_format(format
), format_support
);
4630 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
4631 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
4633 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4635 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
4636 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
4638 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
4639 sample_count
, quality_level_count
);
4642 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
4644 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
4647 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
4648 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
4649 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4651 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4652 "units %p, units_length %p, description %p, description_length %p stub!\n",
4653 iface
, desc
, type
, active_counters
, name
, name_length
,
4654 units
, units_length
, description
, description_length
);
4659 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
4661 FIXME("iface %p stub!\n", iface
);
4666 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
4667 HANDLE resource_handle
, REFIID guid
, void **resource
)
4669 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4670 iface
, resource_handle
, debugstr_guid(guid
), resource
);
4675 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
4677 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
4680 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
4682 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
4685 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
4687 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4689 TRACE("iface %p.\n", iface
);
4691 return device
->feature_level
;
4694 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
4696 /* IUnknown methods */
4697 d3d10_device_QueryInterface
,
4698 d3d10_device_AddRef
,
4699 d3d10_device_Release
,
4700 /* ID3D10Device methods */
4701 d3d10_device_VSSetConstantBuffers
,
4702 d3d10_device_PSSetShaderResources
,
4703 d3d10_device_PSSetShader
,
4704 d3d10_device_PSSetSamplers
,
4705 d3d10_device_VSSetShader
,
4706 d3d10_device_DrawIndexed
,
4708 d3d10_device_PSSetConstantBuffers
,
4709 d3d10_device_IASetInputLayout
,
4710 d3d10_device_IASetVertexBuffers
,
4711 d3d10_device_IASetIndexBuffer
,
4712 d3d10_device_DrawIndexedInstanced
,
4713 d3d10_device_DrawInstanced
,
4714 d3d10_device_GSSetConstantBuffers
,
4715 d3d10_device_GSSetShader
,
4716 d3d10_device_IASetPrimitiveTopology
,
4717 d3d10_device_VSSetShaderResources
,
4718 d3d10_device_VSSetSamplers
,
4719 d3d10_device_SetPredication
,
4720 d3d10_device_GSSetShaderResources
,
4721 d3d10_device_GSSetSamplers
,
4722 d3d10_device_OMSetRenderTargets
,
4723 d3d10_device_OMSetBlendState
,
4724 d3d10_device_OMSetDepthStencilState
,
4725 d3d10_device_SOSetTargets
,
4726 d3d10_device_DrawAuto
,
4727 d3d10_device_RSSetState
,
4728 d3d10_device_RSSetViewports
,
4729 d3d10_device_RSSetScissorRects
,
4730 d3d10_device_CopySubresourceRegion
,
4731 d3d10_device_CopyResource
,
4732 d3d10_device_UpdateSubresource
,
4733 d3d10_device_ClearRenderTargetView
,
4734 d3d10_device_ClearDepthStencilView
,
4735 d3d10_device_GenerateMips
,
4736 d3d10_device_ResolveSubresource
,
4737 d3d10_device_VSGetConstantBuffers
,
4738 d3d10_device_PSGetShaderResources
,
4739 d3d10_device_PSGetShader
,
4740 d3d10_device_PSGetSamplers
,
4741 d3d10_device_VSGetShader
,
4742 d3d10_device_PSGetConstantBuffers
,
4743 d3d10_device_IAGetInputLayout
,
4744 d3d10_device_IAGetVertexBuffers
,
4745 d3d10_device_IAGetIndexBuffer
,
4746 d3d10_device_GSGetConstantBuffers
,
4747 d3d10_device_GSGetShader
,
4748 d3d10_device_IAGetPrimitiveTopology
,
4749 d3d10_device_VSGetShaderResources
,
4750 d3d10_device_VSGetSamplers
,
4751 d3d10_device_GetPredication
,
4752 d3d10_device_GSGetShaderResources
,
4753 d3d10_device_GSGetSamplers
,
4754 d3d10_device_OMGetRenderTargets
,
4755 d3d10_device_OMGetBlendState
,
4756 d3d10_device_OMGetDepthStencilState
,
4757 d3d10_device_SOGetTargets
,
4758 d3d10_device_RSGetState
,
4759 d3d10_device_RSGetViewports
,
4760 d3d10_device_RSGetScissorRects
,
4761 d3d10_device_GetDeviceRemovedReason
,
4762 d3d10_device_SetExceptionMode
,
4763 d3d10_device_GetExceptionMode
,
4764 d3d10_device_GetPrivateData
,
4765 d3d10_device_SetPrivateData
,
4766 d3d10_device_SetPrivateDataInterface
,
4767 d3d10_device_ClearState
,
4769 d3d10_device_CreateBuffer
,
4770 d3d10_device_CreateTexture1D
,
4771 d3d10_device_CreateTexture2D
,
4772 d3d10_device_CreateTexture3D
,
4773 d3d10_device_CreateShaderResourceView
,
4774 d3d10_device_CreateRenderTargetView
,
4775 d3d10_device_CreateDepthStencilView
,
4776 d3d10_device_CreateInputLayout
,
4777 d3d10_device_CreateVertexShader
,
4778 d3d10_device_CreateGeometryShader
,
4779 d3d10_device_CreateGeometryShaderWithStreamOutput
,
4780 d3d10_device_CreatePixelShader
,
4781 d3d10_device_CreateBlendState
,
4782 d3d10_device_CreateDepthStencilState
,
4783 d3d10_device_CreateRasterizerState
,
4784 d3d10_device_CreateSamplerState
,
4785 d3d10_device_CreateQuery
,
4786 d3d10_device_CreatePredicate
,
4787 d3d10_device_CreateCounter
,
4788 d3d10_device_CheckFormatSupport
,
4789 d3d10_device_CheckMultisampleQualityLevels
,
4790 d3d10_device_CheckCounterInfo
,
4791 d3d10_device_CheckCounter
,
4792 d3d10_device_GetCreationFlags
,
4793 d3d10_device_OpenSharedResource
,
4794 d3d10_device_SetTextFilterSize
,
4795 d3d10_device_GetTextFilterSize
,
4796 d3d10_device_CreateShaderResourceView1
,
4797 d3d10_device_CreateBlendState1
,
4798 d3d10_device_GetFeatureLevel
,
4801 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
4803 /* IUnknown methods */
4804 d3d_device_inner_QueryInterface
,
4805 d3d_device_inner_AddRef
,
4806 d3d_device_inner_Release
,
4809 /* ID3D10Multithread methods */
4811 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
4813 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
4816 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
4818 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4820 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
4822 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4825 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
4827 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4829 TRACE("iface %p.\n", iface
);
4831 return IUnknown_AddRef(device
->outer_unk
);
4834 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
4836 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4838 TRACE("iface %p.\n", iface
);
4840 return IUnknown_Release(device
->outer_unk
);
4843 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
4845 TRACE("iface %p.\n", iface
);
4847 wined3d_mutex_lock();
4850 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
4852 TRACE("iface %p.\n", iface
);
4854 wined3d_mutex_unlock();
4857 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
4859 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
4864 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
4866 FIXME("iface %p stub!\n", iface
);
4871 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
4873 d3d10_multithread_QueryInterface
,
4874 d3d10_multithread_AddRef
,
4875 d3d10_multithread_Release
,
4876 d3d10_multithread_Enter
,
4877 d3d10_multithread_Leave
,
4878 d3d10_multithread_SetMultithreadProtected
,
4879 d3d10_multithread_GetMultithreadProtected
,
4882 /* IWineDXGIDeviceParent IUnknown methods */
4884 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
4886 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
4889 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
4890 REFIID riid
, void **ppv
)
4892 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4893 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
4896 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
4898 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4899 return IUnknown_AddRef(device
->outer_unk
);
4902 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
4904 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4905 return IUnknown_Release(device
->outer_unk
);
4908 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
4909 IWineDXGIDeviceParent
*iface
)
4911 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4912 return &device
->device_parent
;
4915 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
4917 /* IUnknown methods */
4918 dxgi_device_parent_QueryInterface
,
4919 dxgi_device_parent_AddRef
,
4920 dxgi_device_parent_Release
,
4921 /* IWineDXGIDeviceParent methods */
4922 dxgi_device_parent_get_wined3d_device_parent
,
4925 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
4927 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
4930 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
4931 struct wined3d_device
*wined3d_device
)
4933 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
4935 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
4937 wined3d_device_incref(wined3d_device
);
4938 device
->wined3d_device
= wined3d_device
;
4941 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
4943 TRACE("device_parent %p.\n", device_parent
);
4946 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
4948 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
4951 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
4952 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
4953 const struct wined3d_parent_ops
**parent_ops
)
4955 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
4956 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
4959 *parent_ops
= &d3d_null_wined3d_parent_ops
;
4964 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
4965 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
4966 struct wined3d_texture
**wined3d_texture
)
4968 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
4969 struct d3d_texture2d
*texture
;
4970 ID3D10Texture2D
*texture_iface
;
4971 D3D10_TEXTURE2D_DESC desc
;
4974 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
4975 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
4977 FIXME("Implement DXGI<->wined3d usage conversion.\n");
4979 desc
.Width
= wined3d_desc
->width
;
4980 desc
.Height
= wined3d_desc
->height
;
4983 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
4984 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
4985 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
4986 desc
.Usage
= D3D10_USAGE_DEFAULT
;
4987 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
4988 desc
.CPUAccessFlags
= 0;
4991 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
4992 &desc
, NULL
, &texture_iface
)))
4994 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
4998 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5000 *wined3d_texture
= texture
->wined3d_texture
;
5001 wined3d_texture_incref(*wined3d_texture
);
5002 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5007 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5008 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5010 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5011 IWineDXGIDevice
*wine_device
;
5014 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5016 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5017 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5019 ERR("Device should implement IWineDXGIDevice.\n");
5023 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, swapchain
);
5024 IWineDXGIDevice_Release(wine_device
);
5027 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5034 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5036 device_parent_wined3d_device_created
,
5037 device_parent_mode_changed
,
5038 device_parent_activate
,
5039 device_parent_sub_resource_created
,
5040 device_parent_sub_resource_created
,
5041 device_parent_create_swapchain_texture
,
5042 device_parent_create_swapchain
,
5045 static void *d3d_rb_alloc(size_t size
)
5047 return HeapAlloc(GetProcessHeap(), 0, size
);
5050 static void *d3d_rb_realloc(void *ptr
, size_t size
)
5052 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
5055 static void d3d_rb_free(void *ptr
)
5057 HeapFree(GetProcessHeap(), 0, ptr
);
5060 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5062 const D3D11_SAMPLER_DESC
*ka
= key
;
5063 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5065 return memcmp(ka
, kb
, sizeof(*ka
));
5068 static const struct wine_rb_functions d3d_sampler_state_rb_ops
=
5073 d3d_sampler_state_compare
,
5076 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5078 const D3D11_BLEND_DESC
*ka
= key
;
5079 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5081 return memcmp(ka
, kb
, sizeof(*ka
));
5084 static const struct wine_rb_functions d3d_blend_state_rb_ops
=
5089 d3d_blend_state_compare
,
5092 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5094 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5095 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5096 const struct d3d_depthstencil_state
, entry
)->desc
;
5098 return memcmp(ka
, kb
, sizeof(*ka
));
5101 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops
=
5106 d3d_depthstencil_state_compare
,
5109 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5111 const D3D11_RASTERIZER_DESC
*ka
= key
;
5112 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5114 return memcmp(ka
, kb
, sizeof(*ka
));
5117 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops
=
5122 d3d_rasterizer_state_compare
,
5125 HRESULT
d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5127 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5128 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5129 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5130 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5131 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5132 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5133 device
->refcount
= 1;
5134 /* COM aggregation always takes place */
5135 device
->outer_unk
= outer_unknown
;
5137 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5138 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5140 if (wine_rb_init(&device
->blend_states
, &d3d_blend_state_rb_ops
) == -1)
5142 WARN("Failed to initialize blend state rbtree.\n");
5145 device
->blend_factor
[0] = 1.0f
;
5146 device
->blend_factor
[1] = 1.0f
;
5147 device
->blend_factor
[2] = 1.0f
;
5148 device
->blend_factor
[3] = 1.0f
;
5150 if (wine_rb_init(&device
->depthstencil_states
, &d3d_depthstencil_state_rb_ops
) == -1)
5152 WARN("Failed to initialize depthstencil state rbtree.\n");
5153 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
5157 if (wine_rb_init(&device
->rasterizer_states
, &d3d_rasterizer_state_rb_ops
) == -1)
5159 WARN("Failed to initialize rasterizer state rbtree.\n");
5160 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
5161 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
5165 if (wine_rb_init(&device
->sampler_states
, &d3d_sampler_state_rb_ops
) == -1)
5167 WARN("Failed to initialize sampler state rbtree.\n");
5168 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
5169 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
5170 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);