D3D7 -> WineD3D, 2nd attempt

Oliver Stieber oliver_stieber at yahoo.co.uk
Wed Oct 12 08:12:09 CDT 2005

--- Stefan Dösinger <stefandoesinger at gmx.at> wrote:

> Hello,

> I am trying again to Implement Direct3D 7 using WineD3D, and I've made some 
> progress. The D3D7 Device implementation seems to initialize correctly, with 
> the correct surfaces.

> My solution looks like this:
> * DirectDraw is unmodified, and it remains in ddraw.dll.
> * Direct3D7 uses generally the Direct3D9 interface of WineD3D. The only 
> changes made to WineD3D are in WineD3DDeviceImpl_Release and a little change 
> in WineD3DSurface.

> * WineD3D Surfaces can be attached to DDraw Surfaces, and they receive the 
> properties of their parents, including the memory reserved for the surface
> * The D3D7 implementation creates a SwapChain and a RenderTarget from the 
> DirectDrawSurface it's attached to, as well as a DepthStencil WineD3D surface 
> to make WineD3D happy

> I've made the following changes to WineD3D so far:
> * Make WineD3D handle dxVersion 7, generally with the same code as with 
> dxVersion 7
> * A new parameter to WineD3DDevice_Create: a pointer, which specifies an 
> existing surface memory. If != NULL is passed, no memory is reserved by 
> WineD3D, and it's not Released on WineD3DSurface_Release

Wined3d need to be able to interact with the HAL a bit better, so that things like fullscreen mode
in x11drv work for wined3d as well as ddraw.

> * When releasing the WineD3DDevice, don't release the parents of the 
> RenderTarget, the DepthStencilBuffer, BackBuffer and FrontBuffer, because 
> ddraw.dll needs it's surfaces. Instead, release the WineD3DSurfaces only.

This should be managed by reference counting wherever possible, if ddraw holds a reference to the
surface then it won't be released when the device is released.

> I've got the light test running successfully, but I have a problem and need 
> your advice:
> WineD3D can't create a device without a Window. For DirectDraw and D3D7 
> running without a Window is valid, at least to a certain extent. The D3D 
> light test does so, and some games use this for some purposes. So I need to 
> do something for the case HWND == 0 or the d3d surface is not a primary 
> surface.
> * Modifiy WineD3D to work without a window. I don't really like this solution.
> * Create a hidden window to pass to WineD3D. Such a thing seems to be in 
> DirectDraw allready, at least there's a WNDCLASS member in IDirectDrawImpl, 
> but it's always 0.

Some work needs to be done to get child and MDI windows working with wined3d, one of the
possibilities would be to render to offscreen surfaces and then do a clipped blit of the results
to the MDI/Child windows. Something similar could be setup so that a device can be created without
a window.

> Does DirectDraw create a internal window somewhere? Is this a useable way to 
> go, or should I try to modify WineD3D for this purpose?

It doesn't look like it, the only CreateWindow in ddraw is in surface_user.c when OWN_WINDOW is
set, the comments note that OWN_WINDOW no longer works because of threading issues.

> Stefan
> (I CCed this mail to Olivier because WineD3D is heavily involved here.)

Get My Web - a better way to save web pages 

More information about the wine-devel mailing list