d3d11: Implement d3d11_rendertarget_view_GetResource().

This commit is contained in:
Józef Kucia 2015-09-09 01:35:43 +02:00 committed by Alexandre Julliard
parent b5b5b381f4
commit 99bb367d52
3 changed files with 35 additions and 20 deletions

View File

@ -180,12 +180,12 @@ struct d3d_rendertarget_view
struct wined3d_private_store private_store;
struct wined3d_rendertarget_view *wined3d_view;
D3D10_RENDER_TARGET_VIEW_DESC desc;
ID3D10Resource *resource;
ID3D11Resource *resource;
ID3D10Device1 *device;
};
HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device,
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc) DECLSPEC_HIDDEN;
ID3D11Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc) DECLSPEC_HIDDEN;
struct d3d_rendertarget_view *unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface) DECLSPEC_HIDDEN;
/* ID3D10ShaderResourceView */

View File

@ -2123,6 +2123,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Devic
{
struct d3d_device *device = impl_from_ID3D10Device(iface);
struct d3d_rendertarget_view *object;
ID3D11Resource *d3d11_resource;
HRESULT hr;
TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
@ -2130,13 +2131,23 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Devic
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d_rendertarget_view_init(object, device, resource, desc)))
if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
{
ERR("Resource does not implement ID3D11Resource.\n");
HeapFree(GetProcessHeap(), 0, object);
return E_FAIL;
}
if (FAILED(hr = d3d_rendertarget_view_init(object, device, d3d11_resource, desc)))
{
WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
ID3D11Resource_Release(d3d11_resource);
return hr;
}
ID3D11Resource_Release(d3d11_resource);
TRACE("Created rendertarget view %p.\n", object);
*view = &object->ID3D10RenderTargetView_iface;

View File

@ -121,21 +121,21 @@ static HRESULT set_dsdesc_from_resource(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3
}
}
static HRESULT set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10Resource *resource)
static HRESULT set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
D3D11_RESOURCE_DIMENSION dimension;
HRESULT hr;
ID3D10Resource_GetType(resource, &dimension);
ID3D11Resource_GetType(resource, &dimension);
switch(dimension)
{
case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
{
ID3D10Texture1D *texture;
D3D10_TEXTURE1D_DESC texture_desc;
hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture);
hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture);
if (FAILED(hr))
{
ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D?\n");
@ -162,12 +162,12 @@ static HRESULT set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3
return S_OK;
}
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
ID3D10Texture2D *texture;
D3D10_TEXTURE2D_DESC texture_desc;
hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture);
hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture);
if (FAILED(hr))
{
ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D?\n");
@ -210,12 +210,12 @@ static HRESULT set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3
return S_OK;
}
case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
{
ID3D10Texture3D *texture;
D3D10_TEXTURE3D_DESC texture_desc;
hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture);
hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture);
if (FAILED(hr))
{
ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D?\n");
@ -826,7 +826,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_Release(ID3D11RenderTarge
{
wined3d_mutex_lock();
wined3d_rendertarget_view_decref(view->wined3d_view);
ID3D10Resource_Release(view->resource);
ID3D11Resource_Release(view->resource);
ID3D10Device1_Release(view->device);
wined3d_private_store_cleanup(&view->private_store);
wined3d_mutex_unlock();
@ -875,7 +875,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_rendertarget_view_SetPrivateDataInterface
static void STDMETHODCALLTYPE d3d11_rendertarget_view_GetResource(ID3D11RenderTargetView *iface,
ID3D11Resource **resource)
{
FIXME("iface %p, resource %p stub!\n", iface, resource);
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
TRACE("iface %p, resource %p.\n", iface, resource);
*resource = view->resource;
ID3D11Resource_AddRef(*resource);
}
static void STDMETHODCALLTYPE d3d11_rendertarget_view_GetDesc(ID3D11RenderTargetView *iface,
@ -991,8 +996,7 @@ static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTa
TRACE("iface %p, resource %p\n", iface, resource);
*resource = view->resource;
ID3D10Resource_AddRef(*resource);
ID3D11Resource_QueryInterface(view->resource, &IID_ID3D10Resource, (void **)resource);
}
/* ID3D10RenderTargetView methods */
@ -1088,7 +1092,7 @@ static void wined3d_rendertarget_view_desc_from_d3d10core(struct wined3d_rendert
}
HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device,
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc)
ID3D11Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc)
{
struct wined3d_rendertarget_view_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
@ -1109,10 +1113,10 @@ HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3
}
wined3d_mutex_lock();
if (!(wined3d_resource = wined3d_resource_from_d3d10_resource(resource)))
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
{
wined3d_mutex_unlock();
ERR("Failed to get wined3d resource for d3d10 resource %p.\n", resource);
ERR("Failed to get wined3d resource for d3d11 resource %p.\n", resource);
return E_FAIL;
}
@ -1128,7 +1132,7 @@ HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3
wined3d_private_store_init(&view->private_store);
wined3d_mutex_unlock();
view->resource = resource;
ID3D10Resource_AddRef(resource);
ID3D11Resource_AddRef(resource);
view->device = &device->ID3D10Device1_iface;
ID3D10Device1_AddRef(view->device);