Henri Verbeet : d3d10core: Implement d3d10_depthstencil_view_GetDesc().
Alexandre Julliard
julliard at winehq.org
Thu Sep 13 14:39:20 CDT 2012
Module: wine
Branch: master
Commit: 05d1fbb392c71b4fd81c30d58961a49f9242119c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=05d1fbb392c71b4fd81c30d58961a49f9242119c
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Sep 13 09:18:14 2012 +0200
d3d10core: Implement d3d10_depthstencil_view_GetDesc().
---
dlls/d3d10core/d3d10core_private.h | 3 +-
dlls/d3d10core/device.c | 2 +-
dlls/d3d10core/view.c | 115 +++++++++++++++++++++++++++++++++++-
3 files changed, 116 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index f45fd34..25fda7c 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -129,11 +129,12 @@ struct d3d10_depthstencil_view
ID3D10DepthStencilView ID3D10DepthStencilView_iface;
LONG refcount;
+ D3D10_DEPTH_STENCIL_VIEW_DESC desc;
ID3D10Resource *resource;
};
HRESULT d3d10_depthstencil_view_init(struct d3d10_depthstencil_view *view,
- ID3D10Resource *resource) DECLSPEC_HIDDEN;
+ ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc) DECLSPEC_HIDDEN;
/* ID3D10RenderTargetView */
struct d3d10_rendertarget_view
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index d184c02..e6c26c2 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -803,7 +803,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Devic
return E_OUTOFMEMORY;
}
- if (FAILED(hr = d3d10_depthstencil_view_init(object, resource)))
+ if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
{
WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
diff --git a/dlls/d3d10core/view.c b/dlls/d3d10core/view.c
index 9bf4fcb..40712fc 100644
--- a/dlls/d3d10core/view.c
+++ b/dlls/d3d10core/view.c
@@ -45,6 +45,101 @@ static struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *r
}
}
+static HRESULT set_dsdesc_from_resource(D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10Resource *resource)
+{
+ D3D10_RESOURCE_DIMENSION dimension;
+ HRESULT hr;
+
+ ID3D10Resource_GetType(resource, &dimension);
+
+ switch (dimension)
+ {
+ case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
+ {
+ D3D10_TEXTURE1D_DESC texture_desc;
+ ID3D10Texture1D *texture;
+
+ if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture)))
+ {
+ ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D.\n");
+ return E_INVALIDARG;
+ }
+
+ ID3D10Texture1D_GetDesc(texture, &texture_desc);
+ ID3D10Texture1D_Release(texture);
+
+ desc->Format = texture_desc.Format;
+ if (texture_desc.ArraySize == 1)
+ {
+ desc->ViewDimension = D3D10_DSV_DIMENSION_TEXTURE1D;
+ desc->u.Texture1D.MipSlice = 0;
+ }
+ else
+ {
+ desc->ViewDimension = D3D10_DSV_DIMENSION_TEXTURE1DARRAY;
+ desc->u.Texture1DArray.MipSlice = 0;
+ desc->u.Texture1DArray.FirstArraySlice = 0;
+ desc->u.Texture1DArray.ArraySize = 1;
+ }
+
+ return S_OK;
+ }
+
+ case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
+ {
+ D3D10_TEXTURE2D_DESC texture_desc;
+ ID3D10Texture2D *texture;
+
+ if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture)))
+ {
+ ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D.\n");
+ return E_INVALIDARG;
+ }
+
+ ID3D10Texture2D_GetDesc(texture, &texture_desc);
+ ID3D10Texture2D_Release(texture);
+
+ desc->Format = texture_desc.Format;
+ if (texture_desc.ArraySize == 1)
+ {
+ if (texture_desc.SampleDesc.Count == 1)
+ {
+ desc->ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;
+ desc->u.Texture2D.MipSlice = 0;
+ }
+ else
+ {
+ desc->ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2DMS;
+ }
+ }
+ else
+ {
+ if (texture_desc.SampleDesc.Count == 1)
+ {
+ desc->ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2DARRAY;
+ desc->u.Texture2DArray.MipSlice = 0;
+ desc->u.Texture2DArray.FirstArraySlice = 0;
+ desc->u.Texture2DArray.ArraySize = 1;
+ }
+ else
+ {
+ desc->ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY;
+ desc->u.Texture2DMSArray.FirstArraySlice = 0;
+ desc->u.Texture2DMSArray.ArraySize = 1;
+ }
+ }
+
+ return S_OK;
+ }
+
+ default:
+ FIXME("Unhandled resource dimension %#x.\n", dimension);
+ case D3D10_RESOURCE_DIMENSION_BUFFER:
+ case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
+ return E_INVALIDARG;
+ }
+}
+
static HRESULT set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
@@ -269,7 +364,11 @@ static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetResource(ID3D10DepthSte
static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetDesc(ID3D10DepthStencilView *iface,
D3D10_DEPTH_STENCIL_VIEW_DESC *desc)
{
- FIXME("iface %p, desc %p stub!\n", iface, desc);
+ struct d3d10_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
+
+ TRACE("iface %p, desc %p.\n", iface, desc);
+
+ *desc = view->desc;
}
static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl =
@@ -290,11 +389,23 @@ static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl =
};
HRESULT d3d10_depthstencil_view_init(struct d3d10_depthstencil_view *view,
- ID3D10Resource *resource)
+ ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc)
{
+ HRESULT hr;
+
view->ID3D10DepthStencilView_iface.lpVtbl = &d3d10_depthstencil_view_vtbl;
view->refcount = 1;
+ if (!desc)
+ {
+ if (FAILED(hr = set_dsdesc_from_resource(&view->desc, resource)))
+ return hr;
+ }
+ else
+ {
+ view->desc = *desc;
+ }
+
view->resource = resource;
ID3D10Resource_AddRef(resource);
More information about the wine-cvs
mailing list