d3d10core: Keep a reference to the wined3d device in the d3d10 device.

This commit is contained in:
Henri Verbeet 2009-02-23 09:16:01 +01:00 committed by Alexandre Julliard
parent 4fe8415070
commit 0048a0373b
7 changed files with 43 additions and 7 deletions

View File

@ -52,6 +52,8 @@ struct d3d10_device
const struct IWineD3DDeviceParentVtbl *device_parent_vtbl;
IUnknown *outer_unknown;
LONG refcount;
IWineD3DDevice *wined3d_device;
};
/* ID3D10Texture2D */

View File

@ -75,6 +75,8 @@ static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (This->wined3d_device) IWineD3DDevice_Release(This->wined3d_device);
return refcount;
}
@ -590,6 +592,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *ifac
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture2D **texture)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
struct d3d10_texture2d *object;
HRESULT hr;
@ -608,7 +611,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
if (desc->MipLevels == 1 && desc->ArraySize == 1)
{
IWineD3DDevice *wined3d_device;
IWineDXGIDevice *wine_device;
hr = ID3D10Device_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
@ -621,24 +623,20 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
hr = IWineDXGIDevice_create_surface(wine_device, NULL, 0, NULL,
(IUnknown *)object, (void **)&object->dxgi_surface);
IWineDXGIDevice_Release(wine_device);
if (FAILED(hr))
{
ERR("Failed to create DXGI surface, returning %#x\n", hr);
HeapFree(GetProcessHeap(), 0, object);
IWineDXGIDevice_Release(wine_device);
return hr;
}
wined3d_device = IWineDXGIDevice_get_wined3d_device(wine_device);
IWineDXGIDevice_Release(wine_device);
FIXME("Implement DXGI<->wined3d usage conversion\n");
hr = IWineD3DDevice_CreateSurface(wined3d_device, desc->Width, desc->Height,
hr = IWineD3DDevice_CreateSurface(This->wined3d_device, desc->Width, desc->Height,
wined3dformat_from_dxgi_format(desc->Format), FALSE, FALSE, 0,
&object->wined3d_surface, WINED3DRTYPE_SURFACE, desc->Usage, WINED3DPOOL_DEFAULT,
desc->SampleDesc.Count, desc->SampleDesc.Quality, NULL, SURFACE_OPENGL, (IUnknown *)object);
IWineD3DDevice_Release(wined3d_device);
if (FAILED(hr))
{
ERR("CreateSurface failed, returning %#x\n", hr);
@ -1144,6 +1142,16 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
/* IWineD3DDeviceParent methods */
static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
{
struct d3d10_device *This = device_from_device_parent(iface);
TRACE("iface %p, device %p\n", iface, device);
IWineD3DDevice_AddRef(device);
This->wined3d_device = device;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@ -1287,6 +1295,7 @@ const struct IWineD3DDeviceParentVtbl d3d10_wined3d_device_parent_vtbl =
device_parent_AddRef,
device_parent_Release,
/* IWineD3DDeviceParent methods */
device_parent_WineD3DDeviceCreated,
device_parent_CreateSurface,
device_parent_CreateRenderTarget,
device_parent_CreateDepthStencilSurface,

View File

@ -2394,6 +2394,11 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
/* IWineD3DDeviceParent methods */
static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
{
TRACE("iface %p, device %p\n", iface, device);
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@ -2591,6 +2596,7 @@ const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl =
device_parent_AddRef,
device_parent_Release,
/* IWineD3DDeviceParent methods */
device_parent_WineD3DDeviceCreated,
device_parent_CreateSurface,
device_parent_CreateRenderTarget,
device_parent_CreateDepthStencilSurface,

View File

@ -1929,6 +1929,11 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
/* IWineD3DDeviceParent methods */
static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
{
TRACE("iface %p, device %p\n", iface, device);
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@ -2130,6 +2135,7 @@ const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl =
device_parent_AddRef,
device_parent_Release,
/* IWineD3DDeviceParent methods */
device_parent_WineD3DDeviceCreated,
device_parent_CreateSurface,
device_parent_CreateRenderTarget,
device_parent_CreateDepthStencilSurface,

View File

@ -3409,6 +3409,11 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
/* IWineD3DDeviceParent methods */
static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
{
TRACE("iface %p, device %p\n", iface, device);
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@ -3624,6 +3629,7 @@ const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl =
device_parent_AddRef,
device_parent_Release,
/* IWineD3DDeviceParent methods */
device_parent_WineD3DDeviceCreated,
device_parent_CreateSurface,
device_parent_CreateRenderTarget,
device_parent_CreateDepthStencilSurface,

View File

@ -3722,6 +3722,9 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
for(i = 0; i < PATCHMAP_SIZE; i++) {
list_init(&object->patches[i]);
}
IWineD3DDeviceParent_WineD3DDeviceCreated(device_parent, *ppReturnedDeviceInterface);
return WINED3D_OK;
}
#undef GLINFO_LOCATION

View File

@ -2188,6 +2188,10 @@ interface IWineD3DDevice;
]
interface IWineD3DDeviceParent : IUnknown
{
void WineD3DDeviceCreated(
[in] IWineD3DDevice *device
);
HRESULT CreateSurface(
[in] IUnknown *superior,
[in] UINT width,