http://bugs.winehq.org/show_bug.cgi?id=10758
--- Comment #8 from Jim Cameron jim_24601@btinternet.com 2008-10-05 11:00:02 --- I've now been able to get onto a Windows machine with Direct3D 9 and done some testing. My findings:
1. IDirect3DDevice9::SetDepthStencilSurface() does not increment the reference count for the IDirect3DSurface9. 2. Releasing a IDirect3DSurface9 does not delete the surface if it is the current depth-stencil surface, even if its reference count goes to zero. 3. IDirect3DDevice9::Reset() fails with a D3DERR_INVALIDCALL if an external reference exists to the current depth-stencil surface. 4. IDirect3DDevice9::Reset() succeeds if no external references exist to the current depth-stencil surface. In this case, the surface is deleted. 5. A user-supplied depth-stencil surface whose reference count is zero will be deleted if a new surface, or NULL surface, is selected into the device using IDirect3DDevice9::SetDepthStencilSurface(). The auto-depth-stencil surface will not be deleted in the equivalent case.
The Wine bug is with number 2. Wine will not delete the auto-depth-stencil surface if its refcount goes to zero because it is marked as implicit. But it will happily delete a user-supplied depth-stencil surface when its refcount goes to zero even if it is currently selected in a device.