Commit 91e4ec57 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Add a wined3d rendertarget view to the d3d10 rendertarget view.

parent c796f764
......@@ -85,7 +85,7 @@ struct d3d10_rendertarget_view
const struct ID3D10RenderTargetViewVtbl *vtbl;
LONG refcount;
ID3D10Resource *resource;
IWineD3DRendertargetView *wined3d_view;
D3D10_RENDER_TARGET_VIEW_DESC desc;
};
......
......@@ -689,6 +689,26 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Dev
return E_NOTIMPL;
}
static IWineD3DResource *d3d10_device_wined3d_resource_from_resource(ID3D10Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
ID3D10Resource_GetType(resource, &dimension);
switch(dimension)
{
case D3D10_RESOURCE_DIMENSION_BUFFER:
return (IWineD3DResource *)((struct d3d10_buffer *)resource)->wined3d_buffer;
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
return (IWineD3DResource *)((struct d3d10_texture2d *)resource)->wined3d_surface;
default:
FIXME("Unhandled resource dimension %#x\n", dimension);
return NULL;
}
}
static HRESULT d3d10_device_set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
......@@ -811,7 +831,9 @@ static HRESULT d3d10_device_set_rtdesc_from_resource(D3D10_RENDER_TARGET_VIEW_DE
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
struct d3d10_rendertarget_view *object;
IWineD3DResource *wined3d_resource;
TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
......@@ -839,8 +861,15 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Devic
object->desc = *desc;
}
object->resource = resource;
ID3D10Resource_AddRef(resource);
wined3d_resource = d3d10_device_wined3d_resource_from_resource(resource);
if (!wined3d_resource)
{
FIXME("Failed to get wined3d resource for d3d10 resource %p\n", resource);
HeapFree(GetProcessHeap(), 0, object);
return E_FAIL;
}
IWineD3DDevice_CreateRendertargetView(This->wined3d_device,
wined3d_resource, (IUnknown *)object, &object->wined3d_view);
*view = (ID3D10RenderTargetView *)object;
......
......@@ -66,7 +66,7 @@ static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTarge
if (!refcount)
{
ID3D10Resource_Release(This->resource);
IWineD3DRendertargetView_Release(This->wined3d_view);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -112,11 +112,37 @@ static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTa
ID3D10Resource **resource)
{
struct d3d10_rendertarget_view *This = (struct d3d10_rendertarget_view *)iface;
IWineD3DResource *wined3d_resource;
IUnknown *parent;
HRESULT hr;
TRACE("iface %p, resource %p\n", iface, resource);
ID3D10Resource_AddRef(This->resource);
*resource = This->resource;
hr = IWineD3DRendertargetView_GetResource(This->wined3d_view, &wined3d_resource);
if (FAILED(hr))
{
ERR("Failed to get wined3d resource, hr %#x\n", hr);
*resource = NULL;
return;
}
hr = IWineD3DResource_GetParent(wined3d_resource, &parent);
IWineD3DResource_Release(wined3d_resource);
if (FAILED(hr))
{
ERR("Failed to get wined3d resource parent, hr %#x\n", hr);
*resource = NULL;
return;
}
hr = IUnknown_QueryInterface(parent, &IID_ID3D10Resource, (void **)&resource);
IUnknown_Release(parent);
if (FAILED(hr))
{
ERR("Resource parent isn't a d3d10 resource, hr %#x\n", hr);
*resource = NULL;
return;
}
}
/* ID3D10RenderTargetView methods */
......
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