Commit 05d1fbb3 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Implement d3d10_depthstencil_view_GetDesc().

parent 3fa6bd0c
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment