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 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
117 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext
*iface
, REFGUID guid
,
118 UINT data_size
, const void *data
)
120 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
125 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext
*iface
,
126 REFGUID guid
, const IUnknown
*data
)
128 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
133 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext
*iface
,
134 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
136 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
139 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
140 iface
, start_slot
, buffer_count
, buffers
);
142 wined3d_mutex_lock();
143 for (i
= 0; i
< buffer_count
; ++i
)
145 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
147 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
148 buffer
? buffer
->wined3d_buffer
: NULL
);
150 wined3d_mutex_unlock();
153 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext
*iface
,
154 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
156 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
159 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
160 iface
, start_slot
, view_count
, views
);
162 wined3d_mutex_lock();
163 for (i
= 0; i
< view_count
; ++i
)
165 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
167 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
168 view
? view
->wined3d_view
: NULL
);
170 wined3d_mutex_unlock();
173 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetShader(ID3D11DeviceContext
*iface
,
174 ID3D11PixelShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
176 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
177 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D11PixelShader(shader
);
179 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
180 iface
, shader
, class_instances
, class_instance_count
);
183 FIXME("Dynamic linking is not implemented yet.\n");
185 wined3d_mutex_lock();
186 wined3d_device_set_pixel_shader(device
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
187 wined3d_mutex_unlock();
190 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext
*iface
,
191 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
193 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
196 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
197 iface
, start_slot
, sampler_count
, samplers
);
199 wined3d_mutex_lock();
200 for (i
= 0; i
< sampler_count
; ++i
)
202 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
204 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
205 sampler
? sampler
->wined3d_sampler
: NULL
);
207 wined3d_mutex_unlock();
210 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShader(ID3D11DeviceContext
*iface
,
211 ID3D11VertexShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
213 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
214 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D11VertexShader(shader
);
216 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
217 iface
, shader
, class_instances
, class_instance_count
);
220 FIXME("Dynamic linking is not implemented yet.\n");
222 wined3d_mutex_lock();
223 wined3d_device_set_vertex_shader(device
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
224 wined3d_mutex_unlock();
227 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext
*iface
,
228 UINT index_count
, UINT start_index_location
, INT base_vertex_location
)
230 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
232 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
233 iface
, index_count
, start_index_location
, base_vertex_location
);
235 wined3d_mutex_lock();
236 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
237 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, start_index_location
, index_count
);
238 wined3d_mutex_unlock();
241 static void STDMETHODCALLTYPE
d3d11_immediate_context_Draw(ID3D11DeviceContext
*iface
,
242 UINT vertex_count
, UINT start_vertex_location
)
244 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
246 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
247 iface
, vertex_count
, start_vertex_location
);
249 wined3d_mutex_lock();
250 wined3d_device_draw_primitive(device
->wined3d_device
, start_vertex_location
, vertex_count
);
251 wined3d_mutex_unlock();
254 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_Map(ID3D11DeviceContext
*iface
, ID3D11Resource
*resource
,
255 UINT subresource_idx
, D3D11_MAP map_type
, UINT map_flags
, D3D11_MAPPED_SUBRESOURCE
*mapped_subresource
)
257 struct wined3d_resource
*wined3d_resource
;
258 struct wined3d_map_desc map_desc
;
261 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
262 iface
, resource
, subresource_idx
, map_type
, map_flags
, mapped_subresource
);
265 FIXME("Ignoring map_flags %#x.\n", map_flags
);
267 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
269 wined3d_mutex_lock();
270 hr
= wined3d_resource_map(wined3d_resource
, subresource_idx
,
271 &map_desc
, NULL
, wined3d_map_flags_from_d3d11_map_type(map_type
));
272 wined3d_mutex_unlock();
274 mapped_subresource
->pData
= map_desc
.data
;
275 mapped_subresource
->RowPitch
= map_desc
.row_pitch
;
276 mapped_subresource
->DepthPitch
= map_desc
.slice_pitch
;
281 static void STDMETHODCALLTYPE
d3d11_immediate_context_Unmap(ID3D11DeviceContext
*iface
, ID3D11Resource
*resource
,
282 UINT subresource_idx
)
284 struct wined3d_resource
*wined3d_resource
;
286 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface
, resource
, subresource_idx
);
288 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
290 wined3d_mutex_lock();
291 wined3d_resource_unmap(wined3d_resource
, subresource_idx
);
292 wined3d_mutex_unlock();
295 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext
*iface
,
296 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
298 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
301 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
302 iface
, start_slot
, buffer_count
, buffers
);
304 wined3d_mutex_lock();
305 for (i
= 0; i
< buffer_count
; ++i
)
307 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
309 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
310 buffer
? buffer
->wined3d_buffer
: NULL
);
312 wined3d_mutex_unlock();
315 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext
*iface
,
316 ID3D11InputLayout
*input_layout
)
318 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
319 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D11InputLayout(input_layout
);
321 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
323 wined3d_mutex_lock();
324 wined3d_device_set_vertex_declaration(device
->wined3d_device
, layout
? layout
->wined3d_decl
: NULL
);
325 wined3d_mutex_unlock();
328 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext
*iface
,
329 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
331 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
334 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
335 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
337 wined3d_mutex_lock();
338 for (i
= 0; i
< buffer_count
; ++i
)
340 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
342 wined3d_device_set_stream_source(device
->wined3d_device
, start_slot
+ i
,
343 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
345 wined3d_mutex_unlock();
348 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext
*iface
,
349 ID3D11Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
351 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
352 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D11Buffer(buffer
);
354 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
355 iface
, buffer
, debug_dxgi_format(format
), offset
);
358 FIXME("offset %u not supported.\n", offset
);
360 wined3d_mutex_lock();
361 wined3d_device_set_index_buffer(device
->wined3d_device
,
362 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
363 wined3dformat_from_dxgi_format(format
));
364 wined3d_mutex_unlock();
367 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext
*iface
,
368 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
, INT base_vertex_location
,
369 UINT start_instance_location
)
371 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
373 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
374 "base_vertex_location %d, start_instance_location %u.\n",
375 iface
, instance_index_count
, instance_count
, start_index_location
,
376 base_vertex_location
, start_instance_location
);
378 wined3d_mutex_lock();
379 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
380 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
381 instance_index_count
, start_instance_location
, instance_count
);
382 wined3d_mutex_unlock();
385 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext
*iface
,
386 UINT instance_vertex_count
, UINT instance_count
, UINT start_vertex_location
, UINT start_instance_location
)
388 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
390 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
391 "start_instance_location %u.\n",
392 iface
, instance_vertex_count
, instance_count
, start_vertex_location
,
393 start_instance_location
);
395 wined3d_mutex_lock();
396 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
397 instance_vertex_count
, start_instance_location
, instance_count
);
398 wined3d_mutex_unlock();
401 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext
*iface
,
402 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
404 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
407 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
408 iface
, start_slot
, buffer_count
, buffers
);
410 wined3d_mutex_lock();
411 for (i
= 0; i
< buffer_count
; ++i
)
413 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
415 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
416 buffer
? buffer
->wined3d_buffer
: NULL
);
418 wined3d_mutex_unlock();
421 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShader(ID3D11DeviceContext
*iface
,
422 ID3D11GeometryShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
424 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
425 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D11GeometryShader(shader
);
427 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
428 iface
, shader
, class_instances
, class_instance_count
);
431 FIXME("Dynamic linking is not implemented yet.\n");
433 wined3d_mutex_lock();
434 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
435 wined3d_mutex_unlock();
438 static void STDMETHODCALLTYPE
d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext
*iface
,
439 D3D11_PRIMITIVE_TOPOLOGY topology
)
441 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
443 TRACE("iface %p, topology %u.\n", iface
, topology
);
445 wined3d_mutex_lock();
446 wined3d_device_set_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
447 wined3d_mutex_unlock();
450 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext
*iface
,
451 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
453 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
456 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
458 wined3d_mutex_lock();
459 for (i
= 0; i
< view_count
; ++i
)
461 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
463 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
464 view
? view
->wined3d_view
: NULL
);
466 wined3d_mutex_unlock();
469 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext
*iface
,
470 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
472 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
475 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
476 iface
, start_slot
, sampler_count
, samplers
);
478 wined3d_mutex_lock();
479 for (i
= 0; i
< sampler_count
; ++i
)
481 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
483 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
484 sampler
? sampler
->wined3d_sampler
: NULL
);
486 wined3d_mutex_unlock();
489 static void STDMETHODCALLTYPE
d3d11_immediate_context_Begin(ID3D11DeviceContext
*iface
,
490 ID3D11Asynchronous
*asynchronous
)
492 FIXME("iface %p, asynchronous %p stub!\n", iface
, asynchronous
);
495 static void STDMETHODCALLTYPE
d3d11_immediate_context_End(ID3D11DeviceContext
*iface
,
496 ID3D11Asynchronous
*asynchronous
)
498 FIXME("iface %p, asynchronous %p stub!\n", iface
, asynchronous
);
501 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_GetData(ID3D11DeviceContext
*iface
,
502 ID3D11Asynchronous
*asynchronous
, void *data
, UINT data_size
, UINT data_flags
)
504 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
505 iface
, asynchronous
, data
, data_size
, data_flags
);
510 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetPredication(ID3D11DeviceContext
*iface
,
511 ID3D11Predicate
*predicate
, BOOL value
)
513 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
514 struct d3d_query
*query
;
516 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
518 query
= unsafe_impl_from_ID3D11Query((ID3D11Query
*)predicate
);
520 wined3d_mutex_lock();
521 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
522 wined3d_mutex_unlock();
525 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext
*iface
,
526 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
528 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
531 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
533 wined3d_mutex_lock();
534 for (i
= 0; i
< view_count
; ++i
)
536 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D11ShaderResourceView(views
[i
]);
538 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
539 view
? view
->wined3d_view
: NULL
);
541 wined3d_mutex_unlock();
544 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext
*iface
,
545 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
547 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
550 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
551 iface
, start_slot
, sampler_count
, samplers
);
553 wined3d_mutex_lock();
554 for (i
= 0; i
< sampler_count
; ++i
)
556 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D11SamplerState(samplers
[i
]);
558 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
559 sampler
? sampler
->wined3d_sampler
: NULL
);
561 wined3d_mutex_unlock();
564 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext
*iface
,
565 UINT render_target_view_count
, ID3D11RenderTargetView
*const *render_target_views
,
566 ID3D11DepthStencilView
*depth_stencil_view
)
568 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
569 struct d3d_depthstencil_view
*dsv
;
572 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
573 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
575 wined3d_mutex_lock();
576 for (i
= 0; i
< render_target_view_count
; ++i
)
578 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D11RenderTargetView(render_target_views
[i
]);
579 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
581 for (; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
583 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
586 dsv
= unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view
);
587 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, dsv
? dsv
->wined3d_view
: NULL
);
588 wined3d_mutex_unlock();
591 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
592 ID3D11DeviceContext
*iface
, UINT render_target_view_count
,
593 ID3D11RenderTargetView
*const *render_target_views
, ID3D11DepthStencilView
*depth_stencil_view
,
594 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
595 ID3D11UnorderedAccessView
*const *unordered_access_views
, const UINT
*initial_counts
)
597 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
598 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
599 "initial_counts %p stub!\n",
600 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
601 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
,
605 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext
*iface
,
606 ID3D11BlendState
*blend_state
, const FLOAT blend_factor
[4], UINT sample_mask
)
608 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
609 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
610 const D3D11_BLEND_DESC
*desc
;
612 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask 0x%08x.\n",
613 iface
, blend_state
, blend_factor
, sample_mask
);
616 blend_factor
= default_blend_factor
;
618 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
619 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
620 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
622 wined3d_mutex_lock();
623 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
624 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
625 if (!(device
->blend_state
= unsafe_impl_from_ID3D11BlendState(blend_state
)))
627 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
628 wined3d_device_set_render_state(device
->wined3d_device
,
629 WINED3D_RS_COLORWRITEENABLE
, D3D11_COLOR_WRITE_ENABLE_ALL
);
630 wined3d_device_set_render_state(device
->wined3d_device
,
631 WINED3D_RS_COLORWRITEENABLE1
, D3D11_COLOR_WRITE_ENABLE_ALL
);
632 wined3d_device_set_render_state(device
->wined3d_device
,
633 WINED3D_RS_COLORWRITEENABLE2
, D3D11_COLOR_WRITE_ENABLE_ALL
);
634 wined3d_device_set_render_state(device
->wined3d_device
,
635 WINED3D_RS_COLORWRITEENABLE3
, D3D11_COLOR_WRITE_ENABLE_ALL
);
636 wined3d_mutex_unlock();
640 desc
= &device
->blend_state
->desc
;
641 /* glSampleCoverage() */
642 if (desc
->AlphaToCoverageEnable
)
643 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
644 /* glEnableIndexedEXT(GL_BLEND, ...) */
645 FIXME("Per-rendertarget blend not implemented.\n");
646 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
,
647 desc
->RenderTarget
[0].BlendEnable
);
648 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
, desc
->RenderTarget
[0].SrcBlend
);
649 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
, desc
->RenderTarget
[0].DestBlend
);
650 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
, desc
->RenderTarget
[0].BlendOp
);
651 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
652 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
,
653 desc
->RenderTarget
[0].SrcBlendAlpha
);
654 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
,
655 desc
->RenderTarget
[0].DestBlendAlpha
);
656 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
,
657 desc
->RenderTarget
[0].BlendOpAlpha
);
658 FIXME("Color mask > 3 not implemented.\n");
659 wined3d_device_set_render_state(device
->wined3d_device
,
660 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTarget
[0].RenderTargetWriteMask
);
661 wined3d_device_set_render_state(device
->wined3d_device
,
662 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTarget
[1].RenderTargetWriteMask
);
663 wined3d_device_set_render_state(device
->wined3d_device
,
664 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTarget
[2].RenderTargetWriteMask
);
665 wined3d_device_set_render_state(device
->wined3d_device
,
666 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTarget
[3].RenderTargetWriteMask
);
667 wined3d_mutex_unlock();
670 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext
*iface
,
671 ID3D11DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
673 FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n", iface
, depth_stencil_state
, stencil_ref
);
676 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext
*iface
, UINT buffer_count
,
677 ID3D11Buffer
*const *buffers
, const UINT
*offsets
)
679 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
680 unsigned int count
, i
;
682 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface
, buffer_count
, buffers
, offsets
);
684 count
= min(buffer_count
, D3D11_SO_BUFFER_SLOT_COUNT
);
685 wined3d_mutex_lock();
686 for (i
= 0; i
< count
; ++i
)
688 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D11Buffer(buffers
[i
]);
690 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
691 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
693 for (; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
695 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
697 wined3d_mutex_unlock();
700 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawAuto(ID3D11DeviceContext
*iface
)
702 FIXME("iface %p stub!\n", iface
);
705 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext
*iface
,
706 ID3D11Buffer
*buffer
, UINT offset
)
708 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
711 static void STDMETHODCALLTYPE
d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext
*iface
,
712 ID3D11Buffer
*buffer
, UINT offset
)
714 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
717 static void STDMETHODCALLTYPE
d3d11_immediate_context_Dispatch(ID3D11DeviceContext
*iface
,
718 UINT thread_group_count_x
, UINT thread_group_count_y
, UINT thread_group_count_z
)
720 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
721 iface
, thread_group_count_x
, thread_group_count_y
, thread_group_count_z
);
724 static void STDMETHODCALLTYPE
d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext
*iface
,
725 ID3D11Buffer
*buffer
, UINT offset
)
727 FIXME("iface %p, buffer %p, offset %u stub!\n", iface
, buffer
, offset
);
730 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetState(ID3D11DeviceContext
*iface
,
731 ID3D11RasterizerState
*rasterizer_state
)
733 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
734 const D3D11_RASTERIZER_DESC
*desc
;
736 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
738 wined3d_mutex_lock();
739 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D11RasterizerState(rasterizer_state
)))
741 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
742 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_CCW
);
743 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
744 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
745 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
746 wined3d_mutex_unlock();
750 desc
= &device
->rasterizer_state
->desc
;
751 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
752 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
754 if (desc
->FrontCounterClockwise
)
755 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc
->FrontCounterClockwise
);
756 /* OpenGL style depth bias. */
757 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
758 FIXME("Ignoring depth bias.\n");
760 if (!desc
->DepthClipEnable
)
761 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
762 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
763 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
764 wined3d_device_set_render_state(device
->wined3d_device
,
765 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
766 wined3d_mutex_unlock();
769 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext
*iface
,
770 UINT viewport_count
, const D3D11_VIEWPORT
*viewports
)
772 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
773 struct wined3d_viewport wined3d_vp
;
775 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
777 if (viewport_count
> 1)
778 FIXME("Multiple viewports not implemented.\n");
783 if (viewports
[0].TopLeftX
!= (UINT
)viewports
[0].TopLeftX
784 || viewports
[0].TopLeftY
!= (UINT
)viewports
[0].TopLeftY
785 || viewports
[0].Width
!= (UINT
)viewports
[0].Width
786 || viewports
[0].Height
!= (UINT
)viewports
[0].Height
)
787 FIXME("Floating-point viewports not implemented.\n");
789 wined3d_vp
.x
= viewports
[0].TopLeftX
;
790 wined3d_vp
.y
= viewports
[0].TopLeftY
;
791 wined3d_vp
.width
= viewports
[0].Width
;
792 wined3d_vp
.height
= viewports
[0].Height
;
793 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
794 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
796 wined3d_mutex_lock();
797 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
798 wined3d_mutex_unlock();
801 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext
*iface
,
802 UINT rect_count
, const D3D11_RECT
*rects
)
804 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
806 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
809 FIXME("Multiple scissor rects not implemented.\n");
814 wined3d_mutex_lock();
815 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
816 wined3d_mutex_unlock();
819 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext
*iface
,
820 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
821 ID3D11Resource
*src_resource
, UINT src_subresource_idx
, const D3D11_BOX
*src_box
)
823 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
824 "src_resource %p, src_subresource_idx %u, src_box %p stub!\n",
825 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
826 src_resource
, src_subresource_idx
, src_box
);
829 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyResource(ID3D11DeviceContext
*iface
,
830 ID3D11Resource
*dst_resource
, ID3D11Resource
*src_resource
)
832 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
833 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
835 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
837 wined3d_dst_resource
= wined3d_resource_from_d3d11_resource(dst_resource
);
838 wined3d_src_resource
= wined3d_resource_from_d3d11_resource(src_resource
);
839 wined3d_mutex_lock();
840 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
841 wined3d_mutex_unlock();
844 static void STDMETHODCALLTYPE
d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext
*iface
,
845 ID3D11Resource
*resource
, UINT subresource_idx
, const D3D11_BOX
*box
,
846 const void *data
, UINT row_pitch
, UINT depth_pitch
)
848 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
849 struct wined3d_resource
*wined3d_resource
;
850 struct wined3d_box wined3d_box
;
852 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
853 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
857 wined3d_box
.left
= box
->left
;
858 wined3d_box
.top
= box
->top
;
859 wined3d_box
.front
= box
->front
;
860 wined3d_box
.right
= box
->right
;
861 wined3d_box
.bottom
= box
->bottom
;
862 wined3d_box
.back
= box
->back
;
865 wined3d_resource
= wined3d_resource_from_d3d11_resource(resource
);
866 wined3d_mutex_lock();
867 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
868 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
869 wined3d_mutex_unlock();
872 static void STDMETHODCALLTYPE
d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext
*iface
,
873 ID3D11Buffer
*dst_buffer
, UINT dst_offset
, ID3D11UnorderedAccessView
*src_view
)
875 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
876 iface
, dst_buffer
, dst_offset
, src_view
);
879 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext
*iface
,
880 ID3D11RenderTargetView
*render_target_view
, const FLOAT color_rgba
[4])
882 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
883 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D11RenderTargetView(render_target_view
);
884 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
887 TRACE("iface %p, render_target_view %p, color_rgba {%.8e %.8e %.8e %.8e}.\n",
888 iface
, render_target_view
, color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]);
890 wined3d_mutex_lock();
891 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
, &color
)))
892 ERR("Failed to clear view, hr %#x.\n", hr
);
893 wined3d_mutex_unlock();
896 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext
*iface
,
897 ID3D11UnorderedAccessView
*unordered_access_view
, const UINT values
[4])
899 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
900 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
903 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext
*iface
,
904 ID3D11UnorderedAccessView
*unordered_access_view
, const FLOAT values
[4])
906 FIXME("iface %p, unordered_access_view %p, values {%.8e %.8e %.8e %.8e} stub!\n",
907 iface
, unordered_access_view
, values
[0], values
[1], values
[2], values
[3]);
910 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext
*iface
,
911 ID3D11DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
913 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
914 iface
, depth_stencil_view
, flags
, depth
, stencil
);
917 static void STDMETHODCALLTYPE
d3d11_immediate_context_GenerateMips(ID3D11DeviceContext
*iface
,
918 ID3D11ShaderResourceView
*view
)
920 FIXME("iface %p, view %p stub!\n", iface
, view
);
923 static void STDMETHODCALLTYPE
d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext
*iface
,
924 ID3D11Resource
*resource
, FLOAT min_lod
)
926 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface
, resource
, min_lod
);
929 static FLOAT STDMETHODCALLTYPE
d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext
*iface
,
930 ID3D11Resource
*resource
)
932 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
937 static void STDMETHODCALLTYPE
d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext
*iface
,
938 ID3D11Resource
*dst_resource
, UINT dst_subresource_idx
,
939 ID3D11Resource
*src_resource
, UINT src_subresource_idx
,
942 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
944 iface
, dst_resource
, dst_subresource_idx
, src_resource
, src_subresource_idx
,
945 debug_dxgi_format(format
));
948 static void STDMETHODCALLTYPE
d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext
*iface
,
949 ID3D11CommandList
*command_list
, BOOL restore_state
)
951 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface
, command_list
, restore_state
);
954 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext
*iface
,
955 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
957 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
958 iface
, start_slot
, view_count
, views
);
961 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetShader(ID3D11DeviceContext
*iface
,
962 ID3D11HullShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
964 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
965 iface
, shader
, class_instances
, class_instance_count
);
968 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext
*iface
,
969 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
971 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
972 iface
, start_slot
, sampler_count
, samplers
);
975 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext
*iface
,
976 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
978 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
979 iface
, start_slot
, buffer_count
, buffers
);
982 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext
*iface
,
983 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
985 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
986 iface
, start_slot
, view_count
, views
);
989 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetShader(ID3D11DeviceContext
*iface
,
990 ID3D11DomainShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
992 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
993 iface
, shader
, class_instances
, class_instance_count
);
996 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext
*iface
,
997 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
999 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1000 iface
, start_slot
, sampler_count
, samplers
);
1003 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1004 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1006 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1007 iface
, start_slot
, buffer_count
, buffers
);
1010 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext
*iface
,
1011 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
*const *views
)
1013 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1014 iface
, start_slot
, view_count
, views
);
1017 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1018 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
*const *views
, const UINT
*initial_counts
)
1020 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1021 iface
, start_slot
, view_count
, views
, initial_counts
);
1024 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetShader(ID3D11DeviceContext
*iface
,
1025 ID3D11ComputeShader
*shader
, ID3D11ClassInstance
*const *class_instances
, UINT class_instance_count
)
1027 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1028 iface
, shader
, class_instances
, class_instance_count
);
1031 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext
*iface
,
1032 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
*const *samplers
)
1034 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1035 iface
, start_slot
, sampler_count
, samplers
);
1038 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext
*iface
,
1039 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
*const *buffers
)
1041 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1042 iface
, start_slot
, buffer_count
, buffers
);
1045 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1046 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1048 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1051 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1052 iface
, start_slot
, buffer_count
, buffers
);
1054 wined3d_mutex_lock();
1055 for (i
= 0; i
< buffer_count
; ++i
)
1057 struct wined3d_buffer
*wined3d_buffer
;
1058 struct d3d_buffer
*buffer_impl
;
1060 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1066 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1067 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1068 ID3D11Buffer_AddRef(buffers
[i
]);
1070 wined3d_mutex_unlock();
1073 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext
*iface
,
1074 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1076 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1079 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1080 iface
, start_slot
, view_count
, views
);
1082 wined3d_mutex_lock();
1083 for (i
= 0; i
< view_count
; ++i
)
1085 struct wined3d_shader_resource_view
*wined3d_view
;
1086 struct d3d_shader_resource_view
*view_impl
;
1088 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1094 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1095 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1096 ID3D11ShaderResourceView_AddRef(views
[i
]);
1098 wined3d_mutex_unlock();
1101 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetShader(ID3D11DeviceContext
*iface
,
1102 ID3D11PixelShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1104 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1105 struct wined3d_shader
*wined3d_shader
;
1106 struct d3d_pixel_shader
*shader_impl
;
1108 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1109 iface
, shader
, class_instances
, class_instance_count
);
1111 if (class_instances
|| class_instance_count
)
1112 FIXME("Dynamic linking not implemented yet.\n");
1114 wined3d_mutex_lock();
1115 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1117 wined3d_mutex_unlock();
1122 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1123 wined3d_mutex_unlock();
1124 *shader
= &shader_impl
->ID3D11PixelShader_iface
;
1125 ID3D11PixelShader_AddRef(*shader
);
1128 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext
*iface
,
1129 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1131 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1134 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1135 iface
, start_slot
, sampler_count
, samplers
);
1137 wined3d_mutex_lock();
1138 for (i
= 0; i
< sampler_count
; ++i
)
1140 struct wined3d_sampler
*wined3d_sampler
;
1141 struct d3d_sampler_state
*sampler_impl
;
1143 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1149 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1150 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1151 ID3D11SamplerState_AddRef(samplers
[i
]);
1153 wined3d_mutex_unlock();
1156 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShader(ID3D11DeviceContext
*iface
,
1157 ID3D11VertexShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1159 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1160 struct d3d_vertex_shader
*shader_impl
;
1161 struct wined3d_shader
*wined3d_shader
;
1163 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1164 iface
, shader
, class_instances
, class_instance_count
);
1166 if (class_instances
|| class_instance_count
)
1167 FIXME("Dynamic linking not implemented yet.\n");
1169 wined3d_mutex_lock();
1170 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1172 wined3d_mutex_unlock();
1177 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1178 wined3d_mutex_unlock();
1179 *shader
= &shader_impl
->ID3D11VertexShader_iface
;
1180 ID3D11VertexShader_AddRef(*shader
);
1183 static void STDMETHODCALLTYPE
d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1184 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1186 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1189 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1190 iface
, start_slot
, buffer_count
, buffers
);
1192 wined3d_mutex_lock();
1193 for (i
= 0; i
< buffer_count
; ++i
)
1195 struct wined3d_buffer
*wined3d_buffer
;
1196 struct d3d_buffer
*buffer_impl
;
1198 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1204 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1205 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1206 ID3D11Buffer_AddRef(buffers
[i
]);
1208 wined3d_mutex_unlock();
1211 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext
*iface
,
1212 ID3D11InputLayout
**input_layout
)
1214 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1215 struct wined3d_vertex_declaration
*wined3d_declaration
;
1216 struct d3d_input_layout
*input_layout_impl
;
1218 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1220 wined3d_mutex_lock();
1221 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1223 wined3d_mutex_unlock();
1224 *input_layout
= NULL
;
1228 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1229 wined3d_mutex_unlock();
1230 *input_layout
= &input_layout_impl
->ID3D11InputLayout_iface
;
1231 ID3D11InputLayout_AddRef(*input_layout
);
1234 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext
*iface
,
1235 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1237 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1238 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1241 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext
*iface
,
1242 ID3D11Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1244 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface
, buffer
, format
, offset
);
1247 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1248 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1250 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1253 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1254 iface
, start_slot
, buffer_count
, buffers
);
1256 wined3d_mutex_lock();
1257 for (i
= 0; i
< buffer_count
; ++i
)
1259 struct wined3d_buffer
*wined3d_buffer
;
1260 struct d3d_buffer
*buffer_impl
;
1262 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1268 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1269 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1270 ID3D11Buffer_AddRef(buffers
[i
]);
1272 wined3d_mutex_unlock();
1275 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShader(ID3D11DeviceContext
*iface
,
1276 ID3D11GeometryShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1278 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1279 struct d3d_geometry_shader
*shader_impl
;
1280 struct wined3d_shader
*wined3d_shader
;
1282 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1283 iface
, shader
, class_instances
, class_instance_count
);
1285 if (class_instances
|| class_instance_count
)
1286 FIXME("Dynamic linking not implemented yet.\n");
1288 wined3d_mutex_lock();
1289 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1291 wined3d_mutex_unlock();
1296 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1297 wined3d_mutex_unlock();
1298 *shader
= &shader_impl
->ID3D11GeometryShader_iface
;
1299 ID3D11GeometryShader_AddRef(*shader
);
1302 static void STDMETHODCALLTYPE
d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext
*iface
,
1303 D3D11_PRIMITIVE_TOPOLOGY
*topology
)
1305 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1307 TRACE("iface %p, topology %p.\n", iface
, topology
);
1309 wined3d_mutex_lock();
1310 wined3d_device_get_primitive_type(device
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1311 wined3d_mutex_unlock();
1314 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext
*iface
,
1315 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1317 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1320 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1322 wined3d_mutex_lock();
1323 for (i
= 0; i
< view_count
; ++i
)
1325 struct wined3d_shader_resource_view
*wined3d_view
;
1326 struct d3d_shader_resource_view
*view_impl
;
1328 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1334 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1335 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1336 ID3D11ShaderResourceView_AddRef(views
[i
]);
1338 wined3d_mutex_unlock();
1341 static void STDMETHODCALLTYPE
d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext
*iface
,
1342 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1344 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1347 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1348 iface
, start_slot
, sampler_count
, samplers
);
1350 wined3d_mutex_lock();
1351 for (i
= 0; i
< sampler_count
; ++i
)
1353 struct wined3d_sampler
*wined3d_sampler
;
1354 struct d3d_sampler_state
*sampler_impl
;
1356 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1362 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1363 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1364 ID3D11SamplerState_AddRef(samplers
[i
]);
1366 wined3d_mutex_unlock();
1369 static void STDMETHODCALLTYPE
d3d11_immediate_context_GetPredication(ID3D11DeviceContext
*iface
,
1370 ID3D11Predicate
**predicate
, BOOL
*value
)
1372 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1373 struct wined3d_query
*wined3d_predicate
;
1374 struct d3d_query
*predicate_impl
;
1376 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1378 wined3d_mutex_lock();
1379 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1381 wined3d_mutex_unlock();
1386 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1387 wined3d_mutex_unlock();
1388 *predicate
= (ID3D11Predicate
*)&predicate_impl
->ID3D11Query_iface
;
1389 ID3D11Predicate_AddRef(*predicate
);
1392 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext
*iface
,
1393 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1395 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1398 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface
, start_slot
, view_count
, views
);
1400 wined3d_mutex_lock();
1401 for (i
= 0; i
< view_count
; ++i
)
1403 struct wined3d_shader_resource_view
*wined3d_view
;
1404 struct d3d_shader_resource_view
*view_impl
;
1406 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1412 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1413 views
[i
] = &view_impl
->ID3D11ShaderResourceView_iface
;
1414 ID3D11ShaderResourceView_AddRef(views
[i
]);
1416 wined3d_mutex_unlock();
1419 static void STDMETHODCALLTYPE
d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext
*iface
,
1420 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1422 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1425 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1426 iface
, start_slot
, sampler_count
, samplers
);
1428 wined3d_mutex_lock();
1429 for (i
= 0; i
< sampler_count
; ++i
)
1431 struct d3d_sampler_state
*sampler_impl
;
1432 struct wined3d_sampler
*wined3d_sampler
;
1434 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1440 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1441 samplers
[i
] = &sampler_impl
->ID3D11SamplerState_iface
;
1442 ID3D11SamplerState_AddRef(samplers
[i
]);
1444 wined3d_mutex_unlock();
1447 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext
*iface
,
1448 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1449 ID3D11DepthStencilView
**depth_stencil_view
)
1451 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1452 struct wined3d_rendertarget_view
*wined3d_view
;
1454 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1455 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
1457 wined3d_mutex_lock();
1458 if (render_target_views
)
1460 struct d3d_rendertarget_view
*view_impl
;
1463 for (i
= 0; i
< render_target_view_count
; ++i
)
1465 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1466 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1468 render_target_views
[i
] = NULL
;
1472 render_target_views
[i
] = &view_impl
->ID3D11RenderTargetView_iface
;
1473 ID3D11RenderTargetView_AddRef(render_target_views
[i
]);
1477 if (depth_stencil_view
)
1479 struct d3d_depthstencil_view
*view_impl
;
1481 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1482 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1484 *depth_stencil_view
= NULL
;
1488 *depth_stencil_view
= &view_impl
->ID3D11DepthStencilView_iface
;
1489 ID3D11DepthStencilView_AddRef(*depth_stencil_view
);
1492 wined3d_mutex_unlock();
1495 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1496 ID3D11DeviceContext
*iface
,
1497 UINT render_target_view_count
, ID3D11RenderTargetView
**render_target_views
,
1498 ID3D11DepthStencilView
**depth_stencil_view
,
1499 UINT unordered_access_view_start_slot
, UINT unordered_access_view_count
,
1500 ID3D11UnorderedAccessView
**unordered_access_views
)
1502 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1503 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1504 "unordered_access_views %p stub!\n",
1505 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
,
1506 unordered_access_view_start_slot
, unordered_access_view_count
, unordered_access_views
);
1509 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext
*iface
,
1510 ID3D11BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1512 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1513 iface
, blend_state
, blend_factor
, sample_mask
);
1516 static void STDMETHODCALLTYPE
d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext
*iface
,
1517 ID3D11DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1519 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface
, depth_stencil_state
, stencil_ref
);
1522 static void STDMETHODCALLTYPE
d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext
*iface
,
1523 UINT buffer_count
, ID3D11Buffer
**buffers
)
1525 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1528 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface
, buffer_count
, buffers
);
1530 wined3d_mutex_lock();
1531 for (i
= 0; i
< buffer_count
; ++i
)
1533 struct wined3d_buffer
*wined3d_buffer
;
1534 struct d3d_buffer
*buffer_impl
;
1536 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, NULL
)))
1542 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1543 buffers
[i
] = &buffer_impl
->ID3D11Buffer_iface
;
1544 ID3D11Buffer_AddRef(buffers
[i
]);
1546 wined3d_mutex_unlock();
1549 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetState(ID3D11DeviceContext
*iface
,
1550 ID3D11RasterizerState
**rasterizer_state
)
1552 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1554 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1556 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D11RasterizerState_iface
: NULL
))
1557 ID3D11RasterizerState_AddRef(*rasterizer_state
);
1560 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext
*iface
,
1561 UINT
*viewport_count
, D3D11_VIEWPORT
*viewports
)
1563 struct d3d_device
*device
= device_from_immediate_ID3D11DeviceContext(iface
);
1564 struct wined3d_viewport wined3d_vp
;
1566 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1570 *viewport_count
= 1;
1574 if (!*viewport_count
)
1577 wined3d_mutex_lock();
1578 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1579 wined3d_mutex_unlock();
1581 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1582 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1583 viewports
[0].Width
= wined3d_vp
.width
;
1584 viewports
[0].Height
= wined3d_vp
.height
;
1585 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1586 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1588 if (*viewport_count
> 1)
1589 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1592 static void STDMETHODCALLTYPE
d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext
*iface
,
1593 UINT
*rect_count
, D3D11_RECT
*rects
)
1595 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface
, rect_count
, rects
);
1598 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext
*iface
,
1599 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1601 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1604 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetShader(ID3D11DeviceContext
*iface
,
1605 ID3D11HullShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1607 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1608 iface
, shader
, class_instances
, class_instance_count
);
1611 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext
*iface
,
1612 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1614 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1615 iface
, start_slot
, sampler_count
, samplers
);
1618 static void STDMETHODCALLTYPE
d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1619 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1621 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1622 iface
, start_slot
, buffer_count
, buffers
);
1625 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext
*iface
,
1626 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1628 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1629 iface
, start_slot
, view_count
, views
);
1632 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetShader(ID3D11DeviceContext
*iface
,
1633 ID3D11DomainShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1635 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1636 iface
, shader
, class_instances
, class_instance_count
);
1639 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext
*iface
,
1640 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1642 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1643 iface
, start_slot
, sampler_count
, samplers
);
1646 static void STDMETHODCALLTYPE
d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1647 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1649 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1650 iface
, start_slot
, buffer_count
, buffers
);
1653 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext
*iface
,
1654 UINT start_slot
, UINT view_count
, ID3D11ShaderResourceView
**views
)
1656 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1659 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext
*iface
,
1660 UINT start_slot
, UINT view_count
, ID3D11UnorderedAccessView
**views
)
1662 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface
, start_slot
, view_count
, views
);
1665 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetShader(ID3D11DeviceContext
*iface
,
1666 ID3D11ComputeShader
**shader
, ID3D11ClassInstance
**class_instances
, UINT
*class_instance_count
)
1668 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1669 iface
, shader
, class_instances
, class_instance_count
);
1672 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext
*iface
,
1673 UINT start_slot
, UINT sampler_count
, ID3D11SamplerState
**samplers
)
1675 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1676 iface
, start_slot
, sampler_count
, samplers
);
1679 static void STDMETHODCALLTYPE
d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext
*iface
,
1680 UINT start_slot
, UINT buffer_count
, ID3D11Buffer
**buffers
)
1682 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1683 iface
, start_slot
, buffer_count
, buffers
);
1686 static void STDMETHODCALLTYPE
d3d11_immediate_context_ClearState(ID3D11DeviceContext
*iface
)
1688 FIXME("iface %p stub!\n", iface
);
1691 static void STDMETHODCALLTYPE
d3d11_immediate_context_Flush(ID3D11DeviceContext
*iface
)
1693 FIXME("iface %p stub!\n", iface
);
1696 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE
d3d11_immediate_context_GetType(ID3D11DeviceContext
*iface
)
1698 TRACE("iface %p.\n", iface
);
1700 return D3D11_DEVICE_CONTEXT_IMMEDIATE
;
1703 static UINT STDMETHODCALLTYPE
d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext
*iface
)
1705 FIXME("iface %p stub!\n", iface
);
1710 static HRESULT STDMETHODCALLTYPE
d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext
*iface
,
1711 BOOL restore
, ID3D11CommandList
**command_list
)
1713 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface
, restore
, command_list
);
1718 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl
=
1720 /* IUnknown methods */
1721 d3d11_immediate_context_QueryInterface
,
1722 d3d11_immediate_context_AddRef
,
1723 d3d11_immediate_context_Release
,
1724 /* ID3D11DeviceChild methods */
1725 d3d11_immediate_context_GetDevice
,
1726 d3d11_immediate_context_GetPrivateData
,
1727 d3d11_immediate_context_SetPrivateData
,
1728 d3d11_immediate_context_SetPrivateDataInterface
,
1729 /* ID3D11DeviceContext methods */
1730 d3d11_immediate_context_VSSetConstantBuffers
,
1731 d3d11_immediate_context_PSSetShaderResources
,
1732 d3d11_immediate_context_PSSetShader
,
1733 d3d11_immediate_context_PSSetSamplers
,
1734 d3d11_immediate_context_VSSetShader
,
1735 d3d11_immediate_context_DrawIndexed
,
1736 d3d11_immediate_context_Draw
,
1737 d3d11_immediate_context_Map
,
1738 d3d11_immediate_context_Unmap
,
1739 d3d11_immediate_context_PSSetConstantBuffers
,
1740 d3d11_immediate_context_IASetInputLayout
,
1741 d3d11_immediate_context_IASetVertexBuffers
,
1742 d3d11_immediate_context_IASetIndexBuffer
,
1743 d3d11_immediate_context_DrawIndexedInstanced
,
1744 d3d11_immediate_context_DrawInstanced
,
1745 d3d11_immediate_context_GSSetConstantBuffers
,
1746 d3d11_immediate_context_GSSetShader
,
1747 d3d11_immediate_context_IASetPrimitiveTopology
,
1748 d3d11_immediate_context_VSSetShaderResources
,
1749 d3d11_immediate_context_VSSetSamplers
,
1750 d3d11_immediate_context_Begin
,
1751 d3d11_immediate_context_End
,
1752 d3d11_immediate_context_GetData
,
1753 d3d11_immediate_context_SetPredication
,
1754 d3d11_immediate_context_GSSetShaderResources
,
1755 d3d11_immediate_context_GSSetSamplers
,
1756 d3d11_immediate_context_OMSetRenderTargets
,
1757 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews
,
1758 d3d11_immediate_context_OMSetBlendState
,
1759 d3d11_immediate_context_OMSetDepthStencilState
,
1760 d3d11_immediate_context_SOSetTargets
,
1761 d3d11_immediate_context_DrawAuto
,
1762 d3d11_immediate_context_DrawIndexedInstancedIndirect
,
1763 d3d11_immediate_context_DrawInstancedIndirect
,
1764 d3d11_immediate_context_Dispatch
,
1765 d3d11_immediate_context_DispatchIndirect
,
1766 d3d11_immediate_context_RSSetState
,
1767 d3d11_immediate_context_RSSetViewports
,
1768 d3d11_immediate_context_RSSetScissorRects
,
1769 d3d11_immediate_context_CopySubresourceRegion
,
1770 d3d11_immediate_context_CopyResource
,
1771 d3d11_immediate_context_UpdateSubresource
,
1772 d3d11_immediate_context_CopyStructureCount
,
1773 d3d11_immediate_context_ClearRenderTargetView
,
1774 d3d11_immediate_context_ClearUnorderedAccessViewUint
,
1775 d3d11_immediate_context_ClearUnorderedAccessViewFloat
,
1776 d3d11_immediate_context_ClearDepthStencilView
,
1777 d3d11_immediate_context_GenerateMips
,
1778 d3d11_immediate_context_SetResourceMinLOD
,
1779 d3d11_immediate_context_GetResourceMinLOD
,
1780 d3d11_immediate_context_ResolveSubresource
,
1781 d3d11_immediate_context_ExecuteCommandList
,
1782 d3d11_immediate_context_HSSetShaderResources
,
1783 d3d11_immediate_context_HSSetShader
,
1784 d3d11_immediate_context_HSSetSamplers
,
1785 d3d11_immediate_context_HSSetConstantBuffers
,
1786 d3d11_immediate_context_DSSetShaderResources
,
1787 d3d11_immediate_context_DSSetShader
,
1788 d3d11_immediate_context_DSSetSamplers
,
1789 d3d11_immediate_context_DSSetConstantBuffers
,
1790 d3d11_immediate_context_CSSetShaderResources
,
1791 d3d11_immediate_context_CSSetUnorderedAccessViews
,
1792 d3d11_immediate_context_CSSetShader
,
1793 d3d11_immediate_context_CSSetSamplers
,
1794 d3d11_immediate_context_CSSetConstantBuffers
,
1795 d3d11_immediate_context_VSGetConstantBuffers
,
1796 d3d11_immediate_context_PSGetShaderResources
,
1797 d3d11_immediate_context_PSGetShader
,
1798 d3d11_immediate_context_PSGetSamplers
,
1799 d3d11_immediate_context_VSGetShader
,
1800 d3d11_immediate_context_PSGetConstantBuffers
,
1801 d3d11_immediate_context_IAGetInputLayout
,
1802 d3d11_immediate_context_IAGetVertexBuffers
,
1803 d3d11_immediate_context_IAGetIndexBuffer
,
1804 d3d11_immediate_context_GSGetConstantBuffers
,
1805 d3d11_immediate_context_GSGetShader
,
1806 d3d11_immediate_context_IAGetPrimitiveTopology
,
1807 d3d11_immediate_context_VSGetShaderResources
,
1808 d3d11_immediate_context_VSGetSamplers
,
1809 d3d11_immediate_context_GetPredication
,
1810 d3d11_immediate_context_GSGetShaderResources
,
1811 d3d11_immediate_context_GSGetSamplers
,
1812 d3d11_immediate_context_OMGetRenderTargets
,
1813 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews
,
1814 d3d11_immediate_context_OMGetBlendState
,
1815 d3d11_immediate_context_OMGetDepthStencilState
,
1816 d3d11_immediate_context_SOGetTargets
,
1817 d3d11_immediate_context_RSGetState
,
1818 d3d11_immediate_context_RSGetViewports
,
1819 d3d11_immediate_context_RSGetScissorRects
,
1820 d3d11_immediate_context_HSGetShaderResources
,
1821 d3d11_immediate_context_HSGetShader
,
1822 d3d11_immediate_context_HSGetSamplers
,
1823 d3d11_immediate_context_HSGetConstantBuffers
,
1824 d3d11_immediate_context_DSGetShaderResources
,
1825 d3d11_immediate_context_DSGetShader
,
1826 d3d11_immediate_context_DSGetSamplers
,
1827 d3d11_immediate_context_DSGetConstantBuffers
,
1828 d3d11_immediate_context_CSGetShaderResources
,
1829 d3d11_immediate_context_CSGetUnorderedAccessViews
,
1830 d3d11_immediate_context_CSGetShader
,
1831 d3d11_immediate_context_CSGetSamplers
,
1832 d3d11_immediate_context_CSGetConstantBuffers
,
1833 d3d11_immediate_context_ClearState
,
1834 d3d11_immediate_context_Flush
,
1835 d3d11_immediate_context_GetType
,
1836 d3d11_immediate_context_GetContextFlags
,
1837 d3d11_immediate_context_FinishCommandList
,
1840 static HRESULT
d3d11_immediate_context_init(struct d3d11_immediate_context
*context
, struct d3d_device
*device
)
1842 context
->ID3D11DeviceContext_iface
.lpVtbl
= &d3d11_immediate_context_vtbl
;
1843 context
->refcount
= 1;
1845 ID3D11Device_AddRef(&device
->ID3D11Device_iface
);
1850 /* ID3D11Device methods */
1852 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
1854 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1855 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
1858 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
1860 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1861 return IUnknown_AddRef(device
->outer_unk
);
1864 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
1866 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1867 return IUnknown_Release(device
->outer_unk
);
1870 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
1871 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
1873 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1874 struct d3d_buffer
*object
;
1877 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
1879 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
1882 *buffer
= &object
->ID3D11Buffer_iface
;
1887 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
1888 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
1890 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
1895 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
1896 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
1898 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1899 struct d3d_texture2d
*object
;
1902 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
1904 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
1907 *texture
= &object
->ID3D11Texture2D_iface
;
1912 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
1913 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
1915 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1916 struct d3d_texture3d
*object
;
1919 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
1921 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
1924 *texture
= &object
->ID3D11Texture3D_iface
;
1929 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
1930 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
1932 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1933 struct d3d_shader_resource_view
*object
;
1936 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
1938 if (FAILED(hr
= d3d_shader_resource_view_create(device
, resource
, desc
, &object
)))
1941 *view
= &object
->ID3D11ShaderResourceView_iface
;
1946 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
1947 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
1949 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
1954 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
1955 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
1957 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1958 struct d3d_rendertarget_view
*object
;
1961 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
1963 if (FAILED(hr
= d3d_rendertarget_view_create(device
, resource
, desc
, &object
)))
1966 *view
= &object
->ID3D11RenderTargetView_iface
;
1971 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
1972 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
1974 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1975 struct d3d_depthstencil_view
*object
;
1978 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
1980 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
1983 *view
= &object
->ID3D11DepthStencilView_iface
;
1988 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
1989 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
1990 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
1992 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
1993 struct d3d_input_layout
*object
;
1996 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
1997 "input_layout %p.\n", iface
, element_descs
, element_count
, shader_byte_code
,
1998 shader_byte_code_length
, input_layout
);
2000 if (FAILED(hr
= d3d_input_layout_create(device
, element_descs
, element_count
,
2001 shader_byte_code
, shader_byte_code_length
, &object
)))
2004 *input_layout
= &object
->ID3D11InputLayout_iface
;
2009 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
2010 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
2012 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2013 struct d3d_vertex_shader
*object
;
2016 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2017 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2020 FIXME("Class linkage is not implemented yet.\n");
2022 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2025 *shader
= &object
->ID3D11VertexShader_iface
;
2030 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
2031 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2033 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2034 struct d3d_geometry_shader
*object
;
2037 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2038 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2041 FIXME("Class linkage is not implemented yet.\n");
2043 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2046 *shader
= &object
->ID3D11GeometryShader_iface
;
2051 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
2052 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
2053 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
2054 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
2056 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2057 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2058 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
2059 rasterized_stream
, class_linkage
, shader
);
2064 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
2065 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
2067 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2068 struct d3d_pixel_shader
*object
;
2071 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2072 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2075 FIXME("Class linkage is not implemented yet.\n");
2077 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
2080 *shader
= &object
->ID3D11PixelShader_iface
;
2085 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
2086 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
2088 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2089 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2094 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
2095 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
2097 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2098 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2103 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
2104 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
2106 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2107 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
2112 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
2113 ID3D11ClassLinkage
**class_linkage
)
2115 FIXME("iface %p, class_linkage %p stub!\n", iface
, class_linkage
);
2120 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
2121 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
2123 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2124 struct d3d_blend_state
*object
;
2125 struct wine_rb_entry
*entry
;
2126 D3D11_BLEND_DESC tmp_desc
;
2130 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2133 return E_INVALIDARG
;
2135 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2136 * D3D11_BLEND_DESC as a key in the rbtree. */
2137 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2138 tmp_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
2139 tmp_desc
.IndependentBlendEnable
= desc
->IndependentBlendEnable
;
2140 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2142 j
= desc
->IndependentBlendEnable
? i
: 0;
2143 tmp_desc
.RenderTarget
[i
].BlendEnable
= desc
->RenderTarget
[j
].BlendEnable
;
2144 tmp_desc
.RenderTarget
[i
].SrcBlend
= desc
->RenderTarget
[j
].SrcBlend
;
2145 tmp_desc
.RenderTarget
[i
].DestBlend
= desc
->RenderTarget
[j
].DestBlend
;
2146 tmp_desc
.RenderTarget
[i
].BlendOp
= desc
->RenderTarget
[j
].BlendOp
;
2147 tmp_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->RenderTarget
[j
].SrcBlendAlpha
;
2148 tmp_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->RenderTarget
[j
].DestBlendAlpha
;
2149 tmp_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->RenderTarget
[j
].BlendOpAlpha
;
2150 tmp_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTarget
[j
].RenderTargetWriteMask
;
2153 wined3d_mutex_lock();
2154 if ((entry
= wine_rb_get(&device
->blend_states
, &tmp_desc
)))
2156 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_blend_state
, entry
);
2158 TRACE("Returning existing blend state %p.\n", object
);
2159 *blend_state
= &object
->ID3D11BlendState_iface
;
2160 ID3D11BlendState_AddRef(*blend_state
);
2161 wined3d_mutex_unlock();
2165 wined3d_mutex_unlock();
2167 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2168 return E_OUTOFMEMORY
;
2170 if (FAILED(hr
= d3d_blend_state_init(object
, device
, &tmp_desc
)))
2172 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2173 HeapFree(GetProcessHeap(), 0, object
);
2177 TRACE("Created blend state %p.\n", object
);
2178 *blend_state
= &object
->ID3D11BlendState_iface
;
2183 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
2184 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
2186 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2187 struct d3d_depthstencil_state
*object
;
2188 D3D11_DEPTH_STENCIL_DESC tmp_desc
;
2189 struct wine_rb_entry
*entry
;
2192 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2195 return E_INVALIDARG
;
2197 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2198 * it as a key in the rbtree. */
2199 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2200 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2201 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2202 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2203 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2204 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2205 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2206 tmp_desc
.FrontFace
= desc
->FrontFace
;
2207 tmp_desc
.BackFace
= desc
->BackFace
;
2209 wined3d_mutex_lock();
2210 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2212 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_depthstencil_state
, entry
);
2214 TRACE("Returning existing depthstencil state %p.\n", object
);
2215 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2216 ID3D11DepthStencilState_AddRef(*depth_stencil_state
);
2217 wined3d_mutex_unlock();
2221 wined3d_mutex_unlock();
2223 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2224 return E_OUTOFMEMORY
;
2226 if (FAILED(hr
= d3d_depthstencil_state_init(object
, device
, &tmp_desc
)))
2228 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2229 HeapFree(GetProcessHeap(), 0, object
);
2233 TRACE("Created depthstencil state %p.\n", object
);
2234 *depth_stencil_state
= &object
->ID3D11DepthStencilState_iface
;
2239 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
2240 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
2242 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2243 struct d3d_rasterizer_state
*object
;
2244 struct wine_rb_entry
*entry
;
2247 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2250 return E_INVALIDARG
;
2252 wined3d_mutex_lock();
2253 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2255 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_rasterizer_state
, entry
);
2257 TRACE("Returning existing rasterizer state %p.\n", object
);
2258 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2259 ID3D11RasterizerState_AddRef(*rasterizer_state
);
2260 wined3d_mutex_unlock();
2264 wined3d_mutex_unlock();
2266 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2267 return E_OUTOFMEMORY
;
2269 if (FAILED(hr
= d3d_rasterizer_state_init(object
, device
, desc
)))
2271 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2272 HeapFree(GetProcessHeap(), 0, object
);
2276 TRACE("Created rasterizer state %p.\n", object
);
2277 *rasterizer_state
= &object
->ID3D11RasterizerState_iface
;
2282 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
2283 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
2285 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2286 D3D11_SAMPLER_DESC normalized_desc
;
2287 struct d3d_sampler_state
*object
;
2288 struct wine_rb_entry
*entry
;
2291 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2294 return E_INVALIDARG
;
2296 normalized_desc
= *desc
;
2297 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc
.Filter
))
2298 normalized_desc
.MaxAnisotropy
= 0;
2299 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc
.Filter
))
2300 normalized_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
2301 if (normalized_desc
.AddressU
!= D3D11_TEXTURE_ADDRESS_BORDER
2302 && normalized_desc
.AddressV
!= D3D11_TEXTURE_ADDRESS_BORDER
2303 && normalized_desc
.AddressW
!= D3D11_TEXTURE_ADDRESS_BORDER
)
2304 memset(&normalized_desc
.BorderColor
, 0, sizeof(normalized_desc
.BorderColor
));
2306 wined3d_mutex_lock();
2307 if ((entry
= wine_rb_get(&device
->sampler_states
, &normalized_desc
)))
2309 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d_sampler_state
, entry
);
2311 TRACE("Returning existing sampler state %p.\n", object
);
2312 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2313 ID3D11SamplerState_AddRef(*sampler_state
);
2314 wined3d_mutex_unlock();
2318 wined3d_mutex_unlock();
2320 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2321 return E_OUTOFMEMORY
;
2323 if (FAILED(hr
= d3d_sampler_state_init(object
, device
, &normalized_desc
)))
2325 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2326 HeapFree(GetProcessHeap(), 0, object
);
2330 TRACE("Created sampler state %p.\n", object
);
2331 *sampler_state
= &object
->ID3D11SamplerState_iface
;
2336 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
2337 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
2339 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2340 struct d3d_query
*object
;
2343 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2345 if (FAILED(hr
= d3d_query_create(device
, desc
, FALSE
, &object
)))
2348 *query
= &object
->ID3D11Query_iface
;
2353 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
2354 ID3D11Predicate
**predicate
)
2356 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2357 struct d3d_query
*object
;
2360 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2362 if (FAILED(hr
= d3d_query_create(device
, desc
, TRUE
, &object
)))
2365 *predicate
= (ID3D11Predicate
*)&object
->ID3D11Query_iface
;
2370 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2371 ID3D11Counter
**counter
)
2373 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2378 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
2379 ID3D11DeviceContext
**context
)
2381 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
2386 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
2389 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
2394 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
2395 UINT
*format_support
)
2397 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
2402 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
2403 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2405 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
2406 iface
, format
, sample_count
, quality_level_count
);
2411 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
2413 FIXME("iface %p, info %p stub!\n", iface
, info
);
2416 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
2417 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
2418 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2420 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2421 "units %p, units_length %p, description %p, description_length %p stub!\n",
2422 iface
, desc
, type
, active_counter_count
, name
, name_length
,
2423 units
, units_length
, description
, description_length
);
2428 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
2429 void *feature_support_data
, UINT feature_support_data_size
)
2431 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2432 iface
, feature
, feature_support_data
, feature_support_data_size
);
2437 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2438 UINT
*data_size
, void *data
)
2440 IDXGIDevice
*dxgi_device
;
2443 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2445 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2447 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
2448 IDXGIDevice_Release(dxgi_device
);
2453 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
2454 UINT data_size
, const void *data
)
2456 IDXGIDevice
*dxgi_device
;
2459 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
2461 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2463 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
2464 IDXGIDevice_Release(dxgi_device
);
2469 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
2470 const IUnknown
*data
)
2472 IDXGIDevice
*dxgi_device
;
2475 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
2477 if (FAILED(hr
= ID3D11Device_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
2479 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
2480 IDXGIDevice_Release(dxgi_device
);
2485 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
2487 FIXME("iface %p stub!\n", iface
);
2489 return D3D_FEATURE_LEVEL_10_0
;
2492 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
2494 FIXME("iface %p stub!\n", iface
);
2499 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
2501 FIXME("iface %p stub!\n", iface
);
2506 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
2507 ID3D11DeviceContext
**immediate_context
)
2509 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
2511 TRACE("iface %p, immediate_context %p.\n", iface
, immediate_context
);
2513 *immediate_context
= &device
->immediate_context
.ID3D11DeviceContext_iface
;
2514 ID3D11DeviceContext_AddRef(*immediate_context
);
2517 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
2519 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2524 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
2526 FIXME("iface %p stub!\n", iface
);
2531 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
2533 /* IUnknown methods */
2534 d3d11_device_QueryInterface
,
2535 d3d11_device_AddRef
,
2536 d3d11_device_Release
,
2537 /* ID3D11Device methods */
2538 d3d11_device_CreateBuffer
,
2539 d3d11_device_CreateTexture1D
,
2540 d3d11_device_CreateTexture2D
,
2541 d3d11_device_CreateTexture3D
,
2542 d3d11_device_CreateShaderResourceView
,
2543 d3d11_device_CreateUnorderedAccessView
,
2544 d3d11_device_CreateRenderTargetView
,
2545 d3d11_device_CreateDepthStencilView
,
2546 d3d11_device_CreateInputLayout
,
2547 d3d11_device_CreateVertexShader
,
2548 d3d11_device_CreateGeometryShader
,
2549 d3d11_device_CreateGeometryShaderWithStreamOutput
,
2550 d3d11_device_CreatePixelShader
,
2551 d3d11_device_CreateHullShader
,
2552 d3d11_device_CreateDomainShader
,
2553 d3d11_device_CreateComputeShader
,
2554 d3d11_device_CreateClassLinkage
,
2555 d3d11_device_CreateBlendState
,
2556 d3d11_device_CreateDepthStencilState
,
2557 d3d11_device_CreateRasterizerState
,
2558 d3d11_device_CreateSamplerState
,
2559 d3d11_device_CreateQuery
,
2560 d3d11_device_CreatePredicate
,
2561 d3d11_device_CreateCounter
,
2562 d3d11_device_CreateDeferredContext
,
2563 d3d11_device_OpenSharedResource
,
2564 d3d11_device_CheckFormatSupport
,
2565 d3d11_device_CheckMultisampleQualityLevels
,
2566 d3d11_device_CheckCounterInfo
,
2567 d3d11_device_CheckCounter
,
2568 d3d11_device_CheckFeatureSupport
,
2569 d3d11_device_GetPrivateData
,
2570 d3d11_device_SetPrivateData
,
2571 d3d11_device_SetPrivateDataInterface
,
2572 d3d11_device_GetFeatureLevel
,
2573 d3d11_device_GetCreationFlags
,
2574 d3d11_device_GetDeviceRemovedReason
,
2575 d3d11_device_GetImmediateContext
,
2576 d3d11_device_SetExceptionMode
,
2577 d3d11_device_GetExceptionMode
,
2580 /* Inner IUnknown methods */
2582 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
2584 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
2587 static HRESULT STDMETHODCALLTYPE
d3d_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
2589 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2591 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
2593 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
2594 || IsEqualGUID(riid
, &IID_IUnknown
))
2596 *out
= &device
->ID3D11Device_iface
;
2598 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
2599 || IsEqualGUID(riid
, &IID_ID3D10Device
))
2601 *out
= &device
->ID3D10Device1_iface
;
2603 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
2605 *out
= &device
->ID3D10Multithread_iface
;
2607 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
2609 *out
= &device
->IWineDXGIDeviceParent_iface
;
2613 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
2615 return E_NOINTERFACE
;
2618 IUnknown_AddRef((IUnknown
*)*out
);
2622 static ULONG STDMETHODCALLTYPE
d3d_device_inner_AddRef(IUnknown
*iface
)
2624 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2625 ULONG refcount
= InterlockedIncrement(&device
->refcount
);
2627 TRACE("%p increasing refcount to %u.\n", device
, refcount
);
2632 static ULONG STDMETHODCALLTYPE
d3d_device_inner_Release(IUnknown
*iface
)
2634 struct d3d_device
*device
= impl_from_IUnknown(iface
);
2635 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
2637 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
2641 if (device
->wined3d_device
)
2643 wined3d_mutex_lock();
2644 wined3d_device_decref(device
->wined3d_device
);
2645 wined3d_mutex_unlock();
2647 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
2648 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
2649 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
2650 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
2656 /* IUnknown methods */
2658 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
2661 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2662 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
2665 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
2667 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2668 return IUnknown_AddRef(This
->outer_unk
);
2671 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
2673 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2674 return IUnknown_Release(This
->outer_unk
);
2677 /* ID3D10Device methods */
2679 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
2680 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2682 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2685 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2686 iface
, start_slot
, buffer_count
, buffers
);
2688 wined3d_mutex_lock();
2689 for (i
= 0; i
< buffer_count
; ++i
)
2691 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2693 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
2694 buffer
? buffer
->wined3d_buffer
: NULL
);
2696 wined3d_mutex_unlock();
2699 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
2700 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
2702 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2705 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2706 iface
, start_slot
, view_count
, views
);
2708 wined3d_mutex_lock();
2709 for (i
= 0; i
< view_count
; ++i
)
2711 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
2713 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
2714 view
? view
->wined3d_view
: NULL
);
2716 wined3d_mutex_unlock();
2719 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
2720 ID3D10PixelShader
*shader
)
2722 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2723 struct d3d_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
2725 TRACE("iface %p, shader %p\n", iface
, shader
);
2727 wined3d_mutex_lock();
2728 wined3d_device_set_pixel_shader(This
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
2729 wined3d_mutex_unlock();
2732 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
2733 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
2735 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2738 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2739 iface
, start_slot
, sampler_count
, samplers
);
2741 wined3d_mutex_lock();
2742 for (i
= 0; i
< sampler_count
; ++i
)
2744 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
2746 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
2747 sampler
? sampler
->wined3d_sampler
: NULL
);
2749 wined3d_mutex_unlock();
2752 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
2753 ID3D10VertexShader
*shader
)
2755 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2756 struct d3d_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
2758 TRACE("iface %p, shader %p\n", iface
, shader
);
2760 wined3d_mutex_lock();
2761 wined3d_device_set_vertex_shader(This
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
2762 wined3d_mutex_unlock();
2765 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
2766 UINT start_index_location
, INT base_vertex_location
)
2768 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2770 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2771 iface
, index_count
, start_index_location
, base_vertex_location
);
2773 wined3d_mutex_lock();
2774 wined3d_device_set_base_vertex_index(This
->wined3d_device
, base_vertex_location
);
2775 wined3d_device_draw_indexed_primitive(This
->wined3d_device
, start_index_location
, index_count
);
2776 wined3d_mutex_unlock();
2779 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
2780 UINT start_vertex_location
)
2782 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2784 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2785 iface
, vertex_count
, start_vertex_location
);
2787 wined3d_mutex_lock();
2788 wined3d_device_draw_primitive(This
->wined3d_device
, start_vertex_location
, vertex_count
);
2789 wined3d_mutex_unlock();
2792 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
2793 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2795 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2798 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2799 iface
, start_slot
, buffer_count
, buffers
);
2801 wined3d_mutex_lock();
2802 for (i
= 0; i
< buffer_count
; ++i
)
2804 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2806 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
2807 buffer
? buffer
->wined3d_buffer
: NULL
);
2809 wined3d_mutex_unlock();
2812 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
2813 ID3D10InputLayout
*input_layout
)
2815 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2816 struct d3d_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
2818 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
2820 wined3d_mutex_lock();
2821 wined3d_device_set_vertex_declaration(This
->wined3d_device
,
2822 layout
? layout
->wined3d_decl
: NULL
);
2823 wined3d_mutex_unlock();
2826 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
2827 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
2829 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2832 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
2833 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
2835 wined3d_mutex_lock();
2836 for (i
= 0; i
< buffer_count
; ++i
)
2838 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2840 wined3d_device_set_stream_source(This
->wined3d_device
, start_slot
+ i
,
2841 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
2843 wined3d_mutex_unlock();
2846 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
2847 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
2849 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2850 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
2852 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
2853 iface
, buffer
, debug_dxgi_format(format
), offset
);
2855 wined3d_mutex_lock();
2856 wined3d_device_set_index_buffer(This
->wined3d_device
,
2857 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
2858 wined3dformat_from_dxgi_format(format
));
2859 wined3d_mutex_unlock();
2860 if (offset
) FIXME("offset %u not supported.\n", offset
);
2863 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
2864 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
2865 INT base_vertex_location
, UINT start_instance_location
)
2867 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2869 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
2870 "base_vertex_location %d, start_instance_location %u.\n",
2871 iface
, instance_index_count
, instance_count
, start_index_location
,
2872 base_vertex_location
, start_instance_location
);
2874 wined3d_mutex_lock();
2875 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
2876 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
2877 instance_index_count
, start_instance_location
, instance_count
);
2878 wined3d_mutex_unlock();
2881 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
2882 UINT instance_vertex_count
, UINT instance_count
,
2883 UINT start_vertex_location
, UINT start_instance_location
)
2885 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2887 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
2888 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
2889 start_vertex_location
, start_instance_location
);
2891 wined3d_mutex_lock();
2892 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
2893 instance_vertex_count
, start_instance_location
, instance_count
);
2894 wined3d_mutex_unlock();
2897 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
2898 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
2900 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2903 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2904 iface
, start_slot
, buffer_count
, buffers
);
2906 wined3d_mutex_lock();
2907 for (i
= 0; i
< buffer_count
; ++i
)
2909 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
2911 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
2912 buffer
? buffer
->wined3d_buffer
: NULL
);
2914 wined3d_mutex_unlock();
2917 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
2919 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2920 struct d3d_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
2922 TRACE("iface %p, shader %p.\n", iface
, shader
);
2924 wined3d_mutex_lock();
2925 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
2926 wined3d_mutex_unlock();
2929 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
2930 D3D10_PRIMITIVE_TOPOLOGY topology
)
2932 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2934 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
2936 wined3d_mutex_lock();
2937 wined3d_device_set_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
2938 wined3d_mutex_unlock();
2941 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
2942 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
2944 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2947 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2948 iface
, start_slot
, view_count
, views
);
2950 wined3d_mutex_lock();
2951 for (i
= 0; i
< view_count
; ++i
)
2953 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
2955 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
2956 view
? view
->wined3d_view
: NULL
);
2958 wined3d_mutex_unlock();
2961 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
2962 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
2964 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2967 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2968 iface
, start_slot
, sampler_count
, samplers
);
2970 wined3d_mutex_lock();
2971 for (i
= 0; i
< sampler_count
; ++i
)
2973 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
2975 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
2976 sampler
? sampler
->wined3d_sampler
: NULL
);
2978 wined3d_mutex_unlock();
2981 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
2983 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2984 struct d3d_query
*query
;
2986 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
2988 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
2989 wined3d_mutex_lock();
2990 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
2991 wined3d_mutex_unlock();
2994 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
2995 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
2997 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3000 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3001 iface
, start_slot
, view_count
, views
);
3003 wined3d_mutex_lock();
3004 for (i
= 0; i
< view_count
; ++i
)
3006 struct d3d_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
3008 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
3009 view
? view
->wined3d_view
: NULL
);
3011 wined3d_mutex_unlock();
3014 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
3015 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
3017 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3020 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3021 iface
, start_slot
, sampler_count
, samplers
);
3023 wined3d_mutex_lock();
3024 for (i
= 0; i
< sampler_count
; ++i
)
3026 struct d3d_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
3028 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
3029 sampler
? sampler
->wined3d_sampler
: NULL
);
3031 wined3d_mutex_unlock();
3034 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
3035 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
3036 ID3D10DepthStencilView
*depth_stencil_view
)
3038 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3039 struct d3d_depthstencil_view
*dsv
;
3042 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3043 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
3045 wined3d_mutex_lock();
3046 for (i
= 0; i
< render_target_view_count
; ++i
)
3048 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
3050 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
3051 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
3053 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3055 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3058 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
3059 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
3060 dsv
? dsv
->wined3d_view
: NULL
);
3061 wined3d_mutex_unlock();
3064 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
3065 ID3D10BlendState
*blend_state
, const FLOAT blend_factor
[4], UINT sample_mask
)
3067 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3068 struct d3d_blend_state
*blend_state_object
;
3070 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask 0x%08x.\n",
3071 iface
, blend_state
, blend_factor
, sample_mask
);
3073 blend_state_object
= unsafe_impl_from_ID3D10BlendState(blend_state
);
3074 d3d11_immediate_context_OMSetBlendState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3075 blend_state_object
? &blend_state_object
->ID3D11BlendState_iface
: NULL
, blend_factor
, sample_mask
);
3078 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
3079 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
3081 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3083 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3084 iface
, depth_stencil_state
, stencil_ref
);
3086 device
->depth_stencil_state
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
3087 device
->stencil_ref
= stencil_ref
;
3090 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
3091 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
3093 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3094 unsigned int count
, i
;
3096 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
3098 count
= min(target_count
, 4);
3099 wined3d_mutex_lock();
3100 for (i
= 0; i
< count
; ++i
)
3102 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
3104 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
3105 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
3108 for (i
= count
; i
< 4; ++i
)
3110 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
3112 wined3d_mutex_unlock();
3115 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
3117 FIXME("iface %p stub!\n", iface
);
3120 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
3122 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3123 struct d3d_rasterizer_state
*rasterizer_state_object
;
3125 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3127 rasterizer_state_object
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
);
3128 d3d11_immediate_context_RSSetState(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3129 rasterizer_state_object
? &rasterizer_state_object
->ID3D11RasterizerState_iface
: NULL
);
3132 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
3133 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
3135 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3136 struct wined3d_viewport wined3d_vp
;
3138 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
3140 if (viewport_count
> 1)
3141 FIXME("Multiple viewports not implemented.\n");
3143 if (!viewport_count
)
3146 wined3d_vp
.x
= viewports
[0].TopLeftX
;
3147 wined3d_vp
.y
= viewports
[0].TopLeftY
;
3148 wined3d_vp
.width
= viewports
[0].Width
;
3149 wined3d_vp
.height
= viewports
[0].Height
;
3150 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
3151 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
3153 wined3d_mutex_lock();
3154 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
3155 wined3d_mutex_unlock();
3158 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
3159 UINT rect_count
, const D3D10_RECT
*rects
)
3161 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3163 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
3166 FIXME("Multiple scissor rects not implemented.\n");
3171 wined3d_mutex_lock();
3172 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
3173 wined3d_mutex_unlock();
3176 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
3177 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
3178 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
3180 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3181 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3182 struct wined3d_box wined3d_src_box
;
3184 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3185 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3186 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
3187 src_resource
, src_subresource_idx
, src_box
);
3189 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3190 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3191 wined3d_src_box
.left
= src_box
->left
;
3192 wined3d_src_box
.top
= src_box
->top
;
3193 wined3d_src_box
.front
= src_box
->front
;
3194 wined3d_src_box
.right
= src_box
->right
;
3195 wined3d_src_box
.bottom
= src_box
->bottom
;
3196 wined3d_src_box
.back
= src_box
->back
;
3197 wined3d_mutex_lock();
3198 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
3199 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, &wined3d_src_box
);
3200 wined3d_mutex_unlock();
3203 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
3204 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
3206 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
3207 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3209 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
3211 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
3212 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
3213 wined3d_mutex_lock();
3214 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
3215 wined3d_mutex_unlock();
3218 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
3219 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
3220 const void *data
, UINT row_pitch
, UINT depth_pitch
)
3222 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3223 ID3D11Resource
*d3d11_resource
;
3225 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3226 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
3228 ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
);
3229 d3d11_immediate_context_UpdateSubresource(&device
->immediate_context
.ID3D11DeviceContext_iface
,
3230 d3d11_resource
, subresource_idx
, (const D3D11_BOX
*)box
, data
, row_pitch
, depth_pitch
);
3231 ID3D11Resource_Release(d3d11_resource
);
3234 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
3235 ID3D10RenderTargetView
*render_target_view
, const FLOAT color_rgba
[4])
3237 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3238 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
3239 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
3242 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
3243 iface
, render_target_view
, color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]);
3245 wined3d_mutex_lock();
3246 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
, &color
)))
3247 ERR("Failed to clear view, hr %#x.\n", hr
);
3248 wined3d_mutex_unlock();
3251 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
3252 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
3254 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
3255 iface
, depth_stencil_view
, flags
, depth
, stencil
);
3258 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
3259 ID3D10ShaderResourceView
*shader_resource_view
)
3261 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
3264 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
3265 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
3266 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
3268 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3269 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3270 iface
, dst_resource
, dst_subresource_idx
,
3271 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
3274 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
3275 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3277 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3280 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3281 iface
, start_slot
, buffer_count
, buffers
);
3283 wined3d_mutex_lock();
3284 for (i
= 0; i
< buffer_count
; ++i
)
3286 struct wined3d_buffer
*wined3d_buffer
;
3287 struct d3d_buffer
*buffer_impl
;
3289 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
3295 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3296 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3297 ID3D10Buffer_AddRef(buffers
[i
]);
3299 wined3d_mutex_unlock();
3302 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
3303 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3305 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3308 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3309 iface
, start_slot
, view_count
, views
);
3311 wined3d_mutex_lock();
3312 for (i
= 0; i
< view_count
; ++i
)
3314 struct wined3d_shader_resource_view
*wined3d_view
;
3315 struct d3d_shader_resource_view
*view_impl
;
3317 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3323 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3324 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3325 ID3D10ShaderResourceView_AddRef(views
[i
]);
3327 wined3d_mutex_unlock();
3330 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
3332 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3333 struct d3d_pixel_shader
*shader_impl
;
3334 struct wined3d_shader
*wined3d_shader
;
3336 TRACE("iface %p, shader %p.\n", iface
, shader
);
3338 wined3d_mutex_lock();
3339 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
3341 wined3d_mutex_unlock();
3346 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3347 wined3d_mutex_unlock();
3348 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
3349 ID3D10PixelShader_AddRef(*shader
);
3352 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
3353 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3355 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3358 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3359 iface
, start_slot
, sampler_count
, samplers
);
3361 wined3d_mutex_lock();
3362 for (i
= 0; i
< sampler_count
; ++i
)
3364 struct d3d_sampler_state
*sampler_impl
;
3365 struct wined3d_sampler
*wined3d_sampler
;
3367 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
3373 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3374 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3375 ID3D10SamplerState_AddRef(samplers
[i
]);
3377 wined3d_mutex_unlock();
3380 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
3382 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3383 struct d3d_vertex_shader
*shader_impl
;
3384 struct wined3d_shader
*wined3d_shader
;
3386 TRACE("iface %p, shader %p.\n", iface
, shader
);
3388 wined3d_mutex_lock();
3389 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
3391 wined3d_mutex_unlock();
3396 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3397 wined3d_mutex_unlock();
3398 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
3399 ID3D10VertexShader_AddRef(*shader
);
3402 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
3403 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3405 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3408 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3409 iface
, start_slot
, buffer_count
, buffers
);
3411 wined3d_mutex_lock();
3412 for (i
= 0; i
< buffer_count
; ++i
)
3414 struct wined3d_buffer
*wined3d_buffer
;
3415 struct d3d_buffer
*buffer_impl
;
3417 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
3423 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3424 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3425 ID3D10Buffer_AddRef(buffers
[i
]);
3427 wined3d_mutex_unlock();
3430 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
3432 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3433 struct wined3d_vertex_declaration
*wined3d_declaration
;
3434 struct d3d_input_layout
*input_layout_impl
;
3436 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
3438 wined3d_mutex_lock();
3439 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
3441 wined3d_mutex_unlock();
3442 *input_layout
= NULL
;
3446 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
3447 wined3d_mutex_unlock();
3448 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
3449 ID3D10InputLayout_AddRef(*input_layout
);
3452 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
3453 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
3455 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3458 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3459 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
3461 wined3d_mutex_lock();
3462 for (i
= 0; i
< buffer_count
; ++i
)
3464 struct wined3d_buffer
*wined3d_buffer
;
3465 struct d3d_buffer
*buffer_impl
;
3467 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
3468 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
3469 ERR("Failed to get vertex buffer.\n");
3471 if (!wined3d_buffer
)
3477 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3478 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3479 ID3D10Buffer_AddRef(buffers
[i
]);
3481 wined3d_mutex_unlock();
3484 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
3485 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
3487 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3488 enum wined3d_format_id wined3d_format
;
3489 struct wined3d_buffer
*wined3d_buffer
;
3490 struct d3d_buffer
*buffer_impl
;
3492 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
3494 wined3d_mutex_lock();
3495 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
);
3496 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
3497 *offset
= 0; /* FIXME */
3498 if (!wined3d_buffer
)
3500 wined3d_mutex_unlock();
3505 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3506 wined3d_mutex_unlock();
3507 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
3508 ID3D10Buffer_AddRef(*buffer
);
3511 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
3512 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
3514 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3517 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3518 iface
, start_slot
, buffer_count
, buffers
);
3520 wined3d_mutex_lock();
3521 for (i
= 0; i
< buffer_count
; ++i
)
3523 struct wined3d_buffer
*wined3d_buffer
;
3524 struct d3d_buffer
*buffer_impl
;
3526 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
3532 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3533 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3534 ID3D10Buffer_AddRef(buffers
[i
]);
3536 wined3d_mutex_unlock();
3539 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
3541 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3542 struct d3d_geometry_shader
*shader_impl
;
3543 struct wined3d_shader
*wined3d_shader
;
3545 TRACE("iface %p, shader %p.\n", iface
, shader
);
3547 wined3d_mutex_lock();
3548 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
3550 wined3d_mutex_unlock();
3555 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
3556 wined3d_mutex_unlock();
3557 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
3558 ID3D10GeometryShader_AddRef(*shader
);
3561 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
3562 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
3564 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
3566 TRACE("iface %p, topology %p\n", iface
, topology
);
3568 wined3d_mutex_lock();
3569 wined3d_device_get_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
3570 wined3d_mutex_unlock();
3573 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
3574 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3576 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3579 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3580 iface
, start_slot
, view_count
, views
);
3582 wined3d_mutex_lock();
3583 for (i
= 0; i
< view_count
; ++i
)
3585 struct wined3d_shader_resource_view
*wined3d_view
;
3586 struct d3d_shader_resource_view
*view_impl
;
3588 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3594 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3595 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3596 ID3D10ShaderResourceView_AddRef(views
[i
]);
3598 wined3d_mutex_unlock();
3601 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
3602 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3604 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3607 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3608 iface
, start_slot
, sampler_count
, samplers
);
3610 wined3d_mutex_lock();
3611 for (i
= 0; i
< sampler_count
; ++i
)
3613 struct d3d_sampler_state
*sampler_impl
;
3614 struct wined3d_sampler
*wined3d_sampler
;
3616 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3622 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3623 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3624 ID3D10SamplerState_AddRef(samplers
[i
]);
3626 wined3d_mutex_unlock();
3629 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
3630 ID3D10Predicate
**predicate
, BOOL
*value
)
3632 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3633 struct wined3d_query
*wined3d_predicate
;
3634 struct d3d_query
*predicate_impl
;
3636 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
3638 wined3d_mutex_lock();
3639 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
3641 wined3d_mutex_unlock();
3646 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
3647 wined3d_mutex_unlock();
3648 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
3649 ID3D10Predicate_AddRef(*predicate
);
3652 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
3653 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
3655 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3658 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3659 iface
, start_slot
, view_count
, views
);
3661 wined3d_mutex_lock();
3662 for (i
= 0; i
< view_count
; ++i
)
3664 struct wined3d_shader_resource_view
*wined3d_view
;
3665 struct d3d_shader_resource_view
*view_impl
;
3667 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
3673 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
3674 views
[i
] = (ID3D10ShaderResourceView
*)&view_impl
->ID3D10ShaderResourceView1_iface
;
3675 ID3D10ShaderResourceView_AddRef(views
[i
]);
3677 wined3d_mutex_unlock();
3680 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
3681 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
3683 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3686 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3687 iface
, start_slot
, sampler_count
, samplers
);
3689 wined3d_mutex_lock();
3690 for (i
= 0; i
< sampler_count
; ++i
)
3692 struct d3d_sampler_state
*sampler_impl
;
3693 struct wined3d_sampler
*wined3d_sampler
;
3695 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
3701 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
3702 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
3703 ID3D10SamplerState_AddRef(samplers
[i
]);
3705 wined3d_mutex_unlock();
3708 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
3709 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
3711 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3712 struct wined3d_rendertarget_view
*wined3d_view
;
3714 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3715 iface
, view_count
, render_target_views
, depth_stencil_view
);
3717 wined3d_mutex_lock();
3718 if (render_target_views
)
3720 struct d3d_rendertarget_view
*view_impl
;
3723 for (i
= 0; i
< view_count
; ++i
)
3725 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
3726 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3728 render_target_views
[i
] = NULL
;
3732 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
3733 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
3737 if (depth_stencil_view
)
3739 struct d3d_depthstencil_view
*view_impl
;
3741 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
3742 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
3744 *depth_stencil_view
= NULL
;
3748 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
3749 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
3752 wined3d_mutex_unlock();
3755 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
3756 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
3758 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3760 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3761 iface
, blend_state
, blend_factor
, sample_mask
);
3763 if ((*blend_state
= device
->blend_state
? (ID3D10BlendState
*)&device
->blend_state
->ID3D10BlendState1_iface
: NULL
))
3764 ID3D10BlendState_AddRef(*blend_state
);
3765 wined3d_mutex_lock();
3766 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
3767 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
3768 wined3d_mutex_unlock();
3771 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
3772 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
3774 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3776 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
3777 iface
, depth_stencil_state
, stencil_ref
);
3779 if ((*depth_stencil_state
= device
->depth_stencil_state
3780 ? &device
->depth_stencil_state
->ID3D10DepthStencilState_iface
: NULL
))
3781 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
3782 *stencil_ref
= device
->stencil_ref
;
3785 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
3786 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
3788 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3791 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
3792 iface
, buffer_count
, buffers
, offsets
);
3794 wined3d_mutex_lock();
3795 for (i
= 0; i
< buffer_count
; ++i
)
3797 struct wined3d_buffer
*wined3d_buffer
;
3798 struct d3d_buffer
*buffer_impl
;
3800 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
3806 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
3807 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
3808 ID3D10Buffer_AddRef(buffers
[i
]);
3810 wined3d_mutex_unlock();
3813 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
3815 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3817 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
3819 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
3820 ID3D10RasterizerState_AddRef(*rasterizer_state
);
3823 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
3824 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
3826 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3827 struct wined3d_viewport wined3d_vp
;
3829 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
3833 *viewport_count
= 1;
3837 if (!*viewport_count
)
3840 wined3d_mutex_lock();
3841 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
3842 wined3d_mutex_unlock();
3844 viewports
[0].TopLeftX
= wined3d_vp
.x
;
3845 viewports
[0].TopLeftY
= wined3d_vp
.y
;
3846 viewports
[0].Width
= wined3d_vp
.width
;
3847 viewports
[0].Height
= wined3d_vp
.height
;
3848 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
3849 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
3851 if (*viewport_count
> 1)
3852 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
3855 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
3857 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3859 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
3870 wined3d_mutex_lock();
3871 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
3872 wined3d_mutex_unlock();
3873 if (*rect_count
> 1)
3874 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
3877 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
3879 TRACE("iface %p.\n", iface
);
3881 /* In the current implementation the device is never removed, so we can
3882 * just return S_OK here. */
3887 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
3889 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
3894 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
3896 FIXME("iface %p stub!\n", iface
);
3901 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
3902 REFGUID guid
, UINT
*data_size
, void *data
)
3904 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3906 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3908 return d3d11_device_GetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
3911 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
3912 REFGUID guid
, UINT data_size
, const void *data
)
3914 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3916 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
3918 return d3d11_device_SetPrivateData(&device
->ID3D11Device_iface
, guid
, data_size
, data
);
3921 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
3922 REFGUID guid
, const IUnknown
*data
)
3924 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3926 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
3928 return d3d11_device_SetPrivateDataInterface(&device
->ID3D11Device_iface
, guid
, data
);
3931 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
3933 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
3934 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
3937 TRACE("iface %p.\n", iface
);
3939 wined3d_mutex_lock();
3940 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
3941 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
3943 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
3945 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3947 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
3949 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
3951 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
3953 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
3954 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
3956 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
3958 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3960 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
3962 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
3964 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
3966 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
3967 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
3969 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
3971 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3973 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
3975 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
3977 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
3979 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3981 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
3983 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
);
3984 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
3985 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
3986 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3988 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
3990 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
3991 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
3992 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
3993 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
3994 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
3995 ID3D10Device1_RSSetState(iface
, NULL
);
3996 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
3998 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
4000 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
4001 wined3d_mutex_unlock();
4004 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
4006 FIXME("iface %p stub!\n", iface
);
4009 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
4010 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
4012 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4013 D3D11_BUFFER_DESC d3d11_desc
;
4014 struct d3d_buffer
*object
;
4017 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
4019 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
4020 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4021 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4022 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4023 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4024 d3d11_desc
.StructureByteStride
= 0;
4026 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4029 *buffer
= &object
->ID3D10Buffer_iface
;
4034 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
4035 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
4037 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
4042 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
4043 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4044 ID3D10Texture2D
**texture
)
4046 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4047 D3D11_TEXTURE2D_DESC d3d11_desc
;
4048 struct d3d_texture2d
*object
;
4051 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4053 d3d11_desc
.Width
= desc
->Width
;
4054 d3d11_desc
.Height
= desc
->Height
;
4055 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4056 d3d11_desc
.ArraySize
= desc
->ArraySize
;
4057 d3d11_desc
.Format
= desc
->Format
;
4058 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
4059 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4060 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4061 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4062 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4064 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4067 *texture
= &object
->ID3D10Texture2D_iface
;
4072 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
4073 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
4074 ID3D10Texture3D
**texture
)
4076 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4077 D3D11_TEXTURE3D_DESC d3d11_desc
;
4078 struct d3d_texture3d
*object
;
4081 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
4083 d3d11_desc
.Width
= desc
->Width
;
4084 d3d11_desc
.Height
= desc
->Height
;
4085 d3d11_desc
.Depth
= desc
->Depth
;
4086 d3d11_desc
.MipLevels
= desc
->MipLevels
;
4087 d3d11_desc
.Format
= desc
->Format
;
4088 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
4089 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
4090 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
4091 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
4093 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
4096 *texture
= &object
->ID3D10Texture3D_iface
;
4101 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
4102 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
4104 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4105 struct d3d_shader_resource_view
*object
;
4106 ID3D11Resource
*d3d11_resource
;
4109 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4111 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4113 ERR("Resource does not implement ID3D11Resource.\n");
4117 hr
= d3d_shader_resource_view_create(device
, d3d11_resource
, (const D3D11_SHADER_RESOURCE_VIEW_DESC
*)desc
,
4119 ID3D11Resource_Release(d3d11_resource
);
4123 *view
= &object
->ID3D10ShaderResourceView1_iface
;
4128 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
4129 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
4131 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4133 return d3d10_device_CreateShaderResourceView1(iface
, resource
,
4134 (const D3D10_SHADER_RESOURCE_VIEW_DESC1
*)desc
, (ID3D10ShaderResourceView1
**)view
);
4137 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
4138 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
4140 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4141 struct d3d_rendertarget_view
*object
;
4142 ID3D11Resource
*d3d11_resource
;
4145 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4147 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4149 ERR("Resource does not implement ID3D11Resource.\n");
4153 hr
= d3d_rendertarget_view_create(device
, d3d11_resource
, (const D3D11_RENDER_TARGET_VIEW_DESC
*)desc
, &object
);
4154 ID3D11Resource_Release(d3d11_resource
);
4158 *view
= &object
->ID3D10RenderTargetView_iface
;
4163 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
4164 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
4166 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4167 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
4168 struct d3d_depthstencil_view
*object
;
4169 ID3D11Resource
*d3d11_resource
;
4172 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
4176 d3d11_desc
.Format
= desc
->Format
;
4177 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
4178 d3d11_desc
.Flags
= 0;
4179 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
4182 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
4184 ERR("Resource does not implement ID3D11Resource.\n");
4188 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
4189 ID3D11Resource_Release(d3d11_resource
);
4193 *view
= &object
->ID3D10DepthStencilView_iface
;
4198 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
4199 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
4200 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
4201 ID3D10InputLayout
**input_layout
)
4203 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4204 struct d3d_input_layout
*object
;
4207 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4208 "shader_byte_code_length %lu, input_layout %p\n",
4209 iface
, element_descs
, element_count
, shader_byte_code
,
4210 shader_byte_code_length
, input_layout
);
4212 if (FAILED(hr
= d3d_input_layout_create(device
, (const D3D11_INPUT_ELEMENT_DESC
*)element_descs
, element_count
,
4213 shader_byte_code
, shader_byte_code_length
, &object
)))
4216 *input_layout
= &object
->ID3D10InputLayout_iface
;
4221 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
4222 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
4224 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4225 struct d3d_vertex_shader
*object
;
4228 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4229 iface
, byte_code
, byte_code_length
, shader
);
4231 if (FAILED(hr
= d3d_vertex_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4234 *shader
= &object
->ID3D10VertexShader_iface
;
4239 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
4240 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
4242 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4243 struct d3d_geometry_shader
*object
;
4246 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4247 iface
, byte_code
, byte_code_length
, shader
);
4249 if (FAILED(hr
= d3d_geometry_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4252 *shader
= &object
->ID3D10GeometryShader_iface
;
4257 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
4258 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
4259 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
4261 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4262 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4263 iface
, byte_code
, byte_code_length
, output_stream_decls
,
4264 output_stream_decl_count
, output_stream_stride
, shader
);
4269 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
4270 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
4272 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4273 struct d3d_pixel_shader
*object
;
4276 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4277 iface
, byte_code
, byte_code_length
, shader
);
4279 if (FAILED(hr
= d3d_pixel_shader_create(device
, byte_code
, byte_code_length
, &object
)))
4282 *shader
= &object
->ID3D10PixelShader_iface
;
4287 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
4288 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
4290 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4291 ID3D11BlendState
*d3d11_blend_state
;
4294 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4296 if (FAILED(hr
= d3d11_device_CreateBlendState(&device
->ID3D11Device_iface
, (D3D11_BLEND_DESC
*)desc
,
4297 &d3d11_blend_state
)))
4300 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState1
, (void **)blend_state
);
4301 ID3D11BlendState_Release(d3d11_blend_state
);
4305 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
4306 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
4308 D3D10_BLEND_DESC1 d3d10_1_desc
;
4311 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
4314 return E_INVALIDARG
;
4316 d3d10_1_desc
.AlphaToCoverageEnable
= desc
->AlphaToCoverageEnable
;
4317 d3d10_1_desc
.IndependentBlendEnable
= FALSE
;
4318 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
4320 if (desc
->BlendEnable
[i
] != desc
->BlendEnable
[i
+ 1]
4321 || desc
->RenderTargetWriteMask
[i
] != desc
->RenderTargetWriteMask
[i
+ 1])
4322 d3d10_1_desc
.IndependentBlendEnable
= TRUE
;
4325 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4327 d3d10_1_desc
.RenderTarget
[i
].BlendEnable
= desc
->BlendEnable
[i
];
4328 d3d10_1_desc
.RenderTarget
[i
].SrcBlend
= desc
->SrcBlend
;
4329 d3d10_1_desc
.RenderTarget
[i
].DestBlend
= desc
->DestBlend
;
4330 d3d10_1_desc
.RenderTarget
[i
].BlendOp
= desc
->BlendOp
;
4331 d3d10_1_desc
.RenderTarget
[i
].SrcBlendAlpha
= desc
->SrcBlendAlpha
;
4332 d3d10_1_desc
.RenderTarget
[i
].DestBlendAlpha
= desc
->DestBlendAlpha
;
4333 d3d10_1_desc
.RenderTarget
[i
].BlendOpAlpha
= desc
->BlendOpAlpha
;
4334 d3d10_1_desc
.RenderTarget
[i
].RenderTargetWriteMask
= desc
->RenderTargetWriteMask
[i
];
4337 return d3d10_device_CreateBlendState1(iface
, &d3d10_1_desc
, (ID3D10BlendState1
**)blend_state
);
4340 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
4341 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
4343 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4344 ID3D11DepthStencilState
*d3d11_depth_stencil_state
;
4347 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
4349 if (FAILED(hr
= d3d11_device_CreateDepthStencilState(&device
->ID3D11Device_iface
,
4350 (const D3D11_DEPTH_STENCIL_DESC
*)desc
, &d3d11_depth_stencil_state
)))
4353 hr
= ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state
, &IID_ID3D10DepthStencilState
,
4354 (void **)depth_stencil_state
);
4355 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state
);
4359 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
4360 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
4362 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4363 ID3D11RasterizerState
*d3d11_rasterizer_state
;
4366 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
4368 if (FAILED(hr
= d3d11_device_CreateRasterizerState(&device
->ID3D11Device_iface
,
4369 (const D3D11_RASTERIZER_DESC
*)desc
, &d3d11_rasterizer_state
)))
4372 hr
= ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state
,
4373 &IID_ID3D10RasterizerState
, (void **)rasterizer_state
);
4374 ID3D11RasterizerState_Release(d3d11_rasterizer_state
);
4378 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
4379 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
4381 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4382 ID3D11SamplerState
*d3d11_sampler_state
;
4385 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
4387 if (FAILED(hr
= d3d11_device_CreateSamplerState(&device
->ID3D11Device_iface
,
4388 (const D3D11_SAMPLER_DESC
*)desc
, &d3d11_sampler_state
)))
4391 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
, (void **)sampler_state
);
4392 ID3D11SamplerState_Release(d3d11_sampler_state
);
4396 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
4397 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
4399 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4400 struct d3d_query
*object
;
4403 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
4405 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, FALSE
, &object
)))
4408 *query
= &object
->ID3D10Query_iface
;
4413 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
4414 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
4416 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
4417 struct d3d_query
*object
;
4420 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
4422 if (FAILED(hr
= d3d_query_create(device
, (const D3D11_QUERY_DESC
*)desc
, TRUE
, &object
)))
4425 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
4430 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
4431 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
4433 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
4438 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
4439 DXGI_FORMAT format
, UINT
*format_support
)
4441 FIXME("iface %p, format %s, format_support %p stub!\n",
4442 iface
, debug_dxgi_format(format
), format_support
);
4447 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
4448 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
4450 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
4451 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
4456 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
4458 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
4461 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
4462 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
4463 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
4465 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4466 "units %p, units_length %p, description %p, description_length %p stub!\n",
4467 iface
, desc
, type
, active_counters
, name
, name_length
,
4468 units
, units_length
, description
, description_length
);
4473 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
4475 FIXME("iface %p stub!\n", iface
);
4480 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
4481 HANDLE resource_handle
, REFIID guid
, void **resource
)
4483 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4484 iface
, resource_handle
, debugstr_guid(guid
), resource
);
4489 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
4491 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
4494 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
4496 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
4499 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
4501 FIXME("iface %p stub!\n", iface
);
4503 return D3D10_FEATURE_LEVEL_10_1
;
4506 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
4508 /* IUnknown methods */
4509 d3d10_device_QueryInterface
,
4510 d3d10_device_AddRef
,
4511 d3d10_device_Release
,
4512 /* ID3D10Device methods */
4513 d3d10_device_VSSetConstantBuffers
,
4514 d3d10_device_PSSetShaderResources
,
4515 d3d10_device_PSSetShader
,
4516 d3d10_device_PSSetSamplers
,
4517 d3d10_device_VSSetShader
,
4518 d3d10_device_DrawIndexed
,
4520 d3d10_device_PSSetConstantBuffers
,
4521 d3d10_device_IASetInputLayout
,
4522 d3d10_device_IASetVertexBuffers
,
4523 d3d10_device_IASetIndexBuffer
,
4524 d3d10_device_DrawIndexedInstanced
,
4525 d3d10_device_DrawInstanced
,
4526 d3d10_device_GSSetConstantBuffers
,
4527 d3d10_device_GSSetShader
,
4528 d3d10_device_IASetPrimitiveTopology
,
4529 d3d10_device_VSSetShaderResources
,
4530 d3d10_device_VSSetSamplers
,
4531 d3d10_device_SetPredication
,
4532 d3d10_device_GSSetShaderResources
,
4533 d3d10_device_GSSetSamplers
,
4534 d3d10_device_OMSetRenderTargets
,
4535 d3d10_device_OMSetBlendState
,
4536 d3d10_device_OMSetDepthStencilState
,
4537 d3d10_device_SOSetTargets
,
4538 d3d10_device_DrawAuto
,
4539 d3d10_device_RSSetState
,
4540 d3d10_device_RSSetViewports
,
4541 d3d10_device_RSSetScissorRects
,
4542 d3d10_device_CopySubresourceRegion
,
4543 d3d10_device_CopyResource
,
4544 d3d10_device_UpdateSubresource
,
4545 d3d10_device_ClearRenderTargetView
,
4546 d3d10_device_ClearDepthStencilView
,
4547 d3d10_device_GenerateMips
,
4548 d3d10_device_ResolveSubresource
,
4549 d3d10_device_VSGetConstantBuffers
,
4550 d3d10_device_PSGetShaderResources
,
4551 d3d10_device_PSGetShader
,
4552 d3d10_device_PSGetSamplers
,
4553 d3d10_device_VSGetShader
,
4554 d3d10_device_PSGetConstantBuffers
,
4555 d3d10_device_IAGetInputLayout
,
4556 d3d10_device_IAGetVertexBuffers
,
4557 d3d10_device_IAGetIndexBuffer
,
4558 d3d10_device_GSGetConstantBuffers
,
4559 d3d10_device_GSGetShader
,
4560 d3d10_device_IAGetPrimitiveTopology
,
4561 d3d10_device_VSGetShaderResources
,
4562 d3d10_device_VSGetSamplers
,
4563 d3d10_device_GetPredication
,
4564 d3d10_device_GSGetShaderResources
,
4565 d3d10_device_GSGetSamplers
,
4566 d3d10_device_OMGetRenderTargets
,
4567 d3d10_device_OMGetBlendState
,
4568 d3d10_device_OMGetDepthStencilState
,
4569 d3d10_device_SOGetTargets
,
4570 d3d10_device_RSGetState
,
4571 d3d10_device_RSGetViewports
,
4572 d3d10_device_RSGetScissorRects
,
4573 d3d10_device_GetDeviceRemovedReason
,
4574 d3d10_device_SetExceptionMode
,
4575 d3d10_device_GetExceptionMode
,
4576 d3d10_device_GetPrivateData
,
4577 d3d10_device_SetPrivateData
,
4578 d3d10_device_SetPrivateDataInterface
,
4579 d3d10_device_ClearState
,
4581 d3d10_device_CreateBuffer
,
4582 d3d10_device_CreateTexture1D
,
4583 d3d10_device_CreateTexture2D
,
4584 d3d10_device_CreateTexture3D
,
4585 d3d10_device_CreateShaderResourceView
,
4586 d3d10_device_CreateRenderTargetView
,
4587 d3d10_device_CreateDepthStencilView
,
4588 d3d10_device_CreateInputLayout
,
4589 d3d10_device_CreateVertexShader
,
4590 d3d10_device_CreateGeometryShader
,
4591 d3d10_device_CreateGeometryShaderWithStreamOutput
,
4592 d3d10_device_CreatePixelShader
,
4593 d3d10_device_CreateBlendState
,
4594 d3d10_device_CreateDepthStencilState
,
4595 d3d10_device_CreateRasterizerState
,
4596 d3d10_device_CreateSamplerState
,
4597 d3d10_device_CreateQuery
,
4598 d3d10_device_CreatePredicate
,
4599 d3d10_device_CreateCounter
,
4600 d3d10_device_CheckFormatSupport
,
4601 d3d10_device_CheckMultisampleQualityLevels
,
4602 d3d10_device_CheckCounterInfo
,
4603 d3d10_device_CheckCounter
,
4604 d3d10_device_GetCreationFlags
,
4605 d3d10_device_OpenSharedResource
,
4606 d3d10_device_SetTextFilterSize
,
4607 d3d10_device_GetTextFilterSize
,
4608 d3d10_device_CreateShaderResourceView1
,
4609 d3d10_device_CreateBlendState1
,
4610 d3d10_device_GetFeatureLevel
,
4613 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl
=
4615 /* IUnknown methods */
4616 d3d_device_inner_QueryInterface
,
4617 d3d_device_inner_AddRef
,
4618 d3d_device_inner_Release
,
4621 /* ID3D10Multithread methods */
4623 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
4625 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
4628 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
4630 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4632 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
4634 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
4637 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
4639 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4641 TRACE("iface %p.\n", iface
);
4643 return IUnknown_AddRef(device
->outer_unk
);
4646 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
4648 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
4650 TRACE("iface %p.\n", iface
);
4652 return IUnknown_Release(device
->outer_unk
);
4655 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
4657 TRACE("iface %p.\n", iface
);
4659 wined3d_mutex_lock();
4662 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
4664 TRACE("iface %p.\n", iface
);
4666 wined3d_mutex_unlock();
4669 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
4671 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
4676 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
4678 FIXME("iface %p stub!\n", iface
);
4683 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
4685 d3d10_multithread_QueryInterface
,
4686 d3d10_multithread_AddRef
,
4687 d3d10_multithread_Release
,
4688 d3d10_multithread_Enter
,
4689 d3d10_multithread_Leave
,
4690 d3d10_multithread_SetMultithreadProtected
,
4691 d3d10_multithread_GetMultithreadProtected
,
4694 /* IWineDXGIDeviceParent IUnknown methods */
4696 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
4698 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
4701 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
4702 REFIID riid
, void **ppv
)
4704 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4705 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
4708 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
4710 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4711 return IUnknown_AddRef(device
->outer_unk
);
4714 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
4716 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4717 return IUnknown_Release(device
->outer_unk
);
4720 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
4721 IWineDXGIDeviceParent
*iface
)
4723 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
4724 return &device
->device_parent
;
4727 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl
=
4729 /* IUnknown methods */
4730 dxgi_device_parent_QueryInterface
,
4731 dxgi_device_parent_AddRef
,
4732 dxgi_device_parent_Release
,
4733 /* IWineDXGIDeviceParent methods */
4734 dxgi_device_parent_get_wined3d_device_parent
,
4737 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
4739 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
4742 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
4743 struct wined3d_device
*wined3d_device
)
4745 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
4747 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
4749 wined3d_device_incref(wined3d_device
);
4750 device
->wined3d_device
= wined3d_device
;
4753 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
4755 TRACE("device_parent %p.\n", device_parent
);
4758 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
4760 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
4763 static HRESULT CDECL
device_parent_surface_created(struct wined3d_device_parent
*device_parent
,
4764 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, struct wined3d_surface
*surface
, void **parent
,
4765 const struct wined3d_parent_ops
**parent_ops
)
4767 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
4768 device_parent
, wined3d_texture
, sub_resource_idx
, surface
, parent
, parent_ops
);
4771 *parent_ops
= &d3d_null_wined3d_parent_ops
;
4776 static HRESULT CDECL
device_parent_volume_created(struct wined3d_device_parent
*device_parent
,
4777 struct wined3d_texture
*wined3d_texture
, unsigned int sub_resource_idx
, void **parent
,
4778 const struct wined3d_parent_ops
**parent_ops
)
4780 TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
4781 device_parent
, wined3d_texture
, sub_resource_idx
, parent
, parent_ops
);
4784 *parent_ops
= &d3d_null_wined3d_parent_ops
;
4789 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
4790 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
4791 struct wined3d_texture
**wined3d_texture
)
4793 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
4794 struct d3d_texture2d
*texture
;
4795 ID3D10Texture2D
*texture_iface
;
4796 D3D10_TEXTURE2D_DESC desc
;
4799 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
4800 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
4802 FIXME("Implement DXGI<->wined3d usage conversion\n");
4804 desc
.Width
= wined3d_desc
->width
;
4805 desc
.Height
= wined3d_desc
->height
;
4808 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
4809 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
4810 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
4811 desc
.Usage
= D3D10_USAGE_DEFAULT
;
4812 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
4813 desc
.CPUAccessFlags
= 0;
4816 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
4817 &desc
, NULL
, &texture_iface
)))
4819 ERR("CreateTexture2D failed, returning %#x\n", hr
);
4823 texture
= impl_from_ID3D10Texture2D(texture_iface
);
4825 *wined3d_texture
= texture
->wined3d_texture
;
4826 wined3d_texture_incref(*wined3d_texture
);
4827 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
4832 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
4833 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
4835 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
4836 IWineDXGIDevice
*wine_device
;
4839 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
4841 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
4842 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
4844 ERR("Device should implement IWineDXGIDevice.\n");
4848 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, swapchain
);
4849 IWineDXGIDevice_Release(wine_device
);
4852 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
4859 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops
=
4861 device_parent_wined3d_device_created
,
4862 device_parent_mode_changed
,
4863 device_parent_activate
,
4864 device_parent_surface_created
,
4865 device_parent_volume_created
,
4866 device_parent_create_swapchain_texture
,
4867 device_parent_create_swapchain
,
4870 static void *d3d_rb_alloc(size_t size
)
4872 return HeapAlloc(GetProcessHeap(), 0, size
);
4875 static void *d3d_rb_realloc(void *ptr
, size_t size
)
4877 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
4880 static void d3d_rb_free(void *ptr
)
4882 HeapFree(GetProcessHeap(), 0, ptr
);
4885 static int d3d_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
4887 const D3D11_SAMPLER_DESC
*ka
= key
;
4888 const D3D11_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_sampler_state
, entry
)->desc
;
4890 return memcmp(ka
, kb
, sizeof(*ka
));
4893 static const struct wine_rb_functions d3d_sampler_state_rb_ops
=
4898 d3d_sampler_state_compare
,
4901 static int d3d_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
4903 const D3D11_BLEND_DESC
*ka
= key
;
4904 const D3D11_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_blend_state
, entry
)->desc
;
4906 return memcmp(ka
, kb
, sizeof(*ka
));
4909 static const struct wine_rb_functions d3d_blend_state_rb_ops
=
4914 d3d_blend_state_compare
,
4917 static int d3d_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
4919 const D3D11_DEPTH_STENCIL_DESC
*ka
= key
;
4920 const D3D11_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
4921 const struct d3d_depthstencil_state
, entry
)->desc
;
4923 return memcmp(ka
, kb
, sizeof(*ka
));
4926 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops
=
4931 d3d_depthstencil_state_compare
,
4934 static int d3d_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
4936 const D3D11_RASTERIZER_DESC
*ka
= key
;
4937 const D3D11_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d_rasterizer_state
, entry
)->desc
;
4939 return memcmp(ka
, kb
, sizeof(*ka
));
4942 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops
=
4947 d3d_rasterizer_state_compare
,
4950 HRESULT
d3d_device_init(struct d3d_device
*device
, void *outer_unknown
)
4952 device
->IUnknown_inner
.lpVtbl
= &d3d_device_inner_unknown_vtbl
;
4953 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
4954 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
4955 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
4956 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d_dxgi_device_parent_vtbl
;
4957 device
->device_parent
.ops
= &d3d_wined3d_device_parent_ops
;
4958 device
->refcount
= 1;
4959 /* COM aggregation always takes place */
4960 device
->outer_unk
= outer_unknown
;
4962 if (FAILED(d3d11_immediate_context_init(&device
->immediate_context
, device
)))
4964 WARN("Failed to initialize immediate device context.\n");
4967 ID3D11DeviceContext_Release(&device
->immediate_context
.ID3D11DeviceContext_iface
);
4969 if (wine_rb_init(&device
->blend_states
, &d3d_blend_state_rb_ops
) == -1)
4971 WARN("Failed to initialize blend state rbtree.\n");
4974 device
->blend_factor
[0] = 1.0f
;
4975 device
->blend_factor
[1] = 1.0f
;
4976 device
->blend_factor
[2] = 1.0f
;
4977 device
->blend_factor
[3] = 1.0f
;
4979 if (wine_rb_init(&device
->depthstencil_states
, &d3d_depthstencil_state_rb_ops
) == -1)
4981 WARN("Failed to initialize depthstencil state rbtree.\n");
4982 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4986 if (wine_rb_init(&device
->rasterizer_states
, &d3d_rasterizer_state_rb_ops
) == -1)
4988 WARN("Failed to initialize rasterizer state rbtree.\n");
4989 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4990 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
4994 if (wine_rb_init(&device
->sampler_states
, &d3d_sampler_state_rb_ops
) == -1)
4996 WARN("Failed to initialize sampler state rbtree.\n");
4997 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
4998 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
4999 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);