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
;
53 ID3D10Resource_GetType(resource
, &dimension
);
57 case D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
59 D3D10_TEXTURE1D_DESC texture_desc
;
60 ID3D10Texture1D
*texture
;
62 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture1D
, (void **)&texture
)))
64 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D.\n");
68 ID3D10Texture1D_GetDesc(texture
, &texture_desc
);
69 ID3D10Texture1D_Release(texture
);
71 desc
->Format
= texture_desc
.Format
;
72 if (texture_desc
.ArraySize
== 1)
74 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE1D
;
75 desc
->u
.Texture1D
.MipSlice
= 0;
79 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE1DARRAY
;
80 desc
->u
.Texture1DArray
.MipSlice
= 0;
81 desc
->u
.Texture1DArray
.FirstArraySlice
= 0;
82 desc
->u
.Texture1DArray
.ArraySize
= 1;
88 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
90 D3D10_TEXTURE2D_DESC texture_desc
;
91 ID3D10Texture2D
*texture
;
93 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture2D
, (void **)&texture
)))
95 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D.\n");
99 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
100 ID3D10Texture2D_Release(texture
);
102 desc
->Format
= texture_desc
.Format
;
103 if (texture_desc
.ArraySize
== 1)
105 if (texture_desc
.SampleDesc
.Count
== 1)
107 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2D
;
108 desc
->u
.Texture2D
.MipSlice
= 0;
112 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2DMS
;
117 if (texture_desc
.SampleDesc
.Count
== 1)
119 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2DARRAY
;
120 desc
->u
.Texture2DArray
.MipSlice
= 0;
121 desc
->u
.Texture2DArray
.FirstArraySlice
= 0;
122 desc
->u
.Texture2DArray
.ArraySize
= 1;
126 desc
->ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY
;
127 desc
->u
.Texture2DMSArray
.FirstArraySlice
= 0;
128 desc
->u
.Texture2DMSArray
.ArraySize
= 1;
136 FIXME("Unhandled resource dimension %#x.\n", dimension
);
137 case D3D10_RESOURCE_DIMENSION_BUFFER
:
138 case D3D10_RESOURCE_DIMENSION_TEXTURE3D
:
143 static HRESULT
set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC
*desc
, ID3D10Resource
*resource
)
145 D3D10_RESOURCE_DIMENSION dimension
;
148 ID3D10Resource_GetType(resource
, &dimension
);
152 case D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
154 ID3D10Texture1D
*texture
;
155 D3D10_TEXTURE1D_DESC texture_desc
;
157 hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture1D
, (void **)&texture
);
160 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D?\n");
164 ID3D10Texture1D_GetDesc(texture
, &texture_desc
);
165 ID3D10Texture1D_Release(texture
);
167 desc
->Format
= texture_desc
.Format
;
168 if (texture_desc
.ArraySize
== 1)
170 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE1D
;
171 desc
->u
.Texture1D
.MipSlice
= 0;
175 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE1DARRAY
;
176 desc
->u
.Texture1DArray
.MipSlice
= 0;
177 desc
->u
.Texture1DArray
.FirstArraySlice
= 0;
178 desc
->u
.Texture1DArray
.ArraySize
= 1;
184 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
186 ID3D10Texture2D
*texture
;
187 D3D10_TEXTURE2D_DESC texture_desc
;
189 hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture2D
, (void **)&texture
);
192 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D?\n");
196 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
197 ID3D10Texture2D_Release(texture
);
199 desc
->Format
= texture_desc
.Format
;
200 if (texture_desc
.ArraySize
== 1)
202 if (texture_desc
.SampleDesc
.Count
== 1)
204 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2D
;
205 desc
->u
.Texture2D
.MipSlice
= 0;
209 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2DMS
;
214 if (texture_desc
.SampleDesc
.Count
== 1)
216 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2DARRAY
;
217 desc
->u
.Texture2DArray
.MipSlice
= 0;
218 desc
->u
.Texture2DArray
.FirstArraySlice
= 0;
219 desc
->u
.Texture2DArray
.ArraySize
= 1;
223 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY
;
224 desc
->u
.Texture2DMSArray
.FirstArraySlice
= 0;
225 desc
->u
.Texture2DMSArray
.ArraySize
= 1;
232 case D3D10_RESOURCE_DIMENSION_TEXTURE3D
:
234 ID3D10Texture3D
*texture
;
235 D3D10_TEXTURE3D_DESC texture_desc
;
237 hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture3D
, (void **)&texture
);
240 ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D?\n");
244 ID3D10Texture3D_GetDesc(texture
, &texture_desc
);
245 ID3D10Texture3D_Release(texture
);
247 desc
->Format
= texture_desc
.Format
;
248 desc
->ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE3D
;
249 desc
->u
.Texture3D
.MipSlice
= 0;
250 desc
->u
.Texture3D
.FirstWSlice
= 0;
251 desc
->u
.Texture3D
.WSize
= 1;
257 FIXME("Unhandled resource dimension %#x.\n", dimension
);
262 static HRESULT
set_srdesc_from_resource(D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
, ID3D10Resource
*resource
)
264 D3D10_RESOURCE_DIMENSION dimension
;
267 ID3D10Resource_GetType(resource
, &dimension
);
271 case D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
273 D3D10_TEXTURE1D_DESC texture_desc
;
274 ID3D10Texture1D
*texture
;
276 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture1D
, (void **)&texture
)))
278 ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D.\n");
282 ID3D10Texture1D_GetDesc(texture
, &texture_desc
);
283 ID3D10Texture1D_Release(texture
);
285 desc
->Format
= texture_desc
.Format
;
286 if (texture_desc
.ArraySize
== 1)
288 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE1D
;
289 desc
->u
.Texture1D
.MostDetailedMip
= 0;
290 desc
->u
.Texture1D
.MipLevels
= texture_desc
.MipLevels
;
294 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE1DARRAY
;
295 desc
->u
.Texture1DArray
.MostDetailedMip
= 0;
296 desc
->u
.Texture1DArray
.MipLevels
= texture_desc
.MipLevels
;
297 desc
->u
.Texture1DArray
.FirstArraySlice
= 0;
298 desc
->u
.Texture1DArray
.ArraySize
= texture_desc
.ArraySize
;
304 case D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
306 D3D10_TEXTURE2D_DESC texture_desc
;
307 ID3D10Texture2D
*texture
;
309 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture2D
, (void **)&texture
)))
311 ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D.\n");
315 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
316 ID3D10Texture2D_Release(texture
);
318 desc
->Format
= texture_desc
.Format
;
319 if (texture_desc
.ArraySize
== 1)
321 if (texture_desc
.SampleDesc
.Count
== 1)
323 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2D
;
324 desc
->u
.Texture2D
.MostDetailedMip
= 0;
325 desc
->u
.Texture2D
.MipLevels
= texture_desc
.MipLevels
;
329 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2DMS
;
334 if (texture_desc
.SampleDesc
.Count
== 1)
336 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2DARRAY
;
337 desc
->u
.Texture2DArray
.MostDetailedMip
= 0;
338 desc
->u
.Texture2DArray
.MipLevels
= texture_desc
.MipLevels
;
339 desc
->u
.Texture2DArray
.FirstArraySlice
= 0;
340 desc
->u
.Texture2DArray
.ArraySize
= texture_desc
.ArraySize
;
344 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY
;
345 desc
->u
.Texture2DMSArray
.FirstArraySlice
= 0;
346 desc
->u
.Texture2DMSArray
.ArraySize
= texture_desc
.ArraySize
;
353 case D3D10_RESOURCE_DIMENSION_TEXTURE3D
:
355 D3D10_TEXTURE3D_DESC texture_desc
;
356 ID3D10Texture3D
*texture
;
358 if (FAILED(hr
= ID3D10Resource_QueryInterface(resource
, &IID_ID3D10Texture3D
, (void **)&texture
)))
360 ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D.\n");
364 ID3D10Texture3D_GetDesc(texture
, &texture_desc
);
365 ID3D10Texture3D_Release(texture
);
367 desc
->Format
= texture_desc
.Format
;
368 desc
->ViewDimension
= D3D10_SRV_DIMENSION_TEXTURE3D
;
369 desc
->u
.Texture3D
.MostDetailedMip
= 0;
370 desc
->u
.Texture3D
.MipLevels
= texture_desc
.MipLevels
;
376 FIXME("Unhandled resource dimension %#x.\n", dimension
);
377 case D3D10_RESOURCE_DIMENSION_BUFFER
:
382 static inline struct d3d10_depthstencil_view
*impl_from_ID3D10DepthStencilView(ID3D10DepthStencilView
*iface
)
384 return CONTAINING_RECORD(iface
, struct d3d10_depthstencil_view
, ID3D10DepthStencilView_iface
);
387 /* IUnknown methods */
389 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_QueryInterface(ID3D10DepthStencilView
*iface
,
390 REFIID riid
, void **object
)
392 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
394 if (IsEqualGUID(riid
, &IID_ID3D10DepthStencilView
)
395 || IsEqualGUID(riid
, &IID_ID3D10View
)
396 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
397 || IsEqualGUID(riid
, &IID_IUnknown
))
399 IUnknown_AddRef(iface
);
404 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
407 return E_NOINTERFACE
;
410 static ULONG STDMETHODCALLTYPE
d3d10_depthstencil_view_AddRef(ID3D10DepthStencilView
*iface
)
412 struct d3d10_depthstencil_view
*This
= impl_from_ID3D10DepthStencilView(iface
);
413 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
415 TRACE("%p increasing refcount to %u.\n", This
, refcount
);
420 static ULONG STDMETHODCALLTYPE
d3d10_depthstencil_view_Release(ID3D10DepthStencilView
*iface
)
422 struct d3d10_depthstencil_view
*This
= impl_from_ID3D10DepthStencilView(iface
);
423 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
425 TRACE("%p decreasing refcount to %u.\n", This
, refcount
);
429 ID3D10Resource_Release(This
->resource
);
430 HeapFree(GetProcessHeap(), 0, This
);
436 /* ID3D10DeviceChild methods */
438 static void STDMETHODCALLTYPE
d3d10_depthstencil_view_GetDevice(ID3D10DepthStencilView
*iface
, ID3D10Device
**device
)
440 FIXME("iface %p, device %p stub!\n", iface
, device
);
443 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_GetPrivateData(ID3D10DepthStencilView
*iface
,
444 REFGUID guid
, UINT
*data_size
, void *data
)
446 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
447 iface
, debugstr_guid(guid
), data_size
, data
);
452 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_SetPrivateData(ID3D10DepthStencilView
*iface
,
453 REFGUID guid
, UINT data_size
, const void *data
)
455 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
456 iface
, debugstr_guid(guid
), data_size
, data
);
461 static HRESULT STDMETHODCALLTYPE
d3d10_depthstencil_view_SetPrivateDataInterface(ID3D10DepthStencilView
*iface
,
462 REFGUID guid
, const IUnknown
*data
)
464 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
469 /* ID3D10View methods */
471 static void STDMETHODCALLTYPE
d3d10_depthstencil_view_GetResource(ID3D10DepthStencilView
*iface
,
472 ID3D10Resource
**resource
)
474 struct d3d10_depthstencil_view
*view
= impl_from_ID3D10DepthStencilView(iface
);
476 TRACE("iface %p, resource %p.\n", iface
, resource
);
478 *resource
= view
->resource
;
479 ID3D10Resource_AddRef(*resource
);
482 /* ID3D10DepthStencilView methods */
484 static void STDMETHODCALLTYPE
d3d10_depthstencil_view_GetDesc(ID3D10DepthStencilView
*iface
,
485 D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
)
487 struct d3d10_depthstencil_view
*view
= impl_from_ID3D10DepthStencilView(iface
);
489 TRACE("iface %p, desc %p.\n", iface
, desc
);
494 static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl
=
496 /* IUnknown methods */
497 d3d10_depthstencil_view_QueryInterface
,
498 d3d10_depthstencil_view_AddRef
,
499 d3d10_depthstencil_view_Release
,
500 /* ID3D10DeviceChild methods */
501 d3d10_depthstencil_view_GetDevice
,
502 d3d10_depthstencil_view_GetPrivateData
,
503 d3d10_depthstencil_view_SetPrivateData
,
504 d3d10_depthstencil_view_SetPrivateDataInterface
,
505 /* ID3D10View methods */
506 d3d10_depthstencil_view_GetResource
,
507 /* ID3D10DepthStencilView methods */
508 d3d10_depthstencil_view_GetDesc
,
511 HRESULT
d3d10_depthstencil_view_init(struct d3d10_depthstencil_view
*view
,
512 ID3D10Resource
*resource
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
)
516 view
->ID3D10DepthStencilView_iface
.lpVtbl
= &d3d10_depthstencil_view_vtbl
;
521 if (FAILED(hr
= set_dsdesc_from_resource(&view
->desc
, resource
)))
529 view
->resource
= resource
;
530 ID3D10Resource_AddRef(resource
);
535 static inline struct d3d10_rendertarget_view
*impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView
*iface
)
537 return CONTAINING_RECORD(iface
, struct d3d10_rendertarget_view
, ID3D10RenderTargetView_iface
);
540 /* IUnknown methods */
542 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_QueryInterface(ID3D10RenderTargetView
*iface
,
543 REFIID riid
, void **object
)
545 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
547 if (IsEqualGUID(riid
, &IID_ID3D10RenderTargetView
)
548 || IsEqualGUID(riid
, &IID_ID3D10View
)
549 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
550 || IsEqualGUID(riid
, &IID_IUnknown
))
552 IUnknown_AddRef(iface
);
557 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
560 return E_NOINTERFACE
;
563 static ULONG STDMETHODCALLTYPE
d3d10_rendertarget_view_AddRef(ID3D10RenderTargetView
*iface
)
565 struct d3d10_rendertarget_view
*This
= impl_from_ID3D10RenderTargetView(iface
);
566 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
568 TRACE("%p increasing refcount to %u\n", This
, refcount
);
573 static ULONG STDMETHODCALLTYPE
d3d10_rendertarget_view_Release(ID3D10RenderTargetView
*iface
)
575 struct d3d10_rendertarget_view
*This
= impl_from_ID3D10RenderTargetView(iface
);
576 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
578 TRACE("%p decreasing refcount to %u\n", This
, refcount
);
582 wined3d_rendertarget_view_decref(This
->wined3d_view
);
583 ID3D10Resource_Release(This
->resource
);
584 HeapFree(GetProcessHeap(), 0, This
);
590 /* ID3D10DeviceChild methods */
592 static void STDMETHODCALLTYPE
d3d10_rendertarget_view_GetDevice(ID3D10RenderTargetView
*iface
, ID3D10Device
**device
)
594 FIXME("iface %p, device %p stub!\n", iface
, device
);
597 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView
*iface
,
598 REFGUID guid
, UINT
*data_size
, void *data
)
600 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
601 iface
, debugstr_guid(guid
), data_size
, data
);
606 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_SetPrivateData(ID3D10RenderTargetView
*iface
,
607 REFGUID guid
, UINT data_size
, const void *data
)
609 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
610 iface
, debugstr_guid(guid
), data_size
, data
);
615 static HRESULT STDMETHODCALLTYPE
d3d10_rendertarget_view_SetPrivateDataInterface(ID3D10RenderTargetView
*iface
,
616 REFGUID guid
, const IUnknown
*data
)
618 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
623 /* ID3D10View methods */
625 static void STDMETHODCALLTYPE
d3d10_rendertarget_view_GetResource(ID3D10RenderTargetView
*iface
,
626 ID3D10Resource
**resource
)
628 struct d3d10_rendertarget_view
*view
= impl_from_ID3D10RenderTargetView(iface
);
630 TRACE("iface %p, resource %p\n", iface
, resource
);
632 *resource
= view
->resource
;
633 ID3D10Resource_AddRef(*resource
);
636 /* ID3D10RenderTargetView methods */
638 static void STDMETHODCALLTYPE
d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView
*iface
,
639 D3D10_RENDER_TARGET_VIEW_DESC
*desc
)
641 struct d3d10_rendertarget_view
*This
= impl_from_ID3D10RenderTargetView(iface
);
643 TRACE("iface %p, desc %p\n", iface
, desc
);
648 static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl
=
650 /* IUnknown methods */
651 d3d10_rendertarget_view_QueryInterface
,
652 d3d10_rendertarget_view_AddRef
,
653 d3d10_rendertarget_view_Release
,
654 /* ID3D10DeviceChild methods */
655 d3d10_rendertarget_view_GetDevice
,
656 d3d10_rendertarget_view_GetPrivateData
,
657 d3d10_rendertarget_view_SetPrivateData
,
658 d3d10_rendertarget_view_SetPrivateDataInterface
,
659 /* ID3D10View methods */
660 d3d10_rendertarget_view_GetResource
,
661 /* ID3D10RenderTargetView methods */
662 d3d10_rendertarget_view_GetDesc
,
665 HRESULT
d3d10_rendertarget_view_init(struct d3d10_rendertarget_view
*view
,
666 ID3D10Resource
*resource
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
)
668 struct wined3d_resource
*wined3d_resource
;
671 view
->ID3D10RenderTargetView_iface
.lpVtbl
= &d3d10_rendertarget_view_vtbl
;
676 HRESULT hr
= set_rtdesc_from_resource(&view
->desc
, resource
);
677 if (FAILED(hr
)) return hr
;
684 wined3d_resource
= wined3d_resource_from_resource(resource
);
685 if (!wined3d_resource
)
687 ERR("Failed to get wined3d resource for d3d10 resource %p.\n", resource
);
691 hr
= wined3d_rendertarget_view_create(wined3d_resource
, view
, &view
->wined3d_view
);
694 WARN("Failed to create a wined3d rendertarget view, hr %#x.\n", hr
);
698 view
->resource
= resource
;
699 ID3D10Resource_AddRef(resource
);
704 struct d3d10_rendertarget_view
*unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView
*iface
)
708 assert(iface
->lpVtbl
== &d3d10_rendertarget_view_vtbl
);
710 return impl_from_ID3D10RenderTargetView(iface
);
713 static inline struct d3d10_shader_resource_view
*impl_from_ID3D10ShaderResourceView(ID3D10ShaderResourceView
*iface
)
715 return CONTAINING_RECORD(iface
, struct d3d10_shader_resource_view
, ID3D10ShaderResourceView_iface
);
718 /* IUnknown methods */
720 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_QueryInterface(ID3D10ShaderResourceView
*iface
,
721 REFIID riid
, void **object
)
723 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
725 if (IsEqualGUID(riid
, &IID_ID3D10ShaderResourceView
)
726 || IsEqualGUID(riid
, &IID_ID3D10View
)
727 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
728 || IsEqualGUID(riid
, &IID_IUnknown
))
730 IUnknown_AddRef(iface
);
735 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
738 return E_NOINTERFACE
;
741 static ULONG STDMETHODCALLTYPE
d3d10_shader_resource_view_AddRef(ID3D10ShaderResourceView
*iface
)
743 struct d3d10_shader_resource_view
*This
= impl_from_ID3D10ShaderResourceView(iface
);
744 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
746 TRACE("%p increasing refcount to %u.\n", This
, refcount
);
751 static ULONG STDMETHODCALLTYPE
d3d10_shader_resource_view_Release(ID3D10ShaderResourceView
*iface
)
753 struct d3d10_shader_resource_view
*This
= impl_from_ID3D10ShaderResourceView(iface
);
754 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
756 TRACE("%p decreasing refcount to %u.\n", This
, refcount
);
760 ID3D10Resource_Release(This
->resource
);
761 HeapFree(GetProcessHeap(), 0, This
);
767 /* ID3D10DeviceChild methods */
769 static void STDMETHODCALLTYPE
d3d10_shader_resource_view_GetDevice(ID3D10ShaderResourceView
*iface
,
770 ID3D10Device
**device
)
772 FIXME("iface %p, device %p stub!\n", iface
, device
);
775 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView
*iface
,
776 REFGUID guid
, UINT
*data_size
, void *data
)
778 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
779 iface
, debugstr_guid(guid
), data_size
, data
);
784 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_SetPrivateData(ID3D10ShaderResourceView
*iface
,
785 REFGUID guid
, UINT data_size
, const void *data
)
787 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
788 iface
, debugstr_guid(guid
), data_size
, data
);
793 static HRESULT STDMETHODCALLTYPE
d3d10_shader_resource_view_SetPrivateDataInterface(ID3D10ShaderResourceView
*iface
,
794 REFGUID guid
, const IUnknown
*data
)
796 FIXME("iface %p, guid %s, data %p stub!\n", iface
, debugstr_guid(guid
), data
);
801 /* ID3D10View methods */
803 static void STDMETHODCALLTYPE
d3d10_shader_resource_view_GetResource(ID3D10ShaderResourceView
*iface
,
804 ID3D10Resource
**resource
)
806 struct d3d10_shader_resource_view
*view
= impl_from_ID3D10ShaderResourceView(iface
);
808 TRACE("iface %p, resource %p.\n", iface
, resource
);
810 *resource
= view
->resource
;
811 ID3D10Resource_AddRef(*resource
);
814 /* ID3D10ShaderResourceView methods */
816 static void STDMETHODCALLTYPE
d3d10_shader_resource_view_GetDesc(ID3D10ShaderResourceView
*iface
,
817 D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
)
819 struct d3d10_shader_resource_view
*view
= impl_from_ID3D10ShaderResourceView(iface
);
821 TRACE("iface %p, desc %p.\n", iface
, desc
);
826 static const struct ID3D10ShaderResourceViewVtbl d3d10_shader_resource_view_vtbl
=
828 /* IUnknown methods */
829 d3d10_shader_resource_view_QueryInterface
,
830 d3d10_shader_resource_view_AddRef
,
831 d3d10_shader_resource_view_Release
,
832 /* ID3D10DeviceChild methods */
833 d3d10_shader_resource_view_GetDevice
,
834 d3d10_shader_resource_view_GetPrivateData
,
835 d3d10_shader_resource_view_SetPrivateData
,
836 d3d10_shader_resource_view_SetPrivateDataInterface
,
837 /* ID3D10View methods */
838 d3d10_shader_resource_view_GetResource
,
839 /* ID3D10ShaderResourceView methods */
840 d3d10_shader_resource_view_GetDesc
,
843 HRESULT
d3d10_shader_resource_view_init(struct d3d10_shader_resource_view
*view
,
844 ID3D10Resource
*resource
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
)
848 view
->ID3D10ShaderResourceView_iface
.lpVtbl
= &d3d10_shader_resource_view_vtbl
;
853 if (FAILED(hr
= set_srdesc_from_resource(&view
->desc
, resource
)))
861 view
->resource
= resource
;
862 ID3D10Resource_AddRef(resource
);