2 * Copyright 2009 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 "d3d10core_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core
);
28 static struct wined3d_resource
*wined3d_resource_from_resource(ID3D10Resource
*resource
)
30 D3D10_RESOURCE_DIMENSION dimension
;
32 ID3D10Resource_GetType(resource
, &dimension
);
36 case D3D10_RESOURCE_DIMENSION_BUFFER
:
37 return wined3d_buffer_get_resource(((struct d3d10_buffer
*)resource
)->wined3d_buffer
);
39 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
40 return wined3d_texture_get_resource(((struct d3d10_texture2d
*)resource
)->wined3d_texture
);
43 FIXME("Unhandled resource dimension %#x.\n", dimension
);
48 static HRESULT
set_dsdesc_from_resource(D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
, ID3D10Resource
*resource
)
50 D3D10_RESOURCE_DIMENSION dimension
;
52 ID3D10Resource_GetType(resource
, &dimension
);
56 case D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
58 D3D10_TEXTURE1D_DESC texture_desc
;
59 ID3D10Texture1D
*texture
;
61 if (FAILED(ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture1D
, (void **)&texture
)))
63 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D.\n");
67 ID3D10Texture1D_GetDesc(texture
, &texture_desc
);
68 ID3D10Texture1D_Release(texture
);
70 desc
->Format
= texture_desc
.Format
;
71 if (texture_desc
.ArraySize
== 1)
73 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE1D
;
74 desc
->u
.Texture1D
.MipSlice
= 0;
78 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE1DARRAY
;
79 desc
->u
.Texture1DArray
.MipSlice
= 0;
80 desc
->u
.Texture1DArray
.FirstArraySlice
= 0;
81 desc
->u
.Texture1DArray
.ArraySize
= 1;
87 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
89 D3D10_TEXTURE2D_DESC texture_desc
;
90 ID3D10Texture2D
*texture
;
92 if (FAILED(ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture2D
, (void **)&texture
)))
94 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D.\n");
98 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
99 ID3D10Texture2D_Release(texture
);
101 desc
->Format
= texture_desc
.Format
;
102 if (texture_desc
.ArraySize
== 1)
104 if (texture_desc
.SampleDesc
.Count
== 1)
106 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2D
;
107 desc
->u
.Texture2D
.MipSlice
= 0;
111 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2DMS
;
116 if (texture_desc
.SampleDesc
.Count
== 1)
118 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2DARRAY
;
119 desc
->u
.Texture2DArray
.MipSlice
= 0;
120 desc
->u
.Texture2DArray
.FirstArraySlice
= 0;
121 desc
->u
.Texture2DArray
.ArraySize
= 1;
125 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY
;
126 desc
->u
.Texture2DMSArray
.FirstArraySlice
= 0;
127 desc
->u
.Texture2DMSArray
.ArraySize
= 1;
135 FIXME("Unhandled resource dimension %#x.\n", dimension
);
136 case D3D10_RESOURCE_DIMENSION_BUFFER
:
137 case D3D10_RESOURCE_DIMENSION_TEXTURE3D
:
142 static HRESULT
set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10Resource
*resource
)
144 D3D10_RESOURCE_DIMENSION dimension
;
147 ID3D10Resource_GetType(resource
, &dimension
);
151 case D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
153 ID3D10Texture1D
*texture
;
154 D3D10_TEXTURE1D_DESC texture_desc
;
156 hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture1D
, (void **)&texture
);
159 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D?\n");
163 ID3D10Texture1D_GetDesc(texture
, &texture_desc
);
164 ID3D10Texture1D_Release(texture
);
166 desc
->Format
= texture_desc
.Format
;
167 if (texture_desc
.ArraySize
== 1)
169 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE1D
;
170 desc
->u
.Texture1D
.MipSlice
= 0;
174 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE1DARRAY
;
175 desc
->u
.Texture1DArray
.MipSlice
= 0;
176 desc
->u
.Texture1DArray
.FirstArraySlice
= 0;
177 desc
->u
.Texture1DArray
.ArraySize
= 1;
183 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
185 ID3D10Texture2D
*texture
;
186 D3D10_TEXTURE2D_DESC texture_desc
;
188 hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture2D
, (void **)&texture
);
191 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D?\n");
195 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
196 ID3D10Texture2D_Release(texture
);
198 desc
->Format
= texture_desc
.Format
;
199 if (texture_desc
.ArraySize
== 1)
201 if (texture_desc
.SampleDesc
.Count
== 1)
203 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2D
;
204 desc
->u
.Texture2D
.MipSlice
= 0;
208 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2DMS
;
213 if (texture_desc
.SampleDesc
.Count
== 1)
215 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2DARRAY
;
216 desc
->u
.Texture2DArray
.MipSlice
= 0;
217 desc
->u
.Texture2DArray
.FirstArraySlice
= 0;
218 desc
->u
.Texture2DArray
.ArraySize
= 1;
222 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY
;
223 desc
->u
.Texture2DMSArray
.FirstArraySlice
= 0;
224 desc
->u
.Texture2DMSArray
.ArraySize
= 1;
231 case D3D10_RESOURCE_DIMENSION_TEXTURE3D
:
233 ID3D10Texture3D
*texture
;
234 D3D10_TEXTURE3D_DESC texture_desc
;
236 hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture3D
, (void **)&texture
);
239 ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D?\n");
243 ID3D10Texture3D_GetDesc(texture
, &texture_desc
);
244 ID3D10Texture3D_Release(texture
);
246 desc
->Format
= texture_desc
.Format
;
247 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE3D
;
248 desc
->u
.Texture3D
.MipSlice
= 0;
249 desc
->u
.Texture3D
.FirstWSlice
= 0;
250 desc
->u
.Texture3D
.WSize
= 1;
256 FIXME("Unhandled resource dimension %#x.\n", dimension
);
261 static HRESULT
set_srdesc_from_resource(D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10Resource
*resource
)
263 D3D10_RESOURCE_DIMENSION dimension
;
265 ID3D10Resource_GetType(resource
, &dimension
);
269 case D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
271 D3D10_TEXTURE1D_DESC texture_desc
;
272 ID3D10Texture1D
*texture
;
274 if (FAILED(ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture1D
, (void **)&texture
)))
276 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D.\n");
280 ID3D10Texture1D_GetDesc(texture
, &texture_desc
);
281 ID3D10Texture1D_Release(texture
);
283 desc
->Format
= texture_desc
.Format
;
284 if (texture_desc
.ArraySize
== 1)
286 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE1D
;
287 desc
->u
.Texture1D
.MostDetailedMip
= 0;
288 desc
->u
.Texture1D
.MipLevels
= texture_desc
.MipLevels
;
292 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE1DARRAY
;
293 desc
->u
.Texture1DArray
.MostDetailedMip
= 0;
294 desc
->u
.Texture1DArray
.MipLevels
= texture_desc
.MipLevels
;
295 desc
->u
.Texture1DArray
.FirstArraySlice
= 0;
296 desc
->u
.Texture1DArray
.ArraySize
= texture_desc
.ArraySize
;
302 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
304 D3D10_TEXTURE2D_DESC texture_desc
;
305 ID3D10Texture2D
*texture
;
307 if (FAILED(ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture2D
, (void **)&texture
)))
309 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D.\n");
313 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
314 ID3D10Texture2D_Release(texture
);
316 desc
->Format
= texture_desc
.Format
;
317 if (texture_desc
.ArraySize
== 1)
319 if (texture_desc
.SampleDesc
.Count
== 1)
321 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2D
;
322 desc
->u
.Texture2D
.MostDetailedMip
= 0;
323 desc
->u
.Texture2D
.MipLevels
= texture_desc
.MipLevels
;
327 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2DMS
;
332 if (texture_desc
.SampleDesc
.Count
== 1)
334 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2DARRAY
;
335 desc
->u
.Texture2DArray
.MostDetailedMip
= 0;
336 desc
->u
.Texture2DArray
.MipLevels
= texture_desc
.MipLevels
;
337 desc
->u
.Texture2DArray
.FirstArraySlice
= 0;
338 desc
->u
.Texture2DArray
.ArraySize
= texture_desc
.ArraySize
;
342 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY
;
343 desc
->u
.Texture2DMSArray
.FirstArraySlice
= 0;
344 desc
->u
.Texture2DMSArray
.ArraySize
= texture_desc
.ArraySize
;
351 case D3D10_RESOURCE_DIMENSION_TEXTURE3D
:
353 D3D10_TEXTURE3D_DESC texture_desc
;
354 ID3D10Texture3D
*texture
;
356 if (FAILED(ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture3D
, (void **)&texture
)))
358 ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D.\n");
362 ID3D10Texture3D_GetDesc(texture
, &texture_desc
);
363 ID3D10Texture3D_Release(texture
);
365 desc
->Format
= texture_desc
.Format
;
366 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE3D
;
367 desc
->u
.Texture3D
.MostDetailedMip
= 0;
368 desc
->u
.Texture3D
.MipLevels
= texture_desc
.MipLevels
;
374 FIXME("Unhandled resource dimension %#x.\n", dimension
);
375 case D3D10_RESOURCE_DIMENSION_BUFFER
:
380 static inline struct d3d10_depthstencil_view
*impl_from_ID3D10DepthStencilView(ID3D10DepthStencilView
*iface
)
382 return CONTAINING_RECORD(iface
, struct d3d10_depthstencil_view
, ID3D10DepthStencilView_iface
);
385 /* IUnknown methods */
387 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_QueryInterface(ID3D10DepthStencilView
*iface
,
388 REFIID riid
, void **object
)
390 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
392 if (IsEqualGUID(riid
, &IID_ID3D10DepthStencilView
)
393 || IsEqualGUID(riid
, &IID_ID3D10View
)
394 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
395 || IsEqualGUID(riid
, &IID_IUnknown
))
397 IUnknown_AddRef(iface
);
402 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
405 return E_NOINTERFACE
;
408 static ULONG STDMETHODCALLTYPE
d3d10_depthstencil_view_AddRef(ID3D10DepthStencilView
*iface
)
410 struct d3d10_depthstencil_view
*This
= impl_from_ID3D10DepthStencilView(iface
);
411 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
413 TRACE("%p increasing refcount to %u.\n", This
, refcount
);
418 static ULONG STDMETHODCALLTYPE
d3d10_depthstencil_view_Release(ID3D10DepthStencilView
*iface
)
420 struct d3d10_depthstencil_view
*This
= impl_from_ID3D10DepthStencilView(iface
);
421 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
423 TRACE("%p decreasing refcount to %u.\n", This
, refcount
);
427 ID3D10Resource_Release(This
->resource
);
428 ID3D10Device1_Release(This
->device
);
429 HeapFree(GetProcessHeap(), 0, This
);
435 /* ID3D10DeviceChild methods */
437 static void STDMETHODCALLTYPE
d3d10_depthstencil_view_GetDevice(ID3D10DepthStencilView
*iface
, ID3D10Device
**device
)
439 struct d3d10_depthstencil_view
*view
= impl_from_ID3D10DepthStencilView(iface
);
441 TRACE("iface %p, device %p.\n", iface
, device
);
443 *device
= (ID3D10Device
*)view
->device
;
444 ID3D10Device_AddRef(*device
);
447 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_GetPrivateData(ID3D10DepthStencilView
*iface
,
448 REFGUID guid
, UINT
*data_size
, void *data
)
450 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
451 iface
, debugstr_guid(guid
), data_size
, data
);
456 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_SetPrivateData(ID3D10DepthStencilView
*iface
,
457 REFGUID guid
, UINT data_size
, const void *data
)
459 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
460 iface
, debugstr_guid(guid
), data_size
, data
);
465 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_SetPrivateDataInterface(ID3D10DepthStencilView
*iface
,
466 REFGUID guid
, const IUnknown
*data
)
468 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
473 /* ID3D10View methods */
475 static void STDMETHODCALLTYPE
d3d10_depthstencil_view_GetResource(ID3D10DepthStencilView
*iface
,
476 ID3D10Resource
**resource
)
478 struct d3d10_depthstencil_view
*view
= impl_from_ID3D10DepthStencilView(iface
);
480 TRACE("iface %p, resource %p.\n", iface
, resource
);
482 *resource
= view
->resource
;
483 ID3D10Resource_AddRef(*resource
);
486 /* ID3D10DepthStencilView methods */
488 static void STDMETHODCALLTYPE
d3d10_depthstencil_view_GetDesc(ID3D10DepthStencilView
*iface
,
489 D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
)
491 struct d3d10_depthstencil_view
*view
= impl_from_ID3D10DepthStencilView(iface
);
493 TRACE("iface %p, desc %p.\n", iface
, desc
);
498 static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl
=
500 /* IUnknown methods */
501 d3d10_depthstencil_view_QueryInterface
,
502 d3d10_depthstencil_view_AddRef
,
503 d3d10_depthstencil_view_Release
,
504 /* ID3D10DeviceChild methods */
505 d3d10_depthstencil_view_GetDevice
,
506 d3d10_depthstencil_view_GetPrivateData
,
507 d3d10_depthstencil_view_SetPrivateData
,
508 d3d10_depthstencil_view_SetPrivateDataInterface
,
509 /* ID3D10View methods */
510 d3d10_depthstencil_view_GetResource
,
511 /* ID3D10DepthStencilView methods */
512 d3d10_depthstencil_view_GetDesc
,
515 HRESULT
d3d10_depthstencil_view_init(struct d3d10_depthstencil_view
*view
, struct d3d10_device
*device
,
516 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
)
520 view
->ID3D10DepthStencilView_iface
.lpVtbl
= &d3d10_depthstencil_view_vtbl
;
525 if (FAILED(hr
= set_dsdesc_from_resource(&view
->desc
, resource
)))
533 view
->resource
= resource
;
534 ID3D10Resource_AddRef(resource
);
535 view
->device
= &device
->ID3D10Device1_iface
;
536 ID3D10Device1_AddRef(view
->device
);
541 static inline struct d3d10_rendertarget_view
*impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView
*iface
)
543 return CONTAINING_RECORD(iface
, struct d3d10_rendertarget_view
, ID3D10RenderTargetView_iface
);
546 /* IUnknown methods */
548 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_QueryInterface(ID3D10RenderTargetView
*iface
,
549 REFIID riid
, void **object
)
551 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
553 if (IsEqualGUID(riid
, &IID_ID3D10RenderTargetView
)
554 || IsEqualGUID(riid
, &IID_ID3D10View
)
555 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
556 || IsEqualGUID(riid
, &IID_IUnknown
))
558 IUnknown_AddRef(iface
);
563 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
566 return E_NOINTERFACE
;
569 static ULONG STDMETHODCALLTYPE
d3d10_rendertarget_view_AddRef(ID3D10RenderTargetView
*iface
)
571 struct d3d10_rendertarget_view
*This
= impl_from_ID3D10RenderTargetView(iface
);
572 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
574 TRACE("%p increasing refcount to %u\n", This
, refcount
);
579 static ULONG STDMETHODCALLTYPE
d3d10_rendertarget_view_Release(ID3D10RenderTargetView
*iface
)
581 struct d3d10_rendertarget_view
*This
= impl_from_ID3D10RenderTargetView(iface
);
582 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
584 TRACE("%p decreasing refcount to %u\n", This
, refcount
);
588 wined3d_rendertarget_view_decref(This
->wined3d_view
);
589 ID3D10Resource_Release(This
->resource
);
590 ID3D10Device1_Release(This
->device
);
591 HeapFree(GetProcessHeap(), 0, This
);
597 /* ID3D10DeviceChild methods */
599 static void STDMETHODCALLTYPE
d3d10_rendertarget_view_GetDevice(ID3D10RenderTargetView
*iface
, ID3D10Device
**device
)
601 struct d3d10_rendertarget_view
*view
= impl_from_ID3D10RenderTargetView(iface
);
603 TRACE("iface %p, device %p.\n", iface
, device
);
605 *device
= (ID3D10Device
*)view
->device
;
606 ID3D10Device_AddRef(*device
);
609 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView
*iface
,
610 REFGUID guid
, UINT
*data_size
, void *data
)
612 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
613 iface
, debugstr_guid(guid
), data_size
, data
);
618 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_SetPrivateData(ID3D10RenderTargetView
*iface
,
619 REFGUID guid
, UINT data_size
, const void *data
)
621 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
622 iface
, debugstr_guid(guid
), data_size
, data
);
627 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_SetPrivateDataInterface(ID3D10RenderTargetView
*iface
,
628 REFGUID guid
, const IUnknown
*data
)
630 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
635 /* ID3D10View methods */
637 static void STDMETHODCALLTYPE
d3d10_rendertarget_view_GetResource(ID3D10RenderTargetView
*iface
,
638 ID3D10Resource
**resource
)
640 struct d3d10_rendertarget_view
*view
= impl_from_ID3D10RenderTargetView(iface
);
642 TRACE("iface %p, resource %p\n", iface
, resource
);
644 *resource
= view
->resource
;
645 ID3D10Resource_AddRef(*resource
);
648 /* ID3D10RenderTargetView methods */
650 static void STDMETHODCALLTYPE
d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView
*iface
,
651 D3D10_RENDER_TARGET_VIEW_DESC
*desc
)
653 struct d3d10_rendertarget_view
*This
= impl_from_ID3D10RenderTargetView(iface
);
655 TRACE("iface %p, desc %p\n", iface
, desc
);
660 static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl
=
662 /* IUnknown methods */
663 d3d10_rendertarget_view_QueryInterface
,
664 d3d10_rendertarget_view_AddRef
,
665 d3d10_rendertarget_view_Release
,
666 /* ID3D10DeviceChild methods */
667 d3d10_rendertarget_view_GetDevice
,
668 d3d10_rendertarget_view_GetPrivateData
,
669 d3d10_rendertarget_view_SetPrivateData
,
670 d3d10_rendertarget_view_SetPrivateDataInterface
,
671 /* ID3D10View methods */
672 d3d10_rendertarget_view_GetResource
,
673 /* ID3D10RenderTargetView methods */
674 d3d10_rendertarget_view_GetDesc
,
677 HRESULT
d3d10_rendertarget_view_init(struct d3d10_rendertarget_view
*view
, struct d3d10_device
*device
,
678 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
)
680 struct wined3d_resource
*wined3d_resource
;
683 view
->ID3D10RenderTargetView_iface
.lpVtbl
= &d3d10_rendertarget_view_vtbl
;
688 HRESULT hr
= set_rtdesc_from_resource(&view
->desc
, resource
);
689 if (FAILED(hr
)) return hr
;
696 wined3d_resource
= wined3d_resource_from_resource(resource
);
697 if (!wined3d_resource
)
699 ERR("Failed to get wined3d resource for d3d10 resource %p.\n", resource
);
703 hr
= wined3d_rendertarget_view_create(wined3d_resource
, view
, &view
->wined3d_view
);
706 WARN("Failed to create a wined3d rendertarget view, hr %#x.\n", hr
);
710 view
->resource
= resource
;
711 ID3D10Resource_AddRef(resource
);
712 view
->device
= &device
->ID3D10Device1_iface
;
713 ID3D10Device1_AddRef(view
->device
);
718 struct d3d10_rendertarget_view
*unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView
*iface
)
722 assert(iface
->lpVtbl
== &d3d10_rendertarget_view_vtbl
);
724 return impl_from_ID3D10RenderTargetView(iface
);
727 static inline struct d3d10_shader_resource_view
*impl_from_ID3D10ShaderResourceView(ID3D10ShaderResourceView
*iface
)
729 return CONTAINING_RECORD(iface
, struct d3d10_shader_resource_view
, ID3D10ShaderResourceView_iface
);
732 /* IUnknown methods */
734 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_QueryInterface(ID3D10ShaderResourceView
*iface
,
735 REFIID riid
, void **object
)
737 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
739 if (IsEqualGUID(riid
, &IID_ID3D10ShaderResourceView
)
740 || IsEqualGUID(riid
, &IID_ID3D10View
)
741 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
742 || IsEqualGUID(riid
, &IID_IUnknown
))
744 IUnknown_AddRef(iface
);
749 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
752 return E_NOINTERFACE
;
755 static ULONG STDMETHODCALLTYPE
d3d10_shader_resource_view_AddRef(ID3D10ShaderResourceView
*iface
)
757 struct d3d10_shader_resource_view
*This
= impl_from_ID3D10ShaderResourceView(iface
);
758 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
760 TRACE("%p increasing refcount to %u.\n", This
, refcount
);
765 static ULONG STDMETHODCALLTYPE
d3d10_shader_resource_view_Release(ID3D10ShaderResourceView
*iface
)
767 struct d3d10_shader_resource_view
*This
= impl_from_ID3D10ShaderResourceView(iface
);
768 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
770 TRACE("%p decreasing refcount to %u.\n", This
, refcount
);
774 ID3D10Resource_Release(This
->resource
);
775 ID3D10Device1_Release(This
->device
);
776 HeapFree(GetProcessHeap(), 0, This
);
782 /* ID3D10DeviceChild methods */
784 static void STDMETHODCALLTYPE
d3d10_shader_resource_view_GetDevice(ID3D10ShaderResourceView
*iface
,
785 ID3D10Device
**device
)
787 struct d3d10_shader_resource_view
*view
= impl_from_ID3D10ShaderResourceView(iface
);
789 TRACE("iface %p, device %p.\n", iface
, device
);
791 *device
= (ID3D10Device
*)view
->device
;
792 ID3D10Device_AddRef(*device
);
795 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView
*iface
,
796 REFGUID guid
, UINT
*data_size
, void *data
)
798 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
799 iface
, debugstr_guid(guid
), data_size
, data
);
804 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_SetPrivateData(ID3D10ShaderResourceView
*iface
,
805 REFGUID guid
, UINT data_size
, const void *data
)
807 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
808 iface
, debugstr_guid(guid
), data_size
, data
);
813 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_SetPrivateDataInterface(ID3D10ShaderResourceView
*iface
,
814 REFGUID guid
, const IUnknown
*data
)
816 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
821 /* ID3D10View methods */
823 static void STDMETHODCALLTYPE
d3d10_shader_resource_view_GetResource(ID3D10ShaderResourceView
*iface
,
824 ID3D10Resource
**resource
)
826 struct d3d10_shader_resource_view
*view
= impl_from_ID3D10ShaderResourceView(iface
);
828 TRACE("iface %p, resource %p.\n", iface
, resource
);
830 *resource
= view
->resource
;
831 ID3D10Resource_AddRef(*resource
);
834 /* ID3D10ShaderResourceView methods */
836 static void STDMETHODCALLTYPE
d3d10_shader_resource_view_GetDesc(ID3D10ShaderResourceView
*iface
,
837 D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
)
839 struct d3d10_shader_resource_view
*view
= impl_from_ID3D10ShaderResourceView(iface
);
841 TRACE("iface %p, desc %p.\n", iface
, desc
);
846 static const struct ID3D10ShaderResourceViewVtbl d3d10_shader_resource_view_vtbl
=
848 /* IUnknown methods */
849 d3d10_shader_resource_view_QueryInterface
,
850 d3d10_shader_resource_view_AddRef
,
851 d3d10_shader_resource_view_Release
,
852 /* ID3D10DeviceChild methods */
853 d3d10_shader_resource_view_GetDevice
,
854 d3d10_shader_resource_view_GetPrivateData
,
855 d3d10_shader_resource_view_SetPrivateData
,
856 d3d10_shader_resource_view_SetPrivateDataInterface
,
857 /* ID3D10View methods */
858 d3d10_shader_resource_view_GetResource
,
859 /* ID3D10ShaderResourceView methods */
860 d3d10_shader_resource_view_GetDesc
,
863 HRESULT
d3d10_shader_resource_view_init(struct d3d10_shader_resource_view
*view
, struct d3d10_device
*device
,
864 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
)
868 view
->ID3D10ShaderResourceView_iface
.lpVtbl
= &d3d10_shader_resource_view_vtbl
;
873 if (FAILED(hr
= set_srdesc_from_resource(&view
->desc
, resource
)))
881 view
->resource
= resource
;
882 ID3D10Resource_AddRef(resource
);
883 view
->device
= &device
->ID3D10Device1_iface
;
884 ID3D10Device1_AddRef(view
->device
);