http://bugs.winehq.org/show_bug.cgi?id=10758
--- Comment #9 from Jim Cameron jim_24601@btinternet.com 2008-10-05 15:36:51 --- Created an attachment (id=16488) --> (http://bugs.winehq.org/attachment.cgi?id=16488) Keep D3D9 device's current depth-stencil surface from being deleted when its refcount goes to 0
Attached is a proof-of-concept patch that fixes the problem with Myst IV. I've added a private reference count to IDirect3DSurface9_Impl that is incremented when a surface is passed to SetDepthStencilSurface() and decremented when it is no longer required. Wine's Direct3D 9 tests pass with the patch.
I haven't included a test for this specific case, nor considered previous Direct3D interface versions or other surface types. The private reference count may also do strange things with implicit surfaces (the auto-depth-stencil buffer). We should look into all these things if we do adopt this approach.