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 #include "d3d11_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
27 static void STDMETHODCALLTYPE
d3d10_null_wined3d_object_destroyed(void *parent
) {}
29 const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops
=
31 d3d10_null_wined3d_object_destroyed
,
34 /* ID3D11Device methods */
36 static inline struct d3d_device
*impl_from_ID3D11Device(ID3D11Device
*iface
)
38 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D11Device_iface
);
41 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
43 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
44 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
47 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
49 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
50 return IUnknown_AddRef(device
->outer_unk
);
53 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
55 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
56 return IUnknown_Release(device
->outer_unk
);
59 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
60 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
62 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
63 struct d3d_buffer
*object
;
66 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
68 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
71 *buffer
= &object
->ID3D11Buffer_iface
;
76 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
77 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
79 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
84 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
85 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
87 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
88 struct d3d_texture2d
*object
;
91 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
93 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
96 *texture
= &object
->ID3D11Texture2D_iface
;
101 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
102 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
104 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
105 struct d3d_texture3d
*object
;
108 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
110 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
113 *texture
= &object
->ID3D11Texture3D_iface
;
118 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
119 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
121 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
126 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
127 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
129 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
134 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
135 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
137 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
142 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
143 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
145 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
150 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
151 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
152 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
154 FIXME("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
155 "input_layout %p stub!\n", iface
, element_descs
, element_count
, shader_byte_code
,
156 shader_byte_code_length
, input_layout
);
161 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
162 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
164 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
165 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
170 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
171 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
173 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
174 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
179 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
180 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
181 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
182 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
184 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
185 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
186 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
187 rasterized_stream
, class_linkage
, shader
);
192 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
193 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
195 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
196 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
201 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
202 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
204 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
205 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
210 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
211 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
213 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
214 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
219 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
220 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
222 FIXME("iface %p, byte_code %p, byte_code_lenghth %lu, class_linkage %p, shader %p stub!\n",
223 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
228 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
229 ID3D11ClassLinkage
**class_linkage
)
231 FIXME("iface %p, class_linkage %p stub!\n", iface
, class_linkage
);
236 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
237 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
239 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface
, desc
, blend_state
);
244 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
245 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
247 FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface
, desc
, depth_stencil_state
);
252 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
253 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
255 FIXME("iface %p, desc %p, rasterizer_state %p stub!\n", iface
, desc
, rasterizer_state
);
260 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
261 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
263 FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface
, desc
, sampler_state
);
268 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
269 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
271 FIXME("iface %p, desc %p, query %p stub!\n", iface
, desc
, query
);
276 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
277 ID3D11Predicate
**predicate
)
279 FIXME("iface %p, desc %p, predicate %p stub!\n", iface
, desc
, predicate
);
284 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
285 ID3D11Counter
**counter
)
287 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
292 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
293 ID3D11DeviceContext
**context
)
295 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
300 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
303 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
308 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
309 UINT
*format_support
)
311 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
316 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
317 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
319 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
320 iface
, format
, sample_count
, quality_level_count
);
325 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
327 FIXME("iface %p, info %p stub!\n", iface
, info
);
330 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
331 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
332 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
334 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
335 "units %p, units_length %p, description %p, description_length %p stub!\n",
336 iface
, desc
, type
, active_counter_count
, name
, name_length
,
337 units
, units_length
, description
, description_length
);
342 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
343 void *feature_support_data
, UINT feature_support_data_size
)
345 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
346 iface
, feature
, feature_support_data
, feature_support_data_size
);
351 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
352 UINT
*data_size
, void *data
)
354 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
359 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
360 UINT data_size
, const void *data
)
362 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
367 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
368 const IUnknown
*data_iface
)
370 FIXME("iface %p, guid %s, data_iface %p stub!\n", iface
, debugstr_guid(guid
), data_iface
);
375 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
377 FIXME("iface %p stub!\n", iface
);
379 return D3D_FEATURE_LEVEL_10_0
;
382 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
384 FIXME("iface %p stub!\n", iface
);
389 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
391 FIXME("iface %p stub!\n", iface
);
396 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
397 ID3D11DeviceContext
**immediate_context
)
399 FIXME("iface %p, immediate_context %p stub!\n", iface
, immediate_context
);
402 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
404 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
409 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
411 FIXME("iface %p stub!\n", iface
);
416 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
418 /* IUnknown methods */
419 d3d11_device_QueryInterface
,
421 d3d11_device_Release
,
422 /* ID3D11Device methods */
423 d3d11_device_CreateBuffer
,
424 d3d11_device_CreateTexture1D
,
425 d3d11_device_CreateTexture2D
,
426 d3d11_device_CreateTexture3D
,
427 d3d11_device_CreateShaderResourceView
,
428 d3d11_device_CreateUnorderedAccessView
,
429 d3d11_device_CreateRenderTargetView
,
430 d3d11_device_CreateDepthStencilView
,
431 d3d11_device_CreateInputLayout
,
432 d3d11_device_CreateVertexShader
,
433 d3d11_device_CreateGeometryShader
,
434 d3d11_device_CreateGeometryShaderWithStreamOutput
,
435 d3d11_device_CreatePixelShader
,
436 d3d11_device_CreateHullShader
,
437 d3d11_device_CreateDomainShader
,
438 d3d11_device_CreateComputeShader
,
439 d3d11_device_CreateClassLinkage
,
440 d3d11_device_CreateBlendState
,
441 d3d11_device_CreateDepthStencilState
,
442 d3d11_device_CreateRasterizerState
,
443 d3d11_device_CreateSamplerState
,
444 d3d11_device_CreateQuery
,
445 d3d11_device_CreatePredicate
,
446 d3d11_device_CreateCounter
,
447 d3d11_device_CreateDeferredContext
,
448 d3d11_device_OpenSharedResource
,
449 d3d11_device_CheckFormatSupport
,
450 d3d11_device_CheckMultisampleQualityLevels
,
451 d3d11_device_CheckCounterInfo
,
452 d3d11_device_CheckCounter
,
453 d3d11_device_CheckFeatureSupport
,
454 d3d11_device_GetPrivateData
,
455 d3d11_device_SetPrivateData
,
456 d3d11_device_SetPrivateDataInterface
,
457 d3d11_device_GetFeatureLevel
,
458 d3d11_device_GetCreationFlags
,
459 d3d11_device_GetDeviceRemovedReason
,
460 d3d11_device_GetImmediateContext
,
461 d3d11_device_SetExceptionMode
,
462 d3d11_device_GetExceptionMode
,
465 /* Inner IUnknown methods */
467 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
469 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
472 static HRESULT STDMETHODCALLTYPE
d3d10_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
474 struct d3d_device
*device
= impl_from_IUnknown(iface
);
476 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
478 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
479 || IsEqualGUID(riid
, &IID_IUnknown
))
481 *out
= &device
->ID3D11Device_iface
;
483 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
484 || IsEqualGUID(riid
, &IID_ID3D10Device
))
486 *out
= &device
->ID3D10Device1_iface
;
488 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
490 *out
= &device
->ID3D10Multithread_iface
;
492 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
494 *out
= &device
->IWineDXGIDeviceParent_iface
;
498 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
500 return E_NOINTERFACE
;
503 IUnknown_AddRef((IUnknown
*)*out
);
507 static ULONG STDMETHODCALLTYPE
d3d10_device_inner_AddRef(IUnknown
*iface
)
509 struct d3d_device
*This
= impl_from_IUnknown(iface
);
510 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
512 TRACE("%p increasing refcount to %u\n", This
, refcount
);
517 static ULONG STDMETHODCALLTYPE
d3d10_device_inner_Release(IUnknown
*iface
)
519 struct d3d_device
*device
= impl_from_IUnknown(iface
);
520 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
522 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
526 if (device
->wined3d_device
)
528 wined3d_mutex_lock();
529 wined3d_device_decref(device
->wined3d_device
);
530 wined3d_mutex_unlock();
532 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
533 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
534 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
535 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
541 /* IUnknown methods */
543 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
546 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
547 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
550 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
552 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
553 return IUnknown_AddRef(This
->outer_unk
);
556 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
558 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
559 return IUnknown_Release(This
->outer_unk
);
562 /* ID3D10Device methods */
564 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
565 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
567 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
570 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
571 iface
, start_slot
, buffer_count
, buffers
);
573 wined3d_mutex_lock();
574 for (i
= 0; i
< buffer_count
; ++i
)
576 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
578 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
579 buffer
? buffer
->wined3d_buffer
: NULL
);
581 wined3d_mutex_unlock();
584 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
585 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
587 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
590 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
591 iface
, start_slot
, view_count
, views
);
593 wined3d_mutex_lock();
594 for (i
= 0; i
< view_count
; ++i
)
596 struct d3d10_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
598 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
599 view
? view
->wined3d_view
: NULL
);
601 wined3d_mutex_unlock();
604 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
605 ID3D10PixelShader
*shader
)
607 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
608 struct d3d10_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
610 TRACE("iface %p, shader %p\n", iface
, shader
);
612 wined3d_mutex_lock();
613 wined3d_device_set_pixel_shader(This
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
614 wined3d_mutex_unlock();
617 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
618 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
620 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
623 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
624 iface
, start_slot
, sampler_count
, samplers
);
626 wined3d_mutex_lock();
627 for (i
= 0; i
< sampler_count
; ++i
)
629 struct d3d10_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
631 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
632 sampler
? sampler
->wined3d_sampler
: NULL
);
634 wined3d_mutex_unlock();
637 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
638 ID3D10VertexShader
*shader
)
640 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
641 struct d3d10_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
643 TRACE("iface %p, shader %p\n", iface
, shader
);
645 wined3d_mutex_lock();
646 wined3d_device_set_vertex_shader(This
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
647 wined3d_mutex_unlock();
650 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
651 UINT start_index_location
, INT base_vertex_location
)
653 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
655 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
656 iface
, index_count
, start_index_location
, base_vertex_location
);
658 wined3d_mutex_lock();
659 wined3d_device_set_base_vertex_index(This
->wined3d_device
, base_vertex_location
);
660 wined3d_device_draw_indexed_primitive(This
->wined3d_device
, start_index_location
, index_count
);
661 wined3d_mutex_unlock();
664 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
665 UINT start_vertex_location
)
667 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
669 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
670 iface
, vertex_count
, start_vertex_location
);
672 wined3d_mutex_lock();
673 wined3d_device_draw_primitive(This
->wined3d_device
, start_vertex_location
, vertex_count
);
674 wined3d_mutex_unlock();
677 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
678 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
680 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
683 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
684 iface
, start_slot
, buffer_count
, buffers
);
686 wined3d_mutex_lock();
687 for (i
= 0; i
< buffer_count
; ++i
)
689 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
691 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
692 buffer
? buffer
->wined3d_buffer
: NULL
);
694 wined3d_mutex_unlock();
697 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
698 ID3D10InputLayout
*input_layout
)
700 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
701 struct d3d10_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
703 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
705 wined3d_mutex_lock();
706 wined3d_device_set_vertex_declaration(This
->wined3d_device
,
707 layout
? layout
->wined3d_decl
: NULL
);
708 wined3d_mutex_unlock();
711 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
712 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
714 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
717 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
718 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
720 wined3d_mutex_lock();
721 for (i
= 0; i
< buffer_count
; ++i
)
723 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
725 wined3d_device_set_stream_source(This
->wined3d_device
, start_slot
+ i
,
726 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
728 wined3d_mutex_unlock();
731 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
732 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
734 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
735 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
737 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
738 iface
, buffer
, debug_dxgi_format(format
), offset
);
740 wined3d_mutex_lock();
741 wined3d_device_set_index_buffer(This
->wined3d_device
,
742 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
743 wined3dformat_from_dxgi_format(format
));
744 wined3d_mutex_unlock();
745 if (offset
) FIXME("offset %u not supported.\n", offset
);
748 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
749 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
750 INT base_vertex_location
, UINT start_instance_location
)
752 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
754 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
755 "base_vertex_location %d, start_instance_location %u.\n",
756 iface
, instance_index_count
, instance_count
, start_index_location
,
757 base_vertex_location
, start_instance_location
);
759 wined3d_mutex_lock();
760 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
761 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
762 instance_index_count
, start_instance_location
, instance_count
);
763 wined3d_mutex_unlock();
766 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
767 UINT instance_vertex_count
, UINT instance_count
,
768 UINT start_vertex_location
, UINT start_instance_location
)
770 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
772 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
773 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
774 start_vertex_location
, start_instance_location
);
776 wined3d_mutex_lock();
777 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
778 instance_vertex_count
, start_instance_location
, instance_count
);
779 wined3d_mutex_unlock();
782 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
783 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
785 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
788 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
789 iface
, start_slot
, buffer_count
, buffers
);
791 wined3d_mutex_lock();
792 for (i
= 0; i
< buffer_count
; ++i
)
794 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
796 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
797 buffer
? buffer
->wined3d_buffer
: NULL
);
799 wined3d_mutex_unlock();
802 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
804 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
805 struct d3d10_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
807 TRACE("iface %p, shader %p.\n", iface
, shader
);
809 wined3d_mutex_lock();
810 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
811 wined3d_mutex_unlock();
814 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
815 D3D10_PRIMITIVE_TOPOLOGY topology
)
817 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
819 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
821 wined3d_mutex_lock();
822 wined3d_device_set_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
823 wined3d_mutex_unlock();
826 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
827 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
829 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
832 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
833 iface
, start_slot
, view_count
, views
);
835 wined3d_mutex_lock();
836 for (i
= 0; i
< view_count
; ++i
)
838 struct d3d10_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
840 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
841 view
? view
->wined3d_view
: NULL
);
843 wined3d_mutex_unlock();
846 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
847 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
849 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
852 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
853 iface
, start_slot
, sampler_count
, samplers
);
855 wined3d_mutex_lock();
856 for (i
= 0; i
< sampler_count
; ++i
)
858 struct d3d10_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
860 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
861 sampler
? sampler
->wined3d_sampler
: NULL
);
863 wined3d_mutex_unlock();
866 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
868 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
869 struct d3d10_query
*query
;
871 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
873 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
874 wined3d_mutex_lock();
875 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
876 wined3d_mutex_unlock();
879 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
880 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
882 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
885 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
886 iface
, start_slot
, view_count
, views
);
888 wined3d_mutex_lock();
889 for (i
= 0; i
< view_count
; ++i
)
891 struct d3d10_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
893 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
894 view
? view
->wined3d_view
: NULL
);
896 wined3d_mutex_unlock();
899 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
900 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
902 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
905 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
906 iface
, start_slot
, sampler_count
, samplers
);
908 wined3d_mutex_lock();
909 for (i
= 0; i
< sampler_count
; ++i
)
911 struct d3d10_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
913 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
914 sampler
? sampler
->wined3d_sampler
: NULL
);
916 wined3d_mutex_unlock();
919 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
920 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
921 ID3D10DepthStencilView
*depth_stencil_view
)
923 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
924 struct d3d_depthstencil_view
*dsv
;
927 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
928 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
930 wined3d_mutex_lock();
931 for (i
= 0; i
< render_target_view_count
; ++i
)
933 struct d3d10_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
935 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
936 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
938 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
940 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
943 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
944 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
945 dsv
? dsv
->wined3d_view
: NULL
);
946 wined3d_mutex_unlock();
949 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
950 ID3D10BlendState
*blend_state
, const FLOAT blend_factor
[4], UINT sample_mask
)
952 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
953 const D3D10_BLEND_DESC
*desc
;
955 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
956 iface
, blend_state
, blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3], sample_mask
);
958 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
959 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
960 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
961 wined3d_mutex_lock();
962 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
963 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
964 if (!(device
->blend_state
= unsafe_impl_from_ID3D10BlendState(blend_state
)))
966 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
967 wined3d_device_set_render_state(device
->wined3d_device
,
968 WINED3D_RS_COLORWRITEENABLE
, D3D10_COLOR_WRITE_ENABLE_ALL
);
969 wined3d_device_set_render_state(device
->wined3d_device
,
970 WINED3D_RS_COLORWRITEENABLE1
, D3D10_COLOR_WRITE_ENABLE_ALL
);
971 wined3d_device_set_render_state(device
->wined3d_device
,
972 WINED3D_RS_COLORWRITEENABLE2
, D3D10_COLOR_WRITE_ENABLE_ALL
);
973 wined3d_device_set_render_state(device
->wined3d_device
,
974 WINED3D_RS_COLORWRITEENABLE3
, D3D10_COLOR_WRITE_ENABLE_ALL
);
975 wined3d_mutex_unlock();
979 desc
= &device
->blend_state
->desc
;
980 /* glSampleCoverage() */
981 if (desc
->AlphaToCoverageEnable
)
982 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
983 /* glEnableIndexedEXT(GL_BLEND, ...) */
984 FIXME("Per-rendertarget blend enable not implemented.\n");
985 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, desc
->BlendEnable
[0]);
986 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
, desc
->SrcBlend
);
987 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
, desc
->DestBlend
);
988 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
, desc
->BlendOp
);
989 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
990 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
, desc
->SrcBlendAlpha
);
991 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
, desc
->DestBlendAlpha
);
992 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
, desc
->BlendOpAlpha
);
993 FIXME("Color mask > 3 not implemented.\n");
994 wined3d_device_set_render_state(device
->wined3d_device
,
995 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTargetWriteMask
[0]);
996 wined3d_device_set_render_state(device
->wined3d_device
,
997 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTargetWriteMask
[1]);
998 wined3d_device_set_render_state(device
->wined3d_device
,
999 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTargetWriteMask
[2]);
1000 wined3d_device_set_render_state(device
->wined3d_device
,
1001 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTargetWriteMask
[3]);
1002 wined3d_mutex_unlock();
1005 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
1006 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
1008 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1010 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
1011 iface
, depth_stencil_state
, stencil_ref
);
1013 device
->depth_stencil_state
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
1014 device
->stencil_ref
= stencil_ref
;
1017 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
1018 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
1020 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1021 unsigned int count
, i
;
1023 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
1025 count
= min(target_count
, 4);
1026 wined3d_mutex_lock();
1027 for (i
= 0; i
< count
; ++i
)
1029 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
1031 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
1032 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
1035 for (i
= count
; i
< 4; ++i
)
1037 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
1039 wined3d_mutex_unlock();
1042 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
1044 FIXME("iface %p stub!\n", iface
);
1047 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
1049 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1050 const D3D10_RASTERIZER_DESC
*desc
;
1052 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1054 wined3d_mutex_lock();
1055 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
)))
1057 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
1058 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_CCW
);
1059 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
1060 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
1061 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
1062 wined3d_mutex_unlock();
1066 desc
= &device
->rasterizer_state
->desc
;
1067 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
1068 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
1070 if (desc
->FrontCounterClockwise
)
1071 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc
->FrontCounterClockwise
);
1072 /* OpenGL style depth bias. */
1073 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
1074 FIXME("Ignoring depth bias.\n");
1075 /* GL_DEPTH_CLAMP */
1076 if (!desc
->DepthClipEnable
)
1077 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
1078 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
1079 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
1080 wined3d_device_set_render_state(device
->wined3d_device
,
1081 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
1082 wined3d_mutex_unlock();
1085 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
1086 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
1088 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1089 struct wined3d_viewport wined3d_vp
;
1091 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
1093 if (viewport_count
> 1)
1094 FIXME("Multiple viewports not implemented.\n");
1096 if (!viewport_count
)
1099 wined3d_vp
.x
= viewports
[0].TopLeftX
;
1100 wined3d_vp
.y
= viewports
[0].TopLeftY
;
1101 wined3d_vp
.width
= viewports
[0].Width
;
1102 wined3d_vp
.height
= viewports
[0].Height
;
1103 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
1104 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
1106 wined3d_mutex_lock();
1107 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
1108 wined3d_mutex_unlock();
1111 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
1112 UINT rect_count
, const D3D10_RECT
*rects
)
1114 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1116 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
1119 FIXME("Multiple scissor rects not implemented.\n");
1124 wined3d_mutex_lock();
1125 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
1126 wined3d_mutex_unlock();
1129 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
1130 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
1131 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
1133 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1134 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1135 struct wined3d_box wined3d_src_box
;
1137 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
1138 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
1139 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
1140 src_resource
, src_subresource_idx
, src_box
);
1142 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
1143 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
1144 wined3d_src_box
.left
= src_box
->left
;
1145 wined3d_src_box
.top
= src_box
->top
;
1146 wined3d_src_box
.front
= src_box
->front
;
1147 wined3d_src_box
.right
= src_box
->right
;
1148 wined3d_src_box
.bottom
= src_box
->bottom
;
1149 wined3d_src_box
.back
= src_box
->back
;
1150 wined3d_mutex_lock();
1151 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
1152 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, &wined3d_src_box
);
1153 wined3d_mutex_unlock();
1156 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
1157 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
1159 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1160 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1162 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1164 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
1165 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
1166 wined3d_mutex_lock();
1167 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1168 wined3d_mutex_unlock();
1171 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
1172 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
1173 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1175 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1176 struct wined3d_resource
*wined3d_resource
;
1177 struct wined3d_box wined3d_box
;
1179 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1180 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1184 wined3d_box
.left
= box
->left
;
1185 wined3d_box
.top
= box
->top
;
1186 wined3d_box
.front
= box
->front
;
1187 wined3d_box
.right
= box
->right
;
1188 wined3d_box
.bottom
= box
->bottom
;
1189 wined3d_box
.back
= box
->back
;
1192 wined3d_resource
= wined3d_resource_from_d3d10_resource(resource
);
1193 wined3d_mutex_lock();
1194 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1195 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
1196 wined3d_mutex_unlock();
1199 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
1200 ID3D10RenderTargetView
*render_target_view
, const FLOAT color_rgba
[4])
1202 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1203 struct d3d10_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
1204 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1207 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
1208 iface
, render_target_view
, color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]);
1210 wined3d_mutex_lock();
1211 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
, &color
)))
1212 ERR("Failed to clear view, hr %#x.\n", hr
);
1213 wined3d_mutex_unlock();
1216 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
1217 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1219 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
1220 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1223 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
1224 ID3D10ShaderResourceView
*shader_resource_view
)
1226 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
1229 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
1230 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
1231 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
1233 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
1234 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
1235 iface
, dst_resource
, dst_subresource_idx
,
1236 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1239 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
1240 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
1242 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1245 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1246 iface
, start_slot
, buffer_count
, buffers
);
1248 wined3d_mutex_lock();
1249 for (i
= 0; i
< buffer_count
; ++i
)
1251 struct wined3d_buffer
*wined3d_buffer
;
1252 struct d3d_buffer
*buffer_impl
;
1254 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1260 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1261 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1262 ID3D10Buffer_AddRef(buffers
[i
]);
1264 wined3d_mutex_unlock();
1267 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
1268 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
1270 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1273 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1274 iface
, start_slot
, view_count
, views
);
1276 wined3d_mutex_lock();
1277 for (i
= 0; i
< view_count
; ++i
)
1279 struct wined3d_shader_resource_view
*wined3d_view
;
1280 struct d3d10_shader_resource_view
*view_impl
;
1282 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1288 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1289 views
[i
] = &view_impl
->ID3D10ShaderResourceView_iface
;
1290 ID3D10ShaderResourceView_AddRef(views
[i
]);
1292 wined3d_mutex_unlock();
1295 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
1297 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1298 struct d3d10_pixel_shader
*shader_impl
;
1299 struct wined3d_shader
*wined3d_shader
;
1301 TRACE("iface %p, shader %p.\n", iface
, shader
);
1303 wined3d_mutex_lock();
1304 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1306 wined3d_mutex_unlock();
1311 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1312 wined3d_mutex_unlock();
1313 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
1314 ID3D10PixelShader_AddRef(*shader
);
1317 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
1318 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
1320 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1323 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1324 iface
, start_slot
, sampler_count
, samplers
);
1326 wined3d_mutex_lock();
1327 for (i
= 0; i
< sampler_count
; ++i
)
1329 struct d3d10_sampler_state
*sampler_impl
;
1330 struct wined3d_sampler
*wined3d_sampler
;
1332 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1338 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1339 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
1340 ID3D10SamplerState_AddRef(samplers
[i
]);
1342 wined3d_mutex_unlock();
1345 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
1347 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1348 struct d3d10_vertex_shader
*shader_impl
;
1349 struct wined3d_shader
*wined3d_shader
;
1351 TRACE("iface %p, shader %p.\n", iface
, shader
);
1353 wined3d_mutex_lock();
1354 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1356 wined3d_mutex_unlock();
1361 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1362 wined3d_mutex_unlock();
1363 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
1364 ID3D10VertexShader_AddRef(*shader
);
1367 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
1368 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
1370 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1373 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1374 iface
, start_slot
, buffer_count
, buffers
);
1376 wined3d_mutex_lock();
1377 for (i
= 0; i
< buffer_count
; ++i
)
1379 struct wined3d_buffer
*wined3d_buffer
;
1380 struct d3d_buffer
*buffer_impl
;
1382 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1388 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1389 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1390 ID3D10Buffer_AddRef(buffers
[i
]);
1392 wined3d_mutex_unlock();
1395 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
1397 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1398 struct wined3d_vertex_declaration
*wined3d_declaration
;
1399 struct d3d10_input_layout
*input_layout_impl
;
1401 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1403 wined3d_mutex_lock();
1404 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1406 wined3d_mutex_unlock();
1407 *input_layout
= NULL
;
1411 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1412 wined3d_mutex_unlock();
1413 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
1414 ID3D10InputLayout_AddRef(*input_layout
);
1417 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
1418 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1420 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1423 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1424 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1426 wined3d_mutex_lock();
1427 for (i
= 0; i
< buffer_count
; ++i
)
1429 struct wined3d_buffer
*wined3d_buffer
;
1430 struct d3d_buffer
*buffer_impl
;
1432 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1433 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1434 ERR("Failed to get vertex buffer.\n");
1436 if (!wined3d_buffer
)
1442 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1443 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1444 ID3D10Buffer_AddRef(buffers
[i
]);
1446 wined3d_mutex_unlock();
1449 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
1450 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1452 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1453 enum wined3d_format_id wined3d_format
;
1454 struct wined3d_buffer
*wined3d_buffer
;
1455 struct d3d_buffer
*buffer_impl
;
1457 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1459 wined3d_mutex_lock();
1460 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
);
1461 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1462 *offset
= 0; /* FIXME */
1463 if (!wined3d_buffer
)
1465 wined3d_mutex_unlock();
1470 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1471 wined3d_mutex_unlock();
1472 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
1473 ID3D10Buffer_AddRef(*buffer
);
1476 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
1477 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
1479 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1482 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1483 iface
, start_slot
, buffer_count
, buffers
);
1485 wined3d_mutex_lock();
1486 for (i
= 0; i
< buffer_count
; ++i
)
1488 struct wined3d_buffer
*wined3d_buffer
;
1489 struct d3d_buffer
*buffer_impl
;
1491 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1497 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1498 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1499 ID3D10Buffer_AddRef(buffers
[i
]);
1501 wined3d_mutex_unlock();
1504 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
1506 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1507 struct d3d10_geometry_shader
*shader_impl
;
1508 struct wined3d_shader
*wined3d_shader
;
1510 TRACE("iface %p, shader %p.\n", iface
, shader
);
1512 wined3d_mutex_lock();
1513 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1515 wined3d_mutex_unlock();
1520 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1521 wined3d_mutex_unlock();
1522 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
1523 ID3D10GeometryShader_AddRef(*shader
);
1526 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
1527 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
1529 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
1531 TRACE("iface %p, topology %p\n", iface
, topology
);
1533 wined3d_mutex_lock();
1534 wined3d_device_get_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1535 wined3d_mutex_unlock();
1538 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
1539 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
1541 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1544 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1545 iface
, start_slot
, view_count
, views
);
1547 wined3d_mutex_lock();
1548 for (i
= 0; i
< view_count
; ++i
)
1550 struct wined3d_shader_resource_view
*wined3d_view
;
1551 struct d3d10_shader_resource_view
*view_impl
;
1553 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1559 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1560 views
[i
] = &view_impl
->ID3D10ShaderResourceView_iface
;
1561 ID3D10ShaderResourceView_AddRef(views
[i
]);
1563 wined3d_mutex_unlock();
1566 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
1567 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
1569 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1572 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1573 iface
, start_slot
, sampler_count
, samplers
);
1575 wined3d_mutex_lock();
1576 for (i
= 0; i
< sampler_count
; ++i
)
1578 struct d3d10_sampler_state
*sampler_impl
;
1579 struct wined3d_sampler
*wined3d_sampler
;
1581 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1587 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1588 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
1589 ID3D10SamplerState_AddRef(samplers
[i
]);
1591 wined3d_mutex_unlock();
1594 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
1595 ID3D10Predicate
**predicate
, BOOL
*value
)
1597 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1598 struct wined3d_query
*wined3d_predicate
;
1599 struct d3d10_query
*predicate_impl
;
1601 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1603 wined3d_mutex_lock();
1604 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1606 wined3d_mutex_unlock();
1611 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1612 wined3d_mutex_unlock();
1613 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
1614 ID3D10Predicate_AddRef(*predicate
);
1617 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
1618 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
1620 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1623 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1624 iface
, start_slot
, view_count
, views
);
1626 wined3d_mutex_lock();
1627 for (i
= 0; i
< view_count
; ++i
)
1629 struct wined3d_shader_resource_view
*wined3d_view
;
1630 struct d3d10_shader_resource_view
*view_impl
;
1632 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1638 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1639 views
[i
] = &view_impl
->ID3D10ShaderResourceView_iface
;
1640 ID3D10ShaderResourceView_AddRef(views
[i
]);
1642 wined3d_mutex_unlock();
1645 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
1646 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
1648 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1651 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1652 iface
, start_slot
, sampler_count
, samplers
);
1654 wined3d_mutex_lock();
1655 for (i
= 0; i
< sampler_count
; ++i
)
1657 struct d3d10_sampler_state
*sampler_impl
;
1658 struct wined3d_sampler
*wined3d_sampler
;
1660 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1666 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1667 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
1668 ID3D10SamplerState_AddRef(samplers
[i
]);
1670 wined3d_mutex_unlock();
1673 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
1674 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
1676 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1677 struct wined3d_rendertarget_view
*wined3d_view
;
1679 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1680 iface
, view_count
, render_target_views
, depth_stencil_view
);
1682 wined3d_mutex_lock();
1683 if (render_target_views
)
1685 struct d3d10_rendertarget_view
*view_impl
;
1688 for (i
= 0; i
< view_count
; ++i
)
1690 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1691 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1693 render_target_views
[i
] = NULL
;
1697 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
1698 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
1702 if (depth_stencil_view
)
1704 struct d3d_depthstencil_view
*view_impl
;
1706 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1707 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1709 *depth_stencil_view
= NULL
;
1713 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
1714 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
1717 wined3d_mutex_unlock();
1720 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
1721 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1723 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1725 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1726 iface
, blend_state
, blend_factor
, sample_mask
);
1728 if ((*blend_state
= device
->blend_state
? &device
->blend_state
->ID3D10BlendState_iface
: NULL
))
1729 ID3D10BlendState_AddRef(*blend_state
);
1730 wined3d_mutex_lock();
1731 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
1732 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1733 wined3d_mutex_unlock();
1736 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
1737 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1739 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1741 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1742 iface
, depth_stencil_state
, stencil_ref
);
1744 if ((*depth_stencil_state
= device
->depth_stencil_state
1745 ? &device
->depth_stencil_state
->ID3D10DepthStencilState_iface
: NULL
))
1746 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
1747 *stencil_ref
= device
->stencil_ref
;
1750 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
1751 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
1753 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1756 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1757 iface
, buffer_count
, buffers
, offsets
);
1759 wined3d_mutex_lock();
1760 for (i
= 0; i
< buffer_count
; ++i
)
1762 struct wined3d_buffer
*wined3d_buffer
;
1763 struct d3d_buffer
*buffer_impl
;
1765 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
1771 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1772 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1773 ID3D10Buffer_AddRef(buffers
[i
]);
1775 wined3d_mutex_unlock();
1778 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
1780 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1782 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1784 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
1785 ID3D10RasterizerState_AddRef(*rasterizer_state
);
1788 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
1789 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
1791 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1792 struct wined3d_viewport wined3d_vp
;
1794 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1798 *viewport_count
= 1;
1802 if (!*viewport_count
)
1805 wined3d_mutex_lock();
1806 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1807 wined3d_mutex_unlock();
1809 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1810 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1811 viewports
[0].Width
= wined3d_vp
.width
;
1812 viewports
[0].Height
= wined3d_vp
.height
;
1813 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1814 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1816 if (*viewport_count
> 1)
1817 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1820 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
1822 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1824 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
1835 wined3d_mutex_lock();
1836 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
1837 wined3d_mutex_unlock();
1838 if (*rect_count
> 1)
1839 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
1842 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
1844 TRACE("iface %p.\n", iface
);
1846 /* In the current implementation the device is never removed, so we can
1847 * just return S_OK here. */
1852 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
1854 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
1859 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
1861 FIXME("iface %p stub!\n", iface
);
1866 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
1867 REFGUID guid
, UINT
*data_size
, void *data
)
1869 IDXGIDevice
*dxgi_device
;
1872 TRACE("iface %p, guid %s, data_size %p, data %p.\n",
1873 iface
, debugstr_guid(guid
), data_size
, data
);
1875 if (FAILED(hr
= ID3D10Device1_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
1877 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
1878 IDXGIDevice_Release(dxgi_device
);
1883 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
1884 REFGUID guid
, UINT data_size
, const void *data
)
1886 IDXGIDevice
*dxgi_device
;
1889 TRACE("iface %p, guid %s, data_size %u, data %p.\n",
1890 iface
, debugstr_guid(guid
), data_size
, data
);
1892 if (FAILED(hr
= ID3D10Device1_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
1894 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
1895 IDXGIDevice_Release(dxgi_device
);
1900 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
1901 REFGUID guid
, const IUnknown
*data
)
1903 IDXGIDevice
*dxgi_device
;
1906 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
1908 if (FAILED(hr
= ID3D10Device1_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
1910 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
1911 IDXGIDevice_Release(dxgi_device
);
1916 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
1918 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
1919 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1922 TRACE("iface %p.\n", iface
);
1924 wined3d_mutex_lock();
1925 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
1926 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
1928 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
1930 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1932 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
1934 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
1936 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
1938 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
1939 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
1941 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
1943 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1945 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
1947 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
1949 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
1951 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
1952 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
1954 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
1956 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1958 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
1960 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
1962 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
1964 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1966 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
1968 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
);
1969 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
1970 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
1971 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
1973 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
1975 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
1976 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
1977 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
1978 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
1979 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
1980 ID3D10Device1_RSSetState(iface
, NULL
);
1981 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
1983 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
1985 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
1986 wined3d_mutex_unlock();
1989 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
1991 FIXME("iface %p stub!\n", iface
);
1994 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
1995 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
1997 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1998 D3D11_BUFFER_DESC d3d11_desc
;
1999 struct d3d_buffer
*object
;
2002 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2004 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
2005 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
2006 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
2007 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
2008 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
2009 d3d11_desc
.StructureByteStride
= 0;
2011 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
2014 *buffer
= &object
->ID3D10Buffer_iface
;
2019 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
2020 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
2022 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2027 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
2028 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
2029 ID3D10Texture2D
**texture
)
2031 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2032 D3D11_TEXTURE2D_DESC d3d11_desc
;
2033 struct d3d_texture2d
*object
;
2036 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2038 d3d11_desc
.Width
= desc
->Width
;
2039 d3d11_desc
.Height
= desc
->Height
;
2040 d3d11_desc
.MipLevels
= desc
->MipLevels
;
2041 d3d11_desc
.ArraySize
= desc
->ArraySize
;
2042 d3d11_desc
.Format
= desc
->Format
;
2043 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
2044 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
2045 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
2046 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
2047 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
2049 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
2052 *texture
= &object
->ID3D10Texture2D_iface
;
2057 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
2058 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
2059 ID3D10Texture3D
**texture
)
2061 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2062 D3D11_TEXTURE3D_DESC d3d11_desc
;
2063 struct d3d_texture3d
*object
;
2066 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2068 d3d11_desc
.Width
= desc
->Width
;
2069 d3d11_desc
.Height
= desc
->Height
;
2070 d3d11_desc
.Depth
= desc
->Depth
;
2071 d3d11_desc
.MipLevels
= desc
->MipLevels
;
2072 d3d11_desc
.Format
= desc
->Format
;
2073 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
2074 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
2075 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
2076 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
2078 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
2081 *texture
= &object
->ID3D10Texture3D_iface
;
2086 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
2087 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
2089 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2090 struct d3d10_shader_resource_view
*object
;
2093 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2095 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2096 return E_OUTOFMEMORY
;
2098 if (FAILED(hr
= d3d10_shader_resource_view_init(object
, device
, resource
, desc
)))
2100 WARN("Failed to initialize shader resource view, hr %#x.\n", hr
);
2101 HeapFree(GetProcessHeap(), 0, object
);
2105 TRACE("Created shader resource view %p.\n", object
);
2106 *view
= &object
->ID3D10ShaderResourceView_iface
;
2111 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
2112 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
2114 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2115 struct d3d10_rendertarget_view
*object
;
2118 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2120 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2121 return E_OUTOFMEMORY
;
2123 if (FAILED(hr
= d3d10_rendertarget_view_init(object
, device
, resource
, desc
)))
2125 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr
);
2126 HeapFree(GetProcessHeap(), 0, object
);
2130 TRACE("Created rendertarget view %p.\n", object
);
2131 *view
= &object
->ID3D10RenderTargetView_iface
;
2136 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
2137 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
2139 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2140 struct d3d_depthstencil_view
*object
;
2141 ID3D11Resource
*d3d11_resource
;
2144 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2146 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2147 return E_OUTOFMEMORY
;
2149 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
2151 ERR("Resource does not implement ID3D11Resource.\n");
2152 HeapFree(GetProcessHeap(), 0, object
);
2156 if (FAILED(hr
= d3d_depthstencil_view_init(object
, device
, d3d11_resource
, desc
)))
2158 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr
);
2159 HeapFree(GetProcessHeap(), 0, object
);
2160 ID3D11Resource_Release(d3d11_resource
);
2164 ID3D11Resource_Release(d3d11_resource
);
2166 TRACE("Created depthstencil view %p.\n", object
);
2167 *view
= &object
->ID3D10DepthStencilView_iface
;
2172 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
2173 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
2174 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
2175 ID3D10InputLayout
**input_layout
)
2177 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2178 struct d3d10_input_layout
*object
;
2181 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
2182 "shader_byte_code_length %lu, input_layout %p\n",
2183 iface
, element_descs
, element_count
, shader_byte_code
,
2184 shader_byte_code_length
, input_layout
);
2186 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2188 return E_OUTOFMEMORY
;
2190 hr
= d3d10_input_layout_init(object
, This
, element_descs
, element_count
,
2191 shader_byte_code
, shader_byte_code_length
);
2194 WARN("Failed to initialize input layout, hr %#x.\n", hr
);
2195 HeapFree(GetProcessHeap(), 0, object
);
2199 TRACE("Created input layout %p.\n", object
);
2200 *input_layout
= &object
->ID3D10InputLayout_iface
;
2205 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
2206 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
2208 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2209 struct d3d10_vertex_shader
*object
;
2212 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
2213 iface
, byte_code
, byte_code_length
, shader
);
2215 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2217 return E_OUTOFMEMORY
;
2219 hr
= d3d10_vertex_shader_init(object
, This
, byte_code
, byte_code_length
);
2222 WARN("Failed to initialize vertex shader, hr %#x.\n", hr
);
2223 HeapFree(GetProcessHeap(), 0, object
);
2227 TRACE("Created vertex shader %p.\n", object
);
2228 *shader
= &object
->ID3D10VertexShader_iface
;
2233 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
2234 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
2236 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2237 struct d3d10_geometry_shader
*object
;
2240 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
2241 iface
, byte_code
, byte_code_length
, shader
);
2243 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2245 return E_OUTOFMEMORY
;
2247 hr
= d3d10_geometry_shader_init(object
, This
, byte_code
, byte_code_length
);
2250 WARN("Failed to initialize geometry shader, hr %#x.\n", hr
);
2251 HeapFree(GetProcessHeap(), 0, object
);
2255 TRACE("Created geometry shader %p.\n", object
);
2256 *shader
= &object
->ID3D10GeometryShader_iface
;
2261 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
2262 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
2263 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
2265 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
2266 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
2267 iface
, byte_code
, byte_code_length
, output_stream_decls
,
2268 output_stream_decl_count
, output_stream_stride
, shader
);
2273 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
2274 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
2276 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2277 struct d3d10_pixel_shader
*object
;
2280 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
2281 iface
, byte_code
, byte_code_length
, shader
);
2283 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2285 return E_OUTOFMEMORY
;
2287 hr
= d3d10_pixel_shader_init(object
, This
, byte_code
, byte_code_length
);
2290 WARN("Failed to initialize pixel shader, hr %#x.\n", hr
);
2291 HeapFree(GetProcessHeap(), 0, object
);
2295 TRACE("Created pixel shader %p.\n", object
);
2296 *shader
= &object
->ID3D10PixelShader_iface
;
2301 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
2302 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
2304 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2305 struct d3d10_blend_state
*object
;
2306 struct wine_rb_entry
*entry
;
2309 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2312 return E_INVALIDARG
;
2314 wined3d_mutex_lock();
2315 if ((entry
= wine_rb_get(&device
->blend_states
, desc
)))
2317 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_blend_state
, entry
);
2319 TRACE("Returning existing blend state %p.\n", object
);
2320 *blend_state
= &object
->ID3D10BlendState_iface
;
2321 ID3D10BlendState_AddRef(*blend_state
);
2322 wined3d_mutex_unlock();
2326 wined3d_mutex_unlock();
2328 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2330 return E_OUTOFMEMORY
;
2332 if (FAILED(hr
= d3d10_blend_state_init(object
, device
, desc
)))
2334 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2335 HeapFree(GetProcessHeap(), 0, object
);
2339 TRACE("Created blend state %p.\n", object
);
2340 *blend_state
= &object
->ID3D10BlendState_iface
;
2345 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
2346 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
2348 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2349 struct d3d10_depthstencil_state
*object
;
2350 D3D10_DEPTH_STENCIL_DESC tmp_desc
;
2351 struct wine_rb_entry
*entry
;
2354 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2357 return E_INVALIDARG
;
2359 /* D3D10_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2360 * it as a key in the rbtree. */
2361 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2362 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2363 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2364 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2365 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2366 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2367 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2368 tmp_desc
.FrontFace
= desc
->FrontFace
;
2369 tmp_desc
.BackFace
= desc
->BackFace
;
2371 wined3d_mutex_lock();
2372 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2374 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_depthstencil_state
, entry
);
2376 TRACE("Returning existing depthstencil state %p.\n", object
);
2377 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
2378 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
2379 wined3d_mutex_unlock();
2383 wined3d_mutex_unlock();
2385 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2387 return E_OUTOFMEMORY
;
2389 if (FAILED(hr
= d3d10_depthstencil_state_init(object
, device
, &tmp_desc
)))
2391 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2392 HeapFree(GetProcessHeap(), 0, object
);
2396 TRACE("Created depthstencil state %p.\n", object
);
2397 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
2402 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
2403 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
2405 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2406 struct d3d10_rasterizer_state
*object
;
2407 struct wine_rb_entry
*entry
;
2410 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2413 return E_INVALIDARG
;
2415 wined3d_mutex_lock();
2416 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2418 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_rasterizer_state
, entry
);
2420 TRACE("Returning existing rasterizer state %p.\n", object
);
2421 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
2422 ID3D10RasterizerState_AddRef(*rasterizer_state
);
2423 wined3d_mutex_unlock();
2427 wined3d_mutex_unlock();
2429 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2431 return E_OUTOFMEMORY
;
2433 if (FAILED(hr
= d3d10_rasterizer_state_init(object
, device
, desc
)))
2435 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2436 HeapFree(GetProcessHeap(), 0, object
);
2440 TRACE("Created rasterizer state %p.\n", object
);
2441 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
2446 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
2447 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
2449 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2450 struct d3d10_sampler_state
*object
;
2451 struct wine_rb_entry
*entry
;
2454 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2457 return E_INVALIDARG
;
2459 wined3d_mutex_lock();
2460 if ((entry
= wine_rb_get(&device
->sampler_states
, desc
)))
2462 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_sampler_state
, entry
);
2464 TRACE("Returning existing sampler state %p.\n", object
);
2465 *sampler_state
= &object
->ID3D10SamplerState_iface
;
2466 ID3D10SamplerState_AddRef(*sampler_state
);
2467 wined3d_mutex_unlock();
2471 wined3d_mutex_unlock();
2473 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2475 return E_OUTOFMEMORY
;
2477 if (FAILED(hr
= d3d10_sampler_state_init(object
, device
, desc
)))
2479 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2480 HeapFree(GetProcessHeap(), 0, object
);
2484 TRACE("Created sampler state %p.\n", object
);
2485 *sampler_state
= &object
->ID3D10SamplerState_iface
;
2490 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
2491 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
2493 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2494 struct d3d10_query
*object
;
2497 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2499 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2500 return E_OUTOFMEMORY
;
2502 if (FAILED(hr
= d3d10_query_init(object
, device
, desc
, FALSE
)))
2504 WARN("Failed to initialize query, hr %#x.\n", hr
);
2505 HeapFree(GetProcessHeap(), 0, object
);
2509 TRACE("Created query %p.\n", object
);
2510 *query
= &object
->ID3D10Query_iface
;
2515 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
2516 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
2518 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2519 struct d3d10_query
*object
;
2522 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2525 return E_INVALIDARG
;
2527 if (desc
->Query
!= D3D10_QUERY_OCCLUSION_PREDICATE
&& desc
->Query
!= D3D10_QUERY_SO_OVERFLOW_PREDICATE
)
2529 WARN("Query type %#x is not a predicate.\n", desc
->Query
);
2530 return E_INVALIDARG
;
2533 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2534 return E_OUTOFMEMORY
;
2536 if (FAILED(hr
= d3d10_query_init(object
, device
, desc
, TRUE
)))
2538 WARN("Failed to initialize predicate, hr %#x.\n", hr
);
2539 HeapFree(GetProcessHeap(), 0, object
);
2543 TRACE("Created predicate %p.\n", object
);
2544 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
2549 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
2550 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
2552 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2557 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
2558 DXGI_FORMAT format
, UINT
*format_support
)
2560 FIXME("iface %p, format %s, format_support %p stub!\n",
2561 iface
, debug_dxgi_format(format
), format_support
);
2566 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
2567 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2569 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
2570 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2575 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
2577 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
2580 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
2581 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
2582 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2584 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
2585 "units %p, units_length %p, description %p, description_length %p stub!\n",
2586 iface
, desc
, type
, active_counters
, name
, name_length
,
2587 units
, units_length
, description
, description_length
);
2592 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
2594 FIXME("iface %p stub!\n", iface
);
2599 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
2600 HANDLE resource_handle
, REFIID guid
, void **resource
)
2602 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
2603 iface
, resource_handle
, debugstr_guid(guid
), resource
);
2608 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
2610 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
2613 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
2615 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
2618 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
2619 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
2621 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
2626 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
2627 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
2629 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface
, desc
, blend_state
);
2634 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
2636 FIXME("iface %p stub!\n", iface
);
2638 return D3D10_FEATURE_LEVEL_10_1
;
2641 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
2643 /* IUnknown methods */
2644 d3d10_device_QueryInterface
,
2645 d3d10_device_AddRef
,
2646 d3d10_device_Release
,
2647 /* ID3D10Device methods */
2648 d3d10_device_VSSetConstantBuffers
,
2649 d3d10_device_PSSetShaderResources
,
2650 d3d10_device_PSSetShader
,
2651 d3d10_device_PSSetSamplers
,
2652 d3d10_device_VSSetShader
,
2653 d3d10_device_DrawIndexed
,
2655 d3d10_device_PSSetConstantBuffers
,
2656 d3d10_device_IASetInputLayout
,
2657 d3d10_device_IASetVertexBuffers
,
2658 d3d10_device_IASetIndexBuffer
,
2659 d3d10_device_DrawIndexedInstanced
,
2660 d3d10_device_DrawInstanced
,
2661 d3d10_device_GSSetConstantBuffers
,
2662 d3d10_device_GSSetShader
,
2663 d3d10_device_IASetPrimitiveTopology
,
2664 d3d10_device_VSSetShaderResources
,
2665 d3d10_device_VSSetSamplers
,
2666 d3d10_device_SetPredication
,
2667 d3d10_device_GSSetShaderResources
,
2668 d3d10_device_GSSetSamplers
,
2669 d3d10_device_OMSetRenderTargets
,
2670 d3d10_device_OMSetBlendState
,
2671 d3d10_device_OMSetDepthStencilState
,
2672 d3d10_device_SOSetTargets
,
2673 d3d10_device_DrawAuto
,
2674 d3d10_device_RSSetState
,
2675 d3d10_device_RSSetViewports
,
2676 d3d10_device_RSSetScissorRects
,
2677 d3d10_device_CopySubresourceRegion
,
2678 d3d10_device_CopyResource
,
2679 d3d10_device_UpdateSubresource
,
2680 d3d10_device_ClearRenderTargetView
,
2681 d3d10_device_ClearDepthStencilView
,
2682 d3d10_device_GenerateMips
,
2683 d3d10_device_ResolveSubresource
,
2684 d3d10_device_VSGetConstantBuffers
,
2685 d3d10_device_PSGetShaderResources
,
2686 d3d10_device_PSGetShader
,
2687 d3d10_device_PSGetSamplers
,
2688 d3d10_device_VSGetShader
,
2689 d3d10_device_PSGetConstantBuffers
,
2690 d3d10_device_IAGetInputLayout
,
2691 d3d10_device_IAGetVertexBuffers
,
2692 d3d10_device_IAGetIndexBuffer
,
2693 d3d10_device_GSGetConstantBuffers
,
2694 d3d10_device_GSGetShader
,
2695 d3d10_device_IAGetPrimitiveTopology
,
2696 d3d10_device_VSGetShaderResources
,
2697 d3d10_device_VSGetSamplers
,
2698 d3d10_device_GetPredication
,
2699 d3d10_device_GSGetShaderResources
,
2700 d3d10_device_GSGetSamplers
,
2701 d3d10_device_OMGetRenderTargets
,
2702 d3d10_device_OMGetBlendState
,
2703 d3d10_device_OMGetDepthStencilState
,
2704 d3d10_device_SOGetTargets
,
2705 d3d10_device_RSGetState
,
2706 d3d10_device_RSGetViewports
,
2707 d3d10_device_RSGetScissorRects
,
2708 d3d10_device_GetDeviceRemovedReason
,
2709 d3d10_device_SetExceptionMode
,
2710 d3d10_device_GetExceptionMode
,
2711 d3d10_device_GetPrivateData
,
2712 d3d10_device_SetPrivateData
,
2713 d3d10_device_SetPrivateDataInterface
,
2714 d3d10_device_ClearState
,
2716 d3d10_device_CreateBuffer
,
2717 d3d10_device_CreateTexture1D
,
2718 d3d10_device_CreateTexture2D
,
2719 d3d10_device_CreateTexture3D
,
2720 d3d10_device_CreateShaderResourceView
,
2721 d3d10_device_CreateRenderTargetView
,
2722 d3d10_device_CreateDepthStencilView
,
2723 d3d10_device_CreateInputLayout
,
2724 d3d10_device_CreateVertexShader
,
2725 d3d10_device_CreateGeometryShader
,
2726 d3d10_device_CreateGeometryShaderWithStreamOutput
,
2727 d3d10_device_CreatePixelShader
,
2728 d3d10_device_CreateBlendState
,
2729 d3d10_device_CreateDepthStencilState
,
2730 d3d10_device_CreateRasterizerState
,
2731 d3d10_device_CreateSamplerState
,
2732 d3d10_device_CreateQuery
,
2733 d3d10_device_CreatePredicate
,
2734 d3d10_device_CreateCounter
,
2735 d3d10_device_CheckFormatSupport
,
2736 d3d10_device_CheckMultisampleQualityLevels
,
2737 d3d10_device_CheckCounterInfo
,
2738 d3d10_device_CheckCounter
,
2739 d3d10_device_GetCreationFlags
,
2740 d3d10_device_OpenSharedResource
,
2741 d3d10_device_SetTextFilterSize
,
2742 d3d10_device_GetTextFilterSize
,
2743 d3d10_device_CreateShaderResourceView1
,
2744 d3d10_device_CreateBlendState1
,
2745 d3d10_device_GetFeatureLevel
,
2748 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl
=
2750 /* IUnknown methods */
2751 d3d10_device_inner_QueryInterface
,
2752 d3d10_device_inner_AddRef
,
2753 d3d10_device_inner_Release
,
2756 /* ID3D10Multithread methods */
2758 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
2760 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
2763 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
2765 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
2767 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
2769 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
2772 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
2774 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
2776 TRACE("iface %p.\n", iface
);
2778 return IUnknown_AddRef(device
->outer_unk
);
2781 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
2783 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
2785 TRACE("iface %p.\n", iface
);
2787 return IUnknown_Release(device
->outer_unk
);
2790 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
2792 TRACE("iface %p.\n", iface
);
2794 wined3d_mutex_lock();
2797 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
2799 TRACE("iface %p.\n", iface
);
2801 wined3d_mutex_unlock();
2804 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
2806 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
2811 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
2813 FIXME("iface %p stub!\n", iface
);
2818 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
2820 d3d10_multithread_QueryInterface
,
2821 d3d10_multithread_AddRef
,
2822 d3d10_multithread_Release
,
2823 d3d10_multithread_Enter
,
2824 d3d10_multithread_Leave
,
2825 d3d10_multithread_SetMultithreadProtected
,
2826 d3d10_multithread_GetMultithreadProtected
,
2829 /* IWineDXGIDeviceParent IUnknown methods */
2831 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
2833 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
2836 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
2837 REFIID riid
, void **ppv
)
2839 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2840 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
2843 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
2845 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2846 return IUnknown_AddRef(device
->outer_unk
);
2849 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
2851 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2852 return IUnknown_Release(device
->outer_unk
);
2855 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
2856 IWineDXGIDeviceParent
*iface
)
2858 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2859 return &device
->device_parent
;
2862 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl
=
2864 /* IUnknown methods */
2865 dxgi_device_parent_QueryInterface
,
2866 dxgi_device_parent_AddRef
,
2867 dxgi_device_parent_Release
,
2868 /* IWineDXGIDeviceParent methods */
2869 dxgi_device_parent_get_wined3d_device_parent
,
2872 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
2874 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
2877 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
2878 struct wined3d_device
*wined3d_device
)
2880 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
2882 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
2884 wined3d_device_incref(wined3d_device
);
2885 device
->wined3d_device
= wined3d_device
;
2888 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
2890 TRACE("device_parent %p.\n", device_parent
);
2893 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
2895 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
2898 static HRESULT CDECL
device_parent_surface_created(struct wined3d_device_parent
*device_parent
,
2899 void *container_parent
, struct wined3d_surface
*surface
, void **parent
,
2900 const struct wined3d_parent_ops
**parent_ops
)
2902 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2903 device_parent
, container_parent
, surface
, parent
, parent_ops
);
2906 *parent_ops
= &d3d10_null_wined3d_parent_ops
;
2911 static HRESULT CDECL
device_parent_volume_created(struct wined3d_device_parent
*device_parent
,
2912 void *container_parent
, struct wined3d_volume
*volume
, void **parent
,
2913 const struct wined3d_parent_ops
**parent_ops
)
2915 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2916 device_parent
, container_parent
, volume
, parent
, parent_ops
);
2919 *parent_ops
= &d3d10_null_wined3d_parent_ops
;
2924 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
2925 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
2926 struct wined3d_texture
**wined3d_texture
)
2928 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
2929 struct d3d_texture2d
*texture
;
2930 ID3D10Texture2D
*texture_iface
;
2931 D3D10_TEXTURE2D_DESC desc
;
2934 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
2935 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
2937 FIXME("Implement DXGI<->wined3d usage conversion\n");
2939 desc
.Width
= wined3d_desc
->width
;
2940 desc
.Height
= wined3d_desc
->height
;
2943 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
2944 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
2945 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
2946 desc
.Usage
= D3D10_USAGE_DEFAULT
;
2947 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
2948 desc
.CPUAccessFlags
= 0;
2951 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
2952 &desc
, NULL
, &texture_iface
)))
2954 ERR("CreateTexture2D failed, returning %#x\n", hr
);
2958 texture
= impl_from_ID3D10Texture2D(texture_iface
);
2960 *wined3d_texture
= texture
->wined3d_texture
;
2961 wined3d_texture_incref(*wined3d_texture
);
2962 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
2967 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
2968 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
2970 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
2971 IWineDXGIDevice
*wine_device
;
2974 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
2976 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
2977 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
2979 ERR("Device should implement IWineDXGIDevice.\n");
2983 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, swapchain
);
2984 IWineDXGIDevice_Release(wine_device
);
2987 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
2994 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops
=
2996 device_parent_wined3d_device_created
,
2997 device_parent_mode_changed
,
2998 device_parent_activate
,
2999 device_parent_surface_created
,
3000 device_parent_volume_created
,
3001 device_parent_create_swapchain_texture
,
3002 device_parent_create_swapchain
,
3005 static void *d3d10_rb_alloc(size_t size
)
3007 return HeapAlloc(GetProcessHeap(), 0, size
);
3010 static void *d3d10_rb_realloc(void *ptr
, size_t size
)
3012 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
3015 static void d3d10_rb_free(void *ptr
)
3017 HeapFree(GetProcessHeap(), 0, ptr
);
3020 static int d3d10_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3022 const D3D10_SAMPLER_DESC
*ka
= key
;
3023 const D3D10_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_sampler_state
, entry
)->desc
;
3025 return memcmp(ka
, kb
, sizeof(*ka
));
3028 static const struct wine_rb_functions d3d10_sampler_state_rb_ops
=
3033 d3d10_sampler_state_compare
,
3036 static int d3d10_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3038 const D3D10_BLEND_DESC
*ka
= key
;
3039 const D3D10_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_blend_state
, entry
)->desc
;
3041 return memcmp(ka
, kb
, sizeof(*ka
));
3044 static const struct wine_rb_functions d3d10_blend_state_rb_ops
=
3049 d3d10_blend_state_compare
,
3052 static int d3d10_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3054 const D3D10_DEPTH_STENCIL_DESC
*ka
= key
;
3055 const D3D10_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
3056 const struct d3d10_depthstencil_state
, entry
)->desc
;
3058 return memcmp(ka
, kb
, sizeof(*ka
));
3061 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops
=
3066 d3d10_depthstencil_state_compare
,
3069 static int d3d10_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3071 const D3D10_RASTERIZER_DESC
*ka
= key
;
3072 const D3D10_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_rasterizer_state
, entry
)->desc
;
3074 return memcmp(ka
, kb
, sizeof(*ka
));
3077 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops
=
3082 d3d10_rasterizer_state_compare
,
3085 HRESULT
d3d10_device_init(struct d3d_device
*device
, void *outer_unknown
)
3087 device
->IUnknown_inner
.lpVtbl
= &d3d10_device_inner_unknown_vtbl
;
3088 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
3089 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
3090 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
3091 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d10_dxgi_device_parent_vtbl
;
3092 device
->device_parent
.ops
= &d3d10_wined3d_device_parent_ops
;
3093 device
->refcount
= 1;
3094 /* COM aggregation always takes place */
3095 device
->outer_unk
= outer_unknown
;
3097 if (wine_rb_init(&device
->blend_states
, &d3d10_blend_state_rb_ops
) == -1)
3099 WARN("Failed to initialize blend state rbtree.\n");
3102 device
->blend_factor
[0] = 1.0f
;
3103 device
->blend_factor
[1] = 1.0f
;
3104 device
->blend_factor
[2] = 1.0f
;
3105 device
->blend_factor
[3] = 1.0f
;
3107 if (wine_rb_init(&device
->depthstencil_states
, &d3d10_depthstencil_state_rb_ops
) == -1)
3109 WARN("Failed to initialize depthstencil state rbtree.\n");
3110 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3114 if (wine_rb_init(&device
->rasterizer_states
, &d3d10_rasterizer_state_rb_ops
) == -1)
3116 WARN("Failed to initialize rasterizer state rbtree.\n");
3117 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3118 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3122 if (wine_rb_init(&device
->sampler_states
, &d3d10_sampler_state_rb_ops
) == -1)
3124 WARN("Failed to initialize sampler state rbtree.\n");
3125 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3126 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3127 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);