d3d8: Release non implicit surfaces only if refcount is 0, with test.

This commit is contained in:
Markus Amsler 2006-12-14 01:55:48 +01:00 committed by Alexandre Julliard
parent 1adf857afc
commit 5dbd834ca0
2 changed files with 10 additions and 5 deletions

View File

@ -72,11 +72,13 @@ static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref); TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0 && This->parentDevice) IUnknown_Release(This->parentDevice); if (ref == 0) {
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */ if (This->parentDevice) IUnknown_Release(This->parentDevice);
if (ref >= 0 && !This->isImplicit) { /* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
IWineD3DSurface_Release(This->wineD3DSurface); if (!This->isImplicit) {
HeapFree(GetProcessHeap(), 0, This); IWineD3DSurface_Release(This->wineD3DSurface);
HeapFree(GetProcessHeap(), 0, This);
}
} }
return ref; return ref;

View File

@ -476,10 +476,13 @@ static void test_refcount(void)
/* Surfaces */ /* Surfaces */
hr = IDirect3DDevice8_CreateDepthStencilSurface( pDevice, 32, 32, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &pStencilSurface ); hr = IDirect3DDevice8_CreateDepthStencilSurface( pDevice, 32, 32, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &pStencilSurface );
CHECK_CALL( hr, "CreateDepthStencilSurface", pDevice, ++refcount ); CHECK_CALL( hr, "CreateDepthStencilSurface", pDevice, ++refcount );
CHECK_REFCOUNT( pStencilSurface, 1);
hr = IDirect3DDevice8_CreateImageSurface( pDevice, 32, 32, D3DFMT_X8R8G8B8, &pImageSurface ); hr = IDirect3DDevice8_CreateImageSurface( pDevice, 32, 32, D3DFMT_X8R8G8B8, &pImageSurface );
CHECK_CALL( hr, "CreateImageSurface", pDevice, ++refcount ); CHECK_CALL( hr, "CreateImageSurface", pDevice, ++refcount );
CHECK_REFCOUNT( pImageSurface, 1);
hr = IDirect3DDevice8_CreateRenderTarget( pDevice, 32, 32, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, TRUE, &pRenderTarget3 ); hr = IDirect3DDevice8_CreateRenderTarget( pDevice, 32, 32, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, TRUE, &pRenderTarget3 );
CHECK_CALL( hr, "CreateRenderTarget", pDevice, ++refcount ); CHECK_CALL( hr, "CreateRenderTarget", pDevice, ++refcount );
CHECK_REFCOUNT( pRenderTarget3, 1);
/* Misc */ /* Misc */
hr = IDirect3DDevice8_CreateStateBlock( pDevice, D3DSBT_ALL, &dStateBlock ); hr = IDirect3DDevice8_CreateStateBlock( pDevice, D3DSBT_ALL, &dStateBlock );
CHECK_CALL( hr, "CreateStateBlock", pDevice, refcount ); CHECK_CALL( hr, "CreateStateBlock", pDevice, refcount );