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 HeapFree(GetProcessHeap(), 0, This);
434 /* ID3D10DeviceChild methods */
436 static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetDevice(ID3D10DepthStencilView *iface, ID3D10Device **device)
438 FIXME("iface %p, device %p stub!\n", iface, device);
441 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_GetPrivateData(ID3D10DepthStencilView *iface,
442 REFGUID guid, UINT *data_size, void *data)
444 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
445 iface, debugstr_guid(guid), data_size, data);
450 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_SetPrivateData(ID3D10DepthStencilView *iface,
451 REFGUID guid, UINT data_size, const void *data)
453 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
454 iface, debugstr_guid(guid), data_size, data);
459 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_SetPrivateDataInterface(ID3D10DepthStencilView *iface,
460 REFGUID guid, const IUnknown *data)
462 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
467 /* ID3D10View methods */
469 static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetResource(ID3D10DepthStencilView *iface,
470 ID3D10Resource **resource)
472 struct d3d10_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
474 TRACE("iface %p, resource %p.\n", iface, resource);
476 *resource = view->resource;
477 ID3D10Resource_AddRef(*resource);
480 /* ID3D10DepthStencilView methods */
482 static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetDesc(ID3D10DepthStencilView *iface,
483 D3D10_DEPTH_STENCIL_VIEW_DESC *desc)
485 struct d3d10_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
487 TRACE("iface %p, desc %p.\n", iface, desc);
492 static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl =
494 /* IUnknown methods */
495 d3d10_depthstencil_view_QueryInterface,
496 d3d10_depthstencil_view_AddRef,
497 d3d10_depthstencil_view_Release,
498 /* ID3D10DeviceChild methods */
499 d3d10_depthstencil_view_GetDevice,
500 d3d10_depthstencil_view_GetPrivateData,
501 d3d10_depthstencil_view_SetPrivateData,
502 d3d10_depthstencil_view_SetPrivateDataInterface,
503 /* ID3D10View methods */
504 d3d10_depthstencil_view_GetResource,
505 /* ID3D10DepthStencilView methods */
506 d3d10_depthstencil_view_GetDesc,
509 HRESULT d3d10_depthstencil_view_init(struct d3d10_depthstencil_view *view,
510 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc)
514 view->ID3D10DepthStencilView_iface.lpVtbl = &d3d10_depthstencil_view_vtbl;
519 if (FAILED(hr = set_dsdesc_from_resource(&view->desc, resource)))
527 view->resource = resource;
528 ID3D10Resource_AddRef(resource);
533 static inline struct d3d10_rendertarget_view *impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface)
535 return CONTAINING_RECORD(iface, struct d3d10_rendertarget_view, ID3D10RenderTargetView_iface);
538 /* IUnknown methods */
540 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_QueryInterface(ID3D10RenderTargetView *iface,
541 REFIID riid, void **object)
543 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
545 if (IsEqualGUID(riid, &IID_ID3D10RenderTargetView)
546 || IsEqualGUID(riid, &IID_ID3D10View)
547 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
548 || IsEqualGUID(riid, &IID_IUnknown))
550 IUnknown_AddRef(iface);
555 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
558 return E_NOINTERFACE;
561 static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_AddRef(ID3D10RenderTargetView *iface)
563 struct d3d10_rendertarget_view *This = impl_from_ID3D10RenderTargetView(iface);
564 ULONG refcount = InterlockedIncrement(&This->refcount);
566 TRACE("%p increasing refcount to %u\n", This, refcount);
571 static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTargetView *iface)
573 struct d3d10_rendertarget_view *This = impl_from_ID3D10RenderTargetView(iface);
574 ULONG refcount = InterlockedDecrement(&This->refcount);
576 TRACE("%p decreasing refcount to %u\n", This, refcount);
580 wined3d_rendertarget_view_decref(This->wined3d_view);
581 ID3D10Resource_Release(This->resource);
582 HeapFree(GetProcessHeap(), 0, This);
588 /* ID3D10DeviceChild methods */
590 static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDevice(ID3D10RenderTargetView *iface, ID3D10Device **device)
592 FIXME("iface %p, device %p stub!\n", iface, device);
595 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView *iface,
596 REFGUID guid, UINT *data_size, void *data)
598 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
599 iface, debugstr_guid(guid), data_size, data);
604 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_SetPrivateData(ID3D10RenderTargetView *iface,
605 REFGUID guid, UINT data_size, const void *data)
607 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
608 iface, debugstr_guid(guid), data_size, data);
613 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_SetPrivateDataInterface(ID3D10RenderTargetView *iface,
614 REFGUID guid, const IUnknown *data)
616 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
621 /* ID3D10View methods */
623 static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTargetView *iface,
624 ID3D10Resource **resource)
626 struct d3d10_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
628 TRACE("iface %p, resource %p\n", iface, resource);
630 *resource = view->resource;
631 ID3D10Resource_AddRef(*resource);
634 /* ID3D10RenderTargetView methods */
636 static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView *iface,
637 D3D10_RENDER_TARGET_VIEW_DESC *desc)
639 struct d3d10_rendertarget_view *This = impl_from_ID3D10RenderTargetView(iface);
641 TRACE("iface %p, desc %p\n", iface, desc);
646 static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
648 /* IUnknown methods */
649 d3d10_rendertarget_view_QueryInterface,
650 d3d10_rendertarget_view_AddRef,
651 d3d10_rendertarget_view_Release,
652 /* ID3D10DeviceChild methods */
653 d3d10_rendertarget_view_GetDevice,
654 d3d10_rendertarget_view_GetPrivateData,
655 d3d10_rendertarget_view_SetPrivateData,
656 d3d10_rendertarget_view_SetPrivateDataInterface,
657 /* ID3D10View methods */
658 d3d10_rendertarget_view_GetResource,
659 /* ID3D10RenderTargetView methods */
660 d3d10_rendertarget_view_GetDesc,
663 HRESULT d3d10_rendertarget_view_init(struct d3d10_rendertarget_view *view,
664 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc)
666 struct wined3d_resource *wined3d_resource;
669 view->ID3D10RenderTargetView_iface.lpVtbl = &d3d10_rendertarget_view_vtbl;
674 HRESULT hr = set_rtdesc_from_resource(&view->desc, resource);
675 if (FAILED(hr)) return hr;
682 wined3d_resource = wined3d_resource_from_resource(resource);
683 if (!wined3d_resource)
685 ERR("Failed to get wined3d resource for d3d10 resource %p.\n", resource);
689 hr = wined3d_rendertarget_view_create(wined3d_resource, view, &view->wined3d_view);
692 WARN("Failed to create a wined3d rendertarget view, hr %#x.\n", hr);
696 view->resource = resource;
697 ID3D10Resource_AddRef(resource);
702 struct d3d10_rendertarget_view *unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface)
706 assert(iface->lpVtbl == &d3d10_rendertarget_view_vtbl);
708 return impl_from_ID3D10RenderTargetView(iface);
711 static inline struct d3d10_shader_resource_view *impl_from_ID3D10ShaderResourceView(ID3D10ShaderResourceView *iface)
713 return CONTAINING_RECORD(iface, struct d3d10_shader_resource_view, ID3D10ShaderResourceView_iface);
716 /* IUnknown methods */
718 static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_QueryInterface(ID3D10ShaderResourceView *iface,
719 REFIID riid, void **object)
721 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
723 if (IsEqualGUID(riid, &IID_ID3D10ShaderResourceView)
724 || IsEqualGUID(riid, &IID_ID3D10View)
725 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
726 || IsEqualGUID(riid, &IID_IUnknown))
728 IUnknown_AddRef(iface);
733 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
736 return E_NOINTERFACE;
739 static ULONG STDMETHODCALLTYPE d3d10_shader_resource_view_AddRef(ID3D10ShaderResourceView *iface)
741 struct d3d10_shader_resource_view *This = impl_from_ID3D10ShaderResourceView(iface);
742 ULONG refcount = InterlockedIncrement(&This->refcount);
744 TRACE("%p increasing refcount to %u.\n", This, refcount);
749 static ULONG STDMETHODCALLTYPE d3d10_shader_resource_view_Release(ID3D10ShaderResourceView *iface)
751 struct d3d10_shader_resource_view *This = impl_from_ID3D10ShaderResourceView(iface);
752 ULONG refcount = InterlockedDecrement(&This->refcount);
754 TRACE("%p decreasing refcount to %u.\n", This, refcount);
758 ID3D10Resource_Release(This->resource);
759 HeapFree(GetProcessHeap(), 0, This);
765 /* ID3D10DeviceChild methods */
767 static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDevice(ID3D10ShaderResourceView *iface,
768 ID3D10Device **device)
770 FIXME("iface %p, device %p stub!\n", iface, device);
773 static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView *iface,
774 REFGUID guid, UINT *data_size, void *data)
776 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
777 iface, debugstr_guid(guid), data_size, data);
782 static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_SetPrivateData(ID3D10ShaderResourceView *iface,
783 REFGUID guid, UINT data_size, const void *data)
785 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
786 iface, debugstr_guid(guid), data_size, data);
791 static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_SetPrivateDataInterface(ID3D10ShaderResourceView *iface,
792 REFGUID guid, const IUnknown *data)
794 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
799 /* ID3D10View methods */
801 static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetResource(ID3D10ShaderResourceView *iface,
802 ID3D10Resource **resource)
804 struct d3d10_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
806 TRACE("iface %p, resource %p.\n", iface, resource);
808 *resource = view->resource;
809 ID3D10Resource_AddRef(*resource);
812 /* ID3D10ShaderResourceView methods */
814 static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDesc(ID3D10ShaderResourceView *iface,
815 D3D10_SHADER_RESOURCE_VIEW_DESC *desc)
817 struct d3d10_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
819 TRACE("iface %p, desc %p.\n", iface, desc);
824 static const struct ID3D10ShaderResourceViewVtbl d3d10_shader_resource_view_vtbl =
826 /* IUnknown methods */
827 d3d10_shader_resource_view_QueryInterface,
828 d3d10_shader_resource_view_AddRef,
829 d3d10_shader_resource_view_Release,
830 /* ID3D10DeviceChild methods */
831 d3d10_shader_resource_view_GetDevice,
832 d3d10_shader_resource_view_GetPrivateData,
833 d3d10_shader_resource_view_SetPrivateData,
834 d3d10_shader_resource_view_SetPrivateDataInterface,
835 /* ID3D10View methods */
836 d3d10_shader_resource_view_GetResource,
837 /* ID3D10ShaderResourceView methods */
838 d3d10_shader_resource_view_GetDesc,
841 HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view,
842 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc)
846 view->ID3D10ShaderResourceView_iface.lpVtbl = &d3d10_shader_resource_view_vtbl;
851 if (FAILED(hr = set_srdesc_from_resource(&view->desc, resource)))
859 view->resource = resource;
860 ID3D10Resource_AddRef(resource);