DIBEngine

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:

Discussions about Massimo Del Fedele's first attempt (merging Jesse's and Huw's):

Discussions about Massimo Del Fedele's second attempt:

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

  1. Grab a copy of Wine's source, either from git or from a tarball (extract it into some directory).

  2. 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.

  3. '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.
  4. 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.
  5. Run 'autoconf' to make a new configure file.
  6. Finally, build Wine: './configure && make depend && make'.

  7. Optionally, install Wine with 'sudo make install'.
  8. 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


DIBEngine (last edited 2009-05-30 21:49:23 by AlexanderScottJohns)