d3d10core: Handle a NULL view desc in CreateRenderTargetView().
This commit is contained in:
parent
9c1abc908a
commit
2953d81463
|
@ -79,6 +79,7 @@ struct d3d10_rendertarget_view
|
||||||
LONG refcount;
|
LONG refcount;
|
||||||
|
|
||||||
ID3D10Resource *resource;
|
ID3D10Resource *resource;
|
||||||
|
D3D10_RENDER_TARGET_VIEW_DESC desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Layered device */
|
/* Layered device */
|
||||||
|
|
|
@ -670,6 +670,125 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Dev
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT d3d10_device_set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10Resource *resource)
|
||||||
|
{
|
||||||
|
D3D10_RESOURCE_DIMENSION dimension;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
ID3D10Resource_GetType(resource, &dimension);
|
||||||
|
|
||||||
|
switch(dimension)
|
||||||
|
{
|
||||||
|
case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
|
||||||
|
{
|
||||||
|
ID3D10Texture1D *texture;
|
||||||
|
D3D10_TEXTURE1D_DESC texture_desc;
|
||||||
|
|
||||||
|
hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
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_RTV_DIMENSION_TEXTURE1D;
|
||||||
|
desc->Texture1D.MipSlice = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE1DARRAY;
|
||||||
|
desc->Texture1DArray.MipSlice = 0;
|
||||||
|
desc->Texture1DArray.FirstArraySlice = 0;
|
||||||
|
desc->Texture1DArray.ArraySize = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
|
||||||
|
{
|
||||||
|
ID3D10Texture2D *texture;
|
||||||
|
D3D10_TEXTURE2D_DESC texture_desc;
|
||||||
|
|
||||||
|
hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
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_RTV_DIMENSION_TEXTURE2D;
|
||||||
|
desc->Texture2D.MipSlice = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (texture_desc.SampleDesc.Count == 1)
|
||||||
|
{
|
||||||
|
desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DARRAY;
|
||||||
|
desc->Texture2DArray.MipSlice = 0;
|
||||||
|
desc->Texture2DArray.FirstArraySlice = 0;
|
||||||
|
desc->Texture2DArray.ArraySize = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
||||||
|
desc->Texture2DMSArray.FirstArraySlice = 0;
|
||||||
|
desc->Texture2DMSArray.ArraySize = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
|
||||||
|
{
|
||||||
|
ID3D10Texture3D *texture;
|
||||||
|
D3D10_TEXTURE3D_DESC texture_desc;
|
||||||
|
|
||||||
|
hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D?\n");
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D10Texture3D_GetDesc(texture, &texture_desc);
|
||||||
|
ID3D10Texture3D_Release(texture);
|
||||||
|
|
||||||
|
desc->Format = texture_desc.Format;
|
||||||
|
desc->ViewDimension = D3D10_RTV_DIMENSION_TEXTURE3D;
|
||||||
|
desc->Texture3D.MipSlice = 0;
|
||||||
|
desc->Texture3D.FirstWSlice = 0;
|
||||||
|
desc->Texture3D.WSize = 1;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
FIXME("Unhandled resource dimension %#x\n", dimension);
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
|
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
|
||||||
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
|
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
|
||||||
{
|
{
|
||||||
|
@ -686,6 +805,21 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Devic
|
||||||
|
|
||||||
object->vtbl = &d3d10_rendertarget_view_vtbl;
|
object->vtbl = &d3d10_rendertarget_view_vtbl;
|
||||||
object->refcount = 1;
|
object->refcount = 1;
|
||||||
|
|
||||||
|
if (!desc)
|
||||||
|
{
|
||||||
|
HRESULT hr = d3d10_device_set_rtdesc_from_resource(&object->desc, resource);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
object->desc = *desc;
|
||||||
|
}
|
||||||
|
|
||||||
object->resource = resource;
|
object->resource = resource;
|
||||||
ID3D10Resource_AddRef(resource);
|
ID3D10Resource_AddRef(resource);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,11 @@ static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTa
|
||||||
static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView* iface,
|
static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView* iface,
|
||||||
D3D10_RENDER_TARGET_VIEW_DESC *desc)
|
D3D10_RENDER_TARGET_VIEW_DESC *desc)
|
||||||
{
|
{
|
||||||
FIXME("iface %p, desc %p stub!\n", iface, desc);
|
struct d3d10_rendertarget_view *This = (struct d3d10_rendertarget_view *)iface;
|
||||||
|
|
||||||
|
TRACE("iface %p, desc %p\n", iface, desc);
|
||||||
|
|
||||||
|
*desc = This->desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
|
const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
|
||||||
|
|
Loading…
Reference in New Issue