d3d9: Get rid of the implicit swapchain refcounting hacks.
This commit is contained in:
parent
4e56a4fe79
commit
3c07f7a68e
@ -222,9 +222,6 @@ typedef struct IDirect3DSwapChain9Impl
|
|||||||
|
|
||||||
/* Parent reference */
|
/* Parent reference */
|
||||||
LPDIRECT3DDEVICE9EX parentDevice;
|
LPDIRECT3DDEVICE9EX parentDevice;
|
||||||
|
|
||||||
/* Flags an implicit swap chain */
|
|
||||||
BOOL isImplicit;
|
|
||||||
} IDirect3DSwapChain9Impl;
|
} IDirect3DSwapChain9Impl;
|
||||||
|
|
||||||
HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl *device,
|
HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl *device,
|
||||||
|
@ -183,14 +183,9 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U
|
|||||||
|
|
||||||
static ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
|
static ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain9Impl *parent;
|
|
||||||
|
|
||||||
TRACE("swapchain %p.\n", swapchain);
|
TRACE("swapchain %p.\n", swapchain);
|
||||||
|
|
||||||
parent = IWineD3DSwapChain_GetParent(swapchain);
|
return IWineD3DSwapChain_Release(swapchain);
|
||||||
parent->isImplicit = FALSE;
|
|
||||||
IDirect3DSwapChain9_AddRef((IDirect3DSwapChain9 *)parent);
|
|
||||||
return IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IDirect3D IUnknown parts follow: */
|
/* IDirect3D IUnknown parts follow: */
|
||||||
@ -3174,8 +3169,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
|
|||||||
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
|
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
|
||||||
{
|
{
|
||||||
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
||||||
IDirect3DSwapChain9Impl *d3d_swapchain;
|
|
||||||
D3DPRESENT_PARAMETERS local_parameters;
|
D3DPRESENT_PARAMETERS local_parameters;
|
||||||
|
IDirect3DSwapChain9 *d3d_swapchain;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
|
TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
|
||||||
@ -3197,7 +3192,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
|
|||||||
local_parameters.PresentationInterval = present_parameters->PresentationInterval;
|
local_parameters.PresentationInterval = present_parameters->PresentationInterval;
|
||||||
|
|
||||||
hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
|
hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
|
||||||
&local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
|
&local_parameters, &d3d_swapchain);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
|
ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
|
||||||
@ -3205,9 +3200,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*swapchain = d3d_swapchain->wineD3DSwapChain;
|
*swapchain = ((IDirect3DSwapChain9Impl *)d3d_swapchain)->wineD3DSwapChain;
|
||||||
d3d_swapchain->isImplicit = TRUE;
|
IWineD3DSwapChain_AddRef(*swapchain);
|
||||||
/* Implicit swap chains are created with an refcount of 0 */
|
|
||||||
IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
|
IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
|
||||||
|
|
||||||
/* Copy back the presentation parameters */
|
/* Copy back the presentation parameters */
|
||||||
|
@ -55,13 +55,10 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface) {
|
|||||||
if (This->parentDevice)
|
if (This->parentDevice)
|
||||||
IDirect3DDevice9Ex_AddRef(This->parentDevice);
|
IDirect3DDevice9Ex_AddRef(This->parentDevice);
|
||||||
|
|
||||||
if (!This->isImplicit)
|
|
||||||
{
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
IWineD3DSwapChain_AddRef(This->wineD3DSwapChain);
|
IWineD3DSwapChain_AddRef(This->wineD3DSwapChain);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
@ -75,11 +72,9 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface)
|
|||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
|
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
|
||||||
|
|
||||||
if (!This->isImplicit) {
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain);
|
IWineD3DSwapChain_Release(This->wineD3DSwapChain);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the device last, as it may cause the device to be destroyed. */
|
/* Release the device last, as it may cause the device to be destroyed. */
|
||||||
if (parentDevice) IDirect3DDevice9Ex_Release(parentDevice);
|
if (parentDevice) IDirect3DDevice9Ex_Release(parentDevice);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user