DIB Engine
Wine requires a DIB engine (part of the display subsystem that, when pointed at screen memory, can serve as a flat-frame-buffer display driver) to properly handle Device Independent Bitmaps (DIBs). In the Win32 API, an application can draw in a DIB via GDI calls or via direct memory access without any synchronization calls in between.
This implies a rather tight coupling of the graphics subsystem with the system memory, which is simply not present in a network transparent design such as X. This is a leftover of the Win16 API, I guess it seemed like a good idea at the time.
To emulate such behavior, we have to play memory tricks (by protecting the DIB memory) and switch between a 'GDI mode' and 'memory mode'. On each of these transitions, we have to copy the DIB to/from the X server. It works, but it is slow, especially over the network.
To fix this problem, we have to be able to emulate the GDI calls in software. This is what the DIB Engine is -- software rendering for the GDI calls.
Software rendering exists -- in fact, we are currently using the X server exactly for that: we copy the DIB to the server, translate the GDI call to an X request, and then we copy the result back. So the code exists, but it is in the X server. We need to copy it over to Wine, clean it up (the X code is not known for its neatness), and integrate it properly (from an architectural perspective) into Wine.
Note: The difficulty in this task is more integration with the current Wine codebase in an incremental and non-intrusive manner. Wine needs infrastructure for the DIB engine so that graphics operations without DIB support can fall back to X11.
A patch that dumps an entire DIB engine somewhere in the Wine tree is unlikely to be accepted (that has already happened!). It needs to be added in an incremental manner, without breaking working functionality.
Discussions
Previous discussions:
GDI engine contributed by the TransGaming folks (wine-patches, Sept 2002)
Jesse Allen: "SOC: Integrate DIB Engine" (wine-devel, Apr 2006)
"Updates on The Big Tickets: Quartz, WineD3D, iPod Support, DIB Engine" (WWN, Oct 2008)
Discussions about Massimo Del Fedele's first attempt (merging Jesse's and Huw's):
"DIB Engine - Patchset separated by original author" (wine-devel, Feb 2009) (more)
"DIB Engine - Separated in small patches" (wine-devel, Feb 2009)
Discussions about Massimo Del Fedele's second attempt:
"The DIB engine... does anyone know how to get it into Wine?" (wine-devel, Apr 2009) (more)
"DIB Engine : Almost 100% working" (wine-devel, May 2009) (more)
"DIB Engine - first set of fixings agains wine test suite" (wine-devel, May 2009)
"DIB Engine - Mostly fixed against test suite" (wine-devel, May 2009)
"DIB Engine : passing all tests" (wine-devel, May 2009) (more)
"A Working DIB Engine" and "The future of Max's DIB Engine" (WWN, May 2009)
Summary of Bug Page 421
- There is an environment variable, WINEDIB, which can be set with "export WINEDIB=ON". This must be done in the terminal before any applications needing the DIB engine are run.
To permanently enable it, use regedit. In "HKEY_CURRENT_USER\Software\Wine\DIB Engine" create a string named "Enabled" with value "Y" (see also comment 99 of bug 421).
Building Wine with the DIB Engine
Grab a copy of Wine's source, either from git or from a tarball (extract it into some directory).
Get the latest copy of the DIB Engine from bug 421. Look at the list of attachments (there are a lot) for the latest DIB engine patches. Extract the archive, and put the patches somewhere.
- 'cd' to the Wine source code and run 'rm -rf dlls/winedib.drv' to remove any old DIB engine stuff. If using git, be sure to run 'git checkout -f' as well as cleanup your git tree.
- Patch your source code. In the root directory, use 'patch -p1 /path/to/patch' for each patch, successively. Currently, there are 10 patches, but there may be more in later versions of the DIB engine.
- Run 'autoconf' to make a new configure file.
Finally, build Wine: './configure && make depend && make'.
- Optionally, install Wine with 'sudo make install'.
- You can then use 'WINEDIB=ON wine program.exe' to run your program with the DIB engine enabled. Now you can run 'export WINEDIB=ON' in the terminal to enable it for all commands executed in that terminal, or edit the registry, as described above.
See also
