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 partial-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
,
610 if (render_target_view_count
!= D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
)
612 d3d11_immediate_context_OMSetRenderTargets(iface
, render_target_view_count
, render_target_views
,
617 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
618 ID3D11BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
620 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
621 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
622 const D3D11_BLEND_DESC
*desc
;
624 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
625 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
628 blend_factor
= default_blend_factor
;
630 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
631 FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor
));
633 wined3d_mutex_lock();
634 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
635 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
636 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
638 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
639 wined3d_device_set_render_state(device
->wined3d_device
,
640 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
641 wined3d_device_set_render_state(device
->wined3d_device
,
642 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
643 wined3d_device_set_render_state(device
->wined3d_device
,
644 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
645 wined3d_device_set_render_state(device
->wined3d_device
,
646 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
647 wined3d_mutex_unlock();
651 desc
= &device
->blend_state
->desc
;
652 /* glSampleCoverage() */
653 if (desc
->AlphaToCoverageEnable
)
654 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
655 /* glEnableIndexedEXT(GL_BLEND, ...) */
656 FIXME("Per-rendertarget blend not implemented.\n");
657 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
658 desc
->RenderTarget
[0].BlendEnable
);
659 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
, desc
->RenderTarget
[0].SrcBlend
);
660 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
, desc
->RenderTarget
[0].DestBlend
);
661 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
, desc
->RenderTarget
[0].BlendOp
);
662 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
663 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
,
664 desc
->RenderTarget
[0].SrcBlendAlpha
);
665 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
,
666 desc
->RenderTarget
[0].DestBlendAlpha
);
667 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
,
668 desc
->RenderTarget
[0].BlendOpAlpha
);
669 FIXME("Color mask > 3 not implemented.\n");
670 wined3d_device_set_render_state(device
->wined3d_device
,
671 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
672 wined3d_device_set_render_state(device
->wined3d_device
,
673 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
674 wined3d_device_set_render_state(device
->wined3d_device
,
675 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
676 wined3d_device_set_render_state(device
->wined3d_device
,
677 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
678 wined3d_mutex_unlock();
681 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
682 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
684 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
685 const D3D11_DEPTH_STENCILOP_DESC
*stencil_desc
;
686 const D3D11_DEPTH_STENCIL_DESC
*desc
;
688 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
689 iface
, depth_stencil_state
, stencil_ref
);
691 wined3d_mutex_lock();
692 device
->stencil_ref
= stencil_ref
;
693 if (!(device
->depth_stencil_state
= unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state
)))
695 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, TRUE
);
696 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, D3D11_DEPTH_WRITE_MASK_ALL
);
697 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, D3D11_COMPARISON_LESS
);
698 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, FALSE
);
699 wined3d_mutex_unlock();
703 desc
= &device
->depth_stencil_state
->desc
;
705 if (desc
->FrontFace
.StencilFailOp
!= desc
->BackFace
.StencilFailOp
706 || desc
->FrontFace
.StencilDepthFailOp
!= desc
->BackFace
.StencilDepthFailOp
707 || desc
->FrontFace
.StencilPassOp
!= desc
->BackFace
.StencilPassOp
708 || desc
->FrontFace
.StencilFunc
!= desc
->BackFace
.StencilFunc
)
709 FIXME("Two-sided stencil testing not supported.\n");
711 stencil_desc
= &desc
->FrontFace
;
713 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZENABLE
, desc
->DepthEnable
);
714 if (desc
->DepthEnable
)
716 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZWRITEENABLE
, desc
->DepthWriteMask
);
717 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ZFUNC
, desc
->DepthFunc
);
720 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILENABLE
, desc
->StencilEnable
);
721 if (desc
->StencilEnable
)
723 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILMASK
, desc
->StencilReadMask
);
724 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILWRITEMASK
, desc
->StencilWriteMask
);
725 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFAIL
, stencil_desc
->StencilFailOp
);
726 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILZFAIL
,
727 stencil_desc
->StencilDepthFailOp
);
728 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILPASS
, stencil_desc
->StencilPassOp
);
729 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILFUNC
, stencil_desc
->StencilFunc
);
730 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_STENCILREF
, stencil_ref
);
732 wined3d_mutex_unlock();
735 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
736 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
738 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
739 unsigned int count
, i
;
741 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
743 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
744 wined3d_mutex_lock();
745 for (i
= 0; i
< count
; ++i
)
747 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
749 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
750 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
752 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
754 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
756 wined3d_mutex_unlock();
759 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
761 FIXME("iface %p stub!\n", iface
);
764 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(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_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
771 ID3D11Buffer
*buffer
, UINT offset
)
773 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
776 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
777 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
779 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
780 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
783 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
784 ID3D11Buffer
*buffer
, UINT offset
)
786 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
789 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
790 ID3D11RasterizerState
*rasterizer_state
)
792 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
793 const D3D11_RASTERIZER_DESC
*desc
;
795 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
797 wined3d_mutex_lock();
798 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
800 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
801 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_CCW
);
802 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
803 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
804 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
805 wined3d_mutex_unlock();
809 desc
= &device
->rasterizer_state
->desc
;
810 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
811 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
813 if (desc
->FrontCounterClockwise
)
814 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc
->FrontCounterClockwise
);
815 /* OpenGL style depth bias. */
816 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
817 FIXME("Ignoring depth bias.\n");
819 if (!desc
->DepthClipEnable
)
820 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
821 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
822 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
823 wined3d_device_set_render_state(device
->wined3d_device
,
824 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
825 wined3d_mutex_unlock();
828 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
829 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
831 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
832 struct wined3d_viewport wined3d_vp
;
834 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
836 if (viewport_count
> 1)
837 FIXME("Multiple viewports not implemented.\n");
842 if (viewports
[0].TopLeftX
!= (UINT
)viewports
[0].TopLeftX
843 || viewports
[0].TopLeftY
!= (UINT
)viewports
[0].TopLeftY
844 || viewports
[0].Width
!= (UINT
)viewports
[0].Width
845 || viewports
[0].Height
!= (UINT
)viewports
[0].Height
)
846 FIXME("Floating-point viewports not implemented.\n");
848 wined3d_vp
.x
= viewports
[0].TopLeftX
;
849 wined3d_vp
.y
= viewports
[0].TopLeftY
;
850 wined3d_vp
.width
= viewports
[0].Width
;
851 wined3d_vp
.height
= viewports
[0].Height
;
852 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
853 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
855 wined3d_mutex_lock();
856 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
857 wined3d_mutex_unlock();
860 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
861 UINT rect_count
, const D3D11_RECT
*rects
)
863 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
865 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
868 FIXME("Multiple scissor rects not implemented.\n");
873 wined3d_mutex_lock();
874 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
875 wined3d_mutex_unlock();
878 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
879 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
880 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
882 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
883 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
884 struct wined3d_box wined3d_src_box
;
886 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
887 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
888 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
889 src_resource
, src_subresource_idx
, src_box
);
893 wined3d_src_box
.left
= src_box
->left
;
894 wined3d_src_box
.top
= src_box
->top
;
895 wined3d_src_box
.front
= src_box
->front
;
896 wined3d_src_box
.right
= src_box
->right
;
897 wined3d_src_box
.bottom
= src_box
->bottom
;
898 wined3d_src_box
.back
= src_box
->back
;
901 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
902 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
903 wined3d_mutex_lock();
904 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
905 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
906 wined3d_mutex_unlock();
909 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
910 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
912 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
913 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
915 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
917 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
918 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
919 wined3d_mutex_lock();
920 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
921 wined3d_mutex_unlock();
924 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
925 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
926 const void *data
, UINT row_pitch
, UINT depth_pitch
)
928 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
929 struct wined3d_resource
*wined3d_resource
;
930 struct wined3d_box wined3d_box
;
932 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
933 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
937 wined3d_box
.left
= box
->left
;
938 wined3d_box
.top
= box
->top
;
939 wined3d_box
.front
= box
->front
;
940 wined3d_box
.right
= box
->right
;
941 wined3d_box
.bottom
= box
->bottom
;
942 wined3d_box
.back
= box
->back
;
945 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
946 wined3d_mutex_lock();
947 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
948 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
949 wined3d_mutex_unlock();
952 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
953 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
955 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
956 iface
, dst_buffer
, dst_offset
, src_view
);
959 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
960 ID3D11RenderTargetView
*render_target_view
, const float color_rgba
[4])
962 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
963 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
964 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
967 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
968 iface
, render_target_view
, debug_float4(color_rgba
));
973 wined3d_mutex_lock();
974 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
975 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
976 ERR("Failed to clear view, hr %#x.\n", hr
);
977 wined3d_mutex_unlock();
980 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
981 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
983 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
984 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
987 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
988 ID3D11UnorderedAccessView
*unordered_access_view
, const float values
[4])
990 FIXME("iface %p, unordered_access_view %p, values %s stub!\n",
991 iface
, unordered_access_view
, debug_float4(values
));
994 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
995 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
997 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
998 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
1002 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
1003 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1008 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
1010 wined3d_mutex_lock();
1011 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
1012 wined3d_flags
, NULL
, depth
, stencil
)))
1013 ERR("Failed to clear view, hr %#x.\n", hr
);
1014 wined3d_mutex_unlock();
1017 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
1018 ID3D11ShaderResourceView
*view
)
1020 FIXME("iface %p, view %p stub!\n", iface
, view
);
1023 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
1024 ID3D11Resource
*resource
, FLOAT min_lod
)
1026 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
1029 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
1030 ID3D11Resource
*resource
)
1032 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1037 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
1038 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
1039 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
1042 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
1043 "format %s stub!\n",
1044 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
1045 debug_dxgi_format(format
));
1048 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
1049 ID3D11CommandList
*command_list
, BOOL restore_state
)
1051 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
1054 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
1055 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1057 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1058 iface
, start_slot
, view_count
, views
);
1061 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
1062 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1064 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1065 iface
, shader
, class_instances
, class_instance_count
);
1068 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
1069 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1071 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1072 iface
, start_slot
, sampler_count
, samplers
);
1075 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1076 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1078 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1079 iface
, start_slot
, buffer_count
, buffers
);
1082 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
1083 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1085 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1086 iface
, start_slot
, view_count
, views
);
1089 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
1090 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1092 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1093 iface
, shader
, class_instances
, class_instance_count
);
1096 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
1097 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1099 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1100 iface
, start_slot
, sampler_count
, samplers
);
1103 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1104 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1106 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1107 iface
, start_slot
, buffer_count
, buffers
);
1110 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1111 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1113 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1114 iface
, start_slot
, view_count
, views
);
1117 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1118 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1120 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1121 iface
, start_slot
, view_count
, views
, initial_counts
);
1124 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1125 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1127 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1128 iface
, shader
, class_instances
, class_instance_count
);
1131 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1132 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1134 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1135 iface
, start_slot
, sampler_count
, samplers
);
1138 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1139 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1141 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1142 iface
, start_slot
, buffer_count
, buffers
);
1145 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1146 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1148 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1151 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1152 iface
, start_slot
, buffer_count
, buffers
);
1154 wined3d_mutex_lock();
1155 for (i
= 0; i
< buffer_count
; ++i
)
1157 struct wined3d_buffer
*wined3d_buffer
;
1158 struct d3d_buffer
*buffer_impl
;
1160 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1166 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1167 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1168 ID3D11Buffer_AddRef(buffers
[i
]);
1170 wined3d_mutex_unlock();
1173 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1174 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1176 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1179 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1180 iface
, start_slot
, view_count
, views
);
1182 wined3d_mutex_lock();
1183 for (i
= 0; i
< view_count
; ++i
)
1185 struct wined3d_shader_resource_view
*wined3d_view
;
1186 struct d3d_shader_resource_view
*view_impl
;
1188 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1194 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1195 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1196 ID3D11ShaderResourceView_AddRef(views
[i
]);
1198 wined3d_mutex_unlock();
1201 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1202 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1204 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1205 struct wined3d_shader
*wined3d_shader
;
1206 struct d3d_pixel_shader
*shader_impl
;
1208 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1209 iface
, shader
, class_instances
, class_instance_count
);
1211 if (class_instances
|| class_instance_count
)
1212 FIXME("Dynamic linking not implemented yet.\n");
1214 wined3d_mutex_lock();
1215 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1217 wined3d_mutex_unlock();
1222 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1223 wined3d_mutex_unlock();
1224 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1225 ID3D11PixelShader_AddRef(*shader
);
1228 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1229 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1231 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1234 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1235 iface
, start_slot
, sampler_count
, samplers
);
1237 wined3d_mutex_lock();
1238 for (i
= 0; i
< sampler_count
; ++i
)
1240 struct wined3d_sampler
*wined3d_sampler
;
1241 struct d3d_sampler_state
*sampler_impl
;
1243 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1249 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1250 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1251 ID3D11SamplerState_AddRef(samplers
[i
]);
1253 wined3d_mutex_unlock();
1256 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1257 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1259 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1260 struct d3d_vertex_shader
*shader_impl
;
1261 struct wined3d_shader
*wined3d_shader
;
1263 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1264 iface
, shader
, class_instances
, class_instance_count
);
1266 if (class_instances
|| class_instance_count
)
1267 FIXME("Dynamic linking not implemented yet.\n");
1269 wined3d_mutex_lock();
1270 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1272 wined3d_mutex_unlock();
1277 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1278 wined3d_mutex_unlock();
1279 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1280 ID3D11VertexShader_AddRef(*shader
);
1283 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1284 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1286 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1289 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1290 iface
, start_slot
, buffer_count
, buffers
);
1292 wined3d_mutex_lock();
1293 for (i
= 0; i
< buffer_count
; ++i
)
1295 struct wined3d_buffer
*wined3d_buffer
;
1296 struct d3d_buffer
*buffer_impl
;
1298 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1304 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1305 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1306 ID3D11Buffer_AddRef(buffers
[i
]);
1308 wined3d_mutex_unlock();
1311 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1312 ID3D11InputLayout
**input_layout
)
1314 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1315 struct wined3d_vertex_declaration
*wined3d_declaration
;
1316 struct d3d_input_layout
*input_layout_impl
;
1318 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1320 wined3d_mutex_lock();
1321 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1323 wined3d_mutex_unlock();
1324 *input_layout
= NULL
;
1328 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1329 wined3d_mutex_unlock();
1330 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1331 ID3D11InputLayout_AddRef(*input_layout
);
1334 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1335 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1337 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1338 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1341 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1342 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1344 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface
, buffer
, format
, offset
);
1347 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1348 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1350 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1353 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1354 iface
, start_slot
, buffer_count
, buffers
);
1356 wined3d_mutex_lock();
1357 for (i
= 0; i
< buffer_count
; ++i
)
1359 struct wined3d_buffer
*wined3d_buffer
;
1360 struct d3d_buffer
*buffer_impl
;
1362 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1368 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1369 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1370 ID3D11Buffer_AddRef(buffers
[i
]);
1372 wined3d_mutex_unlock();
1375 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1376 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1378 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1379 struct d3d_geometry_shader
*shader_impl
;
1380 struct wined3d_shader
*wined3d_shader
;
1382 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1383 iface
, shader
, class_instances
, class_instance_count
);
1385 if (class_instances
|| class_instance_count
)
1386 FIXME("Dynamic linking not implemented yet.\n");
1388 wined3d_mutex_lock();
1389 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1391 wined3d_mutex_unlock();
1396 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1397 wined3d_mutex_unlock();
1398 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1399 ID3D11GeometryShader_AddRef(*shader
);
1402 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1403 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1405 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1407 TRACE("iface %p, topology %p.\n", iface
, topology
);
1409 wined3d_mutex_lock();
1410 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1411 wined3d_mutex_unlock();
1414 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1415 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1417 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1420 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1422 wined3d_mutex_lock();
1423 for (i
= 0; i
< view_count
; ++i
)
1425 struct wined3d_shader_resource_view
*wined3d_view
;
1426 struct d3d_shader_resource_view
*view_impl
;
1428 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1434 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1435 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1436 ID3D11ShaderResourceView_AddRef(views
[i
]);
1438 wined3d_mutex_unlock();
1441 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1442 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1444 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1447 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1448 iface
, start_slot
, sampler_count
, samplers
);
1450 wined3d_mutex_lock();
1451 for (i
= 0; i
< sampler_count
; ++i
)
1453 struct wined3d_sampler
*wined3d_sampler
;
1454 struct d3d_sampler_state
*sampler_impl
;
1456 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1462 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1463 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1464 ID3D11SamplerState_AddRef(samplers
[i
]);
1466 wined3d_mutex_unlock();
1469 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1470 ID3D11Predicate
**predicate
, BOOL
*value
)
1472 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1473 struct wined3d_query
*wined3d_predicate
;
1474 struct d3d_query
*predicate_impl
;
1476 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1478 wined3d_mutex_lock();
1479 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1481 wined3d_mutex_unlock();
1486 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1487 wined3d_mutex_unlock();
1488 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1489 ID3D11Predicate_AddRef(*predicate
);
1492 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1493 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1495 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1498 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1500 wined3d_mutex_lock();
1501 for (i
= 0; i
< view_count
; ++i
)
1503 struct wined3d_shader_resource_view
*wined3d_view
;
1504 struct d3d_shader_resource_view
*view_impl
;
1506 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1512 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1513 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1514 ID3D11ShaderResourceView_AddRef(views
[i
]);
1516 wined3d_mutex_unlock();
1519 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1520 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1522 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1525 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1526 iface
, start_slot
, sampler_count
, samplers
);
1528 wined3d_mutex_lock();
1529 for (i
= 0; i
< sampler_count
; ++i
)
1531 struct d3d_sampler_state
*sampler_impl
;
1532 struct wined3d_sampler
*wined3d_sampler
;
1534 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1540 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1541 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1542 ID3D11SamplerState_AddRef(samplers
[i
]);
1544 wined3d_mutex_unlock();
1547 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1548 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1549 ID3D11DepthStencilView
**depth_stencil_view
)
1551 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1552 struct wined3d_rendertarget_view
*wined3d_view
;
1554 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1555 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1557 wined3d_mutex_lock();
1558 if (render_target_views
)
1560 struct d3d_rendertarget_view
*view_impl
;
1563 for (i
= 0; i
< render_target_view_count
; ++i
)
1565 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1566 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1568 render_target_views
[i
] = NULL
;
1572 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1573 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1577 if (depth_stencil_view
)
1579 struct d3d_depthstencil_view
*view_impl
;
1581 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1582 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1584 *depth_stencil_view
= NULL
;
1588 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1589 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1592 wined3d_mutex_unlock();
1595 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1596 ID3D11DeviceContext
*iface
,
1597 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1598 ID3D11DepthStencilView
**depth_stencil_view
,
1599 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1600 ID3D11UnorderedAccessView
**unordered_access_views
)
1602 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1603 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1604 "unordered_access_views %p stub!\n",
1605 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1606 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1609 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1610 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1612 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1613 iface
, blend_state
, blend_factor
, sample_mask
);
1616 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1617 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1619 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface
, depth_stencil_state
, stencil_ref
);
1622 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1623 UINT buffer_count
, ID3D11Buffer
**buffers
)
1625 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1628 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1630 wined3d_mutex_lock();
1631 for (i
= 0; i
< buffer_count
; ++i
)
1633 struct wined3d_buffer
*wined3d_buffer
;
1634 struct d3d_buffer
*buffer_impl
;
1636 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1642 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1643 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1644 ID3D11Buffer_AddRef(buffers
[i
]);
1646 wined3d_mutex_unlock();
1649 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
1650 ID3D11RasterizerState
**rasterizer_state
)
1652 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1654 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1656 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D11RasterizerState_iface
: NULL
))
1657 ID3D11RasterizerState_AddRef(*rasterizer_state
);
1660 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
1661 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1663 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1664 struct wined3d_viewport wined3d_vp
;
1666 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1670 *viewport_count
= 1;
1674 if (!*viewport_count
)
1677 wined3d_mutex_lock();
1678 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1679 wined3d_mutex_unlock();
1681 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1682 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1683 viewports
[0].Width
= wined3d_vp
.width
;
1684 viewports
[0].Height
= wined3d_vp
.height
;
1685 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1686 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1688 if (*viewport_count
> 1)
1689 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1692 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
1693 UINT
*rect_count
, D3D11_RECT
*rects
)
1695 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface
, rect_count
, rects
);
1698 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
1699 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1701 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1704 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
1705 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1707 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1708 iface
, shader
, class_instances
, class_instance_count
);
1711 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
1712 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1714 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1715 iface
, start_slot
, sampler_count
, samplers
);
1718 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1719 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1721 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1722 iface
, start_slot
, buffer_count
, buffers
);
1725 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
1726 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1728 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1729 iface
, start_slot
, view_count
, views
);
1732 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
1733 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1735 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1736 iface
, shader
, class_instances
, class_instance_count
);
1739 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
1740 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1742 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1743 iface
, start_slot
, sampler_count
, samplers
);
1746 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1747 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1749 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1750 iface
, start_slot
, buffer_count
, buffers
);
1753 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
1754 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1756 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1759 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1760 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
1762 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1765 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
1766 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1768 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1769 iface
, shader
, class_instances
, class_instance_count
);
1772 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
1773 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1775 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1776 iface
, start_slot
, sampler_count
, samplers
);
1779 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1780 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1782 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1783 iface
, start_slot
, buffer_count
, buffers
);
1786 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
1788 FIXME("iface %p stub!\n", iface
);
1791 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
1793 FIXME("iface %p stub!\n", iface
);
1796 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
1798 TRACE("iface %p.\n", iface
);
1800 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
1803 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
1805 FIXME("iface %p stub!\n", iface
);
1810 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
1811 BOOL restore
, ID3D11CommandList
**command_list
)
1813 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
1818 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
1820 /* IUnknown methods */
1821 d3d11_immediate_context_QueryInterface
,
1822 d3d11_immediate_context_AddRef
,
1823 d3d11_immediate_context_Release
,
1824 /* ID3D11DeviceChild methods */
1825 d3d11_immediate_context_GetDevice
,
1826 d3d11_immediate_context_GetPrivateData
,
1827 d3d11_immediate_context_SetPrivateData
,
1828 d3d11_immediate_context_SetPrivateDataInterface
,
1829 /* ID3D11DeviceContext methods */
1830 d3d11_immediate_context_VSSetConstantBuffers
,
1831 d3d11_immediate_context_PSSetShaderResources
,
1832 d3d11_immediate_context_PSSetShader
,
1833 d3d11_immediate_context_PSSetSamplers
,
1834 d3d11_immediate_context_VSSetShader
,
1835 d3d11_immediate_context_DrawIndexed
,
1836 d3d11_immediate_context_Draw
,
1837 d3d11_immediate_context_Map
,
1838 d3d11_immediate_context_Unmap
,
1839 d3d11_immediate_context_PSSetConstantBuffers
,
1840 d3d11_immediate_context_IASetInputLayout
,
1841 d3d11_immediate_context_IASetVertexBuffers
,
1842 d3d11_immediate_context_IASetIndexBuffer
,
1843 d3d11_immediate_context_DrawIndexedInstanced
,
1844 d3d11_immediate_context_DrawInstanced
,
1845 d3d11_immediate_context_GSSetConstantBuffers
,
1846 d3d11_immediate_context_GSSetShader
,
1847 d3d11_immediate_context_IASetPrimitiveTopology
,
1848 d3d11_immediate_context_VSSetShaderResources
,
1849 d3d11_immediate_context_VSSetSamplers
,
1850 d3d11_immediate_context_Begin
,
1851 d3d11_immediate_context_End
,
1852 d3d11_immediate_context_GetData
,
1853 d3d11_immediate_context_SetPredication
,
1854 d3d11_immediate_context_GSSetShaderResources
,
1855 d3d11_immediate_context_GSSetSamplers
,
1856 d3d11_immediate_context_OMSetRenderTargets
,
1857 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
1858 d3d11_immediate_context_OMSetBlendState
,
1859 d3d11_immediate_context_OMSetDepthStencilState
,
1860 d3d11_immediate_context_SOSetTargets
,
1861 d3d11_immediate_context_DrawAuto
,
1862 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
1863 d3d11_immediate_context_DrawInstancedIndirect
,
1864 d3d11_immediate_context_Dispatch
,
1865 d3d11_immediate_context_DispatchIndirect
,
1866 d3d11_immediate_context_RSSetState
,
1867 d3d11_immediate_context_RSSetViewports
,
1868 d3d11_immediate_context_RSSetScissorRects
,
1869 d3d11_immediate_context_CopySubresourceRegion
,
1870 d3d11_immediate_context_CopyResource
,
1871 d3d11_immediate_context_UpdateSubresource
,
1872 d3d11_immediate_context_CopyStructureCount
,
1873 d3d11_immediate_context_ClearRenderTargetView
,
1874 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
1875 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
1876 d3d11_immediate_context_ClearDepthStencilView
,
1877 d3d11_immediate_context_GenerateMips
,
1878 d3d11_immediate_context_SetResourceMinLOD
,
1879 d3d11_immediate_context_GetResourceMinLOD
,
1880 d3d11_immediate_context_ResolveSubresource
,
1881 d3d11_immediate_context_ExecuteCommandList
,
1882 d3d11_immediate_context_HSSetShaderResources
,
1883 d3d11_immediate_context_HSSetShader
,
1884 d3d11_immediate_context_HSSetSamplers
,
1885 d3d11_immediate_context_HSSetConstantBuffers
,
1886 d3d11_immediate_context_DSSetShaderResources
,
1887 d3d11_immediate_context_DSSetShader
,
1888 d3d11_immediate_context_DSSetSamplers
,
1889 d3d11_immediate_context_DSSetConstantBuffers
,
1890 d3d11_immediate_context_CSSetShaderResources
,
1891 d3d11_immediate_context_CSSetUnorderedAccessViews
,
1892 d3d11_immediate_context_CSSetShader
,
1893 d3d11_immediate_context_CSSetSamplers
,
1894 d3d11_immediate_context_CSSetConstantBuffers
,
1895 d3d11_immediate_context_VSGetConstantBuffers
,
1896 d3d11_immediate_context_PSGetShaderResources
,
1897 d3d11_immediate_context_PSGetShader
,
1898 d3d11_immediate_context_PSGetSamplers
,
1899 d3d11_immediate_context_VSGetShader
,
1900 d3d11_immediate_context_PSGetConstantBuffers
,
1901 d3d11_immediate_context_IAGetInputLayout
,
1902 d3d11_immediate_context_IAGetVertexBuffers
,
1903 d3d11_immediate_context_IAGetIndexBuffer
,
1904 d3d11_immediate_context_GSGetConstantBuffers
,
1905 d3d11_immediate_context_GSGetShader
,
1906 d3d11_immediate_context_IAGetPrimitiveTopology
,
1907 d3d11_immediate_context_VSGetShaderResources
,
1908 d3d11_immediate_context_VSGetSamplers
,
1909 d3d11_immediate_context_GetPredication
,
1910 d3d11_immediate_context_GSGetShaderResources
,
1911 d3d11_immediate_context_GSGetSamplers
,
1912 d3d11_immediate_context_OMGetRenderTargets
,
1913 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
1914 d3d11_immediate_context_OMGetBlendState
,
1915 d3d11_immediate_context_OMGetDepthStencilState
,
1916 d3d11_immediate_context_SOGetTargets
,
1917 d3d11_immediate_context_RSGetState
,
1918 d3d11_immediate_context_RSGetViewports
,
1919 d3d11_immediate_context_RSGetScissorRects
,
1920 d3d11_immediate_context_HSGetShaderResources
,
1921 d3d11_immediate_context_HSGetShader
,
1922 d3d11_immediate_context_HSGetSamplers
,
1923 d3d11_immediate_context_HSGetConstantBuffers
,
1924 d3d11_immediate_context_DSGetShaderResources
,
1925 d3d11_immediate_context_DSGetShader
,
1926 d3d11_immediate_context_DSGetSamplers
,
1927 d3d11_immediate_context_DSGetConstantBuffers
,
1928 d3d11_immediate_context_CSGetShaderResources
,
1929 d3d11_immediate_context_CSGetUnorderedAccessViews
,
1930 d3d11_immediate_context_CSGetShader
,
1931 d3d11_immediate_context_CSGetSamplers
,
1932 d3d11_immediate_context_CSGetConstantBuffers
,
1933 d3d11_immediate_context_ClearState
,
1934 d3d11_immediate_context_Flush
,
1935 d3d11_immediate_context_GetType
,
1936 d3d11_immediate_context_GetContextFlags
,
1937 d3d11_immediate_context_FinishCommandList
,
1940 static void d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
1942 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
1943 context
->refcount
= 1;
1945 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
1947 wined3d_private_store_init(&context
->private_store
);
1950 static void d3d11_immediate_context_destroy(struct d3d11_immediate_context
*context
)
1952 wined3d_private_store_cleanup(&context
->private_store
);
1955 /* ID3D11Device methods */
1957 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
1959 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1960 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
1963 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
1965 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1966 return IUnknown_AddRef(device
->outer_unk
);
1969 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
1971 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1972 return IUnknown_Release(device
->outer_unk
);
1975 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
1976 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
1978 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1979 struct d3d_buffer
*object
;
1982 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
1984 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
1987 *buffer
= &object
->ID3D11Buffer_iface
;
1992 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
1993 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
1995 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2000 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
2001 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
2003 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2004 struct d3d_texture2d
*object
;
2007 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2009 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
2012 *texture
= &object
->ID3D11Texture2D_iface
;
2017 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
2018 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
2020 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2021 struct d3d_texture3d
*object
;
2024 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2026 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
2029 *texture
= &object
->ID3D11Texture3D_iface
;
2034 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
2035 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
2037 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2038 struct d3d_shader_resource_view
*object
;
2041 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2043 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
2046 *view
= &object
->ID3D11ShaderResourceView_iface
;
2051 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
2052 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
2054 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
2059 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
2060 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
2062 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2063 struct d3d_rendertarget_view
*object
;
2066 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2068 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
2071 *view
= &object
->ID3D11RenderTargetView_iface
;
2076 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
2077 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
2079 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2080 struct d3d_depthstencil_view
*object
;
2083 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2085 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
2088 *view
= &object
->ID3D11DepthStencilView_iface
;
2093 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
2094 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
2095 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
2097 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2098 struct d3d_input_layout
*object
;
2101 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2102 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
2103 shader_byte_code_length
, input_layout
);
2105 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2106 shader_byte_code
, shader_byte_code_length
, &object
)))
2109 *input_layout
= &object
->ID3D11InputLayout_iface
;
2114 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2115 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2117 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2118 struct d3d_vertex_shader
*object
;
2121 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2122 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2125 FIXME("Class linkage is not implemented yet.\n");
2127 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2130 *shader
= &object
->ID3D11VertexShader_iface
;
2135 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2136 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2138 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2139 struct d3d_geometry_shader
*object
;
2142 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2143 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2146 FIXME("Class linkage is not implemented yet.\n");
2148 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2151 *shader
= &object
->ID3D11GeometryShader_iface
;
2156 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2157 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2158 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
2159 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2161 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2162 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2163 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2164 rasterized_stream
, class_linkage
, shader
);
2169 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2170 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2172 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2173 struct d3d_pixel_shader
*object
;
2176 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2177 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2180 FIXME("Class linkage is not implemented yet.\n");
2182 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2185 *shader
= &object
->ID3D11PixelShader_iface
;
2190 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2191 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2193 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2194 struct d3d11_hull_shader
*object
;
2197 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2198 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2201 FIXME("Class linkage is not implemented yet.\n");
2203 if (FAILED(hr
= d3d11_hull_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2206 *shader
= &object
->ID3D11HullShader_iface
;
2211 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2212 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2214 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2215 struct d3d11_domain_shader
*object
;
2218 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2219 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2222 FIXME("Class linkage is not implemented yet.\n");
2224 if (FAILED(hr
= d3d11_domain_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2227 *shader
= &object
->ID3D11DomainShader_iface
;
2232 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2233 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2235 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2236 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2241 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2242 ID3D11ClassLinkage
**class_linkage
)
2244 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2245 struct d3d11_class_linkage
*object
;
2248 TRACE("iface %p, class_linkage %p.\n", iface
, class_linkage
);
2250 if (FAILED(hr
= d3d11_class_linkage_create(device
, &object
)))
2253 *class_linkage
= &object
->ID3D11ClassLinkage_iface
;
2258 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
2259 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
2261 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2262 struct d3d_blend_state
*object
;
2263 struct wine_rb_entry
*entry
;
2264 D3D11_BLEND_DESC tmp_desc
;
2268 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2271 return E_INVALIDARG
;
2273 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2274 * D3D11_BLEND_DESC as a key in the rbtree. */
2275 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2276 tmp_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
2277 tmp_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
2278 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2280 j
= desc
->IndependentBlendEnable
? i
: 0;
2281 tmp_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[j
].BlendEnable
;
2282 tmp_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[j
].SrcBlend
;
2283 tmp_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[j
].DestBlend
;
2284 tmp_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[j
].BlendOp
;
2285 tmp_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[j
].SrcBlendAlpha
;
2286 tmp_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[j
].DestBlendAlpha
;
2287 tmp_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[j
].BlendOpAlpha
;
2288 tmp_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[j
].RenderTargetWriteMask
;
2291 wined3d_mutex_lock();
2292 if ((entry
= wine_rb_get(&device
->blend_states
, &tmp_desc
)))
2294 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_blend_state
, entry
);
2296 TRACE("Returning existing blend state %p.\n", object
);
2297 *blend_state
= &object
->ID3D11BlendState_iface
;
2298 ID3D11BlendState_AddRef(*blend_state
);
2299 wined3d_mutex_unlock();
2303 wined3d_mutex_unlock();
2305 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2306 return E_OUTOFMEMORY
;
2308 if (FAILED(hr
= d3d_blend_state_init(object
, device
, &tmp_desc
)))
2310 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2311 HeapFree(GetProcessHeap(), 0, object
);
2315 TRACE("Created blend state %p.\n", object
);
2316 *blend_state
= &object
->ID3D11BlendState_iface
;
2321 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
2322 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
2324 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2325 struct d3d_depthstencil_state
*object
;
2326 D3D11_DEPTH_STENCIL_DESC tmp_desc
;
2327 struct wine_rb_entry
*entry
;
2330 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2333 return E_INVALIDARG
;
2335 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2336 * it as a key in the rbtree. */
2337 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2338 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2339 if (desc
->DepthEnable
)
2341 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2342 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2346 tmp_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
2347 tmp_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
2349 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2350 if (desc
->StencilEnable
)
2352 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2353 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2354 tmp_desc
.FrontFace
= desc
->FrontFace
;
2355 tmp_desc
.BackFace
= desc
->BackFace
;
2359 tmp_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
2360 tmp_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
2361 tmp_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2362 tmp_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2363 tmp_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2364 tmp_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2365 tmp_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2366 tmp_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2367 tmp_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2368 tmp_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2371 wined3d_mutex_lock();
2372 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2374 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_depthstencil_state
, entry
);
2376 TRACE("Returning existing depthstencil state %p.\n", object
);
2377 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2378 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
2379 wined3d_mutex_unlock();
2383 wined3d_mutex_unlock();
2385 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2386 return E_OUTOFMEMORY
;
2388 if (FAILED(hr
= d3d_depthstencil_state_init(object
, device
, &tmp_desc
)))
2390 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2391 HeapFree(GetProcessHeap(), 0, object
);
2395 TRACE("Created depthstencil state %p.\n", object
);
2396 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2401 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
2402 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
2404 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2405 struct d3d_rasterizer_state
*object
;
2406 struct wine_rb_entry
*entry
;
2409 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2412 return E_INVALIDARG
;
2414 wined3d_mutex_lock();
2415 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2417 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_rasterizer_state
, entry
);
2419 TRACE("Returning existing rasterizer state %p.\n", object
);
2420 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2421 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2422 wined3d_mutex_unlock();
2426 wined3d_mutex_unlock();
2428 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2429 return E_OUTOFMEMORY
;
2431 if (FAILED(hr
= d3d_rasterizer_state_init(object
, device
, desc
)))
2433 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2434 HeapFree(GetProcessHeap(), 0, object
);
2438 TRACE("Created rasterizer state %p.\n", object
);
2439 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2444 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
2445 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
2447 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2448 D3D11_SAMPLER_DESC normalized_desc
;
2449 struct d3d_sampler_state
*object
;
2450 struct wine_rb_entry
*entry
;
2453 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2456 return E_INVALIDARG
;
2458 normalized_desc
= *desc
;
2459 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc
.Filter
))
2460 normalized_desc
.MaxAnisotropy
= 0;
2461 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc
.Filter
))
2462 normalized_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
2463 if (normalized_desc
.AddressU
!= D3D11_TEXTURE_ADDRESS_BORDER
2464 && normalized_desc
.AddressV
!= D3D11_TEXTURE_ADDRESS_BORDER
2465 && normalized_desc
.AddressW
!= D3D11_TEXTURE_ADDRESS_BORDER
)
2466 memset(&normalized_desc
.BorderColor
, 0, sizeof(normalized_desc
.BorderColor
));
2468 wined3d_mutex_lock();
2469 if ((entry
= wine_rb_get(&device
->sampler_states
, &normalized_desc
)))
2471 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_sampler_state
, entry
);
2473 TRACE("Returning existing sampler state %p.\n", object
);
2474 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2475 ID3D11SamplerState_AddRef(*sampler_state
);
2476 wined3d_mutex_unlock();
2480 wined3d_mutex_unlock();
2482 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2483 return E_OUTOFMEMORY
;
2485 if (FAILED(hr
= d3d_sampler_state_init(object
, device
, &normalized_desc
)))
2487 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2488 HeapFree(GetProcessHeap(), 0, object
);
2492 TRACE("Created sampler state %p.\n", object
);
2493 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2498 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
2499 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
2501 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2502 struct d3d_query
*object
;
2505 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2507 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
2512 *query
= &object
->ID3D11Query_iface
;
2516 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2520 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
2521 ID3D11Predicate
**predicate
)
2523 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2524 struct d3d_query
*object
;
2527 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2529 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
2534 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
2538 ID3D11Query_Release(&object
->ID3D11Query_iface
);
2542 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2543 ID3D11Counter
**counter
)
2545 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2550 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
2551 ID3D11DeviceContext
**context
)
2553 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
2558 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
2561 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
2566 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
2567 UINT
*format_support
)
2569 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
2574 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
2575 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2577 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2578 struct wined3d_device_creation_parameters params
;
2579 struct wined3d
*wined3d
;
2582 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
2583 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2585 if (!quality_level_count
)
2586 return E_INVALIDARG
;
2588 *quality_level_count
= 0;
2592 if (sample_count
== 1)
2594 *quality_level_count
= 1;
2597 if (sample_count
> D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT
)
2600 wined3d_mutex_lock();
2601 wined3d
= wined3d_device_get_wined3d(device
->wined3d_device
);
2602 wined3d_device_get_creation_parameters(device
->wined3d_device
, ¶ms
);
2603 hr
= wined3d_check_device_multisample_type(wined3d
, params
.adapter_idx
, params
.device_type
,
2604 wined3dformat_from_dxgi_format(format
), TRUE
, sample_count
, quality_level_count
);
2605 wined3d_mutex_unlock();
2607 if (hr
== WINED3DERR_INVALIDCALL
)
2608 return E_INVALIDARG
;
2609 if (hr
== WINED3DERR_NOTAVAILABLE
)
2614 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
2616 FIXME("iface %p, info %p stub!\n", iface
, info
);
2619 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2620 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
2621 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2623 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2624 "units %p, units_length %p, description %p, description_length %p stub!\n",
2625 iface
, desc
, type
, active_counter_count
, name
, name_length
,
2626 units
, units_length
, description
, description_length
);
2631 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
2632 void *feature_support_data
, UINT feature_support_data_size
)
2634 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2635 iface
, feature
, feature_support_data
, feature_support_data_size
);
2640 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2641 UINT
*data_size
, void *data
)
2643 IDXGIDevice
*dxgi_device
;
2646 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2648 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2650 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
2651 IDXGIDevice_Release(dxgi_device
);
2656 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2657 UINT data_size
, const void *data
)
2659 IDXGIDevice
*dxgi_device
;
2662 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2664 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2666 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
2667 IDXGIDevice_Release(dxgi_device
);
2672 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
2673 const IUnknown
*data
)
2675 IDXGIDevice
*dxgi_device
;
2678 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
2680 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2682 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
2683 IDXGIDevice_Release(dxgi_device
);
2688 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
2690 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2692 TRACE("iface %p.\n", iface
);
2694 return device
->feature_level
;
2697 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
2699 FIXME("iface %p stub!\n", iface
);
2704 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
2706 FIXME("iface %p stub!\n", iface
);
2711 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
2712 ID3D11DeviceContext
**immediate_context
)
2714 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2716 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
2718 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
2719 ID3D11DeviceContext_AddRef(*immediate_context
);
2722 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
2724 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2729 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
2731 FIXME("iface %p stub!\n", iface
);
2736 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
2738 /* IUnknown methods */
2739 d3d11_device_QueryInterface
,
2740 d3d11_device_AddRef
,
2741 d3d11_device_Release
,
2742 /* ID3D11Device methods */
2743 d3d11_device_CreateBuffer
,
2744 d3d11_device_CreateTexture1D
,
2745 d3d11_device_CreateTexture2D
,
2746 d3d11_device_CreateTexture3D
,
2747 d3d11_device_CreateShaderResourceView
,
2748 d3d11_device_CreateUnorderedAccessView
,
2749 d3d11_device_CreateRenderTargetView
,
2750 d3d11_device_CreateDepthStencilView
,
2751 d3d11_device_CreateInputLayout
,
2752 d3d11_device_CreateVertexShader
,
2753 d3d11_device_CreateGeometryShader
,
2754 d3d11_device_CreateGeometryShaderWithStreamOutput
,
2755 d3d11_device_CreatePixelShader
,
2756 d3d11_device_CreateHullShader
,
2757 d3d11_device_CreateDomainShader
,
2758 d3d11_device_CreateComputeShader
,
2759 d3d11_device_CreateClassLinkage
,
2760 d3d11_device_CreateBlendState
,
2761 d3d11_device_CreateDepthStencilState
,
2762 d3d11_device_CreateRasterizerState
,
2763 d3d11_device_CreateSamplerState
,
2764 d3d11_device_CreateQuery
,
2765 d3d11_device_CreatePredicate
,
2766 d3d11_device_CreateCounter
,
2767 d3d11_device_CreateDeferredContext
,
2768 d3d11_device_OpenSharedResource
,
2769 d3d11_device_CheckFormatSupport
,
2770 d3d11_device_CheckMultisampleQualityLevels
,
2771 d3d11_device_CheckCounterInfo
,
2772 d3d11_device_CheckCounter
,
2773 d3d11_device_CheckFeatureSupport
,
2774 d3d11_device_GetPrivateData
,
2775 d3d11_device_SetPrivateData
,
2776 d3d11_device_SetPrivateDataInterface
,
2777 d3d11_device_GetFeatureLevel
,
2778 d3d11_device_GetCreationFlags
,
2779 d3d11_device_GetDeviceRemovedReason
,
2780 d3d11_device_GetImmediateContext
,
2781 d3d11_device_SetExceptionMode
,
2782 d3d11_device_GetExceptionMode
,
2785 /* Inner IUnknown methods */
2787 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
2789 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
2792 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
2794 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2796 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
2798 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
2799 || IsEqualGUID(riid
, &IID_IUnknown
))
2801 *out
= &device
->ID3D11Device_iface
;
2803 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
2804 || IsEqualGUID(riid
, &IID_ID3D10Device
))
2806 *out
= &device
->ID3D10Device1_iface
;
2808 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
2810 *out
= &device
->ID3D10Multithread_iface
;
2812 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
2814 *out
= &device
->IWineDXGIDeviceParent_iface
;
2818 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
2820 return E_NOINTERFACE
;
2823 IUnknown_AddRef((IUnknown
*)*out
);
2827 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
2829 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2830 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
2832 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
2837 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
2839 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2840 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
2842 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
2846 d3d11_immediate_context_destroy(&device
->immediate_context
);
2847 if (device
->wined3d_device
)
2849 wined3d_mutex_lock();
2850 wined3d_device_decref(device
->wined3d_device
);
2851 wined3d_mutex_unlock();
2853 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
2854 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
2855 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
2856 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
2862 /* IUnknown methods */
2864 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
2867 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2868 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
2871 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
2873 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2874 return IUnknown_AddRef(This
->outer_unk
);
2877 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
2879 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2880 return IUnknown_Release(This
->outer_unk
);
2883 /* ID3D10Device methods */
2885 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
2886 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2888 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2891 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2892 iface
, start_slot
, buffer_count
, buffers
);
2894 wined3d_mutex_lock();
2895 for (i
= 0; i
< buffer_count
; ++i
)
2897 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2899 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
2900 buffer
? buffer
->wined3d_buffer
: NULL
);
2902 wined3d_mutex_unlock();
2905 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
2906 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
2908 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2911 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2912 iface
, start_slot
, view_count
, views
);
2914 wined3d_mutex_lock();
2915 for (i
= 0; i
< view_count
; ++i
)
2917 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
2919 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
2920 view
? view
->wined3d_view
: NULL
);
2922 wined3d_mutex_unlock();
2925 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
2926 ID3D10PixelShader
*shader
)
2928 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2929 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
2931 TRACE("iface %p, shader %p\n", iface
, shader
);
2933 wined3d_mutex_lock();
2934 wined3d_device_set_pixel_shader(This
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
2935 wined3d_mutex_unlock();
2938 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
2939 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
2941 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2944 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2945 iface
, start_slot
, sampler_count
, samplers
);
2947 wined3d_mutex_lock();
2948 for (i
= 0; i
< sampler_count
; ++i
)
2950 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
2952 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
2953 sampler
? sampler
->wined3d_sampler
: NULL
);
2955 wined3d_mutex_unlock();
2958 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
2959 ID3D10VertexShader
*shader
)
2961 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2962 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
2964 TRACE("iface %p, shader %p\n", iface
, shader
);
2966 wined3d_mutex_lock();
2967 wined3d_device_set_vertex_shader(This
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
2968 wined3d_mutex_unlock();
2971 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
2972 UINT start_index_location
, INT base_vertex_location
)
2974 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2976 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2977 iface
, index_count
, start_index_location
, base_vertex_location
);
2979 wined3d_mutex_lock();
2980 wined3d_device_set_base_vertex_index(This
->wined3d_device
, base_vertex_location
);
2981 wined3d_device_draw_indexed_primitive(This
->wined3d_device
, start_index_location
, index_count
);
2982 wined3d_mutex_unlock();
2985 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
2986 UINT start_vertex_location
)
2988 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2990 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2991 iface
, vertex_count
, start_vertex_location
);
2993 wined3d_mutex_lock();
2994 wined3d_device_draw_primitive(This
->wined3d_device
, start_vertex_location
, vertex_count
);
2995 wined3d_mutex_unlock();
2998 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
2999 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3001 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3004 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3005 iface
, start_slot
, buffer_count
, buffers
);
3007 wined3d_mutex_lock();
3008 for (i
= 0; i
< buffer_count
; ++i
)
3010 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3012 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
3013 buffer
? buffer
->wined3d_buffer
: NULL
);
3015 wined3d_mutex_unlock();
3018 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
3019 ID3D10InputLayout
*input_layout
)
3021 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3022 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
3024 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
3026 wined3d_mutex_lock();
3027 wined3d_device_set_vertex_declaration(This
->wined3d_device
,
3028 layout
? layout
->wined3d_decl
: NULL
);
3029 wined3d_mutex_unlock();
3032 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
3033 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
3035 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3038 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
3039 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3041 wined3d_mutex_lock();
3042 for (i
= 0; i
< buffer_count
; ++i
)
3044 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3046 wined3d_device_set_stream_source(This
->wined3d_device
, start_slot
+ i
,
3047 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
3049 wined3d_mutex_unlock();
3052 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
3053 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
3055 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3056 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
3058 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
3059 iface
, buffer
, debug_dxgi_format(format
), offset
);
3061 wined3d_mutex_lock();
3062 wined3d_device_set_index_buffer(This
->wined3d_device
,
3063 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
3064 wined3dformat_from_dxgi_format(format
));
3065 wined3d_mutex_unlock();
3066 if (offset
) FIXME("offset %u not supported.\n", offset
);
3069 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
3070 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
3071 INT base_vertex_location
, UINT start_instance_location
)
3073 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3075 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
3076 "base_vertex_location %d, start_instance_location %u.\n",
3077 iface
, instance_index_count
, instance_count
, start_index_location
,
3078 base_vertex_location
, start_instance_location
);
3080 wined3d_mutex_lock();
3081 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
3082 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
3083 instance_index_count
, start_instance_location
, instance_count
);
3084 wined3d_mutex_unlock();
3087 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
3088 UINT instance_vertex_count
, UINT instance_count
,
3089 UINT start_vertex_location
, UINT start_instance_location
)
3091 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3093 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
3094 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
3095 start_vertex_location
, start_instance_location
);
3097 wined3d_mutex_lock();
3098 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
3099 instance_vertex_count
, start_instance_location
, instance_count
);
3100 wined3d_mutex_unlock();
3103 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
3104 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
3106 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3109 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3110 iface
, start_slot
, buffer_count
, buffers
);
3112 wined3d_mutex_lock();
3113 for (i
= 0; i
< buffer_count
; ++i
)
3115 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
3117 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
3118 buffer
? buffer
->wined3d_buffer
: NULL
);
3120 wined3d_mutex_unlock();
3123 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
3125 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3126 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
3128 TRACE("iface %p, shader %p.\n", iface
, shader
);
3130 wined3d_mutex_lock();
3131 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
3132 wined3d_mutex_unlock();
3135 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
3136 D3D10_PRIMITIVE_TOPOLOGY topology
)
3138 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3140 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
3142 wined3d_mutex_lock();
3143 wined3d_device_set_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
3144 wined3d_mutex_unlock();
3147 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
3148 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3150 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3153 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3154 iface
, start_slot
, view_count
, views
);
3156 wined3d_mutex_lock();
3157 for (i
= 0; i
< view_count
; ++i
)
3159 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3161 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3162 view
? view
->wined3d_view
: NULL
);
3164 wined3d_mutex_unlock();
3167 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
3168 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3170 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3173 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3174 iface
, start_slot
, sampler_count
, samplers
);
3176 wined3d_mutex_lock();
3177 for (i
= 0; i
< sampler_count
; ++i
)
3179 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3181 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
3182 sampler
? sampler
->wined3d_sampler
: NULL
);
3184 wined3d_mutex_unlock();
3187 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
3189 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3190 struct d3d_query
*query
;
3192 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
3194 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
3195 wined3d_mutex_lock();
3196 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
3197 wined3d_mutex_unlock();
3200 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
3201 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
3203 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3206 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3207 iface
, start_slot
, view_count
, views
);
3209 wined3d_mutex_lock();
3210 for (i
= 0; i
< view_count
; ++i
)
3212 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3214 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3215 view
? view
->wined3d_view
: NULL
);
3217 wined3d_mutex_unlock();
3220 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3221 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3223 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3226 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3227 iface
, start_slot
, sampler_count
, samplers
);
3229 wined3d_mutex_lock();
3230 for (i
= 0; i
< sampler_count
; ++i
)
3232 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3234 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3235 sampler
? sampler
->wined3d_sampler
: NULL
);
3237 wined3d_mutex_unlock();
3240 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3241 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3242 ID3D10DepthStencilView
*depth_stencil_view
)
3244 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3245 struct d3d_depthstencil_view
*dsv
;
3248 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3249 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3251 wined3d_mutex_lock();
3252 for (i
= 0; i
< render_target_view_count
; ++i
)
3254 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3256 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3257 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3259 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3261 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3264 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3265 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3266 dsv
? dsv
->wined3d_view
: NULL
);
3267 wined3d_mutex_unlock();
3270 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3271 ID3D10BlendState
*blend_state
, const float blend_factor
[4], UINT sample_mask
)
3273 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3274 struct d3d_blend_state
*blend_state_object
;
3276 TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n",
3277 iface
, blend_state
, debug_float4(blend_factor
), sample_mask
);
3279 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3280 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3281 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3284 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3285 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3287 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3288 struct d3d_depthstencil_state
*ds_state_object
;
3290 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3291 iface
, depth_stencil_state
, stencil_ref
);
3293 ds_state_object
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3294 d3d11_immediate_context_OMSetDepthStencilState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3295 ds_state_object
? &ds_state_object
->ID3D11DepthStencilState_iface
: NULL
, stencil_ref
);
3298 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3299 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3301 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3302 unsigned int count
, i
;
3304 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3306 count
= min(target_count
, 4);
3307 wined3d_mutex_lock();
3308 for (i
= 0; i
< count
; ++i
)
3310 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
3312 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
3313 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
3316 for (i
= count
; i
< 4; ++i
)
3318 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
3320 wined3d_mutex_unlock();
3323 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
3325 FIXME("iface %p stub!\n", iface
);
3328 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
3330 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3331 struct d3d_rasterizer_state
*rasterizer_state_object
;
3333 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3335 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
3336 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3337 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
3340 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
3341 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
3343 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3344 struct wined3d_viewport wined3d_vp
;
3346 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
3348 if (viewport_count
> 1)
3349 FIXME("Multiple viewports not implemented.\n");
3351 if (!viewport_count
)
3354 wined3d_vp
.x
= viewports
[0].TopLeftX
;
3355 wined3d_vp
.y
= viewports
[0].TopLeftY
;
3356 wined3d_vp
.width
= viewports
[0].Width
;
3357 wined3d_vp
.height
= viewports
[0].Height
;
3358 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
3359 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
3361 wined3d_mutex_lock();
3362 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
3363 wined3d_mutex_unlock();
3366 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
3367 UINT rect_count
, const D3D10_RECT
*rects
)
3369 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3371 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
3374 FIXME("Multiple scissor rects not implemented.\n");
3379 wined3d_mutex_lock();
3380 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
3381 wined3d_mutex_unlock();
3384 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
3385 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
3386 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
3388 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3389 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3390 struct wined3d_box wined3d_src_box
;
3392 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3393 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3394 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
3395 src_resource
, src_subresource_idx
, src_box
);
3399 wined3d_src_box
.left
= src_box
->left
;
3400 wined3d_src_box
.top
= src_box
->top
;
3401 wined3d_src_box
.front
= src_box
->front
;
3402 wined3d_src_box
.right
= src_box
->right
;
3403 wined3d_src_box
.bottom
= src_box
->bottom
;
3404 wined3d_src_box
.back
= src_box
->back
;
3407 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3408 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3409 wined3d_mutex_lock();
3410 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
3411 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, src_box
? &wined3d_src_box
: NULL
);
3412 wined3d_mutex_unlock();
3415 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
3416 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
3418 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3419 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3421 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
3423 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3424 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3425 wined3d_mutex_lock();
3426 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
3427 wined3d_mutex_unlock();
3430 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
3431 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
3432 const void *data
, UINT row_pitch
, UINT depth_pitch
)
3434 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3435 ID3D11Resource
*d3d11_resource
;
3437 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3438 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
3440 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
3441 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3442 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
3443 ID3D11Resource_Release(d3d11_resource
);
3446 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
3447 ID3D10RenderTargetView
*render_target_view
, const float color_rgba
[4])
3449 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3450 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
3451 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
3454 TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
3455 iface
, render_target_view
, debug_float4(color_rgba
));
3460 wined3d_mutex_lock();
3461 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3462 WINED3DCLEAR_TARGET
, &color
, 0.0f
, 0)))
3463 ERR("Failed to clear view, hr %#x.\n", hr
);
3464 wined3d_mutex_unlock();
3467 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
3468 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
3470 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3471 struct d3d_depthstencil_view
*view
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3472 DWORD wined3d_flags
;
3475 TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n",
3476 iface
, depth_stencil_view
, flags
, depth
, stencil
);
3481 wined3d_flags
= wined3d_clear_flags_from_d3d11_clear_flags(flags
);
3483 wined3d_mutex_lock();
3484 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
,
3485 wined3d_flags
, NULL
, depth
, stencil
)))
3486 ERR("Failed to clear view, hr %#x.\n", hr
);
3487 wined3d_mutex_unlock();
3490 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
3491 ID3D10ShaderResourceView
*shader_resource_view
)
3493 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
3496 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
3497 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
3498 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
3500 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3501 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3502 iface
, dst_resource
, dst_subresource_idx
,
3503 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
3506 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
3507 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3509 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3512 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3513 iface
, start_slot
, buffer_count
, buffers
);
3515 wined3d_mutex_lock();
3516 for (i
= 0; i
< buffer_count
; ++i
)
3518 struct wined3d_buffer
*wined3d_buffer
;
3519 struct d3d_buffer
*buffer_impl
;
3521 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
3527 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3528 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3529 ID3D10Buffer_AddRef(buffers
[i
]);
3531 wined3d_mutex_unlock();
3534 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
3535 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3537 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3540 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3541 iface
, start_slot
, view_count
, views
);
3543 wined3d_mutex_lock();
3544 for (i
= 0; i
< view_count
; ++i
)
3546 struct wined3d_shader_resource_view
*wined3d_view
;
3547 struct d3d_shader_resource_view
*view_impl
;
3549 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3555 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3556 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3557 ID3D10ShaderResourceView_AddRef(views
[i
]);
3559 wined3d_mutex_unlock();
3562 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
3564 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3565 struct d3d_pixel_shader
*shader_impl
;
3566 struct wined3d_shader
*wined3d_shader
;
3568 TRACE("iface %p, shader %p.\n", iface
, shader
);
3570 wined3d_mutex_lock();
3571 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
3573 wined3d_mutex_unlock();
3578 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3579 wined3d_mutex_unlock();
3580 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
3581 ID3D10PixelShader_AddRef(*shader
);
3584 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
3585 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3587 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3590 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3591 iface
, start_slot
, sampler_count
, samplers
);
3593 wined3d_mutex_lock();
3594 for (i
= 0; i
< sampler_count
; ++i
)
3596 struct d3d_sampler_state
*sampler_impl
;
3597 struct wined3d_sampler
*wined3d_sampler
;
3599 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
3605 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3606 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3607 ID3D10SamplerState_AddRef(samplers
[i
]);
3609 wined3d_mutex_unlock();
3612 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
3614 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3615 struct d3d_vertex_shader
*shader_impl
;
3616 struct wined3d_shader
*wined3d_shader
;
3618 TRACE("iface %p, shader %p.\n", iface
, shader
);
3620 wined3d_mutex_lock();
3621 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
3623 wined3d_mutex_unlock();
3628 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3629 wined3d_mutex_unlock();
3630 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
3631 ID3D10VertexShader_AddRef(*shader
);
3634 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
3635 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3637 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3640 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3641 iface
, start_slot
, buffer_count
, buffers
);
3643 wined3d_mutex_lock();
3644 for (i
= 0; i
< buffer_count
; ++i
)
3646 struct wined3d_buffer
*wined3d_buffer
;
3647 struct d3d_buffer
*buffer_impl
;
3649 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
3655 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3656 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3657 ID3D10Buffer_AddRef(buffers
[i
]);
3659 wined3d_mutex_unlock();
3662 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
3664 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3665 struct wined3d_vertex_declaration
*wined3d_declaration
;
3666 struct d3d_input_layout
*input_layout_impl
;
3668 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
3670 wined3d_mutex_lock();
3671 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
3673 wined3d_mutex_unlock();
3674 *input_layout
= NULL
;
3678 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
3679 wined3d_mutex_unlock();
3680 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
3681 ID3D10InputLayout_AddRef(*input_layout
);
3684 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
3685 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
3687 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3690 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3691 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3693 wined3d_mutex_lock();
3694 for (i
= 0; i
< buffer_count
; ++i
)
3696 struct wined3d_buffer
*wined3d_buffer
;
3697 struct d3d_buffer
*buffer_impl
;
3699 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
3700 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
3701 ERR("Failed to get vertex buffer.\n");
3703 if (!wined3d_buffer
)
3709 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3710 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3711 ID3D10Buffer_AddRef(buffers
[i
]);
3713 wined3d_mutex_unlock();
3716 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
3717 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
3719 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3720 enum wined3d_format_id wined3d_format
;
3721 struct wined3d_buffer
*wined3d_buffer
;
3722 struct d3d_buffer
*buffer_impl
;
3724 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
3726 wined3d_mutex_lock();
3727 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
);
3728 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
3729 *offset
= 0; /* FIXME */
3730 if (!wined3d_buffer
)
3732 wined3d_mutex_unlock();
3737 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3738 wined3d_mutex_unlock();
3739 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
3740 ID3D10Buffer_AddRef(*buffer
);
3743 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
3744 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3746 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3749 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3750 iface
, start_slot
, buffer_count
, buffers
);
3752 wined3d_mutex_lock();
3753 for (i
= 0; i
< buffer_count
; ++i
)
3755 struct wined3d_buffer
*wined3d_buffer
;
3756 struct d3d_buffer
*buffer_impl
;
3758 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
3764 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3765 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3766 ID3D10Buffer_AddRef(buffers
[i
]);
3768 wined3d_mutex_unlock();
3771 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
3773 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3774 struct d3d_geometry_shader
*shader_impl
;
3775 struct wined3d_shader
*wined3d_shader
;
3777 TRACE("iface %p, shader %p.\n", iface
, shader
);
3779 wined3d_mutex_lock();
3780 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
3782 wined3d_mutex_unlock();
3787 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3788 wined3d_mutex_unlock();
3789 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
3790 ID3D10GeometryShader_AddRef(*shader
);
3793 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
3794 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
3796 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3798 TRACE("iface %p, topology %p\n", iface
, topology
);
3800 wined3d_mutex_lock();
3801 wined3d_device_get_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
3802 wined3d_mutex_unlock();
3805 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
3806 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3808 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3811 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3812 iface
, start_slot
, view_count
, views
);
3814 wined3d_mutex_lock();
3815 for (i
= 0; i
< view_count
; ++i
)
3817 struct wined3d_shader_resource_view
*wined3d_view
;
3818 struct d3d_shader_resource_view
*view_impl
;
3820 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3826 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3827 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3828 ID3D10ShaderResourceView_AddRef(views
[i
]);
3830 wined3d_mutex_unlock();
3833 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
3834 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3836 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3839 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3840 iface
, start_slot
, sampler_count
, samplers
);
3842 wined3d_mutex_lock();
3843 for (i
= 0; i
< sampler_count
; ++i
)
3845 struct d3d_sampler_state
*sampler_impl
;
3846 struct wined3d_sampler
*wined3d_sampler
;
3848 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3854 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3855 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3856 ID3D10SamplerState_AddRef(samplers
[i
]);
3858 wined3d_mutex_unlock();
3861 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
3862 ID3D10Predicate
**predicate
, BOOL
*value
)
3864 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3865 struct wined3d_query
*wined3d_predicate
;
3866 struct d3d_query
*predicate_impl
;
3868 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
3870 wined3d_mutex_lock();
3871 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
3873 wined3d_mutex_unlock();
3878 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
3879 wined3d_mutex_unlock();
3880 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
3881 ID3D10Predicate_AddRef(*predicate
);
3884 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
3885 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3887 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3890 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3891 iface
, start_slot
, view_count
, views
);
3893 wined3d_mutex_lock();
3894 for (i
= 0; i
< view_count
; ++i
)
3896 struct wined3d_shader_resource_view
*wined3d_view
;
3897 struct d3d_shader_resource_view
*view_impl
;
3899 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3905 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3906 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3907 ID3D10ShaderResourceView_AddRef(views
[i
]);
3909 wined3d_mutex_unlock();
3912 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
3913 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3915 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3918 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3919 iface
, start_slot
, sampler_count
, samplers
);
3921 wined3d_mutex_lock();
3922 for (i
= 0; i
< sampler_count
; ++i
)
3924 struct d3d_sampler_state
*sampler_impl
;
3925 struct wined3d_sampler
*wined3d_sampler
;
3927 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3933 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3934 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3935 ID3D10SamplerState_AddRef(samplers
[i
]);
3937 wined3d_mutex_unlock();
3940 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
3941 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
3943 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3944 struct wined3d_rendertarget_view
*wined3d_view
;
3946 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3947 iface
, view_count
, render_target_views
, depth_stencil_view
);
3949 wined3d_mutex_lock();
3950 if (render_target_views
)
3952 struct d3d_rendertarget_view
*view_impl
;
3955 for (i
= 0; i
< view_count
; ++i
)
3957 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
3958 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3960 render_target_views
[i
] = NULL
;
3964 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
3965 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
3969 if (depth_stencil_view
)
3971 struct d3d_depthstencil_view
*view_impl
;
3973 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
3974 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3976 *depth_stencil_view
= NULL
;
3980 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
3981 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
3984 wined3d_mutex_unlock();
3987 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
3988 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
3990 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3992 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3993 iface
, blend_state
, blend_factor
, sample_mask
);
3995 if ((*blend_state
= device
->blend_state
? (ID3D10BlendState
*)&device
->blend_state
->ID3D10BlendState1_iface
: NULL
))
3996 ID3D10BlendState_AddRef(*blend_state
);
3997 wined3d_mutex_lock();
3998 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
3999 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
4000 wined3d_mutex_unlock();
4003 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
4004 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
4006 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4008 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
4009 iface
, depth_stencil_state
, stencil_ref
);
4011 if ((*depth_stencil_state
= device
->depth_stencil_state
4012 ? &device
->depth_stencil_state
->ID3D10DepthStencilState_iface
: NULL
))
4013 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
4014 *stencil_ref
= device
->stencil_ref
;
4017 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
4018 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
4020 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4023 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
4024 iface
, buffer_count
, buffers
, offsets
);
4026 wined3d_mutex_lock();
4027 for (i
= 0; i
< buffer_count
; ++i
)
4029 struct wined3d_buffer
*wined3d_buffer
;
4030 struct d3d_buffer
*buffer_impl
;
4032 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
4038 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
4039 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
4040 ID3D10Buffer_AddRef(buffers
[i
]);
4042 wined3d_mutex_unlock();
4045 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
4047 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4049 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
4051 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
4052 ID3D10RasterizerState_AddRef(*rasterizer_state
);
4055 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
4056 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
4058 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4059 struct wined3d_viewport wined3d_vp
;
4061 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
4065 *viewport_count
= 1;
4069 if (!*viewport_count
)
4072 wined3d_mutex_lock();
4073 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
4074 wined3d_mutex_unlock();
4076 viewports
[0].TopLeftX
= wined3d_vp
.x
;
4077 viewports
[0].TopLeftY
= wined3d_vp
.y
;
4078 viewports
[0].Width
= wined3d_vp
.width
;
4079 viewports
[0].Height
= wined3d_vp
.height
;
4080 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
4081 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
4083 if (*viewport_count
> 1)
4084 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
4087 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
4089 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4091 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
4102 wined3d_mutex_lock();
4103 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
4104 wined3d_mutex_unlock();
4105 if (*rect_count
> 1)
4106 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
4109 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
4111 TRACE("iface %p.\n", iface
);
4113 /* In the current implementation the device is never removed, so we can
4114 * just return S_OK here. */
4119 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
4121 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
4126 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
4128 FIXME("iface %p stub!\n", iface
);
4133 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
4134 REFGUID guid
, UINT
*data_size
, void *data
)
4136 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4138 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4140 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4143 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
4144 REFGUID guid
, UINT data_size
, const void *data
)
4146 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4148 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
4150 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
4153 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
4154 REFGUID guid
, const IUnknown
*data
)
4156 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4158 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
4160 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
4163 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
4165 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4166 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4169 TRACE("iface %p.\n", iface
);
4171 wined3d_mutex_lock();
4172 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
4173 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4175 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
4177 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4179 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
4181 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4183 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
4185 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
4186 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4188 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
4190 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4192 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
4194 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4196 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
4198 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
4199 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4201 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
4203 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4205 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
4207 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4209 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
4211 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4213 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
4215 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
);
4216 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
4217 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
4218 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4220 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
4222 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
4223 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
4224 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4225 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
4226 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
4227 ID3D10Device1_RSSetState(iface
, NULL
);
4228 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4230 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4232 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
4233 wined3d_mutex_unlock();
4236 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4238 FIXME("iface %p stub!\n", iface
);
4241 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4242 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4244 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4245 D3D11_BUFFER_DESC d3d11_desc
;
4246 struct d3d_buffer
*object
;
4249 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4251 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4252 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4253 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4254 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4255 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4256 d3d11_desc
.StructureByteStride
= 0;
4258 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4261 *buffer
= &object
->ID3D10Buffer_iface
;
4266 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4267 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4269 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4274 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4275 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4276 ID3D10Texture2D
**texture
)
4278 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4279 D3D11_TEXTURE2D_DESC d3d11_desc
;
4280 struct d3d_texture2d
*object
;
4283 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4285 d3d11_desc
.Width
= desc
->Width
;
4286 d3d11_desc
.Height
= desc
->Height
;
4287 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4288 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4289 d3d11_desc
.Format
= desc
->Format
;
4290 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4291 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4292 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4293 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4294 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4296 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4299 *texture
= &object
->ID3D10Texture2D_iface
;
4304 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4305 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4306 ID3D10Texture3D
**texture
)
4308 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4309 D3D11_TEXTURE3D_DESC d3d11_desc
;
4310 struct d3d_texture3d
*object
;
4313 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4315 d3d11_desc
.Width
= desc
->Width
;
4316 d3d11_desc
.Height
= desc
->Height
;
4317 d3d11_desc
.Depth
= desc
->Depth
;
4318 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4319 d3d11_desc
.Format
= desc
->Format
;
4320 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4321 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4322 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4323 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4325 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4328 *texture
= &object
->ID3D10Texture3D_iface
;
4333 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4334 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4336 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4337 struct d3d_shader_resource_view
*object
;
4338 ID3D11Resource
*d3d11_resource
;
4341 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4343 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4345 ERR("Resource does not implement ID3D11Resource.\n");
4349 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4351 ID3D11Resource_Release(d3d11_resource
);
4355 *view
= &object
->ID3D10ShaderResourceView1_iface
;
4360 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
4361 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
4363 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4365 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
4366 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
4369 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
4370 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
4372 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4373 struct d3d_rendertarget_view
*object
;
4374 ID3D11Resource
*d3d11_resource
;
4377 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4379 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4381 ERR("Resource does not implement ID3D11Resource.\n");
4385 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
4386 ID3D11Resource_Release(d3d11_resource
);
4390 *view
= &object
->ID3D10RenderTargetView_iface
;
4395 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
4396 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
4398 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4399 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
4400 struct d3d_depthstencil_view
*object
;
4401 ID3D11Resource
*d3d11_resource
;
4404 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4408 d3d11_desc
.Format
= desc
->Format
;
4409 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
4410 d3d11_desc
.Flags
= 0;
4411 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
4414 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4416 ERR("Resource does not implement ID3D11Resource.\n");
4420 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
4421 ID3D11Resource_Release(d3d11_resource
);
4425 *view
= &object
->ID3D10DepthStencilView_iface
;
4430 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
4431 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
4432 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
4433 ID3D10InputLayout
**input_layout
)
4435 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4436 struct d3d_input_layout
*object
;
4439 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4440 "shader_byte_code_length %lu, input_layout %p\n",
4441 iface
, element_descs
, element_count
, shader_byte_code
,
4442 shader_byte_code_length
, input_layout
);
4444 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
4445 shader_byte_code
, shader_byte_code_length
, &object
)))
4448 *input_layout
= &object
->ID3D10InputLayout_iface
;
4453 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
4454 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
4456 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4457 struct d3d_vertex_shader
*object
;
4460 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4461 iface
, byte_code
, byte_code_length
, shader
);
4463 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4466 *shader
= &object
->ID3D10VertexShader_iface
;
4471 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
4472 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
4474 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4475 struct d3d_geometry_shader
*object
;
4478 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4479 iface
, byte_code
, byte_code_length
, shader
);
4481 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4484 *shader
= &object
->ID3D10GeometryShader_iface
;
4489 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
4490 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
4491 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
4493 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4494 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4495 iface
, byte_code
, byte_code_length
, output_stream_decls
,
4496 output_stream_decl_count
, output_stream_stride
, shader
);
4501 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
4502 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
4504 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4505 struct d3d_pixel_shader
*object
;
4508 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4509 iface
, byte_code
, byte_code_length
, shader
);
4511 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4514 *shader
= &object
->ID3D10PixelShader_iface
;
4519 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
4520 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
4522 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4523 ID3D11BlendState
*d3d11_blend_state
;
4526 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4528 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device_iface
, (D3D11_BLEND_DESC
*)desc
,
4529 &d3d11_blend_state
)))
4532 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState1
, (void **)blend_state
);
4533 ID3D11BlendState_Release(d3d11_blend_state
);
4537 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
4538 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
4540 D3D10_BLEND_DESC1 d3d10_1_desc
;
4543 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4546 return E_INVALIDARG
;
4548 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
4549 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
4550 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
4552 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
4553 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
4554 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
4557 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4559 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
4560 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
4561 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
4562 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
4563 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
4564 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
4565 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
4566 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
4569 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
4572 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
4573 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
4575 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4576 ID3D11DepthStencilState
*d3d11_depth_stencil_state
;
4579 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
4581 if (FAILED(hr
= d3d11_device_CreateDepthStencilState(&device
->ID3D11Device_iface
,
4582 (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &d3d11_depth_stencil_state
)))
4585 hr
= ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state
, &IID_ID3D10DepthStencilState
,
4586 (void **)depth_stencil_state
);
4587 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state
);
4591 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
4592 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
4594 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4595 ID3D11RasterizerState
*d3d11_rasterizer_state
;
4598 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
4600 if (FAILED(hr
= d3d11_device_CreateRasterizerState(&device
->ID3D11Device_iface
,
4601 (const D3D11_RASTERIZER_DESC
*)desc
, &d3d11_rasterizer_state
)))
4604 hr
= ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state
,
4605 &IID_ID3D10RasterizerState
, (void **)rasterizer_state
);
4606 ID3D11RasterizerState_Release(d3d11_rasterizer_state
);
4610 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
4611 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
4613 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4614 ID3D11SamplerState
*d3d11_sampler_state
;
4617 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
4619 if (FAILED(hr
= d3d11_device_CreateSamplerState(&device
->ID3D11Device_iface
,
4620 (const D3D11_SAMPLER_DESC
*)desc
, &d3d11_sampler_state
)))
4623 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
, (void **)sampler_state
);
4624 ID3D11SamplerState_Release(d3d11_sampler_state
);
4628 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
4629 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
4631 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4632 struct d3d_query
*object
;
4635 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
4637 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
4642 *query
= &object
->ID3D10Query_iface
;
4646 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4650 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
4651 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
4653 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4654 struct d3d_query
*object
;
4657 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
4659 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
4664 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
4668 ID3D10Query_Release(&object
->ID3D10Query_iface
);
4672 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
4673 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
4675 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
4680 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
4681 DXGI_FORMAT format
, UINT
*format_support
)
4683 FIXME("iface %p, format %s, format_support %p stub!\n",
4684 iface
, debug_dxgi_format(format
), format_support
);
4689 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
4690 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
4692 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4694 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
4695 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
4697 return d3d11_device_CheckMultisampleQualityLevels(&device
->ID3D11Device_iface
, format
,
4698 sample_count
, quality_level_count
);
4701 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
4703 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
4706 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
4707 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
4708 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4710 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4711 "units %p, units_length %p, description %p, description_length %p stub!\n",
4712 iface
, desc
, type
, active_counters
, name
, name_length
,
4713 units
, units_length
, description
, description_length
);
4718 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
4720 FIXME("iface %p stub!\n", iface
);
4725 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
4726 HANDLE resource_handle
, REFIID guid
, void **resource
)
4728 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4729 iface
, resource_handle
, debugstr_guid(guid
), resource
);
4734 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
4736 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
4739 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
4741 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
4744 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
4746 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4748 TRACE("iface %p.\n", iface
);
4750 return device
->feature_level
;
4753 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
4755 /* IUnknown methods */
4756 d3d10_device_QueryInterface
,
4757 d3d10_device_AddRef
,
4758 d3d10_device_Release
,
4759 /* ID3D10Device methods */
4760 d3d10_device_VSSetConstantBuffers
,
4761 d3d10_device_PSSetShaderResources
,
4762 d3d10_device_PSSetShader
,
4763 d3d10_device_PSSetSamplers
,
4764 d3d10_device_VSSetShader
,
4765 d3d10_device_DrawIndexed
,
4767 d3d10_device_PSSetConstantBuffers
,
4768 d3d10_device_IASetInputLayout
,
4769 d3d10_device_IASetVertexBuffers
,
4770 d3d10_device_IASetIndexBuffer
,
4771 d3d10_device_DrawIndexedInstanced
,
4772 d3d10_device_DrawInstanced
,
4773 d3d10_device_GSSetConstantBuffers
,
4774 d3d10_device_GSSetShader
,
4775 d3d10_device_IASetPrimitiveTopology
,
4776 d3d10_device_VSSetShaderResources
,
4777 d3d10_device_VSSetSamplers
,
4778 d3d10_device_SetPredication
,
4779 d3d10_device_GSSetShaderResources
,
4780 d3d10_device_GSSetSamplers
,
4781 d3d10_device_OMSetRenderTargets
,
4782 d3d10_device_OMSetBlendState
,
4783 d3d10_device_OMSetDepthStencilState
,
4784 d3d10_device_SOSetTargets
,
4785 d3d10_device_DrawAuto
,
4786 d3d10_device_RSSetState
,
4787 d3d10_device_RSSetViewports
,
4788 d3d10_device_RSSetScissorRects
,
4789 d3d10_device_CopySubresourceRegion
,
4790 d3d10_device_CopyResource
,
4791 d3d10_device_UpdateSubresource
,
4792 d3d10_device_ClearRenderTargetView
,
4793 d3d10_device_ClearDepthStencilView
,
4794 d3d10_device_GenerateMips
,
4795 d3d10_device_ResolveSubresource
,
4796 d3d10_device_VSGetConstantBuffers
,
4797 d3d10_device_PSGetShaderResources
,
4798 d3d10_device_PSGetShader
,
4799 d3d10_device_PSGetSamplers
,
4800 d3d10_device_VSGetShader
,
4801 d3d10_device_PSGetConstantBuffers
,
4802 d3d10_device_IAGetInputLayout
,
4803 d3d10_device_IAGetVertexBuffers
,
4804 d3d10_device_IAGetIndexBuffer
,
4805 d3d10_device_GSGetConstantBuffers
,
4806 d3d10_device_GSGetShader
,
4807 d3d10_device_IAGetPrimitiveTopology
,
4808 d3d10_device_VSGetShaderResources
,
4809 d3d10_device_VSGetSamplers
,
4810 d3d10_device_GetPredication
,
4811 d3d10_device_GSGetShaderResources
,
4812 d3d10_device_GSGetSamplers
,
4813 d3d10_device_OMGetRenderTargets
,
4814 d3d10_device_OMGetBlendState
,
4815 d3d10_device_OMGetDepthStencilState
,
4816 d3d10_device_SOGetTargets
,
4817 d3d10_device_RSGetState
,
4818 d3d10_device_RSGetViewports
,
4819 d3d10_device_RSGetScissorRects
,
4820 d3d10_device_GetDeviceRemovedReason
,
4821 d3d10_device_SetExceptionMode
,
4822 d3d10_device_GetExceptionMode
,
4823 d3d10_device_GetPrivateData
,
4824 d3d10_device_SetPrivateData
,
4825 d3d10_device_SetPrivateDataInterface
,
4826 d3d10_device_ClearState
,
4828 d3d10_device_CreateBuffer
,
4829 d3d10_device_CreateTexture1D
,
4830 d3d10_device_CreateTexture2D
,
4831 d3d10_device_CreateTexture3D
,
4832 d3d10_device_CreateShaderResourceView
,
4833 d3d10_device_CreateRenderTargetView
,
4834 d3d10_device_CreateDepthStencilView
,
4835 d3d10_device_CreateInputLayout
,
4836 d3d10_device_CreateVertexShader
,
4837 d3d10_device_CreateGeometryShader
,
4838 d3d10_device_CreateGeometryShaderWithStreamOutput
,
4839 d3d10_device_CreatePixelShader
,
4840 d3d10_device_CreateBlendState
,
4841 d3d10_device_CreateDepthStencilState
,
4842 d3d10_device_CreateRasterizerState
,
4843 d3d10_device_CreateSamplerState
,
4844 d3d10_device_CreateQuery
,
4845 d3d10_device_CreatePredicate
,
4846 d3d10_device_CreateCounter
,
4847 d3d10_device_CheckFormatSupport
,
4848 d3d10_device_CheckMultisampleQualityLevels
,
4849 d3d10_device_CheckCounterInfo
,
4850 d3d10_device_CheckCounter
,
4851 d3d10_device_GetCreationFlags
,
4852 d3d10_device_OpenSharedResource
,
4853 d3d10_device_SetTextFilterSize
,
4854 d3d10_device_GetTextFilterSize
,
4855 d3d10_device_CreateShaderResourceView1
,
4856 d3d10_device_CreateBlendState1
,
4857 d3d10_device_GetFeatureLevel
,
4860 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
4862 /* IUnknown methods */
4863 d3d_device_inner_QueryInterface
,
4864 d3d_device_inner_AddRef
,
4865 d3d_device_inner_Release
,
4868 /* ID3D10Multithread methods */
4870 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
4872 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
4875 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
4877 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4879 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
4881 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4884 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
4886 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4888 TRACE("iface %p.\n", iface
);
4890 return IUnknown_AddRef(device
->outer_unk
);
4893 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
4895 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4897 TRACE("iface %p.\n", iface
);
4899 return IUnknown_Release(device
->outer_unk
);
4902 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
4904 TRACE("iface %p.\n", iface
);
4906 wined3d_mutex_lock();
4909 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
4911 TRACE("iface %p.\n", iface
);
4913 wined3d_mutex_unlock();
4916 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
4918 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
4923 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
4925 FIXME("iface %p stub!\n", iface
);
4930 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
4932 d3d10_multithread_QueryInterface
,
4933 d3d10_multithread_AddRef
,
4934 d3d10_multithread_Release
,
4935 d3d10_multithread_Enter
,
4936 d3d10_multithread_Leave
,
4937 d3d10_multithread_SetMultithreadProtected
,
4938 d3d10_multithread_GetMultithreadProtected
,
4941 /* IWineDXGIDeviceParent IUnknown methods */
4943 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
4945 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
4948 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
4949 REFIID riid
, void **ppv
)
4951 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4952 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
4955 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
4957 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4958 return IUnknown_AddRef(device
->outer_unk
);
4961 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
4963 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4964 return IUnknown_Release(device
->outer_unk
);
4967 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
4968 IWineDXGIDeviceParent
*iface
)
4970 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4971 return &device
->device_parent
;
4974 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
4976 /* IUnknown methods */
4977 dxgi_device_parent_QueryInterface
,
4978 dxgi_device_parent_AddRef
,
4979 dxgi_device_parent_Release
,
4980 /* IWineDXGIDeviceParent methods */
4981 dxgi_device_parent_get_wined3d_device_parent
,
4984 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
4986 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
4989 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
4990 struct wined3d_device
*wined3d_device
)
4992 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
4994 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
4996 wined3d_device_incref(wined3d_device
);
4997 device
->wined3d_device
= wined3d_device
;
5000 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
5002 TRACE("device_parent %p.\n", device_parent
);
5005 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
5007 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
5010 static HRESULT CDECL
device_parent_sub_resource_created(struct wined3d_device_parent
*device_parent
,
5011 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
5012 const struct wined3d_parent_ops
**parent_ops
)
5014 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
5015 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
5018 *parent_ops
= &d3d_null_wined3d_parent_ops
;
5023 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
5024 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
5025 struct wined3d_texture
**wined3d_texture
)
5027 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5028 struct d3d_texture2d
*texture
;
5029 ID3D10Texture2D
*texture_iface
;
5030 D3D10_TEXTURE2D_DESC desc
;
5033 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
5034 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
5036 FIXME("Implement DXGI<->wined3d usage conversion.\n");
5038 desc
.Width
= wined3d_desc
->width
;
5039 desc
.Height
= wined3d_desc
->height
;
5042 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
5043 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
5044 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
5045 desc
.Usage
= D3D10_USAGE_DEFAULT
;
5046 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5047 desc
.CPUAccessFlags
= 0;
5050 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
5051 &desc
, NULL
, &texture_iface
)))
5053 WARN("CreateTexture2D failed, returning %#x.\n", hr
);
5057 texture
= impl_from_ID3D10Texture2D(texture_iface
);
5059 *wined3d_texture
= texture
->wined3d_texture
;
5060 wined3d_texture_incref(*wined3d_texture
);
5061 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
5066 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
5067 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
5069 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
5070 IWineDXGIDevice
*wine_device
;
5073 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
5075 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
5076 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
5078 ERR("Device should implement IWineDXGIDevice.\n");
5082 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, TRUE
, swapchain
);
5083 IWineDXGIDevice_Release(wine_device
);
5086 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
5093 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
5095 device_parent_wined3d_device_created
,
5096 device_parent_mode_changed
,
5097 device_parent_activate
,
5098 device_parent_sub_resource_created
,
5099 device_parent_sub_resource_created
,
5100 device_parent_create_swapchain_texture
,
5101 device_parent_create_swapchain
,
5104 static void *d3d_rb_alloc(size_t size
)
5106 return HeapAlloc(GetProcessHeap(), 0, size
);
5109 static void *d3d_rb_realloc(void *ptr
, size_t size
)
5111 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
5114 static void d3d_rb_free(void *ptr
)
5116 HeapFree(GetProcessHeap(), 0, ptr
);
5119 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5121 const D3D11_SAMPLER_DESC
*ka
= key
;
5122 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
5124 return memcmp(ka
, kb
, sizeof(*ka
));
5127 static const struct wine_rb_functions d3d_sampler_state_rb_ops
=
5132 d3d_sampler_state_compare
,
5135 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5137 const D3D11_BLEND_DESC
*ka
= key
;
5138 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
5140 return memcmp(ka
, kb
, sizeof(*ka
));
5143 static const struct wine_rb_functions d3d_blend_state_rb_ops
=
5148 d3d_blend_state_compare
,
5151 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5153 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
5154 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
5155 const struct d3d_depthstencil_state
, entry
)->desc
;
5157 return memcmp(ka
, kb
, sizeof(*ka
));
5160 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops
=
5165 d3d_depthstencil_state_compare
,
5168 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
5170 const D3D11_RASTERIZER_DESC
*ka
= key
;
5171 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
5173 return memcmp(ka
, kb
, sizeof(*ka
));
5176 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops
=
5181 d3d_rasterizer_state_compare
,
5184 HRESULT
d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
5186 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
5187 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
5188 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
5189 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
5190 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
5191 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
5192 device
->refcount
= 1;
5193 /* COM aggregation always takes place */
5194 device
->outer_unk
= outer_unknown
;
5196 d3d11_immediate_context_init(&device
->immediate_context
, device
);
5197 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
5199 if (wine_rb_init(&device
->blend_states
, &d3d_blend_state_rb_ops
) == -1)
5201 WARN("Failed to initialize blend state rbtree.\n");
5204 device
->blend_factor
[0] = 1.0f
;
5205 device
->blend_factor
[1] = 1.0f
;
5206 device
->blend_factor
[2] = 1.0f
;
5207 device
->blend_factor
[3] = 1.0f
;
5209 if (wine_rb_init(&device
->depthstencil_states
, &d3d_depthstencil_state_rb_ops
) == -1)
5211 WARN("Failed to initialize depthstencil state rbtree.\n");
5212 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
5216 if (wine_rb_init(&device
->rasterizer_states
, &d3d_rasterizer_state_rb_ops
) == -1)
5218 WARN("Failed to initialize rasterizer state rbtree.\n");
5219 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
5220 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
5224 if (wine_rb_init(&device
->sampler_states
, &d3d_sampler_state_rb_ops
) == -1)
5226 WARN("Failed to initialize sampler state rbtree.\n");
5227 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
5228 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
5229 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);