2 * Copyright 2008-2012 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
23 #define NONAMELESSUNION
24 #include "d3d11_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
28 static void STDMETHODCALLTYPE
d3d10_null_wined3d_object_destroyed(void *parent
) {}
30 const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops
=
32 d3d10_null_wined3d_object_destroyed
,
35 /* ID3D11Device methods */
37 static inline struct d3d_device
*impl_from_ID3D11Device(ID3D11Device
*iface
)
39 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D11Device_iface
);
42 static HRESULT STDMETHODCALLTYPE
d3d11_device_QueryInterface(ID3D11Device
*iface
, REFIID riid
, void **out
)
44 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
45 return IUnknown_QueryInterface(device
->outer_unk
, riid
, out
);
48 static ULONG STDMETHODCALLTYPE
d3d11_device_AddRef(ID3D11Device
*iface
)
50 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
51 return IUnknown_AddRef(device
->outer_unk
);
54 static ULONG STDMETHODCALLTYPE
d3d11_device_Release(ID3D11Device
*iface
)
56 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
57 return IUnknown_Release(device
->outer_unk
);
60 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBuffer(ID3D11Device
*iface
, const D3D11_BUFFER_DESC
*desc
,
61 const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Buffer
**buffer
)
63 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
64 struct d3d_buffer
*object
;
67 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
69 if (FAILED(hr
= d3d_buffer_create(device
, desc
, data
, &object
)))
72 *buffer
= &object
->ID3D11Buffer_iface
;
77 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture1D(ID3D11Device
*iface
,
78 const D3D11_TEXTURE1D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture1D
**texture
)
80 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
85 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture2D(ID3D11Device
*iface
,
86 const D3D11_TEXTURE2D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture2D
**texture
)
88 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
89 struct d3d_texture2d
*object
;
92 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
94 if (FAILED(hr
= d3d_texture2d_create(device
, desc
, data
, &object
)))
97 *texture
= &object
->ID3D11Texture2D_iface
;
102 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateTexture3D(ID3D11Device
*iface
,
103 const D3D11_TEXTURE3D_DESC
*desc
, const D3D11_SUBRESOURCE_DATA
*data
, ID3D11Texture3D
**texture
)
105 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
106 struct d3d_texture3d
*object
;
109 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
111 if (FAILED(hr
= d3d_texture3d_create(device
, desc
, data
, &object
)))
114 *texture
= &object
->ID3D11Texture3D_iface
;
119 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateShaderResourceView(ID3D11Device
*iface
,
120 ID3D11Resource
*resource
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D11ShaderResourceView
**view
)
122 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
127 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateUnorderedAccessView(ID3D11Device
*iface
,
128 ID3D11Resource
*resource
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
, ID3D11UnorderedAccessView
**view
)
130 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
135 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRenderTargetView(ID3D11Device
*iface
,
136 ID3D11Resource
*resource
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
, ID3D11RenderTargetView
**view
)
138 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
143 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilView(ID3D11Device
*iface
,
144 ID3D11Resource
*resource
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D11DepthStencilView
**view
)
146 struct d3d_device
*device
= impl_from_ID3D11Device(iface
);
147 struct d3d_depthstencil_view
*object
;
150 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
152 if (FAILED(hr
= d3d_depthstencil_view_create(device
, resource
, desc
, &object
)))
155 *view
= &object
->ID3D11DepthStencilView_iface
;
160 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateInputLayout(ID3D11Device
*iface
,
161 const D3D11_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
, const void *shader_byte_code
,
162 SIZE_T shader_byte_code_length
, ID3D11InputLayout
**input_layout
)
164 FIXME("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
165 "input_layout %p stub!\n", iface
, element_descs
, element_count
, shader_byte_code
,
166 shader_byte_code_length
, input_layout
);
171 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateVertexShader(ID3D11Device
*iface
, const void *byte_code
,
172 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11VertexShader
**shader
)
174 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
175 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
180 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShader(ID3D11Device
*iface
, const void *byte_code
,
181 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
183 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
184 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
189 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device
*iface
,
190 const void *byte_code
, SIZE_T byte_code_length
, const D3D11_SO_DECLARATION_ENTRY
*so_entries
,
191 UINT entry_count
, const UINT
*buffer_strides
, UINT strides_count
, UINT rasterized_stream
,
192 ID3D11ClassLinkage
*class_linkage
, ID3D11GeometryShader
**shader
)
194 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
195 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
196 iface
, byte_code
, byte_code_length
, so_entries
, entry_count
, buffer_strides
, strides_count
,
197 rasterized_stream
, class_linkage
, shader
);
202 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePixelShader(ID3D11Device
*iface
, const void *byte_code
,
203 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11PixelShader
**shader
)
205 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
206 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
211 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateHullShader(ID3D11Device
*iface
, const void *byte_code
,
212 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11HullShader
**shader
)
214 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
215 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
220 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDomainShader(ID3D11Device
*iface
, const void *byte_code
,
221 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11DomainShader
**shader
)
223 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
224 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
229 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateComputeShader(ID3D11Device
*iface
, const void *byte_code
,
230 SIZE_T byte_code_length
, ID3D11ClassLinkage
*class_linkage
, ID3D11ComputeShader
**shader
)
232 FIXME("iface %p, byte_code %p, byte_code_lenghth %lu, class_linkage %p, shader %p stub!\n",
233 iface
, byte_code
, byte_code_length
, class_linkage
, shader
);
238 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateClassLinkage(ID3D11Device
*iface
,
239 ID3D11ClassLinkage
**class_linkage
)
241 FIXME("iface %p, class_linkage %p stub!\n", iface
, class_linkage
);
246 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateBlendState(ID3D11Device
*iface
,
247 const D3D11_BLEND_DESC
*desc
, ID3D11BlendState
**blend_state
)
249 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface
, desc
, blend_state
);
254 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDepthStencilState(ID3D11Device
*iface
,
255 const D3D11_DEPTH_STENCIL_DESC
*desc
, ID3D11DepthStencilState
**depth_stencil_state
)
257 FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface
, desc
, depth_stencil_state
);
262 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateRasterizerState(ID3D11Device
*iface
,
263 const D3D11_RASTERIZER_DESC
*desc
, ID3D11RasterizerState
**rasterizer_state
)
265 FIXME("iface %p, desc %p, rasterizer_state %p stub!\n", iface
, desc
, rasterizer_state
);
270 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateSamplerState(ID3D11Device
*iface
,
271 const D3D11_SAMPLER_DESC
*desc
, ID3D11SamplerState
**sampler_state
)
273 FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface
, desc
, sampler_state
);
278 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateQuery(ID3D11Device
*iface
,
279 const D3D11_QUERY_DESC
*desc
, ID3D11Query
**query
)
281 FIXME("iface %p, desc %p, query %p stub!\n", iface
, desc
, query
);
286 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreatePredicate(ID3D11Device
*iface
, const D3D11_QUERY_DESC
*desc
,
287 ID3D11Predicate
**predicate
)
289 FIXME("iface %p, desc %p, predicate %p stub!\n", iface
, desc
, predicate
);
294 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
295 ID3D11Counter
**counter
)
297 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
302 static HRESULT STDMETHODCALLTYPE
d3d11_device_CreateDeferredContext(ID3D11Device
*iface
, UINT flags
,
303 ID3D11DeviceContext
**context
)
305 FIXME("iface %p, flags %#x, context %p stub!\n", iface
, flags
, context
);
310 static HRESULT STDMETHODCALLTYPE
d3d11_device_OpenSharedResource(ID3D11Device
*iface
, HANDLE resource
, REFIID riid
,
313 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface
, resource
, debugstr_guid(riid
), out
);
318 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFormatSupport(ID3D11Device
*iface
, DXGI_FORMAT format
,
319 UINT
*format_support
)
321 FIXME("iface %p, format %u, format_support %p stub!\n", iface
, format
, format_support
);
326 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckMultisampleQualityLevels(ID3D11Device
*iface
,
327 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
329 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
330 iface
, format
, sample_count
, quality_level_count
);
335 static void STDMETHODCALLTYPE
d3d11_device_CheckCounterInfo(ID3D11Device
*iface
, D3D11_COUNTER_INFO
*info
)
337 FIXME("iface %p, info %p stub!\n", iface
, info
);
340 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckCounter(ID3D11Device
*iface
, const D3D11_COUNTER_DESC
*desc
,
341 D3D11_COUNTER_TYPE
*type
, UINT
*active_counter_count
, char *name
, UINT
*name_length
,
342 char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
344 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
345 "units %p, units_length %p, description %p, description_length %p stub!\n",
346 iface
, desc
, type
, active_counter_count
, name
, name_length
,
347 units
, units_length
, description
, description_length
);
352 static HRESULT STDMETHODCALLTYPE
d3d11_device_CheckFeatureSupport(ID3D11Device
*iface
, D3D11_FEATURE feature
,
353 void *feature_support_data
, UINT feature_support_data_size
)
355 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
356 iface
, feature
, feature_support_data
, feature_support_data_size
);
361 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
362 UINT
*data_size
, void *data
)
364 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
369 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateData(ID3D11Device
*iface
, REFGUID guid
,
370 UINT data_size
, const void *data
)
372 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
377 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetPrivateDataInterface(ID3D11Device
*iface
, REFGUID guid
,
378 const IUnknown
*data_iface
)
380 FIXME("iface %p, guid %s, data_iface %p stub!\n", iface
, debugstr_guid(guid
), data_iface
);
385 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE
d3d11_device_GetFeatureLevel(ID3D11Device
*iface
)
387 FIXME("iface %p stub!\n", iface
);
389 return D3D_FEATURE_LEVEL_10_0
;
392 static UINT STDMETHODCALLTYPE
d3d11_device_GetCreationFlags(ID3D11Device
*iface
)
394 FIXME("iface %p stub!\n", iface
);
399 static HRESULT STDMETHODCALLTYPE
d3d11_device_GetDeviceRemovedReason(ID3D11Device
*iface
)
401 FIXME("iface %p stub!\n", iface
);
406 static void STDMETHODCALLTYPE
d3d11_device_GetImmediateContext(ID3D11Device
*iface
,
407 ID3D11DeviceContext
**immediate_context
)
409 FIXME("iface %p, immediate_context %p stub!\n", iface
, immediate_context
);
412 static HRESULT STDMETHODCALLTYPE
d3d11_device_SetExceptionMode(ID3D11Device
*iface
, UINT flags
)
414 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
419 static UINT STDMETHODCALLTYPE
d3d11_device_GetExceptionMode(ID3D11Device
*iface
)
421 FIXME("iface %p stub!\n", iface
);
426 static const struct ID3D11DeviceVtbl d3d11_device_vtbl
=
428 /* IUnknown methods */
429 d3d11_device_QueryInterface
,
431 d3d11_device_Release
,
432 /* ID3D11Device methods */
433 d3d11_device_CreateBuffer
,
434 d3d11_device_CreateTexture1D
,
435 d3d11_device_CreateTexture2D
,
436 d3d11_device_CreateTexture3D
,
437 d3d11_device_CreateShaderResourceView
,
438 d3d11_device_CreateUnorderedAccessView
,
439 d3d11_device_CreateRenderTargetView
,
440 d3d11_device_CreateDepthStencilView
,
441 d3d11_device_CreateInputLayout
,
442 d3d11_device_CreateVertexShader
,
443 d3d11_device_CreateGeometryShader
,
444 d3d11_device_CreateGeometryShaderWithStreamOutput
,
445 d3d11_device_CreatePixelShader
,
446 d3d11_device_CreateHullShader
,
447 d3d11_device_CreateDomainShader
,
448 d3d11_device_CreateComputeShader
,
449 d3d11_device_CreateClassLinkage
,
450 d3d11_device_CreateBlendState
,
451 d3d11_device_CreateDepthStencilState
,
452 d3d11_device_CreateRasterizerState
,
453 d3d11_device_CreateSamplerState
,
454 d3d11_device_CreateQuery
,
455 d3d11_device_CreatePredicate
,
456 d3d11_device_CreateCounter
,
457 d3d11_device_CreateDeferredContext
,
458 d3d11_device_OpenSharedResource
,
459 d3d11_device_CheckFormatSupport
,
460 d3d11_device_CheckMultisampleQualityLevels
,
461 d3d11_device_CheckCounterInfo
,
462 d3d11_device_CheckCounter
,
463 d3d11_device_CheckFeatureSupport
,
464 d3d11_device_GetPrivateData
,
465 d3d11_device_SetPrivateData
,
466 d3d11_device_SetPrivateDataInterface
,
467 d3d11_device_GetFeatureLevel
,
468 d3d11_device_GetCreationFlags
,
469 d3d11_device_GetDeviceRemovedReason
,
470 d3d11_device_GetImmediateContext
,
471 d3d11_device_SetExceptionMode
,
472 d3d11_device_GetExceptionMode
,
475 /* Inner IUnknown methods */
477 static inline struct d3d_device
*impl_from_IUnknown(IUnknown
*iface
)
479 return CONTAINING_RECORD(iface
, struct d3d_device
, IUnknown_inner
);
482 static HRESULT STDMETHODCALLTYPE
d3d10_device_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **out
)
484 struct d3d_device
*device
= impl_from_IUnknown(iface
);
486 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
488 if (IsEqualGUID(riid
, &IID_ID3D11Device
)
489 || IsEqualGUID(riid
, &IID_IUnknown
))
491 *out
= &device
->ID3D11Device_iface
;
493 else if (IsEqualGUID(riid
, &IID_ID3D10Device1
)
494 || IsEqualGUID(riid
, &IID_ID3D10Device
))
496 *out
= &device
->ID3D10Device1_iface
;
498 else if (IsEqualGUID(riid
, &IID_ID3D10Multithread
))
500 *out
= &device
->ID3D10Multithread_iface
;
502 else if (IsEqualGUID(riid
, &IID_IWineDXGIDeviceParent
))
504 *out
= &device
->IWineDXGIDeviceParent_iface
;
508 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
510 return E_NOINTERFACE
;
513 IUnknown_AddRef((IUnknown
*)*out
);
517 static ULONG STDMETHODCALLTYPE
d3d10_device_inner_AddRef(IUnknown
*iface
)
519 struct d3d_device
*This
= impl_from_IUnknown(iface
);
520 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
522 TRACE("%p increasing refcount to %u\n", This
, refcount
);
527 static ULONG STDMETHODCALLTYPE
d3d10_device_inner_Release(IUnknown
*iface
)
529 struct d3d_device
*device
= impl_from_IUnknown(iface
);
530 ULONG refcount
= InterlockedDecrement(&device
->refcount
);
532 TRACE("%p decreasing refcount to %u.\n", device
, refcount
);
536 if (device
->wined3d_device
)
538 wined3d_mutex_lock();
539 wined3d_device_decref(device
->wined3d_device
);
540 wined3d_mutex_unlock();
542 wine_rb_destroy(&device
->sampler_states
, NULL
, NULL
);
543 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
544 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
545 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
551 /* IUnknown methods */
553 static HRESULT STDMETHODCALLTYPE
d3d10_device_QueryInterface(ID3D10Device1
*iface
, REFIID riid
,
556 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
557 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
560 static ULONG STDMETHODCALLTYPE
d3d10_device_AddRef(ID3D10Device1
*iface
)
562 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
563 return IUnknown_AddRef(This
->outer_unk
);
566 static ULONG STDMETHODCALLTYPE
d3d10_device_Release(ID3D10Device1
*iface
)
568 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
569 return IUnknown_Release(This
->outer_unk
);
572 /* ID3D10Device methods */
574 static void STDMETHODCALLTYPE
d3d10_device_VSSetConstantBuffers(ID3D10Device1
*iface
,
575 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
577 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
580 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
581 iface
, start_slot
, buffer_count
, buffers
);
583 wined3d_mutex_lock();
584 for (i
= 0; i
< buffer_count
; ++i
)
586 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
588 wined3d_device_set_vs_cb(device
->wined3d_device
, start_slot
+ i
,
589 buffer
? buffer
->wined3d_buffer
: NULL
);
591 wined3d_mutex_unlock();
594 static void STDMETHODCALLTYPE
d3d10_device_PSSetShaderResources(ID3D10Device1
*iface
,
595 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
597 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
600 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
601 iface
, start_slot
, view_count
, views
);
603 wined3d_mutex_lock();
604 for (i
= 0; i
< view_count
; ++i
)
606 struct d3d10_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
608 wined3d_device_set_ps_resource_view(device
->wined3d_device
, start_slot
+ i
,
609 view
? view
->wined3d_view
: NULL
);
611 wined3d_mutex_unlock();
614 static void STDMETHODCALLTYPE
d3d10_device_PSSetShader(ID3D10Device1
*iface
,
615 ID3D10PixelShader
*shader
)
617 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
618 struct d3d10_pixel_shader
*ps
= unsafe_impl_from_ID3D10PixelShader(shader
);
620 TRACE("iface %p, shader %p\n", iface
, shader
);
622 wined3d_mutex_lock();
623 wined3d_device_set_pixel_shader(This
->wined3d_device
, ps
? ps
->wined3d_shader
: NULL
);
624 wined3d_mutex_unlock();
627 static void STDMETHODCALLTYPE
d3d10_device_PSSetSamplers(ID3D10Device1
*iface
,
628 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
630 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
633 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
634 iface
, start_slot
, sampler_count
, samplers
);
636 wined3d_mutex_lock();
637 for (i
= 0; i
< sampler_count
; ++i
)
639 struct d3d10_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
641 wined3d_device_set_ps_sampler(device
->wined3d_device
, start_slot
+ i
,
642 sampler
? sampler
->wined3d_sampler
: NULL
);
644 wined3d_mutex_unlock();
647 static void STDMETHODCALLTYPE
d3d10_device_VSSetShader(ID3D10Device1
*iface
,
648 ID3D10VertexShader
*shader
)
650 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
651 struct d3d10_vertex_shader
*vs
= unsafe_impl_from_ID3D10VertexShader(shader
);
653 TRACE("iface %p, shader %p\n", iface
, shader
);
655 wined3d_mutex_lock();
656 wined3d_device_set_vertex_shader(This
->wined3d_device
, vs
? vs
->wined3d_shader
: NULL
);
657 wined3d_mutex_unlock();
660 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexed(ID3D10Device1
*iface
, UINT index_count
,
661 UINT start_index_location
, INT base_vertex_location
)
663 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
665 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
666 iface
, index_count
, start_index_location
, base_vertex_location
);
668 wined3d_mutex_lock();
669 wined3d_device_set_base_vertex_index(This
->wined3d_device
, base_vertex_location
);
670 wined3d_device_draw_indexed_primitive(This
->wined3d_device
, start_index_location
, index_count
);
671 wined3d_mutex_unlock();
674 static void STDMETHODCALLTYPE
d3d10_device_Draw(ID3D10Device1
*iface
, UINT vertex_count
,
675 UINT start_vertex_location
)
677 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
679 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
680 iface
, vertex_count
, start_vertex_location
);
682 wined3d_mutex_lock();
683 wined3d_device_draw_primitive(This
->wined3d_device
, start_vertex_location
, vertex_count
);
684 wined3d_mutex_unlock();
687 static void STDMETHODCALLTYPE
d3d10_device_PSSetConstantBuffers(ID3D10Device1
*iface
,
688 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
690 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
693 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
694 iface
, start_slot
, buffer_count
, buffers
);
696 wined3d_mutex_lock();
697 for (i
= 0; i
< buffer_count
; ++i
)
699 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
701 wined3d_device_set_ps_cb(device
->wined3d_device
, start_slot
+ i
,
702 buffer
? buffer
->wined3d_buffer
: NULL
);
704 wined3d_mutex_unlock();
707 static void STDMETHODCALLTYPE
d3d10_device_IASetInputLayout(ID3D10Device1
*iface
,
708 ID3D10InputLayout
*input_layout
)
710 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
711 struct d3d10_input_layout
*layout
= unsafe_impl_from_ID3D10InputLayout(input_layout
);
713 TRACE("iface %p, input_layout %p\n", iface
, input_layout
);
715 wined3d_mutex_lock();
716 wined3d_device_set_vertex_declaration(This
->wined3d_device
,
717 layout
? layout
->wined3d_decl
: NULL
);
718 wined3d_mutex_unlock();
721 static void STDMETHODCALLTYPE
d3d10_device_IASetVertexBuffers(ID3D10Device1
*iface
, UINT start_slot
,
722 UINT buffer_count
, ID3D10Buffer
*const *buffers
, const UINT
*strides
, const UINT
*offsets
)
724 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
727 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
728 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
730 wined3d_mutex_lock();
731 for (i
= 0; i
< buffer_count
; ++i
)
733 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
735 wined3d_device_set_stream_source(This
->wined3d_device
, start_slot
+ i
,
736 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
], strides
[i
]);
738 wined3d_mutex_unlock();
741 static void STDMETHODCALLTYPE
d3d10_device_IASetIndexBuffer(ID3D10Device1
*iface
,
742 ID3D10Buffer
*buffer
, DXGI_FORMAT format
, UINT offset
)
744 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
745 struct d3d_buffer
*buffer_impl
= unsafe_impl_from_ID3D10Buffer(buffer
);
747 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
748 iface
, buffer
, debug_dxgi_format(format
), offset
);
750 wined3d_mutex_lock();
751 wined3d_device_set_index_buffer(This
->wined3d_device
,
752 buffer_impl
? buffer_impl
->wined3d_buffer
: NULL
,
753 wined3dformat_from_dxgi_format(format
));
754 wined3d_mutex_unlock();
755 if (offset
) FIXME("offset %u not supported.\n", offset
);
758 static void STDMETHODCALLTYPE
d3d10_device_DrawIndexedInstanced(ID3D10Device1
*iface
,
759 UINT instance_index_count
, UINT instance_count
, UINT start_index_location
,
760 INT base_vertex_location
, UINT start_instance_location
)
762 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
764 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
765 "base_vertex_location %d, start_instance_location %u.\n",
766 iface
, instance_index_count
, instance_count
, start_index_location
,
767 base_vertex_location
, start_instance_location
);
769 wined3d_mutex_lock();
770 wined3d_device_set_base_vertex_index(device
->wined3d_device
, base_vertex_location
);
771 wined3d_device_draw_indexed_primitive_instanced(device
->wined3d_device
, start_index_location
,
772 instance_index_count
, start_instance_location
, instance_count
);
773 wined3d_mutex_unlock();
776 static void STDMETHODCALLTYPE
d3d10_device_DrawInstanced(ID3D10Device1
*iface
,
777 UINT instance_vertex_count
, UINT instance_count
,
778 UINT start_vertex_location
, UINT start_instance_location
)
780 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
782 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
783 "start_instance_location %u.\n", iface
, instance_vertex_count
, instance_count
,
784 start_vertex_location
, start_instance_location
);
786 wined3d_mutex_lock();
787 wined3d_device_draw_primitive_instanced(device
->wined3d_device
, start_vertex_location
,
788 instance_vertex_count
, start_instance_location
, instance_count
);
789 wined3d_mutex_unlock();
792 static void STDMETHODCALLTYPE
d3d10_device_GSSetConstantBuffers(ID3D10Device1
*iface
,
793 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
*const *buffers
)
795 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
798 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
799 iface
, start_slot
, buffer_count
, buffers
);
801 wined3d_mutex_lock();
802 for (i
= 0; i
< buffer_count
; ++i
)
804 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(buffers
[i
]);
806 wined3d_device_set_gs_cb(device
->wined3d_device
, start_slot
+ i
,
807 buffer
? buffer
->wined3d_buffer
: NULL
);
809 wined3d_mutex_unlock();
812 static void STDMETHODCALLTYPE
d3d10_device_GSSetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
*shader
)
814 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
815 struct d3d10_geometry_shader
*gs
= unsafe_impl_from_ID3D10GeometryShader(shader
);
817 TRACE("iface %p, shader %p.\n", iface
, shader
);
819 wined3d_mutex_lock();
820 wined3d_device_set_geometry_shader(device
->wined3d_device
, gs
? gs
->wined3d_shader
: NULL
);
821 wined3d_mutex_unlock();
824 static void STDMETHODCALLTYPE
d3d10_device_IASetPrimitiveTopology(ID3D10Device1
*iface
,
825 D3D10_PRIMITIVE_TOPOLOGY topology
)
827 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
829 TRACE("iface %p, topology %s\n", iface
, debug_d3d10_primitive_topology(topology
));
831 wined3d_mutex_lock();
832 wined3d_device_set_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
)topology
);
833 wined3d_mutex_unlock();
836 static void STDMETHODCALLTYPE
d3d10_device_VSSetShaderResources(ID3D10Device1
*iface
,
837 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
839 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
842 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
843 iface
, start_slot
, view_count
, views
);
845 wined3d_mutex_lock();
846 for (i
= 0; i
< view_count
; ++i
)
848 struct d3d10_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
850 wined3d_device_set_vs_resource_view(device
->wined3d_device
, start_slot
+ i
,
851 view
? view
->wined3d_view
: NULL
);
853 wined3d_mutex_unlock();
856 static void STDMETHODCALLTYPE
d3d10_device_VSSetSamplers(ID3D10Device1
*iface
,
857 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
859 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
862 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
863 iface
, start_slot
, sampler_count
, samplers
);
865 wined3d_mutex_lock();
866 for (i
= 0; i
< sampler_count
; ++i
)
868 struct d3d10_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
870 wined3d_device_set_vs_sampler(device
->wined3d_device
, start_slot
+ i
,
871 sampler
? sampler
->wined3d_sampler
: NULL
);
873 wined3d_mutex_unlock();
876 static void STDMETHODCALLTYPE
d3d10_device_SetPredication(ID3D10Device1
*iface
, ID3D10Predicate
*predicate
, BOOL value
)
878 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
879 struct d3d10_query
*query
;
881 TRACE("iface %p, predicate %p, value %#x.\n", iface
, predicate
, value
);
883 query
= unsafe_impl_from_ID3D10Query((ID3D10Query
*)predicate
);
884 wined3d_mutex_lock();
885 wined3d_device_set_predication(device
->wined3d_device
, query
? query
->wined3d_query
: NULL
, value
);
886 wined3d_mutex_unlock();
889 static void STDMETHODCALLTYPE
d3d10_device_GSSetShaderResources(ID3D10Device1
*iface
,
890 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
*const *views
)
892 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
895 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
896 iface
, start_slot
, view_count
, views
);
898 wined3d_mutex_lock();
899 for (i
= 0; i
< view_count
; ++i
)
901 struct d3d10_shader_resource_view
*view
= unsafe_impl_from_ID3D10ShaderResourceView(views
[i
]);
903 wined3d_device_set_gs_resource_view(device
->wined3d_device
, start_slot
+ i
,
904 view
? view
->wined3d_view
: NULL
);
906 wined3d_mutex_unlock();
909 static void STDMETHODCALLTYPE
d3d10_device_GSSetSamplers(ID3D10Device1
*iface
,
910 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
*const *samplers
)
912 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
915 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
916 iface
, start_slot
, sampler_count
, samplers
);
918 wined3d_mutex_lock();
919 for (i
= 0; i
< sampler_count
; ++i
)
921 struct d3d10_sampler_state
*sampler
= unsafe_impl_from_ID3D10SamplerState(samplers
[i
]);
923 wined3d_device_set_gs_sampler(device
->wined3d_device
, start_slot
+ i
,
924 sampler
? sampler
->wined3d_sampler
: NULL
);
926 wined3d_mutex_unlock();
929 static void STDMETHODCALLTYPE
d3d10_device_OMSetRenderTargets(ID3D10Device1
*iface
,
930 UINT render_target_view_count
, ID3D10RenderTargetView
*const *render_target_views
,
931 ID3D10DepthStencilView
*depth_stencil_view
)
933 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
934 struct d3d_depthstencil_view
*dsv
;
937 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
938 iface
, render_target_view_count
, render_target_views
, depth_stencil_view
);
940 wined3d_mutex_lock();
941 for (i
= 0; i
< render_target_view_count
; ++i
)
943 struct d3d_rendertarget_view
*rtv
= unsafe_impl_from_ID3D10RenderTargetView(render_target_views
[i
]);
945 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
,
946 rtv
? rtv
->wined3d_view
: NULL
, FALSE
);
948 for (; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
950 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
953 dsv
= unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view
);
954 wined3d_device_set_depth_stencil_view(device
->wined3d_device
,
955 dsv
? dsv
->wined3d_view
: NULL
);
956 wined3d_mutex_unlock();
959 static void STDMETHODCALLTYPE
d3d10_device_OMSetBlendState(ID3D10Device1
*iface
,
960 ID3D10BlendState
*blend_state
, const FLOAT blend_factor
[4], UINT sample_mask
)
962 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
963 const D3D10_BLEND_DESC
*desc
;
965 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
966 iface
, blend_state
, blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3], sample_mask
);
968 if (blend_factor
[0] != 1.0f
|| blend_factor
[1] != 1.0f
|| blend_factor
[2] != 1.0f
|| blend_factor
[3] != 1.0f
)
969 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
970 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
971 wined3d_mutex_lock();
972 memcpy(device
->blend_factor
, blend_factor
, 4 * sizeof(*blend_factor
));
973 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
, sample_mask
);
974 if (!(device
->blend_state
= unsafe_impl_from_ID3D10BlendState(blend_state
)))
976 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, FALSE
);
977 wined3d_device_set_render_state(device
->wined3d_device
,
978 WINED3D_RS_COLORWRITEENABLE
, D3D10_COLOR_WRITE_ENABLE_ALL
);
979 wined3d_device_set_render_state(device
->wined3d_device
,
980 WINED3D_RS_COLORWRITEENABLE1
, D3D10_COLOR_WRITE_ENABLE_ALL
);
981 wined3d_device_set_render_state(device
->wined3d_device
,
982 WINED3D_RS_COLORWRITEENABLE2
, D3D10_COLOR_WRITE_ENABLE_ALL
);
983 wined3d_device_set_render_state(device
->wined3d_device
,
984 WINED3D_RS_COLORWRITEENABLE3
, D3D10_COLOR_WRITE_ENABLE_ALL
);
985 wined3d_mutex_unlock();
989 desc
= &device
->blend_state
->desc
;
990 /* glSampleCoverage() */
991 if (desc
->AlphaToCoverageEnable
)
992 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc
->AlphaToCoverageEnable
);
993 /* glEnableIndexedEXT(GL_BLEND, ...) */
994 FIXME("Per-rendertarget blend enable not implemented.\n");
995 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ALPHABLENDENABLE
, desc
->BlendEnable
[0]);
996 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLEND
, desc
->SrcBlend
);
997 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLEND
, desc
->DestBlend
);
998 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOP
, desc
->BlendOp
);
999 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SEPARATEALPHABLENDENABLE
, TRUE
);
1000 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SRCBLENDALPHA
, desc
->SrcBlendAlpha
);
1001 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_DESTBLENDALPHA
, desc
->DestBlendAlpha
);
1002 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_BLENDOPALPHA
, desc
->BlendOpAlpha
);
1003 FIXME("Color mask > 3 not implemented.\n");
1004 wined3d_device_set_render_state(device
->wined3d_device
,
1005 WINED3D_RS_COLORWRITEENABLE
, desc
->RenderTargetWriteMask
[0]);
1006 wined3d_device_set_render_state(device
->wined3d_device
,
1007 WINED3D_RS_COLORWRITEENABLE1
, desc
->RenderTargetWriteMask
[1]);
1008 wined3d_device_set_render_state(device
->wined3d_device
,
1009 WINED3D_RS_COLORWRITEENABLE2
, desc
->RenderTargetWriteMask
[2]);
1010 wined3d_device_set_render_state(device
->wined3d_device
,
1011 WINED3D_RS_COLORWRITEENABLE3
, desc
->RenderTargetWriteMask
[3]);
1012 wined3d_mutex_unlock();
1015 static void STDMETHODCALLTYPE
d3d10_device_OMSetDepthStencilState(ID3D10Device1
*iface
,
1016 ID3D10DepthStencilState
*depth_stencil_state
, UINT stencil_ref
)
1018 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1020 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
1021 iface
, depth_stencil_state
, stencil_ref
);
1023 device
->depth_stencil_state
= unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state
);
1024 device
->stencil_ref
= stencil_ref
;
1027 static void STDMETHODCALLTYPE
d3d10_device_SOSetTargets(ID3D10Device1
*iface
,
1028 UINT target_count
, ID3D10Buffer
*const *targets
, const UINT
*offsets
)
1030 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1031 unsigned int count
, i
;
1033 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface
, target_count
, targets
, offsets
);
1035 count
= min(target_count
, 4);
1036 wined3d_mutex_lock();
1037 for (i
= 0; i
< count
; ++i
)
1039 struct d3d_buffer
*buffer
= unsafe_impl_from_ID3D10Buffer(targets
[i
]);
1041 wined3d_device_set_stream_output(device
->wined3d_device
, i
,
1042 buffer
? buffer
->wined3d_buffer
: NULL
, offsets
[i
]);
1045 for (i
= count
; i
< 4; ++i
)
1047 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
1049 wined3d_mutex_unlock();
1052 static void STDMETHODCALLTYPE
d3d10_device_DrawAuto(ID3D10Device1
*iface
)
1054 FIXME("iface %p stub!\n", iface
);
1057 static void STDMETHODCALLTYPE
d3d10_device_RSSetState(ID3D10Device1
*iface
, ID3D10RasterizerState
*rasterizer_state
)
1059 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1060 const D3D10_RASTERIZER_DESC
*desc
;
1062 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1064 wined3d_mutex_lock();
1065 if (!(device
->rasterizer_state
= unsafe_impl_from_ID3D10RasterizerState(rasterizer_state
)))
1067 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, WINED3D_FILL_SOLID
);
1068 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, WINED3D_CULL_CCW
);
1069 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, FALSE
);
1070 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, FALSE
);
1071 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_ANTIALIASEDLINEENABLE
, FALSE
);
1072 wined3d_mutex_unlock();
1076 desc
= &device
->rasterizer_state
->desc
;
1077 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_FILLMODE
, desc
->FillMode
);
1078 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_CULLMODE
, desc
->CullMode
);
1080 if (desc
->FrontCounterClockwise
)
1081 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc
->FrontCounterClockwise
);
1082 /* OpenGL style depth bias. */
1083 if (desc
->DepthBias
|| desc
->SlopeScaledDepthBias
)
1084 FIXME("Ignoring depth bias.\n");
1085 /* GL_DEPTH_CLAMP */
1086 if (!desc
->DepthClipEnable
)
1087 FIXME("Ignoring DepthClipEnable %#x.\n", desc
->DepthClipEnable
);
1088 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_SCISSORTESTENABLE
, desc
->ScissorEnable
);
1089 wined3d_device_set_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEANTIALIAS
, desc
->MultisampleEnable
);
1090 wined3d_device_set_render_state(device
->wined3d_device
,
1091 WINED3D_RS_ANTIALIASEDLINEENABLE
, desc
->AntialiasedLineEnable
);
1092 wined3d_mutex_unlock();
1095 static void STDMETHODCALLTYPE
d3d10_device_RSSetViewports(ID3D10Device1
*iface
,
1096 UINT viewport_count
, const D3D10_VIEWPORT
*viewports
)
1098 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1099 struct wined3d_viewport wined3d_vp
;
1101 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface
, viewport_count
, viewports
);
1103 if (viewport_count
> 1)
1104 FIXME("Multiple viewports not implemented.\n");
1106 if (!viewport_count
)
1109 wined3d_vp
.x
= viewports
[0].TopLeftX
;
1110 wined3d_vp
.y
= viewports
[0].TopLeftY
;
1111 wined3d_vp
.width
= viewports
[0].Width
;
1112 wined3d_vp
.height
= viewports
[0].Height
;
1113 wined3d_vp
.min_z
= viewports
[0].MinDepth
;
1114 wined3d_vp
.max_z
= viewports
[0].MaxDepth
;
1116 wined3d_mutex_lock();
1117 wined3d_device_set_viewport(device
->wined3d_device
, &wined3d_vp
);
1118 wined3d_mutex_unlock();
1121 static void STDMETHODCALLTYPE
d3d10_device_RSSetScissorRects(ID3D10Device1
*iface
,
1122 UINT rect_count
, const D3D10_RECT
*rects
)
1124 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1126 TRACE("iface %p, rect_count %u, rects %p.\n", iface
, rect_count
, rects
);
1129 FIXME("Multiple scissor rects not implemented.\n");
1134 wined3d_mutex_lock();
1135 wined3d_device_set_scissor_rect(device
->wined3d_device
, rects
);
1136 wined3d_mutex_unlock();
1139 static void STDMETHODCALLTYPE
d3d10_device_CopySubresourceRegion(ID3D10Device1
*iface
,
1140 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
, UINT dst_x
, UINT dst_y
, UINT dst_z
,
1141 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, const D3D10_BOX
*src_box
)
1143 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1144 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1145 struct wined3d_box wined3d_src_box
;
1147 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
1148 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
1149 iface
, dst_resource
, dst_subresource_idx
, dst_x
, dst_y
, dst_z
,
1150 src_resource
, src_subresource_idx
, src_box
);
1152 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
1153 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
1154 wined3d_src_box
.left
= src_box
->left
;
1155 wined3d_src_box
.top
= src_box
->top
;
1156 wined3d_src_box
.front
= src_box
->front
;
1157 wined3d_src_box
.right
= src_box
->right
;
1158 wined3d_src_box
.bottom
= src_box
->bottom
;
1159 wined3d_src_box
.back
= src_box
->back
;
1160 wined3d_mutex_lock();
1161 wined3d_device_copy_sub_resource_region(device
->wined3d_device
, wined3d_dst_resource
, dst_subresource_idx
,
1162 dst_x
, dst_y
, dst_z
, wined3d_src_resource
, src_subresource_idx
, &wined3d_src_box
);
1163 wined3d_mutex_unlock();
1166 static void STDMETHODCALLTYPE
d3d10_device_CopyResource(ID3D10Device1
*iface
,
1167 ID3D10Resource
*dst_resource
, ID3D10Resource
*src_resource
)
1169 struct wined3d_resource
*wined3d_dst_resource
, *wined3d_src_resource
;
1170 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1172 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface
, dst_resource
, src_resource
);
1174 wined3d_dst_resource
= wined3d_resource_from_d3d10_resource(dst_resource
);
1175 wined3d_src_resource
= wined3d_resource_from_d3d10_resource(src_resource
);
1176 wined3d_mutex_lock();
1177 wined3d_device_copy_resource(device
->wined3d_device
, wined3d_dst_resource
, wined3d_src_resource
);
1178 wined3d_mutex_unlock();
1181 static void STDMETHODCALLTYPE
d3d10_device_UpdateSubresource(ID3D10Device1
*iface
,
1182 ID3D10Resource
*resource
, UINT subresource_idx
, const D3D10_BOX
*box
,
1183 const void *data
, UINT row_pitch
, UINT depth_pitch
)
1185 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1186 struct wined3d_resource
*wined3d_resource
;
1187 struct wined3d_box wined3d_box
;
1189 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
1190 iface
, resource
, subresource_idx
, box
, data
, row_pitch
, depth_pitch
);
1194 wined3d_box
.left
= box
->left
;
1195 wined3d_box
.top
= box
->top
;
1196 wined3d_box
.front
= box
->front
;
1197 wined3d_box
.right
= box
->right
;
1198 wined3d_box
.bottom
= box
->bottom
;
1199 wined3d_box
.back
= box
->back
;
1202 wined3d_resource
= wined3d_resource_from_d3d10_resource(resource
);
1203 wined3d_mutex_lock();
1204 wined3d_device_update_sub_resource(device
->wined3d_device
, wined3d_resource
,
1205 subresource_idx
, box
? &wined3d_box
: NULL
, data
, row_pitch
, depth_pitch
);
1206 wined3d_mutex_unlock();
1209 static void STDMETHODCALLTYPE
d3d10_device_ClearRenderTargetView(ID3D10Device1
*iface
,
1210 ID3D10RenderTargetView
*render_target_view
, const FLOAT color_rgba
[4])
1212 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1213 struct d3d_rendertarget_view
*view
= unsafe_impl_from_ID3D10RenderTargetView(render_target_view
);
1214 const struct wined3d_color color
= {color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]};
1217 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
1218 iface
, render_target_view
, color_rgba
[0], color_rgba
[1], color_rgba
[2], color_rgba
[3]);
1220 wined3d_mutex_lock();
1221 if (FAILED(hr
= wined3d_device_clear_rendertarget_view(device
->wined3d_device
, view
->wined3d_view
, NULL
, &color
)))
1222 ERR("Failed to clear view, hr %#x.\n", hr
);
1223 wined3d_mutex_unlock();
1226 static void STDMETHODCALLTYPE
d3d10_device_ClearDepthStencilView(ID3D10Device1
*iface
,
1227 ID3D10DepthStencilView
*depth_stencil_view
, UINT flags
, FLOAT depth
, UINT8 stencil
)
1229 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
1230 iface
, depth_stencil_view
, flags
, depth
, stencil
);
1233 static void STDMETHODCALLTYPE
d3d10_device_GenerateMips(ID3D10Device1
*iface
,
1234 ID3D10ShaderResourceView
*shader_resource_view
)
1236 FIXME("iface %p, shader_resource_view %p stub!\n", iface
, shader_resource_view
);
1239 static void STDMETHODCALLTYPE
d3d10_device_ResolveSubresource(ID3D10Device1
*iface
,
1240 ID3D10Resource
*dst_resource
, UINT dst_subresource_idx
,
1241 ID3D10Resource
*src_resource
, UINT src_subresource_idx
, DXGI_FORMAT format
)
1243 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
1244 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
1245 iface
, dst_resource
, dst_subresource_idx
,
1246 src_resource
, src_subresource_idx
, debug_dxgi_format(format
));
1249 static void STDMETHODCALLTYPE
d3d10_device_VSGetConstantBuffers(ID3D10Device1
*iface
,
1250 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
1252 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1255 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1256 iface
, start_slot
, buffer_count
, buffers
);
1258 wined3d_mutex_lock();
1259 for (i
= 0; i
< buffer_count
; ++i
)
1261 struct wined3d_buffer
*wined3d_buffer
;
1262 struct d3d_buffer
*buffer_impl
;
1264 if (!(wined3d_buffer
= wined3d_device_get_vs_cb(device
->wined3d_device
, start_slot
+ i
)))
1270 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1271 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1272 ID3D10Buffer_AddRef(buffers
[i
]);
1274 wined3d_mutex_unlock();
1277 static void STDMETHODCALLTYPE
d3d10_device_PSGetShaderResources(ID3D10Device1
*iface
,
1278 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
1280 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1283 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1284 iface
, start_slot
, view_count
, views
);
1286 wined3d_mutex_lock();
1287 for (i
= 0; i
< view_count
; ++i
)
1289 struct wined3d_shader_resource_view
*wined3d_view
;
1290 struct d3d10_shader_resource_view
*view_impl
;
1292 if (!(wined3d_view
= wined3d_device_get_ps_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1298 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1299 views
[i
] = &view_impl
->ID3D10ShaderResourceView_iface
;
1300 ID3D10ShaderResourceView_AddRef(views
[i
]);
1302 wined3d_mutex_unlock();
1305 static void STDMETHODCALLTYPE
d3d10_device_PSGetShader(ID3D10Device1
*iface
, ID3D10PixelShader
**shader
)
1307 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1308 struct d3d10_pixel_shader
*shader_impl
;
1309 struct wined3d_shader
*wined3d_shader
;
1311 TRACE("iface %p, shader %p.\n", iface
, shader
);
1313 wined3d_mutex_lock();
1314 if (!(wined3d_shader
= wined3d_device_get_pixel_shader(device
->wined3d_device
)))
1316 wined3d_mutex_unlock();
1321 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1322 wined3d_mutex_unlock();
1323 *shader
= &shader_impl
->ID3D10PixelShader_iface
;
1324 ID3D10PixelShader_AddRef(*shader
);
1327 static void STDMETHODCALLTYPE
d3d10_device_PSGetSamplers(ID3D10Device1
*iface
,
1328 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
1330 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1333 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1334 iface
, start_slot
, sampler_count
, samplers
);
1336 wined3d_mutex_lock();
1337 for (i
= 0; i
< sampler_count
; ++i
)
1339 struct d3d10_sampler_state
*sampler_impl
;
1340 struct wined3d_sampler
*wined3d_sampler
;
1342 if (!(wined3d_sampler
= wined3d_device_get_ps_sampler(device
->wined3d_device
, start_slot
+ i
)))
1348 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1349 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
1350 ID3D10SamplerState_AddRef(samplers
[i
]);
1352 wined3d_mutex_unlock();
1355 static void STDMETHODCALLTYPE
d3d10_device_VSGetShader(ID3D10Device1
*iface
, ID3D10VertexShader
**shader
)
1357 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1358 struct d3d10_vertex_shader
*shader_impl
;
1359 struct wined3d_shader
*wined3d_shader
;
1361 TRACE("iface %p, shader %p.\n", iface
, shader
);
1363 wined3d_mutex_lock();
1364 if (!(wined3d_shader
= wined3d_device_get_vertex_shader(device
->wined3d_device
)))
1366 wined3d_mutex_unlock();
1371 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1372 wined3d_mutex_unlock();
1373 *shader
= &shader_impl
->ID3D10VertexShader_iface
;
1374 ID3D10VertexShader_AddRef(*shader
);
1377 static void STDMETHODCALLTYPE
d3d10_device_PSGetConstantBuffers(ID3D10Device1
*iface
,
1378 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
1380 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1383 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1384 iface
, start_slot
, buffer_count
, buffers
);
1386 wined3d_mutex_lock();
1387 for (i
= 0; i
< buffer_count
; ++i
)
1389 struct wined3d_buffer
*wined3d_buffer
;
1390 struct d3d_buffer
*buffer_impl
;
1392 if (!(wined3d_buffer
= wined3d_device_get_ps_cb(device
->wined3d_device
, start_slot
+ i
)))
1398 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1399 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1400 ID3D10Buffer_AddRef(buffers
[i
]);
1402 wined3d_mutex_unlock();
1405 static void STDMETHODCALLTYPE
d3d10_device_IAGetInputLayout(ID3D10Device1
*iface
, ID3D10InputLayout
**input_layout
)
1407 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1408 struct wined3d_vertex_declaration
*wined3d_declaration
;
1409 struct d3d10_input_layout
*input_layout_impl
;
1411 TRACE("iface %p, input_layout %p.\n", iface
, input_layout
);
1413 wined3d_mutex_lock();
1414 if (!(wined3d_declaration
= wined3d_device_get_vertex_declaration(device
->wined3d_device
)))
1416 wined3d_mutex_unlock();
1417 *input_layout
= NULL
;
1421 input_layout_impl
= wined3d_vertex_declaration_get_parent(wined3d_declaration
);
1422 wined3d_mutex_unlock();
1423 *input_layout
= &input_layout_impl
->ID3D10InputLayout_iface
;
1424 ID3D10InputLayout_AddRef(*input_layout
);
1427 static void STDMETHODCALLTYPE
d3d10_device_IAGetVertexBuffers(ID3D10Device1
*iface
,
1428 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*strides
, UINT
*offsets
)
1430 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1433 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
1434 iface
, start_slot
, buffer_count
, buffers
, strides
, offsets
);
1436 wined3d_mutex_lock();
1437 for (i
= 0; i
< buffer_count
; ++i
)
1439 struct wined3d_buffer
*wined3d_buffer
;
1440 struct d3d_buffer
*buffer_impl
;
1442 if (FAILED(wined3d_device_get_stream_source(device
->wined3d_device
, start_slot
+ i
,
1443 &wined3d_buffer
, &offsets
[i
], &strides
[i
])))
1444 ERR("Failed to get vertex buffer.\n");
1446 if (!wined3d_buffer
)
1452 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1453 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1454 ID3D10Buffer_AddRef(buffers
[i
]);
1456 wined3d_mutex_unlock();
1459 static void STDMETHODCALLTYPE
d3d10_device_IAGetIndexBuffer(ID3D10Device1
*iface
,
1460 ID3D10Buffer
**buffer
, DXGI_FORMAT
*format
, UINT
*offset
)
1462 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1463 enum wined3d_format_id wined3d_format
;
1464 struct wined3d_buffer
*wined3d_buffer
;
1465 struct d3d_buffer
*buffer_impl
;
1467 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface
, buffer
, format
, offset
);
1469 wined3d_mutex_lock();
1470 wined3d_buffer
= wined3d_device_get_index_buffer(device
->wined3d_device
, &wined3d_format
);
1471 *format
= dxgi_format_from_wined3dformat(wined3d_format
);
1472 *offset
= 0; /* FIXME */
1473 if (!wined3d_buffer
)
1475 wined3d_mutex_unlock();
1480 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1481 wined3d_mutex_unlock();
1482 *buffer
= &buffer_impl
->ID3D10Buffer_iface
;
1483 ID3D10Buffer_AddRef(*buffer
);
1486 static void STDMETHODCALLTYPE
d3d10_device_GSGetConstantBuffers(ID3D10Device1
*iface
,
1487 UINT start_slot
, UINT buffer_count
, ID3D10Buffer
**buffers
)
1489 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1492 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1493 iface
, start_slot
, buffer_count
, buffers
);
1495 wined3d_mutex_lock();
1496 for (i
= 0; i
< buffer_count
; ++i
)
1498 struct wined3d_buffer
*wined3d_buffer
;
1499 struct d3d_buffer
*buffer_impl
;
1501 if (!(wined3d_buffer
= wined3d_device_get_gs_cb(device
->wined3d_device
, start_slot
+ i
)))
1507 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1508 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1509 ID3D10Buffer_AddRef(buffers
[i
]);
1511 wined3d_mutex_unlock();
1514 static void STDMETHODCALLTYPE
d3d10_device_GSGetShader(ID3D10Device1
*iface
, ID3D10GeometryShader
**shader
)
1516 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1517 struct d3d10_geometry_shader
*shader_impl
;
1518 struct wined3d_shader
*wined3d_shader
;
1520 TRACE("iface %p, shader %p.\n", iface
, shader
);
1522 wined3d_mutex_lock();
1523 if (!(wined3d_shader
= wined3d_device_get_geometry_shader(device
->wined3d_device
)))
1525 wined3d_mutex_unlock();
1530 shader_impl
= wined3d_shader_get_parent(wined3d_shader
);
1531 wined3d_mutex_unlock();
1532 *shader
= &shader_impl
->ID3D10GeometryShader_iface
;
1533 ID3D10GeometryShader_AddRef(*shader
);
1536 static void STDMETHODCALLTYPE
d3d10_device_IAGetPrimitiveTopology(ID3D10Device1
*iface
,
1537 D3D10_PRIMITIVE_TOPOLOGY
*topology
)
1539 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
1541 TRACE("iface %p, topology %p\n", iface
, topology
);
1543 wined3d_mutex_lock();
1544 wined3d_device_get_primitive_type(This
->wined3d_device
, (enum wined3d_primitive_type
*)topology
);
1545 wined3d_mutex_unlock();
1548 static void STDMETHODCALLTYPE
d3d10_device_VSGetShaderResources(ID3D10Device1
*iface
,
1549 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
1551 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1554 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1555 iface
, start_slot
, view_count
, views
);
1557 wined3d_mutex_lock();
1558 for (i
= 0; i
< view_count
; ++i
)
1560 struct wined3d_shader_resource_view
*wined3d_view
;
1561 struct d3d10_shader_resource_view
*view_impl
;
1563 if (!(wined3d_view
= wined3d_device_get_vs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1569 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1570 views
[i
] = &view_impl
->ID3D10ShaderResourceView_iface
;
1571 ID3D10ShaderResourceView_AddRef(views
[i
]);
1573 wined3d_mutex_unlock();
1576 static void STDMETHODCALLTYPE
d3d10_device_VSGetSamplers(ID3D10Device1
*iface
,
1577 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
1579 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1582 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1583 iface
, start_slot
, sampler_count
, samplers
);
1585 wined3d_mutex_lock();
1586 for (i
= 0; i
< sampler_count
; ++i
)
1588 struct d3d10_sampler_state
*sampler_impl
;
1589 struct wined3d_sampler
*wined3d_sampler
;
1591 if (!(wined3d_sampler
= wined3d_device_get_vs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1597 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1598 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
1599 ID3D10SamplerState_AddRef(samplers
[i
]);
1601 wined3d_mutex_unlock();
1604 static void STDMETHODCALLTYPE
d3d10_device_GetPredication(ID3D10Device1
*iface
,
1605 ID3D10Predicate
**predicate
, BOOL
*value
)
1607 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1608 struct wined3d_query
*wined3d_predicate
;
1609 struct d3d10_query
*predicate_impl
;
1611 TRACE("iface %p, predicate %p, value %p.\n", iface
, predicate
, value
);
1613 wined3d_mutex_lock();
1614 if (!(wined3d_predicate
= wined3d_device_get_predication(device
->wined3d_device
, value
)))
1616 wined3d_mutex_unlock();
1621 predicate_impl
= wined3d_query_get_parent(wined3d_predicate
);
1622 wined3d_mutex_unlock();
1623 *predicate
= (ID3D10Predicate
*)&predicate_impl
->ID3D10Query_iface
;
1624 ID3D10Predicate_AddRef(*predicate
);
1627 static void STDMETHODCALLTYPE
d3d10_device_GSGetShaderResources(ID3D10Device1
*iface
,
1628 UINT start_slot
, UINT view_count
, ID3D10ShaderResourceView
**views
)
1630 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1633 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1634 iface
, start_slot
, view_count
, views
);
1636 wined3d_mutex_lock();
1637 for (i
= 0; i
< view_count
; ++i
)
1639 struct wined3d_shader_resource_view
*wined3d_view
;
1640 struct d3d10_shader_resource_view
*view_impl
;
1642 if (!(wined3d_view
= wined3d_device_get_gs_resource_view(device
->wined3d_device
, start_slot
+ i
)))
1648 view_impl
= wined3d_shader_resource_view_get_parent(wined3d_view
);
1649 views
[i
] = &view_impl
->ID3D10ShaderResourceView_iface
;
1650 ID3D10ShaderResourceView_AddRef(views
[i
]);
1652 wined3d_mutex_unlock();
1655 static void STDMETHODCALLTYPE
d3d10_device_GSGetSamplers(ID3D10Device1
*iface
,
1656 UINT start_slot
, UINT sampler_count
, ID3D10SamplerState
**samplers
)
1658 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1661 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1662 iface
, start_slot
, sampler_count
, samplers
);
1664 wined3d_mutex_lock();
1665 for (i
= 0; i
< sampler_count
; ++i
)
1667 struct d3d10_sampler_state
*sampler_impl
;
1668 struct wined3d_sampler
*wined3d_sampler
;
1670 if (!(wined3d_sampler
= wined3d_device_get_gs_sampler(device
->wined3d_device
, start_slot
+ i
)))
1676 sampler_impl
= wined3d_sampler_get_parent(wined3d_sampler
);
1677 samplers
[i
] = &sampler_impl
->ID3D10SamplerState_iface
;
1678 ID3D10SamplerState_AddRef(samplers
[i
]);
1680 wined3d_mutex_unlock();
1683 static void STDMETHODCALLTYPE
d3d10_device_OMGetRenderTargets(ID3D10Device1
*iface
,
1684 UINT view_count
, ID3D10RenderTargetView
**render_target_views
, ID3D10DepthStencilView
**depth_stencil_view
)
1686 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1687 struct wined3d_rendertarget_view
*wined3d_view
;
1689 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1690 iface
, view_count
, render_target_views
, depth_stencil_view
);
1692 wined3d_mutex_lock();
1693 if (render_target_views
)
1695 struct d3d_rendertarget_view
*view_impl
;
1698 for (i
= 0; i
< view_count
; ++i
)
1700 if (!(wined3d_view
= wined3d_device_get_rendertarget_view(device
->wined3d_device
, i
))
1701 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1703 render_target_views
[i
] = NULL
;
1707 render_target_views
[i
] = &view_impl
->ID3D10RenderTargetView_iface
;
1708 ID3D10RenderTargetView_AddRef(render_target_views
[i
]);
1712 if (depth_stencil_view
)
1714 struct d3d_depthstencil_view
*view_impl
;
1716 if (!(wined3d_view
= wined3d_device_get_depth_stencil_view(device
->wined3d_device
))
1717 || !(view_impl
= wined3d_rendertarget_view_get_parent(wined3d_view
)))
1719 *depth_stencil_view
= NULL
;
1723 *depth_stencil_view
= &view_impl
->ID3D10DepthStencilView_iface
;
1724 ID3D10DepthStencilView_AddRef(*depth_stencil_view
);
1727 wined3d_mutex_unlock();
1730 static void STDMETHODCALLTYPE
d3d10_device_OMGetBlendState(ID3D10Device1
*iface
,
1731 ID3D10BlendState
**blend_state
, FLOAT blend_factor
[4], UINT
*sample_mask
)
1733 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1735 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1736 iface
, blend_state
, blend_factor
, sample_mask
);
1738 if ((*blend_state
= device
->blend_state
? &device
->blend_state
->ID3D10BlendState_iface
: NULL
))
1739 ID3D10BlendState_AddRef(*blend_state
);
1740 wined3d_mutex_lock();
1741 memcpy(blend_factor
, device
->blend_factor
, 4 * sizeof(*blend_factor
));
1742 *sample_mask
= wined3d_device_get_render_state(device
->wined3d_device
, WINED3D_RS_MULTISAMPLEMASK
);
1743 wined3d_mutex_unlock();
1746 static void STDMETHODCALLTYPE
d3d10_device_OMGetDepthStencilState(ID3D10Device1
*iface
,
1747 ID3D10DepthStencilState
**depth_stencil_state
, UINT
*stencil_ref
)
1749 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1751 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1752 iface
, depth_stencil_state
, stencil_ref
);
1754 if ((*depth_stencil_state
= device
->depth_stencil_state
1755 ? &device
->depth_stencil_state
->ID3D10DepthStencilState_iface
: NULL
))
1756 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
1757 *stencil_ref
= device
->stencil_ref
;
1760 static void STDMETHODCALLTYPE
d3d10_device_SOGetTargets(ID3D10Device1
*iface
,
1761 UINT buffer_count
, ID3D10Buffer
**buffers
, UINT
*offsets
)
1763 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1766 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1767 iface
, buffer_count
, buffers
, offsets
);
1769 wined3d_mutex_lock();
1770 for (i
= 0; i
< buffer_count
; ++i
)
1772 struct wined3d_buffer
*wined3d_buffer
;
1773 struct d3d_buffer
*buffer_impl
;
1775 if (!(wined3d_buffer
= wined3d_device_get_stream_output(device
->wined3d_device
, i
, &offsets
[i
])))
1781 buffer_impl
= wined3d_buffer_get_parent(wined3d_buffer
);
1782 buffers
[i
] = &buffer_impl
->ID3D10Buffer_iface
;
1783 ID3D10Buffer_AddRef(buffers
[i
]);
1785 wined3d_mutex_unlock();
1788 static void STDMETHODCALLTYPE
d3d10_device_RSGetState(ID3D10Device1
*iface
, ID3D10RasterizerState
**rasterizer_state
)
1790 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1792 TRACE("iface %p, rasterizer_state %p.\n", iface
, rasterizer_state
);
1794 if ((*rasterizer_state
= device
->rasterizer_state
? &device
->rasterizer_state
->ID3D10RasterizerState_iface
: NULL
))
1795 ID3D10RasterizerState_AddRef(*rasterizer_state
);
1798 static void STDMETHODCALLTYPE
d3d10_device_RSGetViewports(ID3D10Device1
*iface
,
1799 UINT
*viewport_count
, D3D10_VIEWPORT
*viewports
)
1801 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1802 struct wined3d_viewport wined3d_vp
;
1804 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface
, viewport_count
, viewports
);
1808 *viewport_count
= 1;
1812 if (!*viewport_count
)
1815 wined3d_mutex_lock();
1816 wined3d_device_get_viewport(device
->wined3d_device
, &wined3d_vp
);
1817 wined3d_mutex_unlock();
1819 viewports
[0].TopLeftX
= wined3d_vp
.x
;
1820 viewports
[0].TopLeftY
= wined3d_vp
.y
;
1821 viewports
[0].Width
= wined3d_vp
.width
;
1822 viewports
[0].Height
= wined3d_vp
.height
;
1823 viewports
[0].MinDepth
= wined3d_vp
.min_z
;
1824 viewports
[0].MaxDepth
= wined3d_vp
.max_z
;
1826 if (*viewport_count
> 1)
1827 memset(&viewports
[1], 0, (*viewport_count
- 1) * sizeof(*viewports
));
1830 static void STDMETHODCALLTYPE
d3d10_device_RSGetScissorRects(ID3D10Device1
*iface
, UINT
*rect_count
, D3D10_RECT
*rects
)
1832 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1834 TRACE("iface %p, rect_count %p, rects %p.\n", iface
, rect_count
, rects
);
1845 wined3d_mutex_lock();
1846 wined3d_device_get_scissor_rect(device
->wined3d_device
, rects
);
1847 wined3d_mutex_unlock();
1848 if (*rect_count
> 1)
1849 memset(&rects
[1], 0, (*rect_count
- 1) * sizeof(*rects
));
1852 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetDeviceRemovedReason(ID3D10Device1
*iface
)
1854 TRACE("iface %p.\n", iface
);
1856 /* In the current implementation the device is never removed, so we can
1857 * just return S_OK here. */
1862 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetExceptionMode(ID3D10Device1
*iface
, UINT flags
)
1864 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
1869 static UINT STDMETHODCALLTYPE
d3d10_device_GetExceptionMode(ID3D10Device1
*iface
)
1871 FIXME("iface %p stub!\n", iface
);
1876 static HRESULT STDMETHODCALLTYPE
d3d10_device_GetPrivateData(ID3D10Device1
*iface
,
1877 REFGUID guid
, UINT
*data_size
, void *data
)
1879 IDXGIDevice
*dxgi_device
;
1882 TRACE("iface %p, guid %s, data_size %p, data %p.\n",
1883 iface
, debugstr_guid(guid
), data_size
, data
);
1885 if (FAILED(hr
= ID3D10Device1_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
1887 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, guid
, data_size
, data
);
1888 IDXGIDevice_Release(dxgi_device
);
1893 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateData(ID3D10Device1
*iface
,
1894 REFGUID guid
, UINT data_size
, const void *data
)
1896 IDXGIDevice
*dxgi_device
;
1899 TRACE("iface %p, guid %s, data_size %u, data %p.\n",
1900 iface
, debugstr_guid(guid
), data_size
, data
);
1902 if (FAILED(hr
= ID3D10Device1_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
1904 hr
= IDXGIDevice_SetPrivateData(dxgi_device
, guid
, data_size
, data
);
1905 IDXGIDevice_Release(dxgi_device
);
1910 static HRESULT STDMETHODCALLTYPE
d3d10_device_SetPrivateDataInterface(ID3D10Device1
*iface
,
1911 REFGUID guid
, const IUnknown
*data
)
1913 IDXGIDevice
*dxgi_device
;
1916 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
1918 if (FAILED(hr
= ID3D10Device1_QueryInterface(iface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
1920 hr
= IDXGIDevice_SetPrivateDataInterface(dxgi_device
, guid
, data
);
1921 IDXGIDevice_Release(dxgi_device
);
1926 static void STDMETHODCALLTYPE
d3d10_device_ClearState(ID3D10Device1
*iface
)
1928 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
1929 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
1932 TRACE("iface %p.\n", iface
);
1934 wined3d_mutex_lock();
1935 wined3d_device_set_vertex_shader(device
->wined3d_device
, NULL
);
1936 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
1938 wined3d_device_set_vs_sampler(device
->wined3d_device
, i
, NULL
);
1940 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1942 wined3d_device_set_vs_resource_view(device
->wined3d_device
, i
, NULL
);
1944 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
1946 wined3d_device_set_vs_cb(device
->wined3d_device
, i
, NULL
);
1948 wined3d_device_set_geometry_shader(device
->wined3d_device
, NULL
);
1949 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
1951 wined3d_device_set_gs_sampler(device
->wined3d_device
, i
, NULL
);
1953 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1955 wined3d_device_set_gs_resource_view(device
->wined3d_device
, i
, NULL
);
1957 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
1959 wined3d_device_set_gs_cb(device
->wined3d_device
, i
, NULL
);
1961 wined3d_device_set_pixel_shader(device
->wined3d_device
, NULL
);
1962 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
1964 wined3d_device_set_ps_sampler(device
->wined3d_device
, i
, NULL
);
1966 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1968 wined3d_device_set_ps_resource_view(device
->wined3d_device
, i
, NULL
);
1970 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
1972 wined3d_device_set_ps_cb(device
->wined3d_device
, i
, NULL
);
1974 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
1976 wined3d_device_set_stream_source(device
->wined3d_device
, i
, NULL
, 0, 0);
1978 wined3d_device_set_index_buffer(device
->wined3d_device
, NULL
, WINED3DFMT_UNKNOWN
);
1979 wined3d_device_set_vertex_declaration(device
->wined3d_device
, NULL
);
1980 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_UNDEFINED
);
1981 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
1983 wined3d_device_set_rendertarget_view(device
->wined3d_device
, i
, NULL
, FALSE
);
1985 wined3d_device_set_depth_stencil_view(device
->wined3d_device
, NULL
);
1986 ID3D10Device1_OMSetDepthStencilState(iface
, NULL
, 0);
1987 ID3D10Device1_OMSetBlendState(iface
, NULL
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
1988 ID3D10Device1_RSSetViewports(iface
, 0, NULL
);
1989 ID3D10Device1_RSSetScissorRects(iface
, 0, NULL
);
1990 ID3D10Device1_RSSetState(iface
, NULL
);
1991 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
1993 wined3d_device_set_stream_output(device
->wined3d_device
, i
, NULL
, 0);
1995 wined3d_device_set_predication(device
->wined3d_device
, NULL
, FALSE
);
1996 wined3d_mutex_unlock();
1999 static void STDMETHODCALLTYPE
d3d10_device_Flush(ID3D10Device1
*iface
)
2001 FIXME("iface %p stub!\n", iface
);
2004 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBuffer(ID3D10Device1
*iface
,
2005 const D3D10_BUFFER_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Buffer
**buffer
)
2007 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2008 D3D11_BUFFER_DESC d3d11_desc
;
2009 struct d3d_buffer
*object
;
2012 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface
, desc
, data
, buffer
);
2014 d3d11_desc
.ByteWidth
= desc
->ByteWidth
;
2015 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
2016 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
2017 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
2018 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
2019 d3d11_desc
.StructureByteStride
= 0;
2021 if (FAILED(hr
= d3d_buffer_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
2024 *buffer
= &object
->ID3D10Buffer_iface
;
2029 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture1D(ID3D10Device1
*iface
,
2030 const D3D10_TEXTURE1D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
, ID3D10Texture1D
**texture
)
2032 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface
, desc
, data
, texture
);
2037 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture2D(ID3D10Device1
*iface
,
2038 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
2039 ID3D10Texture2D
**texture
)
2041 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2042 D3D11_TEXTURE2D_DESC d3d11_desc
;
2043 struct d3d_texture2d
*object
;
2046 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2048 d3d11_desc
.Width
= desc
->Width
;
2049 d3d11_desc
.Height
= desc
->Height
;
2050 d3d11_desc
.MipLevels
= desc
->MipLevels
;
2051 d3d11_desc
.ArraySize
= desc
->ArraySize
;
2052 d3d11_desc
.Format
= desc
->Format
;
2053 d3d11_desc
.SampleDesc
= desc
->SampleDesc
;
2054 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
2055 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
2056 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
2057 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
2059 if (FAILED(hr
= d3d_texture2d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
2062 *texture
= &object
->ID3D10Texture2D_iface
;
2067 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateTexture3D(ID3D10Device1
*iface
,
2068 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
,
2069 ID3D10Texture3D
**texture
)
2071 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2072 D3D11_TEXTURE3D_DESC d3d11_desc
;
2073 struct d3d_texture3d
*object
;
2076 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface
, desc
, data
, texture
);
2078 d3d11_desc
.Width
= desc
->Width
;
2079 d3d11_desc
.Height
= desc
->Height
;
2080 d3d11_desc
.Depth
= desc
->Depth
;
2081 d3d11_desc
.MipLevels
= desc
->MipLevels
;
2082 d3d11_desc
.Format
= desc
->Format
;
2083 d3d11_desc
.Usage
= d3d11_usage_from_d3d10_usage(desc
->Usage
);
2084 d3d11_desc
.BindFlags
= d3d11_bind_flags_from_d3d10_bind_flags(desc
->BindFlags
);
2085 d3d11_desc
.CPUAccessFlags
= d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc
->CPUAccessFlags
);
2086 d3d11_desc
.MiscFlags
= d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc
->MiscFlags
);
2088 if (FAILED(hr
= d3d_texture3d_create(device
, &d3d11_desc
, (const D3D11_SUBRESOURCE_DATA
*)data
, &object
)))
2091 *texture
= &object
->ID3D10Texture3D_iface
;
2096 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView(ID3D10Device1
*iface
,
2097 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10ShaderResourceView
**view
)
2099 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2100 struct d3d10_shader_resource_view
*object
;
2103 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2105 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2106 return E_OUTOFMEMORY
;
2108 if (FAILED(hr
= d3d10_shader_resource_view_init(object
, device
, resource
, desc
)))
2110 WARN("Failed to initialize shader resource view, hr %#x.\n", hr
);
2111 HeapFree(GetProcessHeap(), 0, object
);
2115 TRACE("Created shader resource view %p.\n", object
);
2116 *view
= &object
->ID3D10ShaderResourceView_iface
;
2121 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRenderTargetView(ID3D10Device1
*iface
,
2122 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10RenderTargetView
**view
)
2124 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2125 struct d3d_rendertarget_view
*object
;
2126 ID3D11Resource
*d3d11_resource
;
2129 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2131 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2132 return E_OUTOFMEMORY
;
2134 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
2136 ERR("Resource does not implement ID3D11Resource.\n");
2137 HeapFree(GetProcessHeap(), 0, object
);
2141 if (FAILED(hr
= d3d_rendertarget_view_init(object
, device
, d3d11_resource
, desc
)))
2143 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr
);
2144 HeapFree(GetProcessHeap(), 0, object
);
2145 ID3D11Resource_Release(d3d11_resource
);
2149 ID3D11Resource_Release(d3d11_resource
);
2151 TRACE("Created rendertarget view %p.\n", object
);
2152 *view
= &object
->ID3D10RenderTargetView_iface
;
2157 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilView(ID3D10Device1
*iface
,
2158 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10DepthStencilView
**view
)
2160 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2161 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc
;
2162 struct d3d_depthstencil_view
*object
;
2163 ID3D11Resource
*d3d11_resource
;
2166 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface
, resource
, desc
, view
);
2170 d3d11_desc
.Format
= desc
->Format
;
2171 d3d11_desc
.ViewDimension
= desc
->ViewDimension
;
2172 d3d11_desc
.Flags
= 0;
2173 memcpy(&d3d11_desc
.u
, &desc
->u
, sizeof(d3d11_desc
.u
));
2176 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D11Resource
, (void **)&d3d11_resource
)))
2178 ERR("Resource does not implement ID3D11Resource.\n");
2182 hr
= d3d_depthstencil_view_create(device
, d3d11_resource
, desc
? &d3d11_desc
: NULL
, &object
);
2183 ID3D11Resource_Release(d3d11_resource
);
2187 *view
= &object
->ID3D10DepthStencilView_iface
;
2192 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateInputLayout(ID3D10Device1
*iface
,
2193 const D3D10_INPUT_ELEMENT_DESC
*element_descs
, UINT element_count
,
2194 const void *shader_byte_code
, SIZE_T shader_byte_code_length
,
2195 ID3D10InputLayout
**input_layout
)
2197 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2198 struct d3d10_input_layout
*object
;
2201 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
2202 "shader_byte_code_length %lu, input_layout %p\n",
2203 iface
, element_descs
, element_count
, shader_byte_code
,
2204 shader_byte_code_length
, input_layout
);
2206 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2208 return E_OUTOFMEMORY
;
2210 hr
= d3d10_input_layout_init(object
, This
, element_descs
, element_count
,
2211 shader_byte_code
, shader_byte_code_length
);
2214 WARN("Failed to initialize input layout, hr %#x.\n", hr
);
2215 HeapFree(GetProcessHeap(), 0, object
);
2219 TRACE("Created input layout %p.\n", object
);
2220 *input_layout
= &object
->ID3D10InputLayout_iface
;
2225 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateVertexShader(ID3D10Device1
*iface
,
2226 const void *byte_code
, SIZE_T byte_code_length
, ID3D10VertexShader
**shader
)
2228 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2229 struct d3d10_vertex_shader
*object
;
2232 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
2233 iface
, byte_code
, byte_code_length
, shader
);
2235 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2237 return E_OUTOFMEMORY
;
2239 hr
= d3d10_vertex_shader_init(object
, This
, byte_code
, byte_code_length
);
2242 WARN("Failed to initialize vertex shader, hr %#x.\n", hr
);
2243 HeapFree(GetProcessHeap(), 0, object
);
2247 TRACE("Created vertex shader %p.\n", object
);
2248 *shader
= &object
->ID3D10VertexShader_iface
;
2253 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShader(ID3D10Device1
*iface
,
2254 const void *byte_code
, SIZE_T byte_code_length
, ID3D10GeometryShader
**shader
)
2256 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2257 struct d3d10_geometry_shader
*object
;
2260 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
2261 iface
, byte_code
, byte_code_length
, shader
);
2263 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2265 return E_OUTOFMEMORY
;
2267 hr
= d3d10_geometry_shader_init(object
, This
, byte_code
, byte_code_length
);
2270 WARN("Failed to initialize geometry shader, hr %#x.\n", hr
);
2271 HeapFree(GetProcessHeap(), 0, object
);
2275 TRACE("Created geometry shader %p.\n", object
);
2276 *shader
= &object
->ID3D10GeometryShader_iface
;
2281 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1
*iface
,
2282 const void *byte_code
, SIZE_T byte_code_length
, const D3D10_SO_DECLARATION_ENTRY
*output_stream_decls
,
2283 UINT output_stream_decl_count
, UINT output_stream_stride
, ID3D10GeometryShader
**shader
)
2285 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
2286 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
2287 iface
, byte_code
, byte_code_length
, output_stream_decls
,
2288 output_stream_decl_count
, output_stream_stride
, shader
);
2293 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePixelShader(ID3D10Device1
*iface
,
2294 const void *byte_code
, SIZE_T byte_code_length
, ID3D10PixelShader
**shader
)
2296 struct d3d_device
*This
= impl_from_ID3D10Device(iface
);
2297 struct d3d10_pixel_shader
*object
;
2300 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
2301 iface
, byte_code
, byte_code_length
, shader
);
2303 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2305 return E_OUTOFMEMORY
;
2307 hr
= d3d10_pixel_shader_init(object
, This
, byte_code
, byte_code_length
);
2310 WARN("Failed to initialize pixel shader, hr %#x.\n", hr
);
2311 HeapFree(GetProcessHeap(), 0, object
);
2315 TRACE("Created pixel shader %p.\n", object
);
2316 *shader
= &object
->ID3D10PixelShader_iface
;
2321 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState(ID3D10Device1
*iface
,
2322 const D3D10_BLEND_DESC
*desc
, ID3D10BlendState
**blend_state
)
2324 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2325 struct d3d10_blend_state
*object
;
2326 struct wine_rb_entry
*entry
;
2329 TRACE("iface %p, desc %p, blend_state %p.\n", iface
, desc
, blend_state
);
2332 return E_INVALIDARG
;
2334 wined3d_mutex_lock();
2335 if ((entry
= wine_rb_get(&device
->blend_states
, desc
)))
2337 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_blend_state
, entry
);
2339 TRACE("Returning existing blend state %p.\n", object
);
2340 *blend_state
= &object
->ID3D10BlendState_iface
;
2341 ID3D10BlendState_AddRef(*blend_state
);
2342 wined3d_mutex_unlock();
2346 wined3d_mutex_unlock();
2348 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2350 return E_OUTOFMEMORY
;
2352 if (FAILED(hr
= d3d10_blend_state_init(object
, device
, desc
)))
2354 WARN("Failed to initialize blend state, hr %#x.\n", hr
);
2355 HeapFree(GetProcessHeap(), 0, object
);
2359 TRACE("Created blend state %p.\n", object
);
2360 *blend_state
= &object
->ID3D10BlendState_iface
;
2365 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateDepthStencilState(ID3D10Device1
*iface
,
2366 const D3D10_DEPTH_STENCIL_DESC
*desc
, ID3D10DepthStencilState
**depth_stencil_state
)
2368 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2369 struct d3d10_depthstencil_state
*object
;
2370 D3D10_DEPTH_STENCIL_DESC tmp_desc
;
2371 struct wine_rb_entry
*entry
;
2374 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface
, desc
, depth_stencil_state
);
2377 return E_INVALIDARG
;
2379 /* D3D10_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2380 * it as a key in the rbtree. */
2381 memset(&tmp_desc
, 0, sizeof(tmp_desc
));
2382 tmp_desc
.DepthEnable
= desc
->DepthEnable
;
2383 tmp_desc
.DepthWriteMask
= desc
->DepthWriteMask
;
2384 tmp_desc
.DepthFunc
= desc
->DepthFunc
;
2385 tmp_desc
.StencilEnable
= desc
->StencilEnable
;
2386 tmp_desc
.StencilReadMask
= desc
->StencilReadMask
;
2387 tmp_desc
.StencilWriteMask
= desc
->StencilWriteMask
;
2388 tmp_desc
.FrontFace
= desc
->FrontFace
;
2389 tmp_desc
.BackFace
= desc
->BackFace
;
2391 wined3d_mutex_lock();
2392 if ((entry
= wine_rb_get(&device
->depthstencil_states
, &tmp_desc
)))
2394 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_depthstencil_state
, entry
);
2396 TRACE("Returning existing depthstencil state %p.\n", object
);
2397 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
2398 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
2399 wined3d_mutex_unlock();
2403 wined3d_mutex_unlock();
2405 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2407 return E_OUTOFMEMORY
;
2409 if (FAILED(hr
= d3d10_depthstencil_state_init(object
, device
, &tmp_desc
)))
2411 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr
);
2412 HeapFree(GetProcessHeap(), 0, object
);
2416 TRACE("Created depthstencil state %p.\n", object
);
2417 *depth_stencil_state
= &object
->ID3D10DepthStencilState_iface
;
2422 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateRasterizerState(ID3D10Device1
*iface
,
2423 const D3D10_RASTERIZER_DESC
*desc
, ID3D10RasterizerState
**rasterizer_state
)
2425 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2426 struct d3d10_rasterizer_state
*object
;
2427 struct wine_rb_entry
*entry
;
2430 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface
, desc
, rasterizer_state
);
2433 return E_INVALIDARG
;
2435 wined3d_mutex_lock();
2436 if ((entry
= wine_rb_get(&device
->rasterizer_states
, desc
)))
2438 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_rasterizer_state
, entry
);
2440 TRACE("Returning existing rasterizer state %p.\n", object
);
2441 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
2442 ID3D10RasterizerState_AddRef(*rasterizer_state
);
2443 wined3d_mutex_unlock();
2447 wined3d_mutex_unlock();
2449 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2451 return E_OUTOFMEMORY
;
2453 if (FAILED(hr
= d3d10_rasterizer_state_init(object
, device
, desc
)))
2455 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr
);
2456 HeapFree(GetProcessHeap(), 0, object
);
2460 TRACE("Created rasterizer state %p.\n", object
);
2461 *rasterizer_state
= &object
->ID3D10RasterizerState_iface
;
2466 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateSamplerState(ID3D10Device1
*iface
,
2467 const D3D10_SAMPLER_DESC
*desc
, ID3D10SamplerState
**sampler_state
)
2469 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2470 struct d3d10_sampler_state
*object
;
2471 struct wine_rb_entry
*entry
;
2474 TRACE("iface %p, desc %p, sampler_state %p.\n", iface
, desc
, sampler_state
);
2477 return E_INVALIDARG
;
2479 wined3d_mutex_lock();
2480 if ((entry
= wine_rb_get(&device
->sampler_states
, desc
)))
2482 object
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_sampler_state
, entry
);
2484 TRACE("Returning existing sampler state %p.\n", object
);
2485 *sampler_state
= &object
->ID3D10SamplerState_iface
;
2486 ID3D10SamplerState_AddRef(*sampler_state
);
2487 wined3d_mutex_unlock();
2491 wined3d_mutex_unlock();
2493 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2495 return E_OUTOFMEMORY
;
2497 if (FAILED(hr
= d3d10_sampler_state_init(object
, device
, desc
)))
2499 WARN("Failed to initialize sampler state, hr %#x.\n", hr
);
2500 HeapFree(GetProcessHeap(), 0, object
);
2504 TRACE("Created sampler state %p.\n", object
);
2505 *sampler_state
= &object
->ID3D10SamplerState_iface
;
2510 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateQuery(ID3D10Device1
*iface
,
2511 const D3D10_QUERY_DESC
*desc
, ID3D10Query
**query
)
2513 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2514 struct d3d10_query
*object
;
2517 TRACE("iface %p, desc %p, query %p.\n", iface
, desc
, query
);
2519 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2520 return E_OUTOFMEMORY
;
2522 if (FAILED(hr
= d3d10_query_init(object
, device
, desc
, FALSE
)))
2524 WARN("Failed to initialize query, hr %#x.\n", hr
);
2525 HeapFree(GetProcessHeap(), 0, object
);
2529 TRACE("Created query %p.\n", object
);
2530 *query
= &object
->ID3D10Query_iface
;
2535 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreatePredicate(ID3D10Device1
*iface
,
2536 const D3D10_QUERY_DESC
*desc
, ID3D10Predicate
**predicate
)
2538 struct d3d_device
*device
= impl_from_ID3D10Device(iface
);
2539 struct d3d10_query
*object
;
2542 TRACE("iface %p, desc %p, predicate %p.\n", iface
, desc
, predicate
);
2545 return E_INVALIDARG
;
2547 if (desc
->Query
!= D3D10_QUERY_OCCLUSION_PREDICATE
&& desc
->Query
!= D3D10_QUERY_SO_OVERFLOW_PREDICATE
)
2549 WARN("Query type %#x is not a predicate.\n", desc
->Query
);
2550 return E_INVALIDARG
;
2553 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
2554 return E_OUTOFMEMORY
;
2556 if (FAILED(hr
= d3d10_query_init(object
, device
, desc
, TRUE
)))
2558 WARN("Failed to initialize predicate, hr %#x.\n", hr
);
2559 HeapFree(GetProcessHeap(), 0, object
);
2563 TRACE("Created predicate %p.\n", object
);
2564 *predicate
= (ID3D10Predicate
*)&object
->ID3D10Query_iface
;
2569 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateCounter(ID3D10Device1
*iface
,
2570 const D3D10_COUNTER_DESC
*desc
, ID3D10Counter
**counter
)
2572 FIXME("iface %p, desc %p, counter %p stub!\n", iface
, desc
, counter
);
2577 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckFormatSupport(ID3D10Device1
*iface
,
2578 DXGI_FORMAT format
, UINT
*format_support
)
2580 FIXME("iface %p, format %s, format_support %p stub!\n",
2581 iface
, debug_dxgi_format(format
), format_support
);
2586 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1
*iface
,
2587 DXGI_FORMAT format
, UINT sample_count
, UINT
*quality_level_count
)
2589 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
2590 iface
, debug_dxgi_format(format
), sample_count
, quality_level_count
);
2595 static void STDMETHODCALLTYPE
d3d10_device_CheckCounterInfo(ID3D10Device1
*iface
, D3D10_COUNTER_INFO
*counter_info
)
2597 FIXME("iface %p, counter_info %p stub!\n", iface
, counter_info
);
2600 static HRESULT STDMETHODCALLTYPE
d3d10_device_CheckCounter(ID3D10Device1
*iface
,
2601 const D3D10_COUNTER_DESC
*desc
, D3D10_COUNTER_TYPE
*type
, UINT
*active_counters
, char *name
,
2602 UINT
*name_length
, char *units
, UINT
*units_length
, char *description
, UINT
*description_length
)
2604 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
2605 "units %p, units_length %p, description %p, description_length %p stub!\n",
2606 iface
, desc
, type
, active_counters
, name
, name_length
,
2607 units
, units_length
, description
, description_length
);
2612 static UINT STDMETHODCALLTYPE
d3d10_device_GetCreationFlags(ID3D10Device1
*iface
)
2614 FIXME("iface %p stub!\n", iface
);
2619 static HRESULT STDMETHODCALLTYPE
d3d10_device_OpenSharedResource(ID3D10Device1
*iface
,
2620 HANDLE resource_handle
, REFIID guid
, void **resource
)
2622 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
2623 iface
, resource_handle
, debugstr_guid(guid
), resource
);
2628 static void STDMETHODCALLTYPE
d3d10_device_SetTextFilterSize(ID3D10Device1
*iface
, UINT width
, UINT height
)
2630 FIXME("iface %p, width %u, height %u stub!\n", iface
, width
, height
);
2633 static void STDMETHODCALLTYPE
d3d10_device_GetTextFilterSize(ID3D10Device1
*iface
, UINT
*width
, UINT
*height
)
2635 FIXME("iface %p, width %p, height %p stub!\n", iface
, width
, height
);
2638 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateShaderResourceView1(ID3D10Device1
*iface
,
2639 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
*desc
, ID3D10ShaderResourceView1
**view
)
2641 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface
, resource
, desc
, view
);
2646 static HRESULT STDMETHODCALLTYPE
d3d10_device_CreateBlendState1(ID3D10Device1
*iface
,
2647 const D3D10_BLEND_DESC1
*desc
, ID3D10BlendState1
**blend_state
)
2649 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface
, desc
, blend_state
);
2654 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE
d3d10_device_GetFeatureLevel(ID3D10Device1
*iface
)
2656 FIXME("iface %p stub!\n", iface
);
2658 return D3D10_FEATURE_LEVEL_10_1
;
2661 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl
=
2663 /* IUnknown methods */
2664 d3d10_device_QueryInterface
,
2665 d3d10_device_AddRef
,
2666 d3d10_device_Release
,
2667 /* ID3D10Device methods */
2668 d3d10_device_VSSetConstantBuffers
,
2669 d3d10_device_PSSetShaderResources
,
2670 d3d10_device_PSSetShader
,
2671 d3d10_device_PSSetSamplers
,
2672 d3d10_device_VSSetShader
,
2673 d3d10_device_DrawIndexed
,
2675 d3d10_device_PSSetConstantBuffers
,
2676 d3d10_device_IASetInputLayout
,
2677 d3d10_device_IASetVertexBuffers
,
2678 d3d10_device_IASetIndexBuffer
,
2679 d3d10_device_DrawIndexedInstanced
,
2680 d3d10_device_DrawInstanced
,
2681 d3d10_device_GSSetConstantBuffers
,
2682 d3d10_device_GSSetShader
,
2683 d3d10_device_IASetPrimitiveTopology
,
2684 d3d10_device_VSSetShaderResources
,
2685 d3d10_device_VSSetSamplers
,
2686 d3d10_device_SetPredication
,
2687 d3d10_device_GSSetShaderResources
,
2688 d3d10_device_GSSetSamplers
,
2689 d3d10_device_OMSetRenderTargets
,
2690 d3d10_device_OMSetBlendState
,
2691 d3d10_device_OMSetDepthStencilState
,
2692 d3d10_device_SOSetTargets
,
2693 d3d10_device_DrawAuto
,
2694 d3d10_device_RSSetState
,
2695 d3d10_device_RSSetViewports
,
2696 d3d10_device_RSSetScissorRects
,
2697 d3d10_device_CopySubresourceRegion
,
2698 d3d10_device_CopyResource
,
2699 d3d10_device_UpdateSubresource
,
2700 d3d10_device_ClearRenderTargetView
,
2701 d3d10_device_ClearDepthStencilView
,
2702 d3d10_device_GenerateMips
,
2703 d3d10_device_ResolveSubresource
,
2704 d3d10_device_VSGetConstantBuffers
,
2705 d3d10_device_PSGetShaderResources
,
2706 d3d10_device_PSGetShader
,
2707 d3d10_device_PSGetSamplers
,
2708 d3d10_device_VSGetShader
,
2709 d3d10_device_PSGetConstantBuffers
,
2710 d3d10_device_IAGetInputLayout
,
2711 d3d10_device_IAGetVertexBuffers
,
2712 d3d10_device_IAGetIndexBuffer
,
2713 d3d10_device_GSGetConstantBuffers
,
2714 d3d10_device_GSGetShader
,
2715 d3d10_device_IAGetPrimitiveTopology
,
2716 d3d10_device_VSGetShaderResources
,
2717 d3d10_device_VSGetSamplers
,
2718 d3d10_device_GetPredication
,
2719 d3d10_device_GSGetShaderResources
,
2720 d3d10_device_GSGetSamplers
,
2721 d3d10_device_OMGetRenderTargets
,
2722 d3d10_device_OMGetBlendState
,
2723 d3d10_device_OMGetDepthStencilState
,
2724 d3d10_device_SOGetTargets
,
2725 d3d10_device_RSGetState
,
2726 d3d10_device_RSGetViewports
,
2727 d3d10_device_RSGetScissorRects
,
2728 d3d10_device_GetDeviceRemovedReason
,
2729 d3d10_device_SetExceptionMode
,
2730 d3d10_device_GetExceptionMode
,
2731 d3d10_device_GetPrivateData
,
2732 d3d10_device_SetPrivateData
,
2733 d3d10_device_SetPrivateDataInterface
,
2734 d3d10_device_ClearState
,
2736 d3d10_device_CreateBuffer
,
2737 d3d10_device_CreateTexture1D
,
2738 d3d10_device_CreateTexture2D
,
2739 d3d10_device_CreateTexture3D
,
2740 d3d10_device_CreateShaderResourceView
,
2741 d3d10_device_CreateRenderTargetView
,
2742 d3d10_device_CreateDepthStencilView
,
2743 d3d10_device_CreateInputLayout
,
2744 d3d10_device_CreateVertexShader
,
2745 d3d10_device_CreateGeometryShader
,
2746 d3d10_device_CreateGeometryShaderWithStreamOutput
,
2747 d3d10_device_CreatePixelShader
,
2748 d3d10_device_CreateBlendState
,
2749 d3d10_device_CreateDepthStencilState
,
2750 d3d10_device_CreateRasterizerState
,
2751 d3d10_device_CreateSamplerState
,
2752 d3d10_device_CreateQuery
,
2753 d3d10_device_CreatePredicate
,
2754 d3d10_device_CreateCounter
,
2755 d3d10_device_CheckFormatSupport
,
2756 d3d10_device_CheckMultisampleQualityLevels
,
2757 d3d10_device_CheckCounterInfo
,
2758 d3d10_device_CheckCounter
,
2759 d3d10_device_GetCreationFlags
,
2760 d3d10_device_OpenSharedResource
,
2761 d3d10_device_SetTextFilterSize
,
2762 d3d10_device_GetTextFilterSize
,
2763 d3d10_device_CreateShaderResourceView1
,
2764 d3d10_device_CreateBlendState1
,
2765 d3d10_device_GetFeatureLevel
,
2768 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl
=
2770 /* IUnknown methods */
2771 d3d10_device_inner_QueryInterface
,
2772 d3d10_device_inner_AddRef
,
2773 d3d10_device_inner_Release
,
2776 /* ID3D10Multithread methods */
2778 static inline struct d3d_device
*impl_from_ID3D10Multithread(ID3D10Multithread
*iface
)
2780 return CONTAINING_RECORD(iface
, struct d3d_device
, ID3D10Multithread_iface
);
2783 static HRESULT STDMETHODCALLTYPE
d3d10_multithread_QueryInterface(ID3D10Multithread
*iface
, REFIID iid
, void **out
)
2785 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
2787 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
2789 return IUnknown_QueryInterface(device
->outer_unk
, iid
, out
);
2792 static ULONG STDMETHODCALLTYPE
d3d10_multithread_AddRef(ID3D10Multithread
*iface
)
2794 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
2796 TRACE("iface %p.\n", iface
);
2798 return IUnknown_AddRef(device
->outer_unk
);
2801 static ULONG STDMETHODCALLTYPE
d3d10_multithread_Release(ID3D10Multithread
*iface
)
2803 struct d3d_device
*device
= impl_from_ID3D10Multithread(iface
);
2805 TRACE("iface %p.\n", iface
);
2807 return IUnknown_Release(device
->outer_unk
);
2810 static void STDMETHODCALLTYPE
d3d10_multithread_Enter(ID3D10Multithread
*iface
)
2812 TRACE("iface %p.\n", iface
);
2814 wined3d_mutex_lock();
2817 static void STDMETHODCALLTYPE
d3d10_multithread_Leave(ID3D10Multithread
*iface
)
2819 TRACE("iface %p.\n", iface
);
2821 wined3d_mutex_unlock();
2824 static BOOL STDMETHODCALLTYPE
d3d10_multithread_SetMultithreadProtected(ID3D10Multithread
*iface
, BOOL protect
)
2826 FIXME("iface %p, protect %#x stub!\n", iface
, protect
);
2831 static BOOL STDMETHODCALLTYPE
d3d10_multithread_GetMultithreadProtected(ID3D10Multithread
*iface
)
2833 FIXME("iface %p stub!\n", iface
);
2838 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl
=
2840 d3d10_multithread_QueryInterface
,
2841 d3d10_multithread_AddRef
,
2842 d3d10_multithread_Release
,
2843 d3d10_multithread_Enter
,
2844 d3d10_multithread_Leave
,
2845 d3d10_multithread_SetMultithreadProtected
,
2846 d3d10_multithread_GetMultithreadProtected
,
2849 /* IWineDXGIDeviceParent IUnknown methods */
2851 static inline struct d3d_device
*device_from_dxgi_device_parent(IWineDXGIDeviceParent
*iface
)
2853 return CONTAINING_RECORD(iface
, struct d3d_device
, IWineDXGIDeviceParent_iface
);
2856 static HRESULT STDMETHODCALLTYPE
dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent
*iface
,
2857 REFIID riid
, void **ppv
)
2859 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2860 return IUnknown_QueryInterface(device
->outer_unk
, riid
, ppv
);
2863 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_AddRef(IWineDXGIDeviceParent
*iface
)
2865 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2866 return IUnknown_AddRef(device
->outer_unk
);
2869 static ULONG STDMETHODCALLTYPE
dxgi_device_parent_Release(IWineDXGIDeviceParent
*iface
)
2871 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2872 return IUnknown_Release(device
->outer_unk
);
2875 static struct wined3d_device_parent
* STDMETHODCALLTYPE
dxgi_device_parent_get_wined3d_device_parent(
2876 IWineDXGIDeviceParent
*iface
)
2878 struct d3d_device
*device
= device_from_dxgi_device_parent(iface
);
2879 return &device
->device_parent
;
2882 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl
=
2884 /* IUnknown methods */
2885 dxgi_device_parent_QueryInterface
,
2886 dxgi_device_parent_AddRef
,
2887 dxgi_device_parent_Release
,
2888 /* IWineDXGIDeviceParent methods */
2889 dxgi_device_parent_get_wined3d_device_parent
,
2892 static inline struct d3d_device
*device_from_wined3d_device_parent(struct wined3d_device_parent
*device_parent
)
2894 return CONTAINING_RECORD(device_parent
, struct d3d_device
, device_parent
);
2897 static void CDECL
device_parent_wined3d_device_created(struct wined3d_device_parent
*device_parent
,
2898 struct wined3d_device
*wined3d_device
)
2900 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
2902 TRACE("device_parent %p, wined3d_device %p.\n", device_parent
, wined3d_device
);
2904 wined3d_device_incref(wined3d_device
);
2905 device
->wined3d_device
= wined3d_device
;
2908 static void CDECL
device_parent_mode_changed(struct wined3d_device_parent
*device_parent
)
2910 TRACE("device_parent %p.\n", device_parent
);
2913 static void CDECL
device_parent_activate(struct wined3d_device_parent
*device_parent
, BOOL activate
)
2915 TRACE("device_parent %p, activate %#x.\n", device_parent
, activate
);
2918 static HRESULT CDECL
device_parent_surface_created(struct wined3d_device_parent
*device_parent
,
2919 void *container_parent
, struct wined3d_surface
*surface
, void **parent
,
2920 const struct wined3d_parent_ops
**parent_ops
)
2922 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2923 device_parent
, container_parent
, surface
, parent
, parent_ops
);
2926 *parent_ops
= &d3d10_null_wined3d_parent_ops
;
2931 static HRESULT CDECL
device_parent_volume_created(struct wined3d_device_parent
*device_parent
,
2932 void *container_parent
, struct wined3d_volume
*volume
, void **parent
,
2933 const struct wined3d_parent_ops
**parent_ops
)
2935 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2936 device_parent
, container_parent
, volume
, parent
, parent_ops
);
2939 *parent_ops
= &d3d10_null_wined3d_parent_ops
;
2944 static HRESULT CDECL
device_parent_create_swapchain_texture(struct wined3d_device_parent
*device_parent
,
2945 void *container_parent
, const struct wined3d_resource_desc
*wined3d_desc
,
2946 struct wined3d_texture
**wined3d_texture
)
2948 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
2949 struct d3d_texture2d
*texture
;
2950 ID3D10Texture2D
*texture_iface
;
2951 D3D10_TEXTURE2D_DESC desc
;
2954 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
2955 device_parent
, container_parent
, wined3d_desc
, wined3d_texture
);
2957 FIXME("Implement DXGI<->wined3d usage conversion\n");
2959 desc
.Width
= wined3d_desc
->width
;
2960 desc
.Height
= wined3d_desc
->height
;
2963 desc
.Format
= dxgi_format_from_wined3dformat(wined3d_desc
->format
);
2964 desc
.SampleDesc
.Count
= wined3d_desc
->multisample_type
? wined3d_desc
->multisample_type
: 1;
2965 desc
.SampleDesc
.Quality
= wined3d_desc
->multisample_quality
;
2966 desc
.Usage
= D3D10_USAGE_DEFAULT
;
2967 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
2968 desc
.CPUAccessFlags
= 0;
2971 if (FAILED(hr
= d3d10_device_CreateTexture2D(&device
->ID3D10Device1_iface
,
2972 &desc
, NULL
, &texture_iface
)))
2974 ERR("CreateTexture2D failed, returning %#x\n", hr
);
2978 texture
= impl_from_ID3D10Texture2D(texture_iface
);
2980 *wined3d_texture
= texture
->wined3d_texture
;
2981 wined3d_texture_incref(*wined3d_texture
);
2982 ID3D10Texture2D_Release(&texture
->ID3D10Texture2D_iface
);
2987 static HRESULT CDECL
device_parent_create_swapchain(struct wined3d_device_parent
*device_parent
,
2988 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain
**swapchain
)
2990 struct d3d_device
*device
= device_from_wined3d_device_parent(device_parent
);
2991 IWineDXGIDevice
*wine_device
;
2994 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent
, desc
, swapchain
);
2996 if (FAILED(hr
= d3d10_device_QueryInterface(&device
->ID3D10Device1_iface
,
2997 &IID_IWineDXGIDevice
, (void **)&wine_device
)))
2999 ERR("Device should implement IWineDXGIDevice.\n");
3003 hr
= IWineDXGIDevice_create_swapchain(wine_device
, desc
, swapchain
);
3004 IWineDXGIDevice_Release(wine_device
);
3007 ERR("Failed to create DXGI swapchain, returning %#x\n", hr
);
3014 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops
=
3016 device_parent_wined3d_device_created
,
3017 device_parent_mode_changed
,
3018 device_parent_activate
,
3019 device_parent_surface_created
,
3020 device_parent_volume_created
,
3021 device_parent_create_swapchain_texture
,
3022 device_parent_create_swapchain
,
3025 static void *d3d10_rb_alloc(size_t size
)
3027 return HeapAlloc(GetProcessHeap(), 0, size
);
3030 static void *d3d10_rb_realloc(void *ptr
, size_t size
)
3032 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
3035 static void d3d10_rb_free(void *ptr
)
3037 HeapFree(GetProcessHeap(), 0, ptr
);
3040 static int d3d10_sampler_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3042 const D3D10_SAMPLER_DESC
*ka
= key
;
3043 const D3D10_SAMPLER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_sampler_state
, entry
)->desc
;
3045 return memcmp(ka
, kb
, sizeof(*ka
));
3048 static const struct wine_rb_functions d3d10_sampler_state_rb_ops
=
3053 d3d10_sampler_state_compare
,
3056 static int d3d10_blend_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3058 const D3D10_BLEND_DESC
*ka
= key
;
3059 const D3D10_BLEND_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_blend_state
, entry
)->desc
;
3061 return memcmp(ka
, kb
, sizeof(*ka
));
3064 static const struct wine_rb_functions d3d10_blend_state_rb_ops
=
3069 d3d10_blend_state_compare
,
3072 static int d3d10_depthstencil_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3074 const D3D10_DEPTH_STENCIL_DESC
*ka
= key
;
3075 const D3D10_DEPTH_STENCIL_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
3076 const struct d3d10_depthstencil_state
, entry
)->desc
;
3078 return memcmp(ka
, kb
, sizeof(*ka
));
3081 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops
=
3086 d3d10_depthstencil_state_compare
,
3089 static int d3d10_rasterizer_state_compare(const void *key
, const struct wine_rb_entry
*entry
)
3091 const D3D10_RASTERIZER_DESC
*ka
= key
;
3092 const D3D10_RASTERIZER_DESC
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_rasterizer_state
, entry
)->desc
;
3094 return memcmp(ka
, kb
, sizeof(*ka
));
3097 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops
=
3102 d3d10_rasterizer_state_compare
,
3105 HRESULT
d3d10_device_init(struct d3d_device
*device
, void *outer_unknown
)
3107 device
->IUnknown_inner
.lpVtbl
= &d3d10_device_inner_unknown_vtbl
;
3108 device
->ID3D11Device_iface
.lpVtbl
= &d3d11_device_vtbl
;
3109 device
->ID3D10Device1_iface
.lpVtbl
= &d3d10_device1_vtbl
;
3110 device
->ID3D10Multithread_iface
.lpVtbl
= &d3d10_multithread_vtbl
;
3111 device
->IWineDXGIDeviceParent_iface
.lpVtbl
= &d3d10_dxgi_device_parent_vtbl
;
3112 device
->device_parent
.ops
= &d3d10_wined3d_device_parent_ops
;
3113 device
->refcount
= 1;
3114 /* COM aggregation always takes place */
3115 device
->outer_unk
= outer_unknown
;
3117 if (wine_rb_init(&device
->blend_states
, &d3d10_blend_state_rb_ops
) == -1)
3119 WARN("Failed to initialize blend state rbtree.\n");
3122 device
->blend_factor
[0] = 1.0f
;
3123 device
->blend_factor
[1] = 1.0f
;
3124 device
->blend_factor
[2] = 1.0f
;
3125 device
->blend_factor
[3] = 1.0f
;
3127 if (wine_rb_init(&device
->depthstencil_states
, &d3d10_depthstencil_state_rb_ops
) == -1)
3129 WARN("Failed to initialize depthstencil state rbtree.\n");
3130 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3134 if (wine_rb_init(&device
->rasterizer_states
, &d3d10_rasterizer_state_rb_ops
) == -1)
3136 WARN("Failed to initialize rasterizer state rbtree.\n");
3137 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3138 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);
3142 if (wine_rb_init(&device
->sampler_states
, &d3d10_sampler_state_rb_ops
) == -1)
3144 WARN("Failed to initialize sampler state rbtree.\n");
3145 wine_rb_destroy(&device
->rasterizer_states
, NULL
, NULL
);
3146 wine_rb_destroy(&device
->depthstencil_states
, NULL
, NULL
);
3147 wine_rb_destroy(&device
->blend_states
, NULL
, NULL
);